SuperTuxKart
|
This object keeps track of which sector an object is on. More...
#include <track_sector.hpp>
Public Member Functions | |
TrackSector () | |
Initialises the object, and sets the current graph node to be undefined. | |
void | reset () |
void | rescue () |
Sets current and last valid graph node to the rescue location. | |
void | update (const Vec3 &xyz, bool ignore_vertical=false) |
Updates the current graph node index, and the track coordinates for the specified point. | |
float | getRelativeDistanceToCenter () const |
Returns the relative distance of the corresponding kart from the center, i.e. | |
float | getDistanceFromStart (bool account_for_checklines, bool strict=false) const |
Returns how far the the object is from the start line. | |
float | getDistanceToCenter () const |
Returns the distance to the centre driveline. | |
int | getCurrentGraphNode () const |
Returns the current graph node. | |
bool | isOnRoad () const |
Returns if this object is on the road (driveline). | |
void | setLastTriggeredCheckline (int i) |
int | getLastTriggeredCheckline () const |
int | getLastValidGraphNode () const |
void | saveState (BareNetworkString *buffer) const |
Only basket ball is used for rewind for TrackSector so save the minimum. | |
void | rewindTo (BareNetworkString *buffer) |
void | saveCompleteState (BareNetworkString *bns) |
Save completely for spectating in linear race. | |
void | restoreCompleteState (const BareNetworkString &b) |
Private Attributes | |
int | m_current_graph_node |
The graph node the object is on. | |
int | m_estimated_valid_graph_node |
The index of the estimated valid graph node. | |
int | m_last_valid_graph_node |
The index of the last valid graph node. | |
Vec3 | m_current_track_coords |
The coordinates of this object on the track, i.e. | |
Vec3 | m_estimated_valid_track_coords |
Vec3 | m_latest_valid_track_coords |
bool | m_on_road |
True if the object is on the road (driveline), or not. | |
int | m_last_triggered_checkline |
This object keeps track of which sector an object is on.
A sector is actually just the graph node (it's called sector to better distinguish the graph node from say xml node and scene node). An object that has a track sector can determine how far away it is from the start line, how far away it is from the center driveline. If the object is not actually on part of the quad graph, it will determine the closest sector it is to, and set a flag (!isOnRoad). This object will also keep track on the last valid sector an object was on, which is used to reset a kart in case of a rescue.
float TrackSector::getRelativeDistanceToCenter | ( | ) | const |
Returns the relative distance of the corresponding kart from the center, i.e.
a value between -1 and 1 inclusive.
void TrackSector::update | ( | const Vec3 & | xyz, |
bool | ignore_vertical = false |
||
) |
Updates the current graph node index, and the track coordinates for the specified point.
xyz | The new coordinates to search the graph node for. |
|
private |
The coordinates of this object on the track, i.e.
how far from the start of the track, and how far to the left or right of the center driveline.
|
private |
The index of the estimated valid graph node.
Used for distance.
|
private |
The index of the last valid graph node.
Used for rescue