perform position correction only when objects are penetrating

This commit is contained in:
Xuchen Han
2019-08-02 13:21:06 -07:00
parent 3dc8abcf36
commit 54303e02b1
3 changed files with 11 additions and 9 deletions

View File

@@ -2271,9 +2271,9 @@ bool btSoftBody::checkContact(const btCollisionObjectWrapper* colObjWrap,
btVector3 nrm;
const btCollisionShape* shp = colObjWrap->getCollisionShape();
const btCollisionObject* tmpCollisionObj = colObjWrap->getCollisionObject();
// get the position x_{n+1}^* = x_n + dt * v_{n+1}^* where v_{n+1}^* = v_n + dtg
// use the position x_{n+1}^* = x_n + dt * v_{n+1}^* where v_{n+1}^* = v_n + dtg for collision detect
// but resolve contact at x_n
const btTransform &wtr = (predict) ? tmpCollisionObj->getInterpolationWorldTransform() : colObjWrap->getWorldTransform();
// const btTransform &wtr = colObjWrap->getWorldTransform();
btScalar dst =
m_worldInfo->m_sparsesdf.Evaluate(
@@ -2281,13 +2281,14 @@ bool btSoftBody::checkContact(const btCollisionObjectWrapper* colObjWrap,
shp,
nrm,
margin);
if (dst < 0 || !predict)
if (!predict)
{
cti.m_colObj = colObjWrap->getCollisionObject();
cti.m_normal = wtr.getBasis() * nrm;
cti.m_offset = dst;
return (true);
}
if (dst < 0)
return true;
return (false);
}