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:
erwin.coumans
2008-11-10 20:33:14 +00:00
parent 8865e38e5b
commit 3c0ca0d931
8 changed files with 39 additions and 25 deletions

View File

@@ -1724,9 +1724,16 @@ void SoftDemo::initPhysics()
tr.setOrigin(btVector3(0,-12,0)); tr.setOrigin(btVector3(0,-12,0));
#define USE_COLLISION_OBJECT 1
localCreateRigidBody(0.f,tr,m_collisionShapes[0]); #ifdef USE_COLLISION_OBJECT
btCollisionObject* newOb = new btCollisionObject();
newOb->setWorldTransform(tr);
newOb->setInterpolationWorldTransform( tr);
newOb->setCollisionShape(m_collisionShapes[0]);
m_dynamicsWorld->addCollisionObject(newOb);
#else
this->localCreateRigidBody(0,tr,m_collisionShapes[0]);
#endif //USE_COLLISION_OBJECT
// clientResetScene(); // clientResetScene();

View File

@@ -22,7 +22,6 @@ ADD_LIBRARY(XML
hash.c hash.c
HTMLparser.c HTMLparser.c
HTMLtree.c HTMLtree.c
legacy.c
list.c list.c
nanoftp.c nanoftp.c
nanohttp.c nanohttp.c

View File

@@ -27,7 +27,7 @@ libxml2_la_SOURCES = SAX.c entities.c encoding.c error.c parserInternals.c \
catalog.c globals.c threads.c c14n.c xmlstring.c \ catalog.c globals.c threads.c c14n.c xmlstring.c \
xmlregexp.c xmlschemas.c xmlschemastypes.c xmlunicode.c \ xmlregexp.c xmlschemas.c xmlschemastypes.c xmlunicode.c \
triostr.c trio.c xmlreader.c relaxng.c dict.c SAX2.c \ triostr.c trio.c xmlreader.c relaxng.c dict.c SAX2.c \
xmlwriter.c legacy.c chvalid.c pattern.c xmlsave.c \ xmlwriter.c chvalid.c pattern.c xmlsave.c \
xmlmodule.c schematron.c xmlmodule.c schematron.c
else else
libxml2_la_SOURCES = SAX.c entities.c encoding.c error.c parserInternals.c \ libxml2_la_SOURCES = SAX.c entities.c encoding.c error.c parserInternals.c \
@@ -37,7 +37,7 @@ libxml2_la_SOURCES = SAX.c entities.c encoding.c error.c parserInternals.c \
catalog.c globals.c threads.c c14n.c xmlstring.c \ catalog.c globals.c threads.c c14n.c xmlstring.c \
xmlregexp.c xmlschemas.c xmlschemastypes.c xmlunicode.c \ xmlregexp.c xmlschemas.c xmlschemastypes.c xmlunicode.c \
xmlreader.c relaxng.c dict.c SAX2.c \ xmlreader.c relaxng.c dict.c SAX2.c \
xmlwriter.c legacy.c chvalid.c pattern.c xmlsave.c \ xmlwriter.c chvalid.c pattern.c xmlsave.c \
xmlmodule.c schematron.c xmlmodule.c schematron.c
endif endif

View File

@@ -2600,7 +2600,7 @@ void btSoftBody::defaultCollisionHandler(btCollisionObject* pco)
case fCollision::CL_RS: case fCollision::CL_RS:
{ {
btSoftColliders::CollideCL_RS collider; btSoftColliders::CollideCL_RS collider;
collider.Process(this,btRigidBody::upcast(pco)); collider.Process(this,pco);
} }
break; break;
} }

View File

