Code-style consistency improvement:
Apply clang-format-all.sh using the _clang-format file through all the cpp/.h files. make sure not to apply it to certain serialization structures, since some parser expects the * as part of the name, instead of type. This commit contains no other changes aside from adding and applying clang-format-all.sh
This commit is contained in:
@@ -13,7 +13,6 @@ subject to the following restrictions:
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
|
||||
#include "btBulletWorldImporter.h"
|
||||
#include "../BulletFileLoader/btBulletFile.h"
|
||||
|
||||
@@ -22,14 +21,13 @@ subject to the following restrictions:
|
||||
#include "BulletCollision/Gimpact/btGImpactShape.h"
|
||||
#endif
|
||||
|
||||
|
||||
//#define USE_INTERNAL_EDGE_UTILITY
|
||||
#ifdef USE_INTERNAL_EDGE_UTILITY
|
||||
#include "BulletCollision/CollisionDispatch/btInternalEdgeUtility.h"
|
||||
#endif //USE_INTERNAL_EDGE_UTILITY
|
||||
#endif //USE_INTERNAL_EDGE_UTILITY
|
||||
|
||||
btBulletWorldImporter::btBulletWorldImporter(btDynamicsWorld* world)
|
||||
:btWorldImporter(world)
|
||||
: btWorldImporter(world)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -37,12 +35,10 @@ btBulletWorldImporter::~btBulletWorldImporter()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
bool btBulletWorldImporter::loadFile( const char* fileName, const char* preSwapFilenameOut)
|
||||
bool btBulletWorldImporter::loadFile(const char* fileName, const char* preSwapFilenameOut)
|
||||
{
|
||||
bParse::btBulletFile* bulletFile2 = new bParse::btBulletFile(fileName);
|
||||
|
||||
|
||||
bool result = loadFileFromMemory(bulletFile2);
|
||||
//now you could save the file in 'native' format using
|
||||
//bulletFile2->writeFile("native.bullet");
|
||||
@@ -53,19 +49,15 @@ bool btBulletWorldImporter::loadFile( const char* fileName, const char* preSwapF
|
||||
bulletFile2->preSwap();
|
||||
bulletFile2->writeFile(preSwapFilenameOut);
|
||||
}
|
||||
|
||||
}
|
||||
delete bulletFile2;
|
||||
|
||||
return result;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool btBulletWorldImporter::loadFileFromMemory( char* memoryBuffer, int len)
|
||||
bool btBulletWorldImporter::loadFileFromMemory(char* memoryBuffer, int len)
|
||||
{
|
||||
bParse::btBulletFile* bulletFile2 = new bParse::btBulletFile(memoryBuffer,len);
|
||||
bParse::btBulletFile* bulletFile2 = new bParse::btBulletFile(memoryBuffer, len);
|
||||
|
||||
bool result = loadFileFromMemory(bulletFile2);
|
||||
|
||||
@@ -74,36 +66,31 @@ bool btBulletWorldImporter::loadFileFromMemory( char* memoryBuffer, int len)
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
bool btBulletWorldImporter::loadFileFromMemory( bParse::btBulletFile* bulletFile2)
|
||||
bool btBulletWorldImporter::loadFileFromMemory(bParse::btBulletFile* bulletFile2)
|
||||
{
|
||||
bool ok = (bulletFile2->getFlags()& bParse::FD_OK)!=0;
|
||||
|
||||
bool ok = (bulletFile2->getFlags() & bParse::FD_OK) != 0;
|
||||
|
||||
if (ok)
|
||||
bulletFile2->parse(m_verboseMode);
|
||||
else
|
||||
else
|
||||
return false;
|
||||
|
||||
|
||||
if (m_verboseMode & bParse::FD_VERBOSE_DUMP_CHUNKS)
|
||||
{
|
||||
bulletFile2->dumpChunks(bulletFile2->getFileDNA());
|
||||
}
|
||||
|
||||
return convertAllObjects(bulletFile2);
|
||||
|
||||
}
|
||||
|
||||
bool btBulletWorldImporter::convertAllObjects( bParse::btBulletFile* bulletFile2)
|
||||
bool btBulletWorldImporter::convertAllObjects(bParse::btBulletFile* bulletFile2)
|
||||
{
|
||||
|
||||
m_shapeMap.clear();
|
||||
m_bodyMap.clear();
|
||||
|
||||
int i;
|
||||
|
||||
for (i=0;i<bulletFile2->m_bvhs.size();i++)
|
||||
|
||||
for (i = 0; i < bulletFile2->m_bvhs.size(); i++)
|
||||
{
|
||||
btOptimizedBvh* bvh = createOptimizedBvh();
|
||||
|
||||
@@ -111,41 +98,34 @@ bool btBulletWorldImporter::convertAllObjects( bParse::btBulletFile* bulletFile
|
||||
{
|
||||
btQuantizedBvhDoubleData* bvhData = (btQuantizedBvhDoubleData*)bulletFile2->m_bvhs[i];
|
||||
bvh->deSerializeDouble(*bvhData);
|
||||
} else
|
||||
}
|
||||
else
|
||||
{
|
||||
btQuantizedBvhFloatData* bvhData = (btQuantizedBvhFloatData*)bulletFile2->m_bvhs[i];
|
||||
bvh->deSerializeFloat(*bvhData);
|
||||
}
|
||||
m_bvhMap.insert(bulletFile2->m_bvhs[i],bvh);
|
||||
m_bvhMap.insert(bulletFile2->m_bvhs[i], bvh);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
for (i=0;i<bulletFile2->m_collisionShapes.size();i++)
|
||||
for (i = 0; i < bulletFile2->m_collisionShapes.size(); i++)
|
||||
{
|
||||
btCollisionShapeData* shapeData = (btCollisionShapeData*)bulletFile2->m_collisionShapes[i];
|
||||
btCollisionShape* shape = convertCollisionShape(shapeData);
|
||||
if (shape)
|
||||
{
|
||||
// printf("shapeMap.insert(%x,%x)\n",shapeData,shape);
|
||||
m_shapeMap.insert(shapeData,shape);
|
||||
// printf("shapeMap.insert(%x,%x)\n",shapeData,shape);
|
||||
m_shapeMap.insert(shapeData, shape);
|
||||
}
|
||||
|
||||
if (shape&& shapeData->m_name)
|
||||
if (shape && shapeData->m_name)
|
||||
{
|
||||
char* newname = duplicateName(shapeData->m_name);
|
||||
m_objectNameMap.insert(shape,newname);
|
||||
m_nameShapeMap.insert(newname,shape);
|
||||
m_objectNameMap.insert(shape, newname);
|
||||
m_nameShapeMap.insert(newname, shape);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
for (int i=0;i<bulletFile2->m_dynamicsWorldInfo.size();i++)
|
||||
for (int i = 0; i < bulletFile2->m_dynamicsWorldInfo.size(); i++)
|
||||
{
|
||||
if (bulletFile2->getFlags() & bParse::FD_DOUBLE_PRECISION)
|
||||
{
|
||||
@@ -169,21 +149,22 @@ bool btBulletWorldImporter::convertAllObjects( bParse::btBulletFile* bulletFile
|
||||
solverInfo.m_globalCfm = btScalar(solverInfoData->m_solverInfo.m_globalCfm);
|
||||
solverInfo.m_splitImpulsePenetrationThreshold = btScalar(solverInfoData->m_solverInfo.m_splitImpulsePenetrationThreshold);
|
||||
solverInfo.m_splitImpulseTurnErp = btScalar(solverInfoData->m_solverInfo.m_splitImpulseTurnErp);
|
||||
|
||||
|
||||
solverInfo.m_linearSlop = btScalar(solverInfoData->m_solverInfo.m_linearSlop);
|
||||
solverInfo.m_warmstartingFactor = btScalar(solverInfoData->m_solverInfo.m_warmstartingFactor);
|
||||
solverInfo.m_maxGyroscopicForce = btScalar(solverInfoData->m_solverInfo.m_maxGyroscopicForce);
|
||||
solverInfo.m_singleAxisRollingFrictionThreshold = btScalar(solverInfoData->m_solverInfo.m_singleAxisRollingFrictionThreshold);
|
||||
|
||||
|
||||
solverInfo.m_numIterations = solverInfoData->m_solverInfo.m_numIterations;
|
||||
solverInfo.m_solverMode = solverInfoData->m_solverInfo.m_solverMode;
|
||||
solverInfo.m_restingContactRestitutionThreshold = solverInfoData->m_solverInfo.m_restingContactRestitutionThreshold;
|
||||
solverInfo.m_minimumSolverBatchSize = solverInfoData->m_solverInfo.m_minimumSolverBatchSize;
|
||||
|
||||
|
||||
solverInfo.m_splitImpulse = solverInfoData->m_solverInfo.m_splitImpulse;
|
||||
|
||||
setDynamicsWorldInfo(gravity,solverInfo);
|
||||
} else
|
||||
setDynamicsWorldInfo(gravity, solverInfo);
|
||||
}
|
||||
else
|
||||
{
|
||||
btDynamicsWorldFloatData* solverInfoData = (btDynamicsWorldFloatData*)bulletFile2->m_dynamicsWorldInfo[i];
|
||||
btContactSolverInfo solverInfo;
|
||||
@@ -205,40 +186,38 @@ bool btBulletWorldImporter::convertAllObjects( bParse::btBulletFile* bulletFile
|
||||
solverInfo.m_globalCfm = solverInfoData->m_solverInfo.m_globalCfm;
|
||||
solverInfo.m_splitImpulsePenetrationThreshold = solverInfoData->m_solverInfo.m_splitImpulsePenetrationThreshold;
|
||||
solverInfo.m_splitImpulseTurnErp = solverInfoData->m_solverInfo.m_splitImpulseTurnErp;
|
||||
|
||||
|
||||
solverInfo.m_linearSlop = solverInfoData->m_solverInfo.m_linearSlop;
|
||||
solverInfo.m_warmstartingFactor = solverInfoData->m_solverInfo.m_warmstartingFactor;
|
||||
solverInfo.m_maxGyroscopicForce = solverInfoData->m_solverInfo.m_maxGyroscopicForce;
|
||||
solverInfo.m_singleAxisRollingFrictionThreshold = solverInfoData->m_solverInfo.m_singleAxisRollingFrictionThreshold;
|
||||
|
||||
|
||||
solverInfo.m_numIterations = solverInfoData->m_solverInfo.m_numIterations;
|
||||
solverInfo.m_solverMode = solverInfoData->m_solverInfo.m_solverMode;
|
||||
solverInfo.m_restingContactRestitutionThreshold = solverInfoData->m_solverInfo.m_restingContactRestitutionThreshold;
|
||||
solverInfo.m_minimumSolverBatchSize = solverInfoData->m_solverInfo.m_minimumSolverBatchSize;
|
||||
|
||||
|
||||
solverInfo.m_splitImpulse = solverInfoData->m_solverInfo.m_splitImpulse;
|
||||
|
||||
setDynamicsWorldInfo(gravity,solverInfo);
|
||||
setDynamicsWorldInfo(gravity, solverInfo);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for (i=0;i<bulletFile2->m_rigidBodies.size();i++)
|
||||
for (i = 0; i < bulletFile2->m_rigidBodies.size(); i++)
|
||||
{
|
||||
if (bulletFile2->getFlags() & bParse::FD_DOUBLE_PRECISION)
|
||||
{
|
||||
btRigidBodyDoubleData* colObjData = (btRigidBodyDoubleData*)bulletFile2->m_rigidBodies[i];
|
||||
convertRigidBodyDouble(colObjData);
|
||||
} else
|
||||
}
|
||||
else
|
||||
{
|
||||
btRigidBodyFloatData* colObjData = (btRigidBodyFloatData*)bulletFile2->m_rigidBodies[i];
|
||||
convertRigidBodyFloat(colObjData);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
for (i=0;i<bulletFile2->m_collisionObjects.size();i++)
|
||||
for (i = 0; i < bulletFile2->m_collisionObjects.size(); i++)
|
||||
{
|
||||
if (bulletFile2->getFlags() & bParse::FD_DOUBLE_PRECISION)
|
||||
{
|
||||
@@ -249,29 +228,30 @@ bool btBulletWorldImporter::convertAllObjects( bParse::btBulletFile* bulletFile
|
||||
btTransform startTransform;
|
||||
colObjData->m_worldTransform.m_origin.m_floats[3] = 0.f;
|
||||
startTransform.deSerializeDouble(colObjData->m_worldTransform);
|
||||
|
||||
|
||||
btCollisionShape* shape = (btCollisionShape*)*shapePtr;
|
||||
btCollisionObject* body = createCollisionObject(startTransform,shape,colObjData->m_name);
|
||||
btCollisionObject* body = createCollisionObject(startTransform, shape, colObjData->m_name);
|
||||
body->setFriction(btScalar(colObjData->m_friction));
|
||||
body->setRestitution(btScalar(colObjData->m_restitution));
|
||||
|
||||
|
||||
#ifdef USE_INTERNAL_EDGE_UTILITY
|
||||
if (shape->getShapeType() == TRIANGLE_MESH_SHAPE_PROXYTYPE)
|
||||
{
|
||||
btBvhTriangleMeshShape* trimesh = (btBvhTriangleMeshShape*)shape;
|
||||
if (trimesh->getTriangleInfoMap())
|
||||
{
|
||||
body->setCollisionFlags(body->getCollisionFlags() | btCollisionObject::CF_CUSTOM_MATERIAL_CALLBACK);
|
||||
body->setCollisionFlags(body->getCollisionFlags() | btCollisionObject::CF_CUSTOM_MATERIAL_CALLBACK);
|
||||
}
|
||||
}
|
||||
#endif //USE_INTERNAL_EDGE_UTILITY
|
||||
m_bodyMap.insert(colObjData,body);
|
||||
} else
|
||||
#endif //USE_INTERNAL_EDGE_UTILITY
|
||||
m_bodyMap.insert(colObjData, body);
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("error: no shape found\n");
|
||||
}
|
||||
|
||||
} else
|
||||
}
|
||||
else
|
||||
{
|
||||
btCollisionObjectFloatData* colObjData = (btCollisionObjectFloatData*)bulletFile2->m_collisionObjects[i];
|
||||
btCollisionShape** shapePtr = m_shapeMap.find(colObjData->m_collisionShape);
|
||||
@@ -280,9 +260,9 @@ bool btBulletWorldImporter::convertAllObjects( bParse::btBulletFile* bulletFile
|
||||
btTransform startTransform;
|
||||
colObjData->m_worldTransform.m_origin.m_floats[3] = 0.f;
|
||||
startTransform.deSerializeFloat(colObjData->m_worldTransform);
|
||||
|
||||
|
||||
btCollisionShape* shape = (btCollisionShape*)*shapePtr;
|
||||
btCollisionObject* body = createCollisionObject(startTransform,shape,colObjData->m_name);
|
||||
btCollisionObject* body = createCollisionObject(startTransform, shape, colObjData->m_name);
|
||||
|
||||
#ifdef USE_INTERNAL_EDGE_UTILITY
|
||||
if (shape->getShapeType() == TRIANGLE_MESH_SHAPE_PROXYTYPE)
|
||||
@@ -290,21 +270,20 @@ bool btBulletWorldImporter::convertAllObjects( bParse::btBulletFile* bulletFile
|
||||
btBvhTriangleMeshShape* trimesh = (btBvhTriangleMeshShape*)shape;
|
||||
if (trimesh->getTriangleInfoMap())
|
||||
{
|
||||
body->setCollisionFlags(body->getCollisionFlags() | btCollisionObject::CF_CUSTOM_MATERIAL_CALLBACK);
|
||||
body->setCollisionFlags(body->getCollisionFlags() | btCollisionObject::CF_CUSTOM_MATERIAL_CALLBACK);
|
||||
}
|
||||
}
|
||||
#endif //USE_INTERNAL_EDGE_UTILITY
|
||||
m_bodyMap.insert(colObjData,body);
|
||||
} else
|
||||
#endif //USE_INTERNAL_EDGE_UTILITY
|
||||
m_bodyMap.insert(colObjData, body);
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("error: no shape found\n");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
for (i=0;i<bulletFile2->m_constraints.size();i++)
|
||||
for (i = 0; i < bulletFile2->m_constraints.size(); i++)
|
||||
{
|
||||
btTypedConstraintData2* constraintData = (btTypedConstraintData2*)bulletFile2->m_constraints[i];
|
||||
|
||||
@@ -328,34 +307,31 @@ bool btBulletWorldImporter::convertAllObjects( bParse::btBulletFile* bulletFile
|
||||
}
|
||||
if (!rbA && !rbB)
|
||||
continue;
|
||||
|
||||
bool isDoublePrecisionData = (bulletFile2->getFlags() & bParse::FD_DOUBLE_PRECISION)!=0;
|
||||
|
||||
|
||||
bool isDoublePrecisionData = (bulletFile2->getFlags() & bParse::FD_DOUBLE_PRECISION) != 0;
|
||||
|
||||
if (isDoublePrecisionData)
|
||||
{
|
||||
if (bulletFile2->getVersion()>=282)
|
||||
if (bulletFile2->getVersion() >= 282)
|
||||
{
|
||||
btTypedConstraintDoubleData* dc = (btTypedConstraintDoubleData*)constraintData;
|
||||
convertConstraintDouble(dc, rbA,rbB, bulletFile2->getVersion());
|
||||
} else
|
||||
convertConstraintDouble(dc, rbA, rbB, bulletFile2->getVersion());
|
||||
}
|
||||
else
|
||||
{
|
||||
//double-precision constraints were messed up until 2.82, try to recover data...
|
||||
|
||||
btTypedConstraintData* oldData = (btTypedConstraintData*)constraintData;
|
||||
|
||||
convertConstraintBackwardsCompatible281(oldData, rbA,rbB, bulletFile2->getVersion());
|
||||
|
||||
btTypedConstraintData* oldData = (btTypedConstraintData*)constraintData;
|
||||
|
||||
convertConstraintBackwardsCompatible281(oldData, rbA, rbB, bulletFile2->getVersion());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
btTypedConstraintFloatData* dc = (btTypedConstraintFloatData*)constraintData;
|
||||
convertConstraintFloat(dc, rbA,rbB, bulletFile2->getVersion());
|
||||
convertConstraintFloat(dc, rbA, rbB, bulletFile2->getVersion());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user