bool btBulletWorldImporter::convertAllObjects( bParse::btBulletFile* bulletFile2) { int i; for (i=0;i<bulletFile2->m_bvhs.size();i++) { btOptimizedBvh* bvh = createOptimizedBvh(); if (bulletFile2->getFlags() & bParse::FD_DOUBLE_PRECISION) { btQuantizedBvhDoubleData* bvhData = (btQuantizedBvhDoubleData*)bulletFile2->m_bvhs[i]; bvh->deSerializeDouble(*bvhData); } else { btQuantizedBvhFloatData* bvhData = (btQuantizedBvhFloatData*)bulletFile2->m_bvhs[i]; bvh->deSerializeFloat(*bvhData); } m_bvhMap.insert(bulletFile2->m_bvhs[i],bvh); } btHashMap<btHashPtr,btCollisionShape*> shapeMap; 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); shapeMap.insert(shapeData,shape); } if (shape&& shapeData->m_name) { char* newname = duplicateName(shapeData->m_name); m_objectNameMap.insert(shape,newname); m_nameShapeMap.insert(newname,shape); } } btHashMap<btHashPtr,btCollisionObject*> bodyMap; for (i=0;i<bulletFile2->m_rigidBodies.size();i++) { if (bulletFile2->getFlags() & bParse::FD_DOUBLE_PRECISION) { 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) { btTransform startTransform; startTransform.deSerializeDouble(colObjData->m_collisionObjectData.m_worldTransform); // startTransform.setBasis(btMatrix3x3::getIdentity()); btCollisionShape* shape = (btCollisionShape*)*shapePtr; if (shape->isNonMoving()) { mass = 0.f; } if (mass) { shape->calculateLocalInertia(mass,localInertia); } bool isDynamic = mass!=0.f; btRigidBody* body = createRigidBody(isDynamic,mass,startTransform,shape,colObjData->m_collisionObjectData.m_name); #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); } } #endif //USE_INTERNAL_EDGE_UTILITY bodyMap.insert(colObjData,body); } else { printf("error: no shape found\n"); } } else { 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 (shape->isNonMoving()) { mass = 0.f; } if (mass) { shape->calculateLocalInertia(mass,localInertia); } bool isDynamic = mass!=0.f; btRigidBody* body = createRigidBody(isDynamic,mass,startTransform,shape,colObjData->m_collisionObjectData.m_name); #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); } } #endif //USE_INTERNAL_EDGE_UTILITY bodyMap.insert(colObjData,body); } else { printf("error: no shape found\n"); } } } for (i=0;i<bulletFile2->m_collisionObjects.size();i++) { if (bulletFile2->getFlags() & bParse::FD_DOUBLE_PRECISION) { btCollisionObjectDoubleData* colObjData = (btCollisionObjectDoubleData*)bulletFile2->m_collisionObjects[i]; btCollisionShape** shapePtr = shapeMap.find(colObjData->m_collisionShape); if (shapePtr && *shapePtr) { btTransform startTransform; startTransform.deSerializeDouble(colObjData->m_worldTransform); btCollisionShape* shape = (btCollisionShape*)*shapePtr; btCollisionObject* body = createCollisionObject(startTransform,shape,colObjData->m_name); #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); } } #endif //USE_INTERNAL_EDGE_UTILITY bodyMap.insert(colObjData,body); } else { printf("error: no shape found\n"); } } else { btCollisionObjectFloatData* colObjData = (btCollisionObjectFloatData*)bulletFile2->m_collisionObjects[i]; btCollisionShape** shapePtr = shapeMap.find(colObjData->m_collisionShape); if (shapePtr && *shapePtr) { btTransform startTransform; startTransform.deSerializeFloat(colObjData->m_worldTransform); btCollisionShape* shape = (btCollisionShape*)*shapePtr; btCollisionObject* body = createCollisionObject(startTransform,shape,colObjData->m_name); #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); } } #endif //USE_INTERNAL_EDGE_UTILITY bodyMap.insert(colObjData,body); } else { printf("error: no shape found\n"); } } printf("bla"); } for (i=0;i<bulletFile2->m_constraints.size();i++) { btTypedConstraintData* constraintData = (btTypedConstraintData*)bulletFile2->m_constraints[i]; btCollisionObject** colAptr = bodyMap.find(constraintData->m_rbA); btCollisionObject** colBptr = bodyMap.find(constraintData->m_rbB); btRigidBody* rbA = 0; btRigidBody* rbB = 0; if (colAptr) { rbA = btRigidBody::upcast(*colAptr); if (!rbA) rbA = &getFixedBody(); } if (colBptr) { rbB = btRigidBody::upcast(*colBptr); if (!rbB) rbB = &getFixedBody(); } btTypedConstraint* constraint = 0; switch (constraintData->m_objectType) { case POINT2POINT_CONSTRAINT_TYPE: { if (bulletFile2->getFlags() & bParse::FD_DOUBLE_PRECISION) { btPoint2PointConstraintDoubleData* p2pData = (btPoint2PointConstraintDoubleData*)constraintData; if (rbA && rbB) { btVector3 pivotInA,pivotInB; pivotInA.deSerializeDouble(p2pData->m_pivotInA); pivotInB.deSerializeDouble(p2pData->m_pivotInB); constraint = createPoint2PointConstraint(*rbA,*rbB,pivotInA,pivotInB); } else { btVector3 pivotInA; pivotInA.deSerializeDouble(p2pData->m_pivotInA); constraint = createPoint2PointConstraint(*rbA,pivotInA); } } else { btPoint2PointConstraintFloatData* p2pData = (btPoint2PointConstraintFloatData*)constraintData; if (rbA&& rbB) { btVector3 pivotInA,pivotInB; pivotInA.deSerializeFloat(p2pData->m_pivotInA); pivotInB.deSerializeFloat(p2pData->m_pivotInB); constraint = createPoint2PointConstraint(*rbA,*rbB,pivotInA,pivotInB); } else { btVector3 pivotInA; pivotInA.deSerializeFloat(p2pData->m_pivotInA); constraint = createPoint2PointConstraint(*rbA,pivotInA); } } break; } case HINGE_CONSTRAINT_TYPE: { btHingeConstraint* hinge = 0; if (bulletFile2->getFlags() & bParse::FD_DOUBLE_PRECISION) { btHingeConstraintDoubleData* hingeData = (btHingeConstraintDoubleData*)constraintData; if (rbA&& rbB) { btTransform rbAFrame,rbBFrame; rbAFrame.deSerializeDouble(hingeData->m_rbAFrame); rbBFrame.deSerializeDouble(hingeData->m_rbBFrame); hinge = createHingeConstraint(*rbA,*rbB,rbAFrame,rbBFrame,hingeData->m_useReferenceFrameA!=0); } else { btTransform rbAFrame; rbAFrame.deSerializeDouble(hingeData->m_rbAFrame); hinge = createHingeConstraint(*rbA,rbAFrame,hingeData->m_useReferenceFrameA!=0); } if (hingeData->m_enableAngularMotor) { hinge->enableAngularMotor(true,hingeData->m_motorTargetVelocity,hingeData->m_maxMotorImpulse); } hinge->setAngularOnly(hingeData->m_angularOnly!=0); hinge->setLimit(btScalar(hingeData->m_lowerLimit),btScalar(hingeData->m_upperLimit),btScalar(hingeData->m_limitSoftness),btScalar(hingeData->m_biasFactor),btScalar(hingeData->m_relaxationFactor)); } else { btHingeConstraintFloatData* hingeData = (btHingeConstraintFloatData*)constraintData; if (rbA&& rbB) { btTransform rbAFrame,rbBFrame; rbAFrame.deSerializeFloat(hingeData->m_rbAFrame); rbBFrame.deSerializeFloat(hingeData->m_rbBFrame); hinge = createHingeConstraint(*rbA,*rbB,rbAFrame,rbBFrame,hingeData->m_useReferenceFrameA!=0); } else { btTransform rbAFrame; rbAFrame.deSerializeFloat(hingeData->m_rbAFrame); hinge = createHingeConstraint(*rbA,rbAFrame,hingeData->m_useReferenceFrameA!=0); } if (hingeData->m_enableAngularMotor) { hinge->enableAngularMotor(true,hingeData->m_motorTargetVelocity,hingeData->m_maxMotorImpulse); } hinge->setAngularOnly(hingeData->m_angularOnly!=0); hinge->setLimit(btScalar(hingeData->m_lowerLimit),btScalar(hingeData->m_upperLimit),btScalar(hingeData->m_limitSoftness),btScalar(hingeData->m_biasFactor),btScalar(hingeData->m_relaxationFactor)); } constraint = hinge; break; } case CONETWIST_CONSTRAINT_TYPE: { btConeTwistConstraintData* coneData = (btConeTwistConstraintData*)constraintData; btConeTwistConstraint* coneTwist = 0; if (rbA&& rbB) { btTransform rbAFrame,rbBFrame; rbAFrame.deSerializeFloat(coneData->m_rbAFrame); rbBFrame.deSerializeFloat(coneData->m_rbBFrame); coneTwist = createConeTwistConstraint(*rbA,*rbB,rbAFrame,rbBFrame); } else { btTransform rbAFrame; rbAFrame.deSerializeFloat(coneData->m_rbAFrame); coneTwist = createConeTwistConstraint(*rbA,rbAFrame); } coneTwist->setLimit(coneData->m_swingSpan1,coneData->m_swingSpan2,coneData->m_twistSpan,coneData->m_limitSoftness,coneData->m_biasFactor,coneData->m_relaxationFactor); coneTwist->setDamping(coneData->m_damping); constraint = coneTwist; break; } case D6_CONSTRAINT_TYPE: { btGeneric6DofConstraintData* dofData = (btGeneric6DofConstraintData*)constraintData; btGeneric6DofConstraint* dof = 0; if (rbA&& rbB) { btTransform rbAFrame,rbBFrame; rbAFrame.deSerializeFloat(dofData->m_rbAFrame); rbBFrame.deSerializeFloat(dofData->m_rbBFrame); dof = createGeneric6DofConstraint(*rbA,*rbB,rbAFrame,rbBFrame,dofData->m_useLinearReferenceFrameA!=0); } else { if (rbB) { btTransform rbBFrame; rbBFrame.deSerializeFloat(dofData->m_rbBFrame); dof = createGeneric6DofConstraint(*rbB,rbBFrame,dofData->m_useLinearReferenceFrameA!=0); } else { printf("Error in btWorldImporter::createGeneric6DofConstraint: missing rbB\n"); } } if (dof) { btVector3 angLowerLimit,angUpperLimit, linLowerLimit,linUpperlimit; angLowerLimit.deSerializeFloat(dofData->m_angularLowerLimit); angUpperLimit.deSerializeFloat(dofData->m_angularUpperLimit); linLowerLimit.deSerializeFloat(dofData->m_linearLowerLimit); linUpperlimit.deSerializeFloat(dofData->m_linearUpperLimit); dof->setAngularLowerLimit(angLowerLimit); dof->setAngularUpperLimit(angUpperLimit); dof->setLinearLowerLimit(linLowerLimit); dof->setLinearUpperLimit(linUpperlimit); } constraint = dof; break; } case SLIDER_CONSTRAINT_TYPE: { btSliderConstraintData* sliderData = (btSliderConstraintData*)constraintData; btSliderConstraint* slider = 0; if (rbA&& rbB) { btTransform rbAFrame,rbBFrame; rbAFrame.deSerializeFloat(sliderData->m_rbAFrame); rbBFrame.deSerializeFloat(sliderData->m_rbBFrame); slider = createSliderConstraint(*rbA,*rbB,rbAFrame,rbBFrame,sliderData->m_useLinearReferenceFrameA!=0); } else { btTransform rbBFrame; rbBFrame.deSerializeFloat(sliderData->m_rbBFrame); slider = createSliderConstraint(*rbB,rbBFrame,sliderData->m_useLinearReferenceFrameA!=0); } slider->setLowerLinLimit(sliderData->m_linearLowerLimit); slider->setUpperLinLimit(sliderData->m_linearUpperLimit); slider->setLowerAngLimit(sliderData->m_angularLowerLimit); slider->setUpperAngLimit(sliderData->m_angularUpperLimit); slider->setUseFrameOffset(sliderData->m_useOffsetForConstraintFrame!=0); constraint = slider; break; } default: { printf("unknown constraint type\n"); } }; if (constraint) { constraint->setDbgDrawSize(constraintData->m_dbgDrawSize); if (constraintData->m_name) { char* newname = duplicateName(constraintData->m_name); m_nameConstraintMap.insert(newname,constraint); m_objectNameMap.insert(constraint,newname); } if(m_dynamicsWorld) m_dynamicsWorld->addConstraint(constraint,constraintData->m_disableCollisionsBetweenLinkedBodies!=0); } } return true; }
void btWorldImporter::convertConstraint(btTypedConstraintData* constraintData,btRigidBody* rbA, btRigidBody* rbB ,bool isDoublePrecisionData, int fileVersion) { btTypedConstraint* constraint = 0; switch (constraintData->m_objectType) { case POINT2POINT_CONSTRAINT_TYPE: { if (isDoublePrecisionData) { btPoint2PointConstraintDoubleData* p2pData = (btPoint2PointConstraintDoubleData*)constraintData; if (rbA && rbB) { btVector3 pivotInA,pivotInB; pivotInA.deSerializeDouble(p2pData->m_pivotInA); pivotInB.deSerializeDouble(p2pData->m_pivotInB); constraint = createPoint2PointConstraint(*rbA,*rbB,pivotInA,pivotInB); } else { btVector3 pivotInA; pivotInA.deSerializeDouble(p2pData->m_pivotInA); constraint = createPoint2PointConstraint(*rbA,pivotInA); } } else { btPoint2PointConstraintFloatData* p2pData = (btPoint2PointConstraintFloatData*)constraintData; if (rbA&& rbB) { btVector3 pivotInA,pivotInB; pivotInA.deSerializeFloat(p2pData->m_pivotInA); pivotInB.deSerializeFloat(p2pData->m_pivotInB); constraint = createPoint2PointConstraint(*rbA,*rbB,pivotInA,pivotInB); } else { btVector3 pivotInA; pivotInA.deSerializeFloat(p2pData->m_pivotInA); constraint = createPoint2PointConstraint(*rbA,pivotInA); } } break; } case HINGE_CONSTRAINT_TYPE: { btHingeConstraint* hinge = 0; if (isDoublePrecisionData) { btHingeConstraintDoubleData* hingeData = (btHingeConstraintDoubleData*)constraintData; if (rbA&& rbB) { btTransform rbAFrame,rbBFrame; rbAFrame.deSerializeDouble(hingeData->m_rbAFrame); rbBFrame.deSerializeDouble(hingeData->m_rbBFrame); hinge = createHingeConstraint(*rbA,*rbB,rbAFrame,rbBFrame,hingeData->m_useReferenceFrameA!=0); } else { btTransform rbAFrame; rbAFrame.deSerializeDouble(hingeData->m_rbAFrame); hinge = createHingeConstraint(*rbA,rbAFrame,hingeData->m_useReferenceFrameA!=0); } if (hingeData->m_enableAngularMotor) { hinge->enableAngularMotor(true,hingeData->m_motorTargetVelocity,hingeData->m_maxMotorImpulse); } hinge->setAngularOnly(hingeData->m_angularOnly!=0); hinge->setLimit(btScalar(hingeData->m_lowerLimit),btScalar(hingeData->m_upperLimit),btScalar(hingeData->m_limitSoftness),btScalar(hingeData->m_biasFactor),btScalar(hingeData->m_relaxationFactor)); } else { btHingeConstraintFloatData* hingeData = (btHingeConstraintFloatData*)constraintData; if (rbA&& rbB) { btTransform rbAFrame,rbBFrame; rbAFrame.deSerializeFloat(hingeData->m_rbAFrame); rbBFrame.deSerializeFloat(hingeData->m_rbBFrame); hinge = createHingeConstraint(*rbA,*rbB,rbAFrame,rbBFrame,hingeData->m_useReferenceFrameA!=0); } else { btTransform rbAFrame; rbAFrame.deSerializeFloat(hingeData->m_rbAFrame); hinge = createHingeConstraint(*rbA,rbAFrame,hingeData->m_useReferenceFrameA!=0); } if (hingeData->m_enableAngularMotor) { hinge->enableAngularMotor(true,hingeData->m_motorTargetVelocity,hingeData->m_maxMotorImpulse); } hinge->setAngularOnly(hingeData->m_angularOnly!=0); hinge->setLimit(btScalar(hingeData->m_lowerLimit),btScalar(hingeData->m_upperLimit),btScalar(hingeData->m_limitSoftness),btScalar(hingeData->m_biasFactor),btScalar(hingeData->m_relaxationFactor)); } constraint = hinge; break; } case CONETWIST_CONSTRAINT_TYPE: { btConeTwistConstraintData* coneData = (btConeTwistConstraintData*)constraintData; btConeTwistConstraint* coneTwist = 0; if (rbA&& rbB) { btTransform rbAFrame,rbBFrame; rbAFrame.deSerializeFloat(coneData->m_rbAFrame); rbBFrame.deSerializeFloat(coneData->m_rbBFrame); coneTwist = createConeTwistConstraint(*rbA,*rbB,rbAFrame,rbBFrame); } else { btTransform rbAFrame; rbAFrame.deSerializeFloat(coneData->m_rbAFrame); coneTwist = createConeTwistConstraint(*rbA,rbAFrame); } coneTwist->setLimit(coneData->m_swingSpan1,coneData->m_swingSpan2,coneData->m_twistSpan,coneData->m_limitSoftness,coneData->m_biasFactor,coneData->m_relaxationFactor); coneTwist->setDamping(coneData->m_damping); constraint = coneTwist; break; } case D6_SPRING_CONSTRAINT_TYPE: { btGeneric6DofSpringConstraintData* dofData = (btGeneric6DofSpringConstraintData*)constraintData; // int sz = sizeof(btGeneric6DofSpringConstraintData); btGeneric6DofSpringConstraint* dof = 0; if (rbA && rbB) { btTransform rbAFrame,rbBFrame; rbAFrame.deSerializeFloat(dofData->m_6dofData.m_rbAFrame); rbBFrame.deSerializeFloat(dofData->m_6dofData.m_rbBFrame); dof = createGeneric6DofSpringConstraint(*rbA,*rbB,rbAFrame,rbBFrame,dofData->m_6dofData.m_useLinearReferenceFrameA!=0); } else { printf("Error in btWorldImporter::createGeneric6DofSpringConstraint: requires rbA && rbB\n"); } if (dof) { btVector3 angLowerLimit,angUpperLimit, linLowerLimit,linUpperlimit; angLowerLimit.deSerializeFloat(dofData->m_6dofData.m_angularLowerLimit); angUpperLimit.deSerializeFloat(dofData->m_6dofData.m_angularUpperLimit); linLowerLimit.deSerializeFloat(dofData->m_6dofData.m_linearLowerLimit); linUpperlimit.deSerializeFloat(dofData->m_6dofData.m_linearUpperLimit); angLowerLimit.setW(0.f); dof->setAngularLowerLimit(angLowerLimit); dof->setAngularUpperLimit(angUpperLimit); dof->setLinearLowerLimit(linLowerLimit); dof->setLinearUpperLimit(linUpperlimit); int i; if (fileVersion>280) { for (i=0;i<6;i++) { dof->setStiffness(i,dofData->m_springStiffness[i]); dof->setEquilibriumPoint(i,dofData->m_equilibriumPoint[i]); dof->enableSpring(i,dofData->m_springEnabled[i]!=0); dof->setDamping(i,dofData->m_springDamping[i]); } } } constraint = dof; break; } case D6_CONSTRAINT_TYPE: { btGeneric6DofConstraintData* dofData = (btGeneric6DofConstraintData*)constraintData; btGeneric6DofConstraint* dof = 0; if (rbA&& rbB) { btTransform rbAFrame,rbBFrame; rbAFrame.deSerializeFloat(dofData->m_rbAFrame); rbBFrame.deSerializeFloat(dofData->m_rbBFrame); dof = createGeneric6DofConstraint(*rbA,*rbB,rbAFrame,rbBFrame,dofData->m_useLinearReferenceFrameA!=0); } else { if (rbB) { btTransform rbBFrame; rbBFrame.deSerializeFloat(dofData->m_rbBFrame); dof = createGeneric6DofConstraint(*rbB,rbBFrame,dofData->m_useLinearReferenceFrameA!=0); } else { printf("Error in btWorldImporter::createGeneric6DofConstraint: missing rbB\n"); } } if (dof) { btVector3 angLowerLimit,angUpperLimit, linLowerLimit,linUpperlimit; angLowerLimit.deSerializeFloat(dofData->m_angularLowerLimit); angUpperLimit.deSerializeFloat(dofData->m_angularUpperLimit); linLowerLimit.deSerializeFloat(dofData->m_linearLowerLimit); linUpperlimit.deSerializeFloat(dofData->m_linearUpperLimit); dof->setAngularLowerLimit(angLowerLimit); dof->setAngularUpperLimit(angUpperLimit); dof->setLinearLowerLimit(linLowerLimit); dof->setLinearUpperLimit(linUpperlimit); } constraint = dof; break; } case SLIDER_CONSTRAINT_TYPE: { btSliderConstraintData* sliderData = (btSliderConstraintData*)constraintData; btSliderConstraint* slider = 0; if (rbA&& rbB) { btTransform rbAFrame,rbBFrame; rbAFrame.deSerializeFloat(sliderData->m_rbAFrame); rbBFrame.deSerializeFloat(sliderData->m_rbBFrame); slider = createSliderConstraint(*rbA,*rbB,rbAFrame,rbBFrame,sliderData->m_useLinearReferenceFrameA!=0); } else { btTransform rbBFrame; rbBFrame.deSerializeFloat(sliderData->m_rbBFrame); slider = createSliderConstraint(*rbB,rbBFrame,sliderData->m_useLinearReferenceFrameA!=0); } slider->setLowerLinLimit(sliderData->m_linearLowerLimit); slider->setUpperLinLimit(sliderData->m_linearUpperLimit); slider->setLowerAngLimit(sliderData->m_angularLowerLimit); slider->setUpperAngLimit(sliderData->m_angularUpperLimit); slider->setUseFrameOffset(sliderData->m_useOffsetForConstraintFrame!=0); constraint = slider; break; } default: { printf("unknown constraint type\n"); } }; if (constraint) { constraint->setDbgDrawSize(constraintData->m_dbgDrawSize); ///those fields didn't exist and set to zero for pre-280 versions, so do a check here if (fileVersion>=280) { constraint->setBreakingImpulseThreshold(constraintData->m_breakingImpulseThreshold); constraint->setEnabled(constraintData->m_isEnabled!=0); constraint->setOverrideNumSolverIterations(constraintData->m_overrideNumSolverIterations); } if (constraintData->m_name) { char* newname = duplicateName(constraintData->m_name); m_nameConstraintMap.insert(newname,constraint); m_objectNameMap.insert(constraint,newname); } if(m_dynamicsWorld) m_dynamicsWorld->addConstraint(constraint,constraintData->m_disableCollisionsBetweenLinkedBodies!=0); } }