Gray C++ Libraries  0.0.2
A set of C++ libraries for MSVC, GNU on Windows, WinCE, Linux
Gray3D::cOctreeNode Class Reference

#include <cOctreeNode.h>

Inheritance diagram for Gray3D::cOctreeNode:
IPoolNode Gray::cListT< cOctreeObject > Gray3D::cOctreeNodeCont Gray::cListBase ISpatialTest

Public Member Functions

 cOctreeNode ()
 
virtual ~cOctreeNode ()
 
float get_StepF () const noexcept
 
CHILDIDX_t get_RootIdx () const
 
CHILDIDX_t get_ChildIdx () const
 
cBounds3f get_BoundBox () const
 
cSpheref get_BoundSphere () const
 
GINTERSECT_TYPE GetIntersectTestNode (const cSpheref &rSphere) const
 
virtual bool TraverseIntersectSphere (ISpatialTestVisitor *tif, const cSpheref &frustum) const override
 
virtual bool TraverseIntersectBounds (ISpatialTestVisitor *tif, const cBounds3f &bbox) const override
 
virtual bool TraverseIntersectHex (ISpatialTestVisitor *tif, const cHexahedron &frustum, cHexahedron::PLANES_MASK_t planes)
 
virtual bool TraverseIntersectSegment (ISpatialTestVisitor *tif, const cSegment3f &segment) override
 
virtual bool TraverseAll (ISpatialTestVisitor *tif) const override
 
int TestTree (const cOctree *pTree, CHILDIDX_t rootIdx) const
 
bool isPoolNodeValid (UINT_PTR uCheckParent=0) const
 
- Public Member Functions inherited from Gray::cListT< cOctreeObject >
cOctreeObject * GetAt (ITERATE_t index) const
 
cOctreeObject * get_Head () const
 
cOctreeObject * get_Tail () const
 
- Public Member Functions inherited from Gray::cListBase
 cListBase () noexcept
 
virtual ~cListBase ()
 
virtual void InsertListNode (cListNodeBase *pNodeNew, cListNodeBase *pNodePrev=nullptr)
 
void InsertList (cListBase *pListSrc, cListNodeBase *pNodePrev=nullptr)
 
void InsertBefore (cListNodeBase *pNodeNew, const cListNodeBase *pNodeNext)
 
void InsertHead (cListNodeBase *pNodeNew)
 
void InsertTail (cListNodeBase *pNodeNew)
 
void DisposeAll ()
 
void Empty ()
 
cListNodeBaseget_Head (void) const noexcept
 
cListNodeBaseget_Tail (void) const noexcept
 
ITERATE_t get_Count () const noexcept
 
bool isEmpty () const noexcept
 
cListNodeBaseGetAt (ITERATE_t index) const
 iterate the linked list. More...
 
bool IsMyChild (const cListNodeBase *pNode) const noexcept
 
- Public Member Functions inherited from Gray3D::cOctreeNodeCont
 cOctreeNodeCont () noexcept
 
virtual ~cOctreeNodeCont ()
 
void FreeChildNode (CHILDIDX_t ci)
 
void FreeChildNodes ()
 
 UNITTEST_FRIEND (cOctree)
 run an heavy usage simulation to test More...
 

Static Public Member Functions

static CHILDIDX_t MakeChildIdx (const cVec3i &vPi)
 

Protected Member Functions

constexpr bool IsInsideNode (const cVec3i &vPi) const noexcept
 
void onDetachSpatialObject (cOctreeObject *pObj)
 
HRESULT DisposeThis ()
 
void FreeThisNode ()
 
bool CollapseLeafCheck ()
 
bool CollapseLeafAndTrimRootCheck ()
 
- Protected Member Functions inherited from Gray::cListBase
virtual void RemoveListNode (cListNodeBase *pNode)
 allow Override of this. called when child pObRec removed from list. More...
 
- Protected Member Functions inherited from Gray3D::cOctreeNodeCont
bool TraverseIntersectHex (ISpatialTestVisitor *pResults, const cHexahedron &frustum, cHexahedron::PLANES_MASK_t planes)
 
virtual bool TraverseIntersectHex (ISpatialTestVisitor *pResults, const cHexahedron &frustum) override
 

Static Protected Member Functions

static constexpr bool IsInsideNode (int v) noexcept
 

Protected Attributes

int m_iLevel
 node step = powf( 2, level ). this is stepping between nodes, size is 2x times bigger, overlap = step More...
 
cVec3i m_vTreePos
 integer node position in m_iLevel steps. (not world coords) More...
 
cOctreem_pTree
 my parent system. nullptr = free node in pool. More...
 
cOctreeNodem_pParentNode
 my parent node, nullptr = in m_pTree->m_aChildNodes. root node. More...
 
- Protected Attributes inherited from Gray::cListBase
ITERATE_t m_iCount
 how many children? nice to get read only direct access to this for scripting. More...
 
- Protected Attributes inherited from Gray3D::cOctreeNodeCont
cOctreeNodem_aChildNodes [k_NodeMax]
 container for sparse 2x2x2 possible subdivided children. for each sign octant More...
 
CHILDIDX_t m_nChildNodes
 Number of actually populated m_aChildNodes. <= 8. More...
 
int m_iSpatialTestVal
 validation value. incremented periodically (per frame?) More...
 

Friends

class cOctree
 
class cOctreeObject
 
class cOctreeNodeCont
 
class cOctreeNodePool
 

Additional Inherited Members

- Public Types inherited from Gray3D::cOctreeNodeCont
typedef int CHILDIDX_t
 0 to 7 k_NodeMax More...
 
