1) Bugfix: rescuing kart (at least) in the startrack would

trigger a rescue loop: rescue, drop, rescue, drop, ...
2) Some code cleanup.


git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/trunk/supertuxkart@1394 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
hikerstk 2008-01-15 11:38:54 +00:00
parent 9202ccf00f
commit bf4ee7a970
6 changed files with 17 additions and 26 deletions

View File

@ -37,21 +37,11 @@
enum WidgetTokens
{
WTOK_RACER0,
WTOK_RACER1,
WTOK_RACER2,
WTOK_RACER3,
WTOK_RACER4,
WTOK_RACER5,
WTOK_RACER6,
WTOK_RACER7,
WTOK_RACER8,
WTOK_RACER9,
WTOK_TITLE,
WTOK_NAME,
WTOK_QUIT
WTOK_QUIT,
WTOK_RACER0
};
CharSel::CharSel(int whichPlayer)

View File

@ -31,8 +31,6 @@ class HighscoreManager
{
public:
private:
static const int HIGHSCORE_LEN = 3; // It's a top 3 list
typedef std::vector<Highscores*> type_all_scores;
type_all_scores m_allScores;

View File

@ -376,6 +376,8 @@ void Kart::reset()
world->m_track->spatialToTrack( m_curr_track_coords, m_curr_pos.xyz,
m_track_sector );
m_vehicle->applyEngineForce (0.0f, 2);
m_vehicle->applyEngineForce (0.0f, 3);
// Set heading:
m_transform.setRotation(btQuaternion(btVector3(0.0f, 0.0f, 1.0f),
DEGREE_TO_RAD(m_reset_pos.hpr[0])) );
@ -383,8 +385,6 @@ void Kart::reset()
m_transform.setOrigin(btVector3(m_reset_pos.xyz[0],
m_reset_pos.xyz[1],
m_reset_pos.xyz[2]+0.5f*m_kart_height));
m_vehicle->applyEngineForce (0.0f, 2);
m_vehicle->applyEngineForce (0.0f, 3);
m_body->setCenterOfMassTransform(m_transform);
m_body->setLinearVelocity (btVector3(0.0f,0.0f,0.0f));
m_body->setAngularVelocity(btVector3(0.0f,0.0f,0.0f));
@ -575,7 +575,8 @@ void Kart::update (float dt)
}
m_curr_pos.xyz[2] += rescue_height*dt/rescue_time;
m_transform.setOrigin(btVector3(m_curr_pos.xyz[0],m_curr_pos.xyz[1],m_curr_pos.xyz[2]));
m_transform.setOrigin(btVector3(m_curr_pos.xyz[0],m_curr_pos.xyz[1],
m_curr_pos.xyz[2]));
btQuaternion q_roll (btVector3(0.f, 1.f, 0.f),
-m_rescue_roll*dt/rescue_time*M_PI/180.0f);
btQuaternion q_pitch(btVector3(1.f, 0.f, 0.f),
@ -916,7 +917,6 @@ void Kart::endRescue()
m_curr_pos.hpr[0] = world->m_track->m_angle[m_track_sector] ;
m_rescue = false ;
world->getPhysics()->addKart(this, m_vehicle);
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
@ -924,14 +924,18 @@ void Kart::endRescue()
// 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??
btTransform pos=m_body->getCenterOfMassTransform();
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(btVector3(m_curr_pos.xyz[0],m_curr_pos.xyz[1],
m_curr_pos.xyz[2]+0.5f*m_kart_height));
m_curr_pos.xyz[2]+0.5f*m_kart_height+0.1f));
pos.setRotation(btQuaternion(btVector3(0.0f, 0.0f, 1.0f),
DEGREE_TO_RAD(world->m_track->m_angle[m_track_sector])));
m_body->setCenterOfMassTransform(pos);
world->getPhysics()->addKart(this, m_vehicle);
setTrans(pos);
} // endRescue
//-----------------------------------------------------------------------------

View File

@ -82,7 +82,6 @@ void Moveable::createBody(float mass, btTransform& trans,
UserPointer::UserPointerType t) {
btVector3 inertia;
m_transform = trans;
shape->calculateLocalInertia(mass, inertia);
m_motion_state = new btDefaultMotionState(trans);
@ -155,7 +154,7 @@ void Moveable::update (float dt)
sgCopyCoord(&(m_history_position[history->GetCurrentIndex()]), &m_curr_pos);
}
} // if m_history_position
m_velocityLC = getVelocity()*getTrans().getBasis();
placeModel();
m_first_time = false ;

View File

@ -82,8 +82,9 @@ public:
void createBody(float mass, btTransform& trans,
btCollisionShape *shape,
UserPointer::UserPointerType t);
const btTransform& getTrans () const {return m_transform;}
void setTrans (btTransform& t){m_motion_state->setWorldTransform(t);}
//void getTrans (btTransform& t) const {m_motion_state->getWorldTransform(t);}
const btTransform& getTrans() const {return m_transform;}
void setTrans (btTransform& t){m_transform=t;m_motion_state->setWorldTransform(t);}
}
; // class Moveable

View File

@ -83,7 +83,6 @@ void Spark::update(float dt)
{ // spark lost energy (less than 80%), i.e. it's too slow - speed it up:
if(vlen==0.0f) {
v = btVector3(.5f, .5f, .5f); // avoid 0 div.
vlen = 0.75;
}
else
{