Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErwin Coumans <blender@erwincoumans.com>2008-09-13 11:06:43 +0400
committerErwin Coumans <blender@erwincoumans.com>2008-09-13 11:06:43 +0400
commit7f293488d12b5d5076b4bbf3d6c9248867c447a0 (patch)
tree977ac9f1063de48615e8f294bfbcadb2a3b645f6 /extern/bullet2/src/BulletCollision/CollisionDispatch
parent206cfe7955683ac166201e417977e933fd98f7b3 (diff)
Upgrade to latest Bullet trunk, that is in sync with Blender/extern/bullet2. (except for one define 'WIN32_AVOID_SSE_WHEN_EMBEDDED_INSIDE_BLENDER')
In case someone reads those SVN logs: you can enable some extra broadphase SSE optimizations by replacing WIN32_AVOID_SSE_WHEN_EMBEDDED_INSIDE_BLENDER by WIN32 in extern/bullet2/src/BulletCollision/BroadphaseCollision/btDbvt.h Thanks to Benoit Bolsee for the upstream patch/contribution. Removed some obsolete files, they were just intended for comparison/testing.
Diffstat (limited to 'extern/bullet2/src/BulletCollision/CollisionDispatch')
-rw-r--r--extern/bullet2/src/BulletCollision/CollisionDispatch/btBoxBoxDetector.cpp4
-rw-r--r--extern/bullet2/src/BulletCollision/CollisionDispatch/btCollisionObject.cpp2
-rw-r--r--extern/bullet2/src/BulletCollision/CollisionDispatch/btCollisionObject.h18
-rw-r--r--extern/bullet2/src/BulletCollision/CollisionDispatch/btCollisionWorld.cpp13
-rw-r--r--extern/bullet2/src/BulletCollision/CollisionDispatch/btCompoundCollisionAlgorithm.cpp211
-rw-r--r--extern/bullet2/src/BulletCollision/CollisionDispatch/btCompoundCollisionAlgorithm.h7
-rw-r--r--extern/bullet2/src/BulletCollision/CollisionDispatch/btDefaultCollisionConfiguration.cpp12
-rw-r--r--extern/bullet2/src/BulletCollision/CollisionDispatch/btDefaultCollisionConfiguration.h3
-rw-r--r--extern/bullet2/src/BulletCollision/CollisionDispatch/btSphereTriangleCollisionAlgorithm.cpp2
9 files changed, 220 insertions, 52 deletions
diff --git a/extern/bullet2/src/BulletCollision/CollisionDispatch/btBoxBoxDetector.cpp b/extern/bullet2/src/BulletCollision/CollisionDispatch/btBoxBoxDetector.cpp
index e55604632c0..45ebff5dc45 100644
--- a/extern/bullet2/src/BulletCollision/CollisionDispatch/btBoxBoxDetector.cpp
+++ b/extern/bullet2/src/BulletCollision/CollisionDispatch/btBoxBoxDetector.cpp
@@ -226,7 +226,7 @@ void cullPoints2 (int n, btScalar p[], int m, int i0, int iret[])
a = btScalar(j)*(2*M__PI/m) + A[i0];
if (a > M__PI) a -= 2*M__PI;
btScalar maxdiff=1e9,diff;
-#ifndef dNODEBUG
+#if defined(DEBUG) || defined (_DEBUG)
*iret = i0; // iret is not allowed to keep this value
#endif
for (i=0; i<n; i++) {
@@ -239,7 +239,7 @@ void cullPoints2 (int n, btScalar p[], int m, int i0, int iret[])
}
}
}
-#ifndef dNODEBUG
+#if defined(DEBUG) || defined (_DEBUG)
btAssert (*iret != i0); // ensure iret got set
#endif
avail[*iret] = 0;
diff --git a/extern/bullet2/src/BulletCollision/CollisionDispatch/btCollisionObject.cpp b/extern/bullet2/src/BulletCollision/CollisionDispatch/btCollisionObject.cpp
index d1641249568..eebd0c99fcb 100644
--- a/extern/bullet2/src/BulletCollision/CollisionDispatch/btCollisionObject.cpp
+++ b/extern/bullet2/src/BulletCollision/CollisionDispatch/btCollisionObject.cpp
@@ -31,7 +31,7 @@ btCollisionObject::btCollisionObject()
m_internalType(CO_COLLISION_OBJECT),
m_hitFraction(btScalar(1.)),
m_ccdSweptSphereRadius(btScalar(0.)),
- m_ccdSquareMotionThreshold(btScalar(0.)),
+ m_ccdMotionThreshold(btScalar(0.)),
m_checkCollideWith(false)
{
diff --git a/extern/bullet2/src/BulletCollision/CollisionDispatch/btCollisionObject.h b/extern/bullet2/src/BulletCollision/CollisionDispatch/btCollisionObject.h
index 96cbd1c3eb8..eb297ef4a3b 100644
--- a/extern/bullet2/src/BulletCollision/CollisionDispatch/btCollisionObject.h
+++ b/extern/bullet2/src/BulletCollision/CollisionDispatch/btCollisionObject.h
@@ -81,8 +81,8 @@ protected:
///Swept sphere radius (0.0 by default), see btConvexConvexAlgorithm::
btScalar m_ccdSweptSphereRadius;
- /// Don't do continuous collision detection if square motion (in one step) is less then m_ccdSquareMotionThreshold
- btScalar m_ccdSquareMotionThreshold;
+ /// Don't do continuous collision detection if the motion (in one step) is less then m_ccdMotionThreshold
+ btScalar m_ccdMotionThreshold;
/// If some object should have elaborate collision filtering by sub-classes
bool m_checkCollideWith;
@@ -332,16 +332,22 @@ public:
m_ccdSweptSphereRadius = radius;
}
+ btScalar getCcdMotionThreshold() const
+ {
+ return m_ccdMotionThreshold;
+ }
+
btScalar getCcdSquareMotionThreshold() const
{
- return m_ccdSquareMotionThreshold;
+ return m_ccdMotionThreshold*m_ccdMotionThreshold;
}
- /// Don't do continuous collision detection if square motion (in one step) is less then m_ccdSquareMotionThreshold
- void setCcdSquareMotionThreshold(btScalar ccdSquareMotionThreshold)
+
+ /// Don't do continuous collision detection if the motion (in one step) is less then m_ccdMotionThreshold
+ void setCcdMotionThreshold(btScalar ccdMotionThreshold)
{
- m_ccdSquareMotionThreshold = ccdSquareMotionThreshold;
+ m_ccdMotionThreshold = ccdMotionThreshold*ccdMotionThreshold;
}
///users can point to their objects, userPointer is not used by Bullet
diff --git a/extern/bullet2/src/BulletCollision/CollisionDispatch/btCollisionWorld.cpp b/extern/bullet2/src/BulletCollision/CollisionDispatch/btCollisionWorld.cpp
index 2fd972a4761..d8674a320a7 100644
--- a/extern/bullet2/src/BulletCollision/CollisionDispatch/btCollisionWorld.cpp
+++ b/extern/bullet2/src/BulletCollision/CollisionDispatch/btCollisionWorld.cpp
@@ -127,6 +127,11 @@ void btCollisionWorld::updateAabbs()
{
btPoint3 minAabb,maxAabb;
colObj->getCollisionShape()->getAabb(colObj->getWorldTransform(), minAabb,maxAabb);
+ //need to increase the aabb for contact thresholds
+ btVector3 contactThreshold(gContactBreakingThreshold,gContactBreakingThreshold,gContactBreakingThreshold);
+ minAabb -= contactThreshold;
+ maxAabb += contactThreshold;
+
btBroadphaseInterface* bp = (btBroadphaseInterface*)m_broadphasePairCache;
//moving objects should be moderately sized, probably something wrong if not
@@ -381,14 +386,14 @@ void btCollisionWorld::rayTestSingle(const btTransform& rayFromTrans,const btTra
btTransform childWorldTrans = colObjWorldTransform * childTrans;
// replace collision shape so that callback can determine the triangle
btCollisionShape* saveCollisionShape = collisionObject->getCollisionShape();
- collisionObject->setCollisionShape((btCollisionShape*)childCollisionShape);
+ collisionObject->internalSetTemporaryCollisionShape((btCollisionShape*)childCollisionShape);
rayTestSingle(rayFromTrans,rayToTrans,
collisionObject,
childCollisionShape,
childWorldTrans,
resultCallback);
// restore
- collisionObject->setCollisionShape(saveCollisionShape);
+ collisionObject->internalSetTemporaryCollisionShape(saveCollisionShape);
}
}
}
@@ -577,14 +582,14 @@ void btCollisionWorld::objectQuerySingle(const btConvexShape* castShape,const bt
btTransform childWorldTrans = colObjWorldTransform * childTrans;
// replace collision shape so that callback can determine the triangle
btCollisionShape* saveCollisionShape = collisionObject->getCollisionShape();
- collisionObject->setCollisionShape((btCollisionShape*)childCollisionShape);
+ collisionObject->internalSetTemporaryCollisionShape((btCollisionShape*)childCollisionShape);
objectQuerySingle(castShape, convexFromTrans,convexToTrans,
collisionObject,
childCollisionShape,
childWorldTrans,
resultCallback, allowedPenetration);
// restore
- collisionObject->setCollisionShape(saveCollisionShape);
+ collisionObject->internalSetTemporaryCollisionShape(saveCollisionShape);
}
}
}
diff --git a/extern/bullet2/src/BulletCollision/CollisionDispatch/btCompoundCollisionAlgorithm.cpp b/extern/bullet2/src/BulletCollision/CollisionDispatch/btCompoundCollisionAlgorithm.cpp
index a29a6d624e5..da9336c55c7 100644
--- a/extern/bullet2/src/BulletCollision/CollisionDispatch/btCompoundCollisionAlgorithm.cpp
+++ b/extern/bullet2/src/BulletCollision/CollisionDispatch/btCompoundCollisionAlgorithm.cpp
@@ -16,12 +16,17 @@ subject to the following restrictions:
#include "BulletCollision/CollisionDispatch/btCompoundCollisionAlgorithm.h"
#include "BulletCollision/CollisionDispatch/btCollisionObject.h"
#include "BulletCollision/CollisionShapes/btCompoundShape.h"
-
+#include "BulletCollision/BroadphaseCollision/btDbvt.h"
+#include "LinearMath/btIDebugDraw.h"
+#include "LinearMath/btAabbUtil2.h"
btCompoundCollisionAlgorithm::btCompoundCollisionAlgorithm( const btCollisionAlgorithmConstructionInfo& ci,btCollisionObject* body0,btCollisionObject* body1,bool isSwapped)
:btCollisionAlgorithm(ci),
-m_isSwapped(isSwapped)
+m_isSwapped(isSwapped),
+m_sharedManifold(ci.m_manifold)
{
+ m_ownsManifold = false;
+
btCollisionObject* colObj = m_isSwapped? body1 : body0;
btCollisionObject* otherObj = m_isSwapped? body0 : body1;
assert (colObj->getCollisionShape()->isCompound());
@@ -33,11 +38,17 @@ m_isSwapped(isSwapped)
m_childCollisionAlgorithms.resize(numChildren);
for (i=0;i<numChildren;i++)
{
- btCollisionShape* tmpShape = colObj->getCollisionShape();
- btCollisionShape* childShape = compoundShape->getChildShape(i);
- colObj->internalSetTemporaryCollisionShape( childShape );
- m_childCollisionAlgorithms[i] = ci.m_dispatcher1->findAlgorithm(colObj,otherObj);
- colObj->internalSetTemporaryCollisionShape( tmpShape );
+ if (compoundShape->getDynamicAabbTree())
+ {
+ m_childCollisionAlgorithms[i] = 0;
+ } else
+ {
+ btCollisionShape* tmpShape = colObj->getCollisionShape();
+ btCollisionShape* childShape = compoundShape->getChildShape(i);
+ colObj->internalSetTemporaryCollisionShape( childShape );
+ m_childCollisionAlgorithms[i] = ci.m_dispatcher1->findAlgorithm(colObj,otherObj,m_sharedManifold);
+ colObj->internalSetTemporaryCollisionShape( tmpShape );
+ }
}
}
@@ -48,11 +59,109 @@ btCompoundCollisionAlgorithm::~btCompoundCollisionAlgorithm()
int i;
for (i=0;i<numChildren;i++)
{
- m_childCollisionAlgorithms[i]->~btCollisionAlgorithm();
- m_dispatcher->freeCollisionAlgorithm(m_childCollisionAlgorithms[i]);
+ if (m_childCollisionAlgorithms[i])
+ {
+ m_childCollisionAlgorithms[i]->~btCollisionAlgorithm();
+ m_dispatcher->freeCollisionAlgorithm(m_childCollisionAlgorithms[i]);
+ }
}
}
+
+
+
+struct btCompoundLeafCallback : btDbvt::ICollide
+{
+
+public:
+
+ btCollisionObject* m_compoundColObj;
+ btCollisionObject* m_otherObj;
+ btDispatcher* m_dispatcher;
+ const btDispatcherInfo& m_dispatchInfo;
+ btManifoldResult* m_resultOut;
+ btCollisionAlgorithm** m_childCollisionAlgorithms;
+ btPersistentManifold* m_sharedManifold;
+
+
+
+
+ btCompoundLeafCallback (btCollisionObject* compoundObj,btCollisionObject* otherObj,btDispatcher* dispatcher,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut,btCollisionAlgorithm** childCollisionAlgorithms,btPersistentManifold* sharedManifold)
+ :m_compoundColObj(compoundObj),m_otherObj(otherObj),m_dispatcher(dispatcher),m_dispatchInfo(dispatchInfo),m_resultOut(resultOut),
+ m_childCollisionAlgorithms(childCollisionAlgorithms),
+ m_sharedManifold(sharedManifold)
+ {
+
+ }
+
+
+ void ProcessChildShape(btCollisionShape* childShape,int index)
+ {
+
+ btCompoundShape* compoundShape = static_cast<btCompoundShape*>(m_compoundColObj->getCollisionShape());
+
+
+ //backup
+ btTransform orgTrans = m_compoundColObj->getWorldTransform();
+ btTransform orgInterpolationTrans = m_compoundColObj->getInterpolationWorldTransform();
+ const btTransform& childTrans = compoundShape->getChildTransform(index);
+ btTransform newChildWorldTrans = orgTrans*childTrans ;
+
+ //perform an AABB check first
+ btVector3 aabbMin0,aabbMax0,aabbMin1,aabbMax1;
+ childShape->getAabb(newChildWorldTrans,aabbMin0,aabbMax0);
+ m_otherObj->getCollisionShape()->getAabb(m_otherObj->getWorldTransform(),aabbMin1,aabbMax1);
+
+ if (TestAabbAgainstAabb2(aabbMin0,aabbMax0,aabbMin1,aabbMax1))
+ {
+
+ m_compoundColObj->setWorldTransform( newChildWorldTrans);
+ m_compoundColObj->setInterpolationWorldTransform(newChildWorldTrans);
+
+ //the contactpoint is still projected back using the original inverted worldtrans
+ btCollisionShape* tmpShape = m_compoundColObj->getCollisionShape();
+ m_compoundColObj->internalSetTemporaryCollisionShape( childShape );
+
+ if (!m_childCollisionAlgorithms[index])
+ m_childCollisionAlgorithms[index] = m_dispatcher->findAlgorithm(m_compoundColObj,m_otherObj,m_sharedManifold);
+
+ m_childCollisionAlgorithms[index]->processCollision(m_compoundColObj,m_otherObj,m_dispatchInfo,m_resultOut);
+ if (m_dispatchInfo.m_debugDraw && (m_dispatchInfo.m_debugDraw->getDebugMode() & btIDebugDraw::DBG_DrawAabb))
+ {
+ btVector3 worldAabbMin,worldAabbMax;
+ m_dispatchInfo.m_debugDraw->drawAabb(aabbMin0,aabbMax0,btVector3(1,1,1));
+ m_dispatchInfo.m_debugDraw->drawAabb(aabbMin1,aabbMax1,btVector3(1,1,1));
+ }
+
+ //revert back transform
+ m_compoundColObj->internalSetTemporaryCollisionShape( tmpShape);
+ m_compoundColObj->setWorldTransform( orgTrans );
+ m_compoundColObj->setInterpolationWorldTransform(orgInterpolationTrans);
+ }
+ }
+ void Process(const btDbvtNode* leaf)
+ {
+ int index = int(leaf->data);
+
+ btCompoundShape* compoundShape = static_cast<btCompoundShape*>(m_compoundColObj->getCollisionShape());
+ btCollisionShape* childShape = compoundShape->getChildShape(index);
+ if (m_dispatchInfo.m_debugDraw && (m_dispatchInfo.m_debugDraw->getDebugMode() & btIDebugDraw::DBG_DrawAabb))
+ {
+ btVector3 worldAabbMin,worldAabbMax;
+ btTransform orgTrans = m_compoundColObj->getWorldTransform();
+ btTransformAabb(leaf->volume.Mins(),leaf->volume.Maxs(),0.,orgTrans,worldAabbMin,worldAabbMax);
+ m_dispatchInfo.m_debugDraw->drawAabb(worldAabbMin,worldAabbMax,btVector3(1,0,0));
+ }
+ ProcessChildShape(childShape,index);
+
+ }
+};
+
+
+
+
+
+
void btCompoundCollisionAlgorithm::processCollision (btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut)
{
btCollisionObject* colObj = m_isSwapped? body1 : body0;
@@ -61,37 +170,69 @@ void btCompoundCollisionAlgorithm::processCollision (btCollisionObject* body0,bt
assert (colObj->getCollisionShape()->isCompound());
btCompoundShape* compoundShape = static_cast<btCompoundShape*>(colObj->getCollisionShape());
- //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.
+ btDbvt* tree = compoundShape->getDynamicAabbTree();
+ //use a dynamic aabb tree to cull potential child-overlaps
+ btCompoundLeafCallback callback(colObj,otherObj,m_dispatcher,dispatchInfo,resultOut,&m_childCollisionAlgorithms[0],m_sharedManifold);
- int numChildren = m_childCollisionAlgorithms.size();
- int i;
- for (i=0;i<numChildren;i++)
+
+ if (tree)
{
- //temporarily exchange parent btCollisionShape with childShape, and recurse
- btCollisionShape* childShape = compoundShape->getChildShape(i);
- //backup
- btTransform orgTrans = colObj->getWorldTransform();
- btTransform orgInterpolationTrans = colObj->getInterpolationWorldTransform();
+ btVector3 localAabbMin,localAabbMax;
+ btTransform otherInCompoundSpace;
+ otherInCompoundSpace = colObj->getWorldTransform().inverse() * otherObj->getWorldTransform();
+ otherObj->getCollisionShape()->getAabb(otherInCompoundSpace,localAabbMin,localAabbMax);
- const btTransform& childTrans = compoundShape->getChildTransform(i);
- btTransform newChildWorldTrans = orgTrans*childTrans ;
- colObj->setWorldTransform( newChildWorldTrans);
- colObj->setInterpolationWorldTransform(newChildWorldTrans);
+ const ATTRIBUTE_ALIGNED16(btDbvtVolume) bounds=btDbvtVolume::FromMM(localAabbMin,localAabbMax);
+ //process all children, that overlap with the given AABB bounds
+ tree->collideTV(tree->m_root,bounds,callback);
+
+ } else
+ {
+ //iterate over all children, perform an AABB check inside ProcessChildShape
+ int numChildren = m_childCollisionAlgorithms.size();
+ int i;
+ for (i=0;i<numChildren;i++)
+ {
+ callback.ProcessChildShape(compoundShape->getChildShape(i),i);
+ }
+ }
+
+ {
+ //iterate over all children, perform an AABB check inside ProcessChildShape
+ int numChildren = m_childCollisionAlgorithms.size();
+ int i;
+ btManifoldArray manifoldArray;
+
+ for (i=0;i<numChildren;i++)
+ {
+ if (m_childCollisionAlgorithms[i])
+ {
+ btCollisionShape* childShape = compoundShape->getChildShape(i);
+ //if not longer overlapping, remove the algorithm
+ btTransform orgTrans = colObj->getWorldTransform();
+ btTransform orgInterpolationTrans = colObj->getInterpolationWorldTransform();
+ const btTransform& childTrans = compoundShape->getChildTransform(i);
+ btTransform newChildWorldTrans = orgTrans*childTrans ;
+
+ //perform an AABB check first
+ btVector3 aabbMin0,aabbMax0,aabbMin1,aabbMax1;
+ childShape->getAabb(newChildWorldTrans,aabbMin0,aabbMax0);
+ otherObj->getCollisionShape()->getAabb(otherObj->getWorldTransform(),aabbMin1,aabbMax1);
+
+ if (!TestAabbAgainstAabb2(aabbMin0,aabbMax0,aabbMin1,aabbMax1))
+ {
+ m_childCollisionAlgorithms[i]->~btCollisionAlgorithm();
+ m_dispatcher->freeCollisionAlgorithm(m_childCollisionAlgorithms[i]);
+ m_childCollisionAlgorithms[i] = 0;
+ }
+
+ }
+
+ }
+
+
- //the contactpoint is still projected back using the original inverted worldtrans
- btCollisionShape* tmpShape = colObj->getCollisionShape();
- colObj->internalSetTemporaryCollisionShape( childShape );
- m_childCollisionAlgorithms[i]->processCollision(colObj,otherObj,dispatchInfo,resultOut);
- //revert back
- colObj->internalSetTemporaryCollisionShape( tmpShape);
- colObj->setWorldTransform( orgTrans );
- colObj->setInterpolationWorldTransform(orgInterpolationTrans);
}
}
diff --git a/extern/bullet2/src/BulletCollision/CollisionDispatch/btCompoundCollisionAlgorithm.h b/extern/bullet2/src/BulletCollision/CollisionDispatch/btCompoundCollisionAlgorithm.h
index 1682c6761cd..624a3cf10f5 100644
--- a/extern/bullet2/src/BulletCollision/CollisionDispatch/btCompoundCollisionAlgorithm.h
+++ b/extern/bullet2/src/BulletCollision/CollisionDispatch/btCompoundCollisionAlgorithm.h
@@ -28,11 +28,13 @@ class btDispatcher;
class btDispatcher;
/// btCompoundCollisionAlgorithm supports collision between CompoundCollisionShapes and other collision shapes
-/// Place holder, not fully implemented yet
class btCompoundCollisionAlgorithm : public btCollisionAlgorithm
{
btAlignedObjectArray<btCollisionAlgorithm*> m_childCollisionAlgorithms;
bool m_isSwapped;
+
+ class btPersistentManifold* m_sharedManifold;
+ bool m_ownsManifold;
public:
@@ -49,7 +51,8 @@ public:
int i;
for (i=0;i<m_childCollisionAlgorithms.size();i++)
{
- m_childCollisionAlgorithms[i]->getAllContactManifolds(manifoldArray);
+ if (m_childCollisionAlgorithms[i])
+ m_childCollisionAlgorithms[i]->getAllContactManifolds(manifoldArray);
}
}
diff --git a/extern/bullet2/src/BulletCollision/CollisionDispatch/btDefaultCollisionConfiguration.cpp b/extern/bullet2/src/BulletCollision/CollisionDispatch/btDefaultCollisionConfiguration.cpp
index 3f94f4d4eac..1c317080544 100644
--- a/extern/bullet2/src/BulletCollision/CollisionDispatch/btDefaultCollisionConfiguration.cpp
+++ b/extern/bullet2/src/BulletCollision/CollisionDispatch/btDefaultCollisionConfiguration.cpp
@@ -22,7 +22,9 @@ subject to the following restrictions:
#include "BulletCollision/CollisionDispatch/btConvexPlaneCollisionAlgorithm.h"
#include "BulletCollision/CollisionDispatch/btBoxBoxCollisionAlgorithm.h"
#include "BulletCollision/CollisionDispatch/btSphereSphereCollisionAlgorithm.h"
+#ifdef USE_BUGGY_SPHERE_BOX_ALGORITHM
#include "BulletCollision/CollisionDispatch/btSphereBoxCollisionAlgorithm.h"
+#endif //USE_BUGGY_SPHERE_BOX_ALGORITHM
#include "BulletCollision/CollisionDispatch/btSphereTriangleCollisionAlgorithm.h"
#include "BulletCollision/NarrowPhaseCollision/btGjkEpaPenetrationDepthSolver.h"
#include "BulletCollision/NarrowPhaseCollision/btMinkowskiPenetrationDepthSolver.h"
@@ -70,11 +72,14 @@ btDefaultCollisionConfiguration::btDefaultCollisionConfiguration(const btDefault
mem = btAlignedAlloc(sizeof(btSphereSphereCollisionAlgorithm::CreateFunc),16);
m_sphereSphereCF = new(mem) btSphereSphereCollisionAlgorithm::CreateFunc;
+#ifdef USE_BUGGY_SPHERE_BOX_ALGORITHM
mem = btAlignedAlloc(sizeof(btSphereBoxCollisionAlgorithm::CreateFunc),16);
m_sphereBoxCF = new(mem) btSphereBoxCollisionAlgorithm::CreateFunc;
mem = btAlignedAlloc(sizeof(btSphereBoxCollisionAlgorithm::CreateFunc),16);
m_boxSphereCF = new (mem)btSphereBoxCollisionAlgorithm::CreateFunc;
m_boxSphereCF->m_swapped = true;
+#endif //USE_BUGGY_SPHERE_BOX_ALGORITHM
+
mem = btAlignedAlloc(sizeof(btSphereTriangleCollisionAlgorithm::CreateFunc),16);
m_sphereTriangleCF = new (mem)btSphereTriangleCollisionAlgorithm::CreateFunc;
mem = btAlignedAlloc(sizeof(btSphereTriangleCollisionAlgorithm::CreateFunc),16);
@@ -176,10 +181,13 @@ btDefaultCollisionConfiguration::~btDefaultCollisionConfiguration()
m_sphereSphereCF->~btCollisionAlgorithmCreateFunc();
btAlignedFree( m_sphereSphereCF);
+#ifdef USE_BUGGY_SPHERE_BOX_ALGORITHM
m_sphereBoxCF->~btCollisionAlgorithmCreateFunc();
btAlignedFree( m_sphereBoxCF);
m_boxSphereCF->~btCollisionAlgorithmCreateFunc();
btAlignedFree( m_boxSphereCF);
+#endif //USE_BUGGY_SPHERE_BOX_ALGORITHM
+
m_sphereTriangleCF->~btCollisionAlgorithmCreateFunc();
btAlignedFree( m_sphereTriangleCF);
m_triangleSphereCF->~btCollisionAlgorithmCreateFunc();
@@ -212,7 +220,7 @@ btCollisionAlgorithmCreateFunc* btDefaultCollisionConfiguration::getCollisionAlg
{
return m_sphereSphereCF;
}
-
+#ifdef USE_BUGGY_SPHERE_BOX_ALGORITHM
if ((proxyType0 == SPHERE_SHAPE_PROXYTYPE) && (proxyType1==BOX_SHAPE_PROXYTYPE))
{
return m_sphereBoxCF;
@@ -222,6 +230,8 @@ btCollisionAlgorithmCreateFunc* btDefaultCollisionConfiguration::getCollisionAlg
{
return m_boxSphereCF;
}
+#endif //USE_BUGGY_SPHERE_BOX_ALGORITHM
+
if ((proxyType0 == SPHERE_SHAPE_PROXYTYPE ) && (proxyType1==TRIANGLE_SHAPE_PROXYTYPE))
{
diff --git a/extern/bullet2/src/BulletCollision/CollisionDispatch/btDefaultCollisionConfiguration.h b/extern/bullet2/src/BulletCollision/CollisionDispatch/btDefaultCollisionConfiguration.h
index 0b274d394af..4f5af5f048c 100644
--- a/extern/bullet2/src/BulletCollision/CollisionDispatch/btDefaultCollisionConfiguration.h
+++ b/extern/bullet2/src/BulletCollision/CollisionDispatch/btDefaultCollisionConfiguration.h
@@ -71,8 +71,11 @@ class btDefaultCollisionConfiguration : public btCollisionConfiguration
btCollisionAlgorithmCreateFunc* m_swappedCompoundCreateFunc;
btCollisionAlgorithmCreateFunc* m_emptyCreateFunc;
btCollisionAlgorithmCreateFunc* m_sphereSphereCF;
+#ifdef USE_BUGGY_SPHERE_BOX_ALGORITHM
btCollisionAlgorithmCreateFunc* m_sphereBoxCF;
btCollisionAlgorithmCreateFunc* m_boxSphereCF;
+#endif //USE_BUGGY_SPHERE_BOX_ALGORITHM
+
btCollisionAlgorithmCreateFunc* m_boxBoxCF;
btCollisionAlgorithmCreateFunc* m_sphereTriangleCF;
btCollisionAlgorithmCreateFunc* m_triangleSphereCF;
diff --git a/extern/bullet2/src/BulletCollision/CollisionDispatch/btSphereTriangleCollisionAlgorithm.cpp b/extern/bullet2/src/BulletCollision/CollisionDispatch/btSphereTriangleCollisionAlgorithm.cpp
index 46961f5d61b..fdbd4abef27 100644
--- a/extern/bullet2/src/BulletCollision/CollisionDispatch/btSphereTriangleCollisionAlgorithm.cpp
+++ b/extern/bullet2/src/BulletCollision/CollisionDispatch/btSphereTriangleCollisionAlgorithm.cpp
@@ -63,7 +63,7 @@ void btSphereTriangleCollisionAlgorithm::processCollision (btCollisionObject* co
input.m_transformA = sphereObj->getWorldTransform();
input.m_transformB = triObj->getWorldTransform();
- bool swapResults = m_swapped && !m_ownManifold;
+ bool swapResults = m_swapped;
detector.getClosestPoints(input,*resultOut,dispatchInfo.m_debugDraw,swapResults);