From 12493d63242b9f274abe2d302a98046437c08294 Mon Sep 17 00:00:00 2001 From: rdb Date: Mon, 4 May 2009 07:07:09 +0000 Subject: [PATCH] Suggestions from forum users (get_id and set_data/get_data published) --- panda/src/ode/odeBody.I | 16 ++++++++++++++++ panda/src/ode/odeBody.h | 14 +++++++++++--- panda/src/ode/odeGeom.h | 3 +-- panda/src/ode/odeJoint.h | 4 +--- panda/src/ode/odeJointGroup.h | 3 +-- panda/src/ode/odeWorld.h | 4 ++-- 6 files changed, 32 insertions(+), 12 deletions(-) diff --git a/panda/src/ode/odeBody.I b/panda/src/ode/odeBody.I index 4bfe80df49..86896d4f2d 100755 --- a/panda/src/ode/odeBody.I +++ b/panda/src/ode/odeBody.I @@ -95,10 +95,26 @@ set_data(void *data) { dBodySetData(_id, data); } +#ifdef HAVE_PYTHON +INLINE void OdeBody:: +set_data(PyObject *data) { + Py_XINCREF(data); + dBodySetData(_id, data); +} + +INLINE PyObject* OdeBody:: +get_data() const { + PyObject* data = (PyObject*) dBodyGetData(_id); + Py_XINCREF(data); + return data; +} +#else + INLINE void* OdeBody:: get_data() const { return dBodyGetData(_id); } +#endif INLINE void OdeBody:: set_position(dReal x, dReal y, dReal z) { diff --git a/panda/src/ode/odeBody.h b/panda/src/ode/odeBody.h index 0611549cce..57cc0b3f8c 100755 --- a/panda/src/ode/odeBody.h +++ b/panda/src/ode/odeBody.h @@ -22,6 +22,9 @@ #include "ode_includes.h" #include "odeWorld.h" #include "odeMass.h" +#ifdef HAVE_PYTHON +#include "Python.h" +#endif class OdeJoint; class OdeGeom; @@ -44,6 +47,7 @@ PUBLISHED: virtual ~OdeBody(); void destroy(); INLINE bool is_empty() const; + INLINE dBodyID get_id() const; INLINE void set_auto_disable_linear_threshold(dReal linear_threshold); INLINE void set_auto_disable_angular_threshold(dReal angular_threshold); @@ -52,6 +56,9 @@ PUBLISHED: INLINE void set_auto_disable_flag(int do_auto_disable); INLINE void set_auto_disable_defaults(); INLINE void set_data(void *data); +#ifdef HAVE_PYTHON + INLINE void set_data(PyObject *data); +#endif INLINE void set_position(dReal x, dReal y, dReal z); INLINE void set_position(const LVecBase3f &pos); @@ -69,7 +76,11 @@ PUBLISHED: INLINE int get_auto_disable_steps() const; INLINE dReal get_auto_disable_time() const; INLINE int get_auto_disable_flag() const; +#ifdef HAVE_PYTHON + INLINE PyObject* get_data() const; +#else INLINE void* get_data() const; +#endif INLINE LVecBase3f get_position() const; INLINE LMatrix3f get_rotation() const; @@ -139,9 +150,6 @@ PUBLISHED: operator bool () const; INLINE int compare_to(const OdeBody &other) const; -public: - INLINE dBodyID get_id() const; - private: dBodyID _id; diff --git a/panda/src/ode/odeGeom.h b/panda/src/ode/odeGeom.h index bde3679fb3..de2017e34b 100755 --- a/panda/src/ode/odeGeom.h +++ b/panda/src/ode/odeGeom.h @@ -73,6 +73,7 @@ PUBLISHED: virtual ~OdeGeom(); void destroy(); INLINE bool is_empty() const; + INLINE dGeomID get_id() const; //INLINE void set_data(void* data); INLINE void set_body(OdeBody &body); @@ -139,8 +140,6 @@ PUBLISHED: public: - INLINE dGeomID get_id() const; - INLINE static int get_geom_class() { return -1; }; protected: diff --git a/panda/src/ode/odeJoint.h b/panda/src/ode/odeJoint.h index bdcdf71ea4..38299720c1 100755 --- a/panda/src/ode/odeJoint.h +++ b/panda/src/ode/odeJoint.h @@ -69,6 +69,7 @@ PUBLISHED: virtual ~OdeJoint(); void destroy(); INLINE bool is_empty() const; + INLINE dJointID get_id() const; /* INLINE void set_data(void *data); */ /* INLINE void *get_data(); */ @@ -98,9 +99,6 @@ PUBLISHED: OdeLMotorJoint convert_to_l_motor() const; OdePlane2dJoint convert_to_plane2d() const; -public: - INLINE dJointID get_id() const; - protected: dJointID _id; diff --git a/panda/src/ode/odeJointGroup.h b/panda/src/ode/odeJointGroup.h index 127d3d34ac..d76c4afd55 100755 --- a/panda/src/ode/odeJointGroup.h +++ b/panda/src/ode/odeJointGroup.h @@ -30,13 +30,12 @@ PUBLISHED: OdeJointGroup(); virtual ~OdeJointGroup(); void destroy(); + INLINE dJointGroupID get_id() const; INLINE void empty() const; INLINE int compare_to(const OdeJointGroup &other) const; -public: - INLINE dJointGroupID get_id() const; private: dJointGroupID _id; diff --git a/panda/src/ode/odeWorld.h b/panda/src/ode/odeWorld.h index 2990056062..dcb1268bec 100755 --- a/panda/src/ode/odeWorld.h +++ b/panda/src/ode/odeWorld.h @@ -43,6 +43,7 @@ PUBLISHED: virtual ~OdeWorld(); void destroy(); INLINE bool is_empty() const; + INLINE dWorldID get_id() const; INLINE void set_gravity(dReal x, dReal y, dReal z); INLINE void set_gravity(const LVecBase3f &vec); @@ -100,8 +101,7 @@ PUBLISHED: operator bool () const; -public: - INLINE dWorldID get_id() const; +public: INLINE sSurfaceParams& get_surface(PN_uint8 surface1, PN_uint8 surface2); INLINE void set_surface(int pos1, int pos2, sSurfaceParams& entry); INLINE sBodyParams get_surface_body(dBodyID id);