added setDefaultToStandingStill

This commit is contained in:
Darren Ranalli 2007-06-27 21:09:32 +00:00
parent 525c9f9dc4
commit 49c6aa19b3
3 changed files with 32 additions and 1 deletions

View File

@ -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

View File

@ -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.

View File

@ -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"