From 4ee837b6da84b6527a39e7520317ee192b330c34 Mon Sep 17 00:00:00 2001 From: hikerstk Date: Fri, 25 Jan 2008 01:29:12 +0000 Subject: [PATCH] Fixed wheel rotation, which would not rotate properly when driving close to a parallel to the X axis (and the rotation wasn't computed correctly in any case). git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/trunk/supertuxkart@1416 178a84e3-b1eb-0310-8ba1-8eac791a3b58 --- src/kart.cpp | 14 +++++++------- src/kart.hpp | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/kart.cpp b/src/kart.cpp index 0b6e646f1..91b973169 100644 --- a/src/kart.cpp +++ b/src/kart.cpp @@ -17,8 +17,7 @@ // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - +#include #include #include @@ -151,7 +150,7 @@ Kart::Kart (const KartProperties* kartProperties_, int position_ , m_max_speed_reverse_ratio = m_kart_properties->getMaxSpeedReverseRatio(); m_speed = 0.0f; - m_wheel_position = 0; + m_wheel_rotation = 0; m_wheel_front_l = NULL; m_wheel_front_r = NULL; @@ -348,7 +347,7 @@ void Kart::reset() m_zipper_time_left = 0.0f; m_rescue = false; m_num_herrings_gobbled = 0; - m_wheel_position = 0; + m_wheel_rotation = 0; m_wheelie_angle = 0.0f; m_controls.lr = 0.0f; @@ -556,9 +555,10 @@ void Kart::update (float dt) { m_zipper_time_left = m_zipper_time_left>0.0f ? m_zipper_time_left-dt : 0.0f; - //m_wheel_position gives the rotation around the X-axis, and since velocity's + //m_wheel_rotation gives the rotation around the X-axis, and since velocity's //timeframe is the delta time, we don't have to multiply it with dt. - m_wheel_position += getVelocity().getY(); + m_wheel_rotation += m_speed*dt / m_kart_properties->getWheelRadius(); + m_wheel_rotation=fmodf(m_wheel_rotation, 2*M_PI); if ( m_rescue ) { @@ -1163,7 +1163,7 @@ void Kart::placeModel () sgMat4 wheel_steer; sgMat4 wheel_rot; - sgMakeRotMat4( wheel_rot, 0, -m_wheel_position, 0); + sgMakeRotMat4( wheel_rot, 0, RAD_TO_DEGREE(-m_wheel_rotation), 0); sgMakeRotMat4( wheel_steer, getSteerAngle()/getMaxSteerAngle() * 30.0f , 0, 0); sgMultMat4(wheel_front, wheel_steer, wheel_rot); diff --git a/src/kart.hpp b/src/kart.hpp index 5a1b82bd7..f1a8e025f 100644 --- a/src/kart.hpp +++ b/src/kart.hpp @@ -112,7 +112,7 @@ private: KartParticleSystem* m_smoke_system; ssgTransform* m_exhaust_pipe; - float m_wheel_position; + float m_wheel_rotation; ssgTransform* m_wheel_front_l; ssgTransform* m_wheel_front_r; ssgTransform* m_wheel_rear_l;