add missing Demos/BulletXmlImportDemo

serialize DynamicsWorldInfo
This commit is contained in:
erwin.coumans
2012-09-22 02:06:09 +00:00
parent f2c9cdfb11
commit 6f60a388c6
20 changed files with 25824 additions and 64 deletions

View File

@@ -87,6 +87,7 @@ struct btContactSolverInfo : public btContactSolverInfoData
m_warmstartingFactor=btScalar(0.85);
//m_solverMode = SOLVER_USE_WARMSTARTING | SOLVER_SIMD | SOLVER_DISABLE_VELOCITY_DEPENDENT_FRICTION_DIRECTION|SOLVER_USE_2_FRICTION_DIRECTIONS|SOLVER_ENABLE_FRICTION_DIRECTION_CACHING;// | SOLVER_RANDMIZE_ORDER;
m_solverMode = SOLVER_USE_WARMSTARTING | SOLVER_SIMD;// | SOLVER_RANDMIZE_ORDER;
m_restingContactRestitutionThreshold = 2;//unused as of 2.81
m_minimumSolverBatchSize = 128; //try to combine islands until the amount of constraints reaches this limit
m_maxGyroscopicForce = 100.f; ///only used to clamp forces for bodies that have their BT_ENABLE_GYROPSCOPIC_FORCE flag set (using btRigidBody::setFlag)
m_singleAxisRollingFrictionThreshold = 1e30f;///if the velocity is above this threshold, it will use a single constraint row (axis), otherwise 3 rows.

View File

@@ -1359,11 +1359,65 @@ void btDiscreteDynamicsWorld::serializeRigidBodies(btSerializer* serializer)
}
void btDiscreteDynamicsWorld::serializeDynamicsWorldInfo(btSerializer* serializer)
{
#ifdef BT_USE_DOUBLE_PRECISION
int len = sizeof(btDynamicsWorldDoubleData);
btChunk* chunk = serializer->allocate(len,1);
btDynamicsWorldDoubleData* worldInfo = (btDynamicsWorldDoubleData*)chunk->m_oldPtr;
#else//BT_USE_DOUBLE_PRECISION
int len = sizeof(btDynamicsWorldFloatData);
btChunk* chunk = serializer->allocate(len,1);
btDynamicsWorldFloatData* worldInfo = (btDynamicsWorldFloatData*)chunk->m_oldPtr;
#endif//BT_USE_DOUBLE_PRECISION
memset(worldInfo ,0x00,len);
m_gravity.serialize(worldInfo->m_gravity);
worldInfo->m_solverInfo.m_tau = getSolverInfo().m_tau;
worldInfo->m_solverInfo.m_damping = getSolverInfo().m_damping;
worldInfo->m_solverInfo.m_friction = getSolverInfo().m_friction;
worldInfo->m_solverInfo.m_timeStep = getSolverInfo().m_timeStep;
worldInfo->m_solverInfo.m_restitution = getSolverInfo().m_restitution;
worldInfo->m_solverInfo.m_maxErrorReduction = getSolverInfo().m_maxErrorReduction;
worldInfo->m_solverInfo.m_sor = getSolverInfo().m_sor;
worldInfo->m_solverInfo.m_erp = getSolverInfo().m_erp;
worldInfo->m_solverInfo.m_erp2 = getSolverInfo().m_erp2;
worldInfo->m_solverInfo.m_globalCfm = getSolverInfo().m_globalCfm;
worldInfo->m_solverInfo.m_splitImpulsePenetrationThreshold = getSolverInfo().m_splitImpulsePenetrationThreshold;
worldInfo->m_solverInfo.m_splitImpulseTurnErp = getSolverInfo().m_splitImpulseTurnErp;
worldInfo->m_solverInfo.m_linearSlop = getSolverInfo().m_linearSlop;
worldInfo->m_solverInfo.m_warmstartingFactor = getSolverInfo().m_warmstartingFactor;
worldInfo->m_solverInfo.m_maxGyroscopicForce = getSolverInfo().m_maxGyroscopicForce;
worldInfo->m_solverInfo.m_singleAxisRollingFrictionThreshold = getSolverInfo().m_singleAxisRollingFrictionThreshold;
worldInfo->m_solverInfo.m_numIterations = getSolverInfo().m_numIterations;
worldInfo->m_solverInfo.m_solverMode = getSolverInfo().m_solverMode;
worldInfo->m_solverInfo.m_restingContactRestitutionThreshold = getSolverInfo().m_restingContactRestitutionThreshold;
worldInfo->m_solverInfo.m_minimumSolverBatchSize = getSolverInfo().m_minimumSolverBatchSize;
worldInfo->m_solverInfo.m_splitImpulse = getSolverInfo().m_splitImpulse;
#ifdef BT_USE_DOUBLE_PRECISION
const char* structType = "btDynamicsWorldDoubleData";
#else//BT_USE_DOUBLE_PRECISION
const char* structType = "btDynamicsWorldFloatData";
#endif//BT_USE_DOUBLE_PRECISION
serializer->finalizeChunk(chunk,structType,BT_DYNAMICSWORLD_CODE,worldInfo);
}
void btDiscreteDynamicsWorld::serialize(btSerializer* serializer)
{
serializer->startSerialization();
serializeDynamicsWorldInfo(serializer);
serializeRigidBodies(serializer);
serializeCollisionObjects(serializer);

View File

@@ -87,6 +87,8 @@ protected:
void serializeRigidBodies(btSerializer* serializer);
void serializeDynamicsWorldInfo(btSerializer* serializer);
public:

View File

@@ -353,6 +353,8 @@ void btSoftRigidDynamicsWorld::serialize(btSerializer* serializer)
serializer->startSerialization();
serializeDynamicsWorldInfo( serializer);
serializeSoftBodies(serializer);
serializeRigidBodies(serializer);

View File

@@ -122,6 +122,7 @@ public:
#define BT_ARRAY_CODE BT_MAKE_ID('A','R','A','Y')
#define BT_SBMATERIAL_CODE BT_MAKE_ID('S','B','M','T')
#define BT_SBNODE_CODE BT_MAKE_ID('S','B','N','D')
#define BT_DYNAMICSWORLD_CODE BT_MAKE_ID('D','W','L','D')
#define BT_DNA_CODE BT_MAKE_ID('D','N','A','1')