VR-Forces 5.0.2 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 VT-MAK Technologies, Inc.
3 ** All rights reserved.
4 ******************************************************************************/
5 
9 
10 #pragma once
11 
12 #include <vrvOsg/vrvOsg.h>
13 
15 
18 
20 
21 #include <osg/Node>
22 
23 #include <boost/thread.hpp>
24 #include <unordered_map>
25 #include <unordered_set>
26 
27 namespace makVrv
28 {
29  class DtDe;
30  class DtIndirectEntityGeometry;
31  class DtIndirectModelsContainer;
32 
34  class DtIndirectGeometryGrid;
35 
37 
40 
42  template <>
43  inline const char* creatorTypeName<DtIndirectGeometryGrid>(void) { return "DtIndirectGeometryGridCreator"; }
44 
58  {
59  public:
60 
61  // The map of a cell 'id' to its corresponding indirect geometry
62  typedef std::unordered_map<Vector3_int, osg::ref_ptr<DtIndirectEntityGeometry>, DtIndirectCellHasher> MapCellIdsToIndirectGeometry;
63 
64  // The map of a cell 'id' to its corresponding debug drawable
65  typedef std::unordered_map<Vector3_int, osg::ref_ptr<osg::Drawable>, DtIndirectCellHasher > MapCellIdsToDebugCellDrawables;
66 
68  {
69  // regular add
70  INSTANCE_ADD_REGULAR
71 
72  // regular remove
73  , INSTANCE_REMOVE_REGULAR
74 
75  // being added to new cell (part of move)
76  , INSTANCE_ADD_MOVE_NEW_CELL
77 
78  // being removed from old cell (part of move)
79  , INSTANCE_REMOVE_MOVE_OLD_CELL
80 
81  // being cancelled (removed) from new cell (part of move)
82  , INSTANCE_REMOVE_MOVE_CANCEL_NEW_CELL
83 
84  // paged out. remove all
85  , INSTANCE_REMOVE_CELL_PAGED_OUT
86  };
87  public:
90 
92  virtual ~DtIndirectGeometryGrid();
93  protected:
95  DtIndirectGeometryGrid(DtDe& de, int modelSet);
96 
97  private:
99  DtIndirectGeometryGrid() = delete;
101  DtIndirectGeometryGrid(const DtIndirectGeometryGrid &other) = delete;
103  DtIndirectGeometryGrid &operator=(const DtIndirectGeometryGrid &other) = delete;
104 
105  public:
109  virtual DtIndirectEntityGeometry* ts_getOrCreateForCell(const Vector3_int& cellId, bool& created);
110 
112  virtual bool ts_removeCell(const Vector3_int& cellId);
113 
115  virtual Vector3_int cellIdFor(const Vector3_64& position) const;
116 
118  virtual Vector3_64 cellCenter(const Vector3_int& cellId) const;
119 
121  virtual AxisAlignedBoundingBox_64 axisAlignedBoundingBox(const Vector3_int& cellId) const;
122 
124  virtual AxisAlignedBoundingBox_64 axisAlignedBoundingBoxWithPadding(const Vector3_int& cellId) const;
125 
127  virtual DtIndirectModelsContainer* modelsContainer();
128 
130  virtual void setCellSize(const Vector3_64& cellSize);
132  virtual const Vector3_64& cellSize(void) const;
134 
136  virtual void setCellPadding(const Vector3_64& padding);
141  virtual const Vector3_64& cellPadding(void) const;
143 
145  virtual osg::ref_ptr<osg::Node> gridNode();
146 
148  virtual const MapCellIdsToIndirectGeometry& mapCellIdsToIndirectGeometry(void) const;
149 
151  virtual const MapCellIdsToDebugCellDrawables& mapCellIdsToDebugCellDrawables(void) const;
152 
154  virtual void trackInstances(const Vector3_int& cellId, int modelId, InstanceTrackingType type);
155 
157  virtual const DtIndirectLimitTextureStrategy* limitTextureStrategy(void) const;
158 
160  virtual DtIndirectLimitTextureStrategy* limitTextureStrategy(void);
161 
163  int modelSet(void) const;
164 
165  protected:
166 
169 
170  // The parent group for all indirect geometries in the grid
172 
174 
176 
178 
181 
184 
186 
188  std::unordered_map<Vector3_int, std::unordered_map<int, int>, DtIndirectCellHasher > myMapCellToModelInstances;
189 
191  std::unordered_map<int, int> myModelIdToNumInstances;
192 
194 
195  const int myModelSet = -1;
196  };
197 
198 }
Vector3_64 myCellPadding
the cell &#39;padding&#39;
Definition: DtIndirectGeometryGrid.h:183
#define DT_DLL_VRVOSG
Definition: vrvOsg.h:23
std::unordered_map< Vector3_int, osg::ref_ptr< DtIndirectEntityGeometry >, DtIndirectCellHasher > MapCellIdsToIndirectGeometry
Definition: DtIndirectGeometryGrid.h:62
DtIndirectLimitTextureStrategy * myLimitTextureStrategy
Definition: DtIndirectGeometryGrid.h:193
DtVirtualBaseClassCreator< DtIndirectGeometryGrid, const int & > DtIndirectGeometryGridCreator
creator
Definition: DtIndirectGeometryGrid.h:36
const char * creatorTypeName< DtIndirectGeometryGrid >(void)
template specialization for the creator (pass the class being created to the creatorTypeName template...
Definition: DtIndirectGeometryGrid.h:43
boost::mutex myMapCellIdsToIndirectGeometryMutex
Definition: DtIndirectGeometryGrid.h:185
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:191
3 dimensional vector
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:38
std::unordered_map< Vector3_int, osg::ref_ptr< osg::Drawable >, DtIndirectCellHasher > MapCellIdsToDebugCellDrawables
Definition: DtIndirectGeometryGrid.h:65
Axis Aligned Bounding Box class.
InstanceTrackingType
Definition: DtIndirectGeometryGrid.h:67
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:188
This class is passed as a pointer to DtIndirectTextureProcessor. The processor then uses this in conj...
Definition: DtIndirectLimitTextureStrategy.h:65
Vector3_64 myCellSize
the cell size
Definition: DtIndirectGeometryGrid.h:180
MapCellIdsToDebugCellDrawables myMapCellIdsToDebugCellDrawables
Definition: DtIndirectGeometryGrid.h:175
DtIndirectModelsContainer * myModelsContainer
Definition: DtIndirectGeometryGrid.h:177
Contains DLL export macros.
MapCellIdsToIndirectGeometry myMapCellIdsToIndirectGeometry
Definition: DtIndirectGeometryGrid.h:173
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:70
osg::ref_ptr< osg::Node > myGridNode
Definition: DtIndirectGeometryGrid.h:171
friend DtIndirectGeometryGridCreator
only creator can created
Definition: DtIndirectGeometryGrid.h:89
DtDe & myDe
reference to DtDe
Definition: DtIndirectGeometryGrid.h:168
Manages a bunch of &#39;cells&#39; for a given cell size (similar to a sparse octree) each cell has a...
Definition: DtIndirectGeometryGrid.h:57
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.

Document ID: Generated on Sun Dec 4 20:22:03 EST 2022 from SVN revision 249613
Copyright © 2005-2021 MAK Technologies. All Rights Reserved (www.mak.com)