prepare for AABB tree traversal for compound objects
This commit is contained in:
@@ -65,6 +65,14 @@ void CompoundCollisionAlgorithm::ProcessCollision (BroadphaseProxy* ,BroadphaseP
|
|||||||
|
|
||||||
CompoundShape* compoundShape = static_cast<CompoundShape*>(colObj->m_collisionShape);
|
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 numChildren = m_childCollisionAlgorithms.size();
|
||||||
int i;
|
int i;
|
||||||
for (i=0;i<numChildren;i++)
|
for (i=0;i<numChildren;i++)
|
||||||
|
|||||||
@@ -21,7 +21,8 @@ subject to the following restrictions:
|
|||||||
|
|
||||||
CompoundShape::CompoundShape()
|
CompoundShape::CompoundShape()
|
||||||
:m_localAabbMin(1e30f,1e30f,1e30f),
|
:m_localAabbMin(1e30f,1e30f,1e30f),
|
||||||
m_localAabbMax(-1e30f,-1e30f,-1e30f)
|
m_localAabbMax(-1e30f,-1e30f,-1e30f),
|
||||||
|
m_aabbTree(0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ subject to the following restrictions:
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
#include "CollisionShapes/CollisionMargin.h"
|
#include "CollisionShapes/CollisionMargin.h"
|
||||||
|
|
||||||
|
class OptimizedBvh;
|
||||||
|
|
||||||
/// CompoundShape allows to store multiple other CollisionShapes
|
/// CompoundShape allows to store multiple other CollisionShapes
|
||||||
/// This allows for concave collision objects. This is more general then the Static Concave TriangleMeshShape.
|
/// 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_localAabbMin;
|
||||||
SimdVector3 m_localAabbMax;
|
SimdVector3 m_localAabbMax;
|
||||||
|
|
||||||
|
OptimizedBvh* m_aabbTree;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CompoundShape();
|
CompoundShape();
|
||||||
@@ -96,6 +97,13 @@ public:
|
|||||||
return "Compound";
|
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:
|
private:
|
||||||
SimdScalar m_collisionMargin;
|
SimdScalar m_collisionMargin;
|
||||||
|
|||||||
@@ -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
|
void OptimizedBvh::ReportAabbOverlappingNodex(NodeOverlapCallback* nodeCallback,const SimdVector3& aabbMin,const SimdVector3& aabbMax) const
|
||||||
{
|
{
|
||||||
if (aabbMin.length() > 1000.f)
|
//either choose recursive traversal (WalkTree) or stackless (WalkStacklessTree)
|
||||||
{
|
|
||||||
for (size_t i=0;i<m_leafNodes.size();i++)
|
//WalkTree(m_rootNode1,nodeCallback,aabbMin,aabbMax);
|
||||||
{
|
|
||||||
const OptimizedBvhNode& node = m_leafNodes[i];
|
WalkStacklessTree(m_rootNode1,nodeCallback,aabbMin,aabbMax);
|
||||||
nodeCallback->ProcessNode(&node);
|
|
||||||
}
|
|
||||||
} else
|
|
||||||
{
|
|
||||||
//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
|
void OptimizedBvh::WalkTree(OptimizedBvhNode* rootNode,NodeOverlapCallback* nodeCallback,const SimdVector3& aabbMin,const SimdVector3& aabbMax) const
|
||||||
|
|||||||
Reference in New Issue
Block a user