VR-Forces Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
DtOctree.h
Go to the documentation of this file.
1 /******************************************************************************
2 ** Copyright (c) 2023 MAK Technologies, Inc.
3 ** All rights reserved.
4 ******************************************************************************/
5 
9 #pragma once
10 
14 
15 #include <list>
16 
17 
18 namespace makVrv {
19 
26  template<class T>
27  class DtOctree
28  {
29  public:
31  DtOctree( DtOctree * parent, DtOctree* treeRoot, size_t maxDepth );
32 
34  ~DtOctree();
35 
39  void addNode( DtOctreeNode<T> * );
40 
42  void removeNode( DtOctreeNode<T> * );
43 
45  int numNodes()
46  {
47  return myNumNodes;
48  };
49 
53 
56 
60  DtOctree* myChildren[ 2 ][ 2 ][ 2 ];
61 
65  bool isTwiceSize( const DtAxisAlignedBoundingBox<T> &box ) const;
66 
71  void getChildIndexes( const DtAxisAlignedBoundingBox<T> &, int *x, int *y, int *z ) const;
72 
76 
77 
78  typedef std::list< DtOctreeNode<T> * > NodeList;
79  typedef std::vector< DtOctreeNode<T> * > NodeVector;
80 
83 
84  void updateOctreeNode(DtOctreeNode<T>* pOctreeNode);
85  void addOctreeNode(DtOctreeNode<T>* pOctreeNode, DtOctree<T>* pOctree, size_t depth = 0);
86  void removeOctreeNode(DtOctreeNode<T>* pOctreeNode);
87 
88  void findVisibleObjects(NodeVector& visibleNodes
89  , DtOctree* pOctree, const DtCamera<T>* pCamera, bool foundVisible) const;
90  void findVisibleObjects(NodeVector& visibleNodes
91  , DtOctree* pOctree, const Frustum<T>* pFrustum, bool foundVisible) const;
92  protected:
93 
95  inline void ref()
96  {
97  myNumNodes++;
98 
99  if (myParent != 0)
100  {
101  myParent->ref();
102  }
103  };
104 
106  inline void unref()
107  {
108  myNumNodes--;
109 
110  if (myParent != 0)
111  {
112  myParent->unref();
113  };
114  }
115 
118 
121 
124 
125  size_t myMaxDepth;
126  };
127 
128 } //namespace makVrv
129 
130 #include "DtOctree.inl"
DtOctree * myOctreeRoot
tree root
Definition: DtOctree.h:123
OctreeNode class.
Definition: DtOctreeNode.h:20
OctreeNode forward declarations.
DtOctree * myChildren[2][2][2]
3D array of children of this octree. Children are dynamically created as needed when nodes are insert...
Definition: DtOctree.h:60
void updateOctreeNode(DtOctreeNode< T > *pOctreeNode)
DtVector3< T > myHalfSize
Vector containing the dimensions of this octree / 2.
Definition: DtOctree.h:55
NodeList myNodes
Public list of SceneNodes attached to this particular octree.
Definition: DtOctree.h:82
size_t myMaxDepth
Definition: DtOctree.h:125
void unref()
Decrements the overall node count of this octree and all its parents.
Definition: DtOctree.h:106
Camera forward declarations.
int myNumNodes
number of SceneNodes in this octree and all its children.
Definition: DtOctree.h:117
Template for 32/64 bit Axis Aligned bounding boxesnot virtual because its stored as is on the GPU...
Definition: DtAxisAlignedBoundingBox.h:27
int numNodes()
Returns the number of scene nodes attached to this octree.
Definition: DtOctree.h:45
void findVisibleObjects(NodeVector &visibleNodes, DtOctree *pOctree, const DtCamera< T > *pCamera, bool foundVisible) const
Axis Aligned Bounding Box class.
Template for 32/64 bit Cameras.
Definition: DtCamera.h:43
void removeNode(DtOctreeNode< T > *)
Removes an Octree scene node to this octree level.
void getChildIndexes(const DtAxisAlignedBoundingBox< T > &, int *x, int *y, int *z) const
Returns the appropriate indexes for the child of this octree into which the box will fit...
Octree datastructure for managing scene nodes. This is a loose octree implementation, meaning that each octant child of the octree actually overlaps it&#39;s siblings by a factor of .5. This guarantees that any thing that is half the size of the parent will fit completely into a child, with no splitting necessary.
Definition: DtOctree.h:27
std::vector< DtOctreeNode< T > * > NodeVector
Definition: DtOctree.h:79
bool isTwiceSize(const DtAxisAlignedBoundingBox< T > &box) const
Determines if this octree is twice as big as the given box. This method is used by the OctreeSceneMan...
DtOctree(DtOctree *parent, DtOctree *treeRoot, size_t maxDepth)
CTOR.
void ref()
Increments the overall node count of this octree and all its parents.
Definition: DtOctree.h:95
DtAxisAlignedBoundingBox< T > myBox
The bounding box of the octree This is used for octant index determination and rendering, but not culling.
Definition: DtOctree.h:48
2 dimensional vector
Definition: DtMath.h:21
std::list< DtOctreeNode< T > * > NodeList
Definition: DtOctree.h:78
DtOctree * myParent
parent octree
Definition: DtOctree.h:120
void addNode(DtOctreeNode< T > *)
Adds an Octree scene node to this octree level. This is called by the OctreeSceneManager after it has...
void removeOctreeNode(DtOctreeNode< T > *pOctreeNode)
Template for 32/64 bit bit frustums.
Definition: DtCamera.h:151
void addOctreeNode(DtOctreeNode< T > *pOctreeNode, DtOctree< T > *pOctree, size_t depth=0)
void getCullBounds(DtAxisAlignedBoundingBox< T > *) const
Creates the AxisAlignedBoundingBox&lt;T&gt; used for culling this octree. Since it&#39;s a loose octree...

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)