From 49c6aa19b379d61dff4932336762f7c28adb1f25 Mon Sep 17 00:00:00 2001 From: Darren Ranalli Date: Wed, 27 Jun 2007 21:09:32 +0000 Subject: [PATCH] added setDefaultToStandingStill --- direct/src/deadrec/smoothMover.I | 26 ++++++++++++++++++++++++++ direct/src/deadrec/smoothMover.cxx | 3 ++- direct/src/deadrec/smoothMover.h | 4 ++++ 3 files changed, 32 insertions(+), 1 deletion(-) diff --git a/direct/src/deadrec/smoothMover.I b/direct/src/deadrec/smoothMover.I index 5b1fc04b0e..753607f2d9 100644 --- a/direct/src/deadrec/smoothMover.I +++ b/direct/src/deadrec/smoothMover.I @@ -693,6 +693,32 @@ get_directional_velocity() { return _directional_velocity; } +//////////////////////////////////////////////////////////////////// +// Function: SmoothMover::set_default_to_standing_still +// Access: Published, Static +// Description: Sets the flag that indicates whether to assume that +// the node stopped moving during periods when we don't +// get enough position updates. If true, the object will +// stand still momentarily. If false, the object will +// continuously lerp between the position updates that +// we did get. +//////////////////////////////////////////////////////////////////// +INLINE void SmoothMover:: +set_default_to_standing_still(bool flag) { + _default_to_standing_still = flag; +} + +//////////////////////////////////////////////////////////////////// +// Function: SmoothMover::get_default_to_standing_still +// Access: Published, Static +// Description: Returns the current state of the 'default to standing +// still' flag. See set_default_to_standing_still(). +//////////////////////////////////////////////////////////////////// +INLINE bool SmoothMover:: +get_default_to_standing_still() { + return _default_to_standing_still; +} + //////////////////////////////////////////////////////////////////// // Function: SmoothMover::get_avg_timestamp_delay // Access: Private diff --git a/direct/src/deadrec/smoothMover.cxx b/direct/src/deadrec/smoothMover.cxx index 636f651300..23feb67f4f 100644 --- a/direct/src/deadrec/smoothMover.cxx +++ b/direct/src/deadrec/smoothMover.cxx @@ -61,6 +61,7 @@ SmoothMover() { _delay = 0.2; _accept_clock_skew = true; _directional_velocity = true; + _default_to_standing_still = true; _max_position_age = 0.25; _expected_broadcast_period = 0.2; _reset_velocity_age = 0.3; @@ -413,7 +414,7 @@ compute_smooth_position(double timestamp) { // The points are different, so we have to do some work. double age = (point_a._timestamp - point_b._timestamp); - if (age > _max_position_age) { + if (_default_to_standing_still && (age > _max_position_age)) { // If the first point is too old, assume there were a lot of // implicit standing still messages that weren't sent. Insert a new // sample point to reflect this. diff --git a/direct/src/deadrec/smoothMover.h b/direct/src/deadrec/smoothMover.h index 7d185a895c..432750f5de 100644 --- a/direct/src/deadrec/smoothMover.h +++ b/direct/src/deadrec/smoothMover.h @@ -149,6 +149,9 @@ PUBLISHED: INLINE void set_directional_velocity(bool flag); INLINE bool get_directional_velocity(); + INLINE void set_default_to_standing_still(bool flag); + INLINE bool get_default_to_standing_still(); + void output(ostream &out) const; void write(ostream &out) const; @@ -217,6 +220,7 @@ private: double _expected_broadcast_period; double _reset_velocity_age; bool _directional_velocity; + bool _default_to_standing_still; }; #include "smoothMover.I"