void SWDynamicTree2D::query( tarray<tuint>& result, const taabb2d& aabb ) const { result.clear(); tlist<tuint> suspects; suspects.push_back( m_rootID ); while ( suspects.size() > 0 ) { tuint nodeID = suspects.front(); suspects.pop_front(); if ( nodeID == nullID ) continue; const TreeNode& node = m_nodes[ nodeID ]; if ( node.aabb.collide( aabb ) ) { if ( node.isLeaf() ) { result.push_back( nodeID ); } else { suspects.push_back( node.childID[0] ); suspects.push_back( node.childID[1] ); } } } }
void addDynamicOccluder(ZTransform* aTransform) { int i; FOccluderBox obox; tvector3 extend(1,1,1); const tmatrix& boxmat = aTransform->GetWorldMatrix(); for (i=0; i<8; i++) { tvector3 bvt(BoxCorners[i].x, BoxCorners[i].y, BoxCorners[i].z),bvt2; bvt2.TransformPoint((bvt*extend), boxmat); obox.mVertex[i] = vector4(bvt2.x, bvt2.y, bvt2.z, 0); } for (i=0; i<6; i++) { tvector3 cross = obox.mVertex[FaceVertexIndex[i][1]]; cross -= obox.mVertex[FaceVertexIndex[i][0]]; tvector3 cr2 = obox.mVertex[FaceVertexIndex[i][2]]; cr2 -= obox.mVertex[FaceVertexIndex[i][0]]; cross.Cross(cr2); obox.mPlanes[i] = vector4(cross.x, cross.y, cross.z, 0); obox.mPlanes[i].Normalize(); obox.mPlanes[i].w = -DotProduct(obox.mPlanes[i], obox.mVertex[FaceVertexIndex[i][0]]); obox.mVertex[i].w = fabs(obox.mPlanes[i].Dot( cross)); // save area in vertex w component } obox.mCenter = vector4(boxmat.m16[12], boxmat.m16[13], boxmat.m16[14], 0); obox.mCenter.w = Distance(obox.mCenter, obox.mVertex[0]); gOccluderBoxes.push_back(obox); }