SuperTuxKart
Loading...
Searching...
No Matches
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.
 
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.
 
unsigned int getSuccessor (unsigned int i) const
 Returns the i-th successor node.
 
unsigned int getNumberOfPredecessors () const
 Returns the number of predecessors.
 
int getPredecessor (unsigned int i) const
 Returns a predecessor for this node.
 
float getDistanceToSuccessor (unsigned int j) const
 Returns the distance to the j-th.
 
float getAngleToSuccessor (unsigned int j) const
 Returns the angle from this node to the j-th.
 
float getDistanceFromStart () const
 Returns the distance from start.
 
void setDistanceFromStart (float d)
 Sets the distance from start for this node.
 
float getPathWidth () const
 Returns the width of the part for this quad.
 
const Vec3getLowerCenter () const
 Returns the center point of the lower edge of this drive node.
 
const Vec3getUpperCenter () const
 Returns the center point of the upper edge of this drive node.
 
float getNodeLength () const
 Returns the length of the quad of this node.
 
bool ignoreSuccessorForAI (unsigned int i) const
 Returns true if the index-successor of this node is one that the AI is allowed to use.
 
int getSuccessorToReach (unsigned int n)
 Returns which successor node to use in order to be able to reach the given node n.
 
const std::vector< int > & getChecklineRequirements () const
 Returns the checkline requirements of this drive node.
 
void getDirectionData (unsigned int succ, DirectionType *dir, unsigned int *last) const
 Returns the direction in which the successor n is.
 
const Vec3getRightUnitVector () const
 Returns a unit vector pointing to the right side of the quad.
 
bool letAIIgnore () const
 True if this node should be ignored by the AI.
 
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.
 
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.
 
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.
 
const Vec3operator[] (int i) const
 Returns the i-th.
 
const Vec3getCenter () const
 Returns the center of a quad.
 
void setQuad (const Vec3 &p0, const Vec3 &p1, const Vec3 &p2, const Vec3 &p3)
 Set new quad coordinates.
 
void setHeightTesting (float min, float max)
 
float getMinHeight () const
 Returns the minimum height of a quad.
 
int getIndex () const
 Returns the index of this quad.
 
bool isInvisible () const
 Returns true of this quad is invisible, i.e.
 
bool isIgnored () const
 
const Vec3getNormal () const
 Returns the normal of this quad.
 
virtual bool pointInside (const Vec3 &p, bool ignore_vertical=false) const
 Returns true if a point is inside this quad.
 
virtual bool is3DQuad () const
 Returns true if this quad is 3D, which additional 3D testing is used in pointInside.
 
virtual float getDistance2FromPoint (const Vec3 &xyz) const
 

Protected Attributes

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

Private Attributes

bool m_ai_ignore
 Set to true if this drive node should not be used by the AI.
 
std::vector< int > m_successor_nodes
 The list of successor drive nodes.
 
std::vector< int > m_predecessor_nodes
 The list of predecessors of a node.
 
std::vector< float > m_distance_to_next
 The distance to each of the successors.
 
std::vector< float > m_angle_to_next
 The angle of the line from this node to each neighbour.
 
float m_width
 Width of the track, which is the average of the width at the beginning and at the end.
 
Vec3 m_center_to_right
 A vector from the center of the quad to the right edge.
 
PathToNodeVector m_path_to_node
 This vector is only used if the drive node has more than one successor.
 
std::vector< DirectionTypem_direction
 The direction for each of the successors.
 
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.
 
Vec3 m_right_unit_vector
 A unit vector pointing from the center to the right side, orthogonal to the driving direction.
 
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.

◆ getDistances()

virtual void DriveNode::getDistances ( const Vec3 xyz,
Vec3 result 
) const
pure virtual

Implemented in DriveNode2D, and DriveNode3D.

◆ getDistanceToSuccessor()

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

Returns the distance to the j-th.

successor.

◆ 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.

◆ 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.

◆ 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.

◆ 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.

Member Data Documentation

◆ 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_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.


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