///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 serialize( object dataBuffer, btSerializer* serializer ) { btTypedConstraintData2* tcd = (btTypedConstraintData2*)dataBuffer; tcd.m_rbA = (btRigidBodyData*)serializer.getUniquePointer( &m_rbA ); tcd.m_rbB = (btRigidBodyData*)serializer.getUniquePointer( &m_rbB ); char* name = (char*)serializer.findNameForPointer( this ); tcd.m_name = (char*)serializer.getUniquePointer( name ); if( tcd.m_name ) { serializer.serializeName( name ); } tcd.m_objectType = m_objectType; tcd.m_needsFeedback = m_needsFeedback; tcd.m_overrideNumSolverIterations = m_overrideNumSolverIterations; tcd.m_breakingImpulseThreshold = m_breakingImpulseThreshold; tcd.m_isEnabled = m_isEnabled ? 1 : 0; tcd.m_userConstraintId = m_userConstraintId; tcd.m_userConstraintType = m_userConstraintType; tcd.m_appliedImpulse = m_appliedImpulse; tcd.m_dbgDrawSize = m_dbgDrawSize; tcd.m_disableCollisionsBetweenLinkedBodies = false; int i; for( i = 0; i < m_rbA.getNumConstraintRefs(); i++ ) if( m_rbA.getConstraintRef( i ) == this ) tcd.m_disableCollisionsBetweenLinkedBodies = true; for( i = 0; i < m_rbB.getNumConstraintRefs(); i++ ) if( m_rbB.getConstraintRef( i ) == this ) tcd.m_disableCollisionsBetweenLinkedBodies = true; return btTypedConstraintDataName; }
///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 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"; }