From 0ff966d7995a4a0f666c18a84a4b370a9f02c3e4 Mon Sep 17 00:00:00 2001 From: David Rose Date: Tue, 23 Oct 2001 23:51:57 +0000 Subject: [PATCH] better predictive smoothing --- direct/src/deadrec/smoothMover.cxx | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/direct/src/deadrec/smoothMover.cxx b/direct/src/deadrec/smoothMover.cxx index 4844da6bb0..bac9272574 100644 --- a/direct/src/deadrec/smoothMover.cxx +++ b/direct/src/deadrec/smoothMover.cxx @@ -260,19 +260,24 @@ compute_smooth_position(double timestamp) { // With prediction in effect, we're allowed to anticipate where // the avatar is going by a tiny bit, if we don't have current // enough data. This works only if we have at least two points of - // old data, and they're not *too* old. - if (point_before > 0 && - timestamp - timestamp_before <= _max_position_age) { + // old data. + if (point_before > 0) { // To implement simple prediction, we simply back up in time to // the previous two timestamps, and base our linear // interpolation off of those two, extending into the future. int point_before_before = point_before - 1; - const SamplePoint &point = _points[point_before_before]; + SamplePoint &point = _points[point_before_before]; if (point._timestamp < timestamp_before) { point_after = point_before; timestamp_after = timestamp_before; point_before = point_before_before; timestamp_before = point._timestamp; + + if (timestamp > timestamp_after + _max_position_age) { + // Don't allow the prediction to get too far into the + // future. + timestamp = timestamp_after + _max_position_age; + } } } }