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

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