From 4546fb9e770cda94f9dcddc715ecd0e41bab983c Mon Sep 17 00:00:00 2001 From: enn0x Date: Mon, 27 Feb 2012 22:46:42 +0000 Subject: [PATCH] (Perhaps) fixing BulletContact crashes on Linux --- dtool/src/parser-inc/btBulletDynamicsCommon.h | 2 ++ panda/src/bullet/bulletContactResult.I | 2 +- panda/src/bullet/bulletContactResult.cxx | 3 +-- panda/src/bullet/bulletContactResult.h | 4 ++-- panda/src/bullet/bulletManifoldPoint.cxx | 4 ++-- panda/src/bullet/bulletManifoldPoint.h | 6 ++--- panda/src/bullet/bulletWorld.cxx | 23 +++++++++++++++++++ 7 files changed, 34 insertions(+), 10 deletions(-) diff --git a/dtool/src/parser-inc/btBulletDynamicsCommon.h b/dtool/src/parser-inc/btBulletDynamicsCommon.h index e5553b70e5..4303a2777c 100644 --- a/dtool/src/parser-inc/btBulletDynamicsCommon.h +++ b/dtool/src/parser-inc/btBulletDynamicsCommon.h @@ -76,6 +76,8 @@ class btTypedObject; class btVector3; class btVehicleRaycaster; +template class btAlignedObjectArray; + class btWheelInfo { public: class RaycastInfo; diff --git a/panda/src/bullet/bulletContactResult.I b/panda/src/bullet/bulletContactResult.I index dafcfcfdaf..aeac0f6371 100644 --- a/panda/src/bullet/bulletContactResult.I +++ b/panda/src/bullet/bulletContactResult.I @@ -43,7 +43,7 @@ get_node1() const { INLINE const BulletManifoldPoint *BulletContact:: get_manifold_point() const { - return new BulletManifoldPoint(*_mp); + return new BulletManifoldPoint(_mp); } //////////////////////////////////////////////////////////////////// diff --git a/panda/src/bullet/bulletContactResult.cxx b/panda/src/bullet/bulletContactResult.cxx index 84aaf8c858..2acf987d7a 100644 --- a/panda/src/bullet/bulletContactResult.cxx +++ b/panda/src/bullet/bulletContactResult.cxx @@ -36,10 +36,9 @@ addSingleResult(btManifoldPoint &mp, const btCollisionObject *obj0, int part_id0, int idx0, const btCollisionObject *obj1, int part_id1, int idx1) { - BulletContact contact; - contact._mp = ∓ + contact._mp = mp; contact._obj0 = obj0; contact._obj1 = obj1; contact._part_id0 = part_id0; diff --git a/panda/src/bullet/bulletContactResult.h b/panda/src/bullet/bulletContactResult.h index b1bba45fb8..f881467e3f 100644 --- a/panda/src/bullet/bulletContactResult.h +++ b/panda/src/bullet/bulletContactResult.h @@ -38,7 +38,7 @@ PUBLISHED: INLINE const int get_part_id1() const; private: - btManifoldPoint *_mp; + btManifoldPoint _mp; const btCollisionObject *_obj0; const btCollisionObject *_obj1; int _part_id0; @@ -71,7 +71,7 @@ protected: private: static BulletContact _empty; - pvector _contacts; + btAlignedObjectArray _contacts; friend class BulletWorld; }; diff --git a/panda/src/bullet/bulletManifoldPoint.cxx b/panda/src/bullet/bulletManifoldPoint.cxx index 9567fabb1d..9985f89b0a 100644 --- a/panda/src/bullet/bulletManifoldPoint.cxx +++ b/panda/src/bullet/bulletManifoldPoint.cxx @@ -20,7 +20,7 @@ // Description: //////////////////////////////////////////////////////////////////// BulletManifoldPoint:: -BulletManifoldPoint(btManifoldPoint &pt) : _pt(pt) { +BulletManifoldPoint(const btManifoldPoint &pt) : _pt(pt) { } @@ -30,7 +30,7 @@ BulletManifoldPoint(btManifoldPoint &pt) : _pt(pt) { // Description: //////////////////////////////////////////////////////////////////// int BulletManifoldPoint:: -get_lift_time() const { +get_life_time() const { return _pt.getLifeTime(); } diff --git a/panda/src/bullet/bulletManifoldPoint.h b/panda/src/bullet/bulletManifoldPoint.h index 0b7319b85b..d1116346f1 100644 --- a/panda/src/bullet/bulletManifoldPoint.h +++ b/panda/src/bullet/bulletManifoldPoint.h @@ -31,7 +31,7 @@ class EXPCL_PANDABULLET BulletManifoldPoint { PUBLISHED: INLINE ~BulletManifoldPoint(); - int get_lift_time() const; + int get_life_time() const; PN_stdfloat get_distance() const; PN_stdfloat get_applied_impulse() const; LPoint3 get_position_world_on_a() const; @@ -45,10 +45,10 @@ PUBLISHED: int get_index1() const; public: - BulletManifoldPoint(btManifoldPoint &pt); + BulletManifoldPoint(const btManifoldPoint &pt); private: - btManifoldPoint &_pt; + const btManifoldPoint _pt; }; #include "bulletManifoldPoint.I" diff --git a/panda/src/bullet/bulletWorld.cxx b/panda/src/bullet/bulletWorld.cxx index d107eb7cf9..732e65ec98 100644 --- a/panda/src/bullet/bulletWorld.cxx +++ b/panda/src/bullet/bulletWorld.cxx @@ -64,6 +64,29 @@ BulletWorld() { // Dispatcher _dispatcher = new btCollisionDispatcher(_configuration); +/* + _dispatcher.registerCollisionCreateFunc( + BroadphaseNativeType.ConvexTriangleMeshShape, + BroadphaseNativeType.ConvexTriangleMeshShape, + dcc.GetCollisionAlgorithmCreateFunc( + BroadphaseNativeType.TriangleMeshShape, + BroadphaseNativeType.TriangleMeshShape)); + + _dispatcher.registerCollisionCreateFunc( + BroadphaseNativeType.TriangleMeshShape, + BroadphaseNativeType.TriangleMeshShape, + dcc.GetCollisionAlgorithmCreateFunc( + BroadphaseNativeType.ConvexTriangleMeshShape, + BroadphaseNativeType.ConvexTriangleMeshShape)); + + _dispatcher.registerCollisionCreateFunc( + BroadphaseNativeType.ConvexTriangleMeshShape, + BroadphaseNativeType.ConvexTriangleMeshShape, + dcc.GetCollisionAlgorithmCreateFunc( + BroadphaseNativeType.ConvexTriangleMeshShape, + BroadphaseNativeType.ConvexTriangleMeshShape)); +*/ + // Solver _solver = new btSequentialImpulseConstraintSolver;