VR-Forces Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
pagedNode2Visitors.h
Go to the documentation of this file.
1 /****************************************************************************
2  * Copyright (c) 2021 MAK Technologies, Inc.
3  * All rights reserved.
4  ****************************************************************************/
5 
6 #pragma once
7 
15 
16 #include <osg/NodeVisitor>
17 #include <osg/Referenced>
18 #include <osg/ref_ptr>
19 #include <osg/Node>
20 #include <osg/LightSource>
21 #include <osgEarth/PagedNode>
22 
23 #include <geometry/chord.h>
24 
25 #include <set>
26 #include <vector>
27 #include <unordered_set>
28 
32 
33 typedef std::vector<osg::Matrix> MatrixStack;
34 
38 {
39 public:
40 
42  virtual ~DtTerrainIsPagedNode2Visitor() override;
43 
45  virtual void apply(osg::Node& node) override;
46 
48  virtual const bool encounteredPagedNode2() const;
49 
50 protected:
51 
54 };
55 
56 
58 {
59 public:
61  : myStack(stack)
62  , myTmpTop(myStack.top())
63  {
64  myStack.pop();
65  }
67  {
68  myStack.push(myTmpTop);
69  }
70  std::stack <osg::ref_ptr<osg::Node> >& myStack;
72 };
73 
77 {
78 public:
80 
81  bool isFullyLoaded() const;
82  virtual void apply(osg::Node& node) override;
83  void apply(osgEarth::PagedNode2& pagedNode);
85  virtual void apply(osg::PagedLOD& node) override;
86  virtual void apply(osg::LightSource& ls) override;
87 
88  void manualUpdate();
89  virtual void reset() override;
90  size_t count() { return myCount; }
91 
92  void setNodePathHint(const std::stack <osg::ref_ptr<osg::Node> >& hint)
93  {
94  myNodePathHint = hint;
95  }
96 protected:
97 
103  std::set < osg::ref_ptr < osgEarth::PagingManager> > myPagingManagers;
104 
105  std::set< std::string > myLoadingList;
106  std::stack <osg::ref_ptr<osg::Node> > myNodePathHint;
107  size_t myCount;
108 };
109 
110 
114 {
115 public:
117  const DrawableList& existingDrawable, DrawableMap& newDrawable, DtNodeBoundingExtendedInfoMap& pagedInBoundingMap,
118  const NodePagingRecordMap& pagedInNodes);
119 
120  virtual void apply(osg::Node& node) override;
121  void apply(osgEarth::PagedNode2& pagedNode);
122  virtual void apply(osg::Drawable& drawable) override;
124  virtual void apply(osg::PagedLOD& node) override;
125  virtual void apply(osg::LightSource& ls) override;
126 
127 
128 protected:
129 
132  {
134  {
135  verts = new osg::Vec3Array();
136  }
137 #if OSG_VERSION_LESS_THAN(3,5,6)
138  inline void operator () (const osg::Vec3& v1, const osg::Vec3& v2, const osg::Vec3& v3, bool treatVertexDataAsTemporary)
139 #else
140  inline void operator () (const osg::Vec3& v1, const osg::Vec3& v2, const osg::Vec3& v3)
141 #endif
142  {
143  verts->push_back(v1);
144  verts->push_back(v2);
145  verts->push_back(v3);
146  }
148  };
149 
150  inline void pushPagedNode2(osgEarth::PagedNode2& pagedNode2) { myPagedNode2Stack.push_back(&pagedNode2); }
151  inline void popPagedNode2() { myPagedNode2Stack.pop_back(); }
152 
153  typedef std::vector<DtNodeId> PagedNode2Stack;
159 };
160 
164 {
165 public:
167 
168  virtual void apply(osg::Node& node) override;
169  void manualUpdate();
170  bool isUnloaded();
171 
172 protected:
173 
177  std::set < osg::ref_ptr < osgEarth::PagingManager> > myPagingManagers;
178 };
179 
183 {
184 public:
186 
187  PagedNode2ActiveVisitor(const NodePagingRecordMap& pagedInNode, const NodePagingRecordMap& emptyPagedInNode,
188  NodePagingRecordMap& pagedOutNodes);
189  virtual void apply(osg::Node& node) override;
190  void apply(osgEarth::PagedNode2& pagedNode);
191  virtual void apply(osg::LightSource& ls) override;
192 
193 protected:
194 
196  bool addToPagedOutVolumesList(DtNodeBoundingInfo* pagedOutArea);
197 
202  std::set< osg::Node* > _traversedNodes;
203  int _level;
206  std::unordered_map<std::string, DtNodeBoundingInfoPtr> myPagedOutBoundingListIndex;
207 };
208 
210 {
211 public:
213 
214  virtual void apply(osg::Node& node) override;
215  void apply(osgEarth::PagedNode2& pagedNode);
216 
217 
218  void manualUpdate();
219  const std::stack< osg::ref_ptr < osg::Node> >& nodesTraveled() const
220  {
221  return myNodesTraveledInReverse;
222  }
223 
224 public:
225  std::set < osg::ref_ptr < osgEarth::PagingManager> > myPagingManagers;
226  std::stack < osg::ref_ptr < osg::Node> > myNodesTraveledInReverse;
227 
228 };
229 
231 size_t getDrawableHash(const osg::Drawable& drawable, const osg::Matrix& matrix);
boost::unordered_map< DtNodeId, DtPagedInExtendInfo > DtNodeBoundingExtendedInfoMap
Definition: boundingNodeInfo.h:140
const NodePagingRecordMap & myPagedInNodes
Holds all the nodes which have been paged in.
Definition: pagedNode2Visitors.h:199
bool addToPagedOutVolumesList(DtNodeBoundingInfoPtr pagedOutArea)
osg::ref_ptr< osg::Vec3Array > verts
Definition: pagedNode2Visitors.h:147
virtual void apply(osg::Transform &node) override
bool myPagedNode2encountered
Definition: pagedNode2Visitors.h:176
void setNodePathHint(const std::stack< osg::ref_ptr< osg::Node > > &hint)
Definition: pagedNode2Visitors.h:92
osg::ref_ptr< osg::Node > myTmpTop
Definition: pagedNode2Visitors.h:71
size_t getDrawableHash(const osg::Drawable &drawable, const osg::Matrix &matrix)
Return a unique ID for a drawable and it&#39;s matrix.
Visitor that tracks whether any part of the terrain contain a pagedNode2.
Definition: pagedNode2Visitors.h:37
Visitor that collect the triangles once pagedNode2 data are loaded in the intersecting area...
Definition: pagedNode2Visitors.h:113
std::stack< osg::ref_ptr< osg::Node > > myNodePathHint
Definition: pagedNode2Visitors.h:106
std::vector< osg::Matrix > MatrixStack
Definition: pagedNode2Visitors.h:33
structure to retrieve the triangles
Definition: pagedNode2Visitors.h:131
std::unordered_map< std::string, NodePagingRecord > NodePagingRecordMap
Definition: vantageTerrainImplementationUtil.h:103
Visitor that load all the pagedNode2 data that intersecting with an area.
Definition: pagedNode2Visitors.h:76
std::unordered_map< std::string, DtNodeBoundingInfoPtr > myPagedOutBoundingListIndex
This is an indexed version of myPagedOutBoundingList (from parent class) so that it is quicker to loo...
Definition: pagedNode2Visitors.h:206
std::set< osg::Node * > _traversedNodes
Definition: pagedNode2Visitors.h:202
DrawableMap & myNewDrawable
Definition: pagedNode2Visitors.h:156
size_t myCount
Definition: pagedNode2Visitors.h:107
DtScopedNodeStackPoopPusher(std::stack< osg::ref_ptr< osg::Node > > &stack)
Definition: pagedNode2Visitors.h:60
PagedNode2Stack myPagedNode2Stack
Definition: pagedNode2Visitors.h:154
std::set< std::string > myLoadingList
Definition: pagedNode2Visitors.h:105
const DrawableList & myExistingDrawable
Definition: pagedNode2Visitors.h:155
Subclass of DtPageInVisitor which pages in only nodes that fall along a particular geometry...
Definition: pageInVisitor.h:104
Definition: coordSystem.h:54
std::shared_ptr< DtTerrainPagingGeometry > DtTerrainPagingGeometryPtr
Definition: terrainPagingGeometry.h:46
std::vector< DtNodeId > PagedNode2Stack
Definition: pagedNode2Visitors.h:153
DtNodeBoundingExtendedInfoMap & myPagedInBoundingMap
Definition: pagedNode2Visitors.h:157
const NodePagingRecordMap & myPagedInNodes
Definition: pagedNode2Visitors.h:158
Visitor class used to find the active paged of a OSG scene graph.
Definition: boundingVolumeTerrainSourcePager.h:48
std::set< osg::ref_ptr< osgEarth::PagingManager > > myPagingManagers
Definition: pagedNode2Visitors.h:103
std::map< size_t, DrawableInfo > DrawableMap
Definition: vantageTerrainImplementationUtil.h:85
std::shared_ptr< DtNodeBoundingInfo > DtNodeBoundingInfoPtr
Definition: boundingNodeInfo.h:94
Visitor that unload a pageNode2.
Definition: pagedNode2Visitors.h:163
NodePagingRecordMap & myPagedNode2OutNodes
Definition: pagedNode2Visitors.h:200
bool myFullyLoaded
Fully loaded is initially set to true then when traversing the scene graph it will check if all inter...
Definition: pagedNode2Visitors.h:102
void popPagedNode2()
Definition: pagedNode2Visitors.h:151
virtual void apply(osg::LOD &node) override
CollectTriangles()
Definition: pagedNode2Visitors.h:133
void pushPagedNode2(osgEarth::PagedNode2 &pagedNode2)
Definition: pagedNode2Visitors.h:150
vrf includes
Definition: boundingNodeInfo.h:28
osg::ref_ptr< osg::Node > myPagedNode2ToUnload
Definition: pagedNode2Visitors.h:174
A DtChord is a finite line segment in 3-space, represented by two points. Data derived from the two e...
std::set< osg::ref_ptr< osgEarth::PagingManager > > myPagingManagers
Definition: pagedNode2Visitors.h:225
#define DT_DLL_vantageTerrainImplementation
This file is used to determine how to build.
Definition: vantageTerrainImplementationDefines.h:28
std::stack< osg::ref_ptr< osg::Node > > & myStack
Definition: pagedNode2Visitors.h:70
std::stack< osg::ref_ptr< osg::Node > > myNodesTraveledInReverse
Definition: pagedNode2Visitors.h:226
Definition: pagedNode2Visitors.h:57
virtual ~DtScopedNodeStackPoopPusher()
Definition: pagedNode2Visitors.h:66
bool myEncounteredPagedNode2
Whether or not the visitor has yet encountered a pagedNode2 node.
Definition: pagedNode2Visitors.h:53
size_t count()
Definition: pagedNode2Visitors.h:90
std::set< size_t > DrawableList
Definition: vantageTerrainImplementationUtil.h:84
const NodePagingRecordMap & myEmptyPagedInNodes
Definition: pagedNode2Visitors.h:201
Visitor that check loaded (active page in/out bounding sphere) pagedNode2.
Definition: pagedNode2Visitors.h:182
int _level
Definition: pagedNode2Visitors.h:203
Definition: pagedNode2Visitors.h:209
bool myEndTraversal
Definition: pagedNode2Visitors.h:175
const std::stack< osg::ref_ptr< osg::Node > > & nodesTraveled() const
Definition: pagedNode2Visitors.h:219
std::set< osg::ref_ptr< osgEarth::PagingManager > > myPagingManagers
Definition: pagedNode2Visitors.h:177

Document ID: Generated on Thu Oct 23 22:29:17 EDT 2025 from SVN revision 280951
Copyright © 2005-2024 MAK Technologies. All Rights Reserved (www.mak.com)