SuperTuxKart
Public Types | Public Member Functions | Protected Attributes | Private Types | Private Member Functions | Private Attributes | List of all members
DriveNode Class Referenceabstract

This class stores a node of the drive graph, i.e. More...

#include <drive_node.hpp>

Inheritance diagram for DriveNode:
Inheritance graph
[legend]

Public Types

enum  DirectionType { DIR_STRAIGHT, DIR_LEFT, DIR_RIGHT, DIR_UNDEFINED }
 To indiciate in which direction the track is going: straight, left, right. More...
 

Public Member Functions

 DriveNode (const Vec3 &p0, const Vec3 &p1, const Vec3 &p2, const Vec3 &p3, const Vec3 &normal, unsigned int node_index, bool invisible, bool ai_ignore, bool ignored)
 
void addSuccessor (unsigned int to)
 Adds a successor to a node. More...
 
void setupPathsToNode ()
 If this node has more than one successor, it will set up a vector that contains the direction to use when a certain drive node X should be reached.
 
void setChecklineRequirements (int latest_checkline)
 
void setDirectionData (unsigned int successor, DirectionType dir, unsigned int last_node_index)
 
unsigned int getNumberOfSuccessors () const
 Returns the number of successors. More...
 
unsigned int getSuccessor (unsigned int i) const
 Returns the i-th successor node. More...
 
unsigned int getNumberOfPredecessors () const
 Returns the number of predecessors. More...
 
int getPredecessor (unsigned int i) const
 Returns a predecessor for this node. More...
 
float getDistanceToSuccessor (unsigned int j) const
 Returns the distance to the j-th. More...
 
float getAngleToSuccessor (unsigned int j) const
 Returns the angle from this node to the j-th. More...
 
float getDistanceFromStart () const
 Returns the distance from start. More...
 
void setDistanceFromStart (float d)
 Sets the distance from start for this node. More...
 
float getPathWidth () const
 Returns the width of the part for this quad. More...
 
const Vec3getLowerCenter () const
 Returns the center point of the lower edge of this drive node. More...
 
const Vec3getUpperCenter () const
 Returns the center point of the upper edge of this drive node. More...
 
float getNodeLength () const
 Returns the length of the quad of this node. More...
 
bool ignoreSuccessorForAI (unsigned int i) const
 Returns true if the index-successor of this node is one that the AI is allowed to use. More...
 
int getSuccessorToReach (unsigned int n)
 Returns which successor node to use in order to be able to reach the given node n. More...
 
const std::vector< int > & getChecklineRequirements () const
 Returns the checkline requirements of this drive node. More...
 
void getDirectionData (unsigned int succ, DirectionType *dir, unsigned int *last) const
 Returns the direction in which the successor n is. More...
 
const Vec3getRightUnitVector () const
 Returns a unit vector pointing to the right side of the quad. More...
 
bool letAIIgnore () const
 True if this node should be ignored by the AI. More...
 
virtual void getDistances (const Vec3 &xyz, Vec3 *result) const =0
 
- Public Member Functions inherited from Quad
 Quad (const Vec3 &p0, const Vec3 &p1, const Vec3 &p2, const Vec3 &p3, const Vec3 &normal=Vec3(0, 1, 0), int index=-1, bool invisible=false, bool ignored=false)
 Constructor, takes 4 points. More...
 
void getVertices (video::S3DVertex *v, const video::SColor &color) const
 Sets the vertices in a irrlicht vertex array to the 4 points of this quad. More...
 
void getSPMVertices (video::S3DVertexSkinnedMesh *v, const video::SColor &color) const
 Sets the vertices in an spm vertex array to the 4 points of this quad. More...
 
const Vec3operator[] (int i) const
 Returns the i-th. More...
 
const Vec3getCenter () const
 Returns the center of a quad. More...
 
void setQuad (const Vec3 &p0, const Vec3 &p1, const Vec3 &p2, const Vec3 &p3)
 Set new quad coordinates. More...
 
void setHeightTesting (float min, float max)
 
float getMinHeight () const
 Returns the minimum height of a quad. More...
 
int getIndex () const
 Returns the index of this quad. More...
 
