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:
@@ -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())
|
switch (shape->getShapeType())
|
||||||
{
|
{
|
||||||
case BOX_SHAPE_PROXYTYPE:
|
case BOX_SHAPE_PROXYTYPE:
|
||||||
@@ -1703,34 +1733,10 @@ void ColladaConverter::buildShape (btCollisionShape* shape, void* collada_shape,
|
|||||||
btCompoundShape* cs = (btCompoundShape*)shape;
|
btCompoundShape* cs = (btCompoundShape*)shape;
|
||||||
for (int i = 0; i < cs->getNumChildShapes (); i++)
|
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);
|
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;
|
break;
|
||||||
@@ -1809,8 +1815,7 @@ domRigid_body* ColladaConverter::addRigidBody (btRigidBody* rb, const char* node
|
|||||||
mi->setUrl (material_name);
|
mi->setUrl (material_name);
|
||||||
// collision shape
|
// collision shape
|
||||||
|
|
||||||
domRigid_body::domTechnique_common::domShape* colladaShape = (domRigid_body::domTechnique_common::domShape*)common->createAndPlace (COLLADA_ELEMENT_SHAPE);
|
buildShapeNew (shape, common, shapeName);
|
||||||
buildShape (shape, colladaShape, shapeName);
|
|
||||||
|
|
||||||
return colladaRigidBody;
|
return colladaRigidBody;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -135,7 +135,8 @@ protected:
|
|||||||
class domPhysics_scene* getDefaultPhysicsScene ();
|
class domPhysics_scene* getDefaultPhysicsScene ();
|
||||||
class domVisual_scene* getDefaultVisualScene ();
|
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 addConvexHull (btCollisionShape* shape, const char* nodeName);
|
||||||
void addConvexMesh (btCollisionShape* shape, const char* nodeName);
|
void addConvexMesh (btCollisionShape* shape, const char* nodeName);
|
||||||
|
|||||||
@@ -579,7 +579,7 @@ DBVT_INLINE int Select( const btDbvtAabbMm& o,
|
|||||||
const btDbvtAabbMm& b)
|
const btDbvtAabbMm& b)
|
||||||
{
|
{
|
||||||
#if DBVT_SELECT_IMPL == DBVT_IMPL_SSE
|
#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
|
///@todo: the intrinsic version is 11% slower
|
||||||
#if DBVT_USE_INTRINSIC_SSE
|
#if DBVT_USE_INTRINSIC_SSE
|
||||||
|
|
||||||
@@ -612,7 +612,7 @@ DBVT_INLINE int Select( const btDbvtAabbMm& o,
|
|||||||
return tmp.ints[0]&1;
|
return tmp.ints[0]&1;
|
||||||
|
|
||||||
#else
|
#else
|
||||||
DBVT_ALIGN __int32 r[1];
|
ATTRIBUTE_ALIGNED16(__int32 r[1]);
|
||||||
__asm
|
__asm
|
||||||
{
|
{
|
||||||
mov eax,o
|
mov eax,o
|
||||||
|
|||||||
Reference in New Issue
Block a user