From 182c3034de92df160af75b5c45ee443225b8ef5c Mon Sep 17 00:00:00 2001 From: "erwin.coumans" Date: Sat, 22 Sep 2012 05:27:35 +0000 Subject: [PATCH] fixes in btBulletXmlWorldImporter, and add premake4 support for the related demo --- Demos/BulletXmlImportDemo/CMakeLists.txt | 1 + Demos/premake4.lua | 3 +- .../btBulletXmlWorldImporter.cpp | 51 +++++++++++-------- Extras/premake4.lua | 2 + .../btSequentialImpulseConstraintSolver.cpp | 1 - 5 files changed, 35 insertions(+), 23 deletions(-) diff --git a/Demos/BulletXmlImportDemo/CMakeLists.txt b/Demos/BulletXmlImportDemo/CMakeLists.txt index c7adcc168..1636e36d5 100644 --- a/Demos/BulletXmlImportDemo/CMakeLists.txt +++ b/Demos/BulletXmlImportDemo/CMakeLists.txt @@ -83,6 +83,7 @@ IF (NOT INTERNAL_CREATE_DISTRIBUTABLE_MSVC_PROJECTFILES AND NOT INTERNAL_UPDATE_ TARGET AppBulletXmlImportDemo POST_BUILD COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different ${BULLET_PHYSICS_SOURCE_DIR}/Demos/BulletXmlImportDemo/bullet_basic.xml ${CMAKE_CURRENT_BINARY_DIR}/bullet_basic.xml + COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different ${BULLET_PHYSICS_SOURCE_DIR}/Demos/BulletXmlImportDemo/bullet_basic.xml ${CMAKE_CURRENT_BINARY_DIR}/Debug/bullet_basic.xml ) ENDIF () diff --git a/Demos/premake4.lua b/Demos/premake4.lua index beb69d4d6..c338411d0 100644 --- a/Demos/premake4.lua +++ b/Demos/premake4.lua @@ -89,9 +89,10 @@ end createDemos({"SoftDemo"},{"../src","OpenGL"}, {"OpenGLSupport","BulletSoftBody", "BulletDynamics", "BulletCollision", "LinearMath"}) createDemos({"SerializeDemo"},{"../Extras/Serialize/BulletFileLoader","../Extras/Serialize/BulletWorldImporter","../src","OpenGL"},{"OpenGLSupport","BulletWorldImporter", "BulletFileLoader", "BulletSoftBody", "BulletDynamics", "BulletCollision", "LinearMath"}) + +createDemos({"BulletXmlImportDemo"},{"../Extras/Serialize/BulletFileLoader","../Extras/Serialize/BulletXmlWorldImporter", "../Extras/Serialize/BulletWorldImporter","../src","OpenGL"},{"OpenGLSupport","BulletXmlWorldImporter","BulletWorldImporter", "BulletFileLoader", "BulletSoftBody", "BulletDynamics", "BulletCollision", "LinearMath"}) - include "OpenGL" diff --git a/Extras/Serialize/BulletXmlWorldImporter/btBulletXmlWorldImporter.cpp b/Extras/Serialize/BulletXmlWorldImporter/btBulletXmlWorldImporter.cpp index 385a9afcf..bf5d94300 100644 --- a/Extras/Serialize/BulletXmlWorldImporter/btBulletXmlWorldImporter.cpp +++ b/Extras/Serialize/BulletXmlWorldImporter/btBulletXmlWorldImporter.cpp @@ -126,8 +126,8 @@ void btBulletXmlWorldImporter::deSerializeVector3FloatData(TiXmlNode* pParent,bt #define SET_POINTER_VALUE(xmlnode, targetdata, argname, pointertype) \ {\ - TiXmlNode* node;\ - if ((node)= xmlnode->FirstChild(#argname))\ + TiXmlNode* node = xmlnode->FirstChild(#argname);\ + if (node)\ {\ const char* txt = (node)->ToElement()->GetText();\ (targetdata).argname= (pointertype) (int) atof(txt);\ @@ -213,7 +213,8 @@ void btBulletXmlWorldImporter::deSerializeCollisionShapeData(TiXmlNode* pParent, void btBulletXmlWorldImporter::deSerializeConvexHullShapeData(TiXmlNode* pParent) { int ptr; - btAssert(get_int_attribute_by_name(pParent->ToElement(),"pointer",&ptr)); + get_int_attribute_by_name(pParent->ToElement(),"pointer",&ptr); + btConvexHullShapeData* convexHullData = (btConvexHullShapeData*)btAlignedAlloc(sizeof(btConvexHullShapeData), 16); TiXmlNode* xmlConvexInt = pParent->FirstChild("m_convexInternalShapeData"); @@ -239,7 +240,7 @@ void btBulletXmlWorldImporter::deSerializeConvexHullShapeData(TiXmlNode* pParent void btBulletXmlWorldImporter::deSerializeCompoundShapeChildData(TiXmlNode* pParent) { int ptr; - btAssert(get_int_attribute_by_name(pParent->ToElement(),"pointer",&ptr)); + get_int_attribute_by_name(pParent->ToElement(),"pointer",&ptr); btCompoundShapeChildData* compoundChildData = (btCompoundShapeChildData*) btAlignedAlloc(sizeof(btCompoundShapeChildData),16); @@ -257,7 +258,7 @@ void btBulletXmlWorldImporter::deSerializeCompoundShapeChildData(TiXmlNode* pPar void btBulletXmlWorldImporter::deSerializeCompoundShapeData(TiXmlNode* pParent) { int ptr; - btAssert(get_int_attribute_by_name(pParent->ToElement(),"pointer",&ptr)); + get_int_attribute_by_name(pParent->ToElement(),"pointer",&ptr); btCompoundShapeData* compoundData = (btCompoundShapeData*) btAlignedAlloc(sizeof(btCompoundShapeData),16); @@ -277,7 +278,7 @@ void btBulletXmlWorldImporter::deSerializeCompoundShapeData(TiXmlNode* pParent) void btBulletXmlWorldImporter::deSerializeStaticPlaneShapeData(TiXmlNode* pParent) { int ptr; - btAssert(get_int_attribute_by_name(pParent->ToElement(),"pointer",&ptr)); + get_int_attribute_by_name(pParent->ToElement(),"pointer",&ptr); btStaticPlaneShapeData* planeData = (btStaticPlaneShapeData*) btAlignedAlloc(sizeof(btStaticPlaneShapeData),16); @@ -301,8 +302,9 @@ void btBulletXmlWorldImporter::deSerializeDynamicsWorldData(TiXmlNode* pParent) void btBulletXmlWorldImporter::deSerializeConvexInternalShapeData(TiXmlNode* pParent) { - int ptr; - btAssert(get_int_attribute_by_name(pParent->ToElement(),"pointer",&ptr)); + int ptr=0; + get_int_attribute_by_name(pParent->ToElement(),"pointer",&ptr); + btConvexInternalShapeData* convexShape = (btConvexInternalShapeData*) btAlignedAlloc(sizeof(btConvexInternalShapeData),16); memset(convexShape,0,sizeof(btConvexInternalShapeData)); @@ -339,8 +341,9 @@ enum btTypedConstraintType void btBulletXmlWorldImporter::deSerializeGeneric6DofConstraintData(TiXmlNode* pParent) { - int ptr; - btAssert(get_int_attribute_by_name(pParent->ToElement(),"pointer",&ptr)); + int ptr=0; + get_int_attribute_by_name(pParent->ToElement(),"pointer",&ptr); + btGeneric6DofConstraintData* dof6Data = (btGeneric6DofConstraintData*)btAlignedAlloc(sizeof(btGeneric6DofConstraintData),16); @@ -378,9 +381,13 @@ void btBulletXmlWorldImporter::deSerializeGeneric6DofConstraintData(TiXmlNode* p void btBulletXmlWorldImporter::deSerializeRigidBodyFloatData(TiXmlNode* pParent) { - int ptr; - btAssert(get_int_attribute_by_name(pParent->ToElement(),"pointer",&ptr)); - + int ptr=0; + if (!get_int_attribute_by_name(pParent->ToElement(),"pointer",&ptr)) + { + m_fileOk = false; + return; + } + btRigidBodyData* rbData = (btRigidBodyData*)btAlignedAlloc(sizeof(btRigidBodyData),16); TiXmlNode* n = pParent->FirstChild("m_collisionObjectData"); @@ -566,7 +573,7 @@ void btBulletXmlWorldImporter::auto_serialize_root_level_children(TiXmlNode* pPa if (!stricmp(pChild->Value(),"btVector3FloatData")) { int ptr; - btAssert(get_int_attribute_by_name(pChild->ToElement(),"pointer",&ptr)); + get_int_attribute_by_name(pChild->ToElement(),"pointer",&ptr); btAlignedObjectArray v; deSerializeVector3FloatData(pChild,v); @@ -648,6 +655,13 @@ void btBulletXmlWorldImporter::auto_serialize_root_level_children(TiXmlNode* pPa } } + for (int i=0;im_collisionShapeData.size();i++) + { + btCollisionShapeData* shapeData = m_collisionShapeData[i]; + fixupCollisionDataPointers(shapeData); + + } + ///now fixup pointers for (int i=0;im_collisionShapeData.size();i++) - { - btCollisionShapeData* shapeData = m_collisionShapeData[i]; - fixupCollisionDataPointers(shapeData); - - } + for (int i=0;iToElement(),"itemcount", &itemcount)); + get_int_attribute_by_name(doc.FirstChildElement()->ToElement(),"itemcount", &itemcount); auto_serialize(&doc); return m_fileOk; diff --git a/Extras/premake4.lua b/Extras/premake4.lua index ca5c766f6..a3f0a6df8 100644 --- a/Extras/premake4.lua +++ b/Extras/premake4.lua @@ -4,3 +4,5 @@ include "ConvexDecomposition" include "Serialize/BulletFileLoader" include "Serialize/BulletWorldImporter" +include "Serialize/BulletXmlWorldImporter" + diff --git a/src/BulletDynamics/ConstraintSolver/btSequentialImpulseConstraintSolver.cpp b/src/BulletDynamics/ConstraintSolver/btSequentialImpulseConstraintSolver.cpp index cfb3dea67..ae5da36a3 100644 --- a/src/BulletDynamics/ConstraintSolver/btSequentialImpulseConstraintSolver.cpp +++ b/src/BulletDynamics/ConstraintSolver/btSequentialImpulseConstraintSolver.cpp @@ -1231,7 +1231,6 @@ btScalar btSequentialImpulseConstraintSolver::solveSingleIteration(int iteration int numNonContactPool = m_tmpSolverNonContactConstraintPool.size(); int numConstraintPool = m_tmpSolverContactConstraintPool.size(); int numFrictionPool = m_tmpSolverContactFrictionConstraintPool.size(); - int numRollingFrictionPool = m_tmpSolverContactRollingFrictionConstraintPool.size(); if (infoGlobal.m_solverMode & SOLVER_RANDMIZE_ORDER) {