Browse Source

Adding helper method for tracking dirty state of BulletRigidBodyNodes.

enn0x 13 years ago
parent
commit
8848966298
2 changed files with 34 additions and 0 deletions
  1. 28 0
      panda/src/bullet/bulletRigidBodyNode.cxx
  2. 6 0
      panda/src/bullet/bulletRigidBodyNode.h

+ 28 - 0
panda/src/bullet/bulletRigidBodyNode.cxx

@@ -513,6 +513,7 @@ MotionState() {
   _scale = LVecBase3(1.0f, 1.0f, 1.0f);
   _scale = LVecBase3(1.0f, 1.0f, 1.0f);
   _disabled = false;
   _disabled = false;
   _dirty = false;
   _dirty = false;
+  _was_dirty = false;
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -536,6 +537,7 @@ setWorldTransform(const btTransform &trans) {
 
 
   _trans = trans;
   _trans = trans;
   _dirty = true;
   _dirty = true;
+  _was_dirty = true;
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -596,3 +598,29 @@ sync_disabled() const {
   return _disabled;
   return _disabled;
 }
 }
 
 
+////////////////////////////////////////////////////////////////////
+//     Function: BulletRigidBodyNode::MotionState::pick_dirty_flag
+//       Access: Public
+//  Description: 
+////////////////////////////////////////////////////////////////////
+bool BulletRigidBodyNode::MotionState::
+pick_dirty_flag() {
+
+  bool flag = _was_dirty;
+  _was_dirty = false;
+  return flag;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: BulletRigidBodyNode::pick_dirty_flag
+//       Access: Published
+//  Description: Returns TRUE if the transform of the rigid body
+//               has changed at least once since the last call to
+//               this method.
+////////////////////////////////////////////////////////////////////
+bool BulletRigidBodyNode::
+pick_dirty_flag() {
+
+  return _motion->pick_dirty_flag();
+}
+

+ 6 - 0
panda/src/bullet/bulletRigidBodyNode.h

@@ -77,6 +77,9 @@ PUBLISHED:
   void set_linear_factor(const LVector3 &factor);
   void set_linear_factor(const LVector3 &factor);
   void set_angular_factor(const LVector3 &factor);
   void set_angular_factor(const LVector3 &factor);
 
 
+  // Special
+  bool pick_dirty_flag();
+
 public:
 public:
   virtual btCollisionObject *get_object() const;
   virtual btCollisionObject *get_object() const;
 
 
@@ -107,11 +110,14 @@ private:
     void sync_b2p(PandaNode *node);
     void sync_b2p(PandaNode *node);
     bool sync_disabled() const;
     bool sync_disabled() const;
 
 
+    bool pick_dirty_flag();
+
   private:
   private:
     btTransform _trans;
     btTransform _trans;
     LVecBase3 _scale;
     LVecBase3 _scale;
     bool _disabled;
     bool _disabled;
     bool _dirty;
     bool _dirty;
+    bool _was_dirty;
   };
   };
 
 
   MotionState *_motion;
   MotionState *_motion;