vsg: include/vsg/app/RecordTraversal.h Source File

vsg 1.1.3 VulkanSceneGraph library

Loading...
Searching...
No Matches
RecordTraversal.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/core/Mask.h>
16#include <vsg/core/Object.h>
17#include <vsg/core/type_name.h>
18#include <vsg/maths/mat4.h>
19
20#include <set>
21#include <vector>
22
23namespace vsg
24{
25
26 // forward declare nodes
27 class Node;
28 class Group;
29 class QuadGroup;
30 class LOD;
31 class PagedLOD;
32 class StateGroup;
33 class CullGroup;
34 class CullNode;
35 class DepthSorted;
36 class Layer;
37 class Transform;
38 class MatrixTransform;
39 class Joint;
40 class TileDatabase;
41 class VertexDraw;
42 class VertexIndexDraw;
43 class Geometry;
44 class Command;
45 class Commands;
46 class CommandBuffer;
47 class State;
48 class DatabasePager;
49 class FrameStamp;
50 class CulledPagedLODs;
51 class View;
52 class Bin;
53 class Switch;
54 class RegionOfInterest;
55 class ViewDependentState;
56 class Light;
57 class AmbientLight;
58 class DirectionalLight;
59 class PointLight;
60 class SpotLight;
61 class CommandGraph;
62 class RecordedCommandBuffers;
63 class Instrumentation;
64
65 VSG_type_name(vsg::RecordTraversal);
66
68 class VSG_DECLSPEC RecordTraversal : public Object
69 {
70 public:
71 explicit RecordTraversal(uint32_t in_maxSlot = 2, std::set<Bin*> in_bins = {});
72
73 RecordTraversal(const RecordTraversal&) = delete;
74 RecordTraversal& operator=(const RecordTraversal& rhs) = delete;
75
76 template<typename... Args>
77 static ref_ptr<RecordTraversal> create(Args&&... args)
78 {
79 return ref_ptr<RecordTraversal>(new RecordTraversal(std::forward<Args>(args)...));
80 }
81
82 std::size_t sizeofObject() const noexcept override { return sizeof(RecordTraversal); }
83 const char* className() const noexcept override { return type_name<RecordTraversal>(); }
84
85 Mask traversalMask = MASK_ALL;
86 Mask overrideMask = MASK_OFF;
87
88 ref_ptr<Instrumentation> instrumentation;
89
91 ref_ptr<RecordedCommandBuffers> recordedCommandBuffers;
92
94 State* getState() { return _state; }
95
97 CommandBuffer* getCommandBuffer();
98
100 uint32_t deviceID() const;
101
102 void setFrameStamp(FrameStamp* fs);
103 FrameStamp* getFrameStamp() { return _frameStamp; }
104
105 void setDatabasePager(DatabasePager* dp);
106 DatabasePager* getDatabasePager() { return _databasePager; }
107
108 void apply(const Object& object);
109
110 // scene graph nodes
111 void apply(const Group& group);
112 void apply(const QuadGroup& quadGroup);
113 void apply(const LOD& lod);
114 void apply(const PagedLOD& pagedLOD);
115 void apply(const TileDatabase& tileDatabase);
116 void apply(const CullGroup& cullGroup);
117 void apply(const CullNode& cullNode);
118 void apply(const DepthSorted& depthSorted);
119 void apply(const Layer& layer);
120 void apply(const Switch& sw);
121 void apply(const RegionOfInterest& roi);
122
123 // leaf node
124 void apply(const VertexDraw& vid);
125 void apply(const VertexIndexDraw& vid);
126 void apply(const Geometry& vid);
127
128 // positional state
129 void apply(const Light& light);
130 void apply(const AmbientLight& light);
131 void apply(const DirectionalLight& light);
132 void apply(const PointLight& light);
133 void apply(const SpotLight& light);
134
135 // transform nodes
136 void apply(const Transform& transform);
137 void apply(const MatrixTransform& mt);
138
139 // Animation nodes
140 void apply(const Joint& joint);
141
142 // Vulkan nodes
143 void apply(const StateGroup& object);
144
145 // Commands
146 void apply(const Commands& commands);
147 void apply(const Command& command);
148
149 // Viewer level nodes
150 void apply(const Bin& bin);
151 void apply(const View& view);
152 void apply(const CommandGraph& commandGraph);
153
154 void addToBin(int32_t binNumber, double value, const Node* node);
155
156 // clear the bins to record a new frame.
157 void clearBins();
158
159 // list of pairs of modelview matrix & region of interest
160 std::vector<std::pair<dmat4, const RegionOfInterest*>> regionsOfInterest;
161
162 protected:
163 virtual ~RecordTraversal();
164
165 ref_ptr<FrameStamp> _frameStamp;
166 ref_ptr<State> _state;
167
168 // used to handle loading of PagedLOD external children.
169 ref_ptr<DatabasePager> _databasePager;
170 ref_ptr<CulledPagedLODs> _culledPagedLODs;
171
172 int32_t _minimumBinNumber = 0;
173 std::vector<ref_ptr<Bin>> _bins;
174 ref_ptr<ViewDependentState> _viewDependentState;
175 };
176
177} // namespace vsg
vsg::CommandBuffer
CommandBuffer encapsulates VkCommandBuffer.
Definition CommandBuffer.h:27
vsg::DatabasePager
Definition DatabasePager.h:84
vsg::FrameStamp
FrameStamp represents the time and frame count of a specific frame.
Definition FrameStamp.h:22
vsg::Object
Definition Object.h:60
vsg::RecordTraversal
RecordTraversal traverses a scene graph doing view frustum culling and invoking state/commands to rec...
Definition RecordTraversal.h:69
vsg::RecordTraversal::getState
State * getState()
get the current State object used to track state and projection/modelview matrices for the current su...
Definition RecordTraversal.h:94
vsg::RecordTraversal::deviceID
uint32_t deviceID() const
get the current DeviceID for the current subgraph being traversed
vsg::RecordTraversal::getCommandBuffer
CommandBuffer * getCommandBuffer()
get the current CommandBuffer for the current subgraph being traversed
vsg::RecordTraversal::recordedCommandBuffers
ref_ptr< RecordedCommandBuffers > recordedCommandBuffers
Container for CommandBuffers that have been recorded in current frame.
Definition RecordTraversal.h:91
vsg::State
vsg::State is used by vsg::RecordTraversal to manage state stacks, projection and modelview matrices ...
Definition State.h:228
vsg::allocator_affinity_nodes
std container adapter for allocating with MEMORY_AFFINITY_NODES
Definition Allocator.h:138