diff --git a/data/stk_config.xml b/data/stk_config.xml index 0c3e9d4c8..0fd9985a4 100644 --- a/data/stk_config.xml +++ b/data/stk_config.xml @@ -183,9 +183,9 @@ which is used to reduce the turn angle used to reduce the turn angle. --> [0, 1] + m_real_steering = m_skid_reduce_turn_min+ + m_skid_reduce_turn_delta*f; + break; + } + case SKID_SHOW_GFX_LEFT: + case SKID_ACCUMULATE_LEFT: + { + float f = (-1.0f+steer)*0.5f; // map [-1,1] --> [-1, 0] + m_real_steering = -m_skid_reduce_turn_min+ + m_skid_reduce_turn_delta*f; + break; + } } // switch m_skid_state - return steering; -} // getSteering + m_visual_rotation = m_skid_visual * m_real_steering; + + float st = fabsf(m_skid_time); + if(st 0 ? SKID_ACCUMULATE_LEFT - : SKID_ACCUMULATE_RIGHT; + // Just testing for the sign of steering can result in unexpected + // beahviour, e.g. if a player is still turning left, but already + // presses right (it will take a few frames for this steering to + // actuallu take place, see player_controller) - the kart would skid + // to the left. So we test for a 'clear enough' steering direction. + if(!skidding || fabsf(steering)<0.3f) break; + m_skid_state = steering > 0 ? SKID_ACCUMULATE_RIGHT + : SKID_ACCUMULATE_LEFT; m_skid_time = 0; // fallthrough case SKID_ACCUMULATE_LEFT: case SKID_ACCUMULATE_RIGHT: @@ -136,14 +176,16 @@ void Skidding::update(float dt, bool is_on_ground, // If at least level 1 bonus is reached, show appropriate gfx if(level>0) m_kart->getKartGFX()->setSkidLevel(level); // If player stops skidding, trigger bonus, and change state to - // SKID_SHOW_GFX + // SKID_SHOW_GFX_* if(!skidding) { - m_skid_state = SKID_SHOW_GFX; + m_skid_state = m_skid_state == SKID_ACCUMULATE_LEFT + ? SKID_SHOW_GFX_LEFT + : SKID_SHOW_GFX_RIGHT; float t = (m_skid_time <= m_skid_visual_time) ? m_skid_time : m_skid_visual_time; - float vso = getVisualSkidOffset(); + float vso = getVisualSkidRotation(); btVector3 rot(0, vso*m_post_skid_rotate_factor, 0); m_kart->getVehicle()->setTimedRotation(t, rot); // skid_time is used to count backwards for the GFX @@ -163,7 +205,8 @@ void Skidding::update(float dt, bool is_on_ground, } break; } // case - case SKID_SHOW_GFX: + case SKID_SHOW_GFX_LEFT: + case SKID_SHOW_GFX_RIGHT: m_skid_time -= dt; if(m_skid_time<=0) { @@ -196,35 +239,3 @@ unsigned int Skidding::getSkidBonus(float *bonus_time, return m_skid_bonus_speed.size(); } // getSkidBonusForce -// ---------------------------------------------------------------------------- -/** Determines how much the graphics model of the kart should be rotated - * additionally (for skidding), depending on how long the kart has been - * skidding etc. - * \return Returns the angle of the additional rotation of the kart. - */ -float Skidding::getVisualSkidOffset() const -{ - float speed = m_kart->getSpeed(); - float steer_percent = m_kart->getSteerPercent(); - float current_max_speed = m_kart->getCurrentMaxSpeed(); - if(m_skid_visual_time==0) - { - float speed_ratio = speed / current_max_speed; - float r = m_skid_factor / m_skid_max; - return steer_percent * speed_ratio * r; - } - - // New skidding code - float f = m_skid_visual * steer_percent; - //if(m_kart->getSpeed() < m_kart->getKartProperties()->getMaxSpeed()) - // f *= m_kart->getSpeed()/m_kart->getKartProperties()->getMaxSpeed(); - - float st = fabsf(m_skid_time); - if(st1.0f; } + // ---------------------------------------------------------------------- + /** Returns the steering fraction to be used by the physics. This is + * a fraction of the maximum steering angle ( so in [-1, 1]). */ + float getSteeringFraction() { return m_real_steering; } }; // Skidding diff --git a/src/karts/skidding_properties.hpp b/src/karts/skidding_properties.hpp index 2d6c89f3c..5de6bad9c 100644 --- a/src/karts/skidding_properties.hpp +++ b/src/karts/skidding_properties.hpp @@ -131,7 +131,6 @@ public: float getSkidReduceTurnMax () const { return m_skid_reduce_turn_max; } - }; // SkiddingProperties