Make .bullet serialization mode robust:

Deal with broken DNA serialization. Bullet 2.76 release revision 2035 - 2046 was broken, and this includes the Maya Dynamica plugin.
Added some workaround to deal with the broken .bullet files, instead of crashing.
This commit is contained in:
erwin.coumans
2010-03-02 09:32:34 +00:00
parent c517f14dd4
commit 8fbe399ea4
19 changed files with 741 additions and 577 deletions

View File

@@ -141,6 +141,11 @@ BT_DECLARE_ALIGNED_ALLOCATOR();
return (proxyType < CONCAVE_SHAPES_START_HERE);
}
static SIMD_FORCE_INLINE bool isNonMoving(int proxyType)
{
return (isConcave(proxyType) && !(proxyType==GIMPACT_SHAPE_PROXYTYPE));
}
static SIMD_FORCE_INLINE bool isConcave(int proxyType)
{
return ((proxyType > CONCAVE_SHAPES_START_HERE) &&

View File

@@ -71,6 +71,10 @@ public:
{
return btBroadphaseProxy::isConvex(getShapeType());
}
SIMD_FORCE_INLINE bool isNonMoving() const
{
return btBroadphaseProxy::isNonMoving(getShapeType());
}
SIMD_FORCE_INLINE bool isConcave() const
{
return btBroadphaseProxy::isConcave(getShapeType());

View File

@@ -220,6 +220,7 @@ const char* btStridingMeshInterface::serialize(void* dataBuffer, btSerializer* s
getLockedReadOnlyVertexIndexBase(&vertexbase,numverts,type,stride,&indexbase,indexstride,numtriangles,gfxindextype,part);
memPtr->m_numTriangles = numtriangles;//indices = 3*numtriangles
memPtr->m_numVertices = numverts;
memPtr->m_indices16 = 0;
memPtr->m_indices32 = 0;
memPtr->m_3indices16 = 0;
memPtr->m_vertices3f = 0;

View File

@@ -104,7 +104,11 @@ struct btIntIndexData
int m_value;
};
struct btShortIntIndexData
{
short m_value;
char m_pad[2];
};
struct btShortIntIndexTripletData
{
@@ -121,6 +125,8 @@ struct btMeshPartData
btIntIndexData *m_indices32;
btShortIntIndexTripletData *m_3indices16;
btShortIntIndexData *m_indices16;//backwards compatibility
int m_numTriangles;//length of m_indices = m_numTriangles
int m_numVertices;
};

View File

@@ -881,22 +881,24 @@ btScalar btGImpactCollisionAlgorithm::calculateTimeOfImpact(btCollisionObject* b
///////////////////////////////////// REGISTERING ALGORITHM //////////////////////////////////////////////
btGImpactCollisionAlgorithm::CreateFunc g_gimpact_cf;
//! Use this function for register the algorithm externally
void btGImpactCollisionAlgorithm::registerAlgorithm(btCollisionDispatcher * dispatcher)
{
static btGImpactCollisionAlgorithm::CreateFunc s_gimpact_cf;
int i;
for ( i = 0;i < MAX_BROADPHASE_COLLISION_TYPES ;i++ )
{
dispatcher->registerCollisionCreateFunc(GIMPACT_SHAPE_PROXYTYPE,i ,&g_gimpact_cf);
dispatcher->registerCollisionCreateFunc(GIMPACT_SHAPE_PROXYTYPE,i ,&s_gimpact_cf);
}
for ( i = 0;i < MAX_BROADPHASE_COLLISION_TYPES ;i++ )
{
dispatcher->registerCollisionCreateFunc(i,GIMPACT_SHAPE_PROXYTYPE ,&g_gimpact_cf);
dispatcher->registerCollisionCreateFunc(i,GIMPACT_SHAPE_PROXYTYPE ,&s_gimpact_cf);
}
}