|
void | createDebugMesh () |
| Creates the debug mesh to display the graph on top of the track model.
|
|
RenderTarget * | makeMiniMap (const core::dimension2du &dimension, const std::string &name, const video::SColor &fill_color, bool invert_x_z) |
| Takes a snapshot of the graph so they can be used as minimap.
|
|
void | mapPoint2MiniMap (const Vec3 &xyz, Vec3 *out) const |
| Returns the 2d coordinates of a point when drawn on the mini map texture.
|
|
Quad * | getQuad (unsigned int i) const |
|
unsigned int | getNumNodes () const |
|
void | findRoadSector (const Vec3 &XYZ, int *sector, std::vector< int > *all_sectors=NULL, bool ignore_vertical=false) const |
| findRoadSector returns in which sector on the road the position xyz is.
|
|
int | findOutOfRoadSector (const Vec3 &xyz, const int curr_sector=UNKNOWN_SECTOR, std::vector< int > *all_sectors=NULL, bool ignore_vertical=false) const |
| findOutOfRoadSector finds the sector where XYZ is, but as it name implies, it is more accurate for the outside of the track than the inside, and for STK's needs the accuracy on top of the track is unacceptable; but if this was a 2D function, the accuracy for out of road sectors would be perfect.
|
|
const Vec3 & | getBBMin () const |
|
const Vec3 & | getBBMax () const |
|
const int * | getBBNodes () const |
|
|
void | createMesh (bool show_invisible=true, bool enable_transparency=false, const video::SColor *track_color=NULL, bool invert_x_z=false, bool flatten=false) |
| Creates the actual mesh that is used by createDebugMesh() or makeMiniMap()
|
|
void | createMeshSP (bool show_invisible=true, bool enable_transparency=false, const video::SColor *track_color=NULL, bool invert_x_z=false) |
| Creates the actual mesh that is used by createDebugMesh() or makeMiniMap()
|
|
void | cleanupDebugMesh () |
| Cleans up the debug mesh.
|
|
virtual bool | hasLapLine () const =0 |
|
virtual void | differentNodeColor (int n, video::SColor *c) const =0 |
|
This class stores a graph of quads.
It uses a 'simplified singleton' design pattern: it has a static create function to create exactly instance, a destroy function, and a get function (that does not have the side effect of the 'normal singleton' design pattern to create an instance). Besides saving on the if statement in get(), this is necessary since certain race modes might not have a quad graph at all (e.g. arena without navmesh). So get() returns NULL in this case, and this is tested where necessary.
int Graph::findOutOfRoadSector |
( |
const Vec3 & |
xyz, |
|
|
const int |
curr_sector = UNKNOWN_SECTOR , |
|
|
std::vector< int > * |
all_sectors = NULL , |
|
|
bool |
ignore_vertical = false |
|
) |
| const |
findOutOfRoadSector finds the sector where XYZ is, but as it name implies, it is more accurate for the outside of the track than the inside, and for STK's needs the accuracy on top of the track is unacceptable; but if this was a 2D function, the accuracy for out of road sectors would be perfect.
To find the sector we look for the closest line segment from the right and left drivelines, and the number of that segment will be the sector.
The SIDE argument is used to speed up the function only; if we know that XYZ is on the left or right side of the track, we know that the closest driveline must be the one that matches that condition. In reality, the side used in STK is the one from the previous frame, but in order to move from one side to another a point would go through the middle, that is handled by findRoadSector() which doesn't has speed ups based on the side.
NOTE: This method of finding the sector outside of the road is not perfect: if two line segments have a similar altitude (but enough to let a kart get through) and they are very close on a 2D system, if a kart is on the air it could be closer to the top line segment even if it is supposed to be on the sector of the lower line segment. Probably the best solution would be to construct a quad that reaches until the next higher overlapping line segment, and find the closest one to XYZ.