From 8316aaa340fd4a4191d11c3514e00032c8090be5 Mon Sep 17 00:00:00 2001 From: Darren Ranalli Date: Wed, 31 Jul 2002 18:13:00 +0000 Subject: [PATCH] lerp t now clamped at 1.0 --- panda/src/lerp/lerp.cxx | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/panda/src/lerp/lerp.cxx b/panda/src/lerp/lerp.cxx index 3c5627fd09..a76ee4d604 100644 --- a/panda/src/lerp/lerp.cxx +++ b/panda/src/lerp/lerp.cxx @@ -66,14 +66,17 @@ Lerp& Lerp::operator=(const Lerp& c) { } void Lerp::step(void) { - if (is_done()) - return; _t += _delta; - float t = scale_t(_t, _startt, _endt); - t = (_blend==(LerpBlendType*)0L)?t:(*_blend)(t); - (*_func)(t); - if (is_done() && !_event.empty()) - throw_event(_event); + if (is_done()) { + (*_func)(1.0); + if (!_event.empty()) { + throw_event(_event); + } + } else { + float t = scale_t(_t, _startt, _endt); + t = (_blend==(LerpBlendType*)0L)?t:(*_blend)(t); + (*_func)(t); + } } void Lerp::set_step_size(float delta) { @@ -183,6 +186,8 @@ std::string AutonomousLerp::get_end_event(void) const { } void AutonomousLerp::step(void) { + // Probably broken because it does not set the final value when t + // exceeds end_t. see fixed Lerp::step() above if (is_done()) { stop(); return;