VR-Forces Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
DtHierarchicalPagedLod.h
Go to the documentation of this file.
1 /******************************************************************************
2 ** Copyright (c) 2023 MAK Technologies, Inc.
3 ** All rights reserved.
4 ******************************************************************************/
5 
9 
10 #pragma once
11 
12 #include <vrvOsg/vrvOsg.h>
13 #include <vrvOsg/DtFastGroup.h>
14 
15 #include <vrvCore/DtUniqueID.h>
16 
18 #include <vrvUtil/signalslib.h>
19 
20 #include <osg/Vec3>
21 #include <osg/MatrixTransform>
22 
23 #include <osgDB/Options>
24 
25 #include <unordered_map>
26 
27 #define DTHIERARCHICALPAGEDLOD_LOGGING 0
28 
29 namespace makVrv
30 {
31  class DtOsgCullVisitor;
32  class DtOsgArticulatedModel;
33  class DtModelDefinition;
34 
40  {
41  public:
42 
43  typedef std::unordered_map<DtUniqueID, DtSceneObject* > SceneObjectMap;
44 
46  DtHierarchicalPagedLod(DtDe& de, const std::string& filename,
47  float distanceNear, float distanceFar, float tileRadius,
48  float childTileRadius, const osg::Vec3d& fileCenter,
49  const osg::Vec3d& childrenCenter, bool sparseChildren,
50  bool substitutiveChildren, const osg::Matrixd& fileTranslation,
51  osgDB::Options* options, osg::Node* parentMetaflightGroup);
52 
54  virtual ~DtHierarchicalPagedLod();
55 
56  virtual const char* className() const { return "DtHierarchicalPagedLod"; }
57 
62  void addChildHierarchy(DtHierarchicalPagedLod* child);
63 
65  virtual void traverse(osg::NodeVisitor& nv);
66 
68  virtual void traverseAll(osg::NodeVisitor& nv);
69 
71  virtual void traverseActive(osg::NodeVisitor& nv);
72 
75  virtual void cullActive(osg::NodeVisitor& nv);
76 
78  void cullActive2D(DtOsgCullVisitor& nv);
79 
81  void cullActive3D(osg::NodeVisitor& nv);
82 
84  virtual osg::BoundingSphere computeBound() const;
85 
88  virtual void traverseFile(osg::NodeVisitor& nv, float distance);
89 
92  virtual void traverseChildren(osg::NodeVisitor& nv);
93 
95  virtual bool fileInRange(float distance) const;
96 
98  virtual float fileRangeDistance(osg::NodeVisitor& nv) const;
99 
101  virtual float childRangeDistance(osg::NodeVisitor& nv) const;
102 
104  void pageInFile(osg::NodeVisitor& nv, float distance);
105 
108  void pageOutFile(int lastCullTime, osg::NodeList& toRemove);
109 
112  bool fileNotLoaded() const;
113 
115  bool fileIsPaging() const;
116 
118  bool fileIsLoaded() const;
119 
121  virtual bool fileInChildRange(float distance) const;
122 
124  void pageInChildren(osg::NodeVisitor& nv, float distance);
125 
127  void pageOutChildren(int lastCullTime, osg::NodeList& toRemove);
128 
130  bool childrenLoaded() const;
131 
134  osg::ref_ptr<osg::Node> fileNode() const;
135 
138  osg::ref_ptr<osg::Node> rootNode() const;
139 
141  virtual bool addPagedInChild(Node* child);
142 
144  inline int getNumChildrenPagedIn() { return myPagedInCount; }
145 
147  void increaseCountUpToParents();
148 
150  void decreaseCountUpToParents(int amount);
151 
153  virtual void adjustLOD(Node* child);
154 
156  float fileRangeCullDistance2D(DtOsgCullVisitor& nv);
157 
159  bool fileInRange2D(float distance, float cull);
160 
162  float childRangeCullDistance2D(DtOsgCullVisitor& nv);
163 
165  bool fileInChildRange2D(float cull, float lod);
166 
168  void setThreadSafeRefUnref(bool threadSafe);
169 
171  virtual void resizeGLObjectBuffers(unsigned int maxSize);
172 
176  virtual void releaseGLObjects(osg::State* state) const;
177 
179  virtual std::string fileName() const;
180 
182  virtual const std::vector<osg::ref_ptr<DtHierarchicalPagedLod> >& children() const;
183 
186  virtual const osg::Matrix& fileTranslation() const;
187 
189  inline float getTileRadius() { return myTileRadius; }
190 
199  boost::signalslib::signal<void(osg::Group* page, osg::Node* child)> signal_childPagedIn;
200 
203  boost::signalslib::signal<void(osg::Group* page, osg::Node* child)> signal_childAboutToPageOut;
204 
205 
208  class DT_DLL_VRVOSG PagedFileRoot : public osg::MatrixTransform
209  {
210  public:
211  PagedFileRoot(DtHierarchicalPagedLod& parent, const osg::Matrixd& m, osg::Node* parentMetaflightGroup);
212 
213  //Override Add child to inform DtHierarchicalPagedLod of page in.
214  virtual bool addChild(Node* child);
215 
216  virtual const char* className() const;
217 
220  virtual osg::Node* parentMetaflightGroup() const;
221 
222  protected:
225 
226 
227  };
228 
229  protected:
230 
232  {
233  NotLoaded = 0,
235  Loaded
236  };
237 
238  osg::Vec3d myFileCenter;
239  osg::Vec3d myChildrenCenter;
240 
241  const float myRangeNear;
242  const float myRangeFar;
243  const float myTileRadius;
244  const float myChildTileRadius;
247 
248  volatile int myCullTracking;
249  std::string myFileName;
252 
253  std::vector<osg::ref_ptr<DtHierarchicalPagedLod> > myChildren;
256 
257  // Am I paged in + how many children are paged in
258  // so a tile that has 4 paged in children would have a count of 5
259  // a tile with no paged in children would have a count of 1
260  // because of DtHierarchicalPagedLod::fileInRange
261  // it looks like if the children are pagedIn, the parent is pagedIn
262  // (but not always displayed)
264 
266 
267  // The metaflight proxy objects are DtOsgArticulatedModels, they are put
268  // under a DtSceneObject so that they work when instancing is off
269  // The DtSceneObject doesn't have the transform, the articulated model does
270  // Maybe this can be eliminated
272 
273 #if DTHIERARCHICALPAGEDLOD_LOGGING
274  static int myHPLODRefCount;
275 #endif
276  };
277 }
volatile int myCullTracking
Definition: DtHierarchicalPagedLod.h:248
int myPagedInCount
Definition: DtHierarchicalPagedLod.h:263
osg::Vec3d myChildrenCenter
Definition: DtHierarchicalPagedLod.h:239
#define DT_DLL_VRVOSG
Definition: vrvOsg.h:23
boost::signalslib::signal< void(osg::Group *page, osg::Node *child)> signal_childAboutToPageOut
signal when a child is about to be paged out (i.e. data corresponding to it unloaded and the child re...
Definition: DtHierarchicalPagedLod.h:203
Contains makVrv::DtFastGroup class.
const float myRangeFar
Definition: DtHierarchicalPagedLod.h:242
int getNumChildrenPagedIn()
If we page in tiles, increase the paged-in count with parents.
Definition: DtHierarchicalPagedLod.h:144
DtOsgCullVisitor will inspect the camera to see which visual mode is active. If the visual mode is a ...
Definition: DtOsgCullVisitor.h:27
float getTileRadius()
Get tile radius (has 20% padding so bounds are not too tight)
Definition: DtHierarchicalPagedLod.h:189
FileState
Definition: DtHierarchicalPagedLod.h:231
std::vector< osg::ref_ptr< DtHierarchicalPagedLod > > myChildren
Definition: DtHierarchicalPagedLod.h:253
std::string myFileName
Definition: DtHierarchicalPagedLod.h:249
DT_DLL_VRVCORE double distance(const makVrv::DtCoordinateSystem &, const DtVector &from, const DtVector &to)
Returns the distance from the two points. Coordinates are in local database coordinates The coordinat...
boost::signalslib::signal< void(osg::Group *page, osg::Node *child)> signal_childPagedIn
signal when a child of &#39;page&#39; is paged in (i.e. added to the scenegraph) &#39;child&#39; can be other pages o...
Definition: DtHierarchicalPagedLod.h:199
SceneObjectMap mySceneObjs
Definition: DtHierarchicalPagedLod.h:271
DtHierarchicalPagedLod & myParent
Definition: DtHierarchicalPagedLod.h:223
osg::ref_ptr< PagedFileRoot > myFileRoot
Definition: DtHierarchicalPagedLod.h:251
DtDe & myDe
Definition: DtHierarchicalPagedLod.h:265
A Hierarchical paged LOD is a paged LOD which pages in a single file when the cull visitor is with-in...
Definition: DtHierarchicalPagedLod.h:39
const float myRangeNear
Definition: DtHierarchicalPagedLod.h:241
osg::Vec3d myFileCenter
Definition: DtHierarchicalPagedLod.h:238
const float myTileRadius
Definition: DtHierarchicalPagedLod.h:243
osg::Group with optimized removeChildren function
Definition: DtFastGroup.h:22
Definition: DtHierarchicalPagedLod.h:234
Base class to provide boost signal/slot management.
FileState myFileState
Definition: DtHierarchicalPagedLod.h:250
osg::ref_ptr< osg::Referenced > myPageRef
Definition: DtHierarchicalPagedLod.h:254
Contains makVrv::DtUniqueID type.
Contains DLL export macros.
std::unordered_map< DtUniqueID, DtSceneObject * > SceneObjectMap
Definition: DtHierarchicalPagedLod.h:43
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
const float myChildTileRadius
Definition: DtHierarchicalPagedLod.h:244
virtual const char * className() const
Definition: DtHierarchicalPagedLod.h:56
osg::ref_ptr< osgDB::Options > myOptions
Definition: DtHierarchicalPagedLod.h:255
const bool myChildrenAreSparse
Definition: DtHierarchicalPagedLod.h:245
Paged file root node, used to change the file state when the file is paged-in.
Definition: DtHierarchicalPagedLod.h:208
osg::Node * myParentMetaflightGroup
Definition: DtHierarchicalPagedLod.h:224
const bool myChildrenAreSubstitutive
Definition: DtHierarchicalPagedLod.h:246

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)