VR-Forces Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
DtIndirectEntityGeometry.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 
12 #include <vrvOsg/vrvOsg.h>
15 
16 #include <tbb/concurrent_vector.h>
17 
18 #include <vector>
19 
20 namespace makVrv
21 {
24 
27 
29  template <>
30  inline const char* creatorTypeName<DtIndirectEntityGeometry>(void) { return "DtIndirectEntityGeometryCreator"; }
31 
43  {
44  public:
47 
50  template<class T>
52  {
55  };
56 
57  template<class T>
59  {
62  int myFlags = 0;
63  };
64 
66  typedef std::unordered_map<int, Matrix4_32> MapInstanceIdToXform;
67 
73  typedef std::unordered_map< osgSim::MultiSwitch*, MultiSwitchPair> MapCloneToMultiSwitchPair;
74  typedef std::unordered_map< int, MapCloneToMultiSwitchPair> MapInstanceToMapCloneToMasterMultiSwitches;
75 
76  //Use the pair to hold the refs and the raw pointer to index into the map
80  typedef std::unordered_map< osgSim::DOFTransform*, DofTransformPair > MapCloneToDofTransformPair;
81  typedef std::unordered_map< int, MapCloneToDofTransformPair> MapInstanceToMapCloneToMasterDofs;
82 
87  typedef std::unordered_map< osg::Sequence*, SequencePair > MapCloneToSequencePair;
88  typedef std::unordered_map< int, MapCloneToSequencePair> MapInstanceToMapCloneToMasterSequences;
89 
91  typedef std::map< const std::string, DtIndirectUvOffsetManager::UvOffset> MapAnnotationToUvOffsetData;
92  typedef std::unordered_map< int, MapAnnotationToUvOffsetData> MapInstanceToMapAnnotationToUvOffsetData;
93 
94  typedef std::unordered_map< int, std::tuple<float, float, float> > MapInstanceToUvOffset;
95 
101  {
105  InstanceUpdateStruct( int id, const Matrix4_32& xFormMat );
108 
111  InstanceUpdateStruct() = delete;
112  InstanceUpdateStruct& operator=( const InstanceUpdateStruct& ) = delete;
114  };
115 
117  using InstanceUpdatesVector = tbb::concurrent_vector<InstanceUpdateStruct>;
118  public:
120  virtual ~DtIndirectEntityGeometry();
121 
122  protected:
124  DtIndirectEntityGeometry(DtDe& de, const DtCullShaderConfig& cullShaderConfig, bool terrainPatch);
125 
126  private:
128  DtIndirectEntityGeometry() = delete;
130  DtIndirectEntityGeometry(const DtIndirectEntityGeometry& other) = delete;
132  DtIndirectEntityGeometry& operator=(const DtIndirectEntityGeometry& other) = delete;
133 
134  public:
136  virtual void setInstanceMatrixTransform(int instanceId, const Matrix4_32& xForm);
137 
139  virtual void concurrentSetInstanceMatrixTransform( int instanceId, const Matrix4_32& xForm );
140 
142  virtual void processUpdates();
143 
145  virtual Matrix4_32 instanceMatrixTransform(int instanceId) const;
146 
148  virtual void removeInstance(int id);
149 
151  virtual void setInstanceMultiSwitch(int id, osgSim::MultiSwitch* clone, osgSim::MultiSwitch* master);
152 
154  virtual void instanceMultiSwitches(int instanceIdIndirect, MapCloneToMultiSwitchPair& mapCloneToMasterMultiSwitches) const;
155 
157  virtual void setInstanceModelId(int id, int modelId);
158 
160  virtual void setInstanceUvOffset(int id, const std::string& annotation, float uOffset, float vOffset);
161 
163  virtual void scrollUv(int id, const std::tuple<float, float, float>& uvspeeds);
164 
166  virtual void instanceAnnotationsAndUvOffsets(int instanceIdIndirect, std::vector<DtIndirectAnnotationAndUvOffset>& annotations) const;
167 
169  virtual void setInstanceColor(int instanceIdIndirect, const Vector4_32& color);
171  virtual Vector4_32 instanceColor(int instanceIdIndirect) const;
173 
175  virtual void setInstanceVisibility(int instanceIdIndirect, bool visible);
177  virtual bool instanceVisibility(int instanceIdIndirect) const;
179 
181  virtual void setInstanceLightPointGroupId(int instanceIdIndirect, int lightPointGroupId);
183  virtual int instanceLightPointGroupId(int instanceIdIndirect) const;
185 
187  virtual void setInstanceLightPointMaxDistance(int instanceIdIndirect, float lightPointMaxDistance);
189  virtual float instanceLightPointMaxDistance(int instanceIdIndirect) const;
191 
193  virtual void setInstanceDof(int id, osgSim::DOFTransform* clone, osgSim::DOFTransform* master, int animationFlags);
194 
196  virtual void setInstanceDofAnimationFlags(int id, osgSim::DOFTransform* clone, osgSim::DOFTransform* master, int animationFlags);
197 
199  virtual void setInstanceDofTranslation(int id, osgSim::DOFTransform* clone, osgSim::DOFTransform* master
200  , const Vector3_64& trans
201  , const Vector3_64& transVel);
202 
204  virtual void setInstanceDofOrientation(int id, osgSim::DOFTransform* clone, osgSim::DOFTransform* master
205  , const Vector3_64& hpr
206  , const Vector3_64& hprVel
207  , int animationFlags);
208 
210  virtual void setInstanceDofOrientation(int id, osgSim::DOFTransform* clone, osgSim::DOFTransform* master
211  , const Vector3_64& hprVel
212  , bool forceUpdate
213  , int animationFlags);
214 
222  virtual void setInstanceDofOrientationBatch(int id,
223  const std::vector<DtInstanceDofBatchEntry>& entries);
224 
226  virtual void instanceDofs(int instanceIdIndirect, MapCloneToDofTransformPair& mapCloneToDofTransformPair) const;
227 
229  virtual void setInstanceSequence(int id, osg::Sequence* clone, osg::Sequence* master);
230 
232  virtual void instanceSequences(int instanceIdIndirect, MapCloneToSequencePair& mapCloneToMasterSequences) const;
233 
234 
238  virtual bool hasInProgressInstanceMove() const;
239 
241  virtual void addInProgressInstanceMove();
242 
244  virtual void subtractInProgressInstanceMove();
245 
251  virtual bool allInstancesAreToBeDeleted() const override;
252 
257  virtual void debugOnlyQueueHealthSnapshot(DebugQueueHealthSnapshot& outSnapshot) const override;
258 
259  protected:
261  virtual void setMultiSwitchOnInstanceInInstanceContainer(int instanceContainerId, osgSim::MultiSwitch* clone, osgSim::MultiSwitch* master);
262 
264  virtual bool setDofOnInstanceInInstanceContainer(int instanceContainerId, osgSim::DOFTransform* clone, osgSim::DOFTransform* master, int animationFlags);
265 
267  virtual void setUvOffsetOnInstanceInInstanceContainer(const int instanceId, const std::string& annotation, float uOffset, float vOffset);
268 
270  virtual bool removeInstanceInInstanceContainer(int instanceContainerId);
271 
274  virtual void removeInstanceFromIndicesCount(int instanceContainerIndex);
275 
277  virtual void updateInstancePositionOrientationAddedActual(const DtIndirectGeometryInstance& instance, int outInstanceIndex) override;
278 
280  virtual void updateInstanceSwitchesAddedActual(const DtIndirectGeometryInstance& instance, int outInstanceIndex) override;
281 
283  virtual void updateInstanceSequencesAddedActual(const DtIndirectGeometryInstance& instance, int outInstanceIndex) override;
284 
286  virtual void updateInstanceUvOffsetsAddedActual(const DtIndirectGeometryInstance& instance, int outInstanceIndex) override;
287 
289  virtual void updateInstanceColorAddedActual(const DtIndirectGeometryInstance& instance, int outInstanceIndex) override;
290 
292  virtual void updateInstanceLightPointGroupIdActual(const DtIndirectGeometryInstance& instance, int outInstanceIndex) override;
293 
295  virtual void updateInstanceVisibilityLightPointMaxDistanceActual(const DtIndirectGeometryInstance& instance, int outInstanceIndex) override;
296 
298  virtual bool updateInstanceDeletionBeforeAddedActual(const DtIndirectGeometryInstance& instance) override;
299 
301  virtual void updateInstancesDofsAddedActual(const DtIndirectGeometryInstance& instance, int outInstanceIndex) override;
302 
304  virtual void updateInstanceModelIdAddedActual(const DtIndirectGeometryInstance& instance, int outInstanceIndex) override;
305 
307  virtual void setInstanceModelIdInInstanceContainer(int instanceId, int modelId);
308 
309  protected:
311  //typedef std::unordered_map<int, Matrix4_32> MapInstanceIdToXform;
313 
314  //Left the typedefs here commented out so they are easier to follow. They need to be at the
315  // top so they can be used as arguments in the functions.
316 
321  //typedef CloneMasterPair<osgSim::MultiSwitch> MultiSwitchPair;
322  //typedef std::map< osgSim::MultiSwitch*, MultiSwitchPair> MapCloneToMultiSwitchPair;
323  //typedef std::map< int, MapCloneToMultiSwitchPair> MapInstanceToMapCloneToMasterMultiSwitches;
325 
326  //Use the pair to hold the refs and the raw pointer to index into the map
329  //typedef CloneMasterPair<osgSim::DOFTransform> DofTransformPair;
330  //typedef std::unordered_map< osgSim::DOFTransform*, DofTransformPair > MapCloneToDofTransformPair;
331  //typedef std::unordered_map< int, MapCloneToDofTransformPair> MapInstanceToMapCloneToMasterDofs;
333 
334  //Use the pair to hold the refs and the raw pointer to index into the map
337  //typedef CloneMasterPair<osg::Sequence> SequencePair;
338  //typedef std::unordered_map< osg::Sequence*, SequencePair > MapCloneToSequencePair;
339  //typedef std::unordered_map< int, MapCloneToSequencePair> MapInstanceToMapCloneToMasterSequences;
341 
343  //typedef std::unordered_map< const std::string, DtIndirectUvOffsetManager::UvOffset> MapAnnotationToUvOffsetData;
344  //typedef std::unordered_map< int, MapAnnotationToUvOffsetData> MapInstanceToMapAnnotationToUvOffsetData;
346 
348  //typedef std::unordered_map< int, DtIndirectUvOffsetManager::UvOffset> MapInstanceToUvOffset;
350 
351  std::unordered_map< int, int > myMapInstanceInIndirectToModelId;
352 
354  std::unordered_map<int, Vector4_32> myMapInstanceToColor;
355 
357  std::unordered_map<int, bool> myMapInstanceToVisibility;
358 
360  std::unordered_map<int, int> myMapInstanceToLightPointGroupId;
361 
363  std::unordered_map<int, float> myMapInstanceToLightPointMaxDistance;
364 
366  typedef std::unordered_set<int> SetInstancesToDelete;
368 
371 
373 
374  // Supporting texture variants is relatively new. If there are bugs,
375  // this can be changed to false, to debug whether texture variants support is the cause.
376  const bool mySupportInstanceModelChanges = true;
377  };
378 }
osg::ref_ptr< T > myMaster
Definition: DtIndirectEntityGeometry.h:54
tbb::concurrent_vector< InstanceUpdateStruct > InstanceUpdatesVector
Holds transform updates that are to be applied to instances.
Definition: DtIndirectEntityGeometry.h:117
const char * creatorTypeName< DtIndirectEntityGeometry >(void)
template specialization for the creator (pass the class being created to the creatorTypeName template...
Definition: DtIndirectEntityGeometry.h:30
std::unordered_map< int, std::tuple< float, float, float > > MapInstanceToUvOffset
Definition: DtIndirectEntityGeometry.h:94
non virtual container class for holding the information needed to create an indirect geometry instanc...
Definition: DtIndirectGeometryInstance.h:26
osg::ref_ptr< T > myClone
Definition: DtIndirectEntityGeometry.h:53
std::unordered_set< int > SetInstancesToDelete
Structure to hold instance ids to be deleted.
Definition: DtIndirectEntityGeometry.h:366
std::unordered_map< int, MapCloneToSequencePair > MapInstanceToMapCloneToMasterSequences
Definition: DtIndirectEntityGeometry.h:88
MapInstanceToMapCloneToMasterSequences myMapInstanceToMapCloneToMasterSequences
Maps an instance id and a master sequence to the clone sequence so we can get to the cloned sequence ...
Definition: DtIndirectEntityGeometry.h:340
MapCloneToDofTransformPairAndFlags< osgSim::DOFTransform > DofTransformPair
Maps an instance id and a master dof to the clone dof so we can get to the cloned dof which contains ...
Definition: DtIndirectEntityGeometry.h:79
osg::ref_ptr< T > myClone
Definition: DtIndirectEntityGeometry.h:60
#define DT_DLL_VRVOSG
Definition: vrvOsg.h:23
Definition: featureContext.h:36
OsgEarth-free batch-entry structs shared by the articulated-model / indirect-entity batch update path...
MapInstanceToMapCloneToMasterDofs myMapInstanceToMapCloneToMasterDofs
Maps an instance id and a master dof to the clone dof so we can get to the cloned dof which contains ...
Definition: DtIndirectEntityGeometry.h:332
CloneMasterPair< osgSim::MultiSwitch > MultiSwitchPair
Structure to hold instance multi-switches&#39; state until the instance is actually added Use the pair to...
Definition: DtIndirectEntityGeometry.h:72
std::map< const std::string, DtIndirectUvOffsetManager::UvOffset > MapAnnotationToUvOffsetData
Maps and instance id and a string to the current uv offset for this particular annotation.
Definition: DtIndirectEntityGeometry.h:91
std::unordered_map< osg::Sequence *, SequencePair > MapCloneToSequencePair
Definition: DtIndirectEntityGeometry.h:87
shader configuration storage class. Has 3 available options which are described in the constructor&#39;s ...
Definition: DtCullShaderConfig.h:21
InstanceUpdatesVector myInstanceUpdates
Updates are pushed to this vector concurrently by the indirect manager.
Definition: DtIndirectEntityGeometry.h:370
Variadic templated creator class for defining a DtVirtualBaseClass creator that is automatically regi...
Definition: DtVirtualBaseClassCreator.h:23
Inherited from DtIndirectGeometry additionally implements: -removal of instances -ability to set/get ...
Definition: DtIndirectEntityGeometry.h:42
std::unordered_map< int, int > myMapInstanceInIndirectToModelId
Definition: DtIndirectEntityGeometry.h:351
Struct to hold an instance ID and matrix transform Transforms are all calculated concurrently then st...
Definition: DtIndirectEntityGeometry.h:100
This class inherits from.
Definition: DtIndirectGeometry.h:122
std::unordered_map< osgSim::MultiSwitch *, MultiSwitchPair > MapCloneToMultiSwitchPair
Definition: DtIndirectEntityGeometry.h:73
Debug-only. Snapshot of queue health counters for this geometry.
Definition: DtIndirectGeometry.h:375
CloneMasterPair< osg::Sequence > SequencePair
Use the pair to hold the refs and the raw pointer to index into the map Maps an instance id and a ma...
Definition: DtIndirectEntityGeometry.h:86
std::unordered_map< int, int > myMapInstanceToLightPointGroupId
Maps an instance id to the light point group id for that instance.
Definition: DtIndirectEntityGeometry.h:360
MapInstanceToMapCloneToMasterMultiSwitches myMapInstanceToMapCloneToMasterMultiSwitches
Structure to hold instance multi-switches&#39; state until the instance is actually added Use the pair to...
Definition: DtIndirectEntityGeometry.h:324
std::unordered_map< int, Matrix4_32 > MapInstanceIdToXform
Structure to hold instance orientation until the instance is actually added.
Definition: DtIndirectEntityGeometry.h:66
std::unordered_map< int, MapCloneToMultiSwitchPair > MapInstanceToMapCloneToMasterMultiSwitches
Definition: DtIndirectEntityGeometry.h:74
friend DtIndirectEntityGeometryCreator
only creator can create
Definition: DtIndirectEntityGeometry.h:46
osg::ref_ptr< T > myMaster
Definition: DtIndirectEntityGeometry.h:61
Contains DLL export macros.
MapInstanceIdToXform myMapInstanceIdToXform
Structure to hold instance orientation until the instance is actually added.
Definition: DtIndirectEntityGeometry.h:312
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::unordered_map< osgSim::DOFTransform *, DofTransformPair > MapCloneToDofTransformPair
Definition: DtIndirectEntityGeometry.h:80
Matrix4_32 myXForm
Definition: DtIndirectEntityGeometry.h:103
MapInstanceToMapAnnotationToUvOffsetData myMapInstanceToMapAnnotationToUvOffsetData
Maps and instance id and a string to the current uv offset for this particular annotation.
Definition: DtIndirectEntityGeometry.h:345
std::unordered_map< int, bool > myMapInstanceToVisibility
Maps an instance id to the visibility for that instance.
Definition: DtIndirectEntityGeometry.h:357
std::atomic< int > myNumInProgressInstanceMoves
Definition: DtIndirectEntityGeometry.h:372
std::unordered_map< int, float > myMapInstanceToLightPointMaxDistance
Maps an instance id to the light point max distance for that instance.
Definition: DtIndirectEntityGeometry.h:363
MapInstanceToUvOffset myMapInstanceToUvOffset
Maps and instance id to the current uv offset for all scrollable uv offsets.
Definition: DtIndirectEntityGeometry.h:349
Contains the DtIndirectGeometry class declaration.
int myInstanceId
Definition: DtIndirectEntityGeometry.h:102
Helper struct to make the code a bit more clear. Used instead of std::pair to hold a pair of ref_ptr&#39;...
Definition: DtIndirectEntityGeometry.h:51
std::unordered_map< int, MapAnnotationToUvOffsetData > MapInstanceToMapAnnotationToUvOffsetData
Definition: DtIndirectEntityGeometry.h:92
std::unordered_map< int, MapCloneToDofTransformPair > MapInstanceToMapCloneToMasterDofs
Definition: DtIndirectEntityGeometry.h:81
std::unordered_map< int, Vector4_32 > myMapInstanceToColor
Maps an instance id to the color for that instance.
Definition: DtIndirectEntityGeometry.h:354
DtVirtualBaseClassCreator< DtIndirectEntityGeometry, const DtCullShaderConfig &, const bool & > DtIndirectEntityGeometryCreator
creator
Definition: DtIndirectEntityGeometry.h:23
SetInstancesToDelete mySetInstancesIndirectIdsToDelete
Definition: DtIndirectEntityGeometry.h:367

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)