From 71994c692f939ac6453dde1222f8de1f93693d9a Mon Sep 17 00:00:00 2001 From: hiker Date: Thu, 27 Nov 2014 22:34:04 +1100 Subject: [PATCH] Fixed replay mode. --- src/karts/kart_model.cpp | 21 +++++++++++++-------- src/karts/skidding.cpp | 5 ++++- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/src/karts/kart_model.cpp b/src/karts/kart_model.cpp index 3f44f062c..50a0a78a1 100644 --- a/src/karts/kart_model.cpp +++ b/src/karts/kart_model.cpp @@ -29,6 +29,7 @@ #include "io/file_manager.hpp" #include "io/xml_node.hpp" #include "karts/abstract_kart.hpp" +#include "karts/ghost_kart.hpp" #include "karts/kart_properties.hpp" #include "physics/btKart.hpp" #include "utils/constants.hpp" @@ -780,16 +781,20 @@ void KartModel::update(float dt, float rotation_dt, float steer, float speed) for(unsigned int i=0; i<4; i++) { if(!m_wheel_node[i]) continue; - const btWheelInfo &wi = m_kart->getVehicle()->getWheelInfo(i); -#ifdef DEBUG - if(UserConfigParams::m_physics_debug && m_kart) + float rel_suspension = 0; + if (!dynamic_cast(m_kart)) { - // Make wheels that are not touching the ground invisible - m_wheel_node[i]->setVisible(wi.m_raycastInfo.m_isInContact); - } + const btWheelInfo &wi = m_kart->getVehicle()->getWheelInfo(i); +#ifdef DEBUG + if (UserConfigParams::m_physics_debug && m_kart) + { + // Make wheels that are not touching the ground invisible + m_wheel_node[i]->setVisible(wi.m_raycastInfo.m_isInContact); + } #endif - float rel_suspension = wi.m_raycastInfo.m_suspensionLength - - m_default_physics_suspension[i]; + rel_suspension = wi.m_raycastInfo.m_suspensionLength + - m_default_physics_suspension[i]; + } // If the suspension is too compressed if(rel_suspension< m_min_suspension[i]) rel_suspension = m_min_suspension[i]; diff --git a/src/karts/skidding.cpp b/src/karts/skidding.cpp index 4a6060fe5..d3e02d413 100644 --- a/src/karts/skidding.cpp +++ b/src/karts/skidding.cpp @@ -23,6 +23,7 @@ #endif #include "achievements/achievement_info.hpp" #include "config/player_manager.hpp" +#include "karts/ghost_kart.hpp" #include "karts/kart.hpp" #include "karts/kart_gfx.hpp" #include "karts/kart_properties.hpp" @@ -79,7 +80,9 @@ void Skidding::reset() m_kart->getControls().m_skid = KartControl::SC_NONE; btVector3 rot(0, 0, 0); - m_kart->getVehicle()->setTimedRotation(0, rot); + // Only access the vehicle if the kart is not a ghost + if (dynamic_cast(m_kart)==NULL) + m_kart->getVehicle()->setTimedRotation(0, rot); } // reset // ----------------------------------------------------------------------------