add support for double precision and 64bit serialization (and compatibility between all versions)

fix some issue in serialization of nested array data
add some tesing files
This commit is contained in:
erwin.coumans
2010-01-25 19:42:51 +00:00
parent 5d8e6dc3f3
commit e7ff71d99b
48 changed files with 1207 additions and 294 deletions

View File

@@ -22,11 +22,12 @@
#include "bullet_PointerArray.h"
#include "bullet_btPhysicsSystem.h"
#include "bullet_ListBase.h"
#include "bullet_btVector3Data.h"
#include "bullet_btVector3FloatData.h"
#include "bullet_btVector3DoubleData.h"
#include "bullet_btMatrix3x3Data.h"
#include "bullet_btTransformData.h"
#include "bullet_btMatrix3x3FloatData.h"
#include "bullet_btMatrix3x3DoubleData.h"
#include "bullet_btTransformFloatData.h"
#include "bullet_btTransformDoubleData.h"
#include "bullet_btCollisionShapeData.h"
#include "bullet_btConvexInternalShapeData.h"
#include "bullet_btPositionAndRadius.h"
@@ -37,6 +38,8 @@
#include "bullet_btStridingMeshInterfaceData.h"
#include "bullet_btTriangleMeshShapeData.h"
#include "bullet_btConvexHullShapeData.h"
#include "bullet_btCollisionObjectData.h"
#include "bullet_btRigidBodyData.h"
#include "bullet_btCollisionObjectDoubleData.h"
#include "bullet_btCollisionObjectFloatData.h"
#include "bullet_btRigidBodyFloatData.h"
#include "bullet_btRigidBodyDoubleData.h"
#endif//__BULLET_H__

View File

