From 6dd109dab0f7db190cb55e8d071cbe750867b83c Mon Sep 17 00:00:00 2001 From: deveee Date: Sat, 26 Oct 2013 09:33:41 +0000 Subject: [PATCH] Smooth rotating when skidding was stopped. git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@14310 178a84e3-b1eb-0310-8ba1-8eac791a3b58 --- src/karts/skidding.cpp | 22 +++++++++++++++++++++- src/karts/skidding.hpp | 5 +++-- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/src/karts/skidding.cpp b/src/karts/skidding.cpp index 4b5ff45e0..79b59683c 100644 --- a/src/karts/skidding.cpp +++ b/src/karts/skidding.cpp @@ -115,6 +115,16 @@ void Skidding::updateSteering(float steer, float dt) m_visual_rotation = f; } break; + case SKID_BREAK: + m_real_steering = steer; + if (m_visual_rotation > 0.05f) m_visual_rotation -= 0.05; + else if (m_visual_rotation < -0.05f) m_visual_rotation += 0.05; + else + { + m_visual_rotation = 0; + reset(); + } + break; case SKID_ACCUMULATE_RIGHT: { float f = (1.0f+steer)*0.5f; // map [-1,1] --> [0, 1] @@ -139,6 +149,8 @@ void Skidding::updateSteering(float steer, float dt) m_visual_rotation = m_skid_visual * m_real_steering; break; } + + } // switch m_skid_state } // updateSteering @@ -160,6 +172,7 @@ float Skidding::getSteeringWhenSkidding(float steering) const case SKID_OLD: assert(false); break; case SKID_SHOW_GFX_LEFT: case SKID_SHOW_GFX_RIGHT: + case SKID_BREAK: case SKID_NONE: return steering; break; case SKID_ACCUMULATE_RIGHT: @@ -201,7 +214,9 @@ void Skidding::update(float dt, bool is_on_ground, // No skidding backwards or while stopped if(m_kart->getSpeed() < 0.001f) { - reset(); + m_skid_state = SKID_BREAK; + m_kart->getKartGFX()->setCreationRateAbsolute(KartGFX::KGFX_SKIDL, 0); + m_kart->getKartGFX()->setCreationRateAbsolute(KartGFX::KGFX_SKIDR, 0); } m_skid_bonus_ready = false; @@ -337,6 +352,11 @@ void Skidding::update(float dt, bool is_on_ground, #endif m_skid_time = 0; // fallthrough } + case SKID_BREAK: + { + updateSteering(steering, dt); + break; + } case SKID_ACCUMULATE_LEFT: case SKID_ACCUMULATE_RIGHT: { diff --git a/src/karts/skidding.hpp b/src/karts/skidding.hpp index d2feaf19e..734b53e70 100644 --- a/src/karts/skidding.hpp +++ b/src/karts/skidding.hpp @@ -81,10 +81,11 @@ public: * SKID_ACCUMULATE_RIGHT: Similar for turning right * SKID_SHOW_GFX_LEFT: Shows the gfx, while the bonus is active, * and the kart was turning left. - * SKID_SHOW_GFX_RIGHT: Similar for turning right. */ + * SKID_SHOW_GFX_RIGHT: Similar for turning right. + * SKID_BREAK: Skidding was stopped without bonus */ enum SkidState {SKID_OLD, SKID_NONE, SKID_ACCUMULATE_LEFT, SKID_ACCUMULATE_RIGHT, SKID_SHOW_GFX_LEFT, - SKID_SHOW_GFX_RIGHT} ; + SKID_SHOW_GFX_RIGHT, SKID_BREAK} ; private: /** The current skidding state. */