VR-Forces 5.0.1 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) 2021 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 <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, osg::Node* parentMetaflightGroup);
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::signalslib::signal<void(osg::Group* page, osg::Node* child)> signal_childPagedIn;
201 
204  boost::signalslib::signal<void(osg::Group* page, osg::Node* child)> signal_childAboutToPageOut;
205 
206 
209  class DT_DLL_VRVOSG PagedFileRoot : public osg::MatrixTransform
210  {
211  public:
212  PagedFileRoot(DtHierarchicalPagedLod& parent, const osg::Matrixd& m, osg::Node* parentMetaflightGroup);
213 
214  //Override Add child to inform DtHierarchicalPagedLod of page in.
215  virtual bool addChild(Node* child);
216 
217  virtual const char* className() const;
218 
221  virtual osg::Node* parentMetaflightGroup() const;
222 
223  protected:
226 
227 
228  };
229 
230  protected:
231 
233  {
234  NotLoaded = 0,
236  Loaded
237  };
238 
239  osg::Vec3d myFileCenter;
240  osg::Vec3d myChildrenCenter;
241 
242  const float myRangeNear;
243  const float myRangeFar;
244  const float myTileRadius;
245  const float myChildTileRadius;
248 
249  volatile int myCullTracking;
250  std::string myFileName;
253 
254  std::vector<osg::ref_ptr<DtHierarchicalPagedLod> > myChildren;
257 
258  // Am I paged in + how many children are paged in
259  // so a tile that has 4 paged in children would have a count of 5
260  // a tile with no paged in children would have a count of 1
261  // because of DtHierarchicalPagedLod::fileInRange
262  // it looks like if the children are pagedIn, the parent is pagedIn
263  // (but not always displayed)
265 
267 
268  // The metaflight proxy objects are DtOsgArticulatedModels, they are put
269  // under a DtSceneObject so that they work when instancing is off
270  // The DtSceneObject doesn't have the transform, the articulated model does
271  // Maybe this can be eliminated
273 
275 
276 #if DTHIERARCHICALPAGEDLOD_LOGGING
277  static int myHPLODRefCount;
278 #endif
279  };
280 }
volatile int myCullTracking
Definition: DtHierarchicalPagedLod.h:249
int myPagedInCount
Definition: DtHierarchicalPagedLod.h:264
osg::Vec3d myChildrenCenter
Definition: DtHierarchicalPagedLod.h:240
#define DT_DLL_VRVOSG
Definition: vrvOsg.h:23
boost::unordered_map< DtUniqueID, DtSceneObject * > SceneObjectMap
Definition: DtHierarchicalPagedLod.h:44
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:204
Contains makVrv::DtFastGroup class.
const float myRangeFar
Definition: DtHierarchicalPagedLod.h:243
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. 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:190
FileState
Definition: DtHierarchicalPagedLod.h:232
std::vector< osg::ref_ptr< DtHierarchicalPagedLod > > myChildren
Definition: DtHierarchicalPagedLod.h:254
std::string myFileName
Definition: DtHierarchicalPagedLod.h:250
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:200
SceneObjectMap mySceneObjs
Definition: DtHierarchicalPagedLod.h:272
DtHierarchicalPagedLod & myParent
Definition: DtHierarchicalPagedLod.h:224
osg::ref_ptr< PagedFileRoot > myFileRoot
Definition: DtHierarchicalPagedLod.h:252
DtDe & myDe
Definition: DtHierarchicalPagedLod.h:266
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:242
osg::Vec3d myFileCenter
Definition: DtHierarchicalPagedLod.h:239
const float myTileRadius
Definition: DtHierarchicalPagedLod.h:244
osg::Group with optimized removeChildren function
Definition: DtFastGroup.h:22
osg::ref_ptr< DtOsgOcclusionQueryNode > myOcclusionNode
Definition: DtHierarchicalPagedLod.h:274
Definition: DtHierarchicalPagedLod.h:235
Base class to provide boost signal/slot management.
FileState myFileState
Definition: DtHierarchicalPagedLod.h:251
osg::ref_ptr< osg::Referenced > myPageRef
Definition: DtHierarchicalPagedLod.h:255
Contains makVrv::DtUniqueID type.
Contains DLL export macros.
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
const float myChildTileRadius
Definition: DtHierarchicalPagedLod.h:245
virtual const char * className() const
Definition: DtHierarchicalPagedLod.h:57
osg::ref_ptr< osgDB::Options > myOptions
Definition: DtHierarchicalPagedLod.h:256
const bool myChildrenAreSparse
Definition: DtHierarchicalPagedLod.h:246
Paged file root node, used to change the file state when the file is paged-in.
Definition: DtHierarchicalPagedLod.h:209
osg::Node * myParentMetaflightGroup
Definition: DtHierarchicalPagedLod.h:225
const bool myChildrenAreSubstitutive
Definition: DtHierarchicalPagedLod.h:247

Document ID: Generated on Mon Jun 20 00:38:30 EDT 2022 from SVN revision 244029
Copyright © 2005-2021 MAK Technologies. All Rights Reserved (www.mak.com)