Support for Bullet v2.81
This commit is contained in:
parent
5178fb9523
commit
6bb5fdc5e0
|
|
@ -13,6 +13,7 @@ class btCharacterControllerInterface;
|
|||
class btCollisionConfiguration;
|
||||
class btCollisionDispatcher;
|
||||
class btCollisionObject;
|
||||
class btCollisionObjectWrapper;
|
||||
class btCollisionShape;
|
||||
class btCompoundShape;
|
||||
class btConcaveShape;
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ PUBLISHED:
|
|||
PN_stdfloat get_hit_fraction() const;
|
||||
|
||||
private:
|
||||
btCollisionObject *_object;
|
||||
const btCollisionObject *_object;
|
||||
btVector3 _normal;
|
||||
btVector3 _pos;
|
||||
btScalar _fraction;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -63,12 +63,16 @@ clear_manifold() {
|
|||
// Access: Published
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
PandaNode *BulletPersistentManifold::
|
||||
const PandaNode *BulletPersistentManifold::
|
||||
get_node0() {
|
||||
|
||||
btCollisionObject *obj = static_cast<btCollisionObject *>(_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<btCollisionObject *>(_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;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in New Issue