prepare for AABB tree traversal for compound objects

This commit is contained in:
ejcoumans
2006-07-25 00:30:15 +00:00
parent 9da13d7628
commit 8bf47140fe
4 changed files with 25 additions and 15 deletions

View File

@@ -65,6 +65,14 @@ void CompoundCollisionAlgorithm::ProcessCollision (BroadphaseProxy* ,BroadphaseP
CompoundShape* compoundShape = static_cast<CompoundShape*>(colObj->m_collisionShape);
//We will use the OptimizedBVH, AABB tree to cull potential child-overlaps
//If both proxies are Compound, we will deal with that directly, by performing sequential/parallel tree traversals
//given Proxy0 and Proxy1, if both have a tree, Tree0 and Tree1, this means:
//determine overlapping nodes of Proxy1 using Proxy0 AABB against Tree1
//then use each overlapping node AABB against Tree0
//and vise versa.
int numChildren = m_childCollisionAlgorithms.size();
int i;
for (i=0;i<numChildren;i++)

View File

@@ -21,7 +21,8 @@ subject to the following restrictions:
CompoundShape::CompoundShape()
:m_localAabbMin(1e30f,1e30f,1e30f),
m_localAabbMax(-1e30f,-1e30f,-1e30f)
m_localAabbMax(-1e30f,-1e30f,-1e30f),
m_aabbTree(0)
{
}

View File

@@ -24,7 +24,7 @@ subject to the following restrictions:
#include <vector>
#include "CollisionShapes/CollisionMargin.h"
class OptimizedBvh;
/// CompoundShape allows to store multiple other CollisionShapes
/// This allows for concave collision objects. This is more general then the Static Concave TriangleMeshShape.
@@ -35,6 +35,7 @@ class CompoundShape : public CollisionShape
SimdVector3 m_localAabbMin;
SimdVector3 m_localAabbMax;
OptimizedBvh* m_aabbTree;
public:
CompoundShape();
@@ -96,6 +97,13 @@ public:
return "Compound";
}
//this is optional, but should make collision queries faster, by culling non-overlapping nodes
void CreateAabbTreeFromChildren();
const OptimizedBvh* GetAabbTree() const
{
return m_aabbTree;
}
private:
SimdScalar m_collisionMargin;

View File

@@ -193,21 +193,14 @@ int OptimizedBvh::CalcSplittingAxis(NodeArray& leafNodes,int startIndex,int endI
}
void OptimizedBvh::ReportAabbOverlappingNodex(NodeOverlapCallback* nodeCallback,const SimdVector3& aabbMin,const SimdVector3& aabbMax) const
{
if (aabbMin.length() > 1000.f)
{
for (size_t i=0;i<m_leafNodes.size();i++)
{
const OptimizedBvhNode& node = m_leafNodes[i];
nodeCallback->ProcessNode(&node);
}
} else
{
//WalkTree(m_rootNode1,nodeCallback,aabbMin,aabbMax);
WalkStacklessTree(m_rootNode1,nodeCallback,aabbMin,aabbMax);
}
//either choose recursive traversal (WalkTree) or stackless (WalkStacklessTree)
//WalkTree(m_rootNode1,nodeCallback,aabbMin,aabbMax);
WalkStacklessTree(m_rootNode1,nodeCallback,aabbMin,aabbMax);
}
void OptimizedBvh::WalkTree(OptimizedBvhNode* rootNode,NodeOverlapCallback* nodeCallback,const SimdVector3& aabbMin,const SimdVector3& aabbMax) const