Browse Source

Make empty ODE objects evaluate to False

rdb 16 years ago
parent
commit
6bd15649f9

+ 5 - 0
panda/src/ode/odeBody.cxx

@@ -53,3 +53,8 @@ write(ostream &out, unsigned int indent) const {
 			 << ")";
 			 << ")";
   #endif //] NDEBUG
   #endif //] NDEBUG
 }
 }
+
+OdeBody::
+operator bool () const {
+  return (_id != NULL);
+}

+ 1 - 0
panda/src/ode/odeBody.h

@@ -135,6 +135,7 @@ PUBLISHED:
   INLINE int get_gravity_mode() const;
   INLINE int get_gravity_mode() const;
 
 
   virtual void write(ostream &out = cout, unsigned int indent=0) const;
   virtual void write(ostream &out = cout, unsigned int indent=0) const;
+  operator bool () const;
   INLINE int compare_to(const OdeBody &other) const;
   INLINE int compare_to(const OdeBody &other) const;
 
 
 public:
 public:

+ 5 - 0
panda/src/ode/odeJoint.cxx

@@ -112,6 +112,11 @@ write(ostream &out, unsigned int indent) const {
   #endif //] NDEBUG
   #endif //] NDEBUG
 }
 }
 
 
+OdeJoint::
+operator bool () const {
+  return (_id != NULL);
+}
+
 OdeBallJoint OdeJoint::
 OdeBallJoint OdeJoint::
 convert_to_ball() const {
 convert_to_ball() const {
   nassertr(_id != 0, OdeBallJoint(0));
   nassertr(_id != 0, OdeBallJoint(0));

+ 1 - 0
panda/src/ode/odeJoint.h

@@ -83,6 +83,7 @@ PUBLISHED:
   virtual void write(ostream &out = cout, unsigned int indent=0) const;
   virtual void write(ostream &out = cout, unsigned int indent=0) const;
   INLINE int compare_to(const OdeJoint &other) const;
   INLINE int compare_to(const OdeJoint &other) const;
   INLINE bool operator == (const OdeJoint &other) const;
   INLINE bool operator == (const OdeJoint &other) const;
+  operator bool () const;
 
 
   OdeBallJoint convert_to_ball() const;
   OdeBallJoint convert_to_ball() const;
   OdeHingeJoint convert_to_hinge() const;
   OdeHingeJoint convert_to_hinge() const;

+ 4 - 0
panda/src/ode/odeSpace.cxx

@@ -101,6 +101,10 @@ write(ostream &out, unsigned int indent) const {
   #endif //] NDEBUG
   #endif //] NDEBUG
 }
 }
 
 
+OdeSpace::
+operator bool () const {
+  return (_id != NULL);
+}
 
 
 void OdeSpace::
 void OdeSpace::
 set_auto_collide_world(OdeWorld &world)
 set_auto_collide_world(OdeWorld &world)

+ 1 - 0
panda/src/ode/odeSpace.h

@@ -81,6 +81,7 @@ PUBLISHED:
   INLINE OdeSpace get_space() const;
   INLINE OdeSpace get_space() const;
 
 
   virtual void write(ostream &out = cout, unsigned int indent=0) const;
   virtual void write(ostream &out = cout, unsigned int indent=0) const;
+  operator bool () const;
 
 
   OdeSimpleSpace convert_to_simple_space() const;
   OdeSimpleSpace convert_to_simple_space() const;
   OdeHashSpace convert_to_hash_space() const;
   OdeHashSpace convert_to_hash_space() const;

+ 4 - 1
panda/src/ode/odeWorld.cxx

@@ -197,4 +197,7 @@ apply_dampening(float dt, OdeBody& body)
     
     
 }
 }
 
 
-
+OdeWorld::
+operator bool () const {
+  return (_id != NULL);
+}

+ 1 - 1
panda/src/ode/odeWorld.h

@@ -97,7 +97,7 @@ PUBLISHED:
                          dReal dampen);
                          dReal dampen);
   float apply_dampening(float dt, OdeBody& body);
   float apply_dampening(float dt, OdeBody& body);
   
   
-  
+  operator bool () const;
     
     
 public: 
 public: 
   INLINE dWorldID get_id() const;
   INLINE dWorldID get_id() const;