VR-Forces 5.0.2 Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
boundingNodeInfo.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 
10 #include <geometry/sphere.h>
11 #include <boost/shared_ptr.hpp>
12 #include <boost/unordered_map.hpp>
13 #include <boost/unordered_set.hpp>
14 #include <tbb/spin_mutex.h>
15 #include <osg/Matrix>
16 #include <vector>
17 
18 //Stores information about a paged out bounding volume.
20 {
21  DtNodeBoundingInfo(DtSphere boundingSphere, std::string filename, bool known=false)
22  : myBoundingSphere(boundingSphere)
23  , myOriginalBoundingSphere(boundingSphere)
24  , myFilename(filename)
25  {
26  }
27 
28  virtual void expandExtent(DtExtent& ext) const
29  {
30  ext.expandToInclude(extent());
31  }
32 
33  virtual DtExtent extent() const
34  {
35  return extentOfSphere(myBoundingSphere);
36  }
37 
38  virtual std::string filename() const
39  {
40  return myFilename;
41  }
42 
45  const std::string myFilename;
46 };
47 
50 {
52  DtNodeBoundingInfo boundingInfo,
53  unsigned int numTriangles,
54  DtTerrainIntersectIDType lastUsed = 0)
55  : myBoundingInfo(boundingInfo)
56  , myLastUsed(lastUsed)
57  , myNumTriangles(numTriangles)
58  , myPendingRemoval(false)
59  {
60  }
61 
63  const unsigned int myNumTriangles;
64 
66 
68  {
69  tbb::spin_mutex::scoped_lock lock(myMutex);
70  if (lastUsed > myLastUsed)
71  {
72  myLastUsed = lastUsed;
73  }
74  }
75 
77  {
78  tbb::spin_mutex::scoped_lock lock(myMutex);
79  return myLastUsed;
80  }
81 
82 protected:
83  mutable tbb::spin_mutex myMutex;
85 };
86 
87 typedef DtBoost::shared_ptr<DtNodeBoundingInfo> DtNodeBoundingInfoPtr;
88 typedef DtBoost::shared_ptr<DtPagedNodeStatus> DtPagedNodeStatusPtr;
89 
91 inline std::size_t hash_value(const DtNodeBoundingInfoPtr& p)
92 {
93  boost::hash<DtNodeBoundingInfo*> hasher;
94  return hasher(p.get());
95 }
96 
98 {
99  DtPagedInExtendInfo(const DtNodeBoundingInfoPtr& nodeBoundingInfoPtr, const osg::Matrix& matrix):
100  myNodeBoundingInfoPtr(nodeBoundingInfoPtr),
101  myMatrix(matrix)
102  {
103  }
105  myNodeBoundingInfoPtr(rh.myNodeBoundingInfoPtr),
106  myMatrix(rh.myMatrix)
107  {
108  for (size_t i = 0; i < rh.myAssociatedDrawable.size(); i++)
109  {
110  myAssociatedDrawable.push_back(rh.myAssociatedDrawable[i]);
111  }
112  for (size_t i = 0; i < rh.myNbTriangles.size(); i++)
113  {
114  myNbTriangles.push_back(rh.myNbTriangles[i]);
115  }
116  }
118  {
119  }
120 
121 public:
123  osg::Matrix myMatrix;
124  std::vector<DtNodeId> myAssociatedDrawable;
125  std::vector<size_t> myAssociatedDrawableId;
127  std::vector<size_t> myNbTriangles;
128 };
129 
130 typedef std::list<DtNodeBoundingInfoPtr> DtNodeBoundingInfoList;
131 typedef boost::unordered_set<DtNodeBoundingInfoPtr> DtNodeBoundingInfoSet;
132 typedef boost::unordered_map<DtNodeId, DtNodeBoundingInfoPtr> DtNodeBoundingInfoMap;
133 typedef boost::unordered_map<DtNodeId, DtPagedInExtendInfo> DtNodeBoundingExtendedInfoMap;
134 typedef boost::unordered_map<DtNodeId, DtPagedNodeStatusPtr> DtPagedNodeStatusMap;
135 
DtBoost::shared_ptr< DtNodeBoundingInfo > DtNodeBoundingInfoPtr
Definition: boundingNodeInfo.h:87
boost::unordered_map< DtNodeId, DtPagedInExtendInfo > DtNodeBoundingExtendedInfoMap
Definition: boundingNodeInfo.h:133
DtNodeBoundingInfo(DtSphere boundingSphere, std::string filename, bool known=false)
Definition: boundingNodeInfo.h:21
DtTerrainIntersectIDType lastUsed() const
Definition: boundingNodeInfo.h:76
DtBoost::shared_ptr< DtPagedNodeStatus > DtPagedNodeStatusPtr
Definition: boundingNodeInfo.h:88
boost::unordered_map< DtNodeId, DtNodeBoundingInfoPtr > DtNodeBoundingInfoMap
Definition: boundingNodeInfo.h:132
Definition: sphere.h:22
DtPagedNodeStatus(DtNodeBoundingInfo boundingInfo, unsigned int numTriangles, DtTerrainIntersectIDType lastUsed=0)
Definition: boundingNodeInfo.h:51
Definition: boundingNodeInfo.h:97
const DtSphere myOriginalBoundingSphere
Definition: boundingNodeInfo.h:44
boost::unordered_map< DtNodeId, DtPagedNodeStatusPtr > DtPagedNodeStatusMap
Definition: boundingNodeInfo.h:134
The DtExtent represents an axis-aligned 3d bounding box.
Definition: extent.h:43
std::list< DtNodeBoundingInfoPtr > DtNodeBoundingInfoList
Definition: boundingNodeInfo.h:130
virtual void expandToInclude(const DtExtent &otherExtent)
Expand extent, if necessary, to include input extent.
bool myPendingRemoval
Definition: boundingNodeInfo.h:65
virtual DtExtent extent() const
Definition: boundingNodeInfo.h:33
std::vector< size_t > myNbTriangles
triangles by drawable
Definition: boundingNodeInfo.h:127
DtSphere myBoundingSphere
Definition: boundingNodeInfo.h:43
const unsigned int myNumTriangles
Definition: boundingNodeInfo.h:63
DT_DLL_geometry DtExtent extentOfSphere(const DtSphere &sphere)
const std::string myFilename
Definition: boundingNodeInfo.h:45
DtTerrainIntersectIDType myLastUsed
Definition: boundingNodeInfo.h:84
std::vector< size_t > myAssociatedDrawableId
Definition: boundingNodeInfo.h:125
DtNodeBoundingInfoPtr myNodeBoundingInfoPtr
Definition: boundingNodeInfo.h:122
Stores the status of a paged in bounding volume.
Definition: boundingNodeInfo.h:49
void updateLastUsed(DtTerrainIntersectIDType lastUsed)
Definition: boundingNodeInfo.h:67
DtPagedInExtendInfo(const DtPagedInExtendInfo &rh)
Definition: boundingNodeInfo.h:104
Definition: boundingNodeInfo.h:19
std::size_t hash_value(const DtNodeBoundingInfoPtr &p)
needed for boost::unordered
Definition: boundingNodeInfo.h:91
std::vector< DtNodeId > myAssociatedDrawable
Definition: boundingNodeInfo.h:124
osg::Matrix myMatrix
Definition: boundingNodeInfo.h:123
DtPagedInExtendInfo(const DtNodeBoundingInfoPtr &nodeBoundingInfoPtr, const osg::Matrix &matrix)
Definition: boundingNodeInfo.h:99
virtual std::string filename() const
Definition: boundingNodeInfo.h:38
#define DT_DLL_vantageTerrainImplementation
This file is used to determine how to build.
Definition: vantageTerrainImplementationDefines.h:28
tbb::spin_mutex myMutex
Definition: boundingNodeInfo.h:83
virtual void expandExtent(DtExtent &ext) const
Definition: boundingNodeInfo.h:28
DtPagedInExtendInfo()
Definition: boundingNodeInfo.h:117
boost::unordered_set< DtNodeBoundingInfoPtr > DtNodeBoundingInfoSet
Definition: boundingNodeInfo.h:131
const DtNodeBoundingInfo myBoundingInfo
Definition: boundingNodeInfo.h:62

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)