From 4c0b28a43e46d1b9ea0d6d1367d14ee798cbf142 Mon Sep 17 00:00:00 2001 From: Benau Date: Thu, 17 Aug 2017 15:48:21 +0800 Subject: [PATCH] Fix speed weight object looping in non-animated character --- src/karts/kart_model.cpp | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/src/karts/kart_model.cpp b/src/karts/kart_model.cpp index 111eab374..90b53ba36 100644 --- a/src/karts/kart_model.cpp +++ b/src/karts/kart_model.cpp @@ -637,7 +637,10 @@ bool KartModel::loadModels(const KartProperties &kart_properties) #endif // Update min/max Vec3 obj_min, obj_max; - MeshTools::minMax3D(obj.m_model, &obj_min, &obj_max); + int frame = m_animation_frame[AF_SPEED_WEIGHTED_START]; + if (frame < 0) + frame = 0; + MeshTools::minMax3D(obj.m_model->getMesh(frame), &obj_min, &obj_max); obj_min += obj.m_position; obj_max += obj.m_position; kart_min.min(obj_min); @@ -1026,15 +1029,6 @@ void KartModel::update(float dt, float distance, float steer, float speed, m_wheel_node[i]->setRotation(wheel_rotation); } // for (i < 4) - // If animations are disabled, stop here - if (m_animated_node == NULL) return; - - if (m_play_non_loop && m_animated_node->getLoopMode() == true) - { - m_play_non_loop = false; - this->setAnimation(AF_DEFAULT); - } - // Update the speed-weighted objects' animations if (m_kart != NULL) { @@ -1088,6 +1082,15 @@ void KartModel::update(float dt, float distance, float steer, float speed, } } + // If animations are disabled, stop here + if (m_animated_node == NULL) return; + + if (m_play_non_loop && m_animated_node->getLoopMode() == true) + { + m_play_non_loop = false; + this->setAnimation(AF_DEFAULT); + } + // Check if the end animation is being played, if so, don't // play steering animation. if(m_current_animation!=AF_DEFAULT) return;