Bullet patch for compound ray cast. The patch is filed in Bullet patch tracker for...
[blender.git] / extern / bullet2 / src / BulletCollision / CollisionDispatch / btCollisionWorld.cpp
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);
                                }
                        }
                }