VR-Forces Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
DtIndirectGeometryGrid.h
Go to the documentation of this file.
1 /******************************************************************************
2 ** Copyright (c) 2022 MAK Technologies, Inc.
3 ** All rights reserved.
4 ******************************************************************************/
5 
9 
10 #pragma once
11 
12 #include <vrvOsg/vrvOsg.h>
13 
15 
16 #include <vrvMath/DtVector3.h>
18 
21 
22 #include <osg/Node>
23 
24 #include <boost/thread.hpp>
25 #include <unordered_map>
26 #include <unordered_set>
27 
28 #include <tbb/concurrent_hash_map.h>
29 #include <tbb/concurrent_vector.h>
30 
31 namespace makVrv
32 {
33  class DtDe;
34  class DtIndirectEntityGeometry;
35  class DtIndirectModelsContainer;
36  class DtIndirectGeometryRenderer;
37 
39  class DtIndirectGeometryGrid;
40 
42 
45 
47  template <>
48  inline const char* creatorTypeName<DtIndirectGeometryGrid>(void) { return "DtIndirectGeometryGridCreator"; }
49 
63  {
64  public:
65 
67  using MapCellIdsToIndirectGeometry = tbb::concurrent_hash_map<Vector3_int, osg::ref_ptr<DtIndirectEntityGeometry>, DtIndirectCellHasher> ;
68 
70  using MapCellIdsToDebugCellDrawables = std::unordered_map<Vector3_int, osg::ref_ptr<osg::Drawable>, DtIndirectCellHasher > ;
71 
73  {
74  // regular add
75  INSTANCE_ADD_REGULAR
76 
77  // regular remove
78  , INSTANCE_REMOVE_REGULAR
79 
80  // being added to new cell (part of move)
81  , INSTANCE_ADD_MOVE_NEW_CELL
82 
83  // being removed from old cell (part of move)
84  , INSTANCE_REMOVE_MOVE_OLD_CELL
85 
86  // being cancelled (removed) from new cell (part of move)
87  , INSTANCE_REMOVE_MOVE_CANCEL_NEW_CELL
88 
89  // paged out. remove all
90  , INSTANCE_REMOVE_CELL_PAGED_OUT
91  };
92 
95  {
97  InstanceTrackingStruct( const Vector3_int& cellId, int modelId, InstanceTrackingType type );
100 
103  InstanceTrackingStruct() = delete;
104  InstanceTrackingStruct& operator=( const InstanceTrackingStruct& ) = delete;
106 
110  };
111 
115  using InstanceTrackingRequestsVector = tbb::concurrent_vector<InstanceTrackingStruct>;
116  public:
119 
121  virtual ~DtIndirectGeometryGrid();
122  protected:
125 
126  private:
128  DtIndirectGeometryGrid() = delete;
130  DtIndirectGeometryGrid(const DtIndirectGeometryGrid &other) = delete;
132  DtIndirectGeometryGrid &operator=(const DtIndirectGeometryGrid &other) = delete;
133 
134  public:
138  virtual DtIndirectEntityGeometry* ts_getOrCreateForCell(const Vector3_int& cellId, bool& created);
139 
142  virtual const DtIndirectEntityGeometry* findIndirectGeometryForCell( const Vector3_int& cellId ) const;
143 
145  virtual bool ts_removeCell(const Vector3_int& cellId);
146 
148  virtual Vector3_int cellIdFor(const Vector3_64& position) const;
149 
151  virtual Vector3_64 cellCenter(const Vector3_int& cellId) const;
152 
154  virtual AxisAlignedBoundingBox_64 axisAlignedBoundingBox(const Vector3_int& cellId) const;
155 
157  virtual AxisAlignedBoundingBox_64 axisAlignedBoundingBoxWithPadding(const Vector3_int& cellId) const;
158 
160  virtual DtIndirectModelsContainer* modelsContainer();
161 
163  virtual void setCellSize(const Vector3_64& cellSize);
165  virtual const Vector3_64& cellSize(void) const;
167 
169  virtual void setCellPadding(const Vector3_64& padding);
174  virtual const Vector3_64& cellPadding(void) const;
176 
178  virtual osg::ref_ptr<osg::Node> gridNode();
179 
181  virtual const MapCellIdsToIndirectGeometry& mapCellIdsToIndirectGeometry(void) const;
182 
184  virtual const MapCellIdsToDebugCellDrawables& mapCellIdsToDebugCellDrawables(void) const;
185 
188  virtual void concurrentAddInstanceTrackingRequest( const Vector3_int& cellId, int modelId, InstanceTrackingType type );
189 
192  virtual void processInstanceTrackingRequests();
193 
195  virtual void trackInstances(const Vector3_int& cellId, int modelId, InstanceTrackingType type);
196 
198  virtual const DtIndirectLimitTextureStrategy* limitTextureStrategy(void) const;
199 
201  virtual DtIndirectLimitTextureStrategy* limitTextureStrategy(void);
202 
204  DtModelSetId modelSet(void) const;
205 
207  virtual osg::ref_ptr<osg::Node> gridRenderer();
208 
210  virtual std::string modelSetString(void) const;
211 
212  protected:
213 
216 
217  // The parent group for all indirect geometries in the grid
219 
221 
223 
226 
228 
231 
234 
236 
238  std::unordered_map<Vector3_int, std::unordered_map<int, int>, DtIndirectCellHasher > myMapCellToModelInstances;
239 
241  std::unordered_map<int, int> myModelIdToNumInstances;
242 
244 
246 
248 
250 
251  // XXX temporary until we finish testing and branch is QA approved.
252  // Connected to cmdline arg enableMutexesOnIndirectStructures
254  };
255 
256 }
Vector3_64 myCellPadding
the cell &#39;padding&#39;
Definition: DtIndirectGeometryGrid.h:233
AxisAlignedBoundingBox_64 myInfiniteBoundingBox
Definition: DtIndirectGeometryGrid.h:247
#define DT_DLL_VRVOSG
Definition: vrvOsg.h:23
Struct for storing tracking ino that can be pushed onto a concurrent vector.
Definition: DtIndirectGeometryGrid.h:94
DtIndirectLimitTextureStrategy * myLimitTextureStrategy
Definition: DtIndirectGeometryGrid.h:243
tbb::concurrent_vector< InstanceTrackingStruct > InstanceTrackingRequestsVector
Concurrent vector for storing indirect tracking info. As indirect geomtries can be created in multipl...
Definition: DtIndirectGeometryGrid.h:115
osg::ref_ptr< DtIndirectGeometryRenderer > myGridRenderer
Definition: DtIndirectGeometryGrid.h:220
tbb::concurrent_hash_map< Vector3_int, osg::ref_ptr< DtIndirectEntityGeometry >, DtIndirectCellHasher > MapCellIdsToIndirectGeometry
The map of a cell &#39;id&#39; to its corresponding indirect geometry.
Definition: DtIndirectGeometryGrid.h:67
const char * creatorTypeName< DtIndirectGeometryGrid >(void)
template specialization for the creator (pass the class being created to the creatorTypeName template...
Definition: DtIndirectGeometryGrid.h:48
boost::mutex myMapCellIdsToIndirectGeometryMutex
Definition: DtIndirectGeometryGrid.h:235
std::unordered_map< int, int > myModelIdToNumInstances
map of model ids to number of instances of those model ids, for the entire grid
Definition: DtIndirectGeometryGrid.h:241
3 dimensional vector
bool myMutexesEnabled
Definition: DtIndirectGeometryGrid.h:253
int myModelId
Definition: DtIndirectGeometryGrid.h:108
class for holding an indirect geometry registrar (which holds the information about how to draw model...
Definition: DtIndirectModelsContainer.h:55
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:40
Axis Aligned Bounding Box class.
InstanceTrackingType
Definition: DtIndirectGeometryGrid.h:72
Vector3_int myCellId
Definition: DtIndirectGeometryGrid.h:107
std::unordered_map< Vector3_int, std::unordered_map< int, int >, DtIndirectCellHasher > myMapCellToModelInstances
map of a cell to a map of model ids to number of instances of those model ids, in the cell ...
Definition: DtIndirectGeometryGrid.h:238
The indirect system uses this in conjunction with the system wide limits (for entity/terrain) to clam...
Definition: DtIndirectLimitTextureStrategy.h:65
InstanceTrackingType myType
Definition: DtIndirectGeometryGrid.h:109
InstanceTrackingRequestsVector myInstanceTrackingRequests
Definition: DtIndirectGeometryGrid.h:249
Vector3_64 myCellSize
the cell size
Definition: DtIndirectGeometryGrid.h:230
MapCellIdsToDebugCellDrawables myMapCellIdsToDebugCellDrawables
Definition: DtIndirectGeometryGrid.h:225
std::unordered_map< Vector3_int, osg::ref_ptr< osg::Drawable >, DtIndirectCellHasher > MapCellIdsToDebugCellDrawables
The map of a cell &#39;id&#39; to its corresponding debug drawable.
Definition: DtIndirectGeometryGrid.h:70
DtIndirectModelsContainer * myModelsContainer
Definition: DtIndirectGeometryGrid.h:227
Contains DLL export macros.
MapCellIdsToIndirectGeometry myMapCellIdsToIndirectGeometry
Definition: DtIndirectGeometryGrid.h:222
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
osg::ref_ptr< osg::Node > myGridNode
Definition: DtIndirectGeometryGrid.h:218
friend DtIndirectGeometryGridCreator
only creator can created
Definition: DtIndirectGeometryGrid.h:118
DtDe & myDe
reference to DtDe
Definition: DtIndirectGeometryGrid.h:215
DtModelSetId
Definition: DtModelSetEnums.h:19
Manages a bunch of &#39;cells&#39; for a given cell size (similar to a sparse octree) each cell has a...
Definition: DtIndirectGeometryGrid.h:62
DtVirtualBaseClassCreator< DtIndirectGeometryGrid, const DtModelSetId & > DtIndirectGeometryGridCreator
creator
Definition: DtIndirectGeometryGrid.h:41
hash for Vector3Int (cell ids), so that we can map cell ids to the corresponding indirect geometry ...
Definition: DtIndirectCellHasher.h:19
Contains makVrv::DtIndirectCellHasher class.
Contains various enum classes relating to model sets.
boost::mutex myMapCellIdsToDebugCellDrawablesMutex
Definition: DtIndirectGeometryGrid.h:224

Document ID: Generated on Wed Mar 27 22:49:11 EDT 2024 from SVN revision 264633
Copyright © 2005-2024 MAK Technologies. All Rights Reserved (www.mak.com)