VR-Forces Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
DtIndirectDofManager.h
Go to the documentation of this file.
1 /*****************************************************************************
2  * Copyright (c) 2026 MAK Technologies, Inc.
3  * All rights reserved.
4  *****************************************************************************/
5 
9 
10 #pragma once
11 
13 
14 #include <vrvOsg/vrvOsg.h>
18 
20 
21 #include <vrvMath/DtMatrix.h>
23 
25 
26 #include <osg/Node>
27 #include <osg/ref_ptr>
28 #include <osg/observer_ptr>
29 #include <osgSim/DOFTransform>
30 
31 #include <unordered_map>
32 #include <deque>
33 
34 namespace osg
35 {
36  class Sequence;
37  class RenderInfo;
38  class FrameStamp;
39 }
40 
41 namespace makVrv
42 {
43  struct PerGeomInstance;
44  class DtDe;
45  class DtOsgShaderFilesCache;
46  class DtIndirectViewParameters;
47  class DtGlBuffer;
48  class DtIndirectDofProgram;
49  class DtIndirectClearBufferProgram;
50  class DtGlDeleteObjectManager;
51 
54 
57 
59  template <>
60  inline const char* creatorTypeName<DtIndirectDofManager>(void) { return "DtIndirectDofManagerCreator"; }
61 
67  {
68  public:
69 
70  #define CPU_SIDE_COMPILATION 1
71  #include <../data/shaders/indirect/DofInfoBuffer.h>
72  #undef CPU_SIDE_COMPILATION
73 
74  typedef osg::observer_ptr<osg::Node> NodeObserverPtr;
75  typedef std::pair<NodeObserverPtr, DtIndirectDofInfo> NodeDofInfoPair;
76  typedef std::pair<NodeObserverPtr, int> NodeDofInfoIndexPair;
77  typedef std::deque<NodeDofInfoPair> DequeNodeDofInfoPairs;
78  typedef std::unordered_map<int, DtIndirectAnimatingDof* > MapInfoIdxToAnimatingDof;
79 
80  typedef std::unordered_map<int, int> MapInstanceIdToDofInfo;
81  typedef std::map<osg::ref_ptr<osgSim::DOFTransform>, MapInstanceIdToDofInfo > MapNodeToMapInstanceIdToDofInfoIndex;
82 
83  public:
86 
88  virtual ~DtIndirectDofManager();
89  protected:
92 
93  private:
95  DtIndirectDofManager() = delete;
97  DtIndirectDofManager(const DtIndirectDofManager &other) = delete;
99  DtIndirectDofManager &operator=(const DtIndirectDofManager &other) = delete;
100 
101  public:
103  virtual void addDofPaths(std::vector<PerGeomInstance*>& perGeomInstances, int containerInstanceId,
104  const DequeNodeDofInfoPairs& parentDofPaths, const DequeNodeDofInfoPairs& dofPaths,
105  float modelScale, float modelRadius);
106 
108  virtual void removeDofPaths(int containerInstanceId);
109 
112  virtual bool setDof(osgSim::DOFTransform* clone, osgSim::DOFTransform* master, int containerInstanceId, int flags);
113 
115  virtual bool setDofAnimationFlags(osgSim::DOFTransform* clone, osgSim::DOFTransform* master, int containerInstanceId
116  , int animationFlags);
117 
119  virtual bool setDofTranslation(osgSim::DOFTransform* clone, osgSim::DOFTransform* master, int containerInstanceId
120  , const Vector3_64& trans
121  , const Vector3_64& transVel);
122 
124  virtual bool setDofOrientation(osgSim::DOFTransform* clone, osgSim::DOFTransform* master, int containerInstanceId
125  , const Vector3_64& hpr
126  , const Vector3_64& hprVel
127  , int animationFlags);
128 
130  virtual bool setDofOrientation(osgSim::DOFTransform* clone, osgSim::DOFTransform* master, int containerInstanceId
131  , const Vector3_64& hprVel, bool forceUpdate, int animationFlags);
132 
134  virtual void setDofTransform(IndirectDofInfo& info, const osgSim::DOFTransform* clone);
135 
137  virtual void setInstanceXform(const Matrix4_32& xform, int containerInstanceId);
138 
140  virtual Matrix4_32 instanceXform(int containerInstanceId) const;
141 
143  virtual void update(const osg::FrameStamp* frameStamp);
144 
147  virtual void setPureSignalBasedDofs(bool val);
148 
151  virtual bool pureSignalBasedDofs(void) const;
152 
154  virtual void reloadShaders() const;
155 
157  virtual void releaseGLObjects(osg::State* state) const;
158 
160  virtual void processDofs(const DtIndirectViewParameters& viewParameters,
161  const DtGlBuffer* gpuInputPerGeomInstancesBuffer, const int instancesToProcess,
162  const unsigned int geometrySpecificationsSize, const DtGlBuffer* gpuMaterialsBuffer, const osg::Camera* camera);
163 
165  virtual const DtGlBuffer* gpuDofTransformBuffer(const osg::Camera* camera) const;
166 
169  virtual const DtGlBuffer* gpuDofModelScaleBuffer(const osg::Camera* camera) const;
170 
171  protected:
172 
174  virtual void addDof(std::vector<PerGeomInstance*>& perGeomInstances, int containerInstanceId,
175  const NodeDofInfoPair& dofChildPair, int baseParentDofIndex,
176  const int dofInfoId, const float modelScale, const float modelRadius);
177 
179  virtual void updateAnimatingDofs(const osg::FrameStamp* frameStamp);
180 
182  virtual void deleteBuffers(void);
183 
185  virtual void tearDownBuffers(void) const;
186 
188  virtual void updateDofBuffersIfNecessary(int instancesToProcess);
189 
190 
192  virtual void updateDofs();
193 
197  virtual bool findDofInfoIndex(osgSim::DOFTransform* clone, osgSim::DOFTransform* master,
198  int containerInstanceId, int& infoIdx);
199 
201  virtual DtIndirectAnimatingDof* findOrCreateAnimatingDof(int infoIdx, osgSim::DOFTransform* dof);
202 
204  virtual void printInfo();
205 
209  virtual void flushCameraSpecificBuffers(void);
210 
213  virtual void createCameraSpecificBuffersIfNeeded(const osg::Camera* camera);
214 
216  virtual void flushCameraSpecificBuffersInMap(std::map<osg::observer_ptr<const osg::Camera>, DtGlBuffer*>& mapToEraseFrom);
217  protected:
218 
220 
222 
224 
227 
228  typedef std::map<osg::observer_ptr<const osg::Camera>, DtGlBuffer*> CameraToBufferMap;
229 
232 
236 
237  mutable bool myMutableDofInfoDirty;
238 
240 
243  {
244  public:
245  void operator()(IndirectDofInfo& info);
246  };
247 
250 
251  std::unordered_map<int, int> myInstanceToXformBaseIndex;
252 
254 
255  std::unordered_map<osgSim::DOFTransform*, DtIndirectAnimatingDof*> myCloneToAnimatingDofCache;
256 
258  };
259 
260 }
VectorIndirectDofInfos myVectorIndirectDofInfos
Definition: DtIndirectDofManager.h:249
std::unordered_map< int, DtIndirectAnimatingDof * > MapInfoIdxToAnimatingDof
Definition: DtIndirectDofManager.h:78
DtVirtualBaseClassCreator< DtIndirectDofManager > DtIndirectDofManagerCreator
creator
Definition: DtIndirectDofManager.h:53
parent manager class for all Indirect managers. Managers handle information about a specific feature ...
Definition: DtIndirectManager.h:25
bool myPureSignalBasedDofs
Definition: DtIndirectDofManager.h:219
#define DT_DLL_VRVOSG
Definition: vrvOsg.h:23
Contains makVrv::DtIndirectDofInfo struct.
Contains makVrv::DtIndirectManager class.
osg::observer_ptr< osg::Node > NodeObserverPtr
Definition: DtIndirectDofManager.h:74
MapNodeToMapInstanceIdToDofInfoIndex myMapNodeToMapInstanceIdToDofInfoIndex
Definition: DtIndirectDofManager.h:239
CameraToBufferMap myGpuDofModelScaleBufferMap
The output buffer containing the computed model scale for each geom instance. This is used by the lod...
Definition: DtIndirectDofManager.h:235
CameraToBufferMap myGpuDofTransformBufferMap
The buffer containing the transform for each instance to know where it should be drawn.
Definition: DtIndirectDofManager.h:231
Wrapper class for wrapping osgSim::DOFTransform animations. Allows to set a translation &amp; translation...
Definition: DtIndirectAnimatingDof.h:34
std::map< osg::ref_ptr< osgSim::DOFTransform >, MapInstanceIdToDofInfo > MapNodeToMapInstanceIdToDofInfoIndex
Definition: DtIndirectDofManager.h:81
std::pair< NodeObserverPtr, DtIndirectDofInfo > NodeDofInfoPair
Definition: DtIndirectDofManager.h:75
DtGlDeleteObjectManager & myGlDeleteObjectManager
Definition: DtIndirectDofManager.h:257
Variadic templated creator class for defining a DtVirtualBaseClass creator that is automatically regi...
Definition: DtVirtualBaseClassCreator.h:23
std::unordered_map< int, int > MapInstanceIdToDofInfo
Definition: DtIndirectDofManager.h:80
std::unordered_map< osgSim::DOFTransform *, DtIndirectAnimatingDof * > myCloneToAnimatingDofCache
Definition: DtIndirectDofManager.h:255
std::deque< NodeDofInfoPair > DequeNodeDofInfoPairs
Definition: DtIndirectDofManager.h:77
std::unordered_map< int, int > myInstanceToXformBaseIndex
Definition: DtIndirectDofManager.h:251
DtReusableMemoryVector< IndirectDofInfo, IndirectDofInfoInvalidator > VectorIndirectDofInfos
Definition: DtIndirectDofManager.h:248
DtGlBuffer * myGpuDofInfoBuffer
The buffer containing all the dof infos for all instances managed by this manager.
Definition: DtIndirectDofManager.h:226
MapInfoIdxToAnimatingDof myAnimatingDofs
Definition: DtIndirectDofManager.h:253
const char * creatorTypeName< DtIndirectDofManager >(void)
template specialization for the creator (pass the class being created to the creatorTypeName template...
Definition: DtIndirectDofManager.h:60
DtIndirectDofProgram * myMutableDofProgram
Definition: DtIndirectDofManager.h:221
handles the dof nodes for all the indirect geometry. Sets up the default state of osg::Dof...
Definition: DtIndirectDofManager.h:66
singleton class that wraps indirect dof gpu shader.
Definition: DtIndirectDofProgram.h:34
Contains makVrv::DtIndirectAnimatingDof class.
A generic OpenGL buffer. This can be: -&gt; a vertex buffer -&gt; an index buffer -&gt; a shader storage buffe...
Definition: DtGlBuffer.h:29
The class that is used to communicate the camera viewing parameters to the DtICullingAndLOD interface...
Definition: DtIndirectViewParameters.h:26
Base class to provide boost signal/slot management.
DtIndirectClearBufferProgram * myMutableBufferClearProgram
Definition: DtIndirectDofManager.h:223
Contains makVrv::DtReusableMemoryVector class.
Vaos are OpenGL context specific. They need to be deleted in the context they are created in...
Definition: DtGlDeleteObjectManager.h:58
This class clears buffers using compute shader Theoretically, there are performance gains to be achie...
Definition: DtIndirectClearBufferProgram.h:33
friend DtIndirectDofManagerCreator
only creator can create
Definition: DtIndirectDofManager.h:85
Contains DLL export macros.
The DtDe is the core component of any VR-Vantage application. It owns a DtRenderer, DtDeCommunicator, as well as a DtDisplay and other things.
Definition: DtDe.h:76
std::map< osg::observer_ptr< const osg::Camera >, DtGlBuffer * > CameraToBufferMap
Definition: DtIndirectDofManager.h:228
initializer/invalidator for dof infos
Definition: DtIndirectDofManager.h:242
std::pair< NodeObserverPtr, int > NodeDofInfoIndexPair
Definition: DtIndirectDofManager.h:76
n dimensional matrix
DtPerGeomInstance class declaration.
bool myMutableDofInfoDirty
Definition: DtIndirectDofManager.h:237

Document ID: Generated on Thu Oct 15 21:27:02 EDT 2026 from SVN revision 296421
Copyright © 2005-2026 MAK Technologies. All Rights Reserved (www.mak.com)