From d25d264e770c9ae03196009edfdfadccb47cd889 Mon Sep 17 00:00:00 2001 From: "erwin.coumans" Date: Wed, 5 Nov 2008 03:28:10 +0000 Subject: [PATCH] Improved CharacterDemo/KinematicCharacterController, dynamic objects will bounce off. Don't create a todo list for doxygen by default (the chaotic todo's would confuse most developers) Improve support for small objects, by having dynamic contact breaking thresholds. Still needs small internal timestep and some GJK improvements. --- Demos/CharacterDemo/CharacterDemo.cpp | 4 +- .../KinematicCharacterController.cpp | 14 +++--- Demos/ConcaveDemo/ConcavePhysicsDemo.cpp | 2 +- .../ConvexDecompositionDemo.cpp | 2 +- .../EPAPenDepthDemo/PenetrationTestBullet.cpp | 2 +- Demos/ForkLiftDemo/ForkLiftDemo.cpp | 10 ++-- Doxyfile | 2 +- .../ColladaConverter.cpp | 9 ++-- Extras/ConvexDecomposition/cd_hull.cpp | 50 +++++++++---------- .../BroadphaseCollision/btBroadphaseProxy.h | 1 + .../SphereTriangleDetector.cpp | 14 +++--- .../SphereTriangleDetector.h | 6 +-- .../btCollisionDispatcher.cpp | 4 +- .../CollisionDispatch/btCollisionObject.h | 3 +- .../btSphereTriangleCollisionAlgorithm.cpp | 2 +- .../CollisionShapes/btCollisionShape.cpp | 6 +++ .../CollisionShapes/btCollisionShape.h | 2 + .../Gimpact/btGImpactCollisionAlgorithm.h | 2 +- .../btPersistentManifold.cpp | 8 +-- .../btPersistentManifold.h | 11 ++-- 20 files changed, 81 insertions(+), 73 deletions(-) diff --git a/Demos/CharacterDemo/CharacterDemo.cpp b/Demos/CharacterDemo/CharacterDemo.cpp index 5b4cd6fe8..8b32ffdd8 100644 --- a/Demos/CharacterDemo/CharacterDemo.cpp +++ b/Demos/CharacterDemo/CharacterDemo.cpp @@ -92,7 +92,7 @@ void CharacterDemo::initPhysics() btScalar characterWidth =1.75; btConvexShape* capsule = new btCapsuleShape(characterWidth,characterHeight); m_ghostObject->setCollisionShape (capsule); - m_ghostObject->setCollisionFlags (btCollisionObject::CF_NO_CONTACT_RESPONSE); + m_ghostObject->setCollisionFlags (btCollisionObject::CF_CHARACTER_OBJECT); btScalar stepHeight = btScalar(0.35); m_character = new KinematicCharacterController (m_ghostObject,capsule,stepHeight); @@ -103,7 +103,7 @@ void CharacterDemo::initPhysics() ///only collide with static for now (no interaction with dynamic objects) - m_dynamicsWorld->addCollisionObject(m_ghostObject,btBroadphaseProxy::DebrisFilter, btBroadphaseProxy::StaticFilter); + m_dynamicsWorld->addCollisionObject(m_ghostObject,btBroadphaseProxy::CharacterFilter, btBroadphaseProxy::StaticFilter|btBroadphaseProxy::DefaultFilter); //////////////// diff --git a/Demos/CharacterDemo/KinematicCharacterController.cpp b/Demos/CharacterDemo/KinematicCharacterController.cpp index 04b58dfce..51ef378df 100644 --- a/Demos/CharacterDemo/KinematicCharacterController.cpp +++ b/Demos/CharacterDemo/KinematicCharacterController.cpp @@ -8,14 +8,12 @@ #include "LinearMath/btDefaultMotionState.h" #include "KinematicCharacterController.h" -/* TODO: - * Interact with dynamic objects - * Ride kinematicly animated platforms properly - * More realistic (or maybe just a config option) falling - * -> Should integrate falling velocity manually and use that in stepDown() - * Support jumping - * Support ducking - */ +///@todo Interact with dynamic objects, +///Ride kinematicly animated platforms properly +///More realistic (or maybe just a config option) falling +/// -> Should integrate falling velocity manually and use that in stepDown() +///Support jumping +///Support ducking class ClosestNotMeRayResultCallback : public btCollisionWorld::ClosestRayResultCallback { public: diff --git a/Demos/ConcaveDemo/ConcavePhysicsDemo.cpp b/Demos/ConcaveDemo/ConcavePhysicsDemo.cpp index 47e1085e8..90aeccfc0 100644 --- a/Demos/ConcaveDemo/ConcavePhysicsDemo.cpp +++ b/Demos/ConcaveDemo/ConcavePhysicsDemo.cpp @@ -259,7 +259,7 @@ void ConcaveDemo::initPhysics() createCollisionLocalStoreMemory, maxNumOutstandingTasks)); #else -///todo other platform threading +///@todo show other platform threading ///Playstation 3 SPU (SPURS) version is available through PS3 Devnet ///Libspe2 SPU support will be available soon ///pthreads version diff --git a/Demos/ConvexDecompositionDemo/ConvexDecompositionDemo.cpp b/Demos/ConvexDecompositionDemo/ConvexDecompositionDemo.cpp index 45af10540..18474b22d 100644 --- a/Demos/ConvexDecompositionDemo/ConvexDecompositionDemo.cpp +++ b/Demos/ConvexDecompositionDemo/ConvexDecompositionDemo.cpp @@ -86,7 +86,7 @@ void ConvexDecompositionDemo::initPhysics(const char* filename) createCollisionLocalStoreMemory, maxNumOutstandingTasks)); #else -///todo other platform threading +///@todo other platform threading ///Playstation 3 SPU (SPURS) version is available through PS3 Devnet ///Libspe2 SPU support will be available soon ///pthreads version diff --git a/Demos/EPAPenDepthDemo/PenetrationTestBullet.cpp b/Demos/EPAPenDepthDemo/PenetrationTestBullet.cpp index 8a0641e9f..2f1003cb7 100644 --- a/Demos/EPAPenDepthDemo/PenetrationTestBullet.cpp +++ b/Demos/EPAPenDepthDemo/PenetrationTestBullet.cpp @@ -44,7 +44,7 @@ #define USE_ORIGINAL 1 #ifndef USE_ORIGINAL -#include "BulletCollision/NarrowPhaseCollision/btGjkEpa.h" +#include "BulletCollision/NarrowPhaseCollision/btGjkEpa2.h" #endif //USE_ORIGINAL static bool gRefMode = false; diff --git a/Demos/ForkLiftDemo/ForkLiftDemo.cpp b/Demos/ForkLiftDemo/ForkLiftDemo.cpp index 96c234c62..b8ffa456b 100644 --- a/Demos/ForkLiftDemo/ForkLiftDemo.cpp +++ b/Demos/ForkLiftDemo/ForkLiftDemo.cpp @@ -13,11 +13,11 @@ subject to the following restrictions: 3. This notice may not be removed or altered from any source distribution. */ -/// September 2006: VehicleDemo is work in progress, this file is mostly just a placeholder -/// This VehicleDemo file is very early in development, please check it later -/// One todo is a basic engine model: -/// A function that maps user input (throttle) into torque/force applied on the wheels -/// with gears etc. +///September 2006: VehicleDemo is work in progress, this file is mostly just a placeholder +///This VehicleDemo file is very early in development, please check it later +///@todo is a basic engine model: +///A function that maps user input (throttle) into torque/force applied on the wheels +///with gears etc. #include "btBulletDynamicsCommon.h" #include "BulletCollision/CollisionShapes/btHeightfieldTerrainShape.h" diff --git a/Doxyfile b/Doxyfile index 39f5fd499..2f9a6b27e 100644 --- a/Doxyfile +++ b/Doxyfile @@ -207,7 +207,7 @@ ENABLED_SECTIONS = # disable (NO) the todo list. This list is created by putting \todo # commands in the documentation. -GENERATE_TODOLIST = YES +GENERATE_TODOLIST = NO # The GENERATE_TESTLIST tag can be used to enable (YES) or # disable (NO) the test list. This list is created by putting \test diff --git a/Extras/BulletColladaConverter/ColladaConverter.cpp b/Extras/BulletColladaConverter/ColladaConverter.cpp index 4e214d554..74927ff7c 100644 --- a/Extras/BulletColladaConverter/ColladaConverter.cpp +++ b/Extras/BulletColladaConverter/ColladaConverter.cpp @@ -13,11 +13,8 @@ subject to the following restrictions: 3. This notice may not be removed or altered from any source distribution. */ -/* Some TODO items: - * fix naming conflicts with BulletUnnamed-* across executions -> need to generate a real unique name. - * double check geometry sharing - */ - +///@todo fix naming conflicts with BulletUnnamed-* across executions -> need to generate a real unique name. +///@todo double check geometry sharing #include "ColladaConverter.h" #include "btBulletDynamicsCommon.h" @@ -430,7 +427,7 @@ bool ColladaConverter::convert() domPhysics_modelRef model = *(domPhysics_modelRef*)&ref; - //todo: group some shared functionality in following 2 'blocks'. + ///@todo: group some shared functionality in following 2 'blocks'. for (r=0;rgetInstance_rigid_body_array().getCount();r++) { domInstance_rigid_bodyRef instRigidbodyRef = instancePhysicsModelRef->getInstance_rigid_body_array()[r]; diff --git a/Extras/ConvexDecomposition/cd_hull.cpp b/Extras/ConvexDecomposition/cd_hull.cpp index e2edbe355..38d1f74b4 100644 --- a/Extras/ConvexDecomposition/cd_hull.cpp +++ b/Extras/ConvexDecomposition/cd_hull.cpp @@ -2308,25 +2308,25 @@ int shareedge(const int3 &a,const int3 &b) return 0; } -class Tri; +class btHullTriangle; -Array tris; +Array tris; -class Tri : public int3 +class btHullTriangle : public int3 { public: int3 n; int id; int vmax; float rise; - Tri(int a,int b,int c):int3(a,b,c),n(-1,-1,-1) + btHullTriangle(int a,int b,int c):int3(a,b,c),n(-1,-1,-1) { id = tris.count; tris.Add(this); vmax=-1; rise = 0.0f; } - ~Tri() + ~btHullTriangle() { assert(tris[id]==this); tris[id]=NULL; @@ -2335,7 +2335,7 @@ public: }; -int &Tri::neib(int a,int b) +int &btHullTriangle::neib(int a,int b) { static int er=-1; int i; @@ -2349,7 +2349,7 @@ int &Tri::neib(int a,int b) assert(0); return er; } -void b2bfix(Tri* s,Tri*t) +void b2bfix(btHullTriangle* s,btHullTriangle*t) { int i; for(i=0;i<3;i++) @@ -2365,14 +2365,14 @@ void b2bfix(Tri* s,Tri*t) } } -void removeb2b(Tri* s,Tri*t) +void removeb2b(btHullTriangle* s,btHullTriangle*t) { b2bfix(s,t); delete s; delete t; } -void checkit(Tri *t) +void checkit(btHullTriangle *t) { int i; assert(tris[t->id]==t); @@ -2386,17 +2386,17 @@ void checkit(Tri *t) assert( tris[t->n[i]]->neib(b,a) == t->id); } } -void extrude(Tri *t0,int v) +void extrude(btHullTriangle *t0,int v) { int3 t= *t0; int n = tris.count; - Tri* ta = new Tri(v,t[1],t[2]); + btHullTriangle* ta = new btHullTriangle(v,t[1],t[2]); ta->n = int3(t0->n[0],n+1,n+2); tris[t0->n[0]]->neib(t[1],t[2]) = n+0; - Tri* tb = new Tri(v,t[2],t[0]); + btHullTriangle* tb = new btHullTriangle(v,t[2],t[0]); tb->n = int3(t0->n[1],n+2,n+0); tris[t0->n[1]]->neib(t[2],t[0]) = n+1; - Tri* tc = new Tri(v,t[0],t[1]); + btHullTriangle* tc = new btHullTriangle(v,t[0],t[1]); tc->n = int3(t0->n[2],n+0,n+1); tris[t0->n[2]]->neib(t[0],t[1]) = n+2; checkit(ta); @@ -2409,10 +2409,10 @@ void extrude(Tri *t0,int v) } -Tri *extrudable(float epsilon) +btHullTriangle *extrudable(float epsilon) { int i; - Tri *t=NULL; + btHullTriangle *t=NULL; for(i=0;iriserise)) @@ -2489,23 +2489,23 @@ int calchullgen(float3 *verts,int verts_count, int vlimit) float3 center = (verts[p[0]]+verts[p[1]]+verts[p[2]]+verts[p[3]]) /4.0f; // a valid interior point - Tri *t0 = new Tri(p[2],p[3],p[1]); t0->n=int3(2,3,1); - Tri *t1 = new Tri(p[3],p[2],p[0]); t1->n=int3(3,2,0); - Tri *t2 = new Tri(p[0],p[1],p[3]); t2->n=int3(0,1,3); - Tri *t3 = new Tri(p[1],p[0],p[2]); t3->n=int3(1,0,2); + btHullTriangle *t0 = new btHullTriangle(p[2],p[3],p[1]); t0->n=int3(2,3,1); + btHullTriangle *t1 = new btHullTriangle(p[3],p[2],p[0]); t1->n=int3(3,2,0); + btHullTriangle *t2 = new btHullTriangle(p[0],p[1],p[3]); t2->n=int3(0,1,3); + btHullTriangle *t3 = new btHullTriangle(p[1],p[0],p[2]); t3->n=int3(1,0,2); isextreme[p[0]]=isextreme[p[1]]=isextreme[p[2]]=isextreme[p[3]]=1; checkit(t0);checkit(t1);checkit(t2);checkit(t3); for(j=0;jvmax<0); float3 n=TriNormal(verts[(*t)[0]],verts[(*t)[1]],verts[(*t)[2]]); t->vmax = maxdirsterid(verts,verts_count,n,allow); t->rise = dot(n,verts[t->vmax]-verts[(*t)[0]]); } - Tri *te; + btHullTriangle *te; vlimit-=4; while(vlimit >0 && (te=extrudable(epsilon))) { @@ -2532,7 +2532,7 @@ int calchullgen(float3 *verts,int verts_count, int vlimit) int3 nt=*tris[j]; if(above(verts,nt,center,0.01f*epsilon) || magnitude(cross(verts[nt[1]]-verts[nt[0]],verts[nt[2]]-verts[nt[1]]))< epsilon*epsilon*0.1f ) { - Tri *nb = tris[tris[j]->n[0]]; + btHullTriangle *nb = tris[tris[j]->n[0]]; assert(nb);assert(!hasvert(*nb,v));assert(nb->idvmax>=0) break; float3 n=TriNormal(verts[(*t)[0]],verts[(*t)[1]],verts[(*t)[2]]); @@ -2586,14 +2586,14 @@ int calchullpbev(float3 *verts,int verts_count,int vlimit, Array &planes, for(i=0;in[j]id) continue; - Tri *s = tris[t->n[j]]; + btHullTriangle *s = tris[t->n[j]]; REAL3 snormal = TriNormal(verts[(*s)[0]],verts[(*s)[1]],verts[(*s)[2]]); if(dot(snormal,p.normal)>=cos(bevangle*DEG2RAD)) continue; REAL3 n = normalize(snormal+p.normal); diff --git a/src/BulletCollision/BroadphaseCollision/btBroadphaseProxy.h b/src/BulletCollision/BroadphaseCollision/btBroadphaseProxy.h index ccc945894..8b7a59a22 100644 --- a/src/BulletCollision/BroadphaseCollision/btBroadphaseProxy.h +++ b/src/BulletCollision/BroadphaseCollision/btBroadphaseProxy.h @@ -92,6 +92,7 @@ BT_DECLARE_ALIGNED_ALLOCATOR(); KinematicFilter = 4, DebrisFilter = 8, SensorTrigger = 16, + CharacterFilter = 32, AllFilter = -1 //all bits sets: DefaultFilter | StaticFilter | KinematicFilter | DebrisFilter | SensorTrigger }; diff --git a/src/BulletCollision/CollisionDispatch/SphereTriangleDetector.cpp b/src/BulletCollision/CollisionDispatch/SphereTriangleDetector.cpp index 29facc857..ae6fe2019 100644 --- a/src/BulletCollision/CollisionDispatch/SphereTriangleDetector.cpp +++ b/src/BulletCollision/CollisionDispatch/SphereTriangleDetector.cpp @@ -19,9 +19,10 @@ subject to the following restrictions: #include "BulletCollision/CollisionShapes/btSphereShape.h" -SphereTriangleDetector::SphereTriangleDetector(btSphereShape* sphere,btTriangleShape* triangle) +SphereTriangleDetector::SphereTriangleDetector(btSphereShape* sphere,btTriangleShape* triangle,btScalar contactBreakingThreshold) :m_sphere(sphere), -m_triangle(triangle) +m_triangle(triangle), +m_contactBreakingThreshold(contactBreakingThreshold) { } @@ -40,7 +41,7 @@ void SphereTriangleDetector::getClosestPoints(const ClosestPointInput& input,Res //move sphere into triangle space btTransform sphereInTr = transformB.inverseTimes(transformA); - if (collide(sphereInTr.getOrigin(),point,normal,depth,timeOfImpact)) + if (collide(sphereInTr.getOrigin(),point,normal,depth,timeOfImpact,m_contactBreakingThreshold)) { if (swapResults) { @@ -93,7 +94,7 @@ bool SphereTriangleDetector::facecontains(const btVector3 &p,const btVector3* ve } ///combined discrete/continuous sphere-triangle -bool SphereTriangleDetector::collide(const btVector3& sphereCenter,btVector3 &point, btVector3& resultNormal, btScalar& depth, btScalar &timeOfImpact) +bool SphereTriangleDetector::collide(const btVector3& sphereCenter,btVector3 &point, btVector3& resultNormal, btScalar& depth, btScalar &timeOfImpact, btScalar contactBreakingThreshold) { const btVector3* vertices = &m_triangle->getVertexPtr(0); @@ -115,10 +116,7 @@ bool SphereTriangleDetector::collide(const btVector3& sphereCenter,btVector3 &po normal *= btScalar(-1.); } - ///@todo: move this gContactBreakingThreshold into a proper structure - extern btScalar gContactBreakingThreshold; - - btScalar contactMargin = gContactBreakingThreshold; + btScalar contactMargin = contactBreakingThreshold; bool isInsideContactPlane = distanceFromPlane < r + contactMargin; bool isInsideShellPlane = distanceFromPlane < r; diff --git a/src/BulletCollision/CollisionDispatch/SphereTriangleDetector.h b/src/BulletCollision/CollisionDispatch/SphereTriangleDetector.h index 5382806bc..981bd54e7 100644 --- a/src/BulletCollision/CollisionDispatch/SphereTriangleDetector.h +++ b/src/BulletCollision/CollisionDispatch/SphereTriangleDetector.h @@ -30,19 +30,19 @@ struct SphereTriangleDetector : public btDiscreteCollisionDetectorInterface { virtual void getClosestPoints(const ClosestPointInput& input,Result& output,class btIDebugDraw* debugDraw,bool swapResults=false); - SphereTriangleDetector(btSphereShape* sphere,btTriangleShape* triangle); + SphereTriangleDetector(btSphereShape* sphere,btTriangleShape* triangle, btScalar contactBreakingThreshold); virtual ~SphereTriangleDetector() {}; private: - bool collide(const btVector3& sphereCenter,btVector3 &point, btVector3& resultNormal, btScalar& depth, btScalar &timeOfImpact); + bool collide(const btVector3& sphereCenter,btVector3 &point, btVector3& resultNormal, btScalar& depth, btScalar &timeOfImpact, btScalar contactBreakingThreshold); bool pointInTriangle(const btVector3 vertices[], const btVector3 &normal, btVector3 *p ); bool facecontains(const btVector3 &p,const btVector3* vertices,btVector3& normal); btSphereShape* m_sphere; btTriangleShape* m_triangle; - + btScalar m_contactBreakingThreshold; }; #endif //SPHERE_TRIANGLE_DETECTOR_H diff --git a/src/BulletCollision/CollisionDispatch/btCollisionDispatcher.cpp b/src/BulletCollision/CollisionDispatch/btCollisionDispatcher.cpp index bdff19c25..44aa00aff 100644 --- a/src/BulletCollision/CollisionDispatch/btCollisionDispatcher.cpp +++ b/src/BulletCollision/CollisionDispatch/btCollisionDispatcher.cpp @@ -78,6 +78,8 @@ btPersistentManifold* btCollisionDispatcher::getNewManifold(void* b0,void* b1) btCollisionObject* body0 = (btCollisionObject*)b0; btCollisionObject* body1 = (btCollisionObject*)b1; + + btScalar contactBreakingThreshold = btMin(gContactBreakingThreshold,btMin(body0->getCollisionShape()->getContactBreakingThreshold(),body1->getCollisionShape()->getContactBreakingThreshold())); void* mem = 0; @@ -89,7 +91,7 @@ btPersistentManifold* btCollisionDispatcher::getNewManifold(void* b0,void* b1) mem = btAlignedAlloc(sizeof(btPersistentManifold),16); } - btPersistentManifold* manifold = new(mem) btPersistentManifold (body0,body1,0); + btPersistentManifold* manifold = new(mem) btPersistentManifold (body0,body1,0,contactBreakingThreshold); manifold->m_index1a = m_manifoldsPtr.size(); m_manifoldsPtr.push_back(manifold); diff --git a/src/BulletCollision/CollisionDispatch/btCollisionObject.h b/src/BulletCollision/CollisionDispatch/btCollisionObject.h index a95728ff6..971a9c986 100644 --- a/src/BulletCollision/CollisionDispatch/btCollisionObject.h +++ b/src/BulletCollision/CollisionDispatch/btCollisionObject.h @@ -106,7 +106,8 @@ public: CF_STATIC_OBJECT= 1, CF_KINEMATIC_OBJECT= 2, CF_NO_CONTACT_RESPONSE = 4, - CF_CUSTOM_MATERIAL_CALLBACK = 8//this allows per-triangle material (friction/restitution) + CF_CUSTOM_MATERIAL_CALLBACK = 8,//this allows per-triangle material (friction/restitution) + CF_CHARACTER_OBJECT = 16 }; enum CollisionObjectTypes diff --git a/src/BulletCollision/CollisionDispatch/btSphereTriangleCollisionAlgorithm.cpp b/src/BulletCollision/CollisionDispatch/btSphereTriangleCollisionAlgorithm.cpp index 491731f9d..8a5d5825f 100644 --- a/src/BulletCollision/CollisionDispatch/btSphereTriangleCollisionAlgorithm.cpp +++ b/src/BulletCollision/CollisionDispatch/btSphereTriangleCollisionAlgorithm.cpp @@ -56,7 +56,7 @@ void btSphereTriangleCollisionAlgorithm::processCollision (btCollisionObject* co /// report a contact. internally this will be kept persistent, and contact reduction is done resultOut->setPersistentManifold(m_manifoldPtr); - SphereTriangleDetector detector(sphere,triangle); + SphereTriangleDetector detector(sphere,triangle, m_manifoldPtr->getContactBreakingThreshold()); btDiscreteCollisionDetectorInterface::ClosestPointInput input; input.m_maximumDistanceSquared = btScalar(1e30);///@todo: tighter bounds diff --git a/src/BulletCollision/CollisionShapes/btCollisionShape.cpp b/src/BulletCollision/CollisionShapes/btCollisionShape.cpp index 21101eb17..834631937 100644 --- a/src/BulletCollision/CollisionShapes/btCollisionShape.cpp +++ b/src/BulletCollision/CollisionShapes/btCollisionShape.cpp @@ -42,8 +42,14 @@ void btCollisionShape::getBoundingSphere(btVector3& center,btScalar& radius) con center = (aabbMin+aabbMax)*btScalar(0.5); } +btScalar btCollisionShape::getContactBreakingThreshold() const +{ + ///@todo make this 0.1 configurable + return getAngularMotionDisc() * btScalar(0.1); +} btScalar btCollisionShape::getAngularMotionDisc() const { + ///@todo cache this value, to improve performance btVector3 center; btScalar disc; getBoundingSphere(center,disc); diff --git a/src/BulletCollision/CollisionShapes/btCollisionShape.h b/src/BulletCollision/CollisionShapes/btCollisionShape.h index b2b3463d9..1f4b9bec6 100644 --- a/src/BulletCollision/CollisionShapes/btCollisionShape.h +++ b/src/BulletCollision/CollisionShapes/btCollisionShape.h @@ -46,6 +46,8 @@ public: ///getAngularMotionDisc returns the maximus radius needed for Conservative Advancement to handle time-of-impact with rotations. virtual btScalar getAngularMotionDisc() const; + virtual btScalar getContactBreakingThreshold() const; + ///calculateTemporalAabb calculates the enclosing aabb for the moving object over interval [0..timeStep) ///result is conservative diff --git a/src/BulletCollision/Gimpact/btGImpactCollisionAlgorithm.h b/src/BulletCollision/Gimpact/btGImpactCollisionAlgorithm.h index c745b7ed5..d98700385 100644 --- a/src/BulletCollision/Gimpact/btGImpactCollisionAlgorithm.h +++ b/src/BulletCollision/Gimpact/btGImpactCollisionAlgorithm.h @@ -67,7 +67,7 @@ protected: //! Creates a new contact point SIMD_FORCE_INLINE btPersistentManifold* newContactManifold(btCollisionObject* body0,btCollisionObject* body1) { - m_manifoldPtr = m_dispatcher->getNewManifold(body0,body1); + m_manifoldPtr = m_dispatcher->getNewManifold(body0,body1); return m_manifoldPtr; } diff --git a/src/BulletCollision/NarrowPhaseCollision/btPersistentManifold.cpp b/src/BulletCollision/NarrowPhaseCollision/btPersistentManifold.cpp index 386885d2a..ece22c6a3 100644 --- a/src/BulletCollision/NarrowPhaseCollision/btPersistentManifold.cpp +++ b/src/BulletCollision/NarrowPhaseCollision/btPersistentManifold.cpp @@ -16,7 +16,7 @@ subject to the following restrictions: #include "btPersistentManifold.h" #include "LinearMath/btTransform.h" -#include + btScalar gContactBreakingThreshold = btScalar(0.02); ContactDestroyedCallback gContactDestroyedCallback = 0; @@ -66,7 +66,7 @@ void btPersistentManifold::clearUserCache(btManifoldPoint& pt) printf("error in clearUserCache\n"); } } - assert(occurance<=0); + btAssert(occurance<=0); #endif //DEBUG_PERSISTENCY if (pt.m_userPersistentData && gContactDestroyedCallback) @@ -164,7 +164,7 @@ int btPersistentManifold::getCacheEntry(const btManifoldPoint& newPoint) const int btPersistentManifold::addManifoldPoint(const btManifoldPoint& newPoint) { - assert(validContactDistance(newPoint)); + btAssert(validContactDistance(newPoint)); int insertIndex = getNumContacts(); if (insertIndex == MANIFOLD_CACHE_SIZE) @@ -190,7 +190,7 @@ int btPersistentManifold::addManifoldPoint(const btManifoldPoint& newPoint) btScalar btPersistentManifold::getContactBreakingThreshold() const { - return gContactBreakingThreshold; + return m_contactBreakingThreshold; } diff --git a/src/BulletCollision/NarrowPhaseCollision/btPersistentManifold.h b/src/BulletCollision/NarrowPhaseCollision/btPersistentManifold.h index 8b5886ebc..1bed564e5 100644 --- a/src/BulletCollision/NarrowPhaseCollision/btPersistentManifold.h +++ b/src/BulletCollision/NarrowPhaseCollision/btPersistentManifold.h @@ -24,7 +24,7 @@ subject to the following restrictions: struct btCollisionResult; -///contact breaking and merging threshold +///maximum contact breaking and merging threshold extern btScalar gContactBreakingThreshold; typedef bool (*ContactDestroyedCallback)(void* userPersistentData); @@ -52,6 +52,8 @@ ATTRIBUTE_ALIGNED16( class) btPersistentManifold /// void* will allow any rigidbody class void* m_body0; void* m_body1; + btScalar m_contactBreakingThreshold; + int m_cachedPoints; @@ -68,10 +70,11 @@ public: btPersistentManifold(); - btPersistentManifold(void* body0,void* body1,int bla) - : m_body0(body0),m_body1(body1),m_cachedPoints(0) + btPersistentManifold(void* body0,void* body1,int bla, btScalar contactBreakingThreshold) + : m_body0(body0),m_body1(body1),m_cachedPoints(0), + m_contactBreakingThreshold(contactBreakingThreshold) { - (void)bla; + } SIMD_FORCE_INLINE void* getBody0() { return m_body0;}