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

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;
56 class ViewDependentState;
57 class Light;
58 class AmbientLight;
59 class DirectionalLight;
60 class PointLight;
61 class SpotLight;
62 class CommandGraph;
63 class RecordedCommandBuffers;
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
92 ref_ptr<RecordedCommandBuffers> recordedCommandBuffers;
93
95 State* getState() { return _state; }
96
98 CommandBuffer* getCommandBuffer();
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
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:27
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::Instrumentation
base class for Instrumentation implentations
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:95
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:92
vsg::RecordedCommandBuffers
Thread safe container class.
Definition CommandBuffer.h:87
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:228
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