22 #ifndef __ND_SCENE_NODE_H__
23 #define __ND_SCENE_NODE_H__
25 #include "ndCollisionStdafx.h"
46 virtual ndBvhNode* GetAsSceneNode()
const;
54 virtual bool SanityCheck(ndUnsigned32 level)
const;
65 ndUnsigned8 m_bhvLinked;
71 static ndVector m_aabbInvQuantization;
72 } D_GCC_NEWTON_ALIGN_32 ;
86 bool SanityCheck(ndUnsigned32 level)
const;
90 } D_GCC_NEWTON_ALIGN_32;
118 ndInt32 m_location : 30;
119 ndUnsigned32 m_cellTest : 1;
136 void Init(ndInt32 maxCount);
151 ndInt32 m_depthLevel;
152 ndInt32 m_leafNodesCount;
166 ndUnsigned32 m_isDirty;
167 ndUnsigned32 m_scansCount;
168 ndUnsigned32 m_scans[256];
191 void BuildBvhTreeSetNodesDepth(
ndThreadPool& threadPool);
192 void BuildBvhGenerateLayerGrids(
ndThreadPool& threadPool);
193 void BuildBvhTreeCalculateLeafBoxes(
ndThreadPool& threadPool);
196 ndInt32 BuildSmallBvhTree(
ndThreadPool& threadPool,
ndBvhNode**
const parentsArray, ndInt32 bashCount);
214 inline ndBvhNode::ndBvhNode(
ndBvhNode*
const parent)
216 ,m_minBox(ndFloat32(-1.0e15f))
217 ,m_maxBox(ndFloat32(1.0e15f))
220 ,m_buildNode(nullptr)
232 inline ndBvhNode::ndBvhNode(
const ndBvhNode& src)
234 ,m_minBox(src.m_minBox)
235 ,m_maxBox(src.m_maxBox)
246 m_buildNode->m_buildNode =
this;
254 inline ndBvhNode::~ndBvhNode()
258 inline ndBvhNode* ndBvhNode::GetAsSceneNode()
const
278 inline ndBvhNode* ndBvhNode::GetLeft()
const
283 inline ndBvhNode* ndBvhNode::GetRight()
const
288 inline void ndBvhNode::Kill()
292 m_buildNode->m_isDead = 1;
302 inline void ndBvhNode::SetAabb(
const ndVector& minBox,
const ndVector& maxBox)
304 ndAssert(minBox.m_x <= maxBox.m_x);
305 ndAssert(minBox.m_y <= maxBox.m_y);
306 ndAssert(minBox.m_z <= maxBox.m_z);
308 const ndVector p0(minBox * m_aabbQuantization);
309 const ndVector p1(maxBox * m_aabbQuantization + ndVector::m_one);
311 m_minBox = p0.Floor() * m_aabbInvQuantization;
312 m_maxBox = p1.Floor() * m_aabbInvQuantization;
314 ndAssert(m_minBox.m_w == ndFloat32(0.0f));
315 ndAssert(m_maxBox.m_w == ndFloat32(0.0f));
318 inline ndBvhNode* ndBvhNode::Clone()
const
324 inline ndBvhLeafNode* ndBvhLeafNode::GetAsSceneBodyNode()
const
339 inline ndBvhNode* ndBvhInternalNode::GetLeft()
const
344 inline ndBvhNode* ndBvhInternalNode::GetRight()
const
351 return m_workingArray;