vsg 1.1.9
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 CoordinateFrame;
40 class Joint;
41 class TileDatabase;
42 class VertexDraw;
43 class VertexIndexDraw;
44 class Geometry;
45 class Command;
46 class Commands;
47 class CommandBuffer;
48 class State;
49 class DatabasePager;
50 class FrameStamp;
51 class CulledPagedLODs;
52 class View;
53 class Bin;
54 class Switch;
55 class RegionOfInterest;
57 class Light;
58 class AmbientLight;
59 class DirectionalLight;
60 class PointLight;
61 class SpotLight;
62 class CommandGraph;
64 class Instrumentation;
65
66 VSG_type_name(vsg::RecordTraversal);
67
69 class VSG_DECLSPEC RecordTraversal : public Object
70 {
71 public:
72 explicit RecordTraversal(uint32_t in_maxSlot = 2, const std::set<Bin*>& in_bins = {});
73
74 RecordTraversal(const RecordTraversal&) = delete;
75 RecordTraversal& operator=(const RecordTraversal& rhs) = delete;
76
77 template<typename... Args>
78 static ref_ptr<RecordTraversal> create(Args&&... args)
79 {
80 return ref_ptr<RecordTraversal>(new RecordTraversal(std::forward<Args>(args)...));
81 }
82
83 std::size_t sizeofObject() const noexcept override { return sizeof(RecordTraversal); }
84 const char* className() const noexcept override { return type_name<RecordTraversal>(); }
85
86 Mask traversalMask = MASK_ALL;
87 Mask overrideMask = MASK_OFF;
88
89 ref_ptr<Instrumentation> instrumentation;
90
93
95 State* getState() { return _state; }
96
99
101 uint32_t deviceID() const;
102
103 void setFrameStamp(FrameStamp* fs);
104 FrameStamp* getFrameStamp() { return _frameStamp; }
105
106 void setDatabasePager(DatabasePager* dp);
107 DatabasePager* getDatabasePager() { return _databasePager; }
108
109 void apply(const Object& object);
110
111 // scene graph nodes
112 void apply(const Group& group);
113 void apply(const QuadGroup& quadGroup);
114 void apply(const LOD& lod);
115 void apply(const PagedLOD& pagedLOD);
116 void apply(const TileDatabase& tileDatabase);
117 void apply(const CullGroup& cullGroup);
118 void apply(const CullNode& cullNode);
119 void apply(const DepthSorted& depthSorted);
120 void apply(const Layer& layer);
121 void apply(const Switch& sw);
122 void apply(const RegionOfInterest& roi);
123
124 // leaf node
125 void apply(const VertexDraw& vid);
126 void apply(const VertexIndexDraw& vid);
127 void apply(const Geometry& vid);
128
129 // positional state
130 void apply(const Light& light);
131 void apply(const AmbientLight& light);
132 void apply(const DirectionalLight& light);
133 void apply(const PointLight& light);
134 void apply(const SpotLight& light);
135
136 // transform nodes
137 void apply(const Transform& transform);
138 void apply(const MatrixTransform& mt);
139 void apply(const CoordinateFrame& cf);
140
141 // Animation nodes
142 void apply(const Joint& joint);
143
144 // Vulkan nodes
145 void apply(const StateGroup& object);
146
147 // Commands
148 void apply(const Commands& commands);
149 void apply(const Command& command);
150
151 // Viewer level nodes
152 void apply(const Bin& bin);
153 void apply(const View& view);
154 void apply(const CommandGraph& commandGraph);
155
156 void addToBin(int32_t binNumber, double value, const Node* node);
157
158 // clear the bins to record a new frame.
159 void clearBins();
160
161 // list of pairs of modelview matrix & region of interest
162 std::vector<std::pair<dmat4, const RegionOfInterest*>> regionsOfInterest;
163
164 protected:
165 virtual ~RecordTraversal();
166
167 ref_ptr<FrameStamp> _frameStamp;
168 ref_ptr<State> _state;
169
170 // used to handle loading of PagedLOD external children.
171 ref_ptr<DatabasePager> _databasePager;
172 ref_ptr<CulledPagedLODs> _culledPagedLODs;
173
174 int32_t _minimumBinNumber = 0;
175 std::vector<ref_ptr<Bin>> _bins;
176 ref_ptr<ViewDependentState> _viewDependentState;
177 };
178
179} // namespace vsg
AmbientLight represents an ambient light source.
Definition AmbientLight.h:24
Definition Bin.h:24
CommandBuffer encapsulates VkCommandBuffer.
Definition CommandBuffer.h:27
CommandGraph is a group node that sits at the top of the scene graph and manages the recording of its...
Definition CommandGraph.h:28
Command base class for encapsulating vkCmd* calls and associated settings.
Definition Command.h:23
Definition Commands.h:29
CoordinateFrame provides support for astronomically large coordinates.
Definition CoordinateFrame.h:22
CullNode that enables view frustum culling on a list of children.
Definition CullGroup.h:23
Definition CullNode.h:25
Class used by the DatabasePager to keep track of PagedLOD nodes.
Definition DatabasePager.h:33
Definition DatabasePager.h:84
Definition DepthSorted.h:27
DirectionalLight represents a directional light source - used for light sources that are treated as i...
Definition DirectionalLight.h:24
FrameStamp represents the time and frame count of a specific frame.
Definition FrameStamp.h:22
Definition Geometry.h:30
Group node provides a list of children.
Definition Group.h:24
base class for Instrumentation implentations
Definition Instrumentation.h:51
Definition Joint.h:22
Definition LOD.h:33
Layer node is used to control which bin to place the subgraph in and what sort value to assign.
Definition Layer.h:23
Definition Light.h:26
Definition MatrixTransform.h:24
Definition Node.h:24
Definition PagedLOD.h:36
PointLight represents a local point light source where all light radiants event from the light positi...
Definition PointLight.h:24
Definition QuadGroup.h:29
State * getState()
get the current State object used to track state and projection/modelview matrices for the current su...
Definition RecordTraversal.h:95
uint32_t deviceID() const
get the current DeviceID for the current subgraph being traversed
CommandBuffer * getCommandBuffer()
get the current CommandBuffer for the current subgraph being traversed
ref_ptr< RecordedCommandBuffers > recordedCommandBuffers
Container for CommandBuffers that have been recorded in current frame.
Definition RecordTraversal.h:92
Thread safe container class.
Definition CommandBuffer.h:87
RegionOfInterest node is inform applications/algorithms extents that should take account of.
Definition RegionOfInterest.h:23
SpotLight represents a local point light source whose intensity varies as a spot light.
Definition SpotLight.h:24
Definition StateGroup.h:32
vsg::State is used by vsg::RecordTraversal to manage state stacks, projection and modelview matrices ...
Definition State.h:228
Switch node for toggling on/off recording of children.
Definition Switch.h:25
Definition TileDatabase.h:80
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 ViewDependentState.h:106
View is a Group class that pairs a Camera that defines the view with a subgraph that defines the scen...
Definition View.h:36
Definition ref_ptr.h:22