bool isInvisible () const
 Returns true of this quad is invisible, i.e. More...
 
bool isIgnored () const
 
const Vec3getNormal () const
 Returns the normal of this quad. More...
 
virtual bool pointInside (const Vec3 &p, bool ignore_vertical=false) const
 Returns true if a point is inside this quad. More...
 
virtual bool is3DQuad () const
 Returns true if this quad is 3D, which additional 3D testing is used in pointInside. More...
 
virtual float getDistance2FromPoint (const Vec3 &xyz) const
 

Protected Attributes

Vec3 m_lower_center
 Lower center point of the drive node. More...
 
Vec3 m_upper_center
 Upper center point of the drive node. More...
 
float m_distance_from_start
 Distance from the start to the beginning of the drive node. More...
 
- Protected Attributes inherited from Quad
Vec3 m_p [4]
 The four points of a quad. More...
 
Vec3 m_center
 The center of all four points, which is used by the AI. More...
 
int m_index
 Index of this quad, used only with graph. More...
 
Vec3 m_normal
 Normal of the quad.
 

Private Types

typedef std::vector< int > PathToNodeVector
 

Private Member Functions

void markAllSuccessorsToUse (unsigned int n, PathToNodeVector *m_path_to_node)
 This function marks that the successor n should be used to reach this node. More...
 

Private Attributes

bool m_ai_ignore
 Set to true if this drive node should not be used by the AI. More...
 
std::vector< int > m_successor_nodes
 The list of successor drive nodes. More...
 
std::vector< int > m_predecessor_nodes
 The list of predecessors of a node. More...
 
std::vector< float > m_distance_to_next
 The distance to each of the successors. More...
 
std::vector< float > m_angle_to_next
 The angle of the line from this node to each neighbour. More...
 
float m_width
 Width of the track, which is the average of the width at the beginning and at the end. More...
 
Vec3 m_center_to_right
 A vector from the center of the quad to the right edge. More...
 
PathToNodeVector m_path_to_node
 This vector is only used if the drive node has more than one successor. More...
 
std::vector< DirectionTypem_direction
 The direction for each of the successors. More...
 
