fixed karts beginning in front of start line by calculating offset from drivelines instead of using arbitrary values

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/trunk/supertuxkart@2668 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
auria
2008-12-13 21:20:21 +00:00
parent c1df016b09
commit 6cd5a152b9
3 changed files with 10 additions and 5 deletions

View File

@@ -253,6 +253,7 @@ void LinearWorld::doLapCounting ( KartInfo& kart_info, Kart* kart )
{
setTimeAtLapForKart( RaceManager::getWorld()->getTime(), kart->getWorldKartId() );
kart_info.m_race_lap++ ;
printf("lap = %i\n", kart_info.m_race_lap);
}
// Race finished
if(kart_info.m_race_lap >= race_manager->getNumLaps() &&

View File

@@ -435,13 +435,17 @@ btTransform Track::getStartTransform(unsigned int pos) const
}
else
{
// Bug fix/workaround: sometimes the first kart would be too close
// sometimes the first kart would be too close
// to the first driveline point and not to the last one -->
// This kart would not get any lap counting done in the first
// lap! Therefor -1.5 is subtracted from the y position - which
// is a somewhat arbitrary value.
// lap! Therefore an offset is substracted from its Y location,
// and this offset is calculated based on the drivelines
float offset = 1.5f;
if(m_left_driveline[0].getY() > 0 || m_right_driveline[0].getY() > 0)
offset += std::max(m_left_driveline[0].getY(), m_left_driveline[0].getY());
orig.setX( pos<m_start_x.size() ? m_start_x[pos] : ((pos%2==0)?1.5f:-1.5f) );
orig.setY( pos<m_start_y.size() ? m_start_y[pos] : -1.5f*pos-1.5f );
orig.setY( pos<m_start_y.size() ? m_start_y[pos] : -1.5f*pos-offset );
orig.setZ( pos<m_start_z.size() ? m_start_z[pos] : 1.0f );
}
btTransform start;

View File

@@ -106,7 +106,7 @@ public:
std::vector<Vec3> m_start_positions;
//Left and Right drivelines for overhead map rendering.
//(Should probably be private as they are only use internally right now)
//(Should probably be private as they are only used internally right now)
std::vector<Vec3> m_left_driveline;
std::vector<Vec3> m_right_driveline;