6 #ifndef _INC_cOctreeNode_H
7 #define _INC_cOctreeNode_H
17 #include "GrayCore/include/CList.h"
23 ,
public cListT<cOctreeObject>
33 friend class cOctreeNodePool;
45 return v >= 0 && v < 6;
49 return IsInsideNode(vPi.m_x - (m_vTreePos.
m_x << 2) + 1)
50 && IsInsideNode(vPi.m_y - (m_vTreePos.
m_y << 2) + 1)
51 && IsInsideNode(vPi.m_z - (m_vTreePos.
m_z << 2) + 1);
59 if (m_pParentNode !=
nullptr)
85 if (m_nChildNodes || !LIST_t::isEmpty())
91 bool CollapseLeafAndTrimRootCheck();
106 return (vPi.
m_x & 1) + ((vPi.
m_y & 1) << 1) + ((vPi.
m_z & 1) << 2);
111 ASSERT(m_pParentNode ==
nullptr);
118 return MakeChildIdx(m_vTreePos);
125 bounds.m_vMin.x = bounds.m_vMax.x = (float)m_vTreePos.
m_x;
126 bounds.m_vMin.y = bounds.m_vMax.y = (
float)m_vTreePos.
m_y;
127 bounds.m_vMin.z = bounds.m_vMax.z = (float)m_vTreePos.
m_z;
129 static const cVector3f k_vMio(-0.5f, -0.5f, -0.5f);
130 bounds.m_vMin += k_vMio;
131 static const cVector3f k_vMao(1.5f, 1.5f, 1.5f);
132 bounds.m_vMax += k_vMao;
134 float fStepSize = get_StepF();
135 bounds.m_vMin *= fStepSize;
136 bounds.m_vMax *= fStepSize;
143 float fStepSize = get_StepF();
146 cSpheref bsphere(0.5f + (
float)m_vTreePos.
m_x, 0.5f + (
float)m_vTreePos.
m_y, 0.5f + (
float)m_vTreePos.
m_z,
147 1.73205080756887729f * fStepSize);
149 bsphere.m_vCenter *= fStepSize;
157 cSpheref bsphereThis = get_BoundSphere();
158 return bsphereThis.GetIntersectSphere(rSphere);
163 virtual bool TraverseIntersectBounds(
ISpatialTestVisitor* tif,
const cBounds3f& bbox)
const override;
168 int TestTree(
const cOctree* pTree, CHILDIDX_t rootIdx)
const;
169 bool isPoolNodeValid(UINT_PTR uCheckParent = 0)
const;
#define GRAY3D_LINK
Definition: Gray3D.h:15
INT32 HRESULT
_WIN32 style error codes. INT32
Definition: SysTypes.h:465
#define ASSERT(exp)
Definition: cDebugAssert.h:87
int CHILDIDX_t
0 to 7 k_NodeMax
Definition: cOctree.h:33
cOctreeNode * m_aChildNodes[k_NodeMax]
container for sparse 2x2x2 possible subdivided children. for each sign octant
Definition: cOctree.h:37
void FreeChildNode(CHILDIDX_t ci)
Definition: cOctree.cpp:52
Definition: cOctreeNode.h:25
cOctreeNode * m_pParentNode
my parent node, nullptr = in m_pTree->m_aChildNodes. root node.
Definition: cOctreeNode.h:40
CHILDIDX_t get_RootIdx() const
Definition: cOctreeNode.h:109
void FreeThisNode()
Definition: cOctreeNode.h:57
int m_iLevel
node step = powf( 2, level ). this is stepping between nodes, size is 2x times bigger,...
Definition: cOctreeNode.h:37
cSpheref get_BoundSphere() const
Definition: cOctreeNode.h:140
static CHILDIDX_t MakeChildIdx(const cVec3i &vPi)
Definition: cOctreeNode.h:102
static constexpr bool IsInsideNode(int v) noexcept
Definition: cOctreeNode.h:43
cVec3i m_vTreePos
integer node position in m_iLevel steps. (not world coords)
Definition: cOctreeNode.h:38
constexpr bool IsInsideNode(const cVec3i &vPi) const noexcept
Definition: cOctreeNode.h:47
CHILDIDX_t get_ChildIdx() const
Definition: cOctreeNode.h:115
cBounds3f get_BoundBox() const
Definition: cOctreeNode.h:121
GINTERSECT_TYPE GetIntersectTestNode(const cSpheref &rSphere) const
Definition: cOctreeNode.h:153
bool CollapseLeafCheck()
Definition: cOctreeNode.h:82
float get_StepF() const noexcept
Definition: cOctreeNode.h:97
cOctree * m_pTree
my parent system. nullptr = free node in pool.
Definition: cOctreeNode.h:39
Definition: cOctreeObject.h:21
static CHILDIDX_t MakeRootIdx(const cVec3i &vPi) noexcept
Definition: cOctree.h:95
static float pow2(int iPow)
Definition: cFloatEst.h:49
Definition: cHexahedron.h:18
UINT PLANES_MASK_t
Bit Mask of the 6 planes.
Definition: cHexahedron.h:24
Definition: cSegment3.h:20
TYPE m_z
Definition: cVecT.h:544
TYPE m_x
Definition: cVecT.h:544
TYPE m_y
Definition: cVecT.h:544
Definition: cSpatialTest.h:19
Definition: Gray3D.cpp:12
GINTERSECT_TYPE
Definition: cVecT.h:20