vsg  1.1.0
VulkanSceneGraph library
ComputeBounds.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/box.h>
16 #include <vsg/state/ArrayState.h>
17 
18 namespace vsg
19 {
20 
22  class VSG_DECLSPEC ComputeBounds : public Inherit<ConstVisitor, ComputeBounds>
23  {
24  public:
25  ComputeBounds(ref_ptr<ArrayState> intialArrayState = {});
26 
29 
32  bool useNodeBounds = true;
33 
34  using ArrayStateStack = std::vector<ref_ptr<ArrayState>>;
35  ArrayStateStack arrayStateStack;
36 
37  using MatrixStack = std::vector<dmat4>;
38  MatrixStack matrixStack;
39 
40  ref_ptr<const ushortArray> ushort_indices;
41  ref_ptr<const uintArray> uint_indices;
42 
43  void apply(const Object& node) override;
44  void apply(const StateGroup& stategroup) override;
45  void apply(const Transform& transform) override;
46  void apply(const MatrixTransform& transform) override;
47  void apply(const CullNode& cullNode) override;
48  void apply(const CullGroup& cullGroup) override;
49  void apply(const LOD& lod) override;
50  void apply(const PagedLOD& plod) override;
51  void apply(const Geometry& geometry) override;
52  void apply(const VertexDraw& vid) override;
53  void apply(const VertexIndexDraw& vid) override;
54  void apply(const BindVertexBuffers& bvb) override;
55  void apply(const BindIndexBuffer& bib) override;
56  void apply(const StateCommand& statecommand) override;
57  void apply(const Draw& draw) override;
58  void apply(const DrawIndexed& drawIndexed) override;
59  void apply(const Text& text) override;
60  void apply(const TextGroup& textGroup) override;
61  void apply(const TextTechnique& techqniey) override;
62 
63  void apply(const BufferInfo& bufferInfo) override;
64  void apply(const ushortArray& array) override;
65  void apply(const uintArray& array) override;
66 
67  virtual void applyDraw(uint32_t firstVertex, uint32_t vertexCount, uint32_t firstInstance, uint32_t instanceCount);
68  virtual void applyDrawIndexed(uint32_t firstIndex, uint32_t indexCount, uint32_t firstInstance, uint32_t instanceCount);
69 
70  void add(const dbox& bb);
71  void add(const dsphere& bs);
72  };
73  VSG_type_name(vsg::ComputeBounds);
74 
75 } // namespace vsg
BindIndexBuffer command encapsulates vkCmdBindIndexBuffer call and associated settings.
Definition: BindIndexBuffer.h:28
BindVertexBuffers command encapsulates vkCmdBindVertexBuffers call and associated settings.
Definition: BindVertexBuffers.h:25
BufferInfo encapsulates the settings that map to VkDescriptorBufferInfo.
Definition: BufferInfo.h:27
ComputeBounds traverses a scene graph computing an overall bounding box that encloses all the geometr...
Definition: ComputeBounds.h:23
dbox bounds
Result of compute bounds traversal.
Definition: ComputeBounds.h:28
CullNode that enables view frustum culling on a list of children.
Definition: CullGroup.h:23
Definition: CullNode.h:25
DrawIndexed command encapsulates vkCmdDrawIndexed call and associated settings.
Definition: DrawIndexed.h:24
Draw command encapsulates vkCmdDraw call and associated settings.
Definition: Draw.h:24
Definition: Geometry.h:30
Definition: Inherit.h:28
Definition: LOD.h:33
Definition: MatrixTransform.h:24
Definition: Object.h:42
Definition: PagedLOD.h:36
Definition: StateCommand.h:24
Definition: StateGroup.h:32
Definition: TextGroup.h:27
Definition: TextTechnique.h:25
Definition: Text.h:30
Transform node is a pure virtual base class for positioning/scaling/rotating subgraphs.
Definition: Transform.h:22
Definition: VertexDraw.h:25
Definition: VertexIndexDraw.h:25
Definition: ref_ptr.h:22