Cleaning up BulletContact (API changes only in C++)

This commit is contained in:
enn0x 2014-02-27 20:57:23 +00:00
parent 79430f6bc5
commit ae820a30bc
5 changed files with 93 additions and 26 deletions

View File

@ -14,41 +14,40 @@
////////////////////////////////////////////////////////////////////
// Function: BulletContactResult::get_node0
// Function: BulletContact::get_node0
// Access: Published
// Description:
////////////////////////////////////////////////////////////////////
INLINE PandaNode *BulletContact::
get_node0() const {
return _obj0 ? (PandaNode *)_obj0->getUserPointer() : NULL;
return _node0;
}
////////////////////////////////////////////////////////////////////
// Function: BulletContactResult::get_node1
// Function: BulletContact::get_node1
// Access: Published
// Description:
////////////////////////////////////////////////////////////////////
INLINE PandaNode *BulletContact::
get_node1() const {
return _obj1 ? (PandaNode *)_obj1->getUserPointer() : NULL;
return _node1;
}
////////////////////////////////////////////////////////////////////
// Function: BulletContactResult::get_manifold_point
// Function: BulletContact::get_manifold_point
// Access: Published
// Description:
////////////////////////////////////////////////////////////////////
INLINE const BulletManifoldPoint *BulletContact::
get_manifold_point() const {
INLINE BulletManifoldPoint &BulletContact::
get_manifold_point() {
btManifoldPoint &mp = const_cast<btManifoldPoint &>(_mp);
return new BulletManifoldPoint(mp);
return _mp;
}
////////////////////////////////////////////////////////////////////
// Function: BulletContactResult::get_idx0
// Function: BulletContact::get_idx0
// Access: Published
// Description:
////////////////////////////////////////////////////////////////////
@ -59,7 +58,7 @@ get_idx0() const {
}
////////////////////////////////////////////////////////////////////
// Function: BulletContactResult::get_idx1
// Function: BulletContact::get_idx1
// Access: Published
// Description:
////////////////////////////////////////////////////////////////////
@ -70,7 +69,7 @@ get_idx1() const {
}
////////////////////////////////////////////////////////////////////
// Function: BulletContactResult::get_part_id0
// Function: BulletContact::get_part_id0
// Access: Published
// Description:
////////////////////////////////////////////////////////////////////
@ -81,7 +80,7 @@ get_part_id0() const {
}
////////////////////////////////////////////////////////////////////
// Function: BulletContactResult::get_part_id1
// Function: BulletContact::get_part_id1
// Access: Published
// Description:
////////////////////////////////////////////////////////////////////
@ -107,8 +106,8 @@ get_num_contacts() const {
// Access: Published
// Description:
////////////////////////////////////////////////////////////////////
INLINE const BulletContact &BulletContactResult::
get_contact(int idx) const {
INLINE BulletContact &BulletContactResult::
get_contact(int idx) {
nassertr(idx >= 0 && idx < (int)_contacts.size(), _empty);
return _contacts[idx];

View File

@ -14,8 +14,37 @@
#include "bulletContactResult.h"
btManifoldPoint BulletContact::_empty;
BulletContact BulletContactResult::_empty;
////////////////////////////////////////////////////////////////////
// Function: BulletContact::Constructor
// Access: Published
// Description:
////////////////////////////////////////////////////////////////////
BulletContact::
BulletContact() : _mp(_empty) {
_node0 = NULL;
_node1 = NULL;
}
////////////////////////////////////////////////////////////////////
// Function: BulletContact::Copy Constructor
// Access: Published
// Description:
////////////////////////////////////////////////////////////////////
BulletContact::
BulletContact(const BulletContact &other) : _mp(other._mp) {
_node0 = other._node0;
_node1 = other._node1;
_part_id0 = other._part_id0;
_part_id1 = other._part_id1;
_idx0 = other._idx0;
_idx1 = other._idx1;
}
////////////////////////////////////////////////////////////////////
// Function: BulletContactResult::Constructor
// Access: Protected
@ -74,11 +103,14 @@ addSingleResult(btManifoldPoint &mp,
const btCollisionObjectWrapper *wrap0, int part_id0, int idx0,
const btCollisionObjectWrapper *wrap1, int part_id1, int idx1) {
const btCollisionObject *obj0 = wrap0->getCollisionObject();
const btCollisionObject *obj1 = wrap1->getCollisionObject();
BulletContact contact;
contact._mp = mp;
contact._obj0 = wrap0->getCollisionObject();
contact._obj1 = wrap1->getCollisionObject();
contact._mp = BulletManifoldPoint(mp);
contact._node0 = obj0 ? (PandaNode *)obj0->getUserPointer() : NULL;
contact._node1 = obj1 ? (PandaNode *)obj1->getUserPointer() : NULL;
contact._part_id0 = part_id0;
contact._part_id1 = part_id1;
contact._idx0 = idx0;
@ -99,11 +131,14 @@ addSingleResult(btManifoldPoint &mp,
const btCollisionObject *obj0, int part_id0, int idx0,
const btCollisionObject *obj1, int part_id1, int idx1) {
const btCollisionObject *obj0 = wrap0->getCollisionObject();
const btCollisionObject *obj1 = wrap1->getCollisionObject();
BulletContact contact;
contact._mp = mp;
contact._obj0 = obj0;
contact._obj1 = obj1;
contact._mp = BulletManifoldPoint(mp);
contact._node0 = obj0 ? (PandaNode *)obj0->getUserPointer() : NULL;
contact._node1 = obj1 ? (PandaNode *)obj1->getUserPointer() : NULL;
contact._part_id0 = part_id0;
contact._part_id1 = part_id1;
contact._idx0 = idx0;

View File

@ -28,8 +28,12 @@
////////////////////////////////////////////////////////////////////
struct EXPCL_PANDABULLET BulletContact {
public:
BulletContact();
BulletContact(const BulletContact &other);
PUBLISHED:
INLINE const BulletManifoldPoint *get_manifold_point() const;
INLINE BulletManifoldPoint &get_manifold_point();
INLINE PandaNode *get_node0() const;
INLINE PandaNode *get_node1() const;
INLINE const int get_idx0() const;
@ -38,9 +42,13 @@ PUBLISHED:
INLINE const int get_part_id1() const;
private:
btManifoldPoint _mp;
const btCollisionObject *_obj0;
const btCollisionObject *_obj1;
static btManifoldPoint _empty;
BulletManifoldPoint _mp;
PT(PandaNode) _node0;
PT(PandaNode) _node1;
int _part_id0;
int _part_id1;
int _idx0;
@ -57,7 +65,7 @@ struct EXPCL_PANDABULLET BulletContactResult : public btCollisionWorld::ContactR
PUBLISHED:
INLINE int get_num_contacts() const;
INLINE const BulletContact &get_contact(int idx) const;
INLINE BulletContact &get_contact(int idx);
MAKE_SEQ(get_contacts, get_num_contacts, get_contact);
public:

View File

@ -25,6 +25,28 @@ BulletManifoldPoint(btManifoldPoint &pt)
}
////////////////////////////////////////////////////////////////////
// Function: BulletManifoldPoint::Copy Constructor
// Access: Public
// Description:
////////////////////////////////////////////////////////////////////
BulletManifoldPoint::
BulletManifoldPoint(const BulletManifoldPoint &other)
: _pt(other._pt) {
}
////////////////////////////////////////////////////////////////////
// Function: BulletManifoldPoint::Copy Assignment
// Access: Public
// Description:
////////////////////////////////////////////////////////////////////
BulletManifoldPoint& BulletManifoldPoint::
operator=(const BulletManifoldPoint& other) {
return *this;
}
////////////////////////////////////////////////////////////////////
// Function: BulletManifoldPoint::get_lift_time
// Access: Published

View File

@ -73,6 +73,9 @@ PUBLISHED:
public:
BulletManifoldPoint(btManifoldPoint &pt);
BulletManifoldPoint(const BulletManifoldPoint &other);
BulletManifoldPoint& operator=(const BulletManifoldPoint& other);
private:
btManifoldPoint &_pt;
};