Merge branch 'Fix_3167_attempt'
This commit is contained in:
commit
7543240db0
@ -636,8 +636,8 @@ void RubberBall::updateDistanceToTarget()
|
|||||||
const LinearWorld *world = dynamic_cast<LinearWorld*>(World::getWorld());
|
const LinearWorld *world = dynamic_cast<LinearWorld*>(World::getWorld());
|
||||||
|
|
||||||
float target_distance =
|
float target_distance =
|
||||||
world->getDistanceDownTrackForKart(m_target->getWorldKartId());
|
world->getDistanceDownTrackForKart(m_target->getWorldKartId(), true);
|
||||||
float ball_distance = getDistanceFromStart();
|
float ball_distance = getDistanceFromStart(true);
|
||||||
|
|
||||||
m_distance_to_target = target_distance - ball_distance;
|
m_distance_to_target = target_distance - ball_distance;
|
||||||
if(m_distance_to_target < 0)
|
if(m_distance_to_target < 0)
|
||||||
|
@ -94,7 +94,7 @@ float MainLoop::getLimitedDt()
|
|||||||
{
|
{
|
||||||
Log::verbose("fps", "time %f distance %f dt %f fps %f",
|
Log::verbose("fps", "time %f distance %f dt %f fps %f",
|
||||||
lw->getTime(),
|
lw->getTime(),
|
||||||
lw->getDistanceDownTrackForKart(0),
|
lw->getDistanceDownTrackForKart(0, true),
|
||||||
dt*0.001f, 1000.0f / dt);
|
dt*0.001f, 1000.0f / dt);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -108,7 +108,7 @@ void LinearWorld::reset()
|
|||||||
for(unsigned int i=0; i<kart_amount; i++)
|
for(unsigned int i=0; i<kart_amount; i++)
|
||||||
{
|
{
|
||||||
m_distance_increase = std::min(m_distance_increase,
|
m_distance_increase = std::min(m_distance_increase,
|
||||||
getDistanceDownTrackForKart(i));
|
getDistanceDownTrackForKart(i, false));
|
||||||
}
|
}
|
||||||
// Track length - minimum distance is how much the track length must
|
// Track length - minimum distance is how much the track length must
|
||||||
// be increased to avoid negative values in estimateFinishTimeForKart
|
// be increased to avoid negative values in estimateFinishTimeForKart
|
||||||
@ -190,7 +190,7 @@ void LinearWorld::update(float dt)
|
|||||||
getTrackSector(n)->update(kart->getFrontXYZ());
|
getTrackSector(n)->update(kart->getFrontXYZ());
|
||||||
kart_info.m_overall_distance = kart_info.m_race_lap
|
kart_info.m_overall_distance = kart_info.m_race_lap
|
||||||
* Track::getCurrentTrack()->getTrackLength()
|
* Track::getCurrentTrack()->getTrackLength()
|
||||||
+ getDistanceDownTrackForKart(kart->getWorldKartId());
|
+ getDistanceDownTrackForKart(kart->getWorldKartId(), true);
|
||||||
} // for n
|
} // for n
|
||||||
|
|
||||||
// Update all positions. This must be done after _all_ karts have
|
// Update all positions. This must be done after _all_ karts have
|
||||||
@ -279,7 +279,7 @@ void LinearWorld::newLap(unsigned int kart_index)
|
|||||||
m_kart_info[kart_index].m_overall_distance =
|
m_kart_info[kart_index].m_overall_distance =
|
||||||
m_kart_info[kart_index].m_race_lap
|
m_kart_info[kart_index].m_race_lap
|
||||||
* Track::getCurrentTrack()->getTrackLength()
|
* Track::getCurrentTrack()->getTrackLength()
|
||||||
+ getDistanceDownTrackForKart(kart->getWorldKartId());
|
+ getDistanceDownTrackForKart(kart->getWorldKartId(), true);
|
||||||
}
|
}
|
||||||
// Last lap message (kart_index's assert in previous block already)
|
// Last lap message (kart_index's assert in previous block already)
|
||||||
if (raceHasLaps() && kart_info.m_race_lap+1 == lap_count)
|
if (raceHasLaps() && kart_info.m_race_lap+1 == lap_count)
|
||||||
@ -388,9 +388,9 @@ void LinearWorld::newLap(unsigned int kart_index)
|
|||||||
* crossing the start line..
|
* crossing the start line..
|
||||||
* \param kart_id Index of the kart.
|
* \param kart_id Index of the kart.
|
||||||
*/
|
*/
|
||||||
float LinearWorld::getDistanceDownTrackForKart(const int kart_id) const
|
float LinearWorld::getDistanceDownTrackForKart(const int kart_id, bool account_for_checklines) const
|
||||||
{
|
{
|
||||||
return getTrackSector(kart_id)->getDistanceFromStart();
|
return getTrackSector(kart_id)->getDistanceFromStart(account_for_checklines);
|
||||||
} // getDistanceDownTrackForKart
|
} // getDistanceDownTrackForKart
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
@ -114,7 +114,7 @@ public:
|
|||||||
virtual ~LinearWorld();
|
virtual ~LinearWorld();
|
||||||
|
|
||||||
virtual void update(float delta) OVERRIDE;
|
virtual void update(float delta) OVERRIDE;
|
||||||
float getDistanceDownTrackForKart(const int kart_id) const;
|
float getDistanceDownTrackForKart(const int kart_id, bool account_for_checklines) const;
|
||||||
float getDistanceToCenterForKart(const int kart_id) const;
|
float getDistanceToCenterForKart(const int kart_id) const;
|
||||||
float getEstimatedFinishTime(const int kart_id) const;
|
float getEstimatedFinishTime(const int kart_id) const;
|
||||||
int getLapForKart(const int kart_id) const;
|
int getLapForKart(const int kart_id) const;
|
||||||
|
@ -770,7 +770,7 @@ void RaceGUIBase::drawGlobalPlayerIcons(int bottom_margin)
|
|||||||
{
|
{
|
||||||
LinearWorld *linear_world = (LinearWorld*)(World::getWorld());
|
LinearWorld *linear_world = (LinearWorld*)(World::getWorld());
|
||||||
|
|
||||||
float distance = linear_world->getDistanceDownTrackForKart(kart_id)
|
float distance = linear_world->getDistanceDownTrackForKart(kart_id, true)
|
||||||
+ Track::getCurrentTrack()->getTrackLength()*lap;
|
+ Track::getCurrentTrack()->getTrackLength()*lap;
|
||||||
if ((position>1) &&
|
if ((position>1) &&
|
||||||
(previous_distance-distance<m_dist_show_overlap) &&
|
(previous_distance-distance<m_dist_show_overlap) &&
|
||||||
|
@ -69,7 +69,7 @@ bool CheckLap::isTriggered(const Vec3 &old_pos, const Vec3 &new_pos,
|
|||||||
// has check defined.
|
// has check defined.
|
||||||
if(!lin_world)
|
if(!lin_world)
|
||||||
return false;
|
return false;
|
||||||
float current_distance = lin_world->getDistanceDownTrackForKart(kart_index);
|
float current_distance = lin_world->getDistanceDownTrackForKart(kart_index, false);
|
||||||
bool result = (m_previous_distance[kart_index]>0.95f*track_length &&
|
bool result = (m_previous_distance[kart_index]>0.95f*track_length &&
|
||||||
current_distance<7.0f);
|
current_distance<7.0f);
|
||||||
|
|
||||||
|
@ -68,35 +68,37 @@ void TrackSector::update(const Vec3 &xyz, bool ignore_vertical)
|
|||||||
|
|
||||||
// If m_track_sector == UNKNOWN_SECTOR, then the kart is not on top of
|
// If m_track_sector == UNKNOWN_SECTOR, then the kart is not on top of
|
||||||
// the road, so we have to use search for the closest graph node.
|
// the road, so we have to use search for the closest graph node.
|
||||||
if(m_current_graph_node == Graph::UNKNOWN_SECTOR)
|
if (m_current_graph_node == Graph::UNKNOWN_SECTOR)
|
||||||
{
|
{
|
||||||
m_current_graph_node = Graph::get()->findOutOfRoadSector(xyz,
|
m_current_graph_node = Graph::get()->findOutOfRoadSector(xyz,
|
||||||
prev_sector, test_nodes, ignore_vertical);
|
prev_sector, test_nodes, ignore_vertical);
|
||||||
|
}
|
||||||
|
|
||||||
// ArenaGraph (battle and soccer mode) doesn't need the code below
|
// ArenaGraph (battle and soccer mode) doesn't need the code below
|
||||||
if (ag) return;
|
if (ag) return;
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (ag) return;
|
|
||||||
// keep the current quad as the latest valid one IF the player has one
|
// keep the current quad as the latest valid one IF the player has one
|
||||||
// of the required checklines
|
// of the required checklines
|
||||||
const DriveNode* dn = DriveGraph::get()->getNode(m_current_graph_node);
|
const DriveNode* dn = DriveGraph::get()->getNode(m_current_graph_node);
|
||||||
const std::vector<int>& checkline_requirements = dn->getChecklineRequirements();
|
const std::vector<int>& checkline_requirements = dn->getChecklineRequirements();
|
||||||
|
|
||||||
|
bool isValidQuad = false;
|
||||||
if (checkline_requirements.size() == 0)
|
if (checkline_requirements.size() == 0)
|
||||||
{
|
{
|
||||||
|
isValidQuad = true;
|
||||||
|
if (m_on_road)
|
||||||
m_last_valid_graph_node = m_current_graph_node;
|
m_last_valid_graph_node = m_current_graph_node;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//bool has_prerequisite = false;
|
|
||||||
|
|
||||||
for (unsigned int i=0; i<checkline_requirements.size(); i++)
|
for (unsigned int i=0; i<checkline_requirements.size(); i++)
|
||||||
{
|
{
|
||||||
if (m_last_triggered_checkline == checkline_requirements[i])
|
if (m_last_triggered_checkline == checkline_requirements[i])
|
||||||
{
|
{
|
||||||
//has_prerequisite = true;
|
//has_prerequisite = true;
|
||||||
|
if (m_on_road)
|
||||||
m_last_valid_graph_node = m_current_graph_node;
|
m_last_valid_graph_node = m_current_graph_node;
|
||||||
|
isValidQuad = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -104,12 +106,17 @@ void TrackSector::update(const Vec3 &xyz, bool ignore_vertical)
|
|||||||
// TODO: show a message when we detect a user cheated.
|
// TODO: show a message when we detect a user cheated.
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Now determine the 'track' coords, i.e. ow far from the start of the
|
// Now determine the 'track' coords, i.e. ow far from the start of the
|
||||||
// track, and how far to the left or right of the center driveline.
|
// track, and how far to the left or right of the center driveline.
|
||||||
DriveGraph::get()->spatialToTrack(&m_current_track_coords, xyz,
|
DriveGraph::get()->spatialToTrack(&m_current_track_coords, xyz,
|
||||||
m_current_graph_node);
|
m_current_graph_node);
|
||||||
|
|
||||||
|
if (m_last_valid_graph_node != Graph::UNKNOWN_SECTOR)
|
||||||
|
{
|
||||||
|
DriveGraph::get()->spatialToTrack(&m_latest_valid_track_coords, xyz,
|
||||||
|
m_last_valid_graph_node);
|
||||||
|
}
|
||||||
} // update
|
} // update
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
@ -48,6 +48,8 @@ private:
|
|||||||
* of the center driveline. */
|
* of the center driveline. */
|
||||||
Vec3 m_current_track_coords;
|
Vec3 m_current_track_coords;
|
||||||
|
|
||||||
|
Vec3 m_latest_valid_track_coords;
|
||||||
|
|
||||||
/** True if the object is on the road (driveline), or not. */
|
/** True if the object is on the road (driveline), or not. */
|
||||||
bool m_on_road;
|
bool m_on_road;
|
||||||
|
|
||||||
@ -61,7 +63,13 @@ public:
|
|||||||
float getRelativeDistanceToCenter() const;
|
float getRelativeDistanceToCenter() const;
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
/** Returns how far the the object is from the start line. */
|
/** Returns how far the the object is from the start line. */
|
||||||
float getDistanceFromStart() const { return m_current_track_coords.getZ();}
|
float getDistanceFromStart(bool account_for_checklines) const
|
||||||
|
{
|
||||||
|
if (account_for_checklines)
|
||||||
|
return m_latest_valid_track_coords.getZ();
|
||||||
|
else
|
||||||
|
return m_current_track_coords.getZ();
|
||||||
|
}
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
/** Returns the distance to the centre driveline. */
|
/** Returns the distance to the centre driveline. */
|
||||||
float getDistanceToCenter() const { return m_current_track_coords.getX(); }
|
float getDistanceToCenter() const { return m_current_track_coords.getX(); }
|
||||||
|
Loading…
x
Reference in New Issue
Block a user