@@ -324,11 +324,17 @@ public:
/* Body */ /* Body */
struct Body struct Body
{ {
Cluster* m_soft; Cluster* m_soft;
btRigidBody* m_rigid; btRigidBody* m_rigid;
Body() : m_soft(0),m_rigid(0) {} btCollisionObject* m_collisionObject;
Body(Cluster* p) : m_soft(p),m_rigid(0) {}
Body(btRigidBody* p) : m_soft(0),m_rigid(p) {} 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 void activate() const
{ {
if(m_rigid) m_rigid->activate(); if(m_rigid) m_rigid->activate();
@@ -349,7 +355,7 @@ public:
const btTransform& xform() const const btTransform& xform() const
{ {
static const btTransform identity=btTransform::getIdentity(); 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); if(m_soft) return(m_soft->m_framexform);
return(identity); return(identity);
} }

View File

@@ -708,23 +708,24 @@ struct btSoftColliders
struct CollideCL_RS : ClusterBase struct CollideCL_RS : ClusterBase
{ {
btSoftBody* psb; btSoftBody* psb;
btRigidBody* prb;
btCollisionObject* m_colObj;
void Process(const btDbvtNode* leaf) void Process(const btDbvtNode* leaf)
{ {
btSoftBody::Cluster* cluster=(btSoftBody::Cluster*)leaf->data; btSoftBody::Cluster* cluster=(btSoftBody::Cluster*)leaf->data;
btSoftClusterCollisionShape cshape(cluster); btSoftClusterCollisionShape cshape(cluster);
const btConvexShape* rshape=(const btConvexShape*)prb->getCollisionShape(); const btConvexShape* rshape=(const btConvexShape*)m_colObj->getCollisionShape();
btGjkEpaSolver2::sResults res; btGjkEpaSolver2::sResults res;
if(btGjkEpaSolver2::SignedDistance( &cshape,btTransform::getIdentity(), if(btGjkEpaSolver2::SignedDistance( &cshape,btTransform::getIdentity(),
rshape,prb->getInterpolationWorldTransform(), rshape,m_colObj->getInterpolationWorldTransform(),
btVector3(1,0,0),res)) btVector3(1,0,0),res))
{ {
btSoftBody::CJoint joint; 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(); btSoftBody::CJoint* pj=new(btAlignedAlloc(sizeof(btSoftBody::CJoint),16)) btSoftBody::CJoint();
*pj=joint;psb->m_joints.push_back(pj); *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_erp *= psb->m_cfg.kSKHR_CL;
pj->m_split *= psb->m_cfg.kSK_SPLT_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; psb = ps;
prb = pr; m_colObj = colOb;
idt = ps->m_sst.isdt; idt = ps->m_sst.isdt;
margin = ps->getCollisionShape()->getMargin()+ margin = m_colObj->getCollisionShape()->getMargin()+
pr->getCollisionShape()->getMargin(); m_colObj->getCollisionShape()->getMargin();
friction = btMin(psb->m_cfg.kDF,prb->getFriction()); friction = btMin(psb->m_cfg.kDF,m_colObj->getFriction());
btVector3 mins; btVector3 mins;
btVector3 maxs; btVector3 maxs;
ATTRIBUTE_ALIGNED16(btDbvtVolume) volume; ATTRIBUTE_ALIGNED16(btDbvtVolume) volume;
pr->getCollisionShape()->getAabb(pr->getInterpolationWorldTransform(),mins,maxs); colOb->getCollisionShape()->getAabb(colOb->getInterpolationWorldTransform(),mins,maxs);
volume=btDbvtVolume::FromMM(mins,maxs); volume=btDbvtVolume::FromMM(mins,maxs);
volume.Expand(btVector3(1,1,1)*margin); volume.Expand(btVector3(1,1,1)*margin);
ps->m_cdbvt.collideTV(ps->m_cdbvt.m_root,volume,*this); ps->m_cdbvt.collideTV(ps->m_cdbvt.m_root,volume,*this);

View File

@@ -18,7 +18,7 @@ subject to the following restrictions:
#include "btScalar.h" #include "btScalar.h"
#include "btMinMax.h" #include "btMinMax.h"
#include <math.h>
#if defined (__CELLOS_LV2) && defined (__SPU__) #if defined (__CELLOS_LV2) && defined (__SPU__)
#include <altivec.h> #include <altivec.h>

View File

@@ -18,6 +18,7 @@ subject to the following restrictions:
#define SIMD___SCALAR_H #define SIMD___SCALAR_H
#include <math.h> #include <math.h>
#include <stdlib.h>//size_t for MSVC 6.0 #include <stdlib.h>//size_t for MSVC 6.0
#include <cstdlib> #include <cstdlib>