diff --git a/dtool/src/parser-inc/btBulletDynamicsCommon.h b/dtool/src/parser-inc/btBulletDynamicsCommon.h index 95bc7a03ca..b53887f946 100644 --- a/dtool/src/parser-inc/btBulletDynamicsCommon.h +++ b/dtool/src/parser-inc/btBulletDynamicsCommon.h @@ -13,6 +13,7 @@ class btCharacterControllerInterface; class btCollisionConfiguration; class btCollisionDispatcher; class btCollisionObject; +class btCollisionObjectWrapper; class btCollisionShape; class btCompoundShape; class btConcaveShape; diff --git a/panda/src/bullet/bulletAllHitsRayResult.h b/panda/src/bullet/bulletAllHitsRayResult.h index 8b77981cbb..347441c62c 100644 --- a/panda/src/bullet/bulletAllHitsRayResult.h +++ b/panda/src/bullet/bulletAllHitsRayResult.h @@ -39,7 +39,7 @@ PUBLISHED: PN_stdfloat get_hit_fraction() const; private: - btCollisionObject *_object; + const btCollisionObject *_object; btVector3 _normal; btVector3 _pos; btScalar _fraction; diff --git a/panda/src/bullet/bulletClosestHitRayResult.cxx b/panda/src/bullet/bulletClosestHitRayResult.cxx index 53ec515353..4b6d920e79 100644 --- a/panda/src/bullet/bulletClosestHitRayResult.cxx +++ b/panda/src/bullet/bulletClosestHitRayResult.cxx @@ -72,11 +72,11 @@ get_hit_fraction() const { // Access: Published // Description: //////////////////////////////////////////////////////////////////// -PandaNode *BulletClosestHitRayResult:: +const PandaNode *BulletClosestHitRayResult:: get_node() const { - btCollisionObject *objectPtr = m_collisionObject; - return (objectPtr) ? (PandaNode *)objectPtr->getUserPointer() : NULL; + const btCollisionObject *objectPtr = m_collisionObject; + return (objectPtr) ? (const PandaNode *)objectPtr->getUserPointer() : NULL; } //////////////////////////////////////////////////////////////////// diff --git a/panda/src/bullet/bulletClosestHitRayResult.h b/panda/src/bullet/bulletClosestHitRayResult.h index 6a982193ea..a6c3f71af9 100644 --- a/panda/src/bullet/bulletClosestHitRayResult.h +++ b/panda/src/bullet/bulletClosestHitRayResult.h @@ -38,7 +38,7 @@ PUBLISHED: bool has_hit() const; - PandaNode *get_node() const; + const PandaNode *get_node() const; LPoint3 get_hit_pos() const; LVector3 get_hit_normal() const; PN_stdfloat get_hit_fraction() const; diff --git a/panda/src/bullet/bulletClosestHitSweepResult.cxx b/panda/src/bullet/bulletClosestHitSweepResult.cxx index 37ef0f9abb..7c4a12c336 100644 --- a/panda/src/bullet/bulletClosestHitSweepResult.cxx +++ b/panda/src/bullet/bulletClosestHitSweepResult.cxx @@ -33,11 +33,6 @@ BulletClosestHitSweepResult(const btVector3 &from_pos, const btVector3 &to_pos, bool BulletClosestHitSweepResult:: needsCollision(btBroadphaseProxy* proxy0) const { - // Original implementation: - //bool collides = (proxy0->m_collisionFilterGroup & m_collisionFilterMask) != 0; - //collides = collides && (m_collisionFilterGroup & proxy0->m_collisionFilterMask); - //return collides; - btCollisionObject *obj0 = (btCollisionObject *) proxy0->m_clientObject; PandaNode *node0 = (PandaNode *) obj0->getUserPointer(); CollideMask mask0 = node0->get_into_collide_mask(); @@ -72,11 +67,11 @@ get_hit_fraction() const { // Access: Published // Description: //////////////////////////////////////////////////////////////////// -PandaNode *BulletClosestHitSweepResult:: +const PandaNode *BulletClosestHitSweepResult:: get_node() const { - btCollisionObject *objectPtr = m_hitCollisionObject; - return (objectPtr) ? (PandaNode *)objectPtr->getUserPointer() : NULL; + const btCollisionObject *objectPtr = m_hitCollisionObject; + return (objectPtr) ? (const PandaNode *)objectPtr->getUserPointer() : NULL; } //////////////////////////////////////////////////////////////////// diff --git a/panda/src/bullet/bulletClosestHitSweepResult.h b/panda/src/bullet/bulletClosestHitSweepResult.h index 7ff7e524b4..6d142452b0 100644 --- a/panda/src/bullet/bulletClosestHitSweepResult.h +++ b/panda/src/bullet/bulletClosestHitSweepResult.h @@ -38,7 +38,7 @@ PUBLISHED: bool has_hit() const; - PandaNode *get_node() const; + const PandaNode *get_node() const; LPoint3 get_hit_pos() const; LVector3 get_hit_normal() const; PN_stdfloat get_hit_fraction() const; diff --git a/panda/src/bullet/bulletContactCallbacks.h b/panda/src/bullet/bulletContactCallbacks.h index 018e5e3e23..e0c3a31b57 100644 --- a/panda/src/bullet/bulletContactCallbacks.h +++ b/panda/src/bullet/bulletContactCallbacks.h @@ -39,16 +39,30 @@ struct UserPersitentData { //////////////////////////////////////////////////////////////////// static bool contact_added_callback(btManifoldPoint &cp, +#if BT_BULLET_VERSION >= 281 + const btCollisionObjectWrapper *wrap0, +#else const btCollisionObject *obj0, +#endif int id0, int index0, +#if BT_BULLET_VERSION >= 281 + const btCollisionObjectWrapper *wrap1, +#else const btCollisionObject *obj1, +#endif int id1, int index1) { if (cp.m_userPersistentData == NULL) { + +#if BT_BULLET_VERSION >= 281 + PT(PandaNode) node0 = (PandaNode *)wrap0->getCollisionObject()->getUserPointer(); + PT(PandaNode) node1 = (PandaNode *)wrap1->getCollisionObject()->getUserPointer(); +#else PT(PandaNode) node0 = (PandaNode *)obj0->getUserPointer(); PT(PandaNode) node1 = (PandaNode *)obj1->getUserPointer(); +#endif bullet_cat.debug() << "contact added: " << cp.m_userPersistentData << endl; diff --git a/panda/src/bullet/bulletContactResult.cxx b/panda/src/bullet/bulletContactResult.cxx index 2acf987d7a..9537ac672a 100644 --- a/panda/src/bullet/bulletContactResult.cxx +++ b/panda/src/bullet/bulletContactResult.cxx @@ -26,6 +26,32 @@ BulletContactResult() : btCollisionWorld::ContactResultCallback() { } +#if BT_BULLET_VERSION >= 281 +//////////////////////////////////////////////////////////////////// +// Function: BulletContactResult::addSingleResult +// Access: Published +// Description: +//////////////////////////////////////////////////////////////////// +btScalar BulletContactResult:: +addSingleResult(btManifoldPoint &mp, + const btCollisionObjectWrapper *wrap0, int part_id0, int idx0, + const btCollisionObjectWrapper *wrap1, int part_id1, int idx1) { + + BulletContact contact; + + contact._mp = mp; + contact._obj0 = wrap0->getCollisionObject(); + contact._obj1 = wrap1->getCollisionObject(); + contact._part_id0 = part_id0; + contact._part_id1 = part_id1; + contact._idx0 = idx0; + contact._idx1 = idx1; + + _contacts.push_back(contact); + + return 1.0f; +} +#else //////////////////////////////////////////////////////////////////// // Function: BulletContactResult::addSingleResult // Access: Published @@ -50,4 +76,5 @@ addSingleResult(btManifoldPoint &mp, return 1.0f; } +#endif diff --git a/panda/src/bullet/bulletContactResult.h b/panda/src/bullet/bulletContactResult.h index f881467e3f..b00d879dad 100644 --- a/panda/src/bullet/bulletContactResult.h +++ b/panda/src/bullet/bulletContactResult.h @@ -61,9 +61,15 @@ PUBLISHED: MAKE_SEQ(get_contacts, get_num_contacts, get_contact); public: +#if BT_BULLET_VERSION >= 281 + virtual btScalar addSingleResult(btManifoldPoint &mp, + const btCollisionObjectWrapper *wrap0, int part_id0, int idx0, + const btCollisionObjectWrapper *wrap1, int part_id1, int idx1); +#else virtual btScalar addSingleResult(btManifoldPoint &mp, const btCollisionObject *obj0, int part_id0, int idx0, const btCollisionObject *obj1, int part_id1, int idx1); +#endif protected: BulletContactResult(); diff --git a/panda/src/bullet/bulletPersistentManifold.cxx b/panda/src/bullet/bulletPersistentManifold.cxx index 5f506a7c6a..4d345294e6 100644 --- a/panda/src/bullet/bulletPersistentManifold.cxx +++ b/panda/src/bullet/bulletPersistentManifold.cxx @@ -63,12 +63,16 @@ clear_manifold() { // Access: Published // Description: //////////////////////////////////////////////////////////////////// -PandaNode *BulletPersistentManifold:: +const PandaNode *BulletPersistentManifold:: get_node0() { - btCollisionObject *obj = static_cast(_manifold->getBody0()); +#if BT_BULLET_VERSION >= 281 + const btCollisionObject *obj = _manifold->getBody0(); +#else + const btCollisionObject *obj = (btCollisionObject *)_manifold->getBody0(); +#endif - return (obj) ? (PandaNode *)obj->getUserPointer(): NULL; + return (obj) ? (const PandaNode *)obj->getUserPointer(): NULL; } //////////////////////////////////////////////////////////////////// @@ -76,12 +80,16 @@ get_node0() { // Access: Published // Description: //////////////////////////////////////////////////////////////////// -PandaNode *BulletPersistentManifold:: +const PandaNode *BulletPersistentManifold:: get_node1() { - btCollisionObject *obj = static_cast(_manifold->getBody1()); +#if BT_BULLET_VERSION >= 281 + const btCollisionObject *obj = _manifold->getBody1(); +#else + const btCollisionObject *obj = (btCollisionObject *)_manifold->getBody1(); +#endif - return (obj) ? (PandaNode *)obj->getUserPointer(): NULL; + return (obj) ? (const PandaNode *)obj->getUserPointer(): NULL; } //////////////////////////////////////////////////////////////////// diff --git a/panda/src/bullet/bulletPersistentManifold.h b/panda/src/bullet/bulletPersistentManifold.h index ee976739c9..0e63c48c08 100644 --- a/panda/src/bullet/bulletPersistentManifold.h +++ b/panda/src/bullet/bulletPersistentManifold.h @@ -32,8 +32,8 @@ class EXPCL_PANDABULLET BulletPersistentManifold { PUBLISHED: INLINE ~BulletPersistentManifold(); - PandaNode *get_node0(); - PandaNode *get_node1(); + const PandaNode *get_node0(); + const PandaNode *get_node1(); int get_num_manifold_points() const; BulletManifoldPoint *get_manifold_point(int idx) const; diff --git a/panda/src/bullet/config_bullet.cxx b/panda/src/bullet/config_bullet.cxx index 2d9c4dc146..908c61eb43 100644 --- a/panda/src/bullet/config_bullet.cxx +++ b/panda/src/bullet/config_bullet.cxx @@ -130,11 +130,11 @@ PRC_DESC("Only used when bullet-additional-damping is set to TRUE. " "Default value is 0.01.")); ConfigVariableBool bullet_full_sync -("bullet-full-sync", true, +("bullet-full-sync", false, PRC_DESC("Enables optional synchronisation features like checking " "for changed in a nodes net transform before each simulation " "step. Disable these features for better performance. " - "Default value is TRUE.")); + "Default value is FALSE.")); //////////////////////////////////////////////////////////////////// // Function: init_libbullet