@@ -29,11 +29,12 @@ namespace Bullet {
class PointerArray;
class btPhysicsSystem;
class ListBase;
class btVector3Data;
class btVector3FloatData;
class btVector3DoubleData;
class btMatrix3x3Data;
class btTransformData;
class btMatrix3x3FloatData;
class btMatrix3x3DoubleData;
class btTransformFloatData;
class btTransformDoubleData;
class btCollisionShapeData;
class btConvexInternalShapeData;
class btPositionAndRadius;
@@ -44,7 +45,9 @@ namespace Bullet {
class btStridingMeshInterfaceData;
class btTriangleMeshShapeData;
class btConvexHullShapeData;
class btCollisionObjectData;
class btRigidBodyData;
class btCollisionObjectDoubleData;
class btCollisionObjectFloatData;
class btRigidBodyFloatData;
class btRigidBodyDoubleData;
}
#endif//__BULLETCOMMON_H__

View File

@@ -0,0 +1,64 @@
/* Copyright (C) 2006-2009 Erwin Coumans & Charlie C
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
*/
// Auto generated from makesdna dna.c
#ifndef __BULLET_BTCOLLISIONOBJECTDOUBLEDATA__H__
#define __BULLET_BTCOLLISIONOBJECTDOUBLEDATA__H__
// -------------------------------------------------- //
#include "bullet_Common.h"
#include "bullet_btTransformDoubleData.h"
#include "bullet_btVector3DoubleData.h"
namespace Bullet {
// ---------------------------------------------- //
class btCollisionObjectDoubleData
{
public:
void *m_broadphaseHandle;
void *m_collisionShape;
btCollisionShapeData *m_rootCollisionShape;
void *m_userObjectPointer;
btTransformDoubleData m_worldTransform;
btTransformDoubleData m_interpolationWorldTransform;
btVector3DoubleData m_interpolationLinearVelocity;
btVector3DoubleData m_interpolationAngularVelocity;
btVector3DoubleData m_anisotropicFriction;
double m_contactProcessingThreshold;
double m_deactivationTime;
double m_friction;
double m_restitution;
double m_hitFraction;
double m_ccdSweptSphereRadius;
double m_ccdMotionThreshold;
int m_hasAnisotropicFriction;
int m_collisionFlags;
int m_islandTag1;
int m_companionId;
int m_activationState1;
int m_internalType;
int m_checkCollideWith;
char m_padding[4];
};
}
#endif//__BULLET_BTCOLLISIONOBJECTDOUBLEDATA__H__

View File

@@ -0,0 +1,63 @@
/* Copyright (C) 2006-2009 Erwin Coumans & Charlie C
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
*/
// Auto generated from makesdna dna.c
#ifndef __BULLET_BTCOLLISIONOBJECTFLOATDATA__H__
#define __BULLET_BTCOLLISIONOBJECTFLOATDATA__H__
// -------------------------------------------------- //
#include "bullet_Common.h"
#include "bullet_btTransformFloatData.h"
#include "bullet_btVector3FloatData.h"
namespace Bullet {
// ---------------------------------------------- //
class btCollisionObjectFloatData
{
public:
void *m_broadphaseHandle;
void *m_collisionShape;
btCollisionShapeData *m_rootCollisionShape;
void *m_userObjectPointer;
btTransformFloatData m_worldTransform;
btTransformFloatData m_interpolationWorldTransform;
btVector3FloatData m_interpolationLinearVelocity;
btVector3FloatData m_interpolationAngularVelocity;
btVector3FloatData m_anisotropicFriction;
float m_contactProcessingThreshold;
float m_deactivationTime;
float m_friction;
float m_restitution;
float m_hitFraction;
float m_ccdSweptSphereRadius;
float m_ccdMotionThreshold;
int m_hasAnisotropicFriction;
int m_collisionFlags;
int m_islandTag1;
int m_companionId;
int m_activationState1;
int m_internalType;
int m_checkCollideWith;
};
}
#endif//__BULLET_BTCOLLISIONOBJECTFLOATDATA__H__

View File

@@ -33,9 +33,10 @@ namespace Bullet {
{
public:
btConvexInternalShapeData m_convexInternalShapeData;
btVector3Data *m_unscaledPointsPtr;
btVector3FloatData *m_unscaledPointsFloatPtr;
btVector3DoubleData *m_unscaledPointsDoublePtr;
int m_numUnscaledPoints;
char m_padding[4];
char m_padding3[4];
};
}

View File

@@ -24,7 +24,7 @@
// -------------------------------------------------- //
#include "bullet_Common.h"
#include "bullet_btCollisionShapeData.h"
#include "bullet_btVector3Data.h"
#include "bullet_btVector3FloatData.h"
namespace Bullet {
@@ -34,10 +34,10 @@ namespace Bullet {
{
public:
btCollisionShapeData m_collisionShapeData;
btVector3Data m_localScaling;
btVector3Data m_implicitShapeDimensions;
btScalar m_collisionMargin;
char m_padding[4];
btVector3FloatData m_localScaling;
btVector3FloatData m_implicitShapeDimensions;
float m_collisionMargin;
int m_padding;
};
}

View File

@@ -0,0 +1,40 @@
/* Copyright (C) 2006-2009 Erwin Coumans & Charlie C
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
*/
// Auto generated from makesdna dna.c
#ifndef __BULLET_BTMATRIX3X3DOUBLEDATA__H__
#define __BULLET_BTMATRIX3X3DOUBLEDATA__H__
// -------------------------------------------------- //
#include "bullet_Common.h"
#include "bullet_btVector3DoubleData.h"
namespace Bullet {
// ---------------------------------------------- //
class btMatrix3x3DoubleData
{
public:
btVector3DoubleData m_el[3];
};
}
#endif//__BULLET_BTMATRIX3X3DOUBLEDATA__H__

View File

@@ -0,0 +1,40 @@
/* Copyright (C) 2006-2009 Erwin Coumans & Charlie C
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
*/
// Auto generated from makesdna dna.c
#ifndef __BULLET_BTMATRIX3X3FLOATDATA__H__
#define __BULLET_BTMATRIX3X3FLOATDATA__H__
// -------------------------------------------------- //
#include "bullet_Common.h"
#include "bullet_btVector3FloatData.h"
namespace Bullet {
// ---------------------------------------------- //
class btMatrix3x3FloatData
{
public:
btVector3FloatData m_el[3];
};
}
#endif//__BULLET_BTMATRIX3X3FLOATDATA__H__

View File

@@ -23,7 +23,7 @@
// -------------------------------------------------- //
#include "bullet_Common.h"
#include "bullet_btVector3Data.h"
#include "bullet_btVector3FloatData.h"
namespace Bullet {
@@ -32,8 +32,8 @@ namespace Bullet {
class btPositionAndRadius
{
public:
btVector3Data m_pos;
btScalar m_radius;
btVector3FloatData m_pos;
float m_radius;
};
}

View File

@@ -0,0 +1,63 @@
/* Copyright (C) 2006-2009 Erwin Coumans & Charlie C
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
*/
// Auto generated from makesdna dna.c
#ifndef __BULLET_BTRIGIDBODYDOUBLEDATA__H__
#define __BULLET_BTRIGIDBODYDOUBLEDATA__H__
// -------------------------------------------------- //
#include "bullet_Common.h"
#include "bullet_btCollisionObjectDoubleData.h"
#include "bullet_btMatrix3x3DoubleData.h"
#include "bullet_btVector3DoubleData.h"
namespace Bullet {
// ---------------------------------------------- //
class btRigidBodyDoubleData
{
public:
btCollisionObjectDoubleData m_collisionObjectData;
btMatrix3x3DoubleData m_invInertiaTensorWorld;
btVector3DoubleData m_linearVelocity;
btVector3DoubleData m_angularVelocity;
btVector3DoubleData m_angularFactor;
btVector3DoubleData m_linearFactor;
btVector3DoubleData m_gravity;
btVector3DoubleData m_gravity_acceleration;
btVector3DoubleData m_invInertiaLocal;
btVector3DoubleData m_totalForce;
btVector3DoubleData m_totalTorque;
double m_inverseMass;
double m_linearDamping;
double m_angularDamping;
double m_additionalDampingFactor;
double m_additionalLinearDampingThresholdSqr;
double m_additionalAngularDampingThresholdSqr;
double m_additionalAngularDampingFactor;
double m_linearSleepingThreshold;
double m_angularSleepingThreshold;
int m_additionalDamping;
char m_padding[4];
};
}
#endif//__BULLET_BTRIGIDBODYDOUBLEDATA__H__

View File

@@ -0,0 +1,62 @@
/* Copyright (C) 2006-2009 Erwin Coumans & Charlie C
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
*/
// Auto generated from makesdna dna.c
#ifndef __BULLET_BTRIGIDBODYFLOATDATA__H__
#define __BULLET_BTRIGIDBODYFLOATDATA__H__
// -------------------------------------------------- //
#include "bullet_Common.h"
#include "bullet_btCollisionObjectFloatData.h"
#include "bullet_btMatrix3x3FloatData.h"
#include "bullet_btVector3FloatData.h"
namespace Bullet {
// ---------------------------------------------- //
class btRigidBodyFloatData
{
public:
btCollisionObjectFloatData m_collisionObjectData;
btMatrix3x3FloatData m_invInertiaTensorWorld;
btVector3FloatData m_linearVelocity;
btVector3FloatData m_angularVelocity;
btVector3FloatData m_angularFactor;
btVector3FloatData m_linearFactor;
btVector3FloatData m_gravity;
btVector3FloatData m_gravity_acceleration;
btVector3FloatData m_invInertiaLocal;
btVector3FloatData m_totalForce;
btVector3FloatData m_totalTorque;
float m_inverseMass;
float m_linearDamping;
float m_angularDamping;
float m_additionalDampingFactor;
float m_additionalLinearDampingThresholdSqr;
float m_additionalAngularDampingThresholdSqr;
float m_additionalAngularDampingFactor;
float m_linearSleepingThreshold;
float m_angularSleepingThreshold;
int m_additionalDamping;
};
}
#endif//__BULLET_BTRIGIDBODYFLOATDATA__H__

View File

@@ -23,7 +23,7 @@
// -------------------------------------------------- //
#include "bullet_Common.h"
#include "bullet_btVector3Data.h"
#include "bullet_btVector3FloatData.h"
namespace Bullet {
@@ -33,8 +33,8 @@ namespace Bullet {
{
public:
btMeshPartData *m_meshPartsPtr;
btVector3FloatData m_scaling;
int m_numMeshParts;
btVector3Data m_scaling;
char m_padding[4];
};
}

View File

@@ -0,0 +1,42 @@
/* Copyright (C) 2006-2009 Erwin Coumans & Charlie C
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
*/
// Auto generated from makesdna dna.c
#ifndef __BULLET_BTTRANSFORMDOUBLEDATA__H__
#define __BULLET_BTTRANSFORMDOUBLEDATA__H__
// -------------------------------------------------- //
#include "bullet_Common.h"
#include "bullet_btMatrix3x3DoubleData.h"
#include "bullet_btVector3DoubleData.h"
namespace Bullet {
// ---------------------------------------------- //
class btTransformDoubleData
{
public:
btMatrix3x3DoubleData m_basis;
btVector3DoubleData m_origin;
};
}
#endif//__BULLET_BTTRANSFORMDOUBLEDATA__H__

View File

@@ -0,0 +1,42 @@
/* Copyright (C) 2006-2009 Erwin Coumans & Charlie C
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
*/
// Auto generated from makesdna dna.c
#ifndef __BULLET_BTTRANSFORMFLOATDATA__H__
#define __BULLET_BTTRANSFORMFLOATDATA__H__
// -------------------------------------------------- //
#include "bullet_Common.h"
#include "bullet_btMatrix3x3FloatData.h"
#include "bullet_btVector3FloatData.h"
namespace Bullet {
// ---------------------------------------------- //
class btTransformFloatData
{
public:
btMatrix3x3FloatData m_basis;
btVector3FloatData m_origin;
};
}
#endif//__BULLET_BTTRANSFORMFLOATDATA__H__

View File

@@ -23,6 +23,7 @@
// -------------------------------------------------- //
#include "bullet_Common.h"
#include "bullet_btCollisionShapeData.h"
#include "bullet_btStridingMeshInterfaceData.h"
namespace Bullet {
@@ -32,10 +33,10 @@ namespace Bullet {
class btTriangleMeshShapeData
{
public:
bInvalidHandle btCollisionShapeData;
bInvalidHandle m_collisionShapeData;
btCollisionShapeData m_collisionShapeData;
btStridingMeshInterfaceData m_meshInterface;
btScalar m_collisionMargin;
float m_collisionMargin;
char m_padding[4];
};
}

View File

@@ -187,6 +187,8 @@ void bDNA::initCmpFlags(bDNA *memDNA)
mCMPFlags[i] = FDF_NONE;
continue;
}
//char* typeName = mTypes[oldStruct[0]];
//#define SLOW_FORWARD_COMPATIBLE 1
#ifdef SLOW_FORWARD_COMPATIBLE
char* typeName = mTypes[oldLookup];
@@ -227,6 +229,8 @@ void bDNA::initCmpFlags(bDNA *memDNA)
for (int j=0; j<elementLength; j++, curStruct+=2, oldStruct+=2)
{
// type the same
//const char* typeFileDNA = mTypes[oldStruct[0]];
//const char* typeMemDNA = mTypes[curStruct[0]];
if (strcmp(mTypes[oldStruct[0]], memDNA->mTypes[curStruct[0]])!=0)
{
isSame=false;

View File

@@ -109,20 +109,26 @@ void bFile::parseHeader()
memcpy(header, blenderBuf, SIZEOFBLENDERHEADER);
header[SIZEOFBLENDERHEADER]='\0';
if (strncmp(header, m_headerString, 7)!=0)
if (strncmp(header, m_headerString, 6)!=0)
{
printf ("Invalid blend file...");
memcpy(header, m_headerString, SIZEOFBLENDERHEADER);
printf ("Invalid %s file...",header);
return;
}
if (header[6] == 'd')
{
mFlags |= FD_DOUBLE_PRECISION;
}
char *ver = header+9;
mVersion = atoi(ver);
if (mVersion <= 241)
printf ("Warning, %d not fully tested : <= 242\n", mVersion);
int endian= 1;
endian= ((char*)&endian)[0];
int littleEndian= 1;
littleEndian= ((char*)&littleEndian)[0];
// swap ptr sizes...
if (header[7]=='-')
@@ -134,10 +140,10 @@ void bFile::parseHeader()
else if (VOID_IS_8) mFlags |= FD_BITS_VARIES;
// swap endian...
if (header[8]=='V' && endian ==1)
if (header[8]=='V' && littleEndian ==1)
mFlags |= FD_ENDIAN_SWAP;
else
if (endian==0)
if (littleEndian==0)
mFlags |= FD_ENDIAN_SWAP;
@@ -383,12 +389,25 @@ void bFile::parseStruct(char *strcPtr, char *dtPtr, int old_dna, int new_dna, bo
cpo = getFileElement(firstStruct, memName, memType, dtPtr, &filePtrOld);
if (cpo)
{
int arrayLen = mFileDNA->getArraySizeNew(filePtrOld[1]);
old_nr = mFileDNA->getReverseType(memType);
new_nr = revType;
fpLen = mFileDNA->getElementSize(filePtrOld[0], filePtrOld[1]);
if (arrayLen==1)
{
parseStruct(cpc, cpo, old_nr, new_nr,fixupPointers);
} else
{
char* tmpCpc = cpc;
char* tmpCpo = cpo;
parseStruct(cpc, cpo, old_nr, new_nr,fixupPointers);
for (int i=0;i<arrayLen;i++)
{
parseStruct(tmpCpc, tmpCpo, old_nr, new_nr,fixupPointers);
tmpCpc += size/arrayLen;
tmpCpo += fpLen/arrayLen;
}
}
cpc+=size;
cpo+=fpLen;
}

View File

@@ -31,7 +31,8 @@ namespace bParse {
FD_ENDIAN_SWAP =4,
FD_FILE_64 =8,
FD_BITS_VARIES =16,
FD_VERSION_VARIES = 32
FD_VERSION_VARIES = 32,
FD_DOUBLE_PRECISION =64
};

View File

@@ -20,11 +20,13 @@ subject to the following restrictions:
// 32 && 64 bit versions
//#ifdef _WIN64
extern unsigned char sBulletDNAstr64[];
extern int sBulletDNAlen64;
//#else
extern unsigned char sBulletDNAstr[];
extern int sBulletDNAlen;
//not yetto. extern unsigned char DNAstr64[];
//not yetto. extern int DNAlen64;
//#endif //_WIN64
using namespace bParse;
@@ -33,7 +35,13 @@ btBulletFile::btBulletFile()
:bFile("", "BULLET ")
{
mMemoryDNA = new bDNA();
mMemoryDNA->init((char*)sBulletDNAstr,sBulletDNAlen);
//#ifdef _WIN64
if (VOID_IS_8)
mMemoryDNA->init((char*)sBulletDNAstr64,sBulletDNAlen64);
else
//#else
mMemoryDNA->init((char*)sBulletDNAstr,sBulletDNAlen);
//#endif
}
@@ -128,6 +136,9 @@ void btBulletFile::parseData()
// {
// m_glob = (bStructHandle*) id;
// }
} else
{
printf("unknown chunk\n");
}
// next please!
@@ -158,17 +169,25 @@ void btBulletFile::writeDNA(FILE* fp)
if (VOID_IS_8)
{
//dataChunk.len = DNAlen64;
//dataChunk.oldPtr = DNAstr64;
//fwrite(&dataChunk,sizeof(bChunkInd),1,fp);
//fwrite(DNAstr64, DNAlen64,1,fp);
//#ifdef _WIN64
dataChunk.len = sBulletDNAlen64;
dataChunk.oldPtr = sBulletDNAstr64;
fwrite(&dataChunk,sizeof(bChunkInd),1,fp);
fwrite(sBulletDNAstr64, sBulletDNAlen64,1,fp);
//#else
// btAssert(0);
//#endif
}
else
{
//#ifndef _WIN64
dataChunk.len = sBulletDNAlen;
dataChunk.oldPtr = sBulletDNAstr;
fwrite(&dataChunk,sizeof(bChunkInd),1,fp);
fwrite(sBulletDNAstr, sBulletDNAlen,1,fp);
//#else
// btAssert(0);
//#endif
}
}
@@ -177,12 +196,19 @@ void btBulletFile::parse(bool verboseDumpAllTypes)
{
if (VOID_IS_8)
{
exit(0);
//parseInternal(verboseDumpAllTypes,(char*)DNAstr64,DNAlen64);
//#ifdef _WIN64
parseInternal(verboseDumpAllTypes,(char*)sBulletDNAstr64,sBulletDNAlen64);
//#else
// btAssert(0);
//#endif
}
else
{
//#ifndef _WIN64
parseInternal(verboseDumpAllTypes,(char*)sBulletDNAstr,sBulletDNAlen);
//#else
// btAssert(0);
//#endif
}
}

View File

@@ -4,6 +4,7 @@
#include "btBulletDynamicsCommon.h"
btBulletFileLoader::btBulletFileLoader(btDynamicsWorld* world)
:m_dynamicsWorld(world),
m_verboseDumpAllTypes(false)
@@ -12,7 +13,7 @@ m_verboseDumpAllTypes(false)
bool btBulletFileLoader::loadFileFromMemory( char* fileName)
{
bParse::btBulletFile* bulletFile2 = new bParse::btBulletFile("testFile.bullet");
bParse::btBulletFile* bulletFile2 = new bParse::btBulletFile(fileName);
bool result = loadFileFromMemory(bulletFile2);
@@ -69,7 +70,7 @@ bool btBulletFileLoader::loadFileFromMemory( bParse::btBulletFile* bulletFile2)
{
btConvexInternalShapeData* bsd = (btConvexInternalShapeData*)shapeData;
btVector3 implicitShapeDimensions;
implicitShapeDimensions.deSerialize(bsd->m_implicitShapeDimensions);
implicitShapeDimensions.deSerializeFloat(bsd->m_implicitShapeDimensions);
btVector3 margin(bsd->m_collisionMargin,bsd->m_collisionMargin,bsd->m_collisionMargin);
btCollisionShape* shape = 0;
switch (shapeData->m_shapeType)
@@ -107,7 +108,7 @@ bool btBulletFileLoader::loadFileFromMemory( bParse::btBulletFile* bulletFile2)
tmpPos.resize(numSpheres);
for (int i=0;i<numSpheres;i++)
{
tmpPos[i].deSerialize(mss->m_localPositionArrayPtr[i].m_pos);
tmpPos[i].deSerializeFloat(mss->m_localPositionArrayPtr[i].m_pos);
radii[i] = mss->m_localPositionArrayPtr[i].m_radius;
}
shape = new btMultiSphereShape(&tmpPos[0],&radii[0],numSpheres);
@@ -115,6 +116,9 @@ bool btBulletFileLoader::loadFileFromMemory( bParse::btBulletFile* bulletFile2)
}
case CONVEX_HULL_SHAPE_PROXYTYPE:
{
int sz = sizeof(btConvexHullShapeData);
int sz2 = sizeof(btConvexInternalShapeData);
int sz3 = sizeof(btCollisionShapeData);
btConvexHullShapeData* convexData = (btConvexHullShapeData*)bsd;
int numPoints = convexData->m_numUnscaledPoints;
@@ -122,7 +126,17 @@ bool btBulletFileLoader::loadFileFromMemory( bParse::btBulletFile* bulletFile2)
tmpPoints.resize(numPoints);
for (int i=0;i<numPoints;i++)
{
tmpPoints[i].deSerialize(convexData->m_unscaledPointsPtr[i]);
#ifdef BT_USE_DOUBLE_PRECISION
if (convexData->m_unscaledPointsDoublePtr)
tmpPoints[i].deSerialize(convexData->m_unscaledPointsDoublePtr[i]);
if (convexData->m_unscaledPointsFloatPtr)
tmpPoints[i].deSerializeFloat(convexData->m_unscaledPointsFloatPtr[i]);
#else
if (convexData->m_unscaledPointsFloatPtr)
tmpPoints[i].deSerialize(convexData->m_unscaledPointsFloatPtr[i]);
if (convexData->m_unscaledPointsDoublePtr)
tmpPoints[i].deSerializeDouble(convexData->m_unscaledPointsDoublePtr[i]);
#endif //BT_USE_DOUBLE_PRECISION
}
shape = new btConvexHullShape(&tmpPoints[0].getX(),numPoints,sizeof(btVector3));
break;
@@ -137,7 +151,7 @@ bool btBulletFileLoader::loadFileFromMemory( bParse::btBulletFile* bulletFile2)
{
shape->setMargin(bsd->m_collisionMargin);
btVector3 localScaling;
localScaling.deSerialize(bsd->m_localScaling);
localScaling.deSerializeFloat(bsd->m_localScaling);
shape->setLocalScaling(localScaling);
shapeMap.insert(shapeData,shape);
@@ -179,7 +193,7 @@ bool btBulletFileLoader::loadFileFromMemory( bParse::btBulletFile* bulletFile2)
meshInterface->addIndexedMesh(meshPart);
}
btVector3 scaling; scaling.deSerialize(trimesh->m_meshInterface.m_scaling);
btVector3 scaling; scaling.deSerializeFloat(trimesh->m_meshInterface.m_scaling);
meshInterface->setScaling(scaling);
btBvhTriangleMeshShape* trimeshShape = new btBvhTriangleMeshShape(meshInterface,true);
@@ -198,29 +212,53 @@ bool btBulletFileLoader::loadFileFromMemory( bParse::btBulletFile* bulletFile2)
}
for (i=0;i<bulletFile2->m_rigidBodies.size();i++)
{
btRigidBodyData* colObjData = (btRigidBodyData*)bulletFile2->m_rigidBodies[i];
btScalar mass = colObjData->m_inverseMass? 1.f/colObjData->m_inverseMass : 0.f;
btVector3 localInertia;
localInertia.setZero();
btCollisionShape** shapePtr = shapeMap.find(colObjData->m_collisionObjectData.m_collisionShape);
if (shapePtr && *shapePtr)
if (bulletFile2->getFlags() & bParse::FD_DOUBLE_PRECISION)
{
btTransform startTransform;
startTransform.deSerialize(colObjData->m_collisionObjectData.m_worldTransform);
btCollisionShape* shape = (btCollisionShape*)*shapePtr;
if (mass)
btRigidBodyDoubleData* colObjData = (btRigidBodyDoubleData*)bulletFile2->m_rigidBodies[i];
btScalar mass = btScalar(colObjData->m_inverseMass? 1.f/colObjData->m_inverseMass : 0.f);
btVector3 localInertia;
localInertia.setZero();
btCollisionShape** shapePtr = shapeMap.find(colObjData->m_collisionObjectData.m_collisionShape);
if (shapePtr && *shapePtr)
{
shape->calculateLocalInertia(mass,localInertia);
btTransform startTransform;
startTransform.deSerializeDouble(colObjData->m_collisionObjectData.m_worldTransform);
// startTransform.setBasis(btMatrix3x3::getIdentity());
btCollisionShape* shape = (btCollisionShape*)*shapePtr;
if (mass)
{
shape->calculateLocalInertia(mass,localInertia);
}
bool isDynamic = mass!=0.f;
createRigidBody(isDynamic,mass,startTransform,shape);
} else
{
printf("error: no shape found\n");
}
bool isDynamic = mass!=0.f;
createRigidBody(isDynamic,mass,startTransform,shape);
} else
{
printf("error: no shape found\n");
btRigidBodyFloatData* colObjData = (btRigidBodyFloatData*)bulletFile2->m_rigidBodies[i];
btScalar mass = btScalar(colObjData->m_inverseMass? 1.f/colObjData->m_inverseMass : 0.f);
btVector3 localInertia;
localInertia.setZero();
btCollisionShape** shapePtr = shapeMap.find(colObjData->m_collisionObjectData.m_collisionShape);
if (shapePtr && *shapePtr)
{
btTransform startTransform;
startTransform.deSerializeFloat(colObjData->m_collisionObjectData.m_worldTransform);
// startTransform.setBasis(btMatrix3x3::getIdentity());
btCollisionShape* shape = (btCollisionShape*)*shapePtr;
if (mass)
{
shape->calculateLocalInertia(mass,localInertia);
}
bool isDynamic = mass!=0.f;
createRigidBody(isDynamic,mass,startTransform,shape);
} else
{
printf("error: no shape found\n");
}
}
}
@@ -244,7 +282,7 @@ btTypedConstraint* btBulletFileLoader::createUniversalD6Constraint(class btRig
return 0;
}
btRigidBody* btBulletFileLoader::createRigidBody(bool isDynamic, float mass, const btTransform& startTransform,btCollisionShape* shape)
btRigidBody* btBulletFileLoader::createRigidBody(bool isDynamic, btScalar mass, const btTransform& startTransform,btCollisionShape* shape)
{
btVector3 localInertia;

View File

@@ -75,7 +75,7 @@ public:
);
virtual btRigidBody* createRigidBody(bool isDynamic,
float mass,
btScalar mass,
const btTransform& startTransform,
btCollisionShape* shape);