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());
|
||||
|
||||
float target_distance =
|
||||
world->getDistanceDownTrackForKart(m_target->getWorldKartId());
|
||||
float ball_distance = getDistanceFromStart();
|
||||
world->getDistanceDownTrackForKart(m_target->getWorldKartId(), true);
|
||||
float ball_distance = getDistanceFromStart(true);
|
||||
|
||||
m_distance_to_target = target_distance - ball_distance;
|
||||
if(m_distance_to_target < 0)
|
||||
|
@ -94,7 +94,7 @@ float MainLoop::getLimitedDt()
|
||||
{
|
||||
Log::verbose("fps", "time %f distance %f dt %f fps %f",
|
||||
lw->getTime(),
|
||||
lw->getDistanceDownTrackForKart(0),
|
||||
lw->getDistanceDownTrackForKart(0, true),
|
||||
dt*0.001f, 1000.0f / dt);
|
||||
}
|
||||
else
|
||||
|
@ -108,7 +108,7 @@ void LinearWorld::reset()
|
||||
for(unsigned int i=0; i<kart_amount; i++)
|
||||
{
|
||||
m_distance_increase = std::min(m_distance_increase,
|
||||
getDistanceDownTrackForKart(i));
|
||||
getDistanceDownTrackForKart(i, false));
|
||||
}
|
||||
// Track length - minimum distance is how much the track length must
|
||||
// be increased to avoid negative values in estimateFinishTimeForKart
|
||||
@ -190,7 +190,7 @@ void LinearWorld::update(float dt)
|
||||
getTrackSector(n)->update(kart->getFrontXYZ());
|
||||
kart_info.m_overall_distance = kart_info.m_race_lap
|
||||
* Track::getCurrentTrack()->getTrackLength()
|
||||
+ getDistanceDownTrackForKart(kart->getWorldKartId());
|
||||
+ getDistanceDownTrackForKart(kart->getWorldKartId(), true);
|
||||
} // for n
|
||||
|
||||
// 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_race_lap
|
||||
* Track::getCurrentTrack()->getTrackLength()
|
||||
+ getDistanceDownTrackForKart(kart->getWorldKartId());
|
||||
+ getDistanceDownTrackForKart(kart->getWorldKartId(), true);
|
||||
}
|
||||
// Last lap message (kart_index's assert in previous block already)
|
||||
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..
|
||||
* \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
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
@ -114,7 +114,7 @@ public:
|
||||
virtual ~LinearWorld();
|
||||
|
||||
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 getEstimatedFinishTime(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());
|
||||
|
||||
float distance = linear_world->getDistanceDownTrackForKart(kart_id)
|
||||
float distance = linear_world->getDistanceDownTrackForKart(kart_id, true)
|
||||
+ Track::getCurrentTrack()->getTrackLength()*lap;
|
||||
if ((position>1) &&
|
||||
(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.
|
||||
if(!lin_world)
|
||||
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 &&
|
||||
current_distance<7.0f);
|
||||
|
||||
|
@ -68,48 +68,55 @@ void TrackSector::update(const Vec3 &xyz, bool ignore_vertical)
|
||||
|
||||
// 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.
|
||||
if(m_current_graph_node == Graph::UNKNOWN_SECTOR)
|
||||
if (m_current_graph_node == Graph::UNKNOWN_SECTOR)
|
||||
{
|
||||
m_current_graph_node = Graph::get()->findOutOfRoadSector(xyz,
|
||||
prev_sector, test_nodes, ignore_vertical);
|
||||
// ArenaGraph (battle and soccer mode) doesn't need the code below
|
||||
if (ag) return;
|
||||
}
|
||||
|
||||
// ArenaGraph (battle and soccer mode) doesn't need the code below
|
||||
if (ag) return;
|
||||
|
||||
// keep the current quad as the latest valid one IF the player has one
|
||||
// of the required checklines
|
||||
const DriveNode* dn = DriveGraph::get()->getNode(m_current_graph_node);
|
||||
const std::vector<int>& checkline_requirements = dn->getChecklineRequirements();
|
||||
|
||||
bool isValidQuad = false;
|
||||
if (checkline_requirements.size() == 0)
|
||||
{
|
||||
isValidQuad = true;
|
||||
if (m_on_road)
|
||||
m_last_valid_graph_node = m_current_graph_node;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ag) return;
|
||||
// keep the current quad as the latest valid one IF the player has one
|
||||
// of the required checklines
|
||||
const DriveNode* dn = DriveGraph::get()->getNode(m_current_graph_node);
|
||||
const std::vector<int>& checkline_requirements = dn->getChecklineRequirements();
|
||||
|
||||
if (checkline_requirements.size() == 0)
|
||||
for (unsigned int i=0; i<checkline_requirements.size(); i++)
|
||||
{
|
||||
m_last_valid_graph_node = m_current_graph_node;
|
||||
}
|
||||
else
|
||||
{
|
||||
//bool has_prerequisite = false;
|
||||
|
||||
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;
|
||||
break;
|
||||
}
|
||||
isValidQuad = true;
|
||||
break;
|
||||
}
|
||||
|
||||
// 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
|
||||
// track, and how far to the left or right of the center driveline.
|
||||
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
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
@ -48,6 +48,8 @@ private:
|
||||
* of the center driveline. */
|
||||
Vec3 m_current_track_coords;
|
||||
|
||||
Vec3 m_latest_valid_track_coords;
|
||||
|
||||
/** True if the object is on the road (driveline), or not. */
|
||||
bool m_on_road;
|
||||
|
||||
@ -61,7 +63,13 @@ public:
|
||||
float getRelativeDistanceToCenter() const;
|
||||
// ------------------------------------------------------------------------
|
||||
/** 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. */
|
||||
float getDistanceToCenter() const { return m_current_track_coords.getX(); }
|
||||
|
Loading…
Reference in New Issue
Block a user