Explorar el Código

Suggestions from forum users (get_id and set_data/get_data published)

rdb hace 16 años
padre
commit
12493d6324

+ 16 - 0
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) {

+ 11 - 3
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;
 

+ 1 - 2
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:

+ 1 - 3
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;
 

+ 1 - 2
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;

+ 2 - 2
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);