From 8bf47140fe092fd0706a73869428feca3b1d9859 Mon Sep 17 00:00:00 2001 From: ejcoumans Date: Tue, 25 Jul 2006 00:30:15 +0000 Subject: [PATCH] prepare for AABB tree traversal for compound objects --- .../CompoundCollisionAlgorithm.cpp | 8 ++++++++ Bullet/CollisionShapes/CompoundShape.cpp | 3 ++- Bullet/CollisionShapes/CompoundShape.h | 10 +++++++++- Bullet/CollisionShapes/OptimizedBvh.cpp | 19 ++++++------------- 4 files changed, 25 insertions(+), 15 deletions(-) diff --git a/Bullet/CollisionDispatch/CompoundCollisionAlgorithm.cpp b/Bullet/CollisionDispatch/CompoundCollisionAlgorithm.cpp index ef27c34c0..9c021f63f 100644 --- a/Bullet/CollisionDispatch/CompoundCollisionAlgorithm.cpp +++ b/Bullet/CollisionDispatch/CompoundCollisionAlgorithm.cpp @@ -65,6 +65,14 @@ void CompoundCollisionAlgorithm::ProcessCollision (BroadphaseProxy* ,BroadphaseP CompoundShape* compoundShape = static_cast(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 #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; diff --git a/Bullet/CollisionShapes/OptimizedBvh.cpp b/Bullet/CollisionShapes/OptimizedBvh.cpp index 0cd20ecd0..1b30bfbcb 100644 --- a/Bullet/CollisionShapes/OptimizedBvh.cpp +++ b/Bullet/CollisionShapes/OptimizedBvh.cpp @@ -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;iProcessNode(&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