Moved common functions behind name decoration.
This commit is contained in:
parent
b21e854c9a
commit
10b330ffb4
@ -21,75 +21,75 @@
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
template<class T> inline void swap(T& a, T& b) { T t = a; a = b; b = t; }
|
||||
template<class T> inline T min(T a, T b) { return a < b ? a : b; }
|
||||
template<class T> inline T max(T a, T b) { return a > b ? a : b; }
|
||||
template<class T> inline T abs(T a) { return a < 0 ? -a : a; }
|
||||
template<class T> inline T sqr(T a) { return a*a; }
|
||||
template<class T> inline T clamp(T v, T mn, T mx) { return v < mn ? mn : (v > mx ? mx : v); }
|
||||
template<class T> inline void dtSwap(T& a, T& b) { T t = a; a = b; b = t; }
|
||||
template<class T> inline T dtMin(T a, T b) { return a < b ? a : b; }
|
||||
template<class T> inline T dtMax(T a, T b) { return a > b ? a : b; }
|
||||
template<class T> inline T dtAbs(T a) { return a < 0 ? -a : a; }
|
||||
template<class T> inline T dtSqr(T a) { return a*a; }
|
||||
template<class T> inline T dtClamp(T v, T mn, T mx) { return v < mn ? mn : (v > mx ? mx : v); }
|
||||
|
||||
inline void vcross(float* dest, const float* v1, const float* v2)
|
||||
inline void dtVcross(float* dest, const float* v1, const float* v2)
|
||||
{
|
||||
dest[0] = v1[1]*v2[2] - v1[2]*v2[1];
|
||||
dest[1] = v1[2]*v2[0] - v1[0]*v2[2];
|
||||
dest[2] = v1[0]*v2[1] - v1[1]*v2[0];
|
||||
}
|
||||
|
||||
inline float vdot(const float* v1, const float* v2)
|
||||
inline float dtVdot(const float* v1, const float* v2)
|
||||
{
|
||||
return v1[0]*v2[0] + v1[1]*v2[1] + v1[2]*v2[2];
|
||||
}
|
||||
|
||||
inline void vmad(float* dest, const float* v1, const float* v2, const float s)
|
||||
inline void dtVmad(float* dest, const float* v1, const float* v2, const float s)
|
||||
{
|
||||
dest[0] = v1[0]+v2[0]*s;
|
||||
dest[1] = v1[1]+v2[1]*s;
|
||||
dest[2] = v1[2]+v2[2]*s;
|
||||
}
|
||||
|
||||
inline void vlerp(float* dest, const float* v1, const float* v2, const float t)
|
||||
inline void dtVlerp(float* dest, const float* v1, const float* v2, const float t)
|
||||
{
|
||||
dest[0] = v1[0]+(v2[0]-v1[0])*t;
|
||||
dest[1] = v1[1]+(v2[1]-v1[1])*t;
|
||||
dest[2] = v1[2]+(v2[2]-v1[2])*t;
|
||||
}
|
||||
|
||||
inline void vadd(float* dest, const float* v1, const float* v2)
|
||||
inline void dtVadd(float* dest, const float* v1, const float* v2)
|
||||
{
|
||||
dest[0] = v1[0]+v2[0];
|
||||
dest[1] = v1[1]+v2[1];
|
||||
dest[2] = v1[2]+v2[2];
|
||||
}
|
||||
|
||||
inline void vsub(float* dest, const float* v1, const float* v2)
|
||||
inline void dtVsub(float* dest, const float* v1, const float* v2)
|
||||
{
|
||||
dest[0] = v1[0]-v2[0];
|
||||
dest[1] = v1[1]-v2[1];
|
||||
dest[2] = v1[2]-v2[2];
|
||||
}
|
||||
|
||||
inline void vmin(float* mn, const float* v)
|
||||
inline void dtVmin(float* mn, const float* v)
|
||||
{
|
||||
mn[0] = min(mn[0], v[0]);
|
||||
mn[1] = min(mn[1], v[1]);
|
||||
mn[2] = min(mn[2], v[2]);
|
||||
mn[0] = dtMin(mn[0], v[0]);
|
||||
mn[1] = dtMin(mn[1], v[1]);
|
||||
mn[2] = dtMin(mn[2], v[2]);
|
||||
}
|
||||
|
||||
inline void vmax(float* mx, const float* v)
|
||||
inline void dtVmax(float* mx, const float* v)
|
||||
{
|
||||
mx[0] = max(mx[0], v[0]);
|
||||
mx[1] = max(mx[1], v[1]);
|
||||
mx[2] = max(mx[2], v[2]);
|
||||
mx[0] = dtMax(mx[0], v[0]);
|
||||
mx[1] = dtMax(mx[1], v[1]);
|
||||
mx[2] = dtMax(mx[2], v[2]);
|
||||
}
|
||||
|
||||
inline void vcopy(float* dest, const float* a)
|
||||
inline void dtVcopy(float* dest, const float* a)
|
||||
{
|
||||
dest[0] = a[0];
|
||||
dest[1] = a[1];
|
||||
dest[2] = a[2];
|
||||
}
|
||||
|
||||
inline float vdist(const float* v1, const float* v2)
|
||||
inline float dtVdist(const float* v1, const float* v2)
|
||||
{
|
||||
float dx = v2[0] - v1[0];
|
||||
float dy = v2[1] - v1[1];
|
||||
@ -97,7 +97,7 @@ inline float vdist(const float* v1, const float* v2)
|
||||
return sqrtf(dx*dx + dy*dy + dz*dz);
|
||||
}
|
||||
|
||||
inline float vdistSqr(const float* v1, const float* v2)
|
||||
inline float dtVdistSqr(const float* v1, const float* v2)
|
||||
{
|
||||
float dx = v2[0] - v1[0];
|
||||
float dy = v2[1] - v1[1];
|
||||
@ -105,18 +105,18 @@ inline float vdistSqr(const float* v1, const float* v2)
|
||||
return dx*dx + dy*dy + dz*dz;
|
||||
}
|
||||
|
||||
inline void vnormalize(float* v)
|
||||
inline void dtVnormalize(float* v)
|
||||
{
|
||||
float d = 1.0f / sqrtf(sqr(v[0]) + sqr(v[1]) + sqr(v[2]));
|
||||
float d = 1.0f / sqrtf(dtSqr(v[0]) + dtSqr(v[1]) + dtSqr(v[2]));
|
||||
v[0] *= d;
|
||||
v[1] *= d;
|
||||
v[2] *= d;
|
||||
}
|
||||
|
||||
inline bool vequal(const float* p0, const float* p1)
|
||||
inline bool dtVequal(const float* p0, const float* p1)
|
||||
{
|
||||
static const float thr = sqr(1.0f/16384.0f);
|
||||
const float d = vdistSqr(p0, p1);
|
||||
static const float thr = dtSqr(1.0f/16384.0f);
|
||||
const float d = dtVdistSqr(p0, p1);
|
||||
return d < thr;
|
||||
}
|
||||
|
||||
|
@ -24,27 +24,27 @@ void closestPtPointTriangle(float* closest, const float* p,
|
||||
{
|
||||
// Check if P in vertex region outside A
|
||||
float ab[3], ac[3], ap[3];
|
||||
vsub(ab, b, a);
|
||||
vsub(ac, c, a);
|
||||
vsub(ap, p, a);
|
||||
float d1 = vdot(ab, ap);
|
||||
float d2 = vdot(ac, ap);
|
||||
dtVsub(ab, b, a);
|
||||
dtVsub(ac, c, a);
|
||||
dtVsub(ap, p, a);
|
||||
float d1 = dtVdot(ab, ap);
|
||||
float d2 = dtVdot(ac, ap);
|
||||
if (d1 <= 0.0f && d2 <= 0.0f)
|
||||
{
|
||||
// barycentric coordinates (1,0,0)
|
||||
vcopy(closest, a);
|
||||
dtVcopy(closest, a);
|
||||
return;
|
||||
}
|
||||
|
||||
// Check if P in vertex region outside B
|
||||
float bp[3];
|
||||
vsub(bp, p, b);
|
||||
float d3 = vdot(ab, bp);
|
||||
float d4 = vdot(ac, bp);
|
||||
dtVsub(bp, p, b);
|
||||
float d3 = dtVdot(ab, bp);
|
||||
float d4 = dtVdot(ac, bp);
|
||||
if (d3 >= 0.0f && d4 <= d3)
|
||||
{
|
||||
// barycentric coordinates (0,1,0)
|
||||
vcopy(closest, b);
|
||||
dtVcopy(closest, b);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -62,13 +62,13 @@ void closestPtPointTriangle(float* closest, const float* p,
|
||||
|
||||
// Check if P in vertex region outside C
|
||||
float cp[3];
|
||||
vsub(cp, p, c);
|
||||
float d5 = vdot(ab, cp);
|
||||
float d6 = vdot(ac, cp);
|
||||
dtVsub(cp, p, c);
|
||||
float d5 = dtVdot(ab, cp);
|
||||
float d6 = dtVdot(ac, cp);
|
||||
if (d6 >= 0.0f && d5 <= d6)
|
||||
{
|
||||
// barycentric coordinates (0,0,1)
|
||||
vcopy(closest, c);
|
||||
dtVcopy(closest, c);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -118,16 +118,16 @@ bool intersectSegmentPoly2D(const float* p0, const float* p1,
|
||||
segMax = -1;
|
||||
|
||||
float dir[3];
|
||||
vsub(dir, p1, p0);
|
||||
dtVsub(dir, p1, p0);
|
||||
|
||||
for (int i = 0, j = nverts-1; i < nverts; j=i++)
|
||||
{
|
||||
float edge[3], diff[3];
|
||||
vsub(edge, &verts[i*3], &verts[j*3]);
|
||||
vsub(diff, p0, &verts[j*3]);
|
||||
dtVsub(edge, &verts[i*3], &verts[j*3]);
|
||||
dtVsub(diff, p0, &verts[j*3]);
|
||||
float n = vperp2D(edge, diff);
|
||||
float d = -vperp2D(edge, dir);
|
||||
if (fabs(d) < EPS)
|
||||
if (fabsf(d) < EPS)
|
||||
{
|
||||
// S is nearly parallel to this edge
|
||||
if (n < 0)
|
||||
@ -202,9 +202,9 @@ void calcPolyCenter(float* tc, const unsigned short* idx, int nidx, const float*
|
||||
bool closestHeightPointTriangle(const float* p, const float* a, const float* b, const float* c, float& h)
|
||||
{
|
||||
float v0[3], v1[3], v2[3];
|
||||
vsub(v0, c,a);
|
||||
vsub(v1, b,a);
|
||||
vsub(v2, p,a);
|
||||
dtVsub(v0, c,a);
|
||||
dtVsub(v1, b,a);
|
||||
dtVsub(v2, p,a);
|
||||
|
||||
const float dot00 = vdot2D(v0, v0);
|
||||
const float dot01 = vdot2D(v0, v1);
|
||||
|
@ -52,17 +52,17 @@ static void calcRect(const float* va, const float* vb,
|
||||
{
|
||||
if (side == 0 || side == 4)
|
||||
{
|
||||
bmin[0] = min(va[2],vb[2]) + padx;
|
||||
bmin[1] = min(va[1],vb[1]) - pady;
|
||||
bmax[0] = max(va[2],vb[2]) - padx;
|
||||
bmax[1] = max(va[1],vb[1]) + pady;
|
||||
bmin[0] = dtMin(va[2],vb[2]) + padx;
|
||||
bmin[1] = dtMin(va[1],vb[1]) - pady;
|
||||
bmax[0] = dtMax(va[2],vb[2]) - padx;
|
||||
bmax[1] = dtMax(va[1],vb[1]) + pady;
|
||||
}
|
||||
else if (side == 2 || side == 6)
|
||||
{
|
||||
bmin[0] = min(va[0],vb[0]) + padx;
|
||||
bmin[1] = min(va[1],vb[1]) - pady;
|
||||
bmax[0] = max(va[0],vb[0]) - padx;
|
||||
bmax[1] = max(va[1],vb[1]) + pady;
|
||||
bmin[0] = dtMin(va[0],vb[0]) + padx;
|
||||
bmin[1] = dtMin(va[1],vb[1]) - pady;
|
||||
bmax[0] = dtMax(va[0],vb[0]) - padx;
|
||||
bmax[1] = dtMax(va[1],vb[1]) + pady;
|
||||
}
|
||||
}
|
||||
|
||||
@ -141,7 +141,7 @@ dtNavMesh::~dtNavMesh()
|
||||
bool dtNavMesh::init(const dtNavMeshParams* params)
|
||||
{
|
||||
memcpy(&m_params, params, sizeof(dtNavMeshParams));
|
||||
vcopy(m_orig, params->orig);
|
||||
dtVcopy(m_orig, params->orig);
|
||||
m_tileWidth = params->tileWidth;
|
||||
m_tileHeight = params->tileHeight;
|
||||
|
||||
@ -181,8 +181,8 @@ bool dtNavMesh::init(const dtNavMeshParams* params)
|
||||
}
|
||||
|
||||
// Init ID generator values.
|
||||
m_tileBits = max((unsigned int)1,ilog2(nextPow2((unsigned int)params->maxTiles)));
|
||||
m_polyBits = max((unsigned int)1,ilog2(nextPow2((unsigned int)params->maxPolys)));
|
||||
m_tileBits = dtMax((unsigned int)1,ilog2(nextPow2((unsigned int)params->maxTiles)));
|
||||
m_polyBits = dtMax((unsigned int)1,ilog2(nextPow2((unsigned int)params->maxPolys)));
|
||||
m_saltBits = 32 - m_tileBits - m_polyBits;
|
||||
if (m_saltBits < 10)
|
||||
return false;
|
||||
@ -200,7 +200,7 @@ bool dtNavMesh::init(unsigned char* data, int dataSize, int flags, int maxNodes)
|
||||
return false;
|
||||
|
||||
dtNavMeshParams params;
|
||||
vcopy(params.orig, header->bmin);
|
||||
dtVcopy(params.orig, header->bmin);
|
||||
params.tileWidth = header->bmax[0] - header->bmin[0];
|
||||
params.tileHeight = header->bmax[2] - header->bmin[2];
|
||||
params.maxTiles = 1;
|
||||
@ -250,8 +250,8 @@ int dtNavMesh::findConnectingPolys(const float* va, const float* vb,
|
||||
// Add return value.
|
||||
if (n < maxcon)
|
||||
{
|
||||
conarea[n*2+0] = max(amin[0], bmin[0]);
|
||||
conarea[n*2+1] = min(amax[0], bmax[0]);
|
||||
conarea[n*2+0] = dtMax(amin[0], bmin[0]);
|
||||
conarea[n*2+1] = dtMin(amax[0], bmax[0]);
|
||||
con[n] = base | (unsigned int)i;
|
||||
n++;
|
||||
}
|
||||
@ -332,17 +332,17 @@ void dtNavMesh::connectExtLinks(dtMeshTile* tile, dtMeshTile* target, int side)
|
||||
// Compress portal limits to a byte value.
|
||||
if (side == 0 || side == 4)
|
||||
{
|
||||
const float lmin = min(va[2], vb[2]);
|
||||
const float lmax = max(va[2], vb[2]);
|
||||
link->bmin = (unsigned char)(clamp((neia[k*2+0]-lmin)/(lmax-lmin), 0.0f, 1.0f)*255.0f);
|
||||
link->bmax = (unsigned char)(clamp((neia[k*2+1]-lmin)/(lmax-lmin), 0.0f, 1.0f)*255.0f);
|
||||
const float lmin = dtMin(va[2], vb[2]);
|
||||
const float lmax = dtMax(va[2], vb[2]);
|
||||
link->bmin = (unsigned char)(dtClamp((neia[k*2+0]-lmin)/(lmax-lmin), 0.0f, 1.0f)*255.0f);
|
||||
link->bmax = (unsigned char)(dtClamp((neia[k*2+1]-lmin)/(lmax-lmin), 0.0f, 1.0f)*255.0f);
|
||||
}
|
||||
else if (side == 2 || side == 6)
|
||||
{
|
||||
const float lmin = min(va[0], vb[0]);
|
||||
const float lmax = max(va[0], vb[0]);
|
||||
link->bmin = (unsigned char)(clamp((neia[k*2+0]-lmin)/(lmax-lmin), 0.0f, 1.0f)*255.0f);
|
||||
link->bmax = (unsigned char)(clamp((neia[k*2+1]-lmin)/(lmax-lmin), 0.0f, 1.0f)*255.0f);
|
||||
const float lmin = dtMin(va[0], vb[0]);
|
||||
const float lmax = dtMax(va[0], vb[0]);
|
||||
link->bmin = (unsigned char)(dtClamp((neia[k*2+0]-lmin)/(lmax-lmin), 0.0f, 1.0f)*255.0f);
|
||||
link->bmax = (unsigned char)(dtClamp((neia[k*2+1]-lmin)/(lmax-lmin), 0.0f, 1.0f)*255.0f);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -375,11 +375,11 @@ void dtNavMesh::connectExtOffMeshLinks(dtMeshTile* tile, dtMeshTile* target, int
|
||||
dtPolyRef ref = findNearestPolyInTile(tile, p, ext, &defaultFilter, nearestPt);
|
||||
if (!ref) continue;
|
||||
// findNearestPoly may return too optimistic results, further check to make sure.
|
||||
if (sqr(nearestPt[0]-p[0])+sqr(nearestPt[2]-p[2]) > sqr(targetCon->rad))
|
||||
if (dtSqr(nearestPt[0]-p[0])+dtSqr(nearestPt[2]-p[2]) > dtSqr(targetCon->rad))
|
||||
continue;
|
||||
// Make sure the location is on current mesh.
|
||||
float* v = &target->verts[targetPoly->verts[1]*3];
|
||||
vcopy(v, nearestPt);
|
||||
dtVcopy(v, nearestPt);
|
||||
|
||||
// Link off-mesh connection to target poly.
|
||||
unsigned int idx = allocLink(target);
|
||||
@ -481,11 +481,11 @@ void dtNavMesh::connectIntOffMeshLinks(dtMeshTile* tile)
|
||||
dtPolyRef ref = findNearestPolyInTile(tile, p, ext, &defaultFilter, nearestPt);
|
||||
if (!ref) continue;
|
||||
// findNearestPoly may return too optimistic results, further check to make sure.
|
||||
if (sqr(nearestPt[0]-p[0])+sqr(nearestPt[2]-p[2]) > sqr(con->rad))
|
||||
if (dtSqr(nearestPt[0]-p[0])+dtSqr(nearestPt[2]-p[2]) > dtSqr(con->rad))
|
||||
continue;
|
||||
// Make sure the location is on current mesh.
|
||||
float* v = &tile->verts[poly->verts[j]*3];
|
||||
vcopy(v, nearestPt);
|
||||
dtVcopy(v, nearestPt);
|
||||
|
||||
// Link off-mesh connection to target poly.
|
||||
unsigned int idx = allocLink(tile);
|
||||
@ -927,10 +927,10 @@ bool dtNavMesh::closestPointOnPolyInTile(const dtMeshTile* tile, unsigned int ip
|
||||
}
|
||||
float pt[3];
|
||||
closestPtPointTriangle(pt, pos, v[0], v[1], v[2]);
|
||||
float d = vdistSqr(pos, pt);
|
||||
float d = dtVdistSqr(pos, pt);
|
||||
if (d < closestDistSqr)
|
||||
{
|
||||
vcopy(closest, pt);
|
||||
dtVcopy(closest, pt);
|
||||
closestDistSqr = d;
|
||||
}
|
||||
}
|
||||
@ -956,7 +956,7 @@ bool dtNavMesh::closestPointOnPolyBoundary(dtPolyRef ref, const float* pos, floa
|
||||
int nv = 0;
|
||||
for (int i = 0; i < (int)poly->vertCount; ++i)
|
||||
{
|
||||
vcopy(&verts[nv*3], &tile->verts[poly->verts[i]*3]);
|
||||
dtVcopy(&verts[nv*3], &tile->verts[poly->verts[i]*3]);
|
||||
nv++;
|
||||
}
|
||||
|
||||
@ -964,11 +964,11 @@ bool dtNavMesh::closestPointOnPolyBoundary(dtPolyRef ref, const float* pos, floa
|
||||
if (inside)
|
||||
{
|
||||
// Point is inside the polygon, return the point.
|
||||
vcopy(closest, pos);
|
||||
dtVcopy(closest, pos);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Point is outside the polygon, clamp to nearest edge.
|
||||
// Point is outside the polygon, dtClamp to nearest edge.
|
||||
float dmin = FLT_MAX;
|
||||
int imin = -1;
|
||||
for (int i = 0; i < nv; ++i)
|
||||
@ -981,7 +981,7 @@ bool dtNavMesh::closestPointOnPolyBoundary(dtPolyRef ref, const float* pos, floa
|
||||
}
|
||||
const float* va = &verts[imin*3];
|
||||
const float* vb = &verts[((imin+1)%nv)*3];
|
||||
vlerp(closest, va, vb, edget[imin]);
|
||||
dtVlerp(closest, va, vb, edget[imin]);
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -1021,8 +1021,8 @@ bool dtNavMesh::getOffMeshConnectionPolyEndPoints(dtPolyRef prevRef, dtPolyRef p
|
||||
}
|
||||
}
|
||||
|
||||
vcopy(startPos, &tile->verts[poly->verts[idx0]*3]);
|
||||
vcopy(endPos, &tile->verts[poly->verts[idx1]*3]);
|
||||
dtVcopy(startPos, &tile->verts[poly->verts[idx0]*3]);
|
||||
dtVcopy(endPos, &tile->verts[poly->verts[idx1]*3]);
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -1043,8 +1043,8 @@ bool dtNavMesh::getPolyHeight(dtPolyRef ref, const float* pos, float* height) co
|
||||
{
|
||||
const float* v0 = &tile->verts[poly->verts[0]*3];
|
||||
const float* v1 = &tile->verts[poly->verts[1]*3];
|
||||
const float d0 = vdist(pos, v0);
|
||||
const float d1 = vdist(pos, v1);
|
||||
const float d0 = dtVdist(pos, v0);
|
||||
const float d1 = dtVdist(pos, v1);
|
||||
const float u = d0 / (d0+d1);
|
||||
if (height)
|
||||
*height = v0[1] + (v1[1] - v0[1]) * u;
|
||||
@ -1105,11 +1105,11 @@ dtPolyRef dtNavMesh::findNearestPoly(const float* center, const float* extents,
|
||||
float closestPtPoly[3];
|
||||
if (!closestPointOnPoly(ref, center, closestPtPoly))
|
||||
continue;
|
||||
float d = vdistSqr(center, closestPtPoly);
|
||||
float d = dtVdistSqr(center, closestPtPoly);
|
||||
if (d < nearestDistanceSqr)
|
||||
{
|
||||
if (nearestPt)
|
||||
vcopy(nearestPt, closestPtPoly);
|
||||
dtVcopy(nearestPt, closestPtPoly);
|
||||
nearestDistanceSqr = d;
|
||||
nearest = ref;
|
||||
}
|
||||
@ -1122,8 +1122,8 @@ dtPolyRef dtNavMesh::findNearestPolyInTile(dtMeshTile* tile, const float* center
|
||||
dtQueryFilter* filter, float* nearestPt)
|
||||
{
|
||||
float bmin[3], bmax[3];
|
||||
vsub(bmin, center, extents);
|
||||
vadd(bmax, center, extents);
|
||||
dtVsub(bmin, center, extents);
|
||||
dtVadd(bmax, center, extents);
|
||||
|
||||
// Get nearby polygons from proximity grid.
|
||||
dtPolyRef polys[128];
|
||||
@ -1138,11 +1138,11 @@ dtPolyRef dtNavMesh::findNearestPolyInTile(dtMeshTile* tile, const float* center
|
||||
float closestPtPoly[3];
|
||||
if (!closestPointOnPolyInTile(tile, decodePolyIdPoly(ref), center, closestPtPoly))
|
||||
continue;
|
||||
float d = vdistSqr(center, closestPtPoly);
|
||||
float d = dtVdistSqr(center, closestPtPoly);
|
||||
if (d < nearestDistanceSqr)
|
||||
{
|
||||
if (nearestPt)
|
||||
vcopy(nearestPt, closestPtPoly);
|
||||
dtVcopy(nearestPt, closestPtPoly);
|
||||
nearestDistanceSqr = d;
|
||||
nearest = ref;
|
||||
}
|
||||
@ -1165,13 +1165,13 @@ int dtNavMesh::queryPolygonsInTile(dtMeshTile* tile, const float* qmin, const fl
|
||||
|
||||
// Calculate quantized box
|
||||
unsigned short bmin[3], bmax[3];
|
||||
// Clamp query box to world box.
|
||||
float minx = clamp(qmin[0], tbmin[0], tbmax[0]) - tbmin[0];
|
||||
float miny = clamp(qmin[1], tbmin[1], tbmax[1]) - tbmin[1];
|
||||
float minz = clamp(qmin[2], tbmin[2], tbmax[2]) - tbmin[2];
|
||||
float maxx = clamp(qmax[0], tbmin[0], tbmax[0]) - tbmin[0];
|
||||
float maxy = clamp(qmax[1], tbmin[1], tbmax[1]) - tbmin[1];
|
||||
float maxz = clamp(qmax[2], tbmin[2], tbmax[2]) - tbmin[2];
|
||||
// dtClamp query box to world box.
|
||||
float minx = dtClamp(qmin[0], tbmin[0], tbmax[0]) - tbmin[0];
|
||||
float miny = dtClamp(qmin[1], tbmin[1], tbmax[1]) - tbmin[1];
|
||||
float minz = dtClamp(qmin[2], tbmin[2], tbmax[2]) - tbmin[2];
|
||||
float maxx = dtClamp(qmax[0], tbmin[0], tbmax[0]) - tbmin[0];
|
||||
float maxy = dtClamp(qmax[1], tbmin[1], tbmax[1]) - tbmin[1];
|
||||
float maxz = dtClamp(qmax[2], tbmin[2], tbmax[2]) - tbmin[2];
|
||||
// Quantize
|
||||
bmin[0] = (unsigned short)(qfac * minx) & 0xfffe;
|
||||
bmin[1] = (unsigned short)(qfac * miny) & 0xfffe;
|
||||
@ -1218,13 +1218,13 @@ int dtNavMesh::queryPolygonsInTile(dtMeshTile* tile, const float* qmin, const fl
|
||||
// Calc polygon bounds.
|
||||
dtPoly* p = &tile->polys[i];
|
||||
const float* v = &tile->verts[p->verts[0]*3];
|
||||
vcopy(bmin, v);
|
||||
vcopy(bmax, v);
|
||||
dtVcopy(bmin, v);
|
||||
dtVcopy(bmax, v);
|
||||
for (int j = 1; j < p->vertCount; ++j)
|
||||
{
|
||||
v = &tile->verts[p->verts[j]*3];
|
||||
vmin(bmin, v);
|
||||
vmax(bmax, v);
|
||||
dtVmin(bmin, v);
|
||||
dtVmax(bmax, v);
|
||||
}
|
||||
if (overlapBoxes(qmin,qmax, bmin,bmax))
|
||||
{
|
||||
@ -1243,8 +1243,8 @@ int dtNavMesh::queryPolygons(const float* center, const float* extents, dtQueryF
|
||||
dtPolyRef* polys, const int maxPolys)
|
||||
{
|
||||
float bmin[3], bmax[3];
|
||||
vsub(bmin, center, extents);
|
||||
vadd(bmax, center, extents);
|
||||
dtVsub(bmin, center, extents);
|
||||
dtVadd(bmax, center, extents);
|
||||
|
||||
// Find tiles the query touches.
|
||||
const int minx = (int)floorf((bmin[0]-m_orig[0]) / m_tileWidth);
|
||||
@ -1298,7 +1298,7 @@ int dtNavMesh::findPath(dtPolyRef startRef, dtPolyRef endRef,
|
||||
dtNode* startNode = m_nodePool->getNode(startRef);
|
||||
startNode->pidx = 0;
|
||||
startNode->cost = 0;
|
||||
startNode->total = vdist(startPos, endPos) * H_SCALE;
|
||||
startNode->total = dtVdist(startPos, endPos) * H_SCALE;
|
||||
startNode->id = startRef;
|
||||
startNode->flags = DT_NODE_OPEN;
|
||||
m_openList->push(startNode);
|
||||
@ -1350,7 +1350,7 @@ int dtNavMesh::findPath(dtPolyRef startRef, dtPolyRef endRef,
|
||||
}
|
||||
else
|
||||
{
|
||||
vcopy(previousEdgeMidPoint, startPos);
|
||||
dtVcopy(previousEdgeMidPoint, startPos);
|
||||
}
|
||||
|
||||
for (unsigned int i = bestPoly->firstLink; i != DT_NULL_LINK; i = bestTile->links[i].next)
|
||||
@ -1387,8 +1387,8 @@ int dtNavMesh::findPath(dtPolyRef startRef, dtPolyRef endRef,
|
||||
{
|
||||
// Cost
|
||||
newNode.cost = bestNode->cost +
|
||||
vdist(previousEdgeMidPoint,edgeMidPoint) * m_areaCost[bestPoly->area] +
|
||||
vdist(edgeMidPoint, endPos) * m_areaCost[neighbourPoly->area];
|
||||
dtVdist(previousEdgeMidPoint,edgeMidPoint) * m_areaCost[bestPoly->area] +
|
||||
dtVdist(edgeMidPoint, endPos) * m_areaCost[neighbourPoly->area];
|
||||
// Heuristic
|
||||
h = 0;
|
||||
}
|
||||
@ -1396,9 +1396,9 @@ int dtNavMesh::findPath(dtPolyRef startRef, dtPolyRef endRef,
|
||||
{
|
||||
// Cost
|
||||
newNode.cost = bestNode->cost +
|
||||
vdist(previousEdgeMidPoint,edgeMidPoint) * m_areaCost[bestPoly->area];
|
||||
dtVdist(previousEdgeMidPoint,edgeMidPoint) * m_areaCost[bestPoly->area];
|
||||
// Heuristic
|
||||
h = vdist(edgeMidPoint,endPos)*H_SCALE;
|
||||
h = dtVdist(edgeMidPoint,endPos)*H_SCALE;
|
||||
}
|
||||
newNode.total = newNode.cost + h;
|
||||
|
||||
@ -1484,7 +1484,7 @@ int dtNavMesh::findStraightPath(const float* startPos, const float* endPos,
|
||||
return 0;
|
||||
|
||||
// Add start point.
|
||||
vcopy(&straightPath[straightPathSize*3], closestStartPos);
|
||||
dtVcopy(&straightPath[straightPathSize*3], closestStartPos);
|
||||
if (straightPathFlags)
|
||||
straightPathFlags[straightPathSize] = DT_STRAIGHTPATH_START;
|
||||
if (straightPathRefs)
|
||||
@ -1500,9 +1500,9 @@ int dtNavMesh::findStraightPath(const float* startPos, const float* endPos,
|
||||
if (pathSize > 1)
|
||||
{
|
||||
float portalApex[3], portalLeft[3], portalRight[3];
|
||||
vcopy(portalApex, closestStartPos);
|
||||
vcopy(portalLeft, portalApex);
|
||||
vcopy(portalRight, portalApex);
|
||||
dtVcopy(portalApex, closestStartPos);
|
||||
dtVcopy(portalLeft, portalApex);
|
||||
dtVcopy(portalRight, portalApex);
|
||||
int apexIndex = 0;
|
||||
int leftIndex = 0;
|
||||
int rightIndex = 0;
|
||||
@ -1526,7 +1526,7 @@ int dtNavMesh::findStraightPath(const float* startPos, const float* endPos,
|
||||
if (!closestPointOnPolyBoundary(path[i], endPos, closestEndPos))
|
||||
return 0;
|
||||
|
||||
vcopy(&straightPath[straightPathSize*3], closestEndPos);
|
||||
dtVcopy(&straightPath[straightPathSize*3], closestEndPos);
|
||||
if (straightPathFlags)
|
||||
straightPathFlags[straightPathSize] = 0;
|
||||
if (straightPathRefs)
|
||||
@ -1547,8 +1547,8 @@ int dtNavMesh::findStraightPath(const float* startPos, const float* endPos,
|
||||
else
|
||||
{
|
||||
// End of the path.
|
||||
vcopy(left, closestEndPos);
|
||||
vcopy(right, closestEndPos);
|
||||
dtVcopy(left, closestEndPos);
|
||||
dtVcopy(right, closestEndPos);
|
||||
|
||||
fromType = toType = DT_POLYTYPE_GROUND;
|
||||
}
|
||||
@ -1556,16 +1556,16 @@ int dtNavMesh::findStraightPath(const float* startPos, const float* endPos,
|
||||
// Right vertex.
|
||||
if (triArea2D(portalApex, portalRight, right) <= 0.0f)
|
||||
{
|
||||
if (vequal(portalApex, portalRight) || triArea2D(portalApex, portalLeft, right) > 0.0f)
|
||||
if (dtVequal(portalApex, portalRight) || triArea2D(portalApex, portalLeft, right) > 0.0f)
|
||||
{
|
||||
vcopy(portalRight, right);
|
||||
dtVcopy(portalRight, right);
|
||||
rightPolyRef = (i+1 < pathSize) ? path[i+1] : 0;
|
||||
rightPolyType = toType;
|
||||
rightIndex = i;
|
||||
}
|
||||
else
|
||||
{
|
||||
vcopy(portalApex, portalLeft);
|
||||
dtVcopy(portalApex, portalLeft);
|
||||
apexIndex = leftIndex;
|
||||
|
||||
unsigned char flags = 0;
|
||||
@ -1575,10 +1575,10 @@ int dtNavMesh::findStraightPath(const float* startPos, const float* endPos,
|
||||
flags = DT_STRAIGHTPATH_OFFMESH_CONNECTION;
|
||||
dtPolyRef ref = leftPolyRef;
|
||||
|
||||
if (!vequal(&straightPath[(straightPathSize-1)*3], portalApex))
|
||||
if (!dtVequal(&straightPath[(straightPathSize-1)*3], portalApex))
|
||||
{
|
||||
// Append new vertex.
|
||||
vcopy(&straightPath[straightPathSize*3], portalApex);
|
||||
dtVcopy(&straightPath[straightPathSize*3], portalApex);
|
||||
if (straightPathFlags)
|
||||
straightPathFlags[straightPathSize] = flags;
|
||||
if (straightPathRefs)
|
||||
@ -1597,8 +1597,8 @@ int dtNavMesh::findStraightPath(const float* startPos, const float* endPos,
|
||||
straightPathRefs[straightPathSize-1] = ref;
|
||||
}
|
||||
|
||||
vcopy(portalLeft, portalApex);
|
||||
vcopy(portalRight, portalApex);
|
||||
dtVcopy(portalLeft, portalApex);
|
||||
dtVcopy(portalRight, portalApex);
|
||||
leftIndex = apexIndex;
|
||||
rightIndex = apexIndex;
|
||||
|
||||
@ -1612,16 +1612,16 @@ int dtNavMesh::findStraightPath(const float* startPos, const float* endPos,
|
||||
// Left vertex.
|
||||
if (triArea2D(portalApex, portalLeft, left) >= 0.0f)
|
||||
{
|
||||
if (vequal(portalApex, portalLeft) || triArea2D(portalApex, portalRight, left) < 0.0f)
|
||||
if (dtVequal(portalApex, portalLeft) || triArea2D(portalApex, portalRight, left) < 0.0f)
|
||||
{
|
||||
vcopy(portalLeft, left);
|
||||
dtVcopy(portalLeft, left);
|
||||
leftPolyRef = (i+1 < pathSize) ? path[i+1] : 0;
|
||||
leftPolyType = toType;
|
||||
leftIndex = i;
|
||||
}
|
||||
else
|
||||
{
|
||||
vcopy(portalApex, portalRight);
|
||||
dtVcopy(portalApex, portalRight);
|
||||
apexIndex = rightIndex;
|
||||
|
||||
unsigned char flags = 0;
|
||||
@ -1631,10 +1631,10 @@ int dtNavMesh::findStraightPath(const float* startPos, const float* endPos,
|
||||
flags = DT_STRAIGHTPATH_OFFMESH_CONNECTION;
|
||||
dtPolyRef ref = rightPolyRef;
|
||||
|
||||
if (!vequal(&straightPath[(straightPathSize-1)*3], portalApex))
|
||||
if (!dtVequal(&straightPath[(straightPathSize-1)*3], portalApex))
|
||||
{
|
||||
// Append new vertex.
|
||||
vcopy(&straightPath[straightPathSize*3], portalApex);
|
||||
dtVcopy(&straightPath[straightPathSize*3], portalApex);
|
||||
if (straightPathFlags)
|
||||
straightPathFlags[straightPathSize] = flags;
|
||||
if (straightPathRefs)
|
||||
@ -1653,8 +1653,8 @@ int dtNavMesh::findStraightPath(const float* startPos, const float* endPos,
|
||||
straightPathRefs[straightPathSize-1] = ref;
|
||||
}
|
||||
|
||||
vcopy(portalLeft, portalApex);
|
||||
vcopy(portalRight, portalApex);
|
||||
dtVcopy(portalLeft, portalApex);
|
||||
dtVcopy(portalRight, portalApex);
|
||||
leftIndex = apexIndex;
|
||||
rightIndex = apexIndex;
|
||||
|
||||
@ -1668,13 +1668,13 @@ int dtNavMesh::findStraightPath(const float* startPos, const float* endPos,
|
||||
}
|
||||
|
||||
// If the point already exists, remove it and add reappend the actual end location.
|
||||
if (straightPathSize && vequal(&straightPath[(straightPathSize-1)*3], closestEndPos))
|
||||
if (straightPathSize && dtVequal(&straightPath[(straightPathSize-1)*3], closestEndPos))
|
||||
straightPathSize--;
|
||||
|
||||
// Add end point.
|
||||
if (straightPathSize < maxStraightPathSize)
|
||||
{
|
||||
vcopy(&straightPath[straightPathSize*3], closestEndPos);
|
||||
dtVcopy(&straightPath[straightPathSize*3], closestEndPos);
|
||||
if (straightPathFlags)
|
||||
straightPathFlags[straightPathSize] = DT_STRAIGHTPATH_END;
|
||||
if (straightPathRefs)
|
||||
@ -1700,7 +1700,7 @@ int dtNavMesh::moveAlongPathCorridor(const float* startPos, const float* endPos,
|
||||
|
||||
static const float SLOP = 0.01f;
|
||||
|
||||
vcopy(resultPos, startPos);
|
||||
dtVcopy(resultPos, startPos);
|
||||
|
||||
while (n < pathSize)
|
||||
{
|
||||
@ -1722,7 +1722,7 @@ int dtNavMesh::moveAlongPathCorridor(const float* startPos, const float* endPos,
|
||||
unsigned char fromType, toType;
|
||||
if (!getPortalPoints(path[n], path[n+1], left, right, fromType, toType))
|
||||
return n;
|
||||
vcopy(resultPos, endPos);
|
||||
dtVcopy(resultPos, endPos);
|
||||
}
|
||||
return n+1;
|
||||
}
|
||||
@ -1731,7 +1731,7 @@ int dtNavMesh::moveAlongPathCorridor(const float* startPos, const float* endPos,
|
||||
int nv = 0;
|
||||
for (int i = 0; i < (int)poly->vertCount; ++i)
|
||||
{
|
||||
vcopy(&verts[nv*3], &tile->verts[poly->verts[i]*3]);
|
||||
dtVcopy(&verts[nv*3], &tile->verts[poly->verts[i]*3]);
|
||||
nv++;
|
||||
}
|
||||
|
||||
@ -1739,7 +1739,7 @@ int dtNavMesh::moveAlongPathCorridor(const float* startPos, const float* endPos,
|
||||
if (inside)
|
||||
{
|
||||
// The end point is inside the current polygon.
|
||||
vcopy(resultPos, endPos);
|
||||
dtVcopy(resultPos, endPos);
|
||||
return n;
|
||||
}
|
||||
|
||||
@ -1757,7 +1757,7 @@ int dtNavMesh::moveAlongPathCorridor(const float* startPos, const float* endPos,
|
||||
}
|
||||
const float* va = &verts[imin*3];
|
||||
const float* vb = &verts[((imin+1)%nv)*3];
|
||||
vlerp(resultPos, va, vb, edget[imin]);
|
||||
dtVlerp(resultPos, va, vb, edget[imin]);
|
||||
|
||||
// Check to see if the point is on the portal edge to the next polygon.
|
||||
if (n+1 >= pathSize)
|
||||
@ -1767,7 +1767,7 @@ int dtNavMesh::moveAlongPathCorridor(const float* startPos, const float* endPos,
|
||||
unsigned char fromType, toType;
|
||||
if (!getPortalPoints(path[n], path[n+1], left, right, fromType, toType))
|
||||
return n;
|
||||
// If the clamped point is close to the next portal edge, advance to next poly.
|
||||
// If the dtClamped point is close to the next portal edge, advance to next poly.
|
||||
float t;
|
||||
float d = distancePtSegSqr2D(resultPos, left, right, t);
|
||||
if (d > SLOP*SLOP)
|
||||
@ -1831,8 +1831,8 @@ bool dtNavMesh::getPortalPoints(dtPolyRef from, const dtPoly* fromPoly, const dt
|
||||
if (fromTile->links[i].ref == to)
|
||||
{
|
||||
const int v = fromTile->links[i].edge;
|
||||
vcopy(left, &fromTile->verts[fromPoly->verts[v]*3]);
|
||||
vcopy(right, &fromTile->verts[fromPoly->verts[v]*3]);
|
||||
dtVcopy(left, &fromTile->verts[fromPoly->verts[v]*3]);
|
||||
dtVcopy(right, &fromTile->verts[fromPoly->verts[v]*3]);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -1846,8 +1846,8 @@ bool dtNavMesh::getPortalPoints(dtPolyRef from, const dtPoly* fromPoly, const dt
|
||||
if (toTile->links[i].ref == from)
|
||||
{
|
||||
const int v = toTile->links[i].edge;
|
||||
vcopy(left, &toTile->verts[toPoly->verts[v]*3]);
|
||||
vcopy(right, &toTile->verts[toPoly->verts[v]*3]);
|
||||
dtVcopy(left, &toTile->verts[toPoly->verts[v]*3]);
|
||||
dtVcopy(right, &toTile->verts[toPoly->verts[v]*3]);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -1857,36 +1857,36 @@ bool dtNavMesh::getPortalPoints(dtPolyRef from, const dtPoly* fromPoly, const dt
|
||||
// Find portal vertices.
|
||||
const int v0 = fromPoly->verts[link->edge];
|
||||
const int v1 = fromPoly->verts[(link->edge+1) % (int)fromPoly->vertCount];
|
||||
vcopy(left, &fromTile->verts[v0*3]);
|
||||
vcopy(right, &fromTile->verts[v1*3]);
|
||||
dtVcopy(left, &fromTile->verts[v0*3]);
|
||||
dtVcopy(right, &fromTile->verts[v1*3]);
|
||||
|
||||
// If the link is at tile boundary, clamp the vertices to
|
||||
// If the link is at tile boundary, dtClamp the vertices to
|
||||
// the link width.
|
||||
if (link->side == 0 || link->side == 4)
|
||||
{
|
||||
// Unpack portal limits.
|
||||
const float smin = min(left[2],right[2]);
|
||||
const float smax = max(left[2],right[2]);
|
||||
const float smin = dtMin(left[2],right[2]);
|
||||
const float smax = dtMax(left[2],right[2]);
|
||||
const float s = (smax-smin) / 255.0f;
|
||||
const float lmin = smin + link->bmin*s;
|
||||
const float lmax = smin + link->bmax*s;
|
||||
left[2] = max(left[2],lmin);
|
||||
left[2] = min(left[2],lmax);
|
||||
right[2] = max(right[2],lmin);
|
||||
right[2] = min(right[2],lmax);
|
||||
left[2] = dtMax(left[2],lmin);
|
||||
left[2] = dtMin(left[2],lmax);
|
||||
right[2] = dtMax(right[2],lmin);
|
||||
right[2] = dtMin(right[2],lmax);
|
||||
}
|
||||
else if (link->side == 2 || link->side == 6)
|
||||
{
|
||||
// Unpack portal limits.
|
||||
const float smin = min(left[0],right[0]);
|
||||
const float smax = max(left[0],right[0]);
|
||||
const float smin = dtMin(left[0],right[0]);
|
||||
const float smax = dtMax(left[0],right[0]);
|
||||
const float s = (smax-smin) / 255.0f;
|
||||
const float lmin = smin + link->bmin*s;
|
||||
const float lmax = smin + link->bmax*s;
|
||||
left[0] = max(left[0],lmin);
|
||||
left[0] = min(left[0],lmax);
|
||||
right[0] = max(right[0],lmin);
|
||||
right[0] = min(right[0],lmax);
|
||||
left[0] = dtMax(left[0],lmin);
|
||||
left[0] = dtMin(left[0],lmax);
|
||||
right[0] = dtMax(right[0],lmin);
|
||||
right[0] = dtMin(right[0],lmax);
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -1996,7 +1996,7 @@ int dtNavMesh::raycast(dtPolyRef centerRef, const float* startPos, const float*
|
||||
int nv = 0;
|
||||
for (int i = 0; i < (int)poly->vertCount; ++i)
|
||||
{
|
||||
vcopy(&verts[nv*3], &tile->verts[poly->verts[i]*3]);
|
||||
dtVcopy(&verts[nv*3], &tile->verts[poly->verts[i]*3]);
|
||||
nv++;
|
||||
}
|
||||
|
||||
@ -2047,8 +2047,8 @@ int dtNavMesh::raycast(dtPolyRef centerRef, const float* startPos, const float*
|
||||
if (link->side == 0 || link->side == 4)
|
||||
{
|
||||
// Calculate link size.
|
||||
const float smin = min(left[2],right[2]);
|
||||
const float smax = max(left[2],right[2]);
|
||||
const float smin = dtMin(left[2],right[2]);
|
||||
const float smax = dtMax(left[2],right[2]);
|
||||
const float s = (smax-smin) / 255.0f;
|
||||
const float lmin = smin + link->bmin*s;
|
||||
const float lmax = smin + link->bmax*s;
|
||||
@ -2063,8 +2063,8 @@ int dtNavMesh::raycast(dtPolyRef centerRef, const float* startPos, const float*
|
||||
else if (link->side == 2 || link->side == 6)
|
||||
{
|
||||
// Calculate link size.
|
||||
const float smin = min(left[0],right[0]);
|
||||
const float smax = max(left[0],right[0]);
|
||||
const float smin = dtMin(left[0],right[0]);
|
||||
const float smax = dtMax(left[0],right[0]);
|
||||
const float s = (smax-smin) / 255.0f;
|
||||
const float lmin = smin + link->bmin*s;
|
||||
const float lmax = smin + link->bmax*s;
|
||||
@ -2093,7 +2093,7 @@ int dtNavMesh::raycast(dtPolyRef centerRef, const float* startPos, const float*
|
||||
hitNormal[0] = dz;
|
||||
hitNormal[1] = 0;
|
||||
hitNormal[2] = -dx;
|
||||
vnormalize(hitNormal);
|
||||
dtVnormalize(hitNormal);
|
||||
|
||||
return n;
|
||||
}
|
||||
@ -2136,7 +2136,7 @@ int dtNavMesh::findPolysAround(dtPolyRef centerRef, const float* centerPos, floa
|
||||
++n;
|
||||
}
|
||||
|
||||
const float radiusSqr = sqr(radius);
|
||||
const float radiusSqr = dtSqr(radius);
|
||||
|
||||
unsigned int it, ip;
|
||||
|
||||
@ -2172,7 +2172,7 @@ int dtNavMesh::findPolysAround(dtPolyRef centerRef, const float* centerPos, floa
|
||||
}
|
||||
else
|
||||
{
|
||||
vcopy(previousEdgeMidPoint, centerPos);
|
||||
dtVcopy(previousEdgeMidPoint, centerPos);
|
||||
}
|
||||
|
||||
for (unsigned int i = bestPoly->firstLink; i != DT_NULL_LINK; i = bestTile->links[i].next)
|
||||
@ -2211,7 +2211,7 @@ int dtNavMesh::findPolysAround(dtPolyRef centerRef, const float* centerPos, floa
|
||||
getEdgeMidPoint(bestRef, bestPoly, bestTile,
|
||||
neighbourRef, neighbourPoly, neighbourTile, edgeMidPoint);
|
||||
|
||||
newNode.total = bestNode->total + vdist(previousEdgeMidPoint, edgeMidPoint);
|
||||
newNode.total = bestNode->total + dtVdist(previousEdgeMidPoint, edgeMidPoint);
|
||||
|
||||
dtNode* actualNode = m_nodePool->getNode(newNode.id);
|
||||
if (!actualNode)
|
||||
@ -2268,7 +2268,7 @@ float dtNavMesh::findDistanceToWall(dtPolyRef centerRef, const float* centerPos,
|
||||
startNode->flags = DT_NODE_OPEN;
|
||||
m_openList->push(startNode);
|
||||
|
||||
float radiusSqr = sqr(maxRadius);
|
||||
float radiusSqr = dtSqr(maxRadius);
|
||||
|
||||
unsigned int it, ip;
|
||||
|
||||
@ -2304,7 +2304,7 @@ float dtNavMesh::findDistanceToWall(dtPolyRef centerRef, const float* centerPos,
|
||||
}
|
||||
else
|
||||
{
|
||||
vcopy(previousEdgeMidPoint, centerPos);
|
||||
dtVcopy(previousEdgeMidPoint, centerPos);
|
||||
}
|
||||
|
||||
// Hit test walls.
|
||||
@ -2387,7 +2387,7 @@ float dtNavMesh::findDistanceToWall(dtPolyRef centerRef, const float* centerPos,
|
||||
getEdgeMidPoint(bestRef, bestPoly, bestTile,
|
||||
neighbourRef, neighbourPoly, neighbourTile, edgeMidPoint);
|
||||
|
||||
newNode.total = bestNode->total + vdist(previousEdgeMidPoint, edgeMidPoint);
|
||||
newNode.total = bestNode->total + dtVdist(previousEdgeMidPoint, edgeMidPoint);
|
||||
|
||||
dtNode* actualNode = m_nodePool->getNode(newNode.id);
|
||||
if (!actualNode)
|
||||
@ -2414,8 +2414,8 @@ float dtNavMesh::findDistanceToWall(dtPolyRef centerRef, const float* centerPos,
|
||||
}
|
||||
|
||||
// Calc hit normal.
|
||||
vsub(hitNormal, centerPos, hitPos);
|
||||
vnormalize(hitNormal);
|
||||
dtVsub(hitNormal, centerPos, hitPos);
|
||||
dtVnormalize(hitNormal);
|
||||
|
||||
return sqrtf(radiusSqr);
|
||||
}
|
||||
|
@ -375,8 +375,8 @@ bool dtCreateNavMeshData(dtNavMeshCreateParams* params, unsigned char** outData,
|
||||
header->polyCount = totPolyCount;
|
||||
header->vertCount = totVertCount;
|
||||
header->maxLinkCount = maxLinkCount;
|
||||
vcopy(header->bmin, params->bmin);
|
||||
vcopy(header->bmax, params->bmax);
|
||||
dtVcopy(header->bmin, params->bmin);
|
||||
dtVcopy(header->bmax, params->bmax);
|
||||
header->detailMeshCount = params->polyCount;
|
||||
header->detailVertCount = uniqueDetailVertCount;
|
||||
header->detailTriCount = params->detailTriCount;
|
||||
@ -410,8 +410,8 @@ bool dtCreateNavMeshData(dtNavMeshCreateParams* params, unsigned char** outData,
|
||||
{
|
||||
const float* linkv = ¶ms->offMeshConVerts[i*2*3];
|
||||
float* v = &navVerts[(offMeshVertsBase + n*2)*3];
|
||||
vcopy(&v[0], &linkv[0]);
|
||||
vcopy(&v[3], &linkv[3]);
|
||||
dtVcopy(&v[0], &linkv[0]);
|
||||
dtVcopy(&v[3], &linkv[3]);
|
||||
n++;
|
||||
}
|
||||
}
|
||||
@ -519,8 +519,8 @@ bool dtCreateNavMeshData(dtNavMeshCreateParams* params, unsigned char** outData,
|
||||
con->poly = (unsigned short)(offMeshPolyBase + n);
|
||||
// Copy connection end-points.
|
||||
const float* endPts = ¶ms->offMeshConVerts[i*2*3];
|
||||
vcopy(&con->pos[0], &endPts[0]);
|
||||
vcopy(&con->pos[3], &endPts[3]);
|
||||
dtVcopy(&con->pos[0], &endPts[0]);
|
||||
dtVcopy(&con->pos[3], &endPts[3]);
|
||||
con->rad = params->offMeshConRad[i];
|
||||
con->flags = params->offMeshConDir[i] ? DT_OFFMESH_CON_BIDIR : 0;
|
||||
con->side = offMeshConClass[i*2+1];
|
||||
|
@ -300,61 +300,61 @@ template<class T> inline T rcSqr(T a) { return a*a; }
|
||||
template<class T> inline T rcClamp(T v, T mn, T mx) { return v < mn ? mn : (v > mx ? mx : v); }
|
||||
|
||||
// Common vector helper functions.
|
||||
inline void vcross(float* dest, const float* v1, const float* v2)
|
||||
inline void rcVcross(float* dest, const float* v1, const float* v2)
|
||||
{
|
||||
dest[0] = v1[1]*v2[2] - v1[2]*v2[1];
|
||||
dest[1] = v1[2]*v2[0] - v1[0]*v2[2];
|
||||
dest[2] = v1[0]*v2[1] - v1[1]*v2[0];
|
||||
}
|
||||
|
||||
inline float vdot(const float* v1, const float* v2)
|
||||
inline float rcVdot(const float* v1, const float* v2)
|
||||
{
|
||||
return v1[0]*v2[0] + v1[1]*v2[1] + v1[2]*v2[2];
|
||||
}
|
||||
|
||||
inline void vmad(float* dest, const float* v1, const float* v2, const float s)
|
||||
inline void rcVmad(float* dest, const float* v1, const float* v2, const float s)
|
||||
{
|
||||
dest[0] = v1[0]+v2[0]*s;
|
||||
dest[1] = v1[1]+v2[1]*s;
|
||||
dest[2] = v1[2]+v2[2]*s;
|
||||
}
|
||||
|
||||
inline void vadd(float* dest, const float* v1, const float* v2)
|
||||
inline void rcVadd(float* dest, const float* v1, const float* v2)
|
||||
{
|
||||
dest[0] = v1[0]+v2[0];
|
||||
dest[1] = v1[1]+v2[1];
|
||||
dest[2] = v1[2]+v2[2];
|
||||
}
|
||||
|
||||
inline void vsub(float* dest, const float* v1, const float* v2)
|
||||
inline void rcVsub(float* dest, const float* v1, const float* v2)
|
||||
{
|
||||
dest[0] = v1[0]-v2[0];
|
||||
dest[1] = v1[1]-v2[1];
|
||||
dest[2] = v1[2]-v2[2];
|
||||
}
|
||||
|
||||
inline void vmin(float* mn, const float* v)
|
||||
inline void rcVmin(float* mn, const float* v)
|
||||
{
|
||||
mn[0] = rcMin(mn[0], v[0]);
|
||||
mn[1] = rcMin(mn[1], v[1]);
|
||||
mn[2] = rcMin(mn[2], v[2]);
|
||||
}
|
||||
|
||||
inline void vmax(float* mx, const float* v)
|
||||
inline void rcVmax(float* mx, const float* v)
|
||||
{
|
||||
mx[0] = rcMax(mx[0], v[0]);
|
||||
mx[1] = rcMax(mx[1], v[1]);
|
||||
mx[2] = rcMax(mx[2], v[2]);
|
||||
}
|
||||
|
||||
inline void vcopy(float* dest, const float* v)
|
||||
inline void rcVcopy(float* dest, const float* v)
|
||||
{
|
||||
dest[0] = v[0];
|
||||
dest[1] = v[1];
|
||||
dest[2] = v[2];
|
||||
}
|
||||
|
||||
inline float vdist(const float* v1, const float* v2)
|
||||
inline float rcVdist(const float* v1, const float* v2)
|
||||
{
|
||||
float dx = v2[0] - v1[0];
|
||||
float dy = v2[1] - v1[1];
|
||||
@ -362,7 +362,7 @@ inline float vdist(const float* v1, const float* v2)
|
||||
return sqrtf(dx*dx + dy*dy + dz*dz);
|
||||
}
|
||||
|
||||
inline float vdistSqr(const float* v1, const float* v2)
|
||||
inline float rcVdistSqr(const float* v1, const float* v2)
|
||||
{
|
||||
float dx = v2[0] - v1[0];
|
||||
float dy = v2[1] - v1[1];
|
||||
@ -370,7 +370,7 @@ inline float vdistSqr(const float* v1, const float* v2)
|
||||
return dx*dx + dy*dy + dz*dz;
|
||||
}
|
||||
|
||||
inline void vnormalize(float* v)
|
||||
inline void rcVnormalize(float* v)
|
||||
{
|
||||
float d = 1.0f / sqrtf(rcSqr(v[0]) + rcSqr(v[1]) + rcSqr(v[2]));
|
||||
v[0] *= d;
|
||||
@ -378,10 +378,10 @@ inline void vnormalize(float* v)
|
||||
v[2] *= d;
|
||||
}
|
||||
|
||||
inline bool vequal(const float* p0, const float* p1)
|
||||
inline bool rcVequal(const float* p0, const float* p1)
|
||||
{
|
||||
static const float thr = rcSqr(1.0f/16384.0f);
|
||||
const float d = vdistSqr(p0, p1);
|
||||
const float d = rcVdistSqr(p0, p1);
|
||||
return d < thr;
|
||||
}
|
||||
|
||||
|
@ -44,13 +44,13 @@ void rcIntArray::resize(int n)
|
||||
void rcCalcBounds(const float* verts, int nv, float* bmin, float* bmax)
|
||||
{
|
||||
// Calculate bounding box.
|
||||
vcopy(bmin, verts);
|
||||
vcopy(bmax, verts);
|
||||
rcVcopy(bmin, verts);
|
||||
rcVcopy(bmax, verts);
|
||||
for (int i = 1; i < nv; ++i)
|
||||
{
|
||||
const float* v = &verts[i*3];
|
||||
vmin(bmin, v);
|
||||
vmax(bmax, v);
|
||||
rcVmin(bmin, v);
|
||||
rcVmax(bmax, v);
|
||||
}
|
||||
}
|
||||
|
||||
@ -67,8 +67,8 @@ bool rcCreateHeightfield(rcHeightfield& hf, int width, int height,
|
||||
hf.width = width;
|
||||
hf.height = height;
|
||||
hf.spans = new rcSpan*[hf.width*hf.height];
|
||||
vcopy(hf.bmin, bmin);
|
||||
vcopy(hf.bmax, bmax);
|
||||
rcVcopy(hf.bmin, bmin);
|
||||
rcVcopy(hf.bmax, bmax);
|
||||
hf.cs = cs;
|
||||
hf.ch = ch;
|
||||
if (!hf.spans)
|
||||
@ -80,10 +80,10 @@ bool rcCreateHeightfield(rcHeightfield& hf, int width, int height,
|
||||
static void calcTriNormal(const float* v0, const float* v1, const float* v2, float* norm)
|
||||
{
|
||||
float e0[3], e1[3];
|
||||
vsub(e0, v1, v0);
|
||||
vsub(e1, v2, v0);
|
||||
vcross(norm, e0, e1);
|
||||
vnormalize(norm);
|
||||
rcVsub(e0, v1, v0);
|
||||
rcVsub(e1, v2, v0);
|
||||
rcVcross(norm, e0, e1);
|
||||
rcVnormalize(norm);
|
||||
}
|
||||
|
||||
void rcMarkWalkableTriangles(const float walkableSlopeAngle,
|
||||
@ -141,8 +141,8 @@ bool rcBuildCompactHeightfield(const int walkableHeight, const int walkableClimb
|
||||
chf.walkableHeight = walkableHeight;
|
||||
chf.walkableClimb = walkableClimb;
|
||||
chf.maxRegions = 0;
|
||||
vcopy(chf.bmin, hf.bmin);
|
||||
vcopy(chf.bmax, hf.bmax);
|
||||
rcVcopy(chf.bmin, hf.bmin);
|
||||
rcVcopy(chf.bmax, hf.bmax);
|
||||
chf.bmax[1] += walkableHeight*hf.ch;
|
||||
chf.cs = hf.cs;
|
||||
chf.ch = hf.ch;
|
||||
|
@ -265,12 +265,12 @@ void rcMarkConvexPolyArea(const float* verts, const int nverts,
|
||||
rcCompactHeightfield& chf)
|
||||
{
|
||||
float bmin[3], bmax[3];
|
||||
vcopy(bmin, verts);
|
||||
vcopy(bmax, verts);
|
||||
rcVcopy(bmin, verts);
|
||||
rcVcopy(bmax, verts);
|
||||
for (int i = 1; i < nverts; ++i)
|
||||
{
|
||||
vmin(bmin, &verts[i*3]);
|
||||
vmax(bmax, &verts[i*3]);
|
||||
rcVmin(bmin, &verts[i*3]);
|
||||
rcVmax(bmax, &verts[i*3]);
|
||||
}
|
||||
bmin[1] = hmin;
|
||||
bmax[1] = hmax;
|
||||
|
@ -565,8 +565,8 @@ bool rcBuildContours(rcCompactHeightfield& chf,
|
||||
|
||||
rcTimeVal startTime = rcGetPerformanceTimer();
|
||||
|
||||
vcopy(cset.bmin, chf.bmin);
|
||||
vcopy(cset.bmax, chf.bmax);
|
||||
rcVcopy(cset.bmin, chf.bmin);
|
||||
rcVcopy(cset.bmax, chf.bmax);
|
||||
cset.cs = chf.cs;
|
||||
cset.ch = chf.ch;
|
||||
|
||||
|
@ -819,8 +819,8 @@ bool rcBuildPolyMesh(rcContourSet& cset, int nvp, rcPolyMesh& mesh)
|
||||
{
|
||||
rcTimeVal startTime = rcGetPerformanceTimer();
|
||||
|
||||
vcopy(mesh.bmin, cset.bmin);
|
||||
vcopy(mesh.bmax, cset.bmax);
|
||||
rcVcopy(mesh.bmin, cset.bmin);
|
||||
rcVcopy(mesh.bmax, cset.bmax);
|
||||
mesh.cs = cset.cs;
|
||||
mesh.ch = cset.ch;
|
||||
|
||||
@ -1125,16 +1125,16 @@ bool rcMergePolyMeshes(rcPolyMesh** meshes, const int nmeshes, rcPolyMesh& mesh)
|
||||
mesh.nvp = meshes[0]->nvp;
|
||||
mesh.cs = meshes[0]->cs;
|
||||
mesh.ch = meshes[0]->ch;
|
||||
vcopy(mesh.bmin, meshes[0]->bmin);
|
||||
vcopy(mesh.bmax, meshes[0]->bmax);
|
||||
rcVcopy(mesh.bmin, meshes[0]->bmin);
|
||||
rcVcopy(mesh.bmax, meshes[0]->bmax);
|
||||
|
||||
int maxVerts = 0;
|
||||
int maxPolys = 0;
|
||||
int maxVertsPerMesh = 0;
|
||||
for (int i = 0; i < nmeshes; ++i)
|
||||
{
|
||||
vmin(mesh.bmin, meshes[i]->bmin);
|
||||
vmax(mesh.bmax, meshes[i]->bmax);
|
||||
rcVmin(mesh.bmin, meshes[i]->bmin);
|
||||
rcVmax(mesh.bmax, meshes[i]->bmax);
|
||||
maxVertsPerMesh = rcMax(maxVertsPerMesh, meshes[i]->nverts);
|
||||
maxVerts += meshes[i]->nverts;
|
||||
maxPolys += meshes[i]->npolys;
|
||||
|
@ -90,9 +90,9 @@ static bool circumCircle(const float* p1, const float* p2, const float* p3,
|
||||
static float distPtTri(const float* p, const float* a, const float* b, const float* c)
|
||||
{
|
||||
float v0[3], v1[3], v2[3];
|
||||
vsub(v0, c,a);
|
||||
vsub(v1, b,a);
|
||||
vsub(v2, p,a);
|
||||
rcVsub(v0, c,a);
|
||||
rcVsub(v1, b,a);
|
||||
rcVsub(v2, p,a);
|
||||
|
||||
const float dot00 = vdot2(v0, v0);
|
||||
const float dot01 = vdot2(v0, v1);
|
||||
@ -508,7 +508,7 @@ static bool buildPolyDetail(const float* in, const int nin,
|
||||
nverts = 0;
|
||||
|
||||
for (int i = 0; i < nin; ++i)
|
||||
vcopy(&verts[i*3], &in[i*3]);
|
||||
rcVcopy(&verts[i*3], &in[i*3]);
|
||||
nverts = nin;
|
||||
|
||||
const float cs = chf.cs;
|
||||
@ -602,7 +602,7 @@ static bool buildPolyDetail(const float* in, const int nin,
|
||||
{
|
||||
for (int k = nidx-2; k > 0; --k)
|
||||
{
|
||||
vcopy(&verts[nverts*3], &edge[idx[k]*3]);
|
||||
rcVcopy(&verts[nverts*3], &edge[idx[k]*3]);
|
||||
hull[nhull++] = nverts;
|
||||
nverts++;
|
||||
}
|
||||
@ -611,7 +611,7 @@ static bool buildPolyDetail(const float* in, const int nin,
|
||||
{
|
||||
for (int k = 1; k < nidx-1; ++k)
|
||||
{
|
||||
vcopy(&verts[nverts*3], &edge[idx[k]*3]);
|
||||
rcVcopy(&verts[nverts*3], &edge[idx[k]*3]);
|
||||
hull[nhull++] = nverts;
|
||||
nverts++;
|
||||
}
|
||||
@ -645,12 +645,12 @@ static bool buildPolyDetail(const float* in, const int nin,
|
||||
{
|
||||
// Create sample locations in a grid.
|
||||
float bmin[3], bmax[3];
|
||||
vcopy(bmin, in);
|
||||
vcopy(bmax, in);
|
||||
rcVcopy(bmin, in);
|
||||
rcVcopy(bmax, in);
|
||||
for (int i = 1; i < nin; ++i)
|
||||
{
|
||||
vmin(bmin, &in[i*3]);
|
||||
vmax(bmax, &in[i*3]);
|
||||
rcVmin(bmin, &in[i*3]);
|
||||
rcVmax(bmax, &in[i*3]);
|
||||
}
|
||||
int x0 = (int)floorf(bmin[0]/sampleDist);
|
||||
int x1 = (int)ceilf(bmax[0]/sampleDist);
|
||||
@ -693,7 +693,7 @@ static bool buildPolyDetail(const float* in, const int nin,
|
||||
if (d > bestd)
|
||||
{
|
||||
bestd = d;
|
||||
vcopy(bestpt,pt);
|
||||
rcVcopy(bestpt,pt);
|
||||
}
|
||||
}
|
||||
// If the max error is within accepted threshold, stop tesselating.
|
||||
@ -701,7 +701,7 @@ static bool buildPolyDetail(const float* in, const int nin,
|
||||
break;
|
||||
|
||||
// Add the new sample point.
|
||||
vcopy(&verts[nverts*3],bestpt);
|
||||
rcVcopy(&verts[nverts*3],bestpt);
|
||||
nverts++;
|
||||
|
||||
// Create new triangulation.
|
||||
@ -1200,7 +1200,7 @@ bool rcMergePolyMeshDetails(rcPolyMeshDetail** meshes, const int nmeshes, rcPoly
|
||||
|
||||
for (int k = 0; k < dm->nverts; ++k)
|
||||
{
|
||||
vcopy(&mesh.verts[mesh.nverts*3], &dm->verts[k*3]);
|
||||
rcVcopy(&mesh.verts[mesh.nverts*3], &dm->verts[k*3]);
|
||||
mesh.nverts++;
|
||||
}
|
||||
for (int k = 0; k < dm->ntris; ++k)
|
||||
|
@ -196,12 +196,12 @@ static void rasterizeTri(const float* v0, const float* v1, const float* v2,
|
||||
const float by = bmax[1] - bmin[1];
|
||||
|
||||
// Calculate the bounding box of the triangle.
|
||||
vcopy(tmin, v0);
|
||||
vcopy(tmax, v0);
|
||||
vmin(tmin, v1);
|
||||
vmin(tmin, v2);
|
||||
vmax(tmax, v1);
|
||||
vmax(tmax, v2);
|
||||
rcVcopy(tmin, v0);
|
||||
rcVcopy(tmax, v0);
|
||||
rcVmin(tmin, v1);
|
||||
rcVmin(tmin, v2);
|
||||
rcVmax(tmax, v1);
|
||||
rcVmax(tmax, v2);
|
||||
|
||||
// If the triangle does not touch the bbox of the heightfield, skip the triagle.
|
||||
if (!overlapBounds(bmin, bmax, tmin, tmax))
|
||||
@ -223,9 +223,9 @@ static void rasterizeTri(const float* v0, const float* v1, const float* v2,
|
||||
for (int y = y0; y <= y1; ++y)
|
||||
{
|
||||
// Clip polygon to row.
|
||||
vcopy(&in[0], v0);
|
||||
vcopy(&in[1*3], v1);
|
||||
vcopy(&in[2*3], v2);
|
||||
rcVcopy(&in[0], v0);
|
||||
rcVcopy(&in[1*3], v1);
|
||||
rcVcopy(&in[2*3], v2);
|
||||
int nvrow = 3;
|
||||
const float cz = bmin[2] + y*cs;
|
||||
nvrow = clipPoly(in, nvrow, out, 0, 1, -cz);
|
||||
|
Binary file not shown.
File diff suppressed because it is too large
Load Diff
@ -216,10 +216,10 @@
|
||||
<key>_historyCapacity</key>
|
||||
<integer>0</integer>
|
||||
<key>bookmark</key>
|
||||
<string>6BF5F3751175AACB000502A6</string>
|
||||
<string>6BF5F4B1117644A2000502A6</string>
|
||||
<key>history</key>
|
||||
<array>
|
||||
<string>6BF5F2B811747E6F000502A6</string>
|
||||
<string>6BF5F3751175AACB000502A6</string>
|
||||
</array>
|
||||
</dict>
|
||||
<key>SplitCount</key>
|
||||
@ -323,8 +323,8 @@
|
||||
<key>PBXSmartGroupTreeModuleOutlineStateSelectionKey</key>
|
||||
<array>
|
||||
<array>
|
||||
<integer>5</integer>
|
||||
<integer>2</integer>
|
||||
<integer>18</integer>
|
||||
<integer>11</integer>
|
||||
<integer>1</integer>
|
||||
<integer>0</integer>
|
||||
</array>
|
||||
@ -365,7 +365,7 @@
|
||||
<key>PBXProjectModuleGUID</key>
|
||||
<string>6B8632A30F78115100E2684A</string>
|
||||
<key>PBXProjectModuleLabel</key>
|
||||
<string>DebugDraw.cpp</string>
|
||||
<string>DetourNavMesh.cpp</string>
|
||||
<key>PBXSplitModuleInNavigatorKey</key>
|
||||
<dict>
|
||||
<key>Split0</key>
|
||||
@ -373,23 +373,19 @@
|
||||
<key>PBXProjectModuleGUID</key>
|
||||
<string>6B8632A40F78115100E2684A</string>
|
||||
<key>PBXProjectModuleLabel</key>
|
||||
<string>DebugDraw.cpp</string>
|
||||
<string>DetourNavMesh.cpp</string>
|
||||
<key>_historyCapacity</key>
|
||||
<integer>0</integer>
|
||||
<key>bookmark</key>
|
||||
<string>6BF5F3741175AACB000502A6</string>
|
||||
<string>6BF5F4A7117644A2000502A6</string>
|
||||
<key>history</key>
|
||||
<array>
|
||||
<string>6BBB4A94115B4F3400CF791D</string>
|
||||
<string>6BBB4A95115B4F3400CF791D</string>
|
||||
<string>6BBB4A96115B4F3400CF791D</string>
|
||||
<string>6BBB4A99115B4F3400CF791D</string>
|
||||
<string>6BBB4A9A115B4F3400CF791D</string>
|
||||
<string>6BBB4A9B115B4F3400CF791D</string>
|
||||
<string>6BBB4A9E115B4F3400CF791D</string>
|
||||
<string>6BBB4AA0115B4F3400CF791D</string>
|
||||
<string>6BBB4AA1115B4F3400CF791D</string>
|
||||
<string>6BBB4AA2115B4F3400CF791D</string>
|
||||
<string>6BBB4AA3115B4F3400CF791D</string>
|
||||
<string>6BBB4AA4115B4F3400CF791D</string>
|
||||
<string>6BBB4AA5115B4F3400CF791D</string>
|
||||
@ -397,39 +393,27 @@
|
||||
<string>6BBB4AA7115B4F3400CF791D</string>
|
||||
<string>6BBB4AAB115B4F3400CF791D</string>
|
||||
<string>6BBB4AB0115B4F3400CF791D</string>
|
||||
<string>6BBB4AB1115B4F3400CF791D</string>
|
||||
<string>6BBB4AB2115B4F3400CF791D</string>
|
||||
<string>6BBB4AB3115B4F3400CF791D</string>
|
||||
<string>6BBB4AB4115B4F3400CF791D</string>
|
||||
<string>6BBB4ABB115B4F3400CF791D</string>
|
||||
<string>6BBB4ABD115B4F3400CF791D</string>
|
||||
<string>6BBB4ABE115B4F3400CF791D</string>
|
||||
<string>6BBB4ABF115B4F3400CF791D</string>
|
||||
<string>6BBB4AC0115B4F3400CF791D</string>
|
||||
<string>6BBB4AC1115B4F3400CF791D</string>
|
||||
<string>6BBB4AC2115B4F3400CF791D</string>
|
||||
<string>6BBB4AC3115B4F3400CF791D</string>
|
||||
<string>6BBB4AC4115B4F3400CF791D</string>
|
||||
<string>6BBB4AC5115B4F3400CF791D</string>
|
||||
<string>6BBB4AC6115B4F3400CF791D</string>
|
||||
<string>6BBB4AC8115B4F3400CF791D</string>
|
||||
<string>6BBB4AC9115B4F3400CF791D</string>
|
||||
<string>6BBB4ACB115B4F3400CF791D</string>
|
||||
<string>6BBB4ACD115B4F3400CF791D</string>
|
||||
<string>6BBB4B7A115B639200CF791D</string>
|
||||
<string>6BBB4B7D115B639200CF791D</string>
|
||||
<string>6BBB4B7F115B639200CF791D</string>
|
||||
<string>6BBB4C34115B7A3D00CF791D</string>
|
||||
<string>6BED8AE2117451EB00582F38</string>
|
||||
<string>6BED8AEE117455CB00582F38</string>
|
||||
<string>6BED8AF21174567000582F38</string>
|
||||
<string>6BF5F27011747CFA000502A6</string>
|
||||
<string>6BF5F27311747CFA000502A6</string>
|
||||
<string>6BF5F2E411748884000502A6</string>
|
||||
<string>6BF5F2E511748884000502A6</string>
|
||||
<string>6BF5F2E611748884000502A6</string>
|
||||
<string>6BF5F2E711748884000502A6</string>
|
||||
<string>6BF5F2E911748884000502A6</string>
|
||||
<string>6BF5F2EA11748884000502A6</string>
|
||||
<string>6BF5F30E1174904B000502A6</string>
|
||||
<string>6BF5F31C117490A1000502A6</string>
|
||||
@ -437,14 +421,30 @@
|
||||
<string>6BF5F32F11759C3C000502A6</string>
|
||||
<string>6BF5F33011759C3C000502A6</string>
|
||||
<string>6BF5F33111759C3C000502A6</string>
|
||||
<string>6BF5F33211759C3C000502A6</string>
|
||||
<string>6BF5F33311759C3C000502A6</string>
|
||||
<string>6BF5F33411759C3C000502A6</string>
|
||||
<string>6BF5F36A1175A3C9000502A6</string>
|
||||
<string>6BF5F36E1175AACB000502A6</string>
|
||||
<string>6BF5F36F1175AACB000502A6</string>
|
||||
<string>6BF5F3701175AACB000502A6</string>
|
||||
<string>6BBB4A9C115B4F3400CF791D</string>
|
||||
<string>6BF5F471117644A2000502A6</string>
|
||||
<string>6BF5F472117644A2000502A6</string>
|
||||
<string>6BF5F473117644A2000502A6</string>
|
||||
<string>6BF5F474117644A2000502A6</string>
|
||||
<string>6BF5F475117644A2000502A6</string>
|
||||
<string>6BF5F476117644A2000502A6</string>
|
||||
<string>6BF5F477117644A2000502A6</string>
|
||||
<string>6BF5F478117644A2000502A6</string>
|
||||
<string>6BF5F479117644A2000502A6</string>
|
||||
<string>6BF5F47A117644A2000502A6</string>
|
||||
<string>6BF5F47B117644A2000502A6</string>
|
||||
<string>6BF5F47C117644A2000502A6</string>
|
||||
<string>6BF5F47D117644A2000502A6</string>
|
||||
<string>6BF5F47E117644A2000502A6</string>
|
||||
<string>6BF5F47F117644A2000502A6</string>
|
||||
<string>6BF5F480117644A2000502A6</string>
|
||||
<string>6BF5F481117644A2000502A6</string>
|
||||
<string>6BF5F482117644A2000502A6</string>
|
||||
<string>6BF5F483117644A2000502A6</string>
|
||||
<string>6BF5F484117644A2000502A6</string>
|
||||
<string>6BF5F485117644A2000502A6</string>
|
||||
</array>
|
||||
<key>prevStack</key>
|
||||
<array>
|
||||
@ -506,73 +506,45 @@
|
||||
<string>6BF5F27811747CFA000502A6</string>
|
||||
<string>6BF5F28011747CFA000502A6</string>
|
||||
<string>6BF5F28D11747CFA000502A6</string>
|
||||
<string>6BF5F2EC11748884000502A6</string>
|
||||
<string>6BF5F2ED11748884000502A6</string>
|
||||
<string>6BF5F2EE11748884000502A6</string>
|
||||
<string>6BF5F2EF11748884000502A6</string>
|
||||
<string>6BF5F2F011748884000502A6</string>
|
||||
<string>6BF5F2F111748884000502A6</string>
|
||||
<string>6BF5F2F211748884000502A6</string>
|
||||
<string>6BF5F2F311748884000502A6</string>
|
||||
<string>6BF5F2F411748884000502A6</string>
|
||||
<string>6BF5F2F511748884000502A6</string>
|
||||
<string>6BF5F2F611748884000502A6</string>
|
||||
<string>6BF5F2F711748884000502A6</string>
|
||||
<string>6BF5F2F811748884000502A6</string>
|
||||
<string>6BF5F2F911748884000502A6</string>
|
||||
<string>6BF5F2FA11748884000502A6</string>
|
||||
<string>6BF5F3121174904B000502A6</string>
|
||||
<string>6BF5F3131174904B000502A6</string>
|
||||
<string>6BF5F3141174904B000502A6</string>
|
||||
<string>6BF5F3151174904B000502A6</string>
|
||||
<string>6BF5F31E117490A1000502A6</string>
|
||||
<string>6BF5F31F117490A1000502A6</string>
|
||||
<string>6BF5F33611759C3C000502A6</string>
|
||||
<string>6BF5F33711759C3C000502A6</string>
|
||||
<string>6BF5F33811759C3C000502A6</string>
|
||||
<string>6BF5F33911759C3C000502A6</string>
|
||||
<string>6BF5F33A11759C3C000502A6</string>
|
||||
<string>6BF5F33B11759C3C000502A6</string>
|
||||
<string>6BF5F33C11759C3C000502A6</string>
|
||||
<string>6BF5F33D11759C3C000502A6</string>
|
||||
<string>6BF5F33E11759C3C000502A6</string>
|
||||
<string>6BF5F33F11759C3C000502A6</string>
|
||||
<string>6BF5F34011759C3C000502A6</string>
|
||||
<string>6BF5F34111759C3C000502A6</string>
|
||||
<string>6BF5F34211759C3C000502A6</string>
|
||||
<string>6BF5F34311759C3C000502A6</string>
|
||||
<string>6BF5F34411759C3C000502A6</string>
|
||||
<string>6BF5F34511759C3C000502A6</string>
|
||||
<string>6BF5F34611759C3C000502A6</string>
|
||||
<string>6BF5F34711759C3C000502A6</string>
|
||||
<string>6BF5F34811759C3C000502A6</string>
|
||||
<string>6BF5F34911759C3C000502A6</string>
|
||||
<string>6BF5F34A11759C3C000502A6</string>
|
||||
<string>6BF5F34B11759C3C000502A6</string>
|
||||
<string>6BF5F34C11759C3C000502A6</string>
|
||||
<string>6BF5F34D11759C3C000502A6</string>
|
||||
<string>6BF5F34E11759C3C000502A6</string>
|
||||
<string>6BF5F3541175A187000502A6</string>
|
||||
<string>6BF5F3551175A187000502A6</string>
|
||||
<string>6BF5F3561175A187000502A6</string>
|
||||
<string>6BF5F3571175A187000502A6</string>
|
||||
<string>6BF5F3581175A187000502A6</string>
|
||||
<string>6BF5F3591175A187000502A6</string>
|
||||
<string>6BF5F35A1175A187000502A6</string>
|
||||
<string>6BF5F35B1175A187000502A6</string>
|
||||
<string>6BF5F35C1175A187000502A6</string>
|
||||
<string>6BF5F35D1175A187000502A6</string>
|
||||
<string>6BF5F35E1175A187000502A6</string>
|
||||
<string>6BF5F35F1175A187000502A6</string>
|
||||
<string>6BF5F3601175A187000502A6</string>
|
||||
<string>6BF5F3611175A187000502A6</string>
|
||||
<string>6BF5F3621175A187000502A6</string>
|
||||
<string>6BF5F3631175A187000502A6</string>
|
||||
<string>6BF5F3671175A3A4000502A6</string>
|
||||
<string>6BF5F36B1175A3C9000502A6</string>
|
||||
<string>6BF5F3711175AACB000502A6</string>
|
||||
<string>6BF5F3721175AACB000502A6</string>
|
||||
<string>6BF5F3731175AACB000502A6</string>
|
||||
<string>6BF5F486117644A2000502A6</string>
|
||||
<string>6BF5F487117644A2000502A6</string>
|
||||
<string>6BF5F488117644A2000502A6</string>
|
||||
<string>6BF5F489117644A2000502A6</string>
|
||||
<string>6BF5F48A117644A2000502A6</string>
|
||||
<string>6BF5F48B117644A2000502A6</string>
|
||||
<string>6BF5F48C117644A2000502A6</string>
|
||||
<string>6BF5F48D117644A2000502A6</string>
|
||||
<string>6BF5F48E117644A2000502A6</string>
|
||||
<string>6BF5F48F117644A2000502A6</string>
|
||||
<string>6BF5F490117644A2000502A6</string>
|
||||
<string>6BF5F491117644A2000502A6</string>
|
||||
<string>6BF5F492117644A2000502A6</string>
|
||||
<string>6BF5F493117644A2000502A6</string>
|
||||
<string>6BF5F494117644A2000502A6</string>
|
||||
<string>6BF5F495117644A2000502A6</string>
|
||||
<string>6BF5F496117644A2000502A6</string>
|
||||
<string>6BF5F497117644A2000502A6</string>
|
||||
<string>6BF5F498117644A2000502A6</string>
|
||||
<string>6BF5F499117644A2000502A6</string>
|
||||
<string>6BF5F49A117644A2000502A6</string>
|
||||
<string>6BF5F49B117644A2000502A6</string>
|
||||
<string>6BF5F49C117644A2000502A6</string>
|
||||
<string>6BF5F49D117644A2000502A6</string>
|
||||
<string>6BF5F49E117644A2000502A6</string>
|
||||
<string>6BF5F49F117644A2000502A6</string>
|
||||
<string>6BF5F4A0117644A2000502A6</string>
|
||||
<string>6BF5F4A1117644A2000502A6</string>
|
||||
<string>6BF5F4A2117644A2000502A6</string>
|
||||
<string>6BF5F4A3117644A2000502A6</string>
|
||||
<string>6BF5F4A4117644A2000502A6</string>
|
||||
<string>6BF5F4A5117644A2000502A6</string>
|
||||
<string>6BF5F4A6117644A2000502A6</string>
|
||||
</array>
|
||||
</dict>
|
||||
<key>SplitCount</key>
|
||||
@ -586,18 +558,18 @@
|
||||
<key>GeometryConfiguration</key>
|
||||
<dict>
|
||||
<key>Frame</key>
|
||||
<string>{{0, 0}, {970, 546}}</string>
|
||||
<string>{{0, 0}, {970, 456}}</string>
|
||||
<key>RubberWindowFrame</key>
|
||||
<string>13 75 1256 702 0 0 1280 778 </string>
|
||||
</dict>
|
||||
<key>Module</key>
|
||||
<string>PBXNavigatorGroup</string>
|
||||
<key>Proportion</key>
|
||||
<string>546pt</string>
|
||||
<string>456pt</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>Proportion</key>
|
||||
<string>110pt</string>
|
||||
<string>200pt</string>
|
||||
<key>Tabs</key>
|
||||
<array>
|
||||
<dict>
|
||||
@ -611,7 +583,7 @@
|
||||
<key>GeometryConfiguration</key>
|
||||
<dict>
|
||||
<key>Frame</key>
|
||||
<string>{{10, 27}, {970, 92}}</string>
|
||||
<string>{{10, 27}, {970, 83}}</string>
|
||||
</dict>
|
||||
<key>Module</key>
|
||||
<string>XCDetailModule</string>
|
||||
@ -665,7 +637,7 @@
|
||||
<key>GeometryConfiguration</key>
|
||||
<dict>
|
||||
<key>Frame</key>
|
||||
<string>{{10, 27}, {970, 83}}</string>
|
||||
<string>{{10, 27}, {970, 173}}</string>
|
||||
<key>RubberWindowFrame</key>
|
||||
<string>13 75 1256 702 0 0 1280 778 </string>
|
||||
</dict>
|
||||
@ -695,11 +667,11 @@
|
||||
</array>
|
||||
<key>TableOfContents</key>
|
||||
<array>
|
||||
<string>6BF5F2FC11748884000502A6</string>
|
||||
<string>6BF5F4A8117644A2000502A6</string>
|
||||
<string>1CA23ED40692098700951B8B</string>
|
||||
<string>6BF5F2FD11748884000502A6</string>
|
||||
<string>6BF5F4A9117644A2000502A6</string>
|
||||
<string>6B8632A30F78115100E2684A</string>
|
||||
<string>6BF5F2FE11748884000502A6</string>
|
||||
<string>6BF5F4AA117644A2000502A6</string>
|
||||
<string>1CA23EDF0692099D00951B8B</string>
|
||||
<string>1CA23EE00692099D00951B8B</string>
|
||||
<string>1CA23EE10692099D00951B8B</string>
|
||||
@ -848,14 +820,14 @@
|
||||
</array>
|
||||
<key>TableOfContents</key>
|
||||
<array>
|
||||
<string>6BF5F2FF11748884000502A6</string>
|
||||
<string>6BF5F4AB117644A2000502A6</string>
|
||||
<string>1CCC7628064C1048000F2A68</string>
|
||||
<string>1CCC7629064C1048000F2A68</string>
|
||||
<string>6BF5F30011748884000502A6</string>
|
||||
<string>6BF5F30111748884000502A6</string>
|
||||
<string>6BF5F30211748884000502A6</string>
|
||||
<string>6BF5F30311748884000502A6</string>
|
||||
<string>6BF5F30411748884000502A6</string>
|
||||
<string>6BF5F4AC117644A2000502A6</string>
|
||||
<string>6BF5F4AD117644A2000502A6</string>
|
||||
<string>6BF5F4AE117644A2000502A6</string>
|
||||
<string>6BF5F4AF117644A2000502A6</string>
|
||||
<string>6BF5F4B0117644A2000502A6</string>
|
||||
</array>
|
||||
<key>ToolbarConfigUserDefaultsMinorVersion</key>
|
||||
<string>2</string>
|
||||
@ -887,8 +859,6 @@
|
||||
<integer>5</integer>
|
||||
<key>WindowOrderList</key>
|
||||
<array>
|
||||
<string>6BF5F322117490A1000502A6</string>
|
||||
<string>6BF5F323117490A1000502A6</string>
|
||||
<string>6BF5F29911747CFA000502A6</string>
|
||||
<string>/Users/memon/Code/recastnavigation/RecastDemo/Build/Xcode/Recast.xcodeproj</string>
|
||||
</array>
|
||||
|
@ -191,14 +191,14 @@ void ConvexVolumeTool::handleClick(const float* p, bool shift)
|
||||
// Create
|
||||
|
||||
// If clicked on that last pt, create the shape.
|
||||
if (m_npts && vdistSqr(p, &m_pts[(m_npts-1)*3]) < rcSqr(0.2f))
|
||||
if (m_npts && rcVdistSqr(p, &m_pts[(m_npts-1)*3]) < rcSqr(0.2f))
|
||||
{
|
||||
if (m_nhull > 2)
|
||||
{
|
||||
// Create shape.
|
||||
float verts[MAX_PTS*3];
|
||||
for (int i = 0; i < m_nhull; ++i)
|
||||
vcopy(&verts[i*3], &m_pts[m_hull[i]*3]);
|
||||
rcVcopy(&verts[i*3], &m_pts[m_hull[i]*3]);
|
||||
|
||||
float minh = FLT_MAX, maxh = 0;
|
||||
for (int i = 0; i < m_nhull; ++i)
|
||||
@ -217,7 +217,7 @@ void ConvexVolumeTool::handleClick(const float* p, bool shift)
|
||||
// Add new point
|
||||
if (m_npts < MAX_PTS)
|
||||
{
|
||||
vcopy(&m_pts[m_npts*3], p);
|
||||
rcVcopy(&m_pts[m_npts*3], p);
|
||||
m_npts++;
|
||||
// Update hull.
|
||||
if (m_npts > 1)
|
||||
|
@ -36,32 +36,32 @@ static bool intersectSegmentTriangle(const float* sp, const float* sq,
|
||||
{
|
||||
float v, w;
|
||||
float ab[3], ac[3], qp[3], ap[3], norm[3], e[3];
|
||||
vsub(ab, b, a);
|
||||
vsub(ac, c, a);
|
||||
vsub(qp, sp, sq);
|
||||
rcVsub(ab, b, a);
|
||||
rcVsub(ac, c, a);
|
||||
rcVsub(qp, sp, sq);
|
||||
|
||||
// Compute triangle normal. Can be precalculated or cached if
|
||||
// intersecting multiple segments against the same triangle
|
||||
vcross(norm, ab, ac);
|
||||
rcVcross(norm, ab, ac);
|
||||
|
||||
// Compute denominator d. If d <= 0, segment is parallel to or points
|
||||
// away from triangle, so exit early
|
||||
float d = vdot(qp, norm);
|
||||
float d = rcVdot(qp, norm);
|
||||
if (d <= 0.0f) return false;
|
||||
|
||||
// Compute intersection t value of pq with plane of triangle. A ray
|
||||
// intersects iff 0 <= t. Segment intersects iff 0 <= t <= 1. Delay
|
||||
// dividing by d until intersection has been found to pierce triangle
|
||||
vsub(ap, sp, a);
|
||||
t = vdot(ap, norm);
|
||||
rcVsub(ap, sp, a);
|
||||
t = rcVdot(ap, norm);
|
||||
if (t < 0.0f) return false;
|
||||
if (t > d) return false; // For segment; exclude this code line for a ray test
|
||||
|
||||
// Compute barycentric coordinate components and test if within bounds
|
||||
vcross(e, qp, ap);
|
||||
v = vdot(ac, e);
|
||||
rcVcross(e, qp, ap);
|
||||
v = rcVdot(ac, e);
|
||||
if (v < 0.0f || v > d) return false;
|
||||
w = -vdot(ab, e);
|
||||
w = -rcVdot(ab, e);
|
||||
if (w < 0.0f || v + w > d) return false;
|
||||
|
||||
// Segment/ray intersects triangle. Perform delayed division
|
||||
@ -289,7 +289,7 @@ bool InputGeom::save(const char* filepath)
|
||||
bool InputGeom::raycastMesh(float* src, float* dst, float& tmin)
|
||||
{
|
||||
float dir[3];
|
||||
vsub(dir, dst, src);
|
||||
rcVsub(dir, dst, src);
|
||||
|
||||
int nt = m_mesh->getTriCount();
|
||||
const float* verts = m_mesh->getVerts();
|
||||
@ -301,7 +301,7 @@ bool InputGeom::raycastMesh(float* src, float* dst, float& tmin)
|
||||
for (int i = 0; i < nt*3; i += 3)
|
||||
{
|
||||
const float* n = &normals[i];
|
||||
if (vdot(dir, n) > 0)
|
||||
if (rcVdot(dir, n) > 0)
|
||||
continue;
|
||||
|
||||
float t = 1;
|
||||
@ -328,8 +328,8 @@ void InputGeom::addOffMeshConnection(const float* spos, const float* epos, const
|
||||
m_offMeshConDirs[m_offMeshConCount] = bidir;
|
||||
m_offMeshConAreas[m_offMeshConCount] = area;
|
||||
m_offMeshConFlags[m_offMeshConCount] = flags;
|
||||
vcopy(&v[0], spos);
|
||||
vcopy(&v[3], epos);
|
||||
rcVcopy(&v[0], spos);
|
||||
rcVcopy(&v[3], epos);
|
||||
m_offMeshConCount++;
|
||||
}
|
||||
|
||||
@ -338,8 +338,8 @@ void InputGeom::deleteOffMeshConnection(int i)
|
||||
m_offMeshConCount--;
|
||||
float* src = &m_offMeshConVerts[m_offMeshConCount*3*2];
|
||||
float* dst = &m_offMeshConVerts[i*3*2];
|
||||
vcopy(&dst[0], &src[0]);
|
||||
vcopy(&dst[3], &src[3]);
|
||||
rcVcopy(&dst[0], &src[0]);
|
||||
rcVcopy(&dst[3], &src[3]);
|
||||
m_offMeshConRads[i] = m_offMeshConRads[m_offMeshConCount];
|
||||
m_offMeshConDirs[i] = m_offMeshConDirs[m_offMeshConCount];
|
||||
m_offMeshConAreas[i] = m_offMeshConAreas[m_offMeshConCount];
|
||||
|
@ -66,7 +66,7 @@ static bool getSteerTarget(dtNavMesh* navMesh, const float* startPos, const floa
|
||||
{
|
||||
*outPointCount = nsteerPath;
|
||||
for (int i = 0; i < nsteerPath; ++i)
|
||||
vcopy(&outPoints[i*3], &steerPath[i*3]);
|
||||
rcVcopy(&outPoints[i*3], &steerPath[i*3]);
|
||||
}
|
||||
|
||||
|
||||
@ -84,7 +84,7 @@ static bool getSteerTarget(dtNavMesh* navMesh, const float* startPos, const floa
|
||||
if (ns >= nsteerPath)
|
||||
return false;
|
||||
|
||||
vcopy(steerPos, &steerPath[ns*3]);
|
||||
rcVcopy(steerPos, &steerPath[ns*3]);
|
||||
steerPosFlag = steerPathFlags[ns];
|
||||
steerPosRef = steerPathPolys[ns];
|
||||
|
||||
@ -258,12 +258,12 @@ void NavMeshTesterTool::handleClick(const float* p, bool shift)
|
||||
if (shift)
|
||||
{
|
||||
m_sposSet = true;
|
||||
vcopy(m_spos, p);
|
||||
rcVcopy(m_spos, p);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_eposSet = true;
|
||||
vcopy(m_epos, p);
|
||||
rcVcopy(m_epos, p);
|
||||
}
|
||||
recalc();
|
||||
}
|
||||
@ -297,12 +297,12 @@ void NavMeshTesterTool::handleStep()
|
||||
|
||||
m_nsmoothPath = 0;
|
||||
|
||||
vcopy(&m_smoothPath[m_nsmoothPath*3], m_iterPos);
|
||||
rcVcopy(&m_smoothPath[m_nsmoothPath*3], m_iterPos);
|
||||
m_nsmoothPath++;
|
||||
}
|
||||
}
|
||||
|
||||
vcopy(m_prevIterPos, m_iterPos);
|
||||
rcVcopy(m_prevIterPos, m_iterPos);
|
||||
|
||||
m_pathIterNum++;
|
||||
|
||||
@ -325,22 +325,22 @@ void NavMeshTesterTool::handleStep()
|
||||
m_steerPoints, &m_steerPointCount))
|
||||
return;
|
||||
|
||||
vcopy(m_steerPos, steerPos);
|
||||
rcVcopy(m_steerPos, steerPos);
|
||||
|
||||
bool endOfPath = (steerPosFlag & DT_STRAIGHTPATH_END) ? true : false;
|
||||
bool offMeshConnection = (steerPosFlag & DT_STRAIGHTPATH_OFFMESH_CONNECTION) ? true : false;
|
||||
|
||||
// Find movement delta.
|
||||
float delta[3], len;
|
||||
vsub(delta, steerPos, m_iterPos);
|
||||
len = sqrtf(vdot(delta,delta));
|
||||
rcVsub(delta, steerPos, m_iterPos);
|
||||
len = sqrtf(rcVdot(delta,delta));
|
||||
// If the steer target is end of path or off-mesh link, do not move past the location.
|
||||
if ((endOfPath || offMeshConnection) && len < STEP_SIZE)
|
||||
len = 1;
|
||||
else
|
||||
len = STEP_SIZE / len;
|
||||
float moveTgt[3];
|
||||
vmad(moveTgt, m_iterPos, delta, len);
|
||||
rcVmad(moveTgt, m_iterPos, delta, len);
|
||||
|
||||
// Move
|
||||
float result[3];
|
||||
@ -355,16 +355,16 @@ void NavMeshTesterTool::handleStep()
|
||||
m_pathIterPolyCount -= n;
|
||||
}
|
||||
// Update position.
|
||||
vcopy(m_iterPos, result);
|
||||
rcVcopy(m_iterPos, result);
|
||||
|
||||
// Handle end of path and off-mesh links when close enough.
|
||||
if (endOfPath && inRange(m_iterPos, steerPos, SLOP, 1.0f))
|
||||
{
|
||||
// Reached end of path.
|
||||
vcopy(m_iterPos, m_targetPos);
|
||||
rcVcopy(m_iterPos, m_targetPos);
|
||||
if (m_nsmoothPath < MAX_SMOOTH)
|
||||
{
|
||||
vcopy(&m_smoothPath[m_nsmoothPath*3], m_iterPos);
|
||||
rcVcopy(&m_smoothPath[m_nsmoothPath*3], m_iterPos);
|
||||
m_nsmoothPath++;
|
||||
}
|
||||
return;
|
||||
@ -389,17 +389,17 @@ void NavMeshTesterTool::handleStep()
|
||||
{
|
||||
if (m_nsmoothPath < MAX_SMOOTH)
|
||||
{
|
||||
vcopy(&m_smoothPath[m_nsmoothPath*3], startPos);
|
||||
rcVcopy(&m_smoothPath[m_nsmoothPath*3], startPos);
|
||||
m_nsmoothPath++;
|
||||
// Hack to make the dotted path not visible during off-mesh connection.
|
||||
if (m_nsmoothPath & 1)
|
||||
{
|
||||
vcopy(&m_smoothPath[m_nsmoothPath*3], startPos);
|
||||
rcVcopy(&m_smoothPath[m_nsmoothPath*3], startPos);
|
||||
m_nsmoothPath++;
|
||||
}
|
||||
}
|
||||
// Move position at the other side of the off-mesh link.
|
||||
vcopy(m_iterPos, endPos);
|
||||
rcVcopy(m_iterPos, endPos);
|
||||
float h;
|
||||
m_navMesh->getPolyHeight(m_pathIterPolys[0], m_iterPos, &h);
|
||||
m_iterPos[1] = h;
|
||||
@ -409,7 +409,7 @@ void NavMeshTesterTool::handleStep()
|
||||
// Store results.
|
||||
if (m_nsmoothPath < MAX_SMOOTH)
|
||||
{
|
||||
vcopy(&m_smoothPath[m_nsmoothPath*3], m_iterPos);
|
||||
rcVcopy(&m_smoothPath[m_nsmoothPath*3], m_iterPos);
|
||||
m_nsmoothPath++;
|
||||
}
|
||||
|
||||
@ -473,7 +473,7 @@ void NavMeshTesterTool::recalc()
|
||||
|
||||
m_nsmoothPath = 0;
|
||||
|
||||
vcopy(&m_smoothPath[m_nsmoothPath*3], iterPos);
|
||||
rcVcopy(&m_smoothPath[m_nsmoothPath*3], iterPos);
|
||||
m_nsmoothPath++;
|
||||
|
||||
// Move towards target a small advancement at a time until target reached or
|
||||
@ -494,15 +494,15 @@ void NavMeshTesterTool::recalc()
|
||||
|
||||
// Find movement delta.
|
||||
float delta[3], len;
|
||||
vsub(delta, steerPos, iterPos);
|
||||
len = sqrtf(vdot(delta,delta));
|
||||
rcVsub(delta, steerPos, iterPos);
|
||||
len = sqrtf(rcVdot(delta,delta));
|
||||
// If the steer target is end of path or off-mesh link, do not move past the location.
|
||||
if ((endOfPath || offMeshConnection) && len < STEP_SIZE)
|
||||
len = 1;
|
||||
else
|
||||
len = STEP_SIZE / len;
|
||||
float moveTgt[3];
|
||||
vmad(moveTgt, iterPos, delta, len);
|
||||
rcVmad(moveTgt, iterPos, delta, len);
|
||||
|
||||
// Move
|
||||
float result[3];
|
||||
@ -517,16 +517,16 @@ void NavMeshTesterTool::recalc()
|
||||
npolys -= n;
|
||||
}
|
||||
// Update position.
|
||||
vcopy(iterPos, result);
|
||||
rcVcopy(iterPos, result);
|
||||
|
||||
// Handle end of path and off-mesh links when close enough.
|
||||
if (endOfPath && inRange(iterPos, steerPos, SLOP, 1.0f))
|
||||
{
|
||||
// Reached end of path.
|
||||
vcopy(iterPos, targetPos);
|
||||
rcVcopy(iterPos, targetPos);
|
||||
if (m_nsmoothPath < MAX_SMOOTH)
|
||||
{
|
||||
vcopy(&m_smoothPath[m_nsmoothPath*3], iterPos);
|
||||
rcVcopy(&m_smoothPath[m_nsmoothPath*3], iterPos);
|
||||
m_nsmoothPath++;
|
||||
}
|
||||
break;
|
||||
@ -551,17 +551,17 @@ void NavMeshTesterTool::recalc()
|
||||
{
|
||||
if (m_nsmoothPath < MAX_SMOOTH)
|
||||
{
|
||||
vcopy(&m_smoothPath[m_nsmoothPath*3], startPos);
|
||||
rcVcopy(&m_smoothPath[m_nsmoothPath*3], startPos);
|
||||
m_nsmoothPath++;
|
||||
// Hack to make the dotted path not visible during off-mesh connection.
|
||||
if (m_nsmoothPath & 1)
|
||||
{
|
||||
vcopy(&m_smoothPath[m_nsmoothPath*3], startPos);
|
||||
rcVcopy(&m_smoothPath[m_nsmoothPath*3], startPos);
|
||||
m_nsmoothPath++;
|
||||
}
|
||||
}
|
||||
// Move position at the other side of the off-mesh link.
|
||||
vcopy(iterPos, endPos);
|
||||
rcVcopy(iterPos, endPos);
|
||||
float h;
|
||||
m_navMesh->getPolyHeight(polys[0], iterPos, &h);
|
||||
iterPos[1] = h;
|
||||
@ -571,7 +571,7 @@ void NavMeshTesterTool::recalc()
|
||||
// Store results.
|
||||
if (m_nsmoothPath < MAX_SMOOTH)
|
||||
{
|
||||
vcopy(&m_smoothPath[m_nsmoothPath*3], iterPos);
|
||||
rcVcopy(&m_smoothPath[m_nsmoothPath*3], iterPos);
|
||||
m_nsmoothPath++;
|
||||
}
|
||||
}
|
||||
@ -628,7 +628,7 @@ void NavMeshTesterTool::recalc()
|
||||
if (t > 1)
|
||||
{
|
||||
// No hit
|
||||
vcopy(m_hitPos, m_epos);
|
||||
rcVcopy(m_hitPos, m_epos);
|
||||
m_hitResult = false;
|
||||
}
|
||||
else
|
||||
@ -645,7 +645,7 @@ void NavMeshTesterTool::recalc()
|
||||
}
|
||||
m_hitResult = true;
|
||||
}
|
||||
vcopy(&m_straightPath[3], m_hitPos);
|
||||
rcVcopy(&m_straightPath[3], m_hitPos);
|
||||
}
|
||||
}
|
||||
else if (m_toolMode == TOOLMODE_DISTANCE_TO_WALL)
|
||||
|
@ -99,7 +99,7 @@ void OffMeshConnectionTool::handleClick(const float* p, bool shift)
|
||||
for (int i = 0; i < geom->getOffMeshConnectionCount()*2; ++i)
|
||||
{
|
||||
const float* v = &verts[i*3];
|
||||
float d = vdistSqr(p, v);
|
||||
float d = rcVdistSqr(p, v);
|
||||
if (d < nearestDist)
|
||||
{
|
||||
nearestDist = d;
|
||||
@ -118,7 +118,7 @@ void OffMeshConnectionTool::handleClick(const float* p, bool shift)
|
||||
// Create
|
||||
if (!m_hitPosSet)
|
||||
{
|
||||
vcopy(m_hitPos, p);
|
||||
rcVcopy(m_hitPos, p);
|
||||
m_hitPosSet = true;
|
||||
}
|
||||
else
|
||||
|
@ -159,8 +159,8 @@ void Sample_Debug::handleRender()
|
||||
duDebugDrawNavMeshPoly(&dd, m_navMesh, m_ref, duRGBA(255,0,0,128));
|
||||
|
||||
float bmin[3], bmax[3];
|
||||
vsub(bmin, m_center, m_ext);
|
||||
vadd(bmax, m_center, m_ext);
|
||||
rcVsub(bmin, m_center, m_ext);
|
||||
rcVadd(bmax, m_center, m_ext);
|
||||
duDebugDrawBoxWire(&dd, bmin[0],bmin[1],bmin[2], bmax[0],bmax[1],bmax[2], duRGBA(255,255,255,128), 1.0f);
|
||||
duDebugDrawCross(&dd, m_center[0], m_center[1], m_center[2], 1.0f, duRGBA(255,255,255,128), 2.0f);
|
||||
|
||||
|
@ -370,8 +370,8 @@ bool Sample_SoloMeshSimple::handleBuild()
|
||||
// Set the area where the navigation will be build.
|
||||
// Here the bounds of the input mesh are used, but the
|
||||
// area could be specified by an user defined box, etc.
|
||||
vcopy(m_cfg.bmin, bmin);
|
||||
vcopy(m_cfg.bmax, bmax);
|
||||
rcVcopy(m_cfg.bmin, bmin);
|
||||
rcVcopy(m_cfg.bmax, bmax);
|
||||
rcCalcGridSize(m_cfg.bmin, m_cfg.bmax, m_cfg.cs, &m_cfg.width, &m_cfg.height);
|
||||
|
||||
// Reset build times gathering.
|
||||
@ -622,8 +622,8 @@ bool Sample_SoloMeshSimple::handleBuild()
|
||||
params.walkableHeight = m_agentHeight;
|
||||
params.walkableRadius = m_agentRadius;
|
||||
params.walkableClimb = m_agentMaxClimb;
|
||||
vcopy(params.bmin, m_pmesh->bmin);
|
||||
vcopy(params.bmax, m_pmesh->bmax);
|
||||
rcVcopy(params.bmin, m_pmesh->bmin);
|
||||
rcVcopy(params.bmax, m_pmesh->bmax);
|
||||
params.cs = m_cfg.cs;
|
||||
params.ch = m_cfg.ch;
|
||||
|
||||
|
@ -81,7 +81,7 @@ public:
|
||||
virtual void handleClick(const float* p, bool /*shift*/)
|
||||
{
|
||||
m_hitPosSet = true;
|
||||
vcopy(m_hitPos,p);
|
||||
rcVcopy(m_hitPos,p);
|
||||
if (m_sample)
|
||||
m_sample->setHighlightedTile(m_hitPos);
|
||||
}
|
||||
@ -716,8 +716,8 @@ bool Sample_SoloMeshTiled::handleBuild()
|
||||
// Set the area where the navigation will be build.
|
||||
// Here the bounds of the input mesh are used, but the
|
||||
// area could be specified by an user defined box, etc.
|
||||
vcopy(m_cfg.bmin, bmin);
|
||||
vcopy(m_cfg.bmax, bmax);
|
||||
rcVcopy(m_cfg.bmin, bmin);
|
||||
rcVcopy(m_cfg.bmax, bmax);
|
||||
rcCalcGridSize(m_cfg.bmin, m_cfg.bmax, m_cfg.cs, &m_cfg.width, &m_cfg.height);
|
||||
|
||||
// Reset build times gathering.
|
||||
@ -735,8 +735,8 @@ bool Sample_SoloMeshTiled::handleBuild()
|
||||
rcGetLog()->log(RC_LOG_ERROR, "buildTiledNavigation: Out of memory 'tileSet'.");
|
||||
return false;
|
||||
}
|
||||
vcopy(m_tileSet->bmin, m_cfg.bmin);
|
||||
vcopy(m_tileSet->bmax, m_cfg.bmax);
|
||||
rcVcopy(m_tileSet->bmin, m_cfg.bmin);
|
||||
rcVcopy(m_tileSet->bmax, m_cfg.bmax);
|
||||
m_tileSet->cs = m_cfg.cs;
|
||||
m_tileSet->ch = m_cfg.ch;
|
||||
m_tileSet->width = (m_cfg.width + m_cfg.tileSize-1) / m_cfg.tileSize;
|
||||
@ -1081,8 +1081,8 @@ bool Sample_SoloMeshTiled::handleBuild()
|
||||
params.walkableHeight = m_agentHeight;
|
||||
params.walkableRadius = m_agentRadius;
|
||||
params.walkableClimb = m_agentMaxClimb;
|
||||
vcopy(params.bmin, m_pmesh->bmin);
|
||||
vcopy(params.bmax, m_pmesh->bmax);
|
||||
rcVcopy(params.bmin, m_pmesh->bmin);
|
||||
rcVcopy(params.bmax, m_pmesh->bmax);
|
||||
params.cs = m_cfg.cs;
|
||||
params.ch = m_cfg.ch;
|
||||
|
||||
|
@ -115,7 +115,7 @@ public:
|
||||
virtual void handleClick(const float* p, bool shift)
|
||||
{
|
||||
m_hitPosSet = true;
|
||||
vcopy(m_hitPos,p);
|
||||
rcVcopy(m_hitPos,p);
|
||||
if (m_sample)
|
||||
{
|
||||
if (shift)
|
||||
@ -509,7 +509,7 @@ bool Sample_TileMesh::handleBuild()
|
||||
}
|
||||
|
||||
dtNavMeshParams params;
|
||||
vcopy(params.orig, m_geom->getMeshBoundsMin());
|
||||
rcVcopy(params.orig, m_geom->getMeshBoundsMin());
|
||||
params.tileWidth = m_tileSize*m_cellSize;
|
||||
params.tileHeight = m_tileSize*m_cellSize;
|
||||
params.maxTiles = m_maxTiles;
|
||||
@ -692,8 +692,8 @@ unsigned char* Sample_TileMesh::buildTileMesh(const int tx, const int ty, const
|
||||
m_cfg.detailSampleDist = m_detailSampleDist < 0.9f ? 0 : m_cellSize * m_detailSampleDist;
|
||||
m_cfg.detailSampleMaxError = m_cellHeight * m_detailSampleMaxError;
|
||||
|
||||
vcopy(m_cfg.bmin, bmin);
|
||||
vcopy(m_cfg.bmax, bmax);
|
||||
rcVcopy(m_cfg.bmin, bmin);
|
||||
rcVcopy(m_cfg.bmax, bmax);
|
||||
m_cfg.bmin[0] -= m_cfg.borderSize*m_cfg.cs;
|
||||
m_cfg.bmin[2] -= m_cfg.borderSize*m_cfg.cs;
|
||||
m_cfg.bmax[0] += m_cfg.borderSize*m_cfg.cs;
|
||||
@ -960,8 +960,8 @@ unsigned char* Sample_TileMesh::buildTileMesh(const int tx, const int ty, const
|
||||
params.walkableClimb = m_agentMaxClimb;
|
||||
params.tileX = tx;
|
||||
params.tileY = ty;
|
||||
vcopy(params.bmin, bmin);
|
||||
vcopy(params.bmax, bmax);
|
||||
rcVcopy(params.bmin, bmin);
|
||||
rcVcopy(params.bmax, bmax);
|
||||
params.cs = m_cfg.cs;
|
||||
params.ch = m_cfg.ch;
|
||||
params.tileSize = m_cfg.tileSize;
|
||||
|
@ -234,8 +234,8 @@ void TestCase::handleRender()
|
||||
for (Test* iter = m_tests; iter; iter = iter->next)
|
||||
{
|
||||
float dir[3];
|
||||
vsub(dir, iter->epos, iter->spos);
|
||||
vnormalize(dir);
|
||||
rcVsub(dir, iter->epos, iter->spos);
|
||||
rcVnormalize(dir);
|
||||
glColor4ub(128,25,0,192);
|
||||
glVertex3f(iter->spos[0],iter->spos[1]-0.3f,iter->spos[2]);
|
||||
glVertex3f(iter->spos[0],iter->spos[1]+0.3f,iter->spos[2]);
|
||||
@ -273,20 +273,20 @@ bool TestCase::handleRenderOverlay(double* proj, double* model, int* view)
|
||||
float pt[3], dir[3];
|
||||
if (iter->nstraight)
|
||||
{
|
||||
vcopy(pt, &iter->straight[3]);
|
||||
if (vdist(pt, iter->spos) > LABEL_DIST)
|
||||
rcVcopy(pt, &iter->straight[3]);
|
||||
if (rcVdist(pt, iter->spos) > LABEL_DIST)
|
||||
{
|
||||
vsub(dir, pt, iter->spos);
|
||||
vnormalize(dir);
|
||||
vmad(pt, iter->spos, dir, LABEL_DIST);
|
||||
rcVsub(dir, pt, iter->spos);
|
||||
rcVnormalize(dir);
|
||||
rcVmad(pt, iter->spos, dir, LABEL_DIST);
|
||||
}
|
||||
pt[1]+=0.5f;
|
||||
}
|
||||
else
|
||||
{
|
||||
vsub(dir, iter->epos, iter->spos);
|
||||
vnormalize(dir);
|
||||
vmad(pt, iter->spos, dir, LABEL_DIST);
|
||||
rcVsub(dir, iter->epos, iter->spos);
|
||||
rcVnormalize(dir);
|
||||
rcVmad(pt, iter->spos, dir, LABEL_DIST);
|
||||
pt[1]+=0.5f;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user