internal void serializeDynamicsWorldInfo( btSerializer* serializer ) { #if 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; #if BT_USE_DOUBLE_PRECISION string structType = "btDynamicsWorldDoubleData"; #else//BT_USE_DOUBLE_PRECISION string structType = "btDynamicsWorldFloatData"; #endif//BT_USE_DOUBLE_PRECISION serializer.finalizeChunk( chunk, structType, BT_DYNAMICSWORLD_CODE, worldInfo ); }
internal void serializeRigidBodies( btSerializer* serializer ) { int i; //serialize all collision objects for( i = 0; i < m_collisionObjects.Count; i++ ) { btCollisionObject colObj = m_collisionObjects[i]; if( colObj.getInternalType() & btCollisionObject::CO_RIGID_BODY ) { int len = colObj.calculateSerializeBufferSize(); btChunk* chunk = serializer.allocate( len, 1 ); string structType = colObj.serialize( chunk.m_oldPtr, serializer ); serializer.finalizeChunk( chunk, structType, BT_RIGIDBODY_CODE, colObj ); } } for( i = 0; i < m_constraints.Count; i++ ) { btTypedConstraint constraint = m_constraints[i]; int size = constraint.calculateSerializeBufferSize(); btChunk* chunk = serializer.allocate( size, 1 ); string structType = constraint.serialize( chunk.m_oldPtr, serializer ); serializer.finalizeChunk( chunk, structType, BT_CONSTRAINT_CODE, constraint ); } }
///fills the dataBuffer and returns the struct name (and 0 on failure) string btCompoundShape::serialize( object dataBuffer, btSerializer* serializer ) { btCompoundShapeData* shapeData = (btCompoundShapeData*)dataBuffer; btCollisionShape::serialize( &shapeData.m_collisionShapeData, serializer ); shapeData.m_collisionMargin = float( m_collisionMargin ); shapeData.m_numChildShapes = m_children.Count; shapeData.m_childShapePtr = 0; if( shapeData.m_numChildShapes ) { btChunk* chunk = serializer.allocate( sizeof( btCompoundShapeChildData ), shapeData.m_numChildShapes ); btCompoundShapeChildData* memPtr = (btCompoundShapeChildData*)chunk.m_oldPtr; shapeData.m_childShapePtr = (btCompoundShapeChildData*)serializer.getUniquePointer( memPtr ); for( int i = 0; i < shapeData.m_numChildShapes; i++, memPtr++ ) { memPtr.m_childMargin = float( m_children[i].m_childMargin ); memPtr.m_childShape = (btCollisionShapeData*)serializer.getUniquePointer( m_children[i].m_childShape ); //don't serialize shapes that already have been serialized if( !serializer.findPointer( m_children[i].m_childShape ) ) { btChunk* chunk = serializer.allocate( m_children[i].m_childShape.calculateSerializeBufferSize(), 1 ); string structType = m_children[i].m_childShape.serialize( chunk.m_oldPtr, serializer ); serializer.finalizeChunk( chunk, structType, BT_SHAPE_CODE, m_children[i].m_childShape ); } memPtr.m_childShapeType = m_children[i].m_childShapeType; m_children[i].m_transform.serializeFloat( memPtr.m_transform ); } serializer.finalizeChunk( chunk, "btCompoundShapeChildData", BT_ARRAY_CODE, chunk.m_oldPtr ); } return "btCompoundShapeData"; }
///fills the dataBuffer and returns the struct name (and 0 on failure) string btMultiSphereShape::serialize( object dataBuffer, btSerializer* serializer ) { btMultiSphereShapeData* shapeData = (btMultiSphereShapeData*)dataBuffer; btConvexInternalShape::serialize( shapeData.m_convexInternalShapeData, serializer ); int numElem = m_localPositionArray.Count; shapeData.m_localPositionArrayPtr = numElem ? (btPositionAndRadius*)serializer.getUniquePointer( (object)&m_localPositionArray ) : 0; shapeData.m_localPositionArraySize = numElem; if( numElem ) { btChunk* chunk = serializer.allocate( sizeof( btPositionAndRadius ), numElem ); btPositionAndRadius* memPtr = (btPositionAndRadius*)chunk.m_oldPtr; for( int i = 0; i < numElem; i++, memPtr++ ) { m_localPositionArray[i].serializeFloat( memPtr.m_pos ); memPtr.m_radius = float( m_radiArray[i] ); } serializer.finalizeChunk( chunk, "btPositionAndRadius", BT_ARRAY_CODE, (object)m_localPositionArray ); } return "btMultiSphereShapeData"; }
///fills the dataBuffer and returns the struct name (and 0 on failure) string btConvexHullShape::serialize( object dataBuffer, btSerializer* serializer ) { //int szc = sizeof(btConvexHullShapeData); btConvexHullShapeData* shapeData = (btConvexHullShapeData*)dataBuffer; btConvexInternalShape::serialize( shapeData.m_convexInternalShapeData, serializer ); int numElem = m_unscaledPoints.Count; shapeData.m_numUnscaledPoints = numElem; #if BT_USE_DOUBLE_PRECISION shapeData.m_unscaledPointsFloatPtr = 0; shapeData.m_unscaledPointsDoublePtr = numElem ? (btVector3Data*)serializer.getUniquePointer((object)&m_unscaledPoints): 0; #else shapeData.m_unscaledPointsFloatPtr = numElem ? (btVector3Data*)serializer.getUniquePointer( (object)m_unscaledPoints ) : 0; shapeData.m_unscaledPointsDoublePtr = 0; #endif if( numElem ) { int sz = sizeof( btVector3Data ); // int sz2 = sizeof(btVector3DoubleData); // int sz3 = sizeof(btVector3FloatData); btChunk* chunk = serializer.allocate( sz, numElem ); btVector3Data* memPtr = (btVector3Data*)chunk.m_oldPtr; for( int i = 0; i < numElem; i++, memPtr++ ) { m_unscaledPoints[i].serialize( *memPtr ); } serializer.finalizeChunk( chunk, btVector3DataName, BT_ARRAY_CODE, (object)m_unscaledPoints ); } return "btConvexHullShapeData"; }