From 20603a208448118de46c19085537ca06aaba1cf2 Mon Sep 17 00:00:00 2001 From: hiker <henrichsjoerg@gmail.com> Date: Wed, 23 Jul 2014 07:59:47 +1000 Subject: [PATCH] Try better computation of heading (which might be better if the kart is not in the xz plane). --- src/karts/moveable.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/karts/moveable.cpp b/src/karts/moveable.cpp index 84f5d17e0..f85474a69 100644 --- a/src/karts/moveable.cpp +++ b/src/karts/moveable.cpp @@ -129,8 +129,8 @@ void Moveable::update(float dt) if(m_body->getInvMass()!=0) m_motion_state->getWorldTransform(m_transform); m_velocityLC = getVelocity()*m_transform.getBasis(); - Vec3 forw_vec = m_transform.getBasis().getColumn(0); - m_heading = -atan2f(forw_vec.getZ(), forw_vec.getX()); + Vec3 forw_vec = m_transform.getBasis().getColumn(2); + m_heading = atan2f(forw_vec.getX(), forw_vec.getZ()); // The pitch in hpr is in between -pi and pi. But for the camera it // must be restricted to -pi/2 and pi/2 - so recompute it by restricting