Bullet patch for compound ray cast. The patch is filed in Bullet patch tracker for...
authorBenoit Bolsee <benoit.bolsee@online.be>
Thu, 11 Sep 2008 20:09:07 +0000 (20:09 +0000)
committerBenoit Bolsee <benoit.bolsee@online.be>
Thu, 11 Sep 2008 20:09:07 +0000 (20:09 +0000)
extern/bullet2/bullet_compound_raycast.patch [new file with mode: 0644]
extern/bullet2/readme.txt
extern/bullet2/src/BulletCollision/CollisionDispatch/btCollisionWorld.cpp

diff --git a/extern/bullet2/bullet_compound_raycast.patch b/extern/bullet2/bullet_compound_raycast.patch
new file mode 100644 (file)
index 0000000..2658f7e
--- /dev/null
@@ -0,0 +1,39 @@
+Index: src/BulletCollision/CollisionDispatch/btCollisionWorld.cpp
+===================================================================
+--- src/BulletCollision/CollisionDispatch/btCollisionWorld.cpp (r\82vision 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);
+                               }
+                       }
+               }
index 4d1a4c11706976037bc96d24d29a5cad05f3619a..02430cb5c0e2c35485c61c097cda47740ea96e72 100644 (file)
@@ -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 ***
 
index 7c2ecd6098aa7dc8d4f26e0212c2c498f8f28350..2fd972a476183c735889f4234aa9137bb21339ca 100644 (file)
@@ -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);
                                }
                        }
                }