SuperTuxKart
Public Member Functions | Private Attributes | List of all members
TrackSector Class Reference

This object keeps track of which sector an object is on. More...

#include <track_sector.hpp>

Inheritance diagram for TrackSector:
Inheritance graph
[legend]

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. More...
 
float getRelativeDistanceToCenter () const
 Returns the relative distance of the corresponding kart from the center, i.e. More...
 
float getDistanceFromStart (bool account_for_checklines, bool strict=false) const
 Returns how far the the object is from the start line. More...
 
float getDistanceToCenter () const
 Returns the distance to the centre driveline. More...
 
int getCurrentGraphNode () const
 Returns the current graph node. More...
 
bool isOnRoad () const
 Returns if this object is on the road (driveline). More...
 
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. More...
 
int m_estimated_valid_graph_node
 The index of the estimated valid graph node. More...
 
int m_last_valid_graph_node
 The index of the last valid graph node. More...
 
Vec3 m_current_track_coords
 The coordinates of this object on the track, i.e. More...
 
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. More...
 
int m_last_triggered_checkline
 

Detailed Description

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.

Member Function Documentation

◆ getCurrentGraphNode()

int TrackSector::getCurrentGraphNode ( ) const
inline

Returns the current graph node.

◆ getDistanceFromStart()

float TrackSector::getDistanceFromStart ( bool  account_for_checklines,
bool  strict = false 
) const
inline

Returns how far the the object is from the start line.

◆ getDistanceToCenter()

float TrackSector::getDistanceToCenter ( ) const
inline

Returns the distance to the centre driveline.

◆ getRelativeDistanceToCenter()

float TrackSector::getRelativeDistanceToCenter ( ) const

Returns the relative distance of the corresponding kart from the center, i.e.

a value between -1 and 1 inclusive.

Returns
THe relative distance between -1.0f and +1.0f;

◆ isOnRoad()

bool TrackSector::isOnRoad ( ) const
inline

Returns if this object is on the road (driveline).

◆ update()

void TrackSector::update ( const Vec3 xyz,
bool  ignore_vertical = false 
)

Updates the current graph node index, and the track coordinates for the specified point.

Parameters
xyzThe new coordinates to search the graph node for.

Member Data Documentation

◆ m_current_graph_node

int TrackSector::m_current_graph_node
private

The graph node the object is on.

◆ m_current_track_coords

Vec3 TrackSector::m_current_track_coords
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.

◆ m_estimated_valid_graph_node

int TrackSector::m_estimated_valid_graph_node
private

The index of the estimated valid graph node.

Used for distance.

◆ m_last_valid_graph_node

int TrackSector::m_last_valid_graph_node
private

The index of the last valid graph node.

Used for rescue

◆ m_on_road

bool TrackSector::m_on_road
private

True if the object is on the road (driveline), or not.


The documentation for this class was generated from the following files: