Moved check_structure detection from center of kart to the front

of the kart (which will work better for a photo finish). Hopefully
no other side effect.
This commit is contained in:
hiker 2014-07-28 09:52:44 +10:00
parent 992c97258f
commit 425675bdac
5 changed files with 19 additions and 2 deletions

View File

@ -157,6 +157,10 @@ public:
/** Returns true if this kart has no wheels. */
bool isWheeless() const;
// ------------------------------------------------------------------------
/** Returns the coordinates of the front of the kart. This is used for
* determining when the lap line is crossed. */
virtual const Vec3& getFrontXYZ() const = 0;
// ------------------------------------------------------------------------
/** Returns the position of a wheel relative to the kart.
* \param i Index of the wheel: 0=front right, 1 = front left, 2 = rear
* right, 3 = rear left. */

View File

@ -408,6 +408,8 @@ void Kart::reset()
m_skidmarks->adjustFog(track->isFogEnabled() );
}
Vec3 front(0, 0, getKartLength()*0.5f);
m_xyz_front = getTrans()(front);
m_terrain_info->update(getTrans());
@ -1190,6 +1192,9 @@ void Kart::update(float dt)
m_body->getBroadphaseHandle()->m_collisionFilterGroup = 0;
}
Vec3 front(0, 0, getKartLength()*0.5f);
m_xyz_front = getTrans()(front);
m_terrain_info->update(getTrans(), epsilon);
if(m_body->getBroadphaseHandle())
{

View File

@ -102,6 +102,10 @@ private:
/** Current race position (1-num_karts). */
int m_race_position;
/** The coordinates of the front of the kart, used to determine when a
* new lap is triggered. */
Vec3 m_xyz_front;
/** True if the kart is eliminated. */
bool m_eliminated;
@ -292,6 +296,10 @@ public:
/** Returns the current position of this kart in the race. */
virtual int getPosition () const { return m_race_position; }
// ------------------------------------------------------------------------
/** Returns the coordinates of the front of the kart. This is used for
* determining when the lap line is crossed. */
virtual const Vec3& getFrontXYZ() const { return m_xyz_front; }
// ------------------------------------------------------------------------
/** Returns the initial position of this kart. */
virtual int getInitialPosition () const { return m_initial_position; }
// ------------------------------------------------------------------------

View File

@ -174,7 +174,7 @@ void LinearWorld::update(float dt)
// rescued or eliminated
if(kart->getKartAnimation()) continue;
kart_info.getTrackSector()->update(kart->getXYZ());
kart_info.getTrackSector()->update(kart->getFrontXYZ());
kart_info.m_overall_distance = kart_info.m_race_lap
* m_track->getTrackLength()
+ getDistanceDownTrackForKart(kart->getWorldKartId());

View File

@ -100,7 +100,7 @@ void CheckStructure::update(float dt)
World *world = World::getWorld();
for(unsigned int i=0; i<world->getNumKarts(); i++)
{
const Vec3 &xyz = world->getKart(i)->getXYZ();
const Vec3 &xyz = world->getKart(i)->getFrontXYZ();
if(world->getKart(i)->getKartAnimation()) continue;
// Only check active checklines.
if(m_is_active[i] && isTriggered(m_previous_position[i], xyz, i))