From dbe4cd02fab4fb69324bc3d08e39b4d24c6cd0a6 Mon Sep 17 00:00:00 2001 From: nixt Date: Fri, 4 Jul 2014 12:43:34 +0530 Subject: [PATCH] First attempt at correcting the rescue animation. --- src/karts/rescue_animation.cpp | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/karts/rescue_animation.cpp b/src/karts/rescue_animation.cpp index a3a660e6c..3a2d7d50f 100644 --- a/src/karts/rescue_animation.cpp +++ b/src/karts/rescue_animation.cpp @@ -45,10 +45,26 @@ RescueAnimation::RescueAnimation(AbstractKart *kart, bool is_auto_rescue) m_kart->getAttachment()->clear(); + // We get the final transform of the kart so that it is rotated + // accordingly during the rescue animation + World * world = World::getWorld(); + unsigned int index = world->getRescuePositionIndex(m_kart); + btTransform t = world->getRescueTransform(index); + Vec3 up = t.getBasis().getColumn(1); + float target_pitch = atan2(up.getZ(), fabsf(up.getY())); + float target_roll = atan2(up.getX(), up.getY()); + + m_curr_rotation.setPitch(m_kart->getPitch()); - m_curr_rotation.setRoll(m_kart->getRoll() ); + m_curr_rotation.setRoll(m_kart->getRoll()); m_curr_rotation.setHeading(0); - m_add_rotation = -m_curr_rotation/m_timer; + + Vec3 required_rotation; + required_rotation.setPitch(target_pitch - m_kart->getPitch()); + required_rotation.setRoll(target_roll - m_kart->getRoll()); + required_rotation.setHeading(0); + m_add_rotation = -required_rotation/m_timer; + m_curr_rotation.setHeading(m_kart->getHeading()); // Add a hit unless it was auto-rescue