VR-Forces 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  if (lastUsed > myLastUsed)
70  {
71  myLastUsed = lastUsed;
72  }
73  }
74 
76  {
77  return myLastUsed;
78  }
79 
80 protected:
81 
82  std::atomic <DtTerrainIntersectIDType> myLastUsed;
83 };
84 
85 typedef DtBoost::shared_ptr<DtNodeBoundingInfo> DtNodeBoundingInfoPtr;
86 typedef DtBoost::shared_ptr<DtPagedNodeStatus> DtPagedNodeStatusPtr;
87 
89 inline std::size_t hash_value(const DtNodeBoundingInfoPtr& p)
90 {
91  boost::hash<DtNodeBoundingInfo*> hasher;
92  return hasher(p.get());
93 }
94 
96 {
97  DtPagedInExtendInfo(const DtNodeBoundingInfoPtr& nodeBoundingInfoPtr, const osg::Matrix& matrix):
98  myNodeBoundingInfoPtr(nodeBoundingInfoPtr),
99  myMatrix(matrix)
100  {
101  }
103  myNodeBoundingInfoPtr(rh.myNodeBoundingInfoPtr),
104  myMatrix(rh.myMatrix)
105  {
106  for (size_t i = 0; i < rh.myAssociatedDrawable.size(); i++)
107  {
108  myAssociatedDrawable.push_back(rh.myAssociatedDrawable[i]);
109  }
110  for (size_t i = 0; i < rh.myNbTriangles.size(); i++)
111  {
112  myNbTriangles.push_back(rh.myNbTriangles[i]);
113  }
114  }
116  {
117  }
118 
119 public:
121  osg::Matrix myMatrix;
122  std::vector<DtNodeId> myAssociatedDrawable;
123  std::vector<size_t> myAssociatedDrawableId;
125  std::vector<size_t> myNbTriangles;
126 };
127 
128 typedef std::list<DtNodeBoundingInfoPtr> DtNodeBoundingInfoList;
129 typedef boost::unordered_set<DtNodeBoundingInfoPtr> DtNodeBoundingInfoSet;
130 typedef boost::unordered_map<DtNodeId, DtNodeBoundingInfoPtr> DtNodeBoundingInfoMap;
131 typedef boost::unordered_map<DtNodeId, DtPagedInExtendInfo> DtNodeBoundingExtendedInfoMap;
132 typedef boost::unordered_map<DtNodeId, DtPagedNodeStatusPtr> DtPagedNodeStatusMap;
133 
DtBoost::shared_ptr< DtNodeBoundingInfo > DtNodeBoundingInfoPtr
Definition: boundingNodeInfo.h:85
boost::unordered_map< DtNodeId, DtPagedInExtendInfo > DtNodeBoundingExtendedInfoMap
Definition: boundingNodeInfo.h:131
DtNodeBoundingInfo(DtSphere boundingSphere, std::string filename, bool known=false)
Definition: boundingNodeInfo.h:21
DtTerrainIntersectIDType lastUsed() const
Definition: boundingNodeInfo.h:75
DtBoost::shared_ptr< DtPagedNodeStatus > DtPagedNodeStatusPtr
Definition: boundingNodeInfo.h:86
boost::unordered_map< DtNodeId, DtNodeBoundingInfoPtr > DtNodeBoundingInfoMap
Definition: boundingNodeInfo.h:130
Definition: sphere.h:22
DtPagedNodeStatus(DtNodeBoundingInfo boundingInfo, unsigned int numTriangles, DtTerrainIntersectIDType lastUsed=0)
Definition: boundingNodeInfo.h:51
Definition: boundingNodeInfo.h:95
const DtSphere myOriginalBoundingSphere
Definition: boundingNodeInfo.h:44
boost::unordered_map< DtNodeId, DtPagedNodeStatusPtr > DtPagedNodeStatusMap
Definition: boundingNodeInfo.h:132
unsigned long long DtTerrainIntersectIDType
Definition: terrainInterfaceDefines.h:28
The DtExtent represents an axis-aligned 3d bounding box.
Definition: extent.h:43
std::list< DtNodeBoundingInfoPtr > DtNodeBoundingInfoList
Definition: boundingNodeInfo.h:128
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:125
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
std::vector< size_t > myAssociatedDrawableId
Definition: boundingNodeInfo.h:123
DtNodeBoundingInfoPtr myNodeBoundingInfoPtr
Definition: boundingNodeInfo.h:120
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:102
Definition: boundingNodeInfo.h:19
std::size_t hash_value(const DtNodeBoundingInfoPtr &p)
needed for boost::unordered
Definition: boundingNodeInfo.h:89
std::vector< DtNodeId > myAssociatedDrawable
Definition: boundingNodeInfo.h:122
osg::Matrix myMatrix
Definition: boundingNodeInfo.h:121
DtPagedInExtendInfo(const DtNodeBoundingInfoPtr &nodeBoundingInfoPtr, const osg::Matrix &matrix)
Definition: boundingNodeInfo.h:97
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
std::atomic< DtTerrainIntersectIDType > myLastUsed
Definition: boundingNodeInfo.h:82
virtual void expandExtent(DtExtent &ext) const
Definition: boundingNodeInfo.h:28
DtPagedInExtendInfo()
Definition: boundingNodeInfo.h:115
boost::unordered_set< DtNodeBoundingInfoPtr > DtNodeBoundingInfoSet
Definition: boundingNodeInfo.h:129
const DtNodeBoundingInfo myBoundingInfo
Definition: boundingNodeInfo.h:62

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)