diff --git a/panda/src/ode/odeCollisionEntry.I b/panda/src/ode/odeCollisionEntry.I index b062500513..13512d3a8c 100644 --- a/panda/src/ode/odeCollisionEntry.I +++ b/panda/src/ode/odeCollisionEntry.I @@ -62,13 +62,24 @@ get_body2() { } //////////////////////////////////////////////////////////////////// -// Function: OdeCollisionEntry::get_num_contact_points +// Function: OdeCollisionEntry::get_num_contacts // Access: Published -// Description: Returns the number of contact points. +// Description: Returns the number of contacts in the collision. //////////////////////////////////////////////////////////////////// INLINE const size_t OdeCollisionEntry:: -get_num_contact_points() { - return _num_points; +get_num_contacts() { + return _num_contacts; +} + +//////////////////////////////////////////////////////////////////// +// Function: OdeCollisionEntry::get_contact_geom +// Access: Published +// Description: Returns the nth contact geom in the collision. +//////////////////////////////////////////////////////////////////// +INLINE const OdeContactGeom OdeCollisionEntry:: +get_contact_geom(size_t n) { + nassertr(n >= 0 && n < _num_contacts, OdeContactGeom()); + return _contact_geoms[n]; } //////////////////////////////////////////////////////////////////// @@ -78,7 +89,7 @@ get_num_contact_points() { //////////////////////////////////////////////////////////////////// INLINE const LPoint3f OdeCollisionEntry:: get_contact_point(size_t n) { - nassertr(n >= 0 && n < _num_points, LPoint3f::zero()); - return _points[n]; + nassertr(n >= 0 && n < _num_contacts, LPoint3f::zero()); + return _contact_geoms[n].get_pos(); } diff --git a/panda/src/ode/odeCollisionEntry.cxx b/panda/src/ode/odeCollisionEntry.cxx index 28f9393931..85e782e161 100644 --- a/panda/src/ode/odeCollisionEntry.cxx +++ b/panda/src/ode/odeCollisionEntry.cxx @@ -16,3 +16,13 @@ TypeHandle OdeCollisionEntry::_type_handle; +//////////////////////////////////////////////////////////////////// +// Function: OdeCollisionEntry::Destructor +// Access: Published +// Description: +//////////////////////////////////////////////////////////////////// +OdeCollisionEntry:: +~OdeCollisionEntry() { + delete[] _contact_geoms; +} + diff --git a/panda/src/ode/odeCollisionEntry.h b/panda/src/ode/odeCollisionEntry.h index 023dbbd3fd..3ccc3c5b7f 100644 --- a/panda/src/ode/odeCollisionEntry.h +++ b/panda/src/ode/odeCollisionEntry.h @@ -18,7 +18,7 @@ #include "pandabase.h" #include "typedReferenceCount.h" -class OdeGeom; +#include "odeContactGeom.h" //////////////////////////////////////////////////////////////////// // Class : OdeCollisionEntry @@ -27,23 +27,25 @@ class OdeGeom; //////////////////////////////////////////////////////////////////// class EXPCL_PANDAODE OdeCollisionEntry : public TypedReferenceCount { PUBLISHED: - virtual ~OdeCollisionEntry() {}; + virtual ~OdeCollisionEntry(); INLINE const OdeGeom get_geom1(); INLINE const OdeGeom get_geom2(); INLINE const OdeBody get_body1(); INLINE const OdeBody get_body2(); + INLINE const size_t get_num_contacts(); INLINE const LPoint3f get_contact_point(size_t n); - INLINE const size_t get_num_contact_points(); - MAKE_SEQ(get_contact_points, get_num_contact_points, get_contact_point); + INLINE const OdeContactGeom get_contact_geom(size_t n); + MAKE_SEQ(get_contact_points, get_num_contacts, get_contact_point); + MAKE_SEQ(get_contact_geoms, get_num_contacts, get_contact_geom); private: INLINE OdeCollisionEntry(); dGeomID _geom1, _geom2; dBodyID _body1, _body2; - size_t _num_points; - LPoint3f *_points; + size_t _num_contacts; + OdeContactGeom *_contact_geoms; public: static TypeHandle get_class_type() { diff --git a/panda/src/ode/odeContactGeom.h b/panda/src/ode/odeContactGeom.h index 59adf69867..52d90601f4 100755 --- a/panda/src/ode/odeContactGeom.h +++ b/panda/src/ode/odeContactGeom.h @@ -22,12 +22,15 @@ #include "ode_includes.h" #include "odeGeom.h" +class OdeSpace; + //////////////////////////////////////////////////////////////////// // Class : OdeContactGeom // Description : //////////////////////////////////////////////////////////////////// class EXPCL_PANDAODE OdeContactGeom : public TypedReferenceCount { friend class OdeContact; + friend class OdeSpace; PUBLISHED: OdeContactGeom(); diff --git a/panda/src/ode/odeSpace.cxx b/panda/src/ode/odeSpace.cxx index 4ce004fc5b..c79c4dead6 100755 --- a/panda/src/ode/odeSpace.cxx +++ b/panda/src/ode/odeSpace.cxx @@ -206,8 +206,8 @@ auto_callback(void *data, dGeomID o1, dGeomID o2) { entry->_geom2 = o2; entry->_body1 = b1; entry->_body2 = b2; - entry->_num_points = numc; - entry->_points = new LPoint3f[numc]; + entry->_num_contacts = numc; + entry->_contact_geoms = new OdeContactGeom[numc]; } for(i=0; i < numc; i++) { @@ -216,9 +216,7 @@ auto_callback(void *data, dGeomID o1, dGeomID o2) { dJointAttach(c, b1, b2); } if (!_collide_space->_collision_event.empty()) { - entry->_points[i][0] = contact[i].geom.pos[0]; - entry->_points[i][1] = contact[i].geom.pos[1]; - entry->_points[i][2] = contact[i].geom.pos[2]; + entry->_contact_geoms[i] = contact[i].geom; } // this creates contact position data for python. It is useful for debugging only 64 points are stored if(contactCount < 64) {