Planeshift
|
Go to the source code of this file.
Functions | |
General helper functions | |
template<class T > | |
void | dtSwap (T &a, T &b) |
Swaps the values of the two parameters. | |
template<class T > | |
T | dtMin (T a, T b) |
Returns the minimum of two values. | |
template<class T > | |
T | dtMax (T a, T b) |
Returns the maximum of two values. | |
template<class T > | |
T | dtAbs (T a) |
Returns the absolute value. | |
template<class T > | |
T | dtSqr (T a) |
Returns the square of the value. | |
template<class T > | |
T | dtClamp (T v, T mn, T mx) |
Clamps the value to the specified range. | |
float | dtSqrt (float x) |
Returns the square root of the value. | |
Vector helper functions. | |
void | dtVcross (float *dest, const float *v1, const float *v2) |
Derives the cross product of two vectors. (v1 x v2 ) | |
float | dtVdot (const float *v1, const float *v2) |
Derives the dot product of two vectors. (v1 . v2 ) | |
void | dtVmad (float *dest, const float *v1, const float *v2, const float s) |
Performs a scaled vector addition. (v1 + (v2 * s )) | |
void | dtVlerp (float *dest, const float *v1, const float *v2, const float t) |
Performs a linear interpolation between two vectors. (v1 toward v2 ) | |
void | dtVadd (float *dest, const float *v1, const float *v2) |
Performs a vector addition. (v1 + v2 ) | |
void | dtVsub (float *dest, const float *v1, const float *v2) |
Performs a vector subtraction. (v1 - v2 ) | |
void | dtVscale (float *dest, const float *v, const float t) |
Scales the vector by the specified value. (v * t ) | |
void | dtVmin (float *mn, const float *v) |
Selects the minimum value of each element from the specified vectors. | |
void | dtVmax (float *mx, const float *v) |
Selects the maximum value of each element from the specified vectors. | |
void | dtVset (float *dest, const float x, const float y, const float z) |
Sets the vector elements to the specified values. | |
void | dtVcopy (float *dest, const float *a) |
Performs a vector copy. | |
float | dtVlen (const float *v) |
Derives the scalar length of the vector. | |
float | dtVlenSqr (const float *v) |
Derives the square of the scalar length of the vector. (len * len) | |
float | dtVdist (const float *v1, const float *v2) |
Returns the distance between two points. | |
float | dtVdistSqr (const float *v1, const float *v2) |
Returns the square of the distance between two points. | |
float | dtVdist2D (const float *v1, const float *v2) |
Derives the distance between the specified points on the xz-plane. | |
float | dtVdist2DSqr (const float *v1, const float *v2) |
Derives the square of the distance between the specified points on the xz-plane. | |
void | dtVnormalize (float *v) |
Normalizes the vector. | |
bool | dtVequal (const float *p0, const float *p1) |
Performs a 'sloppy' colocation check of the specified points. | |
float | dtVdot2D (const float *u, const float *v) |
Derives the dot product of two vectors on the xz-plane. (u . v ) | |
float | dtVperp2D (const float *u, const float *v) |
Derives the xz-plane 2D perp product of the two vectors. (uz*vx - ux*vz) | |
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. | |
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. | |
bool | dtOverlapBounds (const float *amin, const float *amax, const float *bmin, const float *bmax) |
Determines if two axis-aligned bounding boxes overlap. | |
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. | |
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. | |
bool | dtIntersectSegmentPoly2D (const float *p0, const float *p1, const float *verts, int nverts, float &tmin, float &tmax, int &segMin, int &segMax) |
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. | |
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. | |
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. | |
Miscellaneous 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) |
T dtAbs | ( | T | a | ) | [inline] |
Returns the absolute value.
[in] | a | The value. |
Definition at line 55 of file DetourCommon.h.
Definition at line 435 of file DetourCommon.h.
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] |
T dtClamp | ( | T | v, |
T | mn, | ||
T | mx | ||
) | [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. |
Definition at line 67 of file DetourCommon.h.
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 | ||
) |
bool dtIntersectSegmentPoly2D | ( | const float * | p0, |
const float * | p1, | ||
const float * | verts, | ||
int | nverts, | ||
float & | tmin, | ||
float & | tmax, | ||
int & | segMin, | ||
int & | segMax | ||
) |
T dtMax | ( | T | a, |
T | b | ||
) | [inline] |
Returns the maximum of two values.
[in] | a | Value A |
[in] | b | Value B |
Definition at line 50 of file DetourCommon.h.
T dtMin | ( | T | a, |
T | b | ||
) | [inline] |
Returns the minimum of two values.
[in] | a | Value A |
[in] | b | Value B |
Definition at line 44 of file DetourCommon.h.
Definition at line 437 of file DetourCommon.h.
bool dtOverlapBounds | ( | const float * | amin, |
const float * | amax, | ||
const float * | bmin, | ||
const float * | bmax | ||
) | [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)] |
Definition at line 347 of file DetourCommon.h.
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. |
bool dtOverlapQuantBounds | ( | const unsigned short | amin[3], |
const unsigned short | amax[3], | ||
const unsigned short | bmin[3], | ||
const unsigned short | bmax[3] | ||
) | [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)] |
Definition at line 330 of file DetourCommon.h.
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] |
void dtRandomPointInConvexPoly | ( | const float * | pts, |
const int | npts, | ||
float * | areas, | ||
const float | s, | ||
const float | t, | ||
float * | out | ||
) |
T dtSqr | ( | T | a | ) | [inline] |
Returns the square of the value.
[in] | a | The value. |
Definition at line 60 of file DetourCommon.h.
Returns the square root of the value.
[in] | x | The value. |
void dtSwap | ( | T & | a, |
T & | b | ||
) | [inline] |
Swaps the values of the two parameters.
[in,out] | a | Value A |
[in,out] | b | Value B |
Definition at line 38 of file DetourCommon.h.
Definition at line 439 of file DetourCommon.h.
Definition at line 458 of file DetourCommon.h.
void dtSwapEndian | ( | unsigned short * | v | ) | [inline] |
Definition at line 446 of file DetourCommon.h.
void dtSwapEndian | ( | short * | v | ) | [inline] |
Definition at line 452 of file DetourCommon.h.
void dtSwapEndian | ( | float * | v | ) | [inline] |
Definition at line 470 of file DetourCommon.h.
void dtSwapEndian | ( | int * | v | ) | [inline] |
Definition at line 464 of file DetourCommon.h.
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:
Definition at line 314 of file DetourCommon.h.
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)] |
Definition at line 126 of file DetourCommon.h.
Performs a vector copy.
[out] | dest | The result. [(x, y, z)] |
[in] | a | The vector to copy. [(x, y, z)] |
Definition at line 188 of file DetourCommon.h.
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)] |
Definition at line 82 of file DetourCommon.h.
Returns the distance between two points.
[in] | v1 | A point. [(x, y, z)] |
[in] | v2 | A point. [(x, y, z)] |
Definition at line 215 of file DetourCommon.h.
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.
Definition at line 241 of file DetourCommon.h.
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)] |
Definition at line 252 of file DetourCommon.h.
Returns the square of the distance between two points.
[in] | v1 | A point. [(x, y, z)] |
[in] | v2 | A point. [(x, y, z)] |
Definition at line 227 of file DetourCommon.h.
Derives the dot product of two vectors. (v1
. v2
)
[in] | v1 | A Vector [(x, y, z)] |
[in] | v2 | A vector [(x, y, z)] |
Definition at line 93 of file DetourCommon.h.
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.
Definition at line 289 of file DetourCommon.h.
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.
Definition at line 276 of file DetourCommon.h.
Derives the scalar length of the vector.
[in] | v | The vector. [(x, y, z)] |
Definition at line 198 of file DetourCommon.h.
Derives the square of the scalar length of the vector. (len * len)
[in] | v | The vector. [(x, y, z)] |
Definition at line 206 of file DetourCommon.h.
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] |
Definition at line 115 of file DetourCommon.h.
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 . |
Definition at line 103 of file DetourCommon.h.
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)] |
Definition at line 168 of file DetourCommon.h.
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)] |
Definition at line 158 of file DetourCommon.h.
void dtVnormalize | ( | float * | v | ) | [inline] |
Normalizes the vector.
[in,out] | v | The vector to normalize. [(x, y, z)] |
Definition at line 261 of file DetourCommon.h.
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.
Definition at line 300 of file DetourCommon.h.
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. |
Definition at line 148 of file DetourCommon.h.
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. |
Definition at line 180 of file DetourCommon.h.
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)] |
Definition at line 137 of file DetourCommon.h.