19 #ifndef HEADER_DRIVE_NODE_HPP 20 #define HEADER_DRIVE_NODE_HPP 24 #include "tracks/quad.hpp" 72 typedef std::vector<int> PathToNodeVector;
102 PathToNodeVector *m_path_to_node);
107 unsigned int node_index,
bool invisible,
108 bool ai_ignore,
bool ignored);
116 void setChecklineRequirements(
int latest_checkline);
118 void setDirectionData(
unsigned int successor,
DirectionType dir,
119 unsigned int last_node_index);
123 {
return (
unsigned int)m_successor_nodes.size(); }
127 {
return m_successor_nodes[i]; }
131 {
return (
unsigned int)m_predecessor_nodes.size(); }
140 {
return m_distance_to_next[j]; }
144 {
return m_angle_to_next[j]; }
164 {
return (m_lower_center-m_upper_center).length(); }
176 return m_path_to_node.size()>0 ? m_path_to_node[n] : 0;
185 unsigned int *last)
const 187 *dir = m_direction[succ]; *last = m_last_index_same_direction[succ];
196 virtual void getDistances(
const Vec3 &xyz,
Vec3 *result)
const = 0;
float getNodeLength() const
Returns the length of the quad of this node.
Definition: drive_node.hpp:163
Vec3 m_upper_center
Upper center point of the drive node.
Definition: drive_node.hpp:44
PathToNodeVector m_path_to_node
This vector is only used if the drive node has more than one successor.
Definition: drive_node.hpp:77
float getPathWidth() const
Returns the width of the part for this quad.
Definition: drive_node.hpp:154
float getDistanceFromStart() const
Returns the distance from start.
Definition: drive_node.hpp:147
std::vector< DirectionType > m_direction
The direction for each of the successors.
Definition: drive_node.hpp:80
float getAngleToSuccessor(unsigned int j) const
Returns the angle from this node to the j-th.
Definition: drive_node.hpp:143
A wrapper around bullets btVector3 to include conventient conversion functions (e.g.
Definition: vec3.hpp:34
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...
Definition: drive_node.hpp:86
DirectionType
To indiciate in which direction the track is going: straight, left, right.
Definition: drive_node.hpp:37
float m_distance_from_start
Distance from the start to the beginning of the drive node.
Definition: drive_node.hpp:47
std::vector< int > m_successor_nodes
The list of successor drive nodes.
Definition: drive_node.hpp:54
const std::vector< int > & getChecklineRequirements() const
Returns the checkline requirements of this drive node.
Definition: drive_node.hpp:180
bool letAIIgnore() const
True if this node should be ignored by the AI.
Definition: drive_node.hpp:194
void markAllSuccessorsToUse(unsigned int n, PathToNodeVector *m_path_to_node)
This function marks that the successor n should be used to reach this node.
Definition: drive_node.cpp:138
Vec3 m_center_to_right
A vector from the center of the quad to the right edge.
Definition: drive_node.hpp:70
Vec3 m_right_unit_vector
A unit vector pointing from the center to the right side, orthogonal to the driving direction...
Definition: drive_node.hpp:90
std::vector< int > m_predecessor_nodes
The list of predecessors of a node.
Definition: drive_node.hpp:57
void addSuccessor(unsigned int to)
Adds a successor to a node.
Definition: drive_node.cpp:67
void setDistanceFromStart(float d)
Sets the distance from start for this node.
Definition: drive_node.hpp:151
int getPredecessor(unsigned int i) const
Returns a predecessor for this node.
Definition: drive_node.hpp:136
unsigned int getNumberOfPredecessors() const
Returns the number of predecessors.
Definition: drive_node.hpp:130
float m_width
Width of the track, which is the average of the width at the beginning and at the end...
Definition: drive_node.hpp:67
float getDistanceToSuccessor(unsigned int j) const
Returns the distance to the j-th.
Definition: drive_node.hpp:139
This class stores a node of the drive graph, i.e.
Definition: drive_node.hpp:31
void getDirectionData(unsigned int succ, DirectionType *dir, unsigned int *last) const
Returns the direction in which the successor n is.
Definition: drive_node.hpp:184
void setupPathsToNode()
If this node has more than one successor, it will set up a vector that contains the direction to use ...
Definition: drive_node.cpp:92
const Vec3 & getUpperCenter() const
Returns the center point of the upper edge of this drive node.
Definition: drive_node.hpp:160
std::vector< float > m_distance_to_next
The distance to each of the successors.
Definition: drive_node.hpp:60
unsigned int getSuccessor(unsigned int i) const
Returns the i-th successor node.
Definition: drive_node.hpp:126
const Vec3 & getLowerCenter() const
Returns the center point of the lower edge of this drive node.
Definition: drive_node.hpp:157
const Vec3 & getRightUnitVector() const
Returns a unit vector pointing to the right side of the quad.
Definition: drive_node.hpp:191
std::vector< int > m_checkline_requirements
Sets of checklines you should have activated when you are driving on this node (there is a possibilit...
Definition: drive_node.hpp:97
bool ignoreSuccessorForAI(unsigned int i) const
Returns true if the index-successor of this node is one that the AI is allowed to use...
Definition: drive_node.cpp:176
bool m_ai_ignore
Set to true if this drive node should not be used by the AI.
Definition: drive_node.hpp:51
Vec3 m_lower_center
Lower center point of the drive node.
Definition: drive_node.hpp:41
int getSuccessorToReach(unsigned int n)
Returns which successor node to use in order to be able to reach the given node n.
Definition: drive_node.hpp:172
unsigned int getNumberOfSuccessors() const
Returns the number of successors.
Definition: drive_node.hpp:122
std::vector< float > m_angle_to_next
The angle of the line from this node to each neighbour.
Definition: drive_node.hpp:63