fix broken build

Add btCompoundShape export support for BulletColladaConverter. 
Thanks to JamesH for the report/request:
http://www.bulletphysics.com/Bullet/phpBB3/viewtopic.php?f=12&t=2840
This commit is contained in:
erwin.coumans
2008-11-12 22:25:23 +00:00
parent 5feea39803
commit 9516e505a7
3 changed files with 40 additions and 34 deletions

View File

@@ -1647,9 +1647,39 @@ ColladaConverter::addConcaveMesh(btCollisionShape* shape, const char* nodeName)
}
}
void ColladaConverter::buildShape (btCollisionShape* shape, void* collada_shape, const char* shapeName)
void ColladaConverter::buildShapeNew (btCollisionShape* shape, void* domTechniqueCommon, const char* shapeName,bool isChild,const btTransform& childTrans)
{
domRigid_body::domTechnique_common::domShape* colladaShape = (domRigid_body::domTechnique_common::domShape*)collada_shape;
domRigid_body::domTechnique_common* common = (domRigid_body::domTechnique_common*)domTechniqueCommon;
domRigid_body::domTechnique_common::domShape* colladaShape = (domRigid_body::domTechnique_common::domShape*)common->createAndPlace (COLLADA_ELEMENT_SHAPE);
if (isChild)
{
{
domTranslate* translation = (domTranslate*)colladaShape->createAndPlace (COLLADA_ELEMENT_TRANSLATE);
{
btVector3 np = childTrans.getOrigin();
translation->getValue().append(np[0]);
translation->getValue().append(np[1]);
translation->getValue().append(np[2]);
}
domRotate* rotation = (domRotate*)colladaShape->createAndPlace (COLLADA_ELEMENT_ROTATE);
{
btQuaternion quat = childTrans.getRotation();
btVector3 axis(quat.getX(),quat.getY(),quat.getZ());
axis[3] = 0.f;
//check for axis length
btScalar len = axis.length2();
if (len < SIMD_EPSILON*SIMD_EPSILON)
axis = btVector3(1.f,0.f,0.f);
else
axis /= btSqrt(len);
rotation->getValue().set(0,axis[0]);
rotation->getValue().set(1,axis[1]);
rotation->getValue().set(2,axis[2]);
rotation->getValue().set(3,quat.getAngle()*SIMD_DEGS_PER_RAD);
}
}
}
switch (shape->getShapeType())
{
case BOX_SHAPE_PROXYTYPE:
@@ -1703,34 +1733,10 @@ void ColladaConverter::buildShape (btCollisionShape* shape, void* collada_shape,
btCompoundShape* cs = (btCompoundShape*)shape;
for (int i = 0; i < cs->getNumChildShapes (); i++)
{
btTransform xform = cs->getChildTransform (i);
{
domTranslate* translation = (domTranslate*)colladaShape->createAndPlace (COLLADA_ELEMENT_TRANSLATE);
{
btVector3 np = xform.getOrigin();
translation->getValue().append(np[0]);
translation->getValue().append(np[1]);
translation->getValue().append(np[2]);
}
domRotate* rotation = (domRotate*)colladaShape->createAndPlace (COLLADA_ELEMENT_ROTATE);
{
btQuaternion quat = xform.getRotation();
btVector3 axis(quat.getX(),quat.getY(),quat.getZ());
axis[3] = 0.f;
//check for axis length
btScalar len = axis.length2();
if (len < SIMD_EPSILON*SIMD_EPSILON)
axis = btVector3(1.f,0.f,0.f);
else
axis /= btSqrt(len);
rotation->getValue().set(0,axis[0]);
rotation->getValue().set(1,axis[1]);
rotation->getValue().set(2,axis[2]);
rotation->getValue().set(3,quat.getAngle()*SIMD_DEGS_PER_RAD);
}
}
btCollisionShape* child_shape = cs->getChildShape (i);
buildShape (child_shape, colladaShape, shapeName);
char childShapeName[512];
sprintf(childShapeName,"%s-Child%d",shapeName,i);
buildShapeNew (child_shape, domTechniqueCommon, childShapeName,true, cs->getChildTransform(i));
}
}
break;
@@ -1809,8 +1815,7 @@ domRigid_body* ColladaConverter::addRigidBody (btRigidBody* rb, const char* node
mi->setUrl (material_name);
// collision shape
domRigid_body::domTechnique_common::domShape* colladaShape = (domRigid_body::domTechnique_common::domShape*)common->createAndPlace (COLLADA_ELEMENT_SHAPE);
buildShape (shape, colladaShape, shapeName);
buildShapeNew (shape, common, shapeName);
return colladaRigidBody;
}

View File

@@ -135,7 +135,8 @@ protected:
class domPhysics_scene* getDefaultPhysicsScene ();
class domVisual_scene* getDefaultVisualScene ();
void buildShape (btCollisionShape* shape, void* collada_shape, const char* shapeName);
void buildShapeNew(btCollisionShape* shape, void* domTechniqueCommon, const char* shapeName, bool isChild=false,const btTransform& childTrans=btTransform::getIdentity());
void addConvexHull (btCollisionShape* shape, const char* nodeName);
void addConvexMesh (btCollisionShape* shape, const char* nodeName);

View File

@@ -579,7 +579,7 @@ DBVT_INLINE int Select( const btDbvtAabbMm& o,
const btDbvtAabbMm& b)
{
#if DBVT_SELECT_IMPL == DBVT_IMPL_SSE
static DBVT_ALIGN const unsigned __int32 mask[]={0x7fffffff,0x7fffffff,0x7fffffff,0x7fffffff};
static ATTRIBUTE_ALIGNED16(const unsigned __int32) mask[]={0x7fffffff,0x7fffffff,0x7fffffff,0x7fffffff};
///@todo: the intrinsic version is 11% slower
#if DBVT_USE_INTRINSIC_SSE
@@ -612,7 +612,7 @@ DBVT_INLINE int Select( const btDbvtAabbMm& o,
return tmp.ints[0]&1;
#else
DBVT_ALIGN __int32 r[1];
ATTRIBUTE_ALIGNED16(__int32 r[1]);
__asm
{
mov eax,o