VR-Forces 4.8 Class Documentation
 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) 2018 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 
19 #include <osg/Vec3>
20 #include <osg/MatrixTransform>
21 
22 #include <osgDB/Options>
23 
24 #include <boost/signals.hpp>
25 #include <boost/unordered_map.hpp>
26 
27 #define DTHIERARCHICALPAGEDLOD_LOGGING 0
28 
29 namespace makVrv
30 {
31  class DtOsgCullVisitor;
32  class DtOsgArticulatedModel;
33  class DtModelDefinition;
34  class DtOsgOcclusionQueryNode;
35 
41  {
42  public:
43 
44  typedef boost::unordered_map<DtUniqueID, DtSceneObject* > SceneObjectMap;
45 
47  DtHierarchicalPagedLod(DtDe& de, const std::string& filename,
48  float distanceNear, float distanceFar, float tileRadius,
49  float childTileRadius, const osg::Vec3d& fileCenter,
50  const osg::Vec3d& childrenCenter, bool sparseChildren,
51  bool substitutiveChildren, const osg::Matrixd& fileTranslation,
52  osgDB::Options* options);
53 
55  virtual ~DtHierarchicalPagedLod();
56 
57  virtual const char* className() const { return "DtHierarchicalPagedLod"; }
58 
63  void addChildHierarchy(DtHierarchicalPagedLod* child);
64 
66  virtual void traverse(osg::NodeVisitor& nv);
67 
69  virtual void traverseAll(osg::NodeVisitor& nv);
70 
72  virtual void traverseActive(osg::NodeVisitor& nv);
73 
76  virtual void cullActive(osg::NodeVisitor& nv);
77 
79  void cullActive2D(DtOsgCullVisitor& nv);
80 
82  void cullActive3D(osg::NodeVisitor& nv);
83 
85  virtual osg::BoundingSphere computeBound() const;
86 
89  virtual void traverseFile(osg::NodeVisitor& nv, float distance);
90 
93  virtual void traverseChildren(osg::NodeVisitor& nv);
94 
96  virtual bool fileInRange(float distance) const;
97 
99  virtual float fileRangeDistance(osg::NodeVisitor& nv) const;
100 
102  virtual float childRangeDistance(osg::NodeVisitor& nv) const;
103 
105  void pageInFile(osg::NodeVisitor& nv, float distance);
106 
109  void pageOutFile(int lastCullTime, osg::NodeList& toRemove);
110 
113  bool fileNotLoaded() const;
114 
116  bool fileIsPaging() const;
117 
119  bool fileIsLoaded() const;
120 
122  virtual bool fileInChildRange(float distance) const;
123 
125  void pageInChildren(osg::NodeVisitor& nv, float distance);
126 
128  void pageOutChildren(int lastCullTime, osg::NodeList& toRemove);
129 
131  bool childrenLoaded() const;
132 
135  osg::ref_ptr<osg::Node> fileNode() const;
136 
139  osg::ref_ptr<osg::Node> rootNode() const;
140 
142  virtual bool addPagedInChild(Node* child);
143 
145  inline int getNumChildrenPagedIn() { return myPagedInCount; }
146 
148  void increaseCountUpToParents();
149 
151  void decreaseCountUpToParents(int amount);
152 
154  virtual void adjustLOD(Node* child);
155 
157  float fileRangeCullDistance2D(DtOsgCullVisitor& nv);
158 
160  bool fileInRange2D(float distance, float cull);
161 
163  float childRangeCullDistance2D(DtOsgCullVisitor& nv);
164 
166  bool fileInChildRange2D(float cull, float lod);
167 
169  void setThreadSafeRefUnref(bool threadSafe);
170 
172  virtual void resizeGLObjectBuffers(unsigned int maxSize);
173 
177  virtual void releaseGLObjects(osg::State* state) const;
178 
180  virtual std::string fileName() const;
181 
183  virtual const std::vector<osg::ref_ptr<DtHierarchicalPagedLod> >& children() const;
184 
187  virtual const osg::Matrix& fileTranslation() const;
188 
190  inline float getTileRadius() { return myTileRadius; }
191 
200  boost::signal<void(osg::Group* page, osg::Node* child)> signal_childPagedIn;
201 
204  boost::signal<void(osg::Group* page, osg::Node* child)> signal_childAboutToPageOut;
205 
206  protected:
207 
209  {
210  NotLoaded = 0,
212  Loaded
213  };
214 
217  class DT_DLL_VRVOSG PagedFileRoot : public osg::MatrixTransform
218  {
219  public:
220  PagedFileRoot(DtHierarchicalPagedLod& parent, const osg::Matrixd& m);
221 
222  //Override Add child to inform DtHierarchicalPagedLod of page in.
223  virtual bool addChild(Node *child);
224 
225  virtual const char* className() const;
226 
227  protected:
229 
230  };
231 
232  osg::Vec3d myFileCenter;
233  osg::Vec3d myChildrenCenter;
234 
235  const float myRangeNear;
236  const float myRangeFar;
237  const float myTileRadius;
238  const float myChildTileRadius;
241 
242  volatile int myCullTracking;
243  std::string myFileName;
246 
247  std::vector<osg::ref_ptr<DtHierarchicalPagedLod> > myChildren;
250 
251  // Am I paged in + how many children are paged in
252  // so a tile that has 4 paged in children would have a count of 5
253  // a tile with no paged in children would have a count of 1
254  // because of DtHierarchicalPagedLod::fileInRange
255  // it looks like if the children are pagedIn, the parent is pagedIn
256  // (but not always displayed)
258 
260 
261  // The metaflight proxy objects are DtOsgArticulatedModels, they are put
262  // under a DtSceneObject so that they work when instancing is off
263  // The DtSceneObject doesn't have the transform, the articulated model does
264  // Maybe this can be eliminated
266 
268 
269 #if DTHIERARCHICALPAGEDLOD_LOGGING
270  static int myHPLODRefCount;
271 #endif
272  };
273 }
volatile int myCullTracking
Definition: DtHierarchicalPagedLod.h:242
int myPagedInCount
Definition: DtHierarchicalPagedLod.h:257
osg::Vec3d myChildrenCenter
Definition: DtHierarchicalPagedLod.h:233
#define DT_DLL_VRVOSG
Definition: vrvOsg.h:23
boost::unordered_map< DtUniqueID, DtSceneObject * > SceneObjectMap
Definition: DtHierarchicalPagedLod.h:44
Contains makVrv::DtFastGroup class.
const float myRangeFar
Definition: DtHierarchicalPagedLod.h:236
int getNumChildrenPagedIn()
If we page in tiles, increase the paged-in count with parents.
Definition: DtHierarchicalPagedLod.h:145
DtOsgCullVisitor will inspect the camera to see which visual mode is active.
Definition: DtOsgCullVisitor.h:25
float getTileRadius()
Get tile radius (has 20% padding so bounds are not too tight)
Definition: DtHierarchicalPagedLod.h:190
FileState
Definition: DtHierarchicalPagedLod.h:208
boost::signal< void(osg::Group *page, osg::Node *child)> signal_childAboutToPageOut
signal when a child is about to be paged out (i.e.
Definition: DtHierarchicalPagedLod.h:204
std::vector< osg::ref_ptr< DtHierarchicalPagedLod > > myChildren
Definition: DtHierarchicalPagedLod.h:247
std::string myFileName
Definition: DtHierarchicalPagedLod.h:243
DT_DLL_VRVCORE double distance(const makVrv::DtCoordinateSystem &, const DtVector &from, const DtVector &to)
Returns the distance from the two points.
SceneObjectMap mySceneObjs
Definition: DtHierarchicalPagedLod.h:265
DtHierarchicalPagedLod & myParent
Definition: DtHierarchicalPagedLod.h:228
osg::ref_ptr< PagedFileRoot > myFileRoot
Definition: DtHierarchicalPagedLod.h:245
DtDe & myDe
Definition: DtHierarchicalPagedLod.h:259
A Hierarchical paged LOD is a paged LOD which pages in a single file when the cull visitor is with-in...
Definition: DtHierarchicalPagedLod.h:40
const float myRangeNear
Definition: DtHierarchicalPagedLod.h:235
osg::Vec3d myFileCenter
Definition: DtHierarchicalPagedLod.h:232
const float myTileRadius
Definition: DtHierarchicalPagedLod.h:237
osg::Group with optimized removeChildren function
Definition: DtFastGroup.h:22
osg::ref_ptr< DtOsgOcclusionQueryNode > myOcclusionNode
Definition: DtHierarchicalPagedLod.h:267
Definition: DtHierarchicalPagedLod.h:211
Base class to provide boost signal/slot management.
FileState myFileState
Definition: DtHierarchicalPagedLod.h:244
osg::ref_ptr< osg::Referenced > myPageRef
Definition: DtHierarchicalPagedLod.h:248
Contains makVrv::DtUniqueID type.
Contains DLL export macros.
The DtDe is the core component of any VR-Vantage application.
Definition: DtDe.h:69
const float myChildTileRadius
Definition: DtHierarchicalPagedLod.h:238
virtual const char * className() const
Definition: DtHierarchicalPagedLod.h:57
osg::ref_ptr< osgDB::Options > myOptions
Definition: DtHierarchicalPagedLod.h:249
const bool myChildrenAreSparse
Definition: DtHierarchicalPagedLod.h:239
Paged file root node, used to change the file state when the file is paged-in.
Definition: DtHierarchicalPagedLod.h:217
const bool myChildrenAreSubstitutive
Definition: DtHierarchicalPagedLod.h:240
boost::signal< void(osg::Group *page, osg::Node *child)> signal_childPagedIn
signal when a child of &#39;page&#39; is paged in (i.e.
Definition: DtHierarchicalPagedLod.h:200

Document ID: Generated on Thu Aug 27 10:56:05 EDT 2020 from SVN revision 217100
Copyright © 2005-2020 MAK Technologies. All Rights Reserved (www.mak.com)