From 8848966298cae72807a7c1dd69adece3584cb6f3 Mon Sep 17 00:00:00 2001 From: enn0x Date: Thu, 31 Jan 2013 11:51:47 +0000 Subject: [PATCH] Adding helper method for tracking dirty state of BulletRigidBodyNodes. --- panda/src/bullet/bulletRigidBodyNode.cxx | 28 ++++++++++++++++++++++++ panda/src/bullet/bulletRigidBodyNode.h | 6 +++++ 2 files changed, 34 insertions(+) diff --git a/panda/src/bullet/bulletRigidBodyNode.cxx b/panda/src/bullet/bulletRigidBodyNode.cxx index 462ee0bbae..bc605274ba 100644 --- a/panda/src/bullet/bulletRigidBodyNode.cxx +++ b/panda/src/bullet/bulletRigidBodyNode.cxx @@ -513,6 +513,7 @@ MotionState() { _scale = LVecBase3(1.0f, 1.0f, 1.0f); _disabled = false; _dirty = false; + _was_dirty = false; } //////////////////////////////////////////////////////////////////// @@ -536,6 +537,7 @@ setWorldTransform(const btTransform &trans) { _trans = trans; _dirty = true; + _was_dirty = true; } //////////////////////////////////////////////////////////////////// @@ -596,3 +598,29 @@ sync_disabled() const { 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(); +} + diff --git a/panda/src/bullet/bulletRigidBodyNode.h b/panda/src/bullet/bulletRigidBodyNode.h index afe4557bd8..f0f59cfe3d 100644 --- a/panda/src/bullet/bulletRigidBodyNode.h +++ b/panda/src/bullet/bulletRigidBodyNode.h @@ -77,6 +77,9 @@ PUBLISHED: void set_linear_factor(const LVector3 &factor); void set_angular_factor(const LVector3 &factor); + // Special + bool pick_dirty_flag(); + public: virtual btCollisionObject *get_object() const; @@ -107,11 +110,14 @@ private: void sync_b2p(PandaNode *node); bool sync_disabled() const; + bool pick_dirty_flag(); + private: btTransform _trans; LVecBase3 _scale; bool _disabled; bool _dirty; + bool _was_dirty; }; MotionState *_motion;