From 2a671b0e775f3888448a96d29c3115d919b4a093 Mon Sep 17 00:00:00 2001 From: hikerstk Date: Fri, 19 Mar 2010 10:37:51 +0000 Subject: [PATCH] Added separate roll computation, which fixes issues with the upright constraint, and might also fix steering issues on slopes. git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@5031 178a84e3-b1eb-0310-8ba1-8eac791a3b58 --- src/karts/kart_properties.cpp | 8 ++++---- src/karts/moveable.cpp | 1 + src/karts/moveable.hpp | 5 +++++ src/physics/btUprightConstraint.cpp | 3 +-- 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/karts/kart_properties.cpp b/src/karts/kart_properties.cpp index 01b873bcb..1e215f2b0 100644 --- a/src/karts/kart_properties.cpp +++ b/src/karts/kart_properties.cpp @@ -42,10 +42,10 @@ float KartProperties::UNDEFINED = -99.9f; */ KartProperties::KartProperties(const std::string &filename) : m_icon_material(0) { - m_name = "Tux"; - m_ident = "tux"; - m_icon_file = "tuxicon.png"; - m_shadow_file = "generickartshadow.png"; + m_name = "NONAME"; + m_ident = "NONAME"; + m_icon_file = ""; + m_shadow_file = ""; m_groups.clear(); m_custom_sfx_id.resize(SFXManager::NUM_CUSTOMS); diff --git a/src/karts/moveable.cpp b/src/karts/moveable.cpp index 3c264895a..d3e847dd4 100644 --- a/src/karts/moveable.cpp +++ b/src/karts/moveable.cpp @@ -106,6 +106,7 @@ void Moveable::update(float dt) // y to positive values, i.e. no pitch of more than pi/2. Vec3 up = getTrans().getBasis().getColumn(1); m_pitch = atan2(up.getZ(), fabsf(up.getY())); + m_roll = atan2(up.getX(), up.getY()); updateGraphics(Vec3(0,0,0), btQuaternion(0, 0, 0, 1)); m_first_time = false ; diff --git a/src/karts/moveable.hpp b/src/karts/moveable.hpp index 60a7d4012..680fb1f0b 100644 --- a/src/karts/moveable.hpp +++ b/src/karts/moveable.hpp @@ -48,6 +48,8 @@ private: float m_heading; /** The pitch between -90 and 90 degrees. */ float m_pitch; + /** The roll between -180 and 180 degrees. */ + float m_roll; protected: UserPointer m_user_pointer; @@ -79,6 +81,9 @@ public: /** Returns the pitch of the kart, restricted to between -90 and 90 degrees. * Note that using getHPR().getPitch can result in a different value! */ float getPitch() const {return m_pitch; } + /** Returns the roll of the kart between -180 and 180 degrees. Note that + * using getHPR.getRoll can result in a different value! */ + float getRoll() const {return m_roll; } const btQuaternion getRotation() const {return m_transform.getRotation(); } diff --git a/src/physics/btUprightConstraint.cpp b/src/physics/btUprightConstraint.cpp index 305630c84..3792f8df1 100644 --- a/src/physics/btUprightConstraint.cpp +++ b/src/physics/btUprightConstraint.cpp @@ -120,8 +120,7 @@ void btUprightConstraint::buildJacobian() btTransform worldTransform = m_rbA.getCenterOfMassTransform() * m_frameInA; btVector3 upAxis = worldTransform.getBasis().getColumn(2); m_limit[ 0 ].m_angle = m_kart->getPitch(); - m_limit[ 1 ].m_angle = m_kart->getHPR().getRoll(); - + m_limit[ 1 ].m_angle = m_kart->getRoll(); for ( int i = 0; i < 2; i++ ) { new (&m_jacAng[ i ]) btJacobianEntry( m_limit[ i ].m_axis,