add support for btScaledBvhTriangleMeshShape serialization (export and import through btBulletWorldImporter)

This commit is contained in:
erwin.coumans
2011-03-12 20:25:03 +00:00
parent 0c11538a28
commit 7c3db274c2
7 changed files with 726 additions and 652 deletions

View File

@@ -342,6 +342,19 @@ btCollisionShape* btBulletWorldImporter::convertCollisionShape( btCollisionShap
shape = createPlaneShape(planeNormal,planeData->m_planeConstant);
shape->setLocalScaling(localScaling);
break;
}
case SCALED_TRIANGLE_MESH_SHAPE_PROXYTYPE:
{
btScaledTriangleMeshShapeData* scaledMesh = (btScaledTriangleMeshShapeData*) shapeData;
btCollisionShapeData* colShapeData = (btCollisionShapeData*) &scaledMesh->m_trimeshShapeData;
colShapeData->m_shapeType = TRIANGLE_MESH_SHAPE_PROXYTYPE;
btCollisionShape* childShape = convertCollisionShape(colShapeData);
btBvhTriangleMeshShape* meshShape = (btBvhTriangleMeshShape*)childShape;
btVector3 localScaling;
localScaling.deSerializeFloat(scaledMesh->m_localScaling);
shape = createScaledTrangleMeshShape(meshShape, localScaling);
break;
}
case GIMPACT_SHAPE_PROXYTYPE:
@@ -1283,6 +1296,15 @@ btCompoundShape* btBulletWorldImporter::createCompoundShape()
return shape;
}
btScaledBvhTriangleMeshShape* btBulletWorldImporter::createScaledTrangleMeshShape(btBvhTriangleMeshShape* meshShape,const btVector3& localScaling)
{
btScaledBvhTriangleMeshShape* shape = new btScaledBvhTriangleMeshShape(meshShape,localScaling);
m_allocatedCollisionShapes.push_back(shape);
return shape;
}
btRigidBody& btBulletWorldImporter::getFixedBody()
{
static btRigidBody s_fixed(0, 0,0);