From 85724b55000fb2950b2241269200e7cc1d1bcf28 Mon Sep 17 00:00:00 2001 From: "erwin.coumans" Date: Fri, 19 Feb 2010 23:24:04 +0000 Subject: [PATCH] SerializeDemo: create a testFile.bullet if it is missing Serialization: remove obsolete autogenerated headers Minor changes in btSequentialImpulseConstraintSolver: split methods to make it easier to derive from the class and add functionality. --- CMakeLists.txt | 2 +- Demos/SerializeDemo/SerializeDemo.cpp | 259 ++++----- .../bullet_btCollisionObjectData.h | 63 -- .../autogenerated/bullet_btMatrix3x3Data.h | 40 -- .../autogenerated/bullet_btRigidBodyData.h | 62 -- .../autogenerated/bullet_btTransformData.h | 42 -- .../autogenerated/bullet_btVector3Data.h | 39 -- .../Serialize/HeaderGenerator/CMakeLists.txt | 9 + .../HeaderGenerator/bulletGenerate.py | 2 +- .../HeaderGenerator/createDnaString.bat | 2 + .../btSequentialImpulseConstraintSolver.cpp | 536 ++++++++++-------- .../btSequentialImpulseConstraintSolver.h | 22 +- src/LinearMath/btSerializer.cpp | 223 -------- 13 files changed, 436 insertions(+), 865 deletions(-) delete mode 100644 Extras/Serialize/BulletFileLoader/autogenerated/bullet_btCollisionObjectData.h delete mode 100644 Extras/Serialize/BulletFileLoader/autogenerated/bullet_btMatrix3x3Data.h delete mode 100644 Extras/Serialize/BulletFileLoader/autogenerated/bullet_btRigidBodyData.h delete mode 100644 Extras/Serialize/BulletFileLoader/autogenerated/bullet_btTransformData.h delete mode 100644 Extras/Serialize/BulletFileLoader/autogenerated/bullet_btVector3Data.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 552f6ba3a..00f5e30b8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,7 +5,7 @@ cmake_minimum_required(VERSION 2.4) SET(MSVC_INCREMENTAL_DEFAULT ON) PROJECT(BULLET_PHYSICS) -SET(BULLET_VERSION 2.75) +SET(BULLET_VERSION 2.76) IF (NOT CMAKE_BUILD_TYPE) # SET(CMAKE_BUILD_TYPE "Debug") diff --git a/Demos/SerializeDemo/SerializeDemo.cpp b/Demos/SerializeDemo/SerializeDemo.cpp index f9e421718..c8b4534af 100644 --- a/Demos/SerializeDemo/SerializeDemo.cpp +++ b/Demos/SerializeDemo/SerializeDemo.cpp @@ -122,156 +122,133 @@ void SerializeDemo::initPhysics() setupEmptyDynamicsWorld(); - ///create a few basic rigid bodies - btCollisionShape* groundShape = new btBoxShape(btVector3(btScalar(50.),btScalar(50.),btScalar(50.))); -// btCollisionShape* groundShape = new btStaticPlaneShape(btVector3(0,1,0),50); - btCollisionObject* groundObject = 0; - - - m_collisionShapes.push_back(groundShape); - - btTransform groundTransform; - groundTransform.setIdentity(); - groundTransform.setOrigin(btVector3(0,-50,0)); - - //We can also use DemoApplication::localCreateRigidBody, but for clarity it is provided here: - { - btScalar mass(0.); - - //rigidbody is dynamic if and only if mass is non zero, otherwise static - bool isDynamic = (mass != 0.f); - - btVector3 localInertia(0,0,0); - if (isDynamic) - groundShape->calculateLocalInertia(mass,localInertia); - - //using motionstate is recommended, it provides interpolation capabilities, and only synchronizes 'active' objects - btDefaultMotionState* myMotionState = new btDefaultMotionState(groundTransform); - btRigidBody::btRigidBodyConstructionInfo rbInfo(mass,myMotionState,groundShape,localInertia); - btRigidBody* body = new btRigidBody(rbInfo); - - //add the body to the dynamics world - m_dynamicsWorld->addRigidBody(body); - groundObject = body; - } - - - { - //create a few dynamic rigidbodies - // Re-using the same collision is better for memory usage and performance - - int numSpheres = 2; - btVector3 positions[2] = {btVector3(0.1f,0.2f,0.3f),btVector3(0.4f,0.5f,0.6f)}; - btScalar radii[2] = {0.3f,0.4f}; - - btMultiSphereShape* colShape = new btMultiSphereShape(positions,radii,numSpheres); - - //btCollisionShape* colShape = new btCapsuleShapeZ(SCALING*1,SCALING*1); - //btCollisionShape* colShape = new btCylinderShapeZ(btVector3(SCALING*1,SCALING*1,SCALING*1)); - //btCollisionShape* colShape = new btBoxShape(btVector3(SCALING*1,SCALING*1,SCALING*1)); - //btCollisionShape* colShape = new btSphereShape(btScalar(1.)); - m_collisionShapes.push_back(colShape); - - /// Create Dynamic Objects - btTransform startTransform; - startTransform.setIdentity(); - - btScalar mass(1.f); - - //rigidbody is dynamic if and only if mass is non zero, otherwise static - bool isDynamic = (mass != 0.f); - - btVector3 localInertia(0,0,0); - if (isDynamic) - colShape->calculateLocalInertia(mass,localInertia); - - float start_x = START_POS_X - ARRAY_SIZE_X/2; - float start_y = START_POS_Y; - float start_z = START_POS_Z - ARRAY_SIZE_Z/2; - - for (int k=0;ksetActivationState(ISLAND_SLEEPING); - - m_dynamicsWorld->addRigidBody(body); - body->setActivationState(ISLAND_SLEEPING); - } - } - } - } - - - clientResetScene(); - - -#ifdef TEST_SERIALIZATION - //test serializing this - -#ifdef CREATE_NEW_BULLETFILE - int maxSerializeBufferSize = 1024*1024*5; - - btDefaultSerializer* serializer = new btDefaultSerializer(maxSerializeBufferSize); - - static char* groundName = "GroundName"; - serializer->registerNameForPointer(groundObject, groundName); - - for (int i=0;iregisterNameForPointer(m_collisionShapes[i],name); - } - - btPoint2PointConstraint* p2p = new btPoint2PointConstraint(*(btRigidBody*)getDynamicsWorld()->getCollisionObjectArray()[2],btVector3(0,1,0)); - m_dynamicsWorld->addConstraint(p2p); - - const char* name = "constraintje"; - serializer->registerNameForPointer(p2p,name); - - m_dynamicsWorld->serialize(serializer); - - FILE* f2 = fopen("testFile.bullet","wb"); - fwrite(serializer->getBufferPointer(),serializer->getCurrentBufferSize(),1,f2); - fclose(f2); -#endif //CREATE_NEW_BULLETFILE - - exitPhysics(); - - //now try again from the loaded file - setupEmptyDynamicsWorld(); - - printf("loading file\n"); btBulletWorldImporter* fileLoader = new btBulletWorldImporter(m_dynamicsWorld); //fileLoader->setVerboseMode(true); if (!fileLoader->loadFile("testFile.bullet")) { - //cmake generated msvc files need 4 levels deep back... so make a 3rd attempt... - if (fileLoader->loadFile("../../../../testFileOriginal.bullet")) + ///create a few basic rigid bodies and save them to testFile.bullet + btCollisionShape* groundShape = new btBoxShape(btVector3(btScalar(50.),btScalar(50.),btScalar(50.))); + // btCollisionShape* groundShape = new btStaticPlaneShape(btVector3(0,1,0),50); + btCollisionObject* groundObject = 0; + + + m_collisionShapes.push_back(groundShape); + + btTransform groundTransform; + groundTransform.setIdentity(); + groundTransform.setOrigin(btVector3(0,-50,0)); + + //We can also use DemoApplication::localCreateRigidBody, but for clarity it is provided here: { - printf("loaded fine\n"); + btScalar mass(0.); + + //rigidbody is dynamic if and only if mass is non zero, otherwise static + bool isDynamic = (mass != 0.f); + + btVector3 localInertia(0,0,0); + if (isDynamic) + groundShape->calculateLocalInertia(mass,localInertia); + + //using motionstate is recommended, it provides interpolation capabilities, and only synchronizes 'active' objects + btDefaultMotionState* myMotionState = new btDefaultMotionState(groundTransform); + btRigidBody::btRigidBodyConstructionInfo rbInfo(mass,myMotionState,groundShape,localInertia); + btRigidBody* body = new btRigidBody(rbInfo); + + //add the body to the dynamics world + m_dynamicsWorld->addRigidBody(body); + groundObject = body; } + + + { + //create a few dynamic rigidbodies + // Re-using the same collision is better for memory usage and performance + + int numSpheres = 2; + btVector3 positions[2] = {btVector3(0.1f,0.2f,0.3f),btVector3(0.4f,0.5f,0.6f)}; + btScalar radii[2] = {0.3f,0.4f}; + + btMultiSphereShape* colShape = new btMultiSphereShape(positions,radii,numSpheres); + + //btCollisionShape* colShape = new btCapsuleShapeZ(SCALING*1,SCALING*1); + //btCollisionShape* colShape = new btCylinderShapeZ(btVector3(SCALING*1,SCALING*1,SCALING*1)); + //btCollisionShape* colShape = new btBoxShape(btVector3(SCALING*1,SCALING*1,SCALING*1)); + //btCollisionShape* colShape = new btSphereShape(btScalar(1.)); + m_collisionShapes.push_back(colShape); + + /// Create Dynamic Objects + btTransform startTransform; + startTransform.setIdentity(); + + btScalar mass(1.f); + + //rigidbody is dynamic if and only if mass is non zero, otherwise static + bool isDynamic = (mass != 0.f); + + btVector3 localInertia(0,0,0); + if (isDynamic) + colShape->calculateLocalInertia(mass,localInertia); + + float start_x = START_POS_X - ARRAY_SIZE_X/2; + float start_y = START_POS_Y; + float start_z = START_POS_Z - ARRAY_SIZE_Z/2; + + for (int k=0;ksetActivationState(ISLAND_SLEEPING); + + m_dynamicsWorld->addRigidBody(body); + body->setActivationState(ISLAND_SLEEPING); + } + } + } + } + + int maxSerializeBufferSize = 1024*1024*5; + + btDefaultSerializer* serializer = new btDefaultSerializer(maxSerializeBufferSize); + + static char* groundName = "GroundName"; + serializer->registerNameForPointer(groundObject, groundName); + + for (int i=0;iregisterNameForPointer(m_collisionShapes[i],name); + } + + btPoint2PointConstraint* p2p = new btPoint2PointConstraint(*(btRigidBody*)getDynamicsWorld()->getCollisionObjectArray()[2],btVector3(0,1,0)); + m_dynamicsWorld->addConstraint(p2p); + + const char* name = "constraintje"; + serializer->registerNameForPointer(p2p,name); + + m_dynamicsWorld->serialize(serializer); + + FILE* f2 = fopen("testFile.bullet","wb"); + fwrite(serializer->getBufferPointer(),serializer->getCurrentBufferSize(),1,f2); + fclose(f2); } - - -#endif //TEST_SERIALIZATION + clientResetScene(); } diff --git a/Extras/Serialize/BulletFileLoader/autogenerated/bullet_btCollisionObjectData.h b/Extras/Serialize/BulletFileLoader/autogenerated/bullet_btCollisionObjectData.h deleted file mode 100644 index 609ea38b0..000000000 --- a/Extras/Serialize/BulletFileLoader/autogenerated/bullet_btCollisionObjectData.h +++ /dev/null @@ -1,63 +0,0 @@ -/* Copyright (C) 2006-2009 Erwin Coumans & Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BULLET_BTCOLLISIONOBJECTDATA__H__ -#define __BULLET_BTCOLLISIONOBJECTDATA__H__ - - -// -------------------------------------------------- // -#include "bullet_Common.h" -#include "bullet_btTransformData.h" -#include "bullet_btVector3Data.h" - -namespace Bullet { - - - // ---------------------------------------------- // - class btCollisionObjectData - { - public: - btTransformData m_worldTransform; - btTransformData m_interpolationWorldTransform; - btVector3Data m_interpolationLinearVelocity; - btVector3Data m_interpolationAngularVelocity; - btVector3Data m_anisotropicFriction; - int m_hasAnisotropicFriction; - btScalar m_contactProcessingThreshold; - void *m_broadphaseHandle; - void *m_collisionShape; - btCollisionShapeData *m_rootCollisionShape; - int m_collisionFlags; - int m_islandTag1; - int m_companionId; - int m_activationState1; - btScalar m_deactivationTime; - btScalar m_friction; - btScalar m_restitution; - int m_internalType; - void *m_userObjectPointer; - btScalar m_hitFraction; - btScalar m_ccdSweptSphereRadius; - btScalar m_ccdMotionThreshold; - int m_checkCollideWith; - }; -} - - -#endif//__BULLET_BTCOLLISIONOBJECTDATA__H__ diff --git a/Extras/Serialize/BulletFileLoader/autogenerated/bullet_btMatrix3x3Data.h b/Extras/Serialize/BulletFileLoader/autogenerated/bullet_btMatrix3x3Data.h deleted file mode 100644 index daade117b..000000000 --- a/Extras/Serialize/BulletFileLoader/autogenerated/bullet_btMatrix3x3Data.h +++ /dev/null @@ -1,40 +0,0 @@ -/* Copyright (C) 2006-2009 Erwin Coumans & Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BULLET_BTMATRIX3X3DATA__H__ -#define __BULLET_BTMATRIX3X3DATA__H__ - - -// -------------------------------------------------- // -#include "bullet_Common.h" -#include "bullet_btVector3Data.h" - -namespace Bullet { - - - // ---------------------------------------------- // - class btMatrix3x3Data - { - public: - btVector3Data m_el[3]; - }; -} - - -#endif//__BULLET_BTMATRIX3X3DATA__H__ diff --git a/Extras/Serialize/BulletFileLoader/autogenerated/bullet_btRigidBodyData.h b/Extras/Serialize/BulletFileLoader/autogenerated/bullet_btRigidBodyData.h deleted file mode 100644 index d1350cb54..000000000 --- a/Extras/Serialize/BulletFileLoader/autogenerated/bullet_btRigidBodyData.h +++ /dev/null @@ -1,62 +0,0 @@ -/* Copyright (C) 2006-2009 Erwin Coumans & Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BULLET_BTRIGIDBODYDATA__H__ -#define __BULLET_BTRIGIDBODYDATA__H__ - - -// -------------------------------------------------- // -#include "bullet_Common.h" -#include "bullet_btCollisionObjectData.h" -#include "bullet_btMatrix3x3Data.h" -#include "bullet_btVector3Data.h" - -namespace Bullet { - - - // ---------------------------------------------- // - class btRigidBodyData - { - public: - btCollisionObjectData m_collisionObjectData; - btMatrix3x3Data m_invInertiaTensorWorld; - btVector3Data m_linearVelocity; - btVector3Data m_angularVelocity; - btScalar m_inverseMass; - btVector3Data m_angularFactor; - btVector3Data m_linearFactor; - btVector3Data m_gravity; - btVector3Data m_gravity_acceleration; - btVector3Data m_invInertiaLocal; - btVector3Data m_totalForce; - btVector3Data m_totalTorque; - btScalar m_linearDamping; - btScalar m_angularDamping; - int m_additionalDamping; - btScalar m_additionalDampingFactor; - btScalar m_additionalLinearDampingThresholdSqr; - btScalar m_additionalAngularDampingThresholdSqr; - btScalar m_additionalAngularDampingFactor; - btScalar m_linearSleepingThreshold; - btScalar m_angularSleepingThreshold; - }; -} - - -#endif//__BULLET_BTRIGIDBODYDATA__H__ diff --git a/Extras/Serialize/BulletFileLoader/autogenerated/bullet_btTransformData.h b/Extras/Serialize/BulletFileLoader/autogenerated/bullet_btTransformData.h deleted file mode 100644 index b1d9023b3..000000000 --- a/Extras/Serialize/BulletFileLoader/autogenerated/bullet_btTransformData.h +++ /dev/null @@ -1,42 +0,0 @@ -/* Copyright (C) 2006-2009 Erwin Coumans & Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BULLET_BTTRANSFORMDATA__H__ -#define __BULLET_BTTRANSFORMDATA__H__ - - -// -------------------------------------------------- // -#include "bullet_Common.h" -#include "bullet_btMatrix3x3Data.h" -#include "bullet_btVector3Data.h" - -namespace Bullet { - - - // ---------------------------------------------- // - class btTransformData - { - public: - btMatrix3x3Data m_basis; - btVector3Data m_origin; - }; -} - - -#endif//__BULLET_BTTRANSFORMDATA__H__ diff --git a/Extras/Serialize/BulletFileLoader/autogenerated/bullet_btVector3Data.h b/Extras/Serialize/BulletFileLoader/autogenerated/bullet_btVector3Data.h deleted file mode 100644 index 7b8b4e631..000000000 --- a/Extras/Serialize/BulletFileLoader/autogenerated/bullet_btVector3Data.h +++ /dev/null @@ -1,39 +0,0 @@ -/* Copyright (C) 2006-2009 Erwin Coumans & Charlie C -* -* This software is provided 'as-is', without any express or implied -* warranty. In no event will the authors be held liable for any damages -* arising from the use of this software. -* -* Permission is granted to anyone to use this software for any purpose, -* including commercial applications, and to alter it and redistribute it -* freely, subject to the following restrictions: -* -* 1. The origin of this software must not be misrepresented; you must not -* claim that you wrote the original software. If you use this software -* in a product, an acknowledgment in the product documentation would be -* appreciated but is not required. -* 2. Altered source versions must be plainly marked as such, and must not be -* misrepresented as being the original software. -* 3. This notice may not be removed or altered from any source distribution. -*/ -// Auto generated from makesdna dna.c -#ifndef __BULLET_BTVECTOR3DATA__H__ -#define __BULLET_BTVECTOR3DATA__H__ - - -// -------------------------------------------------- // -#include "bullet_Common.h" - -namespace Bullet { - - - // ---------------------------------------------- // - class btVector3Data - { - public: - btScalar m_floats[4]; - }; -} - - -#endif//__BULLET_BTVECTOR3DATA__H__ diff --git a/Extras/Serialize/HeaderGenerator/CMakeLists.txt b/Extras/Serialize/HeaderGenerator/CMakeLists.txt index b21f61100..ee975cc04 100644 --- a/Extras/Serialize/HeaderGenerator/CMakeLists.txt +++ b/Extras/Serialize/HeaderGenerator/CMakeLists.txt @@ -21,3 +21,12 @@ INCLUDE_DIRECTORIES(${includes}) SET(Main_LIBS LinearMath) ADD_EXECUTABLE(HeaderGenerator ${cpp_SRC} ${h_SRC}) + +IF (NOT INTERNAL_CREATE_DISTRIBUTABLE_MSVC_PROJECTFILES) + ADD_CUSTOM_COMMAND( + TARGET HeaderGenerator + POST_BUILD + COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different ${BULLET_PHYSICS_SOURCE_DIR}/Extras/Serialize/HeaderGenerator/createDnaString.bat ${CMAKE_CURRENT_BINARY_DIR}/createDnaString.bat + COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different ${BULLET_PHYSICS_SOURCE_DIR}/Extras/Serialize/HeaderGenerator/bulletGenerate.py ${CMAKE_CURRENT_BINARY_DIR}/bulletGenerate.py + ) +ENDIF (NOT INTERNAL_CREATE_DISTRIBUTABLE_MSVC_PROJECTFILES) diff --git a/Extras/Serialize/HeaderGenerator/bulletGenerate.py b/Extras/Serialize/HeaderGenerator/bulletGenerate.py index aa18dda48..6db03225e 100644 --- a/Extras/Serialize/HeaderGenerator/bulletGenerate.py +++ b/Extras/Serialize/HeaderGenerator/bulletGenerate.py @@ -24,7 +24,7 @@ header = """/* Copyright (C) 2006-2009 Erwin Coumans & Charlie C dtList = dump.DataTypeList -out = "../BulletFileLoader/autogenerated/" +out = "autogenerated/" spaces = 4 def addSpaces(file, space): diff --git a/Extras/Serialize/HeaderGenerator/createDnaString.bat b/Extras/Serialize/HeaderGenerator/createDnaString.bat index cdadf4a14..d4a1dcd12 100644 --- a/Extras/Serialize/HeaderGenerator/createDnaString.bat +++ b/Extras/Serialize/HeaderGenerator/createDnaString.bat @@ -1,5 +1,7 @@ delete dnaString.txt +mkdir autogenerated + Debug\HeaderGenerator.exe python bulletGenerate.py \ No newline at end of file diff --git a/src/BulletDynamics/ConstraintSolver/btSequentialImpulseConstraintSolver.cpp b/src/BulletDynamics/ConstraintSolver/btSequentialImpulseConstraintSolver.cpp index 28c4fa8dc..6157d2924 100644 --- a/src/BulletDynamics/ConstraintSolver/btSequentialImpulseConstraintSolver.cpp +++ b/src/BulletDynamics/ConstraintSolver/btSequentialImpulseConstraintSolver.cpp @@ -329,21 +329,17 @@ void applyAnisotropicFriction(btCollisionObject* colObj,btVector3& frictionDirec } - -btSolverConstraint& btSequentialImpulseConstraintSolver::addFrictionConstraint(const btVector3& normalAxis,btRigidBody* solverBodyA,btRigidBody* solverBodyB,int frictionIndex,btManifoldPoint& cp,const btVector3& rel_pos1,const btVector3& rel_pos2,btCollisionObject* colObj0,btCollisionObject* colObj1, btScalar relaxation, btScalar desiredVelocity, btScalar cfmSlip) +void btSequentialImpulseConstraintSolver::setupFrictionConstraint(btSolverConstraint& solverConstraint, const btVector3& normalAxis,btRigidBody* solverBodyA,btRigidBody* solverBodyB,btManifoldPoint& cp,const btVector3& rel_pos1,const btVector3& rel_pos2,btCollisionObject* colObj0,btCollisionObject* colObj1, btScalar relaxation, btScalar desiredVelocity, btScalar cfmSlip) { btRigidBody* body0=btRigidBody::upcast(colObj0); btRigidBody* body1=btRigidBody::upcast(colObj1); - btSolverConstraint& solverConstraint = m_tmpSolverContactFrictionConstraintPool.expandNonInitializing(); - //memset(&solverConstraint,0xff,sizeof(btSolverConstraint)); solverConstraint.m_contactNormal = normalAxis; solverConstraint.m_solverBodyA = body0 ? body0 : &getFixedBody(); solverConstraint.m_solverBodyB = body1 ? body1 : &getFixedBody(); - solverConstraint.m_frictionIndex = frictionIndex; solverConstraint.m_friction = cp.m_combinedFriction; solverConstraint.m_originalContactPoint = 0; @@ -413,7 +409,16 @@ btSolverConstraint& btSequentialImpulseConstraintSolver::addFrictionConstraint(c solverConstraint.m_lowerLimit = 0; solverConstraint.m_upperLimit = 1e10f; } +} + + +btSolverConstraint& btSequentialImpulseConstraintSolver::addFrictionConstraint(const btVector3& normalAxis,btRigidBody* solverBodyA,btRigidBody* solverBodyB,int frictionIndex,btManifoldPoint& cp,const btVector3& rel_pos1,const btVector3& rel_pos2,btCollisionObject* colObj0,btCollisionObject* colObj1, btScalar relaxation, btScalar desiredVelocity, btScalar cfmSlip) +{ + btSolverConstraint& solverConstraint = m_tmpSolverContactFrictionConstraintPool.expandNonInitializing(); + solverConstraint.m_frictionIndex = frictionIndex; + setupFrictionConstraint(solverConstraint, normalAxis, solverBodyA, solverBodyB, cp, rel_pos1, rel_pos2, + colObj0, colObj1, relaxation, desiredVelocity, cfmSlip); return solverConstraint; } @@ -447,62 +452,30 @@ int btSequentialImpulseConstraintSolver::getOrInitSolverBody(btCollisionObject& #include - -void btSequentialImpulseConstraintSolver::convertContact(btPersistentManifold* manifold,const btContactSolverInfo& infoGlobal) +void btSequentialImpulseConstraintSolver::setupContactConstraint(btSolverConstraint& solverConstraint, + btCollisionObject* colObj0, btCollisionObject* colObj1, + btManifoldPoint& cp, const btContactSolverInfo& infoGlobal, + btVector3& vel, btScalar& rel_vel, btScalar& relaxation, + btVector3& rel_pos1, btVector3& rel_pos2) { - btCollisionObject* colObj0=0,*colObj1=0; - - colObj0 = (btCollisionObject*)manifold->getBody0(); - colObj1 = (btCollisionObject*)manifold->getBody1(); - - - btRigidBody* solverBodyA = btRigidBody::upcast(colObj0); - btRigidBody* solverBodyB = btRigidBody::upcast(colObj1); - - - ///avoid collision response between two static objects - if (!solverBodyA && !solverBodyB) - return; - - btVector3 rel_pos1; - btVector3 rel_pos2; - btScalar relaxation; - - for (int j=0;jgetNumContacts();j++) - { - - btManifoldPoint& cp = manifold->getContactPoint(j); - - if (cp.getDistance() <= manifold->getContactProcessingThreshold()) - { + btRigidBody* rb0 = btRigidBody::upcast(colObj0); + btRigidBody* rb1 = btRigidBody::upcast(colObj1); const btVector3& pos1 = cp.getPositionWorldOnA(); const btVector3& pos2 = cp.getPositionWorldOnB(); +// btVector3 rel_pos1 = pos1 - colObj0->getWorldTransform().getOrigin(); +// btVector3 rel_pos2 = pos2 - colObj1->getWorldTransform().getOrigin(); rel_pos1 = pos1 - colObj0->getWorldTransform().getOrigin(); rel_pos2 = pos2 - colObj1->getWorldTransform().getOrigin(); - relaxation = 1.f; - btScalar rel_vel; - btVector3 vel; - int frictionIndex = m_tmpSolverContactConstraintPool.size(); + btVector3 torqueAxis0 = rel_pos1.cross(cp.m_normalWorldOnB); + solverConstraint.m_angularComponentA = rb0 ? rb0->getInvInertiaTensorWorld()*torqueAxis0*rb0->getAngularFactor() : btVector3(0,0,0); + btVector3 torqueAxis1 = rel_pos2.cross(cp.m_normalWorldOnB); + solverConstraint.m_angularComponentB = rb1 ? rb1->getInvInertiaTensorWorld()*-torqueAxis1*rb1->getAngularFactor() : btVector3(0,0,0); - { - btSolverConstraint& solverConstraint = m_tmpSolverContactConstraintPool.expandNonInitializing(); - btRigidBody* rb0 = btRigidBody::upcast(colObj0); - btRigidBody* rb1 = btRigidBody::upcast(colObj1); - - solverConstraint.m_solverBodyA = rb0? rb0 : &getFixedBody(); - solverConstraint.m_solverBodyB = rb1? rb1 : &getFixedBody(); - - solverConstraint.m_originalContactPoint = &cp; - - btVector3 torqueAxis0 = rel_pos1.cross(cp.m_normalWorldOnB); - solverConstraint.m_angularComponentA = rb0 ? rb0->getInvInertiaTensorWorld()*torqueAxis0*rb0->getAngularFactor() : btVector3(0,0,0); - btVector3 torqueAxis1 = rel_pos2.cross(cp.m_normalWorldOnB); - solverConstraint.m_angularComponentB = rb1 ? rb1->getInvInertiaTensorWorld()*-torqueAxis1*rb1->getAngularFactor() : btVector3(0,0,0); { #ifdef COMPUTE_IMPULSE_DENOM btScalar denom0 = rb0->computeImpulseDenominator(pos1,cp.m_normalWorldOnB); @@ -532,12 +505,12 @@ void btSequentialImpulseConstraintSolver::convertContact(btPersistentManifold* m solverConstraint.m_relpos2CrossNormal = rel_pos2.cross(-cp.m_normalWorldOnB); - btVector3 vel1 = rb0 ? rb0->getVelocityInLocalPoint(rel_pos1) : btVector3(0,0,0); - btVector3 vel2 = rb1 ? rb1->getVelocityInLocalPoint(rel_pos2) : btVector3(0,0,0); - vel = vel1 - vel2; - rel_vel = cp.m_normalWorldOnB.dot(vel); + btVector3 vel1 = rb0 ? rb0->getVelocityInLocalPoint(rel_pos1) : btVector3(0,0,0); + btVector3 vel2 = rb1 ? rb1->getVelocityInLocalPoint(rel_pos2) : btVector3(0,0,0); + vel = vel1 - vel2; + rel_vel = cp.m_normalWorldOnB.dot(vel); btScalar penetration = cp.getDistance()+infoGlobal.m_linearSlop; @@ -605,58 +578,16 @@ void btSequentialImpulseConstraintSolver::convertContact(btPersistentManifold* m } - /////setup the friction constraints + + +} - if (1) - { - solverConstraint.m_frictionIndex = m_tmpSolverContactFrictionConstraintPool.size(); - if (!(infoGlobal.m_solverMode & SOLVER_ENABLE_FRICTION_DIRECTION_CACHING) || !cp.m_lateralFrictionInitialized) - { - cp.m_lateralFrictionDir1 = vel - cp.m_normalWorldOnB * rel_vel; - btScalar lat_rel_vel = cp.m_lateralFrictionDir1.length2(); - if (!(infoGlobal.m_solverMode & SOLVER_DISABLE_VELOCITY_DEPENDENT_FRICTION_DIRECTION) && lat_rel_vel > SIMD_EPSILON) - { - cp.m_lateralFrictionDir1 /= btSqrt(lat_rel_vel); - if((infoGlobal.m_solverMode & SOLVER_USE_2_FRICTION_DIRECTIONS)) - { - cp.m_lateralFrictionDir2 = cp.m_lateralFrictionDir1.cross(cp.m_normalWorldOnB); - cp.m_lateralFrictionDir2.normalize();//?? - applyAnisotropicFriction(colObj0,cp.m_lateralFrictionDir2); - applyAnisotropicFriction(colObj1,cp.m_lateralFrictionDir2); - addFrictionConstraint(cp.m_lateralFrictionDir2,solverBodyA,solverBodyB,frictionIndex,cp,rel_pos1,rel_pos2,colObj0,colObj1, relaxation); - } - - applyAnisotropicFriction(colObj0,cp.m_lateralFrictionDir1); - applyAnisotropicFriction(colObj1,cp.m_lateralFrictionDir1); - addFrictionConstraint(cp.m_lateralFrictionDir1,solverBodyA,solverBodyB,frictionIndex,cp,rel_pos1,rel_pos2,colObj0,colObj1, relaxation); - cp.m_lateralFrictionInitialized = true; - } else - { - //re-calculate friction direction every frame, todo: check if this is really needed - btPlaneSpace1(cp.m_normalWorldOnB,cp.m_lateralFrictionDir1,cp.m_lateralFrictionDir2); - if ((infoGlobal.m_solverMode & SOLVER_USE_2_FRICTION_DIRECTIONS)) - { - applyAnisotropicFriction(colObj0,cp.m_lateralFrictionDir2); - applyAnisotropicFriction(colObj1,cp.m_lateralFrictionDir2); - addFrictionConstraint(cp.m_lateralFrictionDir2,solverBodyA,solverBodyB,frictionIndex,cp,rel_pos1,rel_pos2,colObj0,colObj1, relaxation); - } - - applyAnisotropicFriction(colObj0,cp.m_lateralFrictionDir1); - applyAnisotropicFriction(colObj1,cp.m_lateralFrictionDir1); - addFrictionConstraint(cp.m_lateralFrictionDir1,solverBodyA,solverBodyB,frictionIndex,cp,rel_pos1,rel_pos2,colObj0,colObj1, relaxation); - - cp.m_lateralFrictionInitialized = true; - } - - } else - { - addFrictionConstraint(cp.m_lateralFrictionDir1,solverBodyA,solverBodyB,frictionIndex,cp,rel_pos1,rel_pos2,colObj0,colObj1, relaxation,cp.m_contactMotion1, cp.m_contactCFM1); - if ((infoGlobal.m_solverMode & SOLVER_USE_2_FRICTION_DIRECTIONS)) - addFrictionConstraint(cp.m_lateralFrictionDir2,solverBodyA,solverBodyB,frictionIndex,cp,rel_pos1,rel_pos2,colObj0,colObj1, relaxation, cp.m_contactMotion2, cp.m_contactCFM2); - } - +void btSequentialImpulseConstraintSolver::setFrictionConstraintImpulse( btSolverConstraint& solverConstraint, + btRigidBody* rb0, btRigidBody* rb1, + btManifoldPoint& cp, const btContactSolverInfo& infoGlobal) +{ if (infoGlobal.m_solverMode & SOLVER_USE_FRICTION_WARMSTARTING) { { @@ -699,10 +630,105 @@ void btSequentialImpulseConstraintSolver::convertContact(btPersistentManifold* m frictionConstraint2.m_appliedImpulse = 0.f; } } - } - } +} + + +void btSequentialImpulseConstraintSolver::convertContact(btPersistentManifold* manifold,const btContactSolverInfo& infoGlobal) +{ + btCollisionObject* colObj0=0,*colObj1=0; + + colObj0 = (btCollisionObject*)manifold->getBody0(); + colObj1 = (btCollisionObject*)manifold->getBody1(); + + + btRigidBody* solverBodyA = btRigidBody::upcast(colObj0); + btRigidBody* solverBodyB = btRigidBody::upcast(colObj1); + +//?????????????????? +// TODO : check InverseMass instead + ///avoid collision response between two static objects + if (!solverBodyA && !solverBodyB) + return; + + for (int j=0;jgetNumContacts();j++) + { + + btManifoldPoint& cp = manifold->getContactPoint(j); + + if (cp.getDistance() <= manifold->getContactProcessingThreshold()) + { + btVector3 rel_pos1; + btVector3 rel_pos2; + btScalar relaxation; + btScalar rel_vel; + btVector3 vel; + + int frictionIndex = m_tmpSolverContactConstraintPool.size(); + btSolverConstraint& solverConstraint = m_tmpSolverContactConstraintPool.expandNonInitializing(); + btRigidBody* rb0 = btRigidBody::upcast(colObj0); + btRigidBody* rb1 = btRigidBody::upcast(colObj1); + solverConstraint.m_solverBodyA = rb0? rb0 : &getFixedBody(); + solverConstraint.m_solverBodyB = rb1? rb1 : &getFixedBody(); + solverConstraint.m_originalContactPoint = &cp; + + setupContactConstraint(solverConstraint, colObj0, colObj1, cp, infoGlobal, vel, rel_vel, relaxation, rel_pos1, rel_pos2); + + const btVector3& pos1 = cp.getPositionWorldOnA(); + const btVector3& pos2 = cp.getPositionWorldOnB(); + + /////setup the friction constraints + + solverConstraint.m_frictionIndex = m_tmpSolverContactFrictionConstraintPool.size(); + + if (!(infoGlobal.m_solverMode & SOLVER_ENABLE_FRICTION_DIRECTION_CACHING) || !cp.m_lateralFrictionInitialized) + { + cp.m_lateralFrictionDir1 = vel - cp.m_normalWorldOnB * rel_vel; + btScalar lat_rel_vel = cp.m_lateralFrictionDir1.length2(); + if (!(infoGlobal.m_solverMode & SOLVER_DISABLE_VELOCITY_DEPENDENT_FRICTION_DIRECTION) && lat_rel_vel > SIMD_EPSILON) + { + cp.m_lateralFrictionDir1 /= btSqrt(lat_rel_vel); + if((infoGlobal.m_solverMode & SOLVER_USE_2_FRICTION_DIRECTIONS)) + { + cp.m_lateralFrictionDir2 = cp.m_lateralFrictionDir1.cross(cp.m_normalWorldOnB); + cp.m_lateralFrictionDir2.normalize();//?? + applyAnisotropicFriction(colObj0,cp.m_lateralFrictionDir2); + applyAnisotropicFriction(colObj1,cp.m_lateralFrictionDir2); + addFrictionConstraint(cp.m_lateralFrictionDir2,solverBodyA,solverBodyB,frictionIndex,cp,rel_pos1,rel_pos2,colObj0,colObj1, relaxation); + } + + applyAnisotropicFriction(colObj0,cp.m_lateralFrictionDir1); + applyAnisotropicFriction(colObj1,cp.m_lateralFrictionDir1); + addFrictionConstraint(cp.m_lateralFrictionDir1,solverBodyA,solverBodyB,frictionIndex,cp,rel_pos1,rel_pos2,colObj0,colObj1, relaxation); + cp.m_lateralFrictionInitialized = true; + } else + { + //re-calculate friction direction every frame, todo: check if this is really needed + btPlaneSpace1(cp.m_normalWorldOnB,cp.m_lateralFrictionDir1,cp.m_lateralFrictionDir2); + if ((infoGlobal.m_solverMode & SOLVER_USE_2_FRICTION_DIRECTIONS)) + { + applyAnisotropicFriction(colObj0,cp.m_lateralFrictionDir2); + applyAnisotropicFriction(colObj1,cp.m_lateralFrictionDir2); + addFrictionConstraint(cp.m_lateralFrictionDir2,solverBodyA,solverBodyB,frictionIndex,cp,rel_pos1,rel_pos2,colObj0,colObj1, relaxation); + } + + applyAnisotropicFriction(colObj0,cp.m_lateralFrictionDir1); + applyAnisotropicFriction(colObj1,cp.m_lateralFrictionDir1); + addFrictionConstraint(cp.m_lateralFrictionDir1,solverBodyA,solverBodyB,frictionIndex,cp,rel_pos1,rel_pos2,colObj0,colObj1, relaxation); + + cp.m_lateralFrictionInitialized = true; + } + + } else + { + addFrictionConstraint(cp.m_lateralFrictionDir1,solverBodyA,solverBodyB,frictionIndex,cp,rel_pos1,rel_pos2,colObj0,colObj1, relaxation,cp.m_contactMotion1, cp.m_contactCFM1); + if ((infoGlobal.m_solverMode & SOLVER_USE_2_FRICTION_DIRECTIONS)) + addFrictionConstraint(cp.m_lateralFrictionDir2,solverBodyA,solverBodyB,frictionIndex,cp,rel_pos1,rel_pos2,colObj0,colObj1, relaxation, cp.m_contactMotion2, cp.m_contactCFM2); + } + + setFrictionConstraintImpulse( solverConstraint, rb0, rb1, cp, infoGlobal); + } } } @@ -901,177 +927,173 @@ btScalar btSequentialImpulseConstraintSolver::solveGroupCacheFriendlySetup(btCol } -btScalar btSequentialImpulseConstraintSolver::solveGroupCacheFriendlyIterations(btCollisionObject** /*bodies */,int /*numBodies*/,btPersistentManifold** /*manifoldPtr*/, int /*numManifolds*/,btTypedConstraint** constraints,int numConstraints,const btContactSolverInfo& infoGlobal,btIDebugDraw* /*debugDrawer*/,btStackAlloc* /*stackAlloc*/) +btScalar btSequentialImpulseConstraintSolver::solveSingleIteration(int iteration, btCollisionObject** /*bodies */,int /*numBodies*/,btPersistentManifold** /*manifoldPtr*/, int /*numManifolds*/,btTypedConstraint** constraints,int numConstraints,const btContactSolverInfo& infoGlobal,btIDebugDraw* /*debugDrawer*/,btStackAlloc* /*stackAlloc*/) { - BT_PROFILE("solveGroupCacheFriendlyIterations"); int numConstraintPool = m_tmpSolverContactConstraintPool.size(); int numFrictionPool = m_tmpSolverContactFrictionConstraintPool.size(); - //should traverse the contacts random order... - int iteration; + int j; + + if (infoGlobal.m_solverMode & SOLVER_RANDMIZE_ORDER) { - for ( iteration = 0;iterationsolveConstraintObsolete(constraints[j]->getRigidBodyA(),constraints[j]->getRigidBodyB(),infoGlobal.m_timeStep); - } - - ///solve all contact constraints using SIMD, if available - int numPoolConstraints = m_tmpSolverContactConstraintPool.size(); - for (j=0;jbtScalar(0)) - { - solveManifold.m_lowerLimit = -(solveManifold.m_friction*totalImpulse); - solveManifold.m_upperLimit = solveManifold.m_friction*totalImpulse; - - resolveSingleConstraintRowGenericSIMD(*solveManifold.m_solverBodyA, *solveManifold.m_solverBodyB,solveManifold); - } - } - } else - { - - ///solve all joint constraints - for (j=0;jsolveConstraintObsolete(constraints[j]->getRigidBodyA(),constraints[j]->getRigidBodyB(),infoGlobal.m_timeStep); - } - ///solve all contact constraints - int numPoolConstraints = m_tmpSolverContactConstraintPool.size(); - for (j=0;jbtScalar(0)) - { - solveManifold.m_lowerLimit = -(solveManifold.m_friction*totalImpulse); - solveManifold.m_upperLimit = solveManifold.m_friction*totalImpulse; - - resolveSingleConstraintRowGeneric(*solveManifold.m_solverBodyA,*solveManifold.m_solverBodyB,solveManifold); - } - } + for (j=0; jsolveConstraintObsolete(constraints[j]->getRigidBodyA(),constraints[j]->getRigidBodyB(),infoGlobal.m_timeStep); + } - resolveSplitPenetrationImpulseCacheFriendly(*solveManifold.m_solverBodyA,*solveManifold.m_solverBodyB,solveManifold); - } - } - } + ///solve all contact constraints using SIMD, if available + int numPoolConstraints = m_tmpSolverContactConstraintPool.size(); + for (j=0;jbtScalar(0)) + { + solveManifold.m_lowerLimit = -(solveManifold.m_friction*totalImpulse); + solveManifold.m_upperLimit = solveManifold.m_friction*totalImpulse; + + resolveSingleConstraintRowGenericSIMD(*solveManifold.m_solverBodyA, *solveManifold.m_solverBodyB,solveManifold); + } + } + } else + { + + ///solve all joint constraints + for (j=0;jsolveConstraintObsolete(constraints[j]->getRigidBodyA(),constraints[j]->getRigidBodyB(),infoGlobal.m_timeStep); + } + ///solve all contact constraints + int numPoolConstraints = m_tmpSolverContactConstraintPool.size(); + for (j=0;jbtScalar(0)) + { + solveManifold.m_lowerLimit = -(solveManifold.m_friction*totalImpulse); + solveManifold.m_upperLimit = solveManifold.m_friction*totalImpulse; + + resolveSingleConstraintRowGeneric(*solveManifold.m_solverBodyA,*solveManifold.m_solverBodyB,solveManifold); } } - } return 0.f; } - -/// btSequentialImpulseConstraintSolver Sequentially applies impulses -btScalar btSequentialImpulseConstraintSolver::solveGroup(btCollisionObject** bodies,int numBodies,btPersistentManifold** manifoldPtr, int numManifolds,btTypedConstraint** constraints,int numConstraints,const btContactSolverInfo& infoGlobal,btIDebugDraw* debugDrawer,btStackAlloc* stackAlloc,btDispatcher* /*dispatcher*/) +void btSequentialImpulseConstraintSolver::solveGroupCacheFriendlySplitImpulseIterations(btCollisionObject** bodies,int numBodies,btPersistentManifold** manifoldPtr, int numManifolds,btTypedConstraint** constraints,int numConstraints,const btContactSolverInfo& infoGlobal,btIDebugDraw* debugDrawer,btStackAlloc* stackAlloc) { + int iteration; + if (infoGlobal.m_splitImpulse) + { + if (infoGlobal.m_solverMode & SOLVER_SIMD) + { + for ( iteration = 0;iteration m_orderFrictionConstraintPool; btAlignedObjectArray m_tmpConstraintSizesPool; + void setupFrictionConstraint( btSolverConstraint& solverConstraint, const btVector3& normalAxis,btRigidBody* solverBodyA,btRigidBody* solverBodyIdB, + btManifoldPoint& cp,const btVector3& rel_pos1,const btVector3& rel_pos2, + btCollisionObject* colObj0,btCollisionObject* colObj1, btScalar relaxation, + btScalar desiredVelocity=0., btScalar cfmSlip=0.); + btSolverConstraint& addFrictionConstraint(const btVector3& normalAxis,btRigidBody* solverBodyA,btRigidBody* solverBodyB,int frictionIndex,btManifoldPoint& cp,const btVector3& rel_pos1,const btVector3& rel_pos2,btCollisionObject* colObj0,btCollisionObject* colObj1, btScalar relaxation, btScalar desiredVelocity=0., btScalar cfmSlip=0.); + void setupContactConstraint(btSolverConstraint& solverConstraint, btCollisionObject* colObj0, btCollisionObject* colObj1, btManifoldPoint& cp, + const btContactSolverInfo& infoGlobal, btVector3& vel, btScalar& rel_vel, btScalar& relaxation, + btVector3& rel_pos1, btVector3& rel_pos2); + + void setFrictionConstraintImpulse( btSolverConstraint& solverConstraint, btRigidBody* rb0, btRigidBody* rb1, + btManifoldPoint& cp, const btContactSolverInfo& infoGlobal); + ///m_btSeed2 is used for re-arranging the constraint rows. improves convergence/quality of friction unsigned long m_btSeed2; @@ -75,6 +87,13 @@ protected: s_fixed.setMassProps(btScalar(0.),btVector3(btScalar(0.),btScalar(0.),btScalar(0.))); return s_fixed; } + virtual void solveGroupCacheFriendlySplitImpulseIterations(btCollisionObject** bodies,int numBodies,btPersistentManifold** manifoldPtr, int numManifolds,btTypedConstraint** constraints,int numConstraints,const btContactSolverInfo& infoGlobal,btIDebugDraw* debugDrawer,btStackAlloc* stackAlloc); + virtual btScalar solveGroupCacheFriendlyFinish(btCollisionObject** bodies ,int numBodies,btPersistentManifold** manifoldPtr, int numManifolds,btTypedConstraint** constraints,int numConstraints,const btContactSolverInfo& infoGlobal,btIDebugDraw* debugDrawer,btStackAlloc* stackAlloc); + btScalar solveSingleIteration(int iteration, btCollisionObject** bodies ,int numBodies,btPersistentManifold** manifoldPtr, int numManifolds,btTypedConstraint** constraints,int numConstraints,const btContactSolverInfo& infoGlobal,btIDebugDraw* debugDrawer,btStackAlloc* stackAlloc); + + virtual btScalar solveGroupCacheFriendlySetup(btCollisionObject** bodies,int numBodies,btPersistentManifold** manifoldPtr, int numManifolds,btTypedConstraint** constraints,int numConstraints,const btContactSolverInfo& infoGlobal,btIDebugDraw* debugDrawer,btStackAlloc* stackAlloc); + virtual btScalar solveGroupCacheFriendlyIterations(btCollisionObject** bodies,int numBodies,btPersistentManifold** manifoldPtr, int numManifolds,btTypedConstraint** constraints,int numConstraints,const btContactSolverInfo& infoGlobal,btIDebugDraw* debugDrawer,btStackAlloc* stackAlloc); + public: @@ -84,9 +103,8 @@ public: virtual btScalar solveGroup(btCollisionObject** bodies,int numBodies,btPersistentManifold** manifold,int numManifolds,btTypedConstraint** constraints,int numConstraints,const btContactSolverInfo& info, btIDebugDraw* debugDrawer, btStackAlloc* stackAlloc,btDispatcher* dispatcher); - btScalar solveGroupCacheFriendlySetup(btCollisionObject** bodies,int numBodies,btPersistentManifold** manifoldPtr, int numManifolds,btTypedConstraint** constraints,int numConstraints,const btContactSolverInfo& infoGlobal,btIDebugDraw* debugDrawer,btStackAlloc* stackAlloc); - btScalar solveGroupCacheFriendlyIterations(btCollisionObject** bodies,int numBodies,btPersistentManifold** manifoldPtr, int numManifolds,btTypedConstraint** constraints,int numConstraints,const btContactSolverInfo& infoGlobal,btIDebugDraw* debugDrawer,btStackAlloc* stackAlloc); + ///clear internal cached data and reset random seed virtual void reset(); diff --git a/src/LinearMath/btSerializer.cpp b/src/LinearMath/btSerializer.cpp index c20072854..d5df5fbd2 100644 --- a/src/LinearMath/btSerializer.cpp +++ b/src/LinearMath/btSerializer.cpp @@ -1,226 +1,3 @@ -unsigned char sBulletDNAstr64[]= { -83,68,78,65,78,65,77,69,-124,0,0,0,109,95,115,105,122,101,0,109, -95,99,97,112,97,99,105,116,121,0,42,109,95,100,97,116,97,0,109,95, -99,111,108,108,105,115,105,111,110,83,104,97,112,101,115,0,109,95,99,111, -108,108,105,115,105,111,110,79,98,106,101,99,116,115,0,109,95,99,111,110, -115,116,114,97,105,110,116,115,0,42,102,105,114,115,116,0,42,108,97,115, -116,0,109,95,102,108,111,97,116,115,91,52,93,0,109,95,101,108,91,51, -93,0,109,95,98,97,115,105,115,0,109,95,111,114,105,103,105,110,0,42, -109,95,110,97,109,101,0,109,95,115,104,97,112,101,84,121,112,101,0,109, -95,112,97,100,100,105,110,103,91,52,93,0,109,95,99,111,108,108,105,115, -105,111,110,83,104,97,112,101,68,97,116,97,0,109,95,108,111,99,97,108, -83,99,97,108,105,110,103,0,109,95,112,108,97,110,101,78,111,114,109,97, -108,0,109,95,112,108,97,110,101,67,111,110,115,116,97,110,116,0,109,95, -112,97,100,91,52,93,0,109,95,105,109,112,108,105,99,105,116,83,104,97, -112,101,68,105,109,101,110,115,105,111,110,115,0,109,95,99,111,108,108,105, -115,105,111,110,77,97,114,103,105,110,0,109,95,112,97,100,100,105,110,103, -0,109,95,112,111,115,0,109,95,114,97,100,105,117,115,0,109,95,99,111, -110,118,101,120,73,110,116,101,114,110,97,108,83,104,97,112,101,68,97,116, -97,0,42,109,95,108,111,99,97,108,80,111,115,105,116,105,111,110,65,114, -114,97,121,80,116,114,0,109,95,108,111,99,97,108,80,111,115,105,116,105, -111,110,65,114,114,97,121,83,105,122,101,0,109,95,118,97,108,117,101,0, -105,110,116,0,42,109,95,118,101,114,116,105,99,101,115,51,102,0,42,109, -95,118,101,114,116,105,99,101,115,51,100,0,42,109,95,105,110,100,105,99, -101,115,51,50,0,42,109,95,105,110,100,105,99,101,115,49,54,0,109,95, -110,117,109,84,114,105,97,110,103,108,101,115,0,109,95,110,117,109,86,101, -114,116,105,99,101,115,0,42,109,95,109,101,115,104,80,97,114,116,115,80, -116,114,0,109,95,115,99,97,108,105,110,103,0,109,95,110,117,109,77,101, -115,104,80,97,114,116,115,0,109,95,109,101,115,104,73,110,116,101,114,102, -97,99,101,0,109,95,116,114,97,110,115,102,111,114,109,0,42,109,95,99, -104,105,108,100,83,104,97,112,101,0,109,95,99,104,105,108,100,83,104,97, -112,101,84,121,112,101,0,109,95,99,104,105,108,100,77,97,114,103,105,110, -0,42,109,95,99,104,105,108,100,83,104,97,112,101,80,116,114,0,109,95, -110,117,109,67,104,105,108,100,83,104,97,112,101,115,0,109,95,117,112,65, -120,105,115,0,109,95,103,105,109,112,97,99,116,83,117,98,84,121,112,101, -0,42,109,95,117,110,115,99,97,108,101,100,80,111,105,110,116,115,70,108, -111,97,116,80,116,114,0,42,109,95,117,110,115,99,97,108,101,100,80,111, -105,110,116,115,68,111,117,98,108,101,80,116,114,0,109,95,110,117,109,85, -110,115,99,97,108,101,100,80,111,105,110,116,115,0,109,95,112,97,100,100, -105,110,103,51,91,52,93,0,42,109,95,98,114,111,97,100,112,104,97,115, -101,72,97,110,100,108,101,0,42,109,95,99,111,108,108,105,115,105,111,110, -83,104,97,112,101,0,42,109,95,114,111,111,116,67,111,108,108,105,115,105, -111,110,83,104,97,112,101,0,109,95,119,111,114,108,100,84,114,97,110,115, -102,111,114,109,0,109,95,105,110,116,101,114,112,111,108,97,116,105,111,110, -87,111,114,108,100,84,114,97,110,115,102,111,114,109,0,109,95,105,110,116, -101,114,112,111,108,97,116,105,111,110,76,105,110,101,97,114,86,101,108,111, -99,105,116,121,0,109,95,105,110,116,101,114,112,111,108,97,116,105,111,110, -65,110,103,117,108,97,114,86,101,108,111,99,105,116,121,0,109,95,97,110, -105,115,111,116,114,111,112,105,99,70,114,105,99,116,105,111,110,0,109,95, -99,111,110,116,97,99,116,80,114,111,99,101,115,115,105,110,103,84,104,114, -101,115,104,111,108,100,0,109,95,100,101,97,99,116,105,118,97,116,105,111, -110,84,105,109,101,0,109,95,102,114,105,99,116,105,111,110,0,109,95,114, -101,115,116,105,116,117,116,105,111,110,0,109,95,104,105,116,70,114,97,99, -116,105,111,110,0,109,95,99,99,100,83,119,101,112,116,83,112,104,101,114, -101,82,97,100,105,117,115,0,109,95,99,99,100,77,111,116,105,111,110,84, -104,114,101,115,104,111,108,100,0,109,95,104,97,115,65,110,105,115,111,116, -114,111,112,105,99,70,114,105,99,116,105,111,110,0,109,95,99,111,108,108, -105,115,105,111,110,70,108,97,103,115,0,109,95,105,115,108,97,110,100,84, -97,103,49,0,109,95,99,111,109,112,97,110,105,111,110,73,100,0,109,95, -97,99,116,105,118,97,116,105,111,110,83,116,97,116,101,49,0,109,95,105, -110,116,101,114,110,97,108,84,121,112,101,0,109,95,99,104,101,99,107,67, -111,108,108,105,100,101,87,105,116,104,0,109,95,99,111,108,108,105,115,105, -111,110,79,98,106,101,99,116,68,97,116,97,0,109,95,105,110,118,73,110, -101,114,116,105,97,84,101,110,115,111,114,87,111,114,108,100,0,109,95,108, -105,110,101,97,114,86,101,108,111,99,105,116,121,0,109,95,97,110,103,117, -108,97,114,86,101,108,111,99,105,116,121,0,109,95,97,110,103,117,108,97, -114,70,97,99,116,111,114,0,109,95,108,105,110,101,97,114,70,97,99,116, -111,114,0,109,95,103,114,97,118,105,116,121,0,109,95,103,114,97,118,105, -116,121,95,97,99,99,101,108,101,114,97,116,105,111,110,0,109,95,105,110, -118,73,110,101,114,116,105,97,76,111,99,97,108,0,109,95,116,111,116,97, -108,70,111,114,99,101,0,109,95,116,111,116,97,108,84,111,114,113,117,101, -0,109,95,105,110,118,101,114,115,101,77,97,115,115,0,109,95,108,105,110, -101,97,114,68,97,109,112,105,110,103,0,109,95,97,110,103,117,108,97,114, -68,97,109,112,105,110,103,0,109,95,97,100,100,105,116,105,111,110,97,108, -68,97,109,112,105,110,103,70,97,99,116,111,114,0,109,95,97,100,100,105, -116,105,111,110,97,108,76,105,110,101,97,114,68,97,109,112,105,110,103,84, -104,114,101,115,104,111,108,100,83,113,114,0,109,95,97,100,100,105,116,105, -111,110,97,108,65,110,103,117,108,97,114,68,97,109,112,105,110,103,84,104, -114,101,115,104,111,108,100,83,113,114,0,109,95,97,100,100,105,116,105,111, -110,97,108,65,110,103,117,108,97,114,68,97,109,112,105,110,103,70,97,99, -116,111,114,0,109,95,108,105,110,101,97,114,83,108,101,101,112,105,110,103, -84,104,114,101,115,104,111,108,100,0,109,95,97,110,103,117,108,97,114,83, -108,101,101,112,105,110,103,84,104,114,101,115,104,111,108,100,0,109,95,97, -100,100,105,116,105,111,110,97,108,68,97,109,112,105,110,103,0,109,95,110, -117,109,67,111,110,115,116,114,97,105,110,116,82,111,119,115,0,110,117,98, -0,42,109,95,114,98,65,0,42,109,95,114,98,66,0,109,95,111,98,106, -101,99,116,84,121,112,101,0,109,95,117,115,101,114,67,111,110,115,116,114, -97,105,110,116,84,121,112,101,0,109,95,117,115,101,114,67,111,110,115,116, -114,97,105,110,116,73,100,0,109,95,110,101,101,100,115,70,101,101,100,98, -97,99,107,0,109,95,97,112,112,108,105,101,100,73,109,112,117,108,115,101, -0,109,95,100,98,103,68,114,97,119,83,105,122,101,0,109,95,100,105,115, -97,98,108,101,67,111,108,108,105,115,105,111,110,115,66,101,116,119,101,101, -110,76,105,110,107,101,100,66,111,100,105,101,115,0,109,95,112,97,100,52, -91,52,93,0,109,95,116,121,112,101,67,111,110,115,116,114,97,105,110,116, -68,97,116,97,0,109,95,112,105,118,111,116,73,110,65,0,109,95,112,105, -118,111,116,73,110,66,0,109,95,114,98,65,70,114,97,109,101,0,109,95, -114,98,66,70,114,97,109,101,0,109,95,117,115,101,82,101,102,101,114,101, -110,99,101,70,114,97,109,101,65,0,109,95,97,110,103,117,108,97,114,79, -110,108,121,0,109,95,101,110,97,98,108,101,65,110,103,117,108,97,114,77, -111,116,111,114,0,109,95,109,111,116,111,114,84,97,114,103,101,116,86,101, -108,111,99,105,116,121,0,109,95,109,97,120,77,111,116,111,114,73,109,112, -117,108,115,101,0,109,95,108,111,119,101,114,76,105,109,105,116,0,109,95, -117,112,112,101,114,76,105,109,105,116,0,109,95,108,105,109,105,116,83,111, -102,116,110,101,115,115,0,109,95,98,105,97,115,70,97,99,116,111,114,0, -109,95,114,101,108,97,120,97,116,105,111,110,70,97,99,116,111,114,0,109, -95,115,119,105,110,103,83,112,97,110,49,0,109,95,115,119,105,110,103,83, -112,97,110,50,0,109,95,116,119,105,115,116,83,112,97,110,0,109,95,100, -97,109,112,105,110,103,0,109,95,108,105,110,101,97,114,85,112,112,101,114, -76,105,109,105,116,0,109,95,108,105,110,101,97,114,76,111,119,101,114,76, -105,109,105,116,0,109,95,97,110,103,117,108,97,114,85,112,112,101,114,76, -105,109,105,116,0,109,95,97,110,103,117,108,97,114,76,111,119,101,114,76, -105,109,105,116,0,109,95,117,115,101,76,105,110,101,97,114,82,101,102,101, -114,101,110,99,101,70,114,97,109,101,65,0,109,95,117,115,101,79,102,102, -115,101,116,70,111,114,67,111,110,115,116,114,97,105,110,116,70,114,97,109, -101,0,0,0,84,89,80,69,49,0,0,0,99,104,97,114,0,117,99,104, -97,114,0,115,104,111,114,116,0,117,115,104,111,114,116,0,105,110,116,0, -108,111,110,103,0,117,108,111,110,103,0,102,108,111,97,116,0,100,111,117, -98,108,101,0,118,111,105,100,0,80,111,105,110,116,101,114,65,114,114,97, -121,0,98,116,80,104,121,115,105,99,115,83,121,115,116,101,109,0,76,105, -115,116,66,97,115,101,0,98,116,86,101,99,116,111,114,51,70,108,111,97, -116,68,97,116,97,0,98,116,86,101,99,116,111,114,51,68,111,117,98,108, -101,68,97,116,97,0,98,116,77,97,116,114,105,120,51,120,51,70,108,111, -97,116,68,97,116,97,0,98,116,77,97,116,114,105,120,51,120,51,68,111, -117,98,108,101,68,97,116,97,0,98,116,84,114,97,110,115,102,111,114,109, -70,108,111,97,116,68,97,116,97,0,98,116,84,114,97,110,115,102,111,114, -109,68,111,117,98,108,101,68,97,116,97,0,98,116,67,111,108,108,105,115, -105,111,110,83,104,97,112,101,68,97,116,97,0,98,116,83,116,97,116,105, -99,80,108,97,110,101,83,104,97,112,101,68,97,116,97,0,98,116,67,111, -110,118,101,120,73,110,116,101,114,110,97,108,83,104,97,112,101,68,97,116, -97,0,98,116,80,111,115,105,116,105,111,110,65,110,100,82,97,100,105,117, -115,0,98,116,77,117,108,116,105,83,112,104,101,114,101,83,104,97,112,101, -68,97,116,97,0,98,116,73,110,116,73,110,100,101,120,68,97,116,97,0, -98,116,83,104,111,114,116,73,110,116,73,110,100,101,120,68,97,116,97,0, -98,116,77,101,115,104,80,97,114,116,68,97,116,97,0,98,116,83,116,114, -105,100,105,110,103,77,101,115,104,73,110,116,101,114,102,97,99,101,68,97, -116,97,0,98,116,84,114,105,97,110,103,108,101,77,101,115,104,83,104,97, -112,101,68,97,116,97,0,98,116,67,111,109,112,111,117,110,100,83,104,97, -112,101,67,104,105,108,100,68,97,116,97,0,98,116,67,111,109,112,111,117, -110,100,83,104,97,112,101,68,97,116,97,0,98,116,67,121,108,105,110,100, -101,114,83,104,97,112,101,68,97,116,97,0,98,116,67,97,112,115,117,108, -101,83,104,97,112,101,68,97,116,97,0,98,116,71,73,109,112,97,99,116, -77,101,115,104,83,104,97,112,101,68,97,116,97,0,98,116,67,111,110,118, -101,120,72,117,108,108,83,104,97,112,101,68,97,116,97,0,98,116,67,111, -108,108,105,115,105,111,110,79,98,106,101,99,116,68,111,117,98,108,101,68, -97,116,97,0,98,116,67,111,108,108,105,115,105,111,110,79,98,106,101,99, -116,70,108,111,97,116,68,97,116,97,0,98,116,82,105,103,105,100,66,111, -100,121,70,108,111,97,116,68,97,116,97,0,98,116,82,105,103,105,100,66, -111,100,121,68,111,117,98,108,101,68,97,116,97,0,98,116,67,111,110,115, -116,114,97,105,110,116,73,110,102,111,49,0,98,116,84,121,112,101,100,67, -111,110,115,116,114,97,105,110,116,68,97,116,97,0,98,116,82,105,103,105, -100,66,111,100,121,68,97,116,97,0,98,116,80,111,105,110,116,50,80,111, -105,110,116,67,111,110,115,116,114,97,105,110,116,70,108,111,97,116,68,97, -116,97,0,98,116,80,111,105,110,116,50,80,111,105,110,116,67,111,110,115, -116,114,97,105,110,116,68,111,117,98,108,101,68,97,116,97,0,98,116,72, -105,110,103,101,67,111,110,115,116,114,97,105,110,116,68,111,117,98,108,101, -68,97,116,97,0,98,116,72,105,110,103,101,67,111,110,115,116,114,97,105, -110,116,70,108,111,97,116,68,97,116,97,0,98,116,67,111,110,101,84,119, -105,115,116,67,111,110,115,116,114,97,105,110,116,68,97,116,97,0,98,116, -71,101,110,101,114,105,99,54,68,111,102,67,111,110,115,116,114,97,105,110, -116,68,97,116,97,0,98,116,83,108,105,100,101,114,67,111,110,115,116,114, -97,105,110,116,68,97,116,97,0,0,0,0,84,76,69,78,1,0,1,0, -2,0,2,0,4,0,4,0,4,0,4,0,8,0,0,0,16,0,48,0, -16,0,16,0,32,0,48,0,96,0,64,0,-128,0,16,0,56,0,56,0, -20,0,72,0,4,0,4,0,40,0,32,0,56,0,80,0,32,0,64,0, -64,0,72,0,80,0,-40,1,8,1,-16,1,-88,3,8,0,56,0,0,0, -88,0,120,0,96,1,-32,0,-40,0,0,1,-48,0,0,0,83,84,82,67, -38,0,0,0,10,0,3,0,4,0,0,0,4,0,1,0,9,0,2,0, -11,0,3,0,10,0,3,0,10,0,4,0,10,0,5,0,12,0,2,0, -9,0,6,0,9,0,7,0,13,0,1,0,7,0,8,0,14,0,1,0, -8,0,8,0,15,0,1,0,13,0,9,0,16,0,1,0,14,0,9,0, -17,0,2,0,15,0,10,0,13,0,11,0,18,0,2,0,16,0,10,0, -14,0,11,0,19,0,3,0,0,0,12,0,4,0,13,0,0,0,14,0, -20,0,5,0,19,0,15,0,13,0,16,0,13,0,17,0,7,0,18,0, -0,0,19,0,21,0,5,0,19,0,15,0,13,0,16,0,13,0,20,0, -7,0,21,0,4,0,22,0,22,0,2,0,13,0,23,0,7,0,24,0, -23,0,4,0,21,0,25,0,22,0,26,0,4,0,27,0,0,0,14,0, -24,0,1,0,4,0,28,0,25,0,2,0,2,0,29,0,2,0,28,0, -26,0,6,0,13,0,30,0,14,0,31,0,24,0,32,0,25,0,33,0, -4,0,34,0,4,0,35,0,27,0,4,0,26,0,36,0,13,0,37,0, -4,0,38,0,0,0,14,0,28,0,4,0,19,0,15,0,27,0,39,0, -7,0,21,0,0,0,14,0,29,0,4,0,17,0,40,0,19,0,41,0, -4,0,42,0,7,0,43,0,30,0,4,0,19,0,15,0,29,0,44,0, -4,0,45,0,7,0,21,0,31,0,3,0,21,0,25,0,4,0,46,0, -0,0,14,0,32,0,3,0,21,0,25,0,4,0,46,0,0,0,14,0, -33,0,5,0,19,0,15,0,27,0,39,0,13,0,16,0,7,0,21,0, -4,0,47,0,34,0,5,0,21,0,25,0,13,0,48,0,14,0,49,0, -4,0,50,0,0,0,51,0,35,0,24,0,9,0,52,0,9,0,53,0, -19,0,54,0,0,0,12,0,18,0,55,0,18,0,56,0,14,0,57,0, -14,0,58,0,14,0,59,0,8,0,60,0,8,0,61,0,8,0,62,0, -8,0,63,0,8,0,64,0,8,0,65,0,8,0,66,0,4,0,67,0, -4,0,68,0,4,0,69,0,4,0,70,0,4,0,71,0,4,0,72,0, -4,0,73,0,0,0,14,0,36,0,23,0,9,0,52,0,9,0,53,0, -19,0,54,0,0,0,12,0,17,0,55,0,17,0,56,0,13,0,57,0, -13,0,58,0,13,0,59,0,7,0,60,0,7,0,61,0,7,0,62,0, -7,0,63,0,7,0,64,0,7,0,65,0,7,0,66,0,4,0,67,0, -4,0,68,0,4,0,69,0,4,0,70,0,4,0,71,0,4,0,72,0, -4,0,73,0,37,0,21,0,36,0,74,0,15,0,75,0,13,0,76,0, -13,0,77,0,13,0,78,0,13,0,79,0,13,0,80,0,13,0,81,0, -13,0,82,0,13,0,83,0,13,0,84,0,7,0,85,0,7,0,86,0, -7,0,87,0,7,0,88,0,7,0,89,0,7,0,90,0,7,0,91,0, -7,0,92,0,7,0,93,0,4,0,94,0,38,0,22,0,35,0,74,0, -16,0,75,0,14,0,76,0,14,0,77,0,14,0,78,0,14,0,79,0, -14,0,80,0,14,0,81,0,14,0,82,0,14,0,83,0,14,0,84,0, -8,0,85,0,8,0,86,0,8,0,87,0,8,0,88,0,8,0,89,0, -8,0,90,0,8,0,91,0,8,0,92,0,8,0,93,0,4,0,94,0, -0,0,14,0,39,0,2,0,4,0,95,0,4,0,96,0,40,0,11,0, -41,0,97,0,41,0,98,0,0,0,12,0,4,0,99,0,4,0,100,0, -4,0,101,0,4,0,102,0,7,0,103,0,7,0,104,0,4,0,105,0, -0,0,106,0,42,0,3,0,40,0,107,0,13,0,108,0,13,0,109,0, -43,0,3,0,40,0,107,0,14,0,108,0,14,0,109,0,44,0,13,0, -40,0,107,0,18,0,110,0,18,0,111,0,4,0,112,0,4,0,113,0, -4,0,114,0,7,0,115,0,7,0,116,0,7,0,117,0,7,0,118,0, -7,0,119,0,7,0,120,0,7,0,121,0,45,0,13,0,40,0,107,0, -17,0,110,0,17,0,111,0,4,0,112,0,4,0,113,0,4,0,114,0, -7,0,115,0,7,0,116,0,7,0,117,0,7,0,118,0,7,0,119,0, -7,0,120,0,7,0,121,0,46,0,11,0,40,0,107,0,17,0,110,0, -17,0,111,0,7,0,122,0,7,0,123,0,7,0,124,0,7,0,119,0, -7,0,120,0,7,0,121,0,7,0,125,0,0,0,19,0,47,0,9,0, -40,0,107,0,17,0,110,0,17,0,111,0,13,0,126,0,13,0,127,0, -13,0,-128,0,13,0,-127,0,4,0,-126,0,4,0,-125,0,48,0,9,0, -40,0,107,0,17,0,110,0,17,0,111,0,7,0,126,0,7,0,127,0, -7,0,-128,0,7,0,-127,0,4,0,-126,0,4,0,-125,0,}; -int sBulletDNAlen64= sizeof(sBulletDNAstr64); - unsigned char sBulletDNAstr[]= { 83,68,78,65,78,65,77,69,-124,0,0,0,109,95,115,105,122,101,0,109, 95,99,97,112,97,99,105,116,121,0,42,109,95,100,97,116,97,0,109,95,