From 431ed63da2e1eedf47fc8b53755d6a21f163c8c7 Mon Sep 17 00:00:00 2001 From: hiker Date: Mon, 27 Jun 2016 07:48:30 +1000 Subject: [PATCH] Improved fix for 2522 by using isStaticOrKinematicObject() function (instead of accessing the rigid body). This separates collision and dynamic handling of bullet again. --- .../CollisionDispatch/SphereTriangleDetector.cpp | 13 ++++++------- .../NarrowPhaseCollision/btGjkPairDetector.cpp | 13 ++++++------- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/lib/bullet/src/BulletCollision/CollisionDispatch/SphereTriangleDetector.cpp b/lib/bullet/src/BulletCollision/CollisionDispatch/SphereTriangleDetector.cpp index 60187b106..9a3a58592 100644 --- a/lib/bullet/src/BulletCollision/CollisionDispatch/SphereTriangleDetector.cpp +++ b/lib/bullet/src/BulletCollision/CollisionDispatch/SphereTriangleDetector.cpp @@ -20,7 +20,6 @@ subject to the following restrictions: #include "BulletCollision/CollisionDispatch/btCollisionObject.h" #include "BulletCollision/CollisionDispatch/btManifoldResult.h" #include "BulletCollision/CollisionShapes/btTriangleShape.h" -#include "BulletDynamics/Dynamics/btRigidBody.h" SphereTriangleDetector::SphereTriangleDetector(btSphereShape* sphere,btTriangleShape* triangle,btScalar contactBreakingThreshold) @@ -59,15 +58,15 @@ void SphereTriangleDetector::getClosestPoints(const ClosestPointInput& input,Res if(mani) { // Find the triangle: - const btCollisionObject *b = mani->getBody0Internal(); - const btTriangleShape *tri = dynamic_cast(b->getCollisionShape()); + const btCollisionObject *co = mani->getBody0Internal(); + const btTriangleShape *tri = dynamic_cast(co->getCollisionShape()); if(!tri) { - b = mani->getBody1Internal(); - tri = dynamic_cast(b->getCollisionShape()); + co = mani->getBody1Internal(); + tri = dynamic_cast(co->getCollisionShape()); } - // If we have a triangle and it is static (mass=0), recompute the normal - if(tri && btRigidBody::upcast(b)->getInvMass()==0) + // If we have a triangle and it is static, recompute the normal + if(tri && co->isStaticOrKinematicObject()) { normal = (tri->m_vertices1[1]-tri->m_vertices1[0]) .cross(tri->m_vertices1[2]-tri->m_vertices1[0]); diff --git a/lib/bullet/src/BulletCollision/NarrowPhaseCollision/btGjkPairDetector.cpp b/lib/bullet/src/BulletCollision/NarrowPhaseCollision/btGjkPairDetector.cpp index 3dcf58515..5f7552a11 100644 --- a/lib/bullet/src/BulletCollision/NarrowPhaseCollision/btGjkPairDetector.cpp +++ b/lib/bullet/src/BulletCollision/NarrowPhaseCollision/btGjkPairDetector.cpp @@ -20,7 +20,6 @@ subject to the following restrictions: #include "BulletCollision/CollisionDispatch/btManifoldResult.h" #include "BulletCollision/CollisionDispatch/btCollisionObject.h" #include "BulletCollision/CollisionShapes/btTriangleShape.h" -#include "BulletDynamics/Dynamics/btRigidBody.h" @@ -456,15 +455,15 @@ void btGjkPairDetector::getClosestPointsNonVirtual(const ClosestPointInput& inpu if(mani) { // Find the triangle: - const btCollisionObject *b = mani->getBody0Internal(); - const btTriangleShape *tri = dynamic_cast(b->getCollisionShape()); + const btCollisionObject *co = mani->getBody0Internal(); + const btTriangleShape *tri = dynamic_cast(co->getCollisionShape()); if(!tri) { - b = mani->getBody1Internal(); - tri = dynamic_cast(b->getCollisionShape()); + co = mani->getBody1Internal(); + tri = dynamic_cast(co->getCollisionShape()); } - // If we have a triangle and it is static (mass=0), recompute the normal - if(tri && btRigidBody::upcast(b)->getInvMass()==0) + // If we have a triangle and it is static, recompute the normal + if(tri && co->isStaticOrKinematicObject()) { normalInB = (tri->m_vertices1[1]-tri->m_vertices1[0]) .cross(tri->m_vertices1[2]-tri->m_vertices1[0]);