vsg 1.1.3
VulkanSceneGraph library
Loading...
Searching...
No Matches
Bin.h
1#pragma once
2
3/* <editor-fold desc="MIT License">
4
5Copyright(c) 2018 Robert Osfield
6
7Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
8
9The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
10
11THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
12
13</editor-fold> */
14
15#include <vsg/maths/sphere.h>
16#include <vsg/nodes/Node.h>
17
18namespace vsg
19{
20
23 class VSG_DECLSPEC Bin : public Inherit<Node, Bin>
24 {
25 public:
26 enum SortOrder
27 {
28 NO_SORT,
29 ASCENDING,
30 DESCENDING
31 };
32
33 Bin();
34 Bin(const Bin& rhs, const CopyOp& copyop = {});
35 Bin(int32_t in_binNumber, SortOrder in_sortOrder);
36
37 int32_t binNumber = 0;
38 SortOrder sortOrder = NO_SORT;
39
40 void clear();
41
42 void add(State* state, double value, const Node* node);
43
44 public:
45 ref_ptr<Object> clone(const CopyOp& copyop = {}) const override { return Bin::create(*this, copyop); }
46 int compare(const Object& rhs) const override;
47
48 void traverse(RecordTraversal& visitor) const override;
49
50 void read(Input& input) override;
51 void write(Output& output) const override;
52
53 protected:
54 virtual ~Bin();
55
56 std::vector<dmat4> _matrices;
57 std::vector<const StateCommand*> _stateCommands;
58
59 struct Element
60 {
61 uint32_t matrixIndex = 0;
62 uint32_t stateCommandIndex = 0;
63 uint32_t stateCommandCount = 0;
64 const Node* child = nullptr;
65 };
66
67 std::vector<Element> _elements;
68
69 using KeyIndex = std::pair<float, uint32_t>;
70 mutable std::vector<KeyIndex> _binElements;
71 };
72 VSG_type_name(vsg::Bin);
73
74} // namespace vsg
Definition Bin.h:24
int compare(const Object &rhs) const override
compare two objects, return -1 if this object is less than rhs, return 0 if it's equal,...
ref_ptr< Object > clone(const CopyOp &copyop={}) const override
Definition Bin.h:45
Definition Object.h:42
Definition Inherit.h:28
Definition Input.h:44
Definition Node.h:24
Definition Object.h:60
Definition Output.h:41
RecordTraversal traverses a scene graph doing view frustum culling and invoking state/commands to rec...
Definition RecordTraversal.h:69
vsg::State is used by vsg::RecordTraversal to manage state stacks, projection and modelview matrices ...
Definition State.h:228
Definition ref_ptr.h:22
Definition Bin.h:60