std::vector< unsigned int > m_last_index_same_direction
 Stores for each successor the index of the last drive node that has the same direction (i.e. More...
 
Vec3 m_right_unit_vector
 A unit vector pointing from the center to the right side, orthogonal to the driving direction. More...
 
std::vector< int > m_checkline_requirements
 Sets of checklines you should have activated when you are driving on this node (there is a possibility of more than one set because of alternate ways)
 

Detailed Description

This class stores a node of the drive graph, i.e.

a list of successor edges, it can either be 2d or 3d.

Member Enumeration Documentation

◆ DirectionType

To indiciate in which direction the track is going: straight, left, right.

The undefined direction is used by the AI only.

Member Function Documentation

◆ addSuccessor()

void DriveNode::addSuccessor ( unsigned int  to)

Adds a successor to a node.

This function will also pre-compute certain values (like distance from this node to the successor, angle (in world) between this node and the successor.

Parameters
toThe index of the drive node of the successor.

◆ getAngleToSuccessor()

float DriveNode::getAngleToSuccessor ( unsigned int  j) const
inline

Returns the angle from this node to the j-th.

successor.

◆ getChecklineRequirements()

const std::vector<int>& DriveNode::getChecklineRequirements ( ) const
inline

Returns the checkline requirements of this drive node.

◆ getDirectionData()

void DriveNode::getDirectionData ( unsigned int  succ,
DirectionType dir,
unsigned int *  last 
) const
inline

Returns the direction in which the successor n is.

◆ getDistanceFromStart()

float DriveNode::getDistanceFromStart ( ) const
inline

Returns the distance from start.

◆ getDistanceToSuccessor()

float DriveNode::getDistanceToSuccessor ( unsigned int  j) const
inline

Returns the distance to the j-th.

successor.

◆ getLowerCenter()

const Vec3& DriveNode::getLowerCenter ( ) const
inline

Returns the center point of the lower edge of this drive node.

◆ getNodeLength()

float DriveNode::getNodeLength ( ) const
inline

Returns the length of the quad of this node.

◆ getNumberOfPredecessors()

unsigned int DriveNode::getNumberOfPredecessors ( ) const
inline

Returns the number of predecessors.

◆ getNumberOfSuccessors()

unsigned int DriveNode::getNumberOfSuccessors ( ) const
inline

Returns the number of successors.

◆ getPathWidth()

float DriveNode::getPathWidth ( ) const
inline

Returns the width of the part for this quad.

◆ getPredecessor()

int DriveNode::getPredecessor ( unsigned int  i) const
inline

Returns a predecessor for this node.

Note that the first predecessor is the most 'natural' one, i.e. the one on the main driveline.

◆ getRightUnitVector()

const Vec3& DriveNode::getRightUnitVector ( ) const
inline

Returns a unit vector pointing to the right side of the quad.

◆ getSuccessor()

unsigned int DriveNode::getSuccessor ( unsigned int  i) const
inline

Returns the i-th successor node.

◆ getSuccessorToReach()

int DriveNode::getSuccessorToReach ( unsigned int  n)
inline

Returns which successor node to use in order to be able to reach the given node n.

Parameters
nIndex of the drive node to reach.

◆ getUpperCenter()

const Vec3& DriveNode::getUpperCenter ( ) const
inline

Returns the center point of the upper edge of this drive node.

◆ ignoreSuccessorForAI()

bool DriveNode::ignoreSuccessorForAI ( unsigned int  i) const

Returns true if the index-successor of this node is one that the AI is allowed to use.

Parameters
indexIndex of the successor.

◆ letAIIgnore()

bool DriveNode::letAIIgnore ( ) const
inline

True if this node should be ignored by the AI.

◆ markAllSuccessorsToUse()

void DriveNode::markAllSuccessorsToUse ( unsigned int  n,
PathToNodeVector *  path_to_node 
)
private

This function marks that the successor n should be used to reach this node.

It then recursively (depth first) does the same for all its successors. Depth-first

Parameters
nThe successor which should be used in m_path_node to reach this node.
path_to_nodeThe path-to-node data structure of the node for which the paths are currently determined.

◆ setDistanceFromStart()

void DriveNode::setDistanceFromStart ( float  d)
inline

Sets the distance from start for this node.

Member Data Documentation

◆ m_ai_ignore

bool DriveNode::m_ai_ignore
private

Set to true if this drive node should not be used by the AI.

◆ m_angle_to_next

std::vector<float> DriveNode::m_angle_to_next
private

The angle of the line from this node to each neighbour.

◆ m_center_to_right

Vec3 DriveNode::m_center_to_right
private

A vector from the center of the quad to the right edge.

◆ m_direction

std::vector<DirectionType> DriveNode::m_direction
private

The direction for each of the successors.

◆ m_distance_from_start

float DriveNode::m_distance_from_start
protected

Distance from the start to the beginning of the drive node.

◆ m_distance_to_next

std::vector<float> DriveNode::m_distance_to_next
private

The distance to each of the successors.

◆ m_last_index_same_direction

std::vector<unsigned int> DriveNode::m_last_index_same_direction
private

Stores for each successor the index of the last drive node that has the same direction (i.e.

if index 0 curves left, this vector will store the index of the last drive node that is still turning left.

◆ m_lower_center

Vec3 DriveNode::m_lower_center
protected

Lower center point of the drive node.

◆ m_path_to_node

PathToNodeVector DriveNode::m_path_to_node
private

This vector is only used if the drive node has more than one successor.

In this case m_path_to_node[X] will contain the index of the successor to use in order to reach drive node X for this drive nodes.

◆ m_predecessor_nodes

std::vector<int> DriveNode::m_predecessor_nodes
private

The list of predecessors of a node.

◆ m_right_unit_vector

Vec3 DriveNode::m_right_unit_vector
private

A unit vector pointing from the center to the right side, orthogonal to the driving direction.

◆ m_successor_nodes

std::vector<int> DriveNode::m_successor_nodes
private

The list of successor drive nodes.

◆ m_upper_center

Vec3 DriveNode::m_upper_center
protected

Upper center point of the drive node.

◆ m_width

float DriveNode::m_width
private

Width of the track, which is the average of the width at the beginning and at the end.


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