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) 2024 MAK Technologies, Inc.
3 ** All rights reserved.
4 ******************************************************************************/
5 
9 
10 #pragma once
11 
12 #include <vrvOsg/vrvOsg.h>
14 
15 #include <tbb/concurrent_vector.h>
16 
17 namespace makVrv
18 {
21 
24 
26  template <>
27  inline const char* creatorTypeName<DtIndirectEntityGeometry>(void) { return "DtIndirectEntityGeometryCreator"; }
28 
40  {
41  public:
44 
47  template<class T>
49  {
52  };
53 
54  template<class T>
56  {
59  int myFlags = 0;
60  };
61 
63  typedef std::unordered_map<int, Matrix4_32> MapInstanceIdToXform;
64 
70  typedef std::unordered_map< osgSim::MultiSwitch*, MultiSwitchPair> MapCloneToMultiSwitchPair;
71  typedef std::unordered_map< int, MapCloneToMultiSwitchPair> MapInstanceToMapCloneToMasterMultiSwitches;
72 
73  //Use the pair to hold the refs and the raw pointer to index into the map
77  typedef std::unordered_map< osgSim::DOFTransform*, DofTransformPair > MapCloneToDofTransformPair;
78  typedef std::unordered_map< int, MapCloneToDofTransformPair> MapInstanceToMapCloneToMasterDofs;
79 
84  typedef std::unordered_map< osg::Sequence*, SequencePair > MapCloneToSequencePair;
85  typedef std::unordered_map< int, MapCloneToSequencePair> MapInstanceToMapCloneToMasterSequences;
86 
88  typedef std::map< const std::string, DtIndirectUvOffsetManager::UvOffset> MapAnnotationToUvOffsetData;
89  typedef std::unordered_map< int, MapAnnotationToUvOffsetData> MapInstanceToMapAnnotationToUvOffsetData;
90 
91  typedef std::unordered_map< int, std::tuple<float, float, float> > MapInstanceToUvOffset;
92 
98  {
102  InstanceUpdateStruct( int id, const Matrix4_32& xFormMat );
105 
108  InstanceUpdateStruct() = delete;
109  InstanceUpdateStruct& operator=( const InstanceUpdateStruct& ) = delete;
111  };
112 
114  using InstanceUpdatesVector = tbb::concurrent_vector<InstanceUpdateStruct>;
115  public:
117  virtual ~DtIndirectEntityGeometry();
118 
119  protected:
121  DtIndirectEntityGeometry(DtDe& de, const DtCullShaderConfig& cullShaderConfig, bool terrainPatch);
122 
123  private:
125  DtIndirectEntityGeometry() = delete;
127  DtIndirectEntityGeometry(const DtIndirectEntityGeometry& other) = delete;
129  DtIndirectEntityGeometry& operator=(const DtIndirectEntityGeometry& other) = delete;
130 
131  public:
133  virtual void setInstanceMatrixTransform(int instanceId, const Matrix4_32& xForm);
134 
136  virtual void concurrentSetInstanceMatrixTransform( int instanceId, const Matrix4_32& xForm );
137 
139  virtual void processUpdates();
140 
142  virtual Matrix4_32 instanceMatrixTransform(int instanceId) const;
143 
145  virtual void removeInstance(int id);
146 
148  virtual void setInstanceMultiSwitch(int id, osgSim::MultiSwitch* clone, osgSim::MultiSwitch* master);
149 
151  virtual void instanceMultiSwitches(int instanceIdIndirect, MapCloneToMultiSwitchPair& mapCloneToMasterMultiSwitches) const;
152 
154  virtual void setInstanceModelId(int id, int modelId);
155 
157  virtual void setInstanceUvOffset(int id, const std::string& annotation, float uOffset, float vOffset);
158 
160  virtual void scrollUv(int id, const std::tuple<float, float, float>& uvspeeds);
161 
163  virtual void instanceAnnotationsAndUvOffsets(int instanceIdIndirect, std::vector<DtIndirectAnnotationAndUvOffset>& annotations) const;
164 
166  virtual void setInstanceColor(int instanceIdIndirect, const Vector4_32& color);
168  virtual Vector4_32 instanceColor(int instanceIdIndirect) const;
170 
172  virtual void setInstanceVisibility(int instanceIdIndirect, bool visible);
174  virtual bool instanceVisibility(int instanceIdIndirect) const;
176 
178  virtual void setInstanceLightPointGroupId(int instanceIdIndirect, int lightPointGroupId);
180  virtual int instanceLightPointGroupId(int instanceIdIndirect) const;
182 
184  virtual void setInstanceLightPointMaxDistance(int instanceIdIndirect, float lightPointMaxDistance);
186  virtual float instanceLightPointMaxDistance(int instanceIdIndirect) const;
188 
190  virtual void setInstanceDof(int id, osgSim::DOFTransform* clone, osgSim::DOFTransform* master, int animationFlags);
191 
193  virtual void setInstanceDofTranslation(int id, osgSim::DOFTransform* clone, osgSim::DOFTransform* master
194  , const Vector3_64& trans
195  , const Vector3_64& transVel);
196 
198  virtual void setInstanceDofOrientation(int id, osgSim::DOFTransform* clone, osgSim::DOFTransform* master
199  , const Vector3_64& hpr
200  , const Vector3_64& hprVel
201  , int animationFlags);
202 
204  virtual void setInstanceDofOrientation(int id, osgSim::DOFTransform* clone, osgSim::DOFTransform* master
205  , const Vector3_64& hprVel
206  , bool forceUpdate
207  , int animationFlags);
208 
210  virtual void instanceDofs(int instanceIdIndirect, MapCloneToDofTransformPair& mapCloneToDofTransformPair) const;
211 
213  virtual void setInstanceSequence(int id, osg::Sequence* clone, osg::Sequence* master);
214 
216  virtual void instanceSequences(int instanceIdIndirect, MapCloneToSequencePair& mapCloneToMasterSequences) const;
217 
218 
222  virtual bool hasInProgressInstanceMove() const;
223 
225  virtual void addInProgressInstanceMove();
226 
228  virtual void subtractInProgressInstanceMove();
229 
235  virtual bool allInstancesAreToBeDeleted() const override;
236 
237  protected:
239  virtual void setMultiSwitchOnInstanceInInstanceContainer(int instanceContainerId, osgSim::MultiSwitch* clone, osgSim::MultiSwitch* master);
240 
242  virtual bool setDofOnInstanceInInstanceContainer(int instanceContainerId, osgSim::DOFTransform* clone, osgSim::DOFTransform* master, int animationFlags);
243 
245  virtual void setUvOffsetOnInstanceInInstanceContainer(const int instanceId, const std::string& annotation, float uOffset, float vOffset);
246 
248  virtual bool removeInstanceInInstanceContainer(int instanceContainerId);
249 
252  virtual void removeInstanceFromIndicesCount(int instanceContainerIndex);
253 
255  virtual void updateInstancePositionOrientationAddedActual(const DtIndirectGeometryInstance& instance, int outInstanceIndex) override;
256 
258  virtual void updateInstanceSwitchesAddedActual(const DtIndirectGeometryInstance& instance, int outInstanceIndex) override;
259 
261  virtual void updateInstanceSequencesAddedActual(const DtIndirectGeometryInstance& instance, int outInstanceIndex) override;
262 
264  virtual void updateInstanceUvOffsetsAddedActual(const DtIndirectGeometryInstance& instance, int outInstanceIndex) override;
265 
267  virtual void updateInstanceColorAddedActual(const DtIndirectGeometryInstance& instance, int outInstanceIndex) override;
268 
270  virtual void updateInstanceLightPointGroupIdActual(const DtIndirectGeometryInstance& instance, int outInstanceIndex) override;
271 
273  virtual void updateInstanceVisibilityLightPointMaxDistanceActual(const DtIndirectGeometryInstance& instance, int outInstanceIndex) override;
274 
276  virtual bool updateInstanceDeletionBeforeAddedActual(const DtIndirectGeometryInstance& instance) override;
277 
279  virtual void updateInstancesDofsAddedActual(const DtIndirectGeometryInstance& instance, int outInstanceIndex) override;
280 
282  virtual void updateInstanceModelIdAddedActual(const DtIndirectGeometryInstance& instance, int outInstanceIndex) override;
283 
285  virtual void setInstanceModelIdInInstanceContainer(int instanceId, int modelId);
286 
287  protected:
289  //typedef std::unordered_map<int, Matrix4_32> MapInstanceIdToXform;
291 
292  //Left the typedefs here commented out so they are easier to follow. They need to be at the
293  // top so they can be used as arguments in the functions.
294 
299  //typedef CloneMasterPair<osgSim::MultiSwitch> MultiSwitchPair;
300  //typedef std::map< osgSim::MultiSwitch*, MultiSwitchPair> MapCloneToMultiSwitchPair;
301  //typedef std::map< int, MapCloneToMultiSwitchPair> MapInstanceToMapCloneToMasterMultiSwitches;
303 
304  //Use the pair to hold the refs and the raw pointer to index into the map
307  //typedef CloneMasterPair<osgSim::DOFTransform> DofTransformPair;
308  //typedef std::unordered_map< osgSim::DOFTransform*, DofTransformPair > MapCloneToDofTransformPair;
309  //typedef std::unordered_map< int, MapCloneToDofTransformPair> MapInstanceToMapCloneToMasterDofs;
311 
312  //Use the pair to hold the refs and the raw pointer to index into the map
315  //typedef CloneMasterPair<osg::Sequence> SequencePair;
316  //typedef std::unordered_map< osg::Sequence*, SequencePair > MapCloneToSequencePair;
317  //typedef std::unordered_map< int, MapCloneToSequencePair> MapInstanceToMapCloneToMasterSequences;
319 
321  //typedef std::unordered_map< const std::string, DtIndirectUvOffsetManager::UvOffset> MapAnnotationToUvOffsetData;
322  //typedef std::unordered_map< int, MapAnnotationToUvOffsetData> MapInstanceToMapAnnotationToUvOffsetData;
324 
326  //typedef std::unordered_map< int, DtIndirectUvOffsetManager::UvOffset> MapInstanceToUvOffset;
328 
329  std::unordered_map< int, int > myMapInstanceInIndirectToModelId;
330 
332  std::unordered_map<int, Vector4_32> myMapInstanceToColor;
333 
335  std::unordered_map<int, bool> myMapInstanceToVisibility;
336 
338  std::unordered_map<int, int> myMapInstanceToLightPointGroupId;
339 
341  std::unordered_map<int, float> myMapInstanceToLightPointMaxDistance;
342 
344  typedef std::unordered_set<int> SetInstancesToDelete;
346 
349 
351 
352  // Supporting texture variants is relatively new. If there are bugs,
353  // this can be changed to false, to debug whether texture variants support is the cause.
354  const bool mySupportInstanceModelChanges = true;
355  };
356 }
osg::ref_ptr< T > myMaster
Definition: DtIndirectEntityGeometry.h:51
tbb::concurrent_vector< InstanceUpdateStruct > InstanceUpdatesVector
Holds transform updates that are to be applied to instances.
Definition: DtIndirectEntityGeometry.h:114
const char * creatorTypeName< DtIndirectEntityGeometry >(void)
template specialization for the creator (pass the class being created to the creatorTypeName template...
Definition: DtIndirectEntityGeometry.h:27
std::unordered_map< int, std::tuple< float, float, float > > MapInstanceToUvOffset
Definition: DtIndirectEntityGeometry.h:91
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:50
std::unordered_set< int > SetInstancesToDelete
Structure to hold instance ids to be deleted.
Definition: DtIndirectEntityGeometry.h:344
std::unordered_map< int, MapCloneToSequencePair > MapInstanceToMapCloneToMasterSequences
Definition: DtIndirectEntityGeometry.h:85
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:318
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:76
osg::ref_ptr< T > myClone
Definition: DtIndirectEntityGeometry.h:57
#define DT_DLL_VRVOSG
Definition: vrvOsg.h:23
Definition: featureContext.h:37
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:310
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:69
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:88
std::unordered_map< osg::Sequence *, SequencePair > MapCloneToSequencePair
Definition: DtIndirectEntityGeometry.h:84
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:348
Variadic templated creator class for defining a DtVirtualBaseClass creator that is automatically regi...
Definition: DtVirtualBaseClassCreator.h:22
Inherited from DtIndirectGeometry additionally implements: -removal of instances -ability to set/get ...
Definition: DtIndirectEntityGeometry.h:39
std::unordered_map< int, int > myMapInstanceInIndirectToModelId
Definition: DtIndirectEntityGeometry.h:329
Struct to hold an instance ID and matrix transform Transforms are all calculated concurrently then st...
Definition: DtIndirectEntityGeometry.h:97
\ ::, which allows us to hook into our indirect engine to render using indirect rendering...
Definition: DtIndirectGeometry.h:120
std::unordered_map< osgSim::MultiSwitch *, MultiSwitchPair > MapCloneToMultiSwitchPair
Definition: DtIndirectEntityGeometry.h:70
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:83
std::unordered_map< int, int > myMapInstanceToLightPointGroupId
Maps an instance id to the light point group id for that instance.
Definition: DtIndirectEntityGeometry.h:338
MapInstanceToMapCloneToMasterMultiSwitches myMapInstanceToMapCloneToMasterMultiSwitches
Structure to hold instance multi-switches&#39; state until the instance is actually added Use the pair to...
Definition: DtIndirectEntityGeometry.h:302
std::unordered_map< int, Matrix4_32 > MapInstanceIdToXform
Structure to hold instance orientation until the instance is actually added.
Definition: DtIndirectEntityGeometry.h:63
std::unordered_map< int, MapCloneToMultiSwitchPair > MapInstanceToMapCloneToMasterMultiSwitches
Definition: DtIndirectEntityGeometry.h:71
friend DtIndirectEntityGeometryCreator
only creator can create
Definition: DtIndirectEntityGeometry.h:43
osg::ref_ptr< T > myMaster
Definition: DtIndirectEntityGeometry.h:58
Contains DLL export macros.
MapInstanceIdToXform myMapInstanceIdToXform
Structure to hold instance orientation until the instance is actually added.
Definition: DtIndirectEntityGeometry.h:290
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:72
std::unordered_map< osgSim::DOFTransform *, DofTransformPair > MapCloneToDofTransformPair
Definition: DtIndirectEntityGeometry.h:77
Matrix4_32 myXForm
Definition: DtIndirectEntityGeometry.h:100
MapInstanceToMapAnnotationToUvOffsetData myMapInstanceToMapAnnotationToUvOffsetData
Maps and instance id and a string to the current uv offset for this particular annotation.
Definition: DtIndirectEntityGeometry.h:323
std::unordered_map< int, bool > myMapInstanceToVisibility
Maps an instance id to the visibility for that instance.
Definition: DtIndirectEntityGeometry.h:335
std::atomic< int > myNumInProgressInstanceMoves
Definition: DtIndirectEntityGeometry.h:350
std::unordered_map< int, float > myMapInstanceToLightPointMaxDistance
Maps an instance id to the light point max distance for that instance.
Definition: DtIndirectEntityGeometry.h:341
MapInstanceToUvOffset myMapInstanceToUvOffset
Maps and instance id to the current uv offset for all scrollable uv offsets.
Definition: DtIndirectEntityGeometry.h:327
Contains the DtIndirectGeometry class declaration.
int myInstanceId
Definition: DtIndirectEntityGeometry.h:99
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:48
std::unordered_map< int, MapAnnotationToUvOffsetData > MapInstanceToMapAnnotationToUvOffsetData
Definition: DtIndirectEntityGeometry.h:89
std::unordered_map< int, MapCloneToDofTransformPair > MapInstanceToMapCloneToMasterDofs
Definition: DtIndirectEntityGeometry.h:78
std::unordered_map< int, Vector4_32 > myMapInstanceToColor
Maps an instance id to the color for that instance.
Definition: DtIndirectEntityGeometry.h:332
DtVirtualBaseClassCreator< DtIndirectEntityGeometry, const DtCullShaderConfig &, const bool & > DtIndirectEntityGeometryCreator
creator
Definition: DtIndirectEntityGeometry.h:20
SetInstancesToDelete mySetInstancesIndirectIdsToDelete
Definition: DtIndirectEntityGeometry.h:345

Document ID: Generated on Tue Sep 24 19:28:17 EDT 2024 from SVN revision 269799
Copyright © 2005-2024 MAK Technologies. All Rights Reserved (www.mak.com)