Recast Navigation
Navigation-mesh Toolset for Games
|
Go to the source code of this file.
Functions | |
General helper functions | |
template<class T > | |
void | dtIgnoreUnused (const T &) |
Used to ignore a function parameter. More... | |
template<class T > | |
void | dtSwap (T &a, T &b) |
Swaps the values of the two parameters. More... | |
template<class T > | |
T | dtMin (T a, T b) |
Returns the minimum of two values. More... | |
template<class T > | |
T | dtMax (T a, T b) |
Returns the maximum of two values. More... | |
template<class T > | |
T | dtAbs (T a) |
Returns the absolute value. More... | |
template<class T > | |
T | dtSqr (T a) |
Returns the square of the value. More... | |
template<class T > | |
T | dtClamp (T v, T mn, T mx) |
Clamps the value to the specified range. More... | |
Vector helper functions. | |
void | dtVcross (float *dest, const float *v1, const float *v2) |
Derives the cross product of two vectors. More... | |
float | dtVdot (const float *v1, const float *v2) |
Derives the dot product of two vectors. More... | |
void | dtVmad (float *dest, const float *v1, const float *v2, const float s) |
Performs a scaled vector addition. More... | |
void | dtVlerp (float *dest, const float *v1, const float *v2, const float t) |
Performs a linear interpolation between two vectors. More... | |
void | dtVadd (float *dest, const float *v1, const float *v2) |
Performs a vector addition. More... | |
void | dtVsub (float *dest, const float *v1, const float *v2) |
Performs a vector subtraction. More... | |
void | dtVscale (float *dest, const float *v, const float t) |
Scales the vector by the specified value. More... | |
void | dtVmin (float *mn, const float *v) |
Selects the minimum value of each element from the specified vectors. More... | |
void | dtVmax (float *mx, const float *v) |
Selects the maximum value of each element from the specified vectors. More... | |
void | dtVset (float *dest, const float x, const float y, const float z) |
Sets the vector elements to the specified values. More... | |
void | dtVcopy (float *dest, const float *a) |
Performs a vector copy. More... | |
float | dtVlen (const float *v) |
Derives the scalar length of the vector. More... | |
float | dtVlenSqr (const float *v) |
Derives the square of the scalar length of the vector. More... | |
float | dtVdist (const float *v1, const float *v2) |
Returns the distance between two points. More... | |
float | dtVdistSqr (const float *v1, const float *v2) |
Returns the square of the distance between two points. More... | |
float | dtVdist2D (const float *v1, const float *v2) |
Derives the distance between the specified points on the xz-plane. More... | |
float | dtVdist2DSqr (const float *v1, const float *v2) |
Derives the square of the distance between the specified points on the xz-plane. More... | |
void | dtVnormalize (float *v) |
Normalizes the vector. More... | |
bool | dtVequal (const float *p0, const float *p1) |
Performs a 'sloppy' colocation check of the specified points. More... | |
bool | dtVisfinite (const float *v) |
Checks that the specified vector's components are all finite. More... | |
bool | dtVisfinite2D (const float *v) |
Checks that the specified vector's 2D components are finite. More... | |
float | dtVdot2D (const float *u, const float *v) |
Derives the dot product of two vectors on the xz-plane. More... | |
float | dtVperp2D (const float *u, const float *v) |
Derives the xz-plane 2D perp product of the two vectors. More... | |
Computational geometry helper functions. | |
float | dtTriArea2D (const float *a, const float *b, const float *c) |
Derives the signed xz-plane area of the triangle ABC, or the relationship of line AB to point C. More... | |
bool | dtOverlapQuantBounds (const unsigned short amin[3], const unsigned short amax[3], const unsigned short bmin[3], const unsigned short bmax[3]) |
Determines if two axis-aligned bounding boxes overlap. More... | |
bool | dtOverlapBounds (const float *amin, const float *amax, const float *bmin, const float *bmax) |
Determines if two axis-aligned bounding boxes overlap. More... | |
void | dtClosestPtPointTriangle (float *closest, const float *p, const float *a, const float *b, const float *c) |
Derives the closest point on a triangle from the specified reference point. More... | |
bool | dtClosestHeightPointTriangle (const float *p, const float *a, const float *b, const float *c, float &h) |
Derives the y-axis height of the closest point on the triangle from the specified reference point. More... | |
bool | dtIntersectSegmentPoly2D (const float *p0, const float *p1, const float *verts, int nverts, float &tmin, float &tmax, int &segMin, int &segMax) |
bool | dtIntersectSegSeg2D (const float *ap, const float *aq, const float *bp, const float *bq, float &s, float &t) |
bool | dtPointInPolygon (const float *pt, const float *verts, const int nverts) |
Determines if the specified point is inside the convex polygon on the xz-plane. More... | |
bool | dtDistancePtPolyEdgesSqr (const float *pt, const float *verts, const int nverts, float *ed, float *et) |
float | dtDistancePtSegSqr2D (const float *pt, const float *p, const float *q, float &t) |
void | dtCalcPolyCenter (float *tc, const unsigned short *idx, int nidx, const float *verts) |
Derives the centroid of a convex polygon. More... | |
bool | dtOverlapPolyPoly2D (const float *polya, const int npolya, const float *polyb, const int npolyb) |
Determines if the two convex polygons overlap on the xz-plane. More... | |
Miscellanious functions. | |
unsigned int | dtNextPow2 (unsigned int v) |
unsigned int | dtIlog2 (unsigned int v) |
int | dtAlign4 (int x) |
int | dtOppositeTile (int side) |
void | dtSwapByte (unsigned char *a, unsigned char *b) |
void | dtSwapEndian (unsigned short *v) |
void | dtSwapEndian (short *v) |
void | dtSwapEndian (unsigned int *v) |
void | dtSwapEndian (int *v) |
void | dtSwapEndian (float *v) |
void | dtRandomPointInConvexPoly (const float *pts, const int npts, float *areas, const float s, const float t, float *out) |
template<typename TypeToRetrieveAs > | |
TypeToRetrieveAs * | dtGetThenAdvanceBufferPointer (const unsigned char *&buffer, const size_t distanceToAdvance) |
template<typename TypeToRetrieveAs > | |
TypeToRetrieveAs * | dtGetThenAdvanceBufferPointer (unsigned char *&buffer, const size_t distanceToAdvance) |
|
inline |
Returns the absolute value.
[in] | a | The value. |
|
inline |
void dtCalcPolyCenter | ( | float * | tc, |
const unsigned short * | idx, | ||
int | nidx, | ||
const float * | verts | ||
) |
Derives the centroid of a convex polygon.
[out] | tc | The centroid of the polgyon. [(x, y, z)] |
[in] | idx | The polygon indices. [(vertIndex) * nidx ] |
[in] | nidx | The number of indices in the polygon. [Limit: >= 3] |
[in] | verts | The polygon vertices. [(x, y, z) * vertCount] |
|
inline |
Clamps the value to the specified range.
[in] | v | The value to clamp. |
[in] | mn | The minimum permitted return value. |
[in] | mx | The maximum permitted return value. |
bool dtClosestHeightPointTriangle | ( | const float * | p, |
const float * | a, | ||
const float * | b, | ||
const float * | c, | ||
float & | h | ||
) |
Derives the y-axis height of the closest point on the triangle from the specified reference point.
[in] | p | The reference point from which to test. [(x, y, z)] |
[in] | a | Vertex A of triangle ABC. [(x, y, z)] |
[in] | b | Vertex B of triangle ABC. [(x, y, z)] |
[in] | c | Vertex C of triangle ABC. [(x, y, z)] |
[out] | h | The resulting height. |
void dtClosestPtPointTriangle | ( | float * | closest, |
const float * | p, | ||
const float * | a, | ||
const float * | b, | ||
const float * | c | ||
) |
Derives the closest point on a triangle from the specified reference point.
[out] | closest | The closest point on the triangle. |
[in] | p | The reference point from which to test. [(x, y, z)] |
[in] | a | Vertex A of triangle ABC. [(x, y, z)] |
[in] | b | Vertex B of triangle ABC. [(x, y, z)] |
[in] | c | Vertex C of triangle ABC. [(x, y, z)] |
bool dtDistancePtPolyEdgesSqr | ( | const float * | pt, |
const float * | verts, | ||
const int | nverts, | ||
float * | ed, | ||
float * | et | ||
) |
float dtDistancePtSegSqr2D | ( | const float * | pt, |
const float * | p, | ||
const float * | q, | ||
float & | t | ||
) |
TypeToRetrieveAs* dtGetThenAdvanceBufferPointer | ( | const unsigned char *& | buffer, |
const size_t | distanceToAdvance | ||
) |
TypeToRetrieveAs* dtGetThenAdvanceBufferPointer | ( | unsigned char *& | buffer, |
const size_t | distanceToAdvance | ||
) |
void dtIgnoreUnused | ( | const T & | ) |
Used to ignore a function parameter.
VS complains about unused parameters and this silences the warning.
|
inline |
bool dtIntersectSegmentPoly2D | ( | const float * | p0, |
const float * | p1, | ||
const float * | verts, | ||
int | nverts, | ||
float & | tmin, | ||
float & | tmax, | ||
int & | segMin, | ||
int & | segMax | ||
) |
bool dtIntersectSegSeg2D | ( | const float * | ap, |
const float * | aq, | ||
const float * | bp, | ||
const float * | bq, | ||
float & | s, | ||
float & | t | ||
) |
|
inline |
Returns the maximum of two values.
[in] | a | Value A |
[in] | b | Value B |
|
inline |
Returns the minimum of two values.
[in] | a | Value A |
[in] | b | Value B |
|
inline |
|
inline |
|
inline |
Determines if two axis-aligned bounding boxes overlap.
[in] | amin | Minimum bounds of box A. [(x, y, z)] |
[in] | amax | Maximum bounds of box A. [(x, y, z)] |
[in] | bmin | Minimum bounds of box B. [(x, y, z)] |
[in] | bmax | Maximum bounds of box B. [(x, y, z)] |
bool dtOverlapPolyPoly2D | ( | const float * | polya, |
const int | npolya, | ||
const float * | polyb, | ||
const int | npolyb | ||
) |
Determines if the two convex polygons overlap on the xz-plane.
[in] | polya | Polygon A vertices. [(x, y, z) * npolya ] |
[in] | npolya | The number of vertices in polygon A. |
[in] | polyb | Polygon B vertices. [(x, y, z) * npolyb ] |
[in] | npolyb | The number of vertices in polygon B. |
All vertices are projected onto the xz-plane, so the y-values are ignored.
|
inline |
Determines if two axis-aligned bounding boxes overlap.
[in] | amin | Minimum bounds of box A. [(x, y, z)] |
[in] | amax | Maximum bounds of box A. [(x, y, z)] |
[in] | bmin | Minimum bounds of box B. [(x, y, z)] |
[in] | bmax | Maximum bounds of box B. [(x, y, z)] |
bool dtPointInPolygon | ( | const float * | pt, |
const float * | verts, | ||
const int | nverts | ||
) |
Determines if the specified point is inside the convex polygon on the xz-plane.
[in] | pt | The point to check. [(x, y, z)] |
[in] | verts | The polygon vertices. [(x, y, z) * nverts ] |
[in] | nverts | The number of vertices. [Limit: >= 3] |
All points are projected onto the xz-plane, so the y-values are ignored.
void dtRandomPointInConvexPoly | ( | const float * | pts, |
const int | npts, | ||
float * | areas, | ||
const float | s, | ||
const float | t, | ||
float * | out | ||
) |
|
inline |
Returns the square of the value.
[in] | a | The value. |
|
inline |
Swaps the values of the two parameters.
[in,out] | a | Value A |
[in,out] | b | Value B |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Derives the signed xz-plane area of the triangle ABC, or the relationship of line AB to point C.
[in] | a | Vertex A. [(x, y, z)] |
[in] | b | Vertex B. [(x, y, z)] |
[in] | c | Vertex C. [(x, y, z)] |
The vertices are projected onto the xz-plane, so the y-values are ignored.
This is a low cost function than can be used for various purposes. Its main purpose is for point/line relationship testing.
In all cases: A value of zero indicates that all vertices are collinear or represent the same point. (On the xz-plane.)
When used for point/line relationship tests, AB usually represents a line against which the C point is to be tested. In this case:
A positive value indicates that point C is to the left of line AB, looking from A toward B.
A negative value indicates that point C is to the right of lineAB, looking from A toward B.
When used for evaluating a triangle:
The absolute value of the return value is two times the area of the triangle when it is projected onto the xz-plane.
A positive return value indicates:
A negative return value indicates:
|
inline |
Performs a vector addition.
(v1
+ v2
)
[out] | dest | The result vector. [(x, y, z)] |
[in] | v1 | The base vector. [(x, y, z)] |
[in] | v2 | The vector to add to v1 . [(x, y, z)] |
|
inline |
Performs a vector copy.
[out] | dest | The result. [(x, y, z)] |
[in] | a | The vector to copy. [(x, y, z)] |
|
inline |
Derives the cross product of two vectors.
(v1
x v2
)
[out] | dest | The cross product. [(x, y, z)] |
[in] | v1 | A Vector [(x, y, z)] |
[in] | v2 | A vector [(x, y, z)] |
|
inline |
Returns the distance between two points.
[in] | v1 | A point. [(x, y, z)] |
[in] | v2 | A point. [(x, y, z)] |
|
inline |
Derives the distance between the specified points on the xz-plane.
[in] | v1 | A point. [(x, y, z)] |
[in] | v2 | A point. [(x, y, z)] |
The vectors are projected onto the xz-plane, so the y-values are ignored.
|
inline |
Derives the square of the distance between the specified points on the xz-plane.
[in] | v1 | A point. [(x, y, z)] |
[in] | v2 | A point. [(x, y, z)] |
|
inline |
Returns the square of the distance between two points.
[in] | v1 | A point. [(x, y, z)] |
[in] | v2 | A point. [(x, y, z)] |
|
inline |
Derives the dot product of two vectors.
(v1
. v2
)
[in] | v1 | A Vector [(x, y, z)] |
[in] | v2 | A vector [(x, y, z)] |
|
inline |
Derives the dot product of two vectors on the xz-plane.
(u
. v
)
[in] | u | A vector [(x, y, z)] |
[in] | v | A vector [(x, y, z)] |
The vectors are projected onto the xz-plane, so the y-values are ignored.
|
inline |
Performs a 'sloppy' colocation check of the specified points.
[in] | p0 | A point. [(x, y, z)] |
[in] | p1 | A point. [(x, y, z)] |
Basically, this function will return true if the specified points are close enough to eachother to be considered colocated.
|
inline |
Checks that the specified vector's components are all finite.
[in] | v | A point. [(x, y, z)] |
|
inline |
Checks that the specified vector's 2D components are finite.
[in] | v | A point. [(x, y, z)] |
|
inline |
Derives the scalar length of the vector.
[in] | v | The vector. [(x, y, z)] |
|
inline |
Derives the square of the scalar length of the vector.
(len * len)
[in] | v | The vector. [(x, y, z)] |
|
inline |
Performs a linear interpolation between two vectors.
(v1
toward v2
)
[out] | dest | The result vector. [(x, y, x)] |
[in] | v1 | The starting vector. |
[in] | v2 | The destination vector. |
[in] | t | The interpolation factor. [Limits: 0 <= value <= 1.0] |
|
inline |
Performs a scaled vector addition.
(v1
+ (v2
* s
))
[out] | dest | The result vector. [(x, y, z)] |
[in] | v1 | The base vector. [(x, y, z)] |
[in] | v2 | The vector to scale and add to v1 . [(x, y, z)] |
[in] | s | The amount to scale v2 by before adding to v1 . |
|
inline |
Selects the maximum value of each element from the specified vectors.
[in,out] | mx | A vector. (Will be updated with the result.) [(x, y, z)] |
[in] | v | A vector. [(x, y, z)] |
|
inline |
Selects the minimum value of each element from the specified vectors.
[in,out] | mn | A vector. (Will be updated with the result.) [(x, y, z)] |
[in] | v | A vector. [(x, y, z)] |
|
inline |
Normalizes the vector.
[in,out] | v | The vector to normalize. [(x, y, z)] |
|
inline |
Derives the xz-plane 2D perp product of the two vectors.
(uz*vx - ux*vz)
[in] | u | The LHV vector [(x, y, z)] |
[in] | v | The RHV vector [(x, y, z)] |
The vectors are projected onto the xz-plane, so the y-values are ignored.
|
inline |
Scales the vector by the specified value.
(v
* t
)
[out] | dest | The result vector. [(x, y, z)] |
[in] | v | The vector to scale. [(x, y, z)] |
[in] | t | The scaling factor. |
|
inline |
Sets the vector elements to the specified values.
[out] | dest | The result vector. [(x, y, z)] |
[in] | x | The x-value of the vector. |
[in] | y | The y-value of the vector. |
[in] | z | The z-value of the vector. |
|
inline |
Performs a vector subtraction.
(v1
- v2
)
[out] | dest | The result vector. [(x, y, z)] |
[in] | v1 | The base vector. [(x, y, z)] |
[in] | v2 | The vector to subtract from v1 . [(x, y, z)] |