Use the original code for convex-plane collision in (btConvexPlaneCollisionAlgorithm),
rather than the perturbed rotated version (it is slower and harder to debug)
This commit is contained in:
@@ -102,14 +102,29 @@ void btConvexPlaneCollisionAlgorithm::processCollision (btCollisionObject* body0
|
|||||||
btConvexShape* convexShape = (btConvexShape*) convexObj->getCollisionShape();
|
btConvexShape* convexShape = (btConvexShape*) convexObj->getCollisionShape();
|
||||||
btStaticPlaneShape* planeShape = (btStaticPlaneShape*) planeObj->getCollisionShape();
|
btStaticPlaneShape* planeShape = (btStaticPlaneShape*) planeObj->getCollisionShape();
|
||||||
|
|
||||||
|
bool hasCollision = false;
|
||||||
const btVector3& planeNormal = planeShape->getPlaneNormal();
|
const btVector3& planeNormal = planeShape->getPlaneNormal();
|
||||||
//const btScalar& planeConstant = planeShape->getPlaneConstant();
|
const btScalar& planeConstant = planeShape->getPlaneConstant();
|
||||||
|
btTransform planeInConvex;
|
||||||
|
planeInConvex= convexObj->getWorldTransform().inverse() * planeObj->getWorldTransform();
|
||||||
|
btTransform convexInPlaneTrans;
|
||||||
|
convexInPlaneTrans= planeObj->getWorldTransform().inverse() * convexObj->getWorldTransform();
|
||||||
|
|
||||||
//first perform a collision query with the non-perturbated collision objects
|
btVector3 vtx = convexShape->localGetSupportingVertex(planeInConvex.getBasis()*-planeNormal);
|
||||||
|
btVector3 vtxInPlane = convexInPlaneTrans(vtx);
|
||||||
|
btScalar distance = (planeNormal.dot(vtxInPlane) - planeConstant);
|
||||||
|
|
||||||
|
btVector3 vtxInPlaneProjected = vtxInPlane - distance*planeNormal;
|
||||||
|
btVector3 vtxInPlaneWorld = planeObj->getWorldTransform() * vtxInPlaneProjected;
|
||||||
|
|
||||||
|
hasCollision = distance < m_manifoldPtr->getContactBreakingThreshold();
|
||||||
|
resultOut->setPersistentManifold(m_manifoldPtr);
|
||||||
|
if (hasCollision)
|
||||||
{
|
{
|
||||||
btQuaternion rotq(0,0,0,1);
|
/// report a contact. internally this will be kept persistent, and contact reduction is done
|
||||||
collideSingleContact(rotq,body0,body1,dispatchInfo,resultOut);
|
btVector3 normalOnSurfaceB = planeObj->getWorldTransform().getBasis() * planeNormal;
|
||||||
|
btVector3 pOnB = vtxInPlaneWorld;
|
||||||
|
resultOut->addContactPoint(normalOnSurfaceB,pOnB,distance);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (resultOut->getPersistentManifold()->getNumContacts()<m_minimumPointsPerturbationThreshold)
|
if (resultOut->getPersistentManifold()->getNumContacts()<m_minimumPointsPerturbationThreshold)
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ public:
|
|||||||
|
|
||||||
CreateFunc()
|
CreateFunc()
|
||||||
: m_numPerturbationIterations(1),
|
: m_numPerturbationIterations(1),
|
||||||
m_minimumPointsPerturbationThreshold(1)
|
m_minimumPointsPerturbationThreshold(0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -417,10 +417,10 @@ void btPolyhedralConvexAabbCachingShape::recalcLocalAabb()
|
|||||||
btVector3 vec(btScalar(0.),btScalar(0.),btScalar(0.));
|
btVector3 vec(btScalar(0.),btScalar(0.),btScalar(0.));
|
||||||
vec[i] = btScalar(1.);
|
vec[i] = btScalar(1.);
|
||||||
btVector3 tmp = localGetSupportingVertex(vec);
|
btVector3 tmp = localGetSupportingVertex(vec);
|
||||||
m_localAabbMax[i] = tmp[i]+m_collisionMargin;
|
m_localAabbMax[i] = tmp[i];
|
||||||
vec[i] = btScalar(-1.);
|
vec[i] = btScalar(-1.);
|
||||||
tmp = localGetSupportingVertex(vec);
|
tmp = localGetSupportingVertex(vec);
|
||||||
m_localAabbMin[i] = tmp[i]-m_collisionMargin;
|
m_localAabbMin[i] = tmp[i];
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user