- Static Public Attributes inherited from Gray3D::cOctreeNodeCont
static const CHILDIDX_t k_NodeMax = 8
 2x2x2 = 8 More...
 

Detailed Description

A node in the octree can contain list of cOctreeObject/cSpatialObject(s). and 8 child cOctreeNode(s) cListT<cOctreeObject> = the list of spatial objects in this node.

Constructor & Destructor Documentation

◆ cOctreeNode()

Gray3D::cOctreeNode::cOctreeNode ( )

◆ ~cOctreeNode()

Gray3D::cOctreeNode::~cOctreeNode ( )
virtual

Member Function Documentation

◆ CollapseLeafAndTrimRootCheck()

bool Gray3D::cOctreeNode::CollapseLeafAndTrimRootCheck ( )
protected

if this node has <=1 child then collapse.

◆ CollapseLeafCheck()

bool Gray3D::cOctreeNode::CollapseLeafCheck ( )
inlineprotected

If this leaf/node is empty then delete it.

◆ DisposeThis()

HRESULT Gray3D::cOctreeNode::DisposeThis ( )
protected

◆ FreeThisNode()

void Gray3D::cOctreeNode::FreeThisNode ( )
inlineprotected

◆ get_BoundBox()

cBounds3f Gray3D::cOctreeNode::get_BoundBox ( ) const
inline

get the bounds of this node.

◆ get_BoundSphere()

cSpheref Gray3D::cOctreeNode::get_BoundSphere ( ) const
inline

get the bounding sphere of this node.

◆ get_ChildIdx()

CHILDIDX_t Gray3D::cOctreeNode::get_ChildIdx ( ) const
inline

Assume m_pParentNode will be set.

◆ get_RootIdx()

CHILDIDX_t Gray3D::cOctreeNode::get_RootIdx ( ) const
inline

◆ get_StepF()

float Gray3D::cOctreeNode::get_StepF ( ) const
inlinenoexcept

◆ GetIntersectTestNode()

GINTERSECT_TYPE Gray3D::cOctreeNode::GetIntersectTestNode ( const cSpheref rSphere) const
inline

does rSphere intersect this node? GINTERSECT_In2 = Node fully in rSphere

◆ IsInsideNode() [1/2]

constexpr bool Gray3D::cOctreeNode::IsInsideNode ( const cVec3i vPi) const
inlineconstexprprotectednoexcept

◆ IsInsideNode() [2/2]

static constexpr bool Gray3D::cOctreeNode::IsInsideNode ( int  v)
inlinestaticconstexprprotectednoexcept

◆ isPoolNodeValid()

bool Gray3D::cOctreeNode::isPoolNodeValid ( UINT_PTR  uCheckParent = 0) const

in s_OctreeNodes

◆ MakeChildIdx()

static CHILDIDX_t Gray3D::cOctreeNode::MakeChildIdx ( const cVec3i vPi)
inlinestatic

Make Hash ID similar to MakeRootIdx()

Returns
0 to 7 k_NodeMax

◆ onDetachSpatialObject()

void Gray3D::cOctreeNode::onDetachSpatialObject ( cOctreeObject pObj)
protected

remove pObj from this node.

◆ TestTree()

int Gray3D::cOctreeNode::TestTree ( const cOctree pTree,
CHILDIDX_t  rootIdx 
) const

◆ TraverseAll()

bool Gray3D::cOctreeNode::TraverseAll ( ISpatialTestVisitor tif) const
overridevirtual

short cut to traverse all with out re-checking. GINTERSECT_In

Reimplemented from Gray3D::cOctreeNodeCont.

◆ TraverseIntersectBounds()

bool Gray3D::cOctreeNode::TraverseIntersectBounds ( ISpatialTestVisitor tif,
const cBounds3f &  bbox 
) const
overridevirtual

Reimplemented from Gray3D::cOctreeNodeCont.

◆ TraverseIntersectHex()

bool Gray3D::cOctreeNode::TraverseIntersectHex ( ISpatialTestVisitor tif,
const cHexahedron frustum,
cHexahedron::PLANES_MASK_t  planes 
)
virtual

◆ TraverseIntersectSegment()

bool Gray3D::cOctreeNode::TraverseIntersectSegment ( ISpatialTestVisitor tif,
const cSegment3f segment 
)
overridevirtual

Ray = A subset of bounds.

Reimplemented from Gray3D::cOctreeNodeCont.

◆ TraverseIntersectSphere()

bool Gray3D::cOctreeNode::TraverseIntersectSphere ( ISpatialTestVisitor tif,
const cSpheref frustum 
) const
overridevirtual

Reimplemented from Gray3D::cOctreeNodeCont.

Friends And Related Function Documentation

◆ cOctree

friend class cOctree
friend

◆ cOctreeNodeCont

friend class cOctreeNodeCont
friend

◆ cOctreeNodePool

friend class cOctreeNodePool
friend

◆ cOctreeObject

friend class cOctreeObject
friend

Member Data Documentation

◆ m_iLevel

int Gray3D::cOctreeNode::m_iLevel
protected

node step = powf( 2, level ). this is stepping between nodes, size is 2x times bigger, overlap = step

◆ m_pParentNode

cOctreeNode* Gray3D::cOctreeNode::m_pParentNode
protected

my parent node, nullptr = in m_pTree->m_aChildNodes. root node.

◆ m_pTree

cOctree* Gray3D::cOctreeNode::m_pTree
protected

my parent system. nullptr = free node in pool.

◆ m_vTreePos

cVec3i Gray3D::cOctreeNode::m_vTreePos
protected

integer node position in m_iLevel steps. (not world coords)


The documentation for this class was generated from the following files: