fixed rescuing
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/trunk/supertuxkart@2304 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
019eaca2cf
commit
8d48875044
22
src/kart.cpp
22
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
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
@ -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;
|
||||
}
|
@ -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'
|
||||
|
@ -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();
|
||||
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user