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

@@ -53,6 +53,7 @@ typedef struct bInvalidHandle {
class btMeshPartData;
class btStridingMeshInterfaceData;
class btTriangleMeshShapeData;
class btScaledTriangleMeshShapeData;
class btCompoundShapeChildData;
class btCompoundShapeData;
class btCylinderShapeData;
@@ -379,6 +380,15 @@ typedef struct bInvalidHandle {
};
// -------------------------------------------------- //
class btScaledTriangleMeshShapeData
{
public:
btTriangleMeshShapeData m_trimeshShapeData;
btVector3FloatData m_localScaling;
};
// -------------------------------------------------- //
class btCompoundShapeChildData
{

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);

View File

@@ -175,6 +175,8 @@ public:
virtual class btConvexHullShape* createConvexHullShape();
virtual class btCompoundShape* createCompoundShape();
virtual class btScaledBvhTriangleMeshShape* createScaledTrangleMeshShape(btBvhTriangleMeshShape* meshShape,const btVector3& localScalingbtBvhTriangleMeshShape);
virtual btTriangleIndexVertexArray* createMeshInterface(btStridingMeshInterfaceData& meshData);
///acceleration and connectivity structures

View File

@@ -130,6 +130,7 @@ typedef unsigned long uintptr_t;
#include "BulletCollision/CollisionShapes/btConvexHullShape.h"
#include "BulletCollision/CollisionShapes/btStridingMeshInterface.h"
#include "BulletCollision/CollisionShapes/btBvhTriangleMeshShape.h"
#include "BulletCollision/CollisionShapes/btScaledBvhTriangleMeshShape.h"
#include "BulletCollision/CollisionShapes/btCompoundShape.h"
#include "BulletCollision/CollisionShapes/btCylinderShape.h"
#include "BulletCollision/CollisionShapes/btCapsuleShape.h"
@@ -170,6 +171,7 @@ char *includefiles[] = {
"../../../src/BulletCollision/CollisionShapes/btMultiSphereShape.h",
"../../../src/BulletCollision/CollisionShapes/btStridingMeshInterface.h",
"../../../src/BulletCollision/CollisionShapes/btBvhTriangleMeshShape.h",
"../../../src/BulletCollision/CollisionShapes/btScaledBvhTriangleMeshShape.h",
"../../../src/BulletCollision/CollisionShapes/btCompoundShape.h",
"../../../src/BulletCollision/CollisionShapes/btCylinderShape.h",
"../../../src/BulletCollision/CollisionShapes/btCapsuleShape.h",

View File

@@ -57,6 +57,37 @@ public:
//debugging
virtual const char* getName()const {return "SCALEDBVHTRIANGLEMESH";}
virtual int calculateSerializeBufferSize() const;
///fills the dataBuffer and returns the struct name (and 0 on failure)
virtual const char* serialize(void* dataBuffer, btSerializer* serializer) const;
};
///do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64
struct btScaledTriangleMeshShapeData
{
btTriangleMeshShapeData m_trimeshShapeData;
btVector3FloatData m_localScaling;
};
SIMD_FORCE_INLINE int btScaledBvhTriangleMeshShape::calculateSerializeBufferSize() const
{
return sizeof(btScaledTriangleMeshShapeData);
}
///fills the dataBuffer and returns the struct name (and 0 on failure)
SIMD_FORCE_INLINE const char* btScaledBvhTriangleMeshShape::serialize(void* dataBuffer, btSerializer* serializer) const
{
btScaledTriangleMeshShapeData* scaledMeshData = (btScaledTriangleMeshShapeData*) dataBuffer;
m_bvhTriMeshShape->serialize(&scaledMeshData->m_trimeshShapeData,serializer);
scaledMeshData->m_trimeshShapeData.m_collisionShapeData.m_shapeType = SCALED_TRIANGLE_MESH_SHAPE_PROXYTYPE;
m_localScaling.serializeFloat(scaledMeshData->m_localScaling);
return "btScaledTriangleMeshShapeData";
}
#endif //BVH_TRIANGLE_MESH_SHAPE_H

File diff suppressed because it is too large Load Diff

View File

@@ -33,6 +33,7 @@ subject to the following restrictions:
#include "BulletCollision/CollisionShapes/btTriangleMesh.h"
#include "BulletCollision/CollisionShapes/btConvexTriangleMeshShape.h"
#include "BulletCollision/CollisionShapes/btBvhTriangleMeshShape.h"
#include "BulletCollision/CollisionShapes/btScaledBvhTriangleMeshShape.h"
#include "BulletCollision/CollisionShapes/btTriangleMeshShape.h"
#include "BulletCollision/CollisionShapes/btTriangleIndexVertexArray.h"
#include "BulletCollision/CollisionShapes/btCompoundShape.h"