diff --git a/src/kart.cpp b/src/kart.cpp index 8ae45e08f..cf604b7fe 100644 --- a/src/kart.cpp +++ b/src/kart.cpp @@ -833,29 +833,15 @@ void Kart::forceRescue() */ void Kart::endRescue() { - RaceManager::getWorld()->moveKartAfterRescue(this); - m_rescue = false ; m_body->setLinearVelocity (btVector3(0.0f,0.0f,0.0f)); m_body->setAngularVelocity(btVector3(0.0f,0.0f,0.0f)); - // FIXME: This code positions the kart correctly back on the track - // (nearest waypoint) - but if the kart is simply upside down, - // it feels better if the kart is left where it was. Perhaps - // this code should only be used if a rescue was not triggered - // by the kart being upside down?? - // FIXME - why is transform set twice? - /* - btTransform pos; - // A certain epsilon is added here to the Z coordinate (0.1), in case - // that the drivelines are somewhat under the track. Otherwise, the - // kart will be placed a little bit under the track, triggering - // a rescue, ... - pos.setOrigin(getXYZ()+btVector3(0, 0, 0.5f*getKartHeight()+0.1f)); - m_body->setCenterOfMassTransform(pos); - */ + + // let the mode decide where to put the kart + RaceManager::getWorld()->moveKartAfterRescue(this, m_body); + RaceManager::getWorld()->getPhysics()->addKart(this, m_vehicle); - //setTrans(pos); } // endRescue //----------------------------------------------------------------------------- diff --git a/src/modes/follow_the_leader.cpp b/src/modes/follow_the_leader.cpp index ac93d9867..2a2635f6e 100644 --- a/src/modes/follow_the_leader.cpp +++ b/src/modes/follow_the_leader.cpp @@ -132,4 +132,5 @@ KartIconDisplayInfo* FollowTheLeaderRace::getKartsDisplayInfo(const RaceGUI* cal { LinearWorld::getKartsDisplayInfo(caller); m_kart_display_info[0].special_title = _("Leader"); + return m_kart_display_info; } \ No newline at end of file diff --git a/src/modes/linear_world.cpp b/src/modes/linear_world.cpp index bf7911b08..3943c01f9 100644 --- a/src/modes/linear_world.cpp +++ b/src/modes/linear_world.cpp @@ -108,15 +108,15 @@ void LinearWorld::update(float delta) // Check if the kart is taking a shortcut (if it's not already doing one): if(!kart->isRescue() && RaceManager::getTrack()->isShortcut(prev_sector, kart_info.m_track_sector)) { - forceRescue(kart, kart_info, /*is rescue*/ true); // bring karts back to where they left the track. + forceRescue(kart, kart_info, /*is shortcut*/ true); // bring karts back to where they left the track. if(kart->isPlayerKart()) { - RaceGUI* m=(RaceGUI*)menu_manager->getRaceMenu(); // Can happen if the option menu is called if(m) m->addMessage(_("Invalid short-cut!!"), kart, 2.0f, 60); } + return; } if (kart_info.m_track_sector == Track::UNKNOWN_SECTOR && !kart->isRescue()) @@ -413,7 +413,7 @@ void LinearWorld::forceRescue(Kart* kart, KartInfo& kart_info, bool shortcut) kart->forceRescue(); } //----------------------------------------------------------------------------- -void LinearWorld::moveKartAfterRescue(Kart* kart) +void LinearWorld::moveKartAfterRescue(Kart* kart, btRigidBody* body) { KartInfo& info = m_kart_info[kart->getWorldKartId()]; @@ -423,6 +423,17 @@ void LinearWorld::moveKartAfterRescue(Kart* kart) btQuaternion heading(btVector3(0.0f, 0.0f, 1.0f), DEGREE_TO_RAD(RaceManager::getTrack()->m_angle[info.m_track_sector]) ); kart->setRotation(heading); + + // A certain epsilon is added here to the Z coordinate (0.1), in case + // that the drivelines are somewhat under the track. Otherwise, the + // kart will be placed a little bit under the track, triggering + // a rescue, ... + btTransform pos; + pos.setOrigin(kart->getXYZ()+btVector3(0, 0, 0.5f*kart->getKartHeight()+0.1f)); + pos.setRotation(btQuaternion(btVector3(0.0f, 0.0f, 1.0f), + DEGREE_TO_RAD(RaceManager::getTrack()->m_angle[info.m_track_sector]))); + + body->setCenterOfMassTransform(pos); } //----------------------------------------------------------------------------- /** Find the position (rank) of 'kart' diff --git a/src/modes/linear_world.hpp b/src/modes/linear_world.hpp index fc05f67d7..122517e4e 100644 --- a/src/modes/linear_world.hpp +++ b/src/modes/linear_world.hpp @@ -78,7 +78,7 @@ public: float getTimeAtLapForKart(const int kart_id) const; virtual KartIconDisplayInfo* getKartsDisplayInfo(const RaceGUI* caller); - virtual void moveKartAfterRescue(Kart* kart); + virtual void moveKartAfterRescue(Kart* kart, btRigidBody* body); virtual void terminateRace(); diff --git a/src/modes/world.hpp b/src/modes/world.hpp index 2cec6625b..3ca63e722 100644 --- a/src/modes/world.hpp +++ b/src/modes/world.hpp @@ -36,6 +36,7 @@ class SFXBase; struct KartIconDisplayInfo; class RaceGUI; +class btRigidBody; /** This class is responsible for running the actual race. A world is created * by the race manager on the start of each race (so a new world is created @@ -201,7 +202,7 @@ public: /** Since each mode will have a different way of deciding where a rescued * kart is dropped, this method will be called and each mode can implement it. */ - virtual void moveKartAfterRescue(Kart* kart) = 0; + virtual void moveKartAfterRescue(Kart* kart, btRigidBody* body) = 0; }; #endif