TrinityCore
|
#include "DetourMath.h"
Go to the source code of this file.
Functions | |
General helper functions | |
template<class T > | |
void | dtIgnoreUnused (const T &) |
template<class T > | |
void | dtSwap (T &a, T &b) |
template<class T > | |
T | dtMin (T a, T b) |
template<class T > | |
T | dtMax (T a, T b) |
template<class T > | |
T | dtAbs (T a) |
template<class T > | |
T | dtSqr (T a) |
template<class T > | |
T | dtClamp (T v, T mn, T mx) |
Vector helper functions. | |
void | dtVcross (float *dest, const float *v1, const float *v2) |
float | dtVdot (const float *v1, const float *v2) |
void | dtVmad (float *dest, const float *v1, const float *v2, const float s) |
void | dtVlerp (float *dest, const float *v1, const float *v2, const float t) |
void | dtVadd (float *dest, const float *v1, const float *v2) |
void | dtVsub (float *dest, const float *v1, const float *v2) |
void | dtVscale (float *dest, const float *v, const float t) |
void | dtVmin (float *mn, const float *v) |
void | dtVmax (float *mx, const float *v) |
void | dtVset (float *dest, const float x, const float y, const float z) |
void | dtVcopy (float *dest, const float *a) |
float | dtVlen (const float *v) |
float | dtVlenSqr (const float *v) |
float | dtVdist (const float *v1, const float *v2) |
float | dtVdistSqr (const float *v1, const float *v2) |
float | dtVdist2D (const float *v1, const float *v2) |
float | dtVdist2DSqr (const float *v1, const float *v2) |
void | dtVnormalize (float *v) |
bool | dtVequal (const float *p0, const float *p1) |
float | dtVdot2D (const float *u, const float *v) |
float | dtVperp2D (const float *u, const float *v) |
Computational geometry helper functions. | |
float | dtTriArea2D (const float *a, const float *b, const float *c) |
bool | dtOverlapQuantBounds (const unsigned short amin[3], const unsigned short amax[3], const unsigned short bmin[3], const unsigned short bmax[3]) |
bool | dtOverlapBounds (const float *amin, const float *amax, const float *bmin, const float *bmax) |
void | dtClosestPtPointTriangle (float *closest, const float *p, const float *a, const float *b, const float *c) |
bool | dtClosestHeightPointTriangle (const float *p, const float *a, const float *b, const float *c, float &h) |
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) |
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) |
bool | dtOverlapPolyPoly2D (const float *polya, const int npolya, const float *polyb, const int npolyb) |
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) |
|
inline |
|
inline |
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 | ||
) |
void dtIgnoreUnused | ( | const T & | ) |
|
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 |
|
inline |
|
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)] |
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 |
|
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:
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 |
Returns the distance between two points.
[in] | v1 | A point. [(x, y, z)] |
[in] | v2 | A point. [(x, y, z)] |
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.
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)] |
Returns the square of the distance between two points.
[in] | v1 | A point. [(x, y, z)] |
[in] | v2 | A point. [(x, y, z)] |
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.
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 |
Derives the scalar length of the vector.
[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] |
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)] |
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.
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. |
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)] |