mirror of
https://github.com/Mauler125/r5sdk.git
synced 2025-02-09 19:15:03 +01:00
More XZY->XYZ changes
* dtIntersectSegSeg2D: Calculate over zy-plane instead. * dtOverlapPolyPoly2D: Calculate over zy-plane instead. * dtNavMeshQuery::findRandomPoint: z = h. * dtNavMeshQuery::raycast: Invert hit normals. * Update all comments to use xyz vector instead (previously xzy (xz-plane z-height)).
This commit is contained in:
parent
c7d61e8b77
commit
cbaf10478a
@ -46,7 +46,7 @@ inline bool cmppt(const float* a, const float* b)
|
||||
if (a[1] > b[1]) return false;
|
||||
return false;
|
||||
}
|
||||
// Calculates convex hull on xz-plane of points on 'pts',
|
||||
// Calculates convex hull on xy-plane of points on 'pts',
|
||||
// stores the indices of the resulting hull in 'out' and
|
||||
// returns number of points on hull.
|
||||
static int convexhull(const float* pts, int npts, int* out)
|
||||
|
@ -305,7 +305,7 @@ inline bool dtVisfinite2D(const float* v)
|
||||
return result;
|
||||
}
|
||||
|
||||
/// Derives the dot product of two vectors on the xz-plane. (@p u . @p v)
|
||||
/// Derives the dot product of two vectors on the xy-plane. (@p u . @p v)
|
||||
/// @param[in] u A vector [(x, y, z)]
|
||||
/// @param[in] v A vector [(x, y, z)]
|
||||
/// @return The dot product on the xy-plane.
|
||||
@ -407,7 +407,7 @@ bool dtIntersectSegSeg2D(const float* ap, const float* aq,
|
||||
|
||||
float distancePtLine2d(const float* pt, const float* p, const float* q);
|
||||
|
||||
/// Determines if the specified point is inside the convex polygon on the xz-plane.
|
||||
/// Determines if the specified point is inside the convex polygon on the xy-plane.
|
||||
/// @param[in] pt The point to check. [(x, y, z)]
|
||||
/// @param[in] verts The polygon vertices. [(x, y, z) * @p nverts]
|
||||
/// @param[in] nverts The number of vertices. [Limit: >= 3]
|
||||
@ -426,7 +426,7 @@ float dtDistancePtSegSqr2D(const float* pt, const float* p, const float* q, floa
|
||||
/// @param[in] verts The polygon vertices. [(x, y, z) * vertCount]
|
||||
void dtCalcPolyCenter(float* tc, const unsigned short* idx, int nidx, const float* verts);
|
||||
|
||||
/// Determines if the two convex polygons overlap on the xz-plane.
|
||||
/// Determines if the two convex polygons overlap on the xy-plane.
|
||||
/// @param[in] polya Polygon A vertices. [(x, y, z) * @p npolya]
|
||||
/// @param[in] npolya The number of vertices in polygon A.
|
||||
/// @param[in] polyb Polygon B vertices. [(x, y, z) * @p npolyb]
|
||||
@ -538,13 +538,13 @@ TypeToRetrieveAs* dtGetThenAdvanceBufferPointer(unsigned char*& buffer, const si
|
||||
@fn float dtTriArea2D(const float* a, const float* b, const float* c)
|
||||
@par
|
||||
|
||||
The vertices are projected onto the xz-plane, so the y-values are ignored.
|
||||
The vertices are projected onto the xy-plane, so the z-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.)
|
||||
(On the xy-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:
|
||||
@ -555,7 +555,7 @@ A negative value indicates that point C is to the right of lineAB, looking from
|
||||
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.
|
||||
projected onto the xy-plane.
|
||||
|
||||
A positive return value indicates:
|
||||
|
||||
|
@ -94,8 +94,8 @@ struct dtNavMeshCreateParams
|
||||
float walkableHeight; ///< The agent height. [Unit: wu]
|
||||
float walkableRadius; ///< The agent radius. [Unit: wu]
|
||||
float walkableClimb; ///< The agent maximum traversable ledge. (Up/Down) [Unit: wu]
|
||||
float cs; ///< The xz-plane cell size of the polygon mesh. [Limit: > 0] [Unit: wu]
|
||||
float ch; ///< The y-axis cell height of the polygon mesh. [Limit: > 0] [Unit: wu]
|
||||
float cs; ///< The xy-plane cell size of the polygon mesh. [Limit: > 0] [Unit: wu]
|
||||
float ch; ///< The z-axis cell height of the polygon mesh. [Limit: > 0] [Unit: wu]
|
||||
|
||||
/// True if a bounding volume tree should be built for the tile.
|
||||
/// @note The BVTree is not normally needed for layered navigation meshes.
|
||||
|
@ -290,7 +290,7 @@ inline bool overlapRange(const float amin, const float amax,
|
||||
|
||||
/// @par
|
||||
///
|
||||
/// All vertices are projected onto the xz-plane, so the y-values are ignored.
|
||||
/// All vertices are projected onto the xy-plane, so the z-values are ignored.
|
||||
bool dtOverlapPolyPoly2D(const float* polya, const int npolya,
|
||||
const float* polyb, const int npolyb)
|
||||
{
|
||||
@ -300,7 +300,7 @@ bool dtOverlapPolyPoly2D(const float* polya, const int npolya,
|
||||
{
|
||||
const float* va = &polya[j*3];
|
||||
const float* vb = &polya[i*3];
|
||||
const float n[3] = { vb[2]-va[2], 0, -(vb[0]-va[0]) };
|
||||
const float n[3] = { vb[1]-va[1], 0, -(vb[0]-va[0]) };
|
||||
float amin,amax,bmin,bmax;
|
||||
projectPoly(n, polya, npolya, amin,amax);
|
||||
projectPoly(n, polyb, npolyb, bmin,bmax);
|
||||
@ -314,7 +314,7 @@ bool dtOverlapPolyPoly2D(const float* polya, const int npolya,
|
||||
{
|
||||
const float* va = &polyb[j*3];
|
||||
const float* vb = &polyb[i*3];
|
||||
const float n[3] = { vb[2]-va[2], 0, -(vb[0]-va[0]) };
|
||||
const float n[3] = { vb[1]-va[1], 0, -(vb[0]-va[0]) };
|
||||
float amin,amax,bmin,bmax;
|
||||
projectPoly(n, polya, npolya, amin,amax);
|
||||
projectPoly(n, polyb, npolyb, bmin,bmax);
|
||||
@ -388,14 +388,13 @@ bool dtIntersectSegSeg2D(const float* ap, const float* aq,
|
||||
float distancePtLine2d(const float* pt, const float* p, const float* q)
|
||||
{
|
||||
float pqx = q[0] - p[0];
|
||||
float pqz = q[2] - p[2];
|
||||
float pqy = q[1] - p[1];
|
||||
float dx = pt[0] - p[0];
|
||||
float dz = pt[2] - p[2];
|
||||
float d = pqx * pqx + pqz * pqz;
|
||||
float t = pqx * dx + pqz * dz;
|
||||
float dy = pt[1] - p[1];
|
||||
float d = pqx * pqx + pqy * pqy;
|
||||
float t = pqx * dx + pqy * dy;
|
||||
if (d != 0) t /= d;
|
||||
dx = p[0] + t * pqx - pt[0];
|
||||
dz = p[2] + t * pqz - pt[2];
|
||||
return dx * dx + dz * dz;
|
||||
dy = p[1] + t * pqy - pt[1];
|
||||
return dx * dx + dy * dy;
|
||||
}
|
||||
|
||||
|
@ -305,7 +305,7 @@ dtStatus dtNavMeshQuery::findRandomPoint(const dtQueryFilter* filter, float (*fr
|
||||
dtStatus status = getPolyHeight(polyRef, pt, &h);
|
||||
if (dtStatusFailed(status))
|
||||
return status;
|
||||
pt[1] = h;
|
||||
pt[2] = h;
|
||||
|
||||
dtVcopy(randomPt, pt);
|
||||
*randomRef = polyRef;
|
||||
@ -2654,8 +2654,8 @@ dtStatus dtNavMeshQuery::raycast(dtPolyRef startRef, const float* startPos, cons
|
||||
const float* vb = &verts[b*3];
|
||||
const float dx = vb[0] - va[0];
|
||||
const float dy = vb[1] - va[1];
|
||||
hit->hitNormal[0] = dy;
|
||||
hit->hitNormal[1] = -dx;
|
||||
hit->hitNormal[0] = -dy;
|
||||
hit->hitNormal[1] = dx;
|
||||
hit->hitNormal[2] = 0;
|
||||
dtVnormalize(hit->hitNormal);
|
||||
|
||||
@ -2700,7 +2700,7 @@ dtStatus dtNavMeshQuery::raycast(dtPolyRef startRef, const float* startPos, cons
|
||||
/// y-value will effect the costs.
|
||||
///
|
||||
/// Intersection tests occur in 2D. All polygons and the search circle are
|
||||
/// projected onto the xz-plane. So the y-value of the center point does not
|
||||
/// projected onto the xy-plane. So the z-value of the center point does not
|
||||
/// effect intersection tests.
|
||||
///
|
||||
/// If the result arrays are to small to hold the entire result set, they will be
|
||||
@ -2875,7 +2875,7 @@ dtStatus dtNavMeshQuery::findPolysAroundCircle(dtPolyRef startRef, const float*
|
||||
/// calculations.
|
||||
///
|
||||
/// Intersection tests occur in 2D. All polygons are projected onto the
|
||||
/// xz-plane. So the y-values of the vertices do not effect intersection tests.
|
||||
/// xy-plane. So the z-values of the vertices do not effect intersection tests.
|
||||
///
|
||||
/// If the result arrays are is too small to hold the entire result set, they will
|
||||
/// be filled to capacity.
|
||||
@ -3072,7 +3072,7 @@ dtStatus dtNavMeshQuery::getPathFromDijkstraSearch(dtPolyRef endRef, dtPolyRef*
|
||||
/// the costs.
|
||||
///
|
||||
/// Intersection tests occur in 2D. All polygons and the search circle are
|
||||
/// projected onto the xz-plane. So the y-value of the center point does not
|
||||
/// projected onto the xy-plane. So the z-value of the center point does not
|
||||
/// effect intersection tests.
|
||||
///
|
||||
/// If the result arrays are is too small to hold the entire result set, they will
|
||||
|
34
r5dev/thirdparty/recast/Recast/Include/Recast.h
vendored
34
r5dev/thirdparty/recast/Recast/Include/Recast.h
vendored
@ -203,16 +203,16 @@ struct rcConfig
|
||||
/// The height of the field along the z-axis. [Limit: >= 0] [Units: vx]
|
||||
int height;
|
||||
|
||||
/// The width/height size of tile's on the xz-plane. [Limit: >= 0] [Units: vx]
|
||||
/// The width/height size of tile's on the xy-plane. [Limit: >= 0] [Units: vx]
|
||||
int tileSize;
|
||||
|
||||
/// The size of the non-navigable border around the heightfield. [Limit: >=0] [Units: vx]
|
||||
int borderSize;
|
||||
|
||||
/// The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
|
||||
/// The xy-plane cell size to use for fields. [Limit: > 0] [Units: wu]
|
||||
float cs;
|
||||
|
||||
/// The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
|
||||
/// The z-axis cell size to use for fields. [Limit: > 0] [Units: wu]
|
||||
float ch;
|
||||
|
||||
/// The minimum bounds of the field's AABB. [(x, y, z)] [Units: wu]
|
||||
@ -300,8 +300,8 @@ struct rcHeightfield
|
||||
int height; ///< The height of the heightfield. (Along the z-axis in cell units.)
|
||||
float bmin[3]; ///< The minimum bounds in world space. [(x, y, z)]
|
||||
float bmax[3]; ///< The maximum bounds in world space. [(x, y, z)]
|
||||
float cs; ///< The size of each cell. (On the xz-plane.)
|
||||
float ch; ///< The height of each cell. (The minimum increment along the y-axis.)
|
||||
float cs; ///< The size of each cell. (On the xy-plane.)
|
||||
float ch; ///< The height of each cell. (The minimum increment along the z-axis.)
|
||||
rcSpan** spans; ///< Heightfield of spans (width*height).
|
||||
rcSpanPool* pools; ///< Linked list of span pools.
|
||||
rcSpan* freelist; ///< The next free span.
|
||||
@ -344,8 +344,8 @@ struct rcCompactHeightfield
|
||||
unsigned short maxRegions; ///< The maximum region id of any span within the field.
|
||||
float bmin[3]; ///< The minimum bounds in world space. [(x, y, z)]
|
||||
float bmax[3]; ///< The maximum bounds in world space. [(x, y, z)]
|
||||
float cs; ///< The size of each cell. (On the xz-plane.)
|
||||
float ch; ///< The height of each cell. (The minimum increment along the y-axis.)
|
||||
float cs; ///< The size of each cell. (On the xy-plane.)
|
||||
float ch; ///< The height of each cell. (The minimum increment along the z-axis.)
|
||||
rcCompactCell* cells; ///< Array of cells. [Size: #width*#height]
|
||||
rcCompactSpan* spans; ///< Array of spans. [Size: #spanCount]
|
||||
unsigned short* dist; ///< Array containing border distance data. [Size: #spanCount]
|
||||
@ -358,8 +358,8 @@ struct rcHeightfieldLayer
|
||||
{
|
||||
float bmin[3]; ///< The minimum bounds in world space. [(x, y, z)]
|
||||
float bmax[3]; ///< The maximum bounds in world space. [(x, y, z)]
|
||||
float cs; ///< The size of each cell. (On the xz-plane.)
|
||||
float ch; ///< The height of each cell. (The minimum increment along the y-axis.)
|
||||
float cs; ///< The size of each cell. (On the xy-plane.)
|
||||
float ch; ///< The height of each cell. (The minimum increment along the z-axis.)
|
||||
int width; ///< The width of the heightfield. (Along the x-axis in cell units.)
|
||||
int height; ///< The height of the heightfield. (Along the z-axis in cell units.)
|
||||
int minx; ///< The minimum x-bounds of usable data.
|
||||
@ -405,8 +405,8 @@ struct rcContourSet
|
||||
int nconts; ///< The number of contours in the set.
|
||||
float bmin[3]; ///< The minimum bounds in world space. [(x, y, z)]
|
||||
float bmax[3]; ///< The maximum bounds in world space. [(x, y, z)]
|
||||
float cs; ///< The size of each cell. (On the xz-plane.)
|
||||
float ch; ///< The height of each cell. (The minimum increment along the y-axis.)
|
||||
float cs; ///< The size of each cell. (On the xy-plane.)
|
||||
float ch; ///< The height of each cell. (The minimum increment along the z-axis.)
|
||||
int width; ///< The width of the set. (Along the x-axis in cell units.)
|
||||
int height; ///< The height of the set. (Along the z-axis in cell units.)
|
||||
int borderSize; ///< The AABB border size used to generate the source data from which the contours were derived.
|
||||
@ -430,8 +430,8 @@ struct rcPolyMesh
|
||||
int nvp; ///< The maximum number of vertices per polygon.
|
||||
float bmin[3]; ///< The minimum bounds in world space. [(x, y, z)]
|
||||
float bmax[3]; ///< The maximum bounds in world space. [(x, y, z)]
|
||||
float cs; ///< The size of each cell. (On the xz-plane.)
|
||||
float ch; ///< The height of each cell. (The minimum increment along the y-axis.)
|
||||
float cs; ///< The size of each cell. (On the xy-plane.)
|
||||
float ch; ///< The height of each cell. (The minimum increment along the z-axis.)
|
||||
int borderSize; ///< The AABB border size used to generate the source data from which the mesh was derived.
|
||||
float maxEdgeError; ///< The max error of the polygon edges in the mesh.
|
||||
};
|
||||
@ -785,9 +785,9 @@ void rcCalcBounds(const float* verts, int nv, float* bmin, float* bmax);
|
||||
/// @ingroup recast
|
||||
/// @param[in] bmin The minimum bounds of the AABB. [(x, y, z)] [Units: wu]
|
||||
/// @param[in] bmax The maximum bounds of the AABB. [(x, y, z)] [Units: wu]
|
||||
/// @param[in] cs The xz-plane cell size. [Limit: > 0] [Units: wu]
|
||||
/// @param[in] cs The xy-plane cell size. [Limit: > 0] [Units: wu]
|
||||
/// @param[out] w The width along the x-axis. [Limit: >= 0] [Units: vx]
|
||||
/// @param[out] h The height along the z-axis. [Limit: >= 0] [Units: vx]
|
||||
/// @param[out] h The height along the y-axis. [Limit: >= 0] [Units: vx]
|
||||
void rcCalcGridSize(const float* bmin, const float* bmax, float cs, int* w, int* h);
|
||||
|
||||
/// Initializes a new heightfield.
|
||||
@ -798,8 +798,8 @@ void rcCalcGridSize(const float* bmin, const float* bmax, float cs, int* w, int*
|
||||
/// @param[in] height The height of the field along the z-axis. [Limit: >= 0] [Units: vx]
|
||||
/// @param[in] bmin The minimum bounds of the field's AABB. [(x, y, z)] [Units: wu]
|
||||
/// @param[in] bmax The maximum bounds of the field's AABB. [(x, y, z)] [Units: wu]
|
||||
/// @param[in] cs The xz-plane cell size to use for the field. [Limit: > 0] [Units: wu]
|
||||
/// @param[in] ch The y-axis cell size to use for field. [Limit: > 0] [Units: wu]
|
||||
/// @param[in] cs The xy-plane cell size to use for the field. [Limit: > 0] [Units: wu]
|
||||
/// @param[in] ch The z-axis cell size to use for field. [Limit: > 0] [Units: wu]
|
||||
/// @returns True if the operation completed successfully.
|
||||
bool rcCreateHeightfield(rcContext* ctx, rcHeightfield& hf, int width, int height,
|
||||
const float* bmin, const float* bmax,
|
||||
|
@ -375,7 +375,7 @@ static int pointInPoly(int nvert, const float* verts, const float* p)
|
||||
/// The value of spacial parameters are in world units.
|
||||
///
|
||||
/// The y-values of the polygon vertices are ignored. So the polygon is effectively
|
||||
/// projected onto the xz-plane at @p hmin, then extruded to @p hmax.
|
||||
/// projected onto the xy-plane at @p hmin, then extruded to @p hmax.
|
||||
///
|
||||
/// @see rcCompactHeightfield, rcMedianFilterWalkableArea
|
||||
void rcMarkConvexPolyArea(rcContext* ctx, const float* verts, const int nverts,
|
||||
@ -429,8 +429,8 @@ void rcMarkConvexPolyArea(rcContext* ctx, const float* verts, const int nverts,
|
||||
if ((int)s.z >= minz && (int)s.z <= maxz)
|
||||
{
|
||||
float p[3];
|
||||
p[0] = chf.bmin[0] + (x+0.5f)*chf.cs;
|
||||
p[1] = chf.bmin[1] + (y + 0.5f)*chf.cs;
|
||||
p[0] = chf.bmin[0] + (x+0.5f)*chf.cs;
|
||||
p[1] = chf.bmin[1] + (y+0.5f)*chf.cs;
|
||||
p[2] = 0;
|
||||
|
||||
if (pointInPoly(nverts, verts, p))
|
||||
|
@ -579,7 +579,7 @@ static bool inCone(int i, int n, const int* verts, const int* pj)
|
||||
|
||||
static void removeDegenerateSegments(rcIntArray& simplified)
|
||||
{
|
||||
// Remove adjacent vertices which are equal on xz-plane,
|
||||
// Remove adjacent vertices which are equal on xy-plane,
|
||||
// or else the triangulator will get confused.
|
||||
int npts = simplified.size()/4;
|
||||
for (int i = 0; i < npts; ++i)
|
||||
|
Loading…
x
Reference in New Issue
Block a user