From 643b0be4cb3f73bd876493d2a7bd6f76ef27cf06 Mon Sep 17 00:00:00 2001 From: Sergej Reich Date: Thu, 7 Mar 2013 17:53:16 +0000 Subject: bullet: Update to current svn, r2636 Apply patches in patches directory, remove patches that were applied upstream. If you made changes without adding a patch, please check. Fixes [#32233] exporting bullet format results in corrupt files. --- .../src/BulletSoftBody/btSoftBodyInternals.h | 72 ++++++++-------------- 1 file changed, 25 insertions(+), 47 deletions(-) (limited to 'extern/bullet2/src/BulletSoftBody/btSoftBodyInternals.h') diff --git a/extern/bullet2/src/BulletSoftBody/btSoftBodyInternals.h b/extern/bullet2/src/BulletSoftBody/btSoftBodyInternals.h index 5ef8db19396..19d0543ef9e 100644 --- a/extern/bullet2/src/BulletSoftBody/btSoftBodyInternals.h +++ b/extern/bullet2/src/BulletSoftBody/btSoftBodyInternals.h @@ -21,6 +21,7 @@ subject to the following restrictions: #include "LinearMath/btQuickprof.h" +#include "LinearMath/btPolarDecomposition.h" #include "BulletCollision/BroadphaseCollision/btBroadphaseInterface.h" #include "BulletCollision/CollisionDispatch/btCollisionDispatcher.h" #include "BulletCollision/CollisionShapes/btConvexInternalShape.h" @@ -614,32 +615,8 @@ private: // static inline int PolarDecompose( const btMatrix3x3& m,btMatrix3x3& q,btMatrix3x3& s) { - static const btScalar half=(btScalar)0.5; - static const btScalar accuracy=(btScalar)0.0001; - static const int maxiterations=16; - int i=0; - btScalar det=0; - q = Mul(m,1/btVector3(m[0][0],m[1][1],m[2][2]).length()); - det = q.determinant(); - if(!btFuzzyZero(det)) - { - for(;iaccuracy) det=ndet; else break; - } - /* Final orthogonalization */ - Orthogonalize(q); - /* Compute 'S' */ - s=q.transpose()*m; - } - else - { - q.setIdentity(); - s.setIdentity(); - } - return(i); + static const btPolarDecomposition polar; + return polar.decompose(m, q, s); } // @@ -666,7 +643,7 @@ struct btSoftColliders threshold =(btScalar)0; } bool SolveContact( const btGjkEpaSolver2::sResults& res, - btSoftBody::Body ba,btSoftBody::Body bb, + btSoftBody::Body ba,const btSoftBody::Body bb, btSoftBody::CJoint& joint) { if(res.distancedata; btSoftClusterCollisionShape cshape(cluster); - const btConvexShape* rshape=(const btConvexShape*)m_colObj->getCollisionShape(); + const btConvexShape* rshape=(const btConvexShape*)m_colObjWrap->getCollisionShape(); ///don't collide an anchored cluster with a static/kinematic object - if(m_colObj->isStaticOrKinematicObject() && cluster->m_containsAnchor) + if(m_colObjWrap->getCollisionObject()->isStaticOrKinematicObject() && cluster->m_containsAnchor) return; btGjkEpaSolver2::sResults res; if(btGjkEpaSolver2::SignedDistance( &cshape,btTransform::getIdentity(), - rshape,m_colObj->getWorldTransform(), + rshape,m_colObjWrap->getWorldTransform(), btVector3(1,0,0),res)) { btSoftBody::CJoint joint; - if(SolveContact(res,cluster,m_colObj,joint))//prb,joint)) + if(SolveContact(res,cluster,m_colObjWrap->getCollisionObject(),joint))//prb,joint)) { btSoftBody::CJoint* pj=new(btAlignedAlloc(sizeof(btSoftBody::CJoint),16)) btSoftBody::CJoint(); *pj=joint;psb->m_joints.push_back(pj); - if(m_colObj->isStaticOrKinematicObject()) + if(m_colObjWrap->getCollisionObject()->isStaticOrKinematicObject()) { pj->m_erp *= psb->m_cfg.kSKHR_CL; pj->m_split *= psb->m_cfg.kSK_SPLT_CL; @@ -753,19 +730,19 @@ struct btSoftColliders } } } - void Process(btSoftBody* ps,btCollisionObject* colOb) + void ProcessColObj(btSoftBody* ps,const btCollisionObjectWrapper* colObWrap) { psb = ps; - m_colObj = colOb; + m_colObjWrap = colObWrap; idt = ps->m_sst.isdt; - m_margin = m_colObj->getCollisionShape()->getMargin()+psb->getCollisionShape()->getMargin(); + m_margin = m_colObjWrap->getCollisionShape()->getMargin()+psb->getCollisionShape()->getMargin(); ///Bullet rigid body uses multiply instead of minimum to determine combined friction. Some customization would be useful. - friction = btMin(psb->m_cfg.kDF,m_colObj->getFriction()); + friction = btMin(psb->m_cfg.kDF,m_colObjWrap->getCollisionObject()->getFriction()); btVector3 mins; btVector3 maxs; ATTRIBUTE_ALIGNED16(btDbvtVolume) volume; - colOb->getCollisionShape()->getAabb(colOb->getWorldTransform(),mins,maxs); + colObWrap->getCollisionShape()->getAabb(colObWrap->getWorldTransform(),mins,maxs); volume=btDbvtVolume::FromMM(mins,maxs); volume.Expand(btVector3(1,1,1)*m_margin); ps->m_cdbvt.collideTV(ps->m_cdbvt.m_root,volume,*this); @@ -815,7 +792,7 @@ struct btSoftColliders } } - void Process(btSoftBody* psa,btSoftBody* psb) + void ProcessSoftSoft(btSoftBody* psa,btSoftBody* psb) { idt = psa->m_sst.isdt; //m_margin = (psa->getCollisionShape()->getMargin()+psb->getCollisionShape()->getMargin())/2; @@ -840,15 +817,16 @@ struct btSoftColliders { const btScalar m=n.m_im>0?dynmargin:stamargin; btSoftBody::RContact c; + if( (!n.m_battach)&& - psb->checkContact(m_colObj1,n.m_x,m,c.m_cti)) + psb->checkContact(m_colObj1Wrap,n.m_x,m,c.m_cti)) { const btScalar ima=n.m_im; const btScalar imb= m_rigidBody? m_rigidBody->getInvMass() : 0.f; const btScalar ms=ima+imb; if(ms>0) { - const btTransform& wtr=m_rigidBody?m_rigidBody->getWorldTransform() : m_colObj1->getWorldTransform(); + const btTransform& wtr=m_rigidBody?m_rigidBody->getWorldTransform() : m_colObj1Wrap->getCollisionObject()->getWorldTransform(); static const btMatrix3x3 iwiStatic(0,0,0,0,0,0,0,0,0); const btMatrix3x3& iwi=m_rigidBody?m_rigidBody->getInvInertiaTensorWorld() : iwiStatic; const btVector3 ra=n.m_x-wtr.getOrigin(); @@ -857,13 +835,13 @@ struct btSoftColliders const btVector3 vr=vb-va; const btScalar dn=btDot(vr,c.m_cti.m_normal); const btVector3 fv=vr-c.m_cti.m_normal*dn; - const btScalar fc=psb->m_cfg.kDF*m_colObj1->getFriction(); + const btScalar fc=psb->m_cfg.kDF*m_colObj1Wrap->getCollisionObject()->getFriction(); c.m_node = &n; c.m_c0 = ImpulseMatrix(psb->m_sst.sdt,ima,imb,iwi,ra); c.m_c1 = ra; c.m_c2 = ima*psb->m_sst.sdt; - c.m_c3 = fv.length2()<(btFabs(dn)*fc)?0:1-fc; - c.m_c4 = m_colObj1->isStaticOrKinematicObject()?psb->m_cfg.kKHR:psb->m_cfg.kCHR; + c.m_c3 = fv.length2()<(dn*fc*dn*fc)?0:1-fc; + c.m_c4 = m_colObj1Wrap->getCollisionObject()->isStaticOrKinematicObject()?psb->m_cfg.kKHR:psb->m_cfg.kCHR; psb->m_rcontacts.push_back(c); if (m_rigidBody) m_rigidBody->activate(); @@ -871,7 +849,7 @@ struct btSoftColliders } } btSoftBody* psb; - btCollisionObject* m_colObj1; + const btCollisionObjectWrapper* m_colObj1Wrap; btRigidBody* m_rigidBody; btScalar dynmargin; btScalar stamargin; -- cgit v1.2.3