Fix btSoftBody issue, so it can interact with btCollisionObject and btGhostObject (and not just btRigidBody and btSoftBody)
Thank for the report mi076 http://www.bulletphysics.com/Bullet/phpBB3/viewtopic.php?f=9&t=2823 remove legacy.c from libxml removed #include <math.h> from btQuadWord.h , it should be centralized in btScalar.h (to allow easier replacement with fastmath.h etc)
This commit is contained in:
@@ -2600,7 +2600,7 @@ void btSoftBody::defaultCollisionHandler(btCollisionObject* pco)
|
||||
case fCollision::CL_RS:
|
||||
{
|
||||
btSoftColliders::CollideCL_RS collider;
|
||||
collider.Process(this,btRigidBody::upcast(pco));
|
||||
collider.Process(this,pco);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -324,11 +324,17 @@ public:
|
||||
/* Body */
|
||||
struct Body
|
||||
{
|
||||
Cluster* m_soft;
|
||||
btRigidBody* m_rigid;
|
||||
Body() : m_soft(0),m_rigid(0) {}
|
||||
Body(Cluster* p) : m_soft(p),m_rigid(0) {}
|
||||
Body(btRigidBody* p) : m_soft(0),m_rigid(p) {}
|
||||
Cluster* m_soft;
|
||||
btRigidBody* m_rigid;
|
||||
btCollisionObject* m_collisionObject;
|
||||
|
||||
Body() : m_soft(0),m_rigid(0),m_collisionObject(0) {}
|
||||
Body(Cluster* p) : m_soft(p),m_rigid(0),m_collisionObject(0) {}
|
||||
Body(btCollisionObject* colObj) : m_soft(0),m_collisionObject(colObj)
|
||||
{
|
||||
m_rigid = btRigidBody::upcast(m_collisionObject);
|
||||
}
|
||||
|
||||
void activate() const
|
||||
{
|
||||
if(m_rigid) m_rigid->activate();
|
||||
@@ -349,7 +355,7 @@ public:
|
||||
const btTransform& xform() const
|
||||
{
|
||||
static const btTransform identity=btTransform::getIdentity();
|
||||
if(m_rigid) return(m_rigid->getInterpolationWorldTransform());
|
||||
if(m_collisionObject) return(m_collisionObject->getInterpolationWorldTransform());
|
||||
if(m_soft) return(m_soft->m_framexform);
|
||||
return(identity);
|
||||
}
|
||||
|
||||
@@ -708,23 +708,24 @@ struct btSoftColliders
|
||||
struct CollideCL_RS : ClusterBase
|
||||
{
|
||||
btSoftBody* psb;
|
||||
btRigidBody* prb;
|
||||
|
||||
btCollisionObject* m_colObj;
|
||||
void Process(const btDbvtNode* leaf)
|
||||
{
|
||||
btSoftBody::Cluster* cluster=(btSoftBody::Cluster*)leaf->data;
|
||||
btSoftClusterCollisionShape cshape(cluster);
|
||||
const btConvexShape* rshape=(const btConvexShape*)prb->getCollisionShape();
|
||||
const btConvexShape* rshape=(const btConvexShape*)m_colObj->getCollisionShape();
|
||||
btGjkEpaSolver2::sResults res;
|
||||
if(btGjkEpaSolver2::SignedDistance( &cshape,btTransform::getIdentity(),
|
||||
rshape,prb->getInterpolationWorldTransform(),
|
||||
rshape,m_colObj->getInterpolationWorldTransform(),
|
||||
btVector3(1,0,0),res))
|
||||
{
|
||||
btSoftBody::CJoint joint;
|
||||
if(SolveContact(res,cluster,prb,joint))
|
||||
if(SolveContact(res,cluster,m_colObj,joint))//prb,joint))
|
||||
{
|
||||
btSoftBody::CJoint* pj=new(btAlignedAlloc(sizeof(btSoftBody::CJoint),16)) btSoftBody::CJoint();
|
||||
*pj=joint;psb->m_joints.push_back(pj);
|
||||
if(prb->isStaticOrKinematicObject())
|
||||
if(m_colObj->isStaticOrKinematicObject())
|
||||
{
|
||||
pj->m_erp *= psb->m_cfg.kSKHR_CL;
|
||||
pj->m_split *= psb->m_cfg.kSK_SPLT_CL;
|
||||
@@ -737,19 +738,19 @@ struct btSoftColliders
|
||||
}
|
||||
}
|
||||
}
|
||||
void Process(btSoftBody* ps,btRigidBody* pr)
|
||||
void Process(btSoftBody* ps,btCollisionObject* colOb)
|
||||
{
|
||||
psb = ps;
|
||||
prb = pr;
|
||||
m_colObj = colOb;
|
||||
idt = ps->m_sst.isdt;
|
||||
margin = ps->getCollisionShape()->getMargin()+
|
||||
pr->getCollisionShape()->getMargin();
|
||||
friction = btMin(psb->m_cfg.kDF,prb->getFriction());
|
||||
margin = m_colObj->getCollisionShape()->getMargin()+
|
||||
m_colObj->getCollisionShape()->getMargin();
|
||||
friction = btMin(psb->m_cfg.kDF,m_colObj->getFriction());
|
||||
btVector3 mins;
|
||||
btVector3 maxs;
|
||||
|
||||
ATTRIBUTE_ALIGNED16(btDbvtVolume) volume;
|
||||
pr->getCollisionShape()->getAabb(pr->getInterpolationWorldTransform(),mins,maxs);
|
||||
colOb->getCollisionShape()->getAabb(colOb->getInterpolationWorldTransform(),mins,maxs);
|
||||
volume=btDbvtVolume::FromMM(mins,maxs);
|
||||
volume.Expand(btVector3(1,1,1)*margin);
|
||||
ps->m_cdbvt.collideTV(ps->m_cdbvt.m_root,volume,*this);
|
||||
|
||||
Reference in New Issue
Block a user