From 10ed7bffd5750b34f195d8d6251c627d93145432 Mon Sep 17 00:00:00 2001 From: "erwin.coumans" Date: Tue, 24 Jul 2012 04:07:25 +0000 Subject: [PATCH] Fix serialization issue with btGeneric6DofSpringConstraintData, due to typo Skip btGeneric6DofSpringConstraintData parts of the data that will be invalid in .bullet files version 280 or older This fixes Issue 618, thanks to cyrfer for the report. minor improvements in premake build (name library output so multiple Visual Studio installations don't conflict) remove msvc folder --- .../btBulletWorldImporter.cpp | 24 +++++++++++++---- build/premake4.lua | 26 +++++++++---------- build/vs2008.bat | 2 +- .../btGeneric6DofSpringConstraint.h | 2 +- .../ConstraintSolver/btTypedConstraint.h | 3 ++- src/BulletSoftBody/btSoftBodyData.h | 2 +- 6 files changed, 37 insertions(+), 22 deletions(-) diff --git a/Extras/Serialize/BulletWorldImporter/btBulletWorldImporter.cpp b/Extras/Serialize/BulletWorldImporter/btBulletWorldImporter.cpp index dab5d6764..8e3b92d9d 100644 --- a/Extras/Serialize/BulletWorldImporter/btBulletWorldImporter.cpp +++ b/Extras/Serialize/BulletWorldImporter/btBulletWorldImporter.cpp @@ -793,7 +793,9 @@ bool btBulletWorldImporter::convertAllObjects( bParse::btBulletFile* bulletFile if (shapePtr && *shapePtr) { btTransform startTransform; + colObjData->m_collisionObjectData.m_worldTransform.m_origin.m_floats[3] = 0.f; startTransform.deSerializeDouble(colObjData->m_collisionObjectData.m_worldTransform); + // startTransform.setBasis(btMatrix3x3::getIdentity()); btCollisionShape* shape = (btCollisionShape*)*shapePtr; if (shape->isNonMoving()) @@ -834,7 +836,9 @@ bool btBulletWorldImporter::convertAllObjects( bParse::btBulletFile* bulletFile if (shapePtr && *shapePtr) { btTransform startTransform; + colObjData->m_collisionObjectData.m_worldTransform.m_origin.m_floats[3] = 0.f; startTransform.deSerializeFloat(colObjData->m_collisionObjectData.m_worldTransform); + // startTransform.setBasis(btMatrix3x3::getIdentity()); btCollisionShape* shape = (btCollisionShape*)*shapePtr; if (shape->isNonMoving()) @@ -878,7 +882,9 @@ bool btBulletWorldImporter::convertAllObjects( bParse::btBulletFile* bulletFile if (shapePtr && *shapePtr) { 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); body->setFriction(btScalar(colObjData->m_friction)); @@ -907,7 +913,9 @@ bool btBulletWorldImporter::convertAllObjects( bParse::btBulletFile* bulletFile if (shapePtr && *shapePtr) { 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); @@ -1075,7 +1083,9 @@ bool btBulletWorldImporter::convertAllObjects( bParse::btBulletFile* bulletFile case D6_SPRING_CONSTRAINT_TYPE: { + btGeneric6DofSpringConstraintData* dofData = (btGeneric6DofSpringConstraintData*)constraintData; + int sz = sizeof(btGeneric6DofSpringConstraintData); btGeneric6DofSpringConstraint* dof = 0; if (rbA && rbB) @@ -1097,18 +1107,22 @@ bool btBulletWorldImporter::convertAllObjects( bParse::btBulletFile* bulletFile 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; - for (i=0;i<6;i++) + if (bulletFile2->getVersion()>280) { - 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]); + 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]); + } } } diff --git a/build/premake4.lua b/build/premake4.lua index 6a56a9084..3bfc4f09d 100644 --- a/build/premake4.lua +++ b/build/premake4.lua @@ -49,8 +49,8 @@ solution "0BulletSolution" configuration "Debug" flags { "Symbols", "StaticRuntime" , "NoMinimalRebuild", "NoEditAndContinue" ,"FloatFast"} - --platforms {"x32", "x64"} - platforms {"x32"} + platforms {"x32", "x64"} + --platforms {"x32"} configuration {"Windows"} defines { "_CRT_SECURE_NO_WARNINGS","_CRT_SECURE_NO_DEPRECATE"} @@ -83,17 +83,17 @@ solution "0BulletSolution" end - configuration "x32" - targetsuffix ("x32" .. postfix) - configuration "x64" - targetsuffix ("x64" .. postfix) - configuration {"x64", "debug"} - targetsuffix ("x64Debug" .. postfix) - configuration {"x64", "release"} - targetsuffix ("x64" .. postfix) - configuration {"x32", "debug"} - targetsuffix ("Debug" .. postfix) - + configuration {"x32"} + targetsuffix ("_" .. _ACTION) + configuration "x64" + targetsuffix ("_" .. _ACTION .. "_64" ) + configuration {"x64", "debug"} + targetsuffix ("_" .. _ACTION .. "_x64_debug") + configuration {"x64", "release"} + targetsuffix ("_" .. _ACTION .. "_x64_release" ) + configuration {"x32", "debug"} + targetsuffix ("_" .. _ACTION .. "_debug" ) + configuration{} diff --git a/build/vs2008.bat b/build/vs2008.bat index f172640a5..c516f8462 100644 --- a/build/vs2008.bat +++ b/build/vs2008.bat @@ -4,7 +4,7 @@ rem premake4 --no-pedemos vs2008 rem premake4 --no-bulletlibs --no-pelibs vs2008 rem premake4 --with-nacl vs2008 -premake4 vs2008 +premake4 --with-demos vs2008 pause \ No newline at end of file diff --git a/src/BulletDynamics/ConstraintSolver/btGeneric6DofSpringConstraint.h b/src/BulletDynamics/ConstraintSolver/btGeneric6DofSpringConstraint.h index 187267f5e..ffbf8a9c7 100644 --- a/src/BulletDynamics/ConstraintSolver/btGeneric6DofSpringConstraint.h +++ b/src/BulletDynamics/ConstraintSolver/btGeneric6DofSpringConstraint.h @@ -95,7 +95,7 @@ SIMD_FORCE_INLINE const char* btGeneric6DofSpringConstraint::serialize(void* dat dof->m_springEnabled[i] = m_springEnabled[i]? 1 : 0; dof->m_springStiffness[i] = m_springStiffness[i]; } - return "btGeneric6DofConstraintData"; + return "btGeneric6DofSpringConstraintData"; } #endif // BT_GENERIC_6DOF_SPRING_CONSTRAINT_H diff --git a/src/BulletDynamics/ConstraintSolver/btTypedConstraint.h b/src/BulletDynamics/ConstraintSolver/btTypedConstraint.h index 1445b2416..9546b6213 100644 --- a/src/BulletDynamics/ConstraintSolver/btTypedConstraint.h +++ b/src/BulletDynamics/ConstraintSolver/btTypedConstraint.h @@ -16,9 +16,10 @@ subject to the following restrictions: #ifndef BT_TYPED_CONSTRAINT_H #define BT_TYPED_CONSTRAINT_H -class btRigidBody; + #include "LinearMath/btScalar.h" #include "btSolverConstraint.h" +#include "BulletDynamics/Dynamics/btRigidBody.h" class btSerializer; diff --git a/src/BulletSoftBody/btSoftBodyData.h b/src/BulletSoftBody/btSoftBodyData.h index 40dc65c3d..87d8841cf 100644 --- a/src/BulletSoftBody/btSoftBodyData.h +++ b/src/BulletSoftBody/btSoftBodyData.h @@ -17,7 +17,7 @@ subject to the following restrictions: #define BT_SOFTBODY_FLOAT_DATA #include "BulletCollision/CollisionDispatch/btCollisionObject.h" - +#include "BulletDynamics/Dynamics/btRigidBody.h" struct SoftBodyMaterialData