From 15c26079f175fc4d6eb7f1f89c96818d2de09ecb Mon Sep 17 00:00:00 2001 From: hikerstk Date: Wed, 6 Nov 2013 06:22:51 +0000 Subject: [PATCH] Raise karts somewhat when they are leaning (otherwise the karts will be partially inside of the track). Some dead code removal. git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@14394 178a84e3-b1eb-0310-8ba1-8eac791a3b58 --- src/karts/kart.cpp | 12 ++++++++---- src/karts/kart_model.cpp | 23 +---------------------- 2 files changed, 9 insertions(+), 26 deletions(-) diff --git a/src/karts/kart.cpp b/src/karts/kart.cpp index 9e9783a5f..492086311 100644 --- a/src/karts/kart.cpp +++ b/src/karts/kart.cpp @@ -2400,10 +2400,9 @@ void Kart::updateGraphics(float dt, const Vec3& offset_xyz, Vec3 center_shift = m_kart_properties->getGravityCenterShift(); - float y = m_kart_model->getWheelGraphicsRadius(0) - - m_vehicle->getWheelInfo(0).m_wheelsRadius - + m_skidding->getGraphicalJumpOffset(); - center_shift.setY(y); + float kart_y_offset = m_kart_model->getWheelGraphicsRadius(0) + - m_vehicle->getWheelInfo(0).m_wheelsRadius + + m_skidding->getGraphicalJumpOffset(); if ((m_controls.m_nitro || m_min_nitro_time > 0.0f) && isOnGround() && m_collected_energy > 0) { @@ -2487,6 +2486,11 @@ void Kart::updateGraphics(float dt, const Vec3& offset_xyz, } } + // If the kart is leaning, part of the kart might end up 'in' the track. + // To avoid this, raise the kart enough to offset the leaning. + float lean_height = tan(fabsf(m_current_lean)) * getKartWidth()*0.5f; + + center_shift.setY(kart_y_offset + lean_height); float heading = m_skidding->getVisualSkidRotation(); Moveable::updateGraphics(dt, center_shift, btQuaternion(heading, 0, m_current_lean)); diff --git a/src/karts/kart_model.cpp b/src/karts/kart_model.cpp index 8b757eb67..60d6a8d34 100644 --- a/src/karts/kart_model.cpp +++ b/src/karts/kart_model.cpp @@ -742,28 +742,7 @@ void KartModel::OnAnimationEnd(scene::IAnimatedMeshSceneNode *node) */ void KartModel::update(float dt, float rotation_dt, float steer, const float suspension[4], float speed) { - float clamped_suspension[4]; - // Clamp suspension to minimum and maximum suspension length, so that - // the graphical wheel models don't look too wrong. - for(unsigned int i=0; i<4; i++) - { - const float suspension_length = (m_max_suspension[i]-m_min_suspension[i])/2; - - // limit amplitude between set limits, first dividing it by a - // somewhat arbitrary constant to reduce visible wheel movement - clamped_suspension[i] = suspension[i]/m_dampen_suspension_amplitude[i]; - float ratio = clamped_suspension[i] / suspension_length; - const int sign = ratio < 0 ? -1 : 1; - // expanded form of 1 - (1 - x)^2, i.e. making suspension display - // quadratic and not linear - ratio = sign * fabsf(ratio*(2-ratio)); -// clamped_suspension[i] = ratio*suspension_length; - clamped_suspension[i] = std::min(std::max(ratio*suspension_length, - m_min_suspension[i]), - m_max_suspension[i]); - } // for i<4 - - core::vector3df wheel_steer(0, steer*30.0f, 0); + core::vector3df wheel_steer(0, steer*30.0f, 0); for(unsigned int i=0; i<4; i++) {