Add support to serialize btOptimizedBvh/btQuantizedBvh for a btBvhTriangleMeshShape (using the new btSerializer). This is a new implementation, with full cross-platform support.

So it is different from the in-place method (btQuantizedBvh::serializeInPlace/deserializeInPlace).

It is also possible to serialize/deserialize just the bvh, using the btSerializer (needs some code snippet/helper)
See also http://bulletphysics.org/Bullet/phpBB3/viewtopic.php?f=9&t=4770
This commit is contained in:
erwin.coumans
2010-02-23 09:03:46 +00:00
parent e4c3c2a1a2
commit 41e9115bca
15 changed files with 929 additions and 451 deletions

View File

@@ -282,7 +282,22 @@ btCollisionShape* btBulletWorldImporter::convertCollisionShape( btCollisionShap
btVector3 scaling; scaling.deSerializeFloat(trimesh->m_meshInterface.m_scaling);
meshInterface->setScaling(scaling);
btCollisionShape* trimeshShape = createBvhTriangleMeshShape(meshInterface);
btOptimizedBvh* bvh = 0;
if (trimesh->m_quantizedFloatBvh)
{
bvh = createOptimizedBvh();
bvh->deSerializeFloat(*trimesh->m_quantizedFloatBvh);
}
if (trimesh->m_quantizedDoubleBvh)
{
bvh = createOptimizedBvh();
bvh->deSerializeDouble(*trimesh->m_quantizedDoubleBvh);
}
btCollisionShape* trimeshShape = createBvhTriangleMeshShape(meshInterface,bvh);
trimeshShape->setMargin(trimesh->m_collisionMargin);
shape = trimeshShape;
@@ -750,8 +765,20 @@ btTriangleIndexVertexArray* btBulletWorldImporter::createTriangleMeshContainer()
{
return new btTriangleIndexVertexArray();
}
btCollisionShape* btBulletWorldImporter::createBvhTriangleMeshShape(btStridingMeshInterface* trimesh)
btOptimizedBvh* btBulletWorldImporter::createOptimizedBvh()
{
return new btOptimizedBvh();
}
btCollisionShape* btBulletWorldImporter::createBvhTriangleMeshShape(btStridingMeshInterface* trimesh, btOptimizedBvh* bvh)
{
if (bvh)
{
btBvhTriangleMeshShape* bvhTriMesh = new btBvhTriangleMeshShape(trimesh,bvh->isQuantized(), false);
bvhTriMesh->setOptimizedBvh(bvh);
return bvhTriMesh;
}
return new btBvhTriangleMeshShape(trimesh,true);
}
btCollisionShape* btBulletWorldImporter::createConvexTriangleMeshShape(btStridingMeshInterface* trimesh)