vsg  1.1.0
VulkanSceneGraph library
Bin.h
1 #pragma once
2 
3 /* <editor-fold desc="MIT License">
4 
5 Copyright(c) 2018 Robert Osfield
6 
7 Permission 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 
9 The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
10 
11 THE 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 
18 namespace 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(int32_t in_binNumber, SortOrder in_sortOrder);
35 
36  void traverse(RecordTraversal& visitor) const override;
37 
38  void read(Input& input) override;
39  void write(Output& output) const override;
40 
41  void clear();
42 
43  void add(State* state, double value, const Node* node);
44 
45  int32_t binNumber = 0;
46  SortOrder sortOrder = NO_SORT;
47 
48  protected:
49  virtual ~Bin();
50 
51  std::vector<dmat4> _matrices;
52  std::vector<const StateCommand*> _stateCommands;
53 
54  struct Element
55  {
56  uint32_t matrixIndex = 0;
57  uint32_t stateCommandIndex = 0;
58  uint32_t stateCommandCount = 0;
59  const Node* child = nullptr;
60  };
61 
62  std::vector<Element> _elements;
63 
64  using KeyIndex = std::pair<float, uint32_t>;
65  mutable std::vector<KeyIndex> _binElements;
66  };
67  VSG_type_name(vsg::Bin);
68 
69 } // namespace vsg
Definition: Bin.h:24
Definition: Inherit.h:28
Definition: Input.h:44
Definition: Node.h:24
Definition: Output.h:41
RecordTraversal traverses a scene graph doing view frustum culling and invoking state/commands to rec...
Definition: RecordTraversal.h:61
vsg::State is used by vsg::RecordTraversal to manage state stacks, projection and modelview matrices ...
Definition: State.h:228
Definition: Bin.h:55