From 13b0cf94d5da4cf96607ea8736fad6ae3ab68a4f Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Thu, 11 Sep 2008 20:09:07 +0000 Subject: Bullet patch for compound ray cast. The patch is filed in Bullet patch tracker for inclusion in later revision. If it is not included, apply manually extern/bullet2/bullet_compound_raycast.patch --- extern/bullet2/bullet_compound_raycast.patch | 39 ++++++++++++++++++++++ extern/bullet2/readme.txt | 5 +++ .../CollisionDispatch/btCollisionWorld.cpp | 11 +++++- 3 files changed, 54 insertions(+), 1 deletion(-) create mode 100644 extern/bullet2/bullet_compound_raycast.patch (limited to 'extern/bullet2') diff --git a/extern/bullet2/bullet_compound_raycast.patch b/extern/bullet2/bullet_compound_raycast.patch new file mode 100644 index 00000000000..2658f7ed56e --- /dev/null +++ b/extern/bullet2/bullet_compound_raycast.patch @@ -0,0 +1,39 @@ +Index: src/BulletCollision/CollisionDispatch/btCollisionWorld.cpp +=================================================================== +--- src/BulletCollision/CollisionDispatch/btCollisionWorld.cpp (r‚vision 16464) ++++ src/BulletCollision/CollisionDispatch/btCollisionWorld.cpp (copie de travail) +@@ -379,12 +379,16 @@ + btTransform childTrans = compoundShape->getChildTransform(i); + const btCollisionShape* childCollisionShape = compoundShape->getChildShape(i); + btTransform childWorldTrans = colObjWorldTransform * childTrans; ++ // replace collision shape so that callback can determine the triangle ++ btCollisionShape* saveCollisionShape = collisionObject->getCollisionShape(); ++ collisionObject->setCollisionShape((btCollisionShape*)childCollisionShape); + rayTestSingle(rayFromTrans,rayToTrans, + collisionObject, + childCollisionShape, + childWorldTrans, + resultCallback); +- ++ // restore ++ collisionObject->setCollisionShape(saveCollisionShape); + } + } + } +@@ -571,11 +575,16 @@ + btTransform childTrans = compoundShape->getChildTransform(i); + const btCollisionShape* childCollisionShape = compoundShape->getChildShape(i); + btTransform childWorldTrans = colObjWorldTransform * childTrans; ++ // replace collision shape so that callback can determine the triangle ++ btCollisionShape* saveCollisionShape = collisionObject->getCollisionShape(); ++ collisionObject->setCollisionShape((btCollisionShape*)childCollisionShape); + objectQuerySingle(castShape, convexFromTrans,convexToTrans, + collisionObject, + childCollisionShape, + childWorldTrans, + resultCallback, allowedPenetration); ++ // restore ++ collisionObject->setCollisionShape(saveCollisionShape); + } + } + } diff --git a/extern/bullet2/readme.txt b/extern/bullet2/readme.txt index 4d1a4c11706..02430cb5c0e 100644 --- a/extern/bullet2/readme.txt +++ b/extern/bullet2/readme.txt @@ -1,3 +1,8 @@ +*** +Apply bullet_compound_raycast.patch if not already applied in Bullet source +This patch is needed to return correct raycast results on compound shape. +/ben + *** These files in extern/bullet2 are NOT part of the Blender build yet *** diff --git a/extern/bullet2/src/BulletCollision/CollisionDispatch/btCollisionWorld.cpp b/extern/bullet2/src/BulletCollision/CollisionDispatch/btCollisionWorld.cpp index 7c2ecd6098a..2fd972a4761 100644 --- a/extern/bullet2/src/BulletCollision/CollisionDispatch/btCollisionWorld.cpp +++ b/extern/bullet2/src/BulletCollision/CollisionDispatch/btCollisionWorld.cpp @@ -379,12 +379,16 @@ void btCollisionWorld::rayTestSingle(const btTransform& rayFromTrans,const btTra btTransform childTrans = compoundShape->getChildTransform(i); const btCollisionShape* childCollisionShape = compoundShape->getChildShape(i); btTransform childWorldTrans = colObjWorldTransform * childTrans; + // replace collision shape so that callback can determine the triangle + btCollisionShape* saveCollisionShape = collisionObject->getCollisionShape(); + collisionObject->setCollisionShape((btCollisionShape*)childCollisionShape); rayTestSingle(rayFromTrans,rayToTrans, collisionObject, childCollisionShape, childWorldTrans, resultCallback); - + // restore + collisionObject->setCollisionShape(saveCollisionShape); } } } @@ -571,11 +575,16 @@ void btCollisionWorld::objectQuerySingle(const btConvexShape* castShape,const bt btTransform childTrans = compoundShape->getChildTransform(i); const btCollisionShape* childCollisionShape = compoundShape->getChildShape(i); btTransform childWorldTrans = colObjWorldTransform * childTrans; + // replace collision shape so that callback can determine the triangle + btCollisionShape* saveCollisionShape = collisionObject->getCollisionShape(); + collisionObject->setCollisionShape((btCollisionShape*)childCollisionShape); objectQuerySingle(castShape, convexFromTrans,convexToTrans, collisionObject, childCollisionShape, childWorldTrans, resultCallback, allowedPenetration); + // restore + collisionObject->setCollisionShape(saveCollisionShape); } } } -- cgit v1.2.3