forked from bit/DotRecastNetSim
[0, 1, 2] => xyz
This commit is contained in:
parent
98e2504d7f
commit
abf52d1ec3
|
@ -76,7 +76,7 @@ namespace DotRecast.Detour
|
||||||
Vector3f A = vSub(a, a1);
|
Vector3f A = vSub(a, a1);
|
||||||
Vector3f B = vSub(b, b1);
|
Vector3f B = vSub(b, b1);
|
||||||
|
|
||||||
float cross = B[0] * A[2] - A[0] * B[2]; // triArea2D({0, 0}, A, B);
|
float cross = B.x * A.z - A.x * B.z; // triArea2D({0, 0}, A, B);
|
||||||
float aHB = triArea2D(b1, b, a);
|
float aHB = triArea2D(b1, b, a);
|
||||||
float bHA = triArea2D(a1, a, b);
|
float bHA = triArea2D(a1, a, b);
|
||||||
if (Math.Abs(cross) < EPSILON)
|
if (Math.Abs(cross) < EPSILON)
|
||||||
|
@ -215,20 +215,20 @@ namespace DotRecast.Detour
|
||||||
{
|
{
|
||||||
if (ii > 0)
|
if (ii > 0)
|
||||||
{
|
{
|
||||||
if (inters[ii - 3] == p[0] && inters[ii - 2] == p[1] && inters[ii - 1] == p[2])
|
if (inters[ii - 3] == p.x && inters[ii - 2] == p.y && inters[ii - 1] == p.z)
|
||||||
{
|
{
|
||||||
return ii;
|
return ii;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (inters[0] == p[0] && inters[1] == p[1] && inters[2] == p[2])
|
if (inters[0] == p.x && inters[1] == p.y && inters[2] == p.z)
|
||||||
{
|
{
|
||||||
return ii;
|
return ii;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
inters[ii] = p[0];
|
inters[ii] = p.x;
|
||||||
inters[ii + 1] = p[1];
|
inters[ii + 1] = p.y;
|
||||||
inters[ii + 2] = p[2];
|
inters[ii + 2] = p.z;
|
||||||
return ii + 3;
|
return ii + 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -256,9 +256,9 @@ namespace DotRecast.Detour
|
||||||
float t = isec.Item2;
|
float t = isec.Item2;
|
||||||
if (s >= 0.0f && s <= 1.0f && t >= 0.0f && t <= 1.0f)
|
if (s >= 0.0f && s <= 1.0f && t >= 0.0f && t <= 1.0f)
|
||||||
{
|
{
|
||||||
p.x = a[0] + (b[0] - a[0]) * s;
|
p.x = a.x + (b.x - a.x) * s;
|
||||||
p.y = a[1] + (b[1] - a[1]) * s;
|
p.y = a.y + (b.y - a.y) * s;
|
||||||
p.z = a[2] + (b[2] - a[2]) * s;
|
p.z = a.z + (b.z - a.z) * s;
|
||||||
return Intersection.Single;
|
return Intersection.Single;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -315,14 +315,14 @@ namespace DotRecast.Detour
|
||||||
|
|
||||||
private static bool between(Vector3f a, Vector3f b, Vector3f c)
|
private static bool between(Vector3f a, Vector3f b, Vector3f c)
|
||||||
{
|
{
|
||||||
if (Math.Abs(a[0] - b[0]) > Math.Abs(a[2] - b[2]))
|
if (Math.Abs(a.x - b.x) > Math.Abs(a.z - b.z))
|
||||||
{
|
{
|
||||||
return ((a[0] <= c[0]) && (c[0] <= b[0])) || ((a[0] >= c[0]) && (c[0] >= b[0]));
|
return ((a.x <= c.x) && (c.x <= b.x)) || ((a.x >= c.x) && (c.x >= b.x));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return ((a[2] <= c[2]) && (c[2] <= b[2])) || ((a[2] >= c[2]) && (c[2] >= b[2]));
|
return ((a.z <= c.z) && (c.z <= b.z)) || ((a.z >= c.z) && (c.z >= b.z));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,7 +36,7 @@ namespace DotRecast.Detour
|
||||||
Vector3f diff = vSub(center, closestPtPoly);
|
Vector3f diff = vSub(center, closestPtPoly);
|
||||||
if (posOverPoly)
|
if (posOverPoly)
|
||||||
{
|
{
|
||||||
d = Math.Abs(diff[1]) - tile.data.header.walkableClimb;
|
d = Math.Abs(diff.y) - tile.data.header.walkableClimb;
|
||||||
d = d > 0 ? d * d : 0;
|
d = d > 0 ? d * d : 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -44,12 +44,12 @@ namespace DotRecast.Detour.Io
|
||||||
write(stream, header.walkableHeight, order);
|
write(stream, header.walkableHeight, order);
|
||||||
write(stream, header.walkableRadius, order);
|
write(stream, header.walkableRadius, order);
|
||||||
write(stream, header.walkableClimb, order);
|
write(stream, header.walkableClimb, order);
|
||||||
write(stream, header.bmin[0], order);
|
write(stream, header.bmin.x, order);
|
||||||
write(stream, header.bmin[1], order);
|
write(stream, header.bmin.y, order);
|
||||||
write(stream, header.bmin[2], order);
|
write(stream, header.bmin.z, order);
|
||||||
write(stream, header.bmax[0], order);
|
write(stream, header.bmax.x, order);
|
||||||
write(stream, header.bmax[1], order);
|
write(stream, header.bmax.y, order);
|
||||||
write(stream, header.bmax[2], order);
|
write(stream, header.bmax.z, order);
|
||||||
write(stream, header.bvQuantFactor, order);
|
write(stream, header.bvQuantFactor, order);
|
||||||
writeVerts(stream, data.verts, header.vertCount, order);
|
writeVerts(stream, data.verts, header.vertCount, order);
|
||||||
writePolys(stream, data, order, cCompatibility);
|
writePolys(stream, data, order, cCompatibility);
|
||||||
|
|
|
@ -7,9 +7,9 @@ namespace DotRecast.Detour.Io
|
||||||
public NavMeshParams read(ByteBuffer bb)
|
public NavMeshParams read(ByteBuffer bb)
|
||||||
{
|
{
|
||||||
NavMeshParams option = new NavMeshParams();
|
NavMeshParams option = new NavMeshParams();
|
||||||
option.orig[0] = bb.getFloat();
|
option.orig.x = bb.getFloat();
|
||||||
option.orig[1] = bb.getFloat();
|
option.orig.y = bb.getFloat();
|
||||||
option.orig[2] = bb.getFloat();
|
option.orig.z = bb.getFloat();
|
||||||
option.tileWidth = bb.getFloat();
|
option.tileWidth = bb.getFloat();
|
||||||
option.tileHeight = bb.getFloat();
|
option.tileHeight = bb.getFloat();
|
||||||
option.maxTiles = bb.getInt();
|
option.maxTiles = bb.getInt();
|
||||||
|
|
|
@ -7,9 +7,9 @@ namespace DotRecast.Detour.Io
|
||||||
{
|
{
|
||||||
public void write(BinaryWriter stream, NavMeshParams option, ByteOrder order)
|
public void write(BinaryWriter stream, NavMeshParams option, ByteOrder order)
|
||||||
{
|
{
|
||||||
write(stream, option.orig[0], order);
|
write(stream, option.orig.x, order);
|
||||||
write(stream, option.orig[1], order);
|
write(stream, option.orig.y, order);
|
||||||
write(stream, option.orig[2], order);
|
write(stream, option.orig.z, order);
|
||||||
write(stream, option.tileWidth, order);
|
write(stream, option.tileWidth, order);
|
||||||
write(stream, option.tileHeight, order);
|
write(stream, option.tileHeight, order);
|
||||||
write(stream, option.maxTiles, order);
|
write(stream, option.maxTiles, order);
|
||||||
|
|
|
@ -750,10 +750,10 @@ namespace DotRecast.Detour
|
||||||
// Hit wall, update radius.
|
// Hit wall, update radius.
|
||||||
radiusSqr = distSqr;
|
radiusSqr = distSqr;
|
||||||
// Calculate hit pos.
|
// Calculate hit pos.
|
||||||
hitPos[0] = bestTile.data.verts[vj] + (bestTile.data.verts[vi] - bestTile.data.verts[vj]) * tseg;
|
hitPos.x = bestTile.data.verts[vj] + (bestTile.data.verts[vi] - bestTile.data.verts[vj]) * tseg;
|
||||||
hitPos[1] = bestTile.data.verts[vj + 1]
|
hitPos.y = bestTile.data.verts[vj + 1]
|
||||||
+ (bestTile.data.verts[vi + 1] - bestTile.data.verts[vj + 1]) * tseg;
|
+ (bestTile.data.verts[vi + 1] - bestTile.data.verts[vj + 1]) * tseg;
|
||||||
hitPos[2] = bestTile.data.verts[vj + 2]
|
hitPos.z = bestTile.data.verts[vj + 2]
|
||||||
+ (bestTile.data.verts[vi + 2] - bestTile.data.verts[vj + 2]) * tseg;
|
+ (bestTile.data.verts[vi + 2] - bestTile.data.verts[vj + 2]) * tseg;
|
||||||
bestvj = new VectorPtr(bestTile.data.verts, vj);
|
bestvj = new VectorPtr(bestTile.data.verts, vj);
|
||||||
bestvi = new VectorPtr(bestTile.data.verts, vi);
|
bestvi = new VectorPtr(bestTile.data.verts, vi);
|
||||||
|
@ -844,9 +844,9 @@ namespace DotRecast.Detour
|
||||||
if (bestvi != null && bestvj != null)
|
if (bestvi != null && bestvj != null)
|
||||||
{
|
{
|
||||||
var tangent = vSub(bestvi, bestvj);
|
var tangent = vSub(bestvi, bestvj);
|
||||||
hitNormal.x = tangent[2];
|
hitNormal.x = tangent.z;
|
||||||
hitNormal.y = 0;
|
hitNormal.y = 0;
|
||||||
hitNormal.z = -tangent[0];
|
hitNormal.z = -tangent.x;
|
||||||
vNormalize(ref hitNormal);
|
vNormalize(ref hitNormal);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -216,8 +216,8 @@ namespace DotRecast.Detour
|
||||||
*/
|
*/
|
||||||
public int[] calcTileLoc(Vector3f pos)
|
public int[] calcTileLoc(Vector3f pos)
|
||||||
{
|
{
|
||||||
int tx = (int)Math.Floor((pos[0] - m_orig[0]) / m_tileWidth);
|
int tx = (int)Math.Floor((pos.x - m_orig.x) / m_tileWidth);
|
||||||
int ty = (int)Math.Floor((pos[2] - m_orig[2]) / m_tileHeight);
|
int ty = (int)Math.Floor((pos.z - m_orig.z) / m_tileHeight);
|
||||||
return new int[] { tx, ty };
|
return new int[] { tx, ty };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -327,8 +327,8 @@ namespace DotRecast.Detour
|
||||||
{
|
{
|
||||||
NavMeshParams option = new NavMeshParams();
|
NavMeshParams option = new NavMeshParams();
|
||||||
option.orig = data.header.bmin;
|
option.orig = data.header.bmin;
|
||||||
option.tileWidth = data.header.bmax[0] - data.header.bmin[0];
|
option.tileWidth = data.header.bmax.x - data.header.bmin.x;
|
||||||
option.tileHeight = data.header.bmax[2] - data.header.bmin[2];
|
option.tileHeight = data.header.bmax.z - data.header.bmin.z;
|
||||||
option.maxTiles = 1;
|
option.maxTiles = 1;
|
||||||
option.maxPolys = data.header.polyCount;
|
option.maxPolys = data.header.polyCount;
|
||||||
return option;
|
return option;
|
||||||
|
@ -350,12 +350,12 @@ namespace DotRecast.Detour
|
||||||
int[] bmin = new int[3];
|
int[] bmin = new int[3];
|
||||||
int[] bmax = new int[3];
|
int[] bmax = new int[3];
|
||||||
// dtClamp query box to world box.
|
// dtClamp query box to world box.
|
||||||
float minx = clamp(qmin[0], tbmin[0], tbmax[0]) - tbmin[0];
|
float minx = clamp(qmin.x, tbmin.x, tbmax.x) - tbmin.x;
|
||||||
float miny = clamp(qmin[1], tbmin[1], tbmax[1]) - tbmin[1];
|
float miny = clamp(qmin.y, tbmin.y, tbmax.y) - tbmin.y;
|
||||||
float minz = clamp(qmin[2], tbmin[2], tbmax[2]) - tbmin[2];
|
float minz = clamp(qmin.z, tbmin.z, tbmax.z) - tbmin.z;
|
||||||
float maxx = clamp(qmax[0], tbmin[0], tbmax[0]) - tbmin[0];
|
float maxx = clamp(qmax.x, tbmin.x, tbmax.x) - tbmin.x;
|
||||||
float maxy = clamp(qmax[1], tbmin[1], tbmax[1]) - tbmin[1];
|
float maxy = clamp(qmax.y, tbmin.y, tbmax.y) - tbmin.y;
|
||||||
float maxz = clamp(qmax[2], tbmin[2], tbmax[2]) - tbmin[2];
|
float maxz = clamp(qmax.z, tbmin.z, tbmax.z) - tbmin.z;
|
||||||
// Quantize
|
// Quantize
|
||||||
bmin[0] = (int)(qfac * minx) & 0x7ffffffe;
|
bmin[0] = (int)(qfac * minx) & 0x7ffffffe;
|
||||||
bmin[1] = (int)(qfac * miny) & 0x7ffffffe;
|
bmin[1] = (int)(qfac * miny) & 0x7ffffffe;
|
||||||
|
@ -843,9 +843,9 @@ namespace DotRecast.Detour
|
||||||
|
|
||||||
// Find polygon to connect to.
|
// Find polygon to connect to.
|
||||||
Vector3f p = new Vector3f();
|
Vector3f p = new Vector3f();
|
||||||
p[0] = targetCon.pos[3];
|
p.x = targetCon.pos[3];
|
||||||
p[1] = targetCon.pos[4];
|
p.y = targetCon.pos[4];
|
||||||
p[2] = targetCon.pos[5];
|
p.z = targetCon.pos[5];
|
||||||
FindNearestPolyResult nearest = findNearestPolyInTile(tile, p, ext);
|
FindNearestPolyResult nearest = findNearestPolyInTile(tile, p, ext);
|
||||||
long refs = nearest.getNearestRef();
|
long refs = nearest.getNearestRef();
|
||||||
if (refs == 0)
|
if (refs == 0)
|
||||||
|
@ -857,15 +857,15 @@ namespace DotRecast.Detour
|
||||||
// findNearestPoly may return too optimistic results, further check
|
// findNearestPoly may return too optimistic results, further check
|
||||||
// to make sure.
|
// to make sure.
|
||||||
|
|
||||||
if (sqr(nearestPt[0] - p[0]) + sqr(nearestPt[2] - p[2]) > sqr(targetCon.rad))
|
if (sqr(nearestPt.x - p.x) + sqr(nearestPt.z - p.z) > sqr(targetCon.rad))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make sure the location is on current mesh.
|
// Make sure the location is on current mesh.
|
||||||
target.data.verts[targetPoly.verts[1] * 3] = nearestPt[0];
|
target.data.verts[targetPoly.verts[1] * 3] = nearestPt.x;
|
||||||
target.data.verts[targetPoly.verts[1] * 3 + 1] = nearestPt[1];
|
target.data.verts[targetPoly.verts[1] * 3 + 1] = nearestPt.y;
|
||||||
target.data.verts[targetPoly.verts[1] * 3 + 2] = nearestPt[2];
|
target.data.verts[targetPoly.verts[1] * 3 + 2] = nearestPt.z;
|
||||||
|
|
||||||
// Link off-mesh connection to target poly.
|
// Link off-mesh connection to target poly.
|
||||||
int idx = allocLink(target);
|
int idx = allocLink(target);
|
||||||
|
@ -1087,15 +1087,15 @@ namespace DotRecast.Detour
|
||||||
Vector3f nearestPt = nearestPoly.getNearestPos();
|
Vector3f nearestPt = nearestPoly.getNearestPos();
|
||||||
// findNearestPoly may return too optimistic results, further check
|
// findNearestPoly may return too optimistic results, further check
|
||||||
// to make sure.
|
// to make sure.
|
||||||
if (sqr(nearestPt[0] - p[0]) + sqr(nearestPt[2] - p[2]) > sqr(con.rad))
|
if (sqr(nearestPt.x - p[0]) + sqr(nearestPt.z - p[2]) > sqr(con.rad))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make sure the location is on current mesh.
|
// Make sure the location is on current mesh.
|
||||||
tile.data.verts[poly.verts[0] * 3] = nearestPt[0];
|
tile.data.verts[poly.verts[0] * 3] = nearestPt.x;
|
||||||
tile.data.verts[poly.verts[0] * 3 + 1] = nearestPt[1];
|
tile.data.verts[poly.verts[0] * 3 + 1] = nearestPt.y;
|
||||||
tile.data.verts[poly.verts[0] * 3 + 2] = nearestPt[2];
|
tile.data.verts[poly.verts[0] * 3 + 2] = nearestPt.z;
|
||||||
|
|
||||||
// Link off-mesh connection to target poly.
|
// Link off-mesh connection to target poly.
|
||||||
int idx = allocLink(tile);
|
int idx = allocLink(tile);
|
||||||
|
@ -1206,12 +1206,12 @@ namespace DotRecast.Detour
|
||||||
for (int j = 0; j < poly.vertCount; ++j)
|
for (int j = 0; j < poly.vertCount; ++j)
|
||||||
{
|
{
|
||||||
int k = (j + 1) % poly.vertCount;
|
int k = (j + 1) % poly.vertCount;
|
||||||
v[0][0] = tile.data.verts[poly.verts[j] * 3];
|
v[0].x = tile.data.verts[poly.verts[j] * 3];
|
||||||
v[0][1] = tile.data.verts[poly.verts[j] * 3 + 1];
|
v[0].y = tile.data.verts[poly.verts[j] * 3 + 1];
|
||||||
v[0][2] = tile.data.verts[poly.verts[j] * 3 + 2];
|
v[0].z = tile.data.verts[poly.verts[j] * 3 + 2];
|
||||||
v[1][0] = tile.data.verts[poly.verts[k] * 3];
|
v[1].x = tile.data.verts[poly.verts[k] * 3];
|
||||||
v[1][1] = tile.data.verts[poly.verts[k] * 3 + 1];
|
v[1].y = tile.data.verts[poly.verts[k] * 3 + 1];
|
||||||
v[1][2] = tile.data.verts[poly.verts[k] * 3 + 2];
|
v[1].z = tile.data.verts[poly.verts[k] * 3 + 2];
|
||||||
|
|
||||||
Tuple<float, float> dt = distancePtSegSqr2D(pos, v[0], v[1]);
|
Tuple<float, float> dt = distancePtSegSqr2D(pos, v[0], v[1]);
|
||||||
float d = dt.Item1;
|
float d = dt.Item1;
|
||||||
|
@ -1294,16 +1294,16 @@ namespace DotRecast.Detour
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Vector3f[] v = new Vector3f[3];
|
Vector3f[] v = new Vector3f[3];
|
||||||
v[0][0] = tile.data.verts[poly.verts[0] * 3];
|
v[0].x = tile.data.verts[poly.verts[0] * 3];
|
||||||
v[0][1] = tile.data.verts[poly.verts[0] * 3 + 1];
|
v[0].y = tile.data.verts[poly.verts[0] * 3 + 1];
|
||||||
v[0][2] = tile.data.verts[poly.verts[0] * 3 + 2];
|
v[0].z = tile.data.verts[poly.verts[0] * 3 + 2];
|
||||||
for (int j = 1; j < poly.vertCount - 1; ++j)
|
for (int j = 1; j < poly.vertCount - 1; ++j)
|
||||||
{
|
{
|
||||||
for (int k = 0; k < 2; ++k)
|
for (int k = 0; k < 2; ++k)
|
||||||
{
|
{
|
||||||
v[k + 1][0] = tile.data.verts[poly.verts[j + k] * 3];
|
v[k + 1].x = tile.data.verts[poly.verts[j + k] * 3];
|
||||||
v[k + 1][1] = tile.data.verts[poly.verts[j + k] * 3 + 1];
|
v[k + 1].y = tile.data.verts[poly.verts[j + k] * 3 + 1];
|
||||||
v[k + 1][2] = tile.data.verts[poly.verts[j + k] * 3 + 2];
|
v[k + 1].z = tile.data.verts[poly.verts[j + k] * 3 + 2];
|
||||||
}
|
}
|
||||||
|
|
||||||
float? h = closestHeightPointTriangle(pos, v[0], v[1], v[2]);
|
float? h = closestHeightPointTriangle(pos, v[0], v[1], v[2]);
|
||||||
|
@ -1319,7 +1319,7 @@ namespace DotRecast.Detour
|
||||||
// closest. This should almost never happen so the extra iteration here is
|
// closest. This should almost never happen so the extra iteration here is
|
||||||
// ok.
|
// ok.
|
||||||
var closest = closestPointOnDetailEdges(tile, poly, pos, false);
|
var closest = closestPointOnDetailEdges(tile, poly, pos, false);
|
||||||
return closest[1];
|
return closest.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ClosestPointOnPolyResult closestPointOnPoly(long refs, Vector3f pos)
|
public ClosestPointOnPolyResult closestPointOnPoly(long refs, Vector3f pos)
|
||||||
|
@ -1332,7 +1332,7 @@ namespace DotRecast.Detour
|
||||||
float? h = getPolyHeight(tile, poly, pos);
|
float? h = getPolyHeight(tile, poly, pos);
|
||||||
if (null != h)
|
if (null != h)
|
||||||
{
|
{
|
||||||
closest[1] = h.Value;
|
closest.y = h.Value;
|
||||||
return new ClosestPointOnPolyResult(true, closest);
|
return new ClosestPointOnPolyResult(true, closest);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1377,7 +1377,7 @@ namespace DotRecast.Detour
|
||||||
Vector3f diff = vSub(center, closestPtPoly);
|
Vector3f diff = vSub(center, closestPtPoly);
|
||||||
if (posOverPoly)
|
if (posOverPoly)
|
||||||
{
|
{
|
||||||
d = Math.Abs(diff[1]) - tile.data.header.walkableClimb;
|
d = Math.Abs(diff.y) - tile.data.header.walkableClimb;
|
||||||
d = d > 0 ? d * d : 0;
|
d = d > 0 ? d * d : 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -1748,4 +1748,4 @@ namespace DotRecast.Detour
|
||||||
return tiles;
|
return tiles;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -202,13 +202,13 @@ namespace DotRecast.Detour
|
||||||
}
|
}
|
||||||
|
|
||||||
// BV-tree uses cs for all dimensions
|
// BV-tree uses cs for all dimensions
|
||||||
it.bmin[0] = clamp((int)((bmin[0] - option.bmin[0]) * quantFactor), 0, int.MaxValue);
|
it.bmin[0] = clamp((int)((bmin.x - option.bmin.x) * quantFactor), 0, int.MaxValue);
|
||||||
it.bmin[1] = clamp((int)((bmin[1] - option.bmin[1]) * quantFactor), 0, int.MaxValue);
|
it.bmin[1] = clamp((int)((bmin.y - option.bmin.y) * quantFactor), 0, int.MaxValue);
|
||||||
it.bmin[2] = clamp((int)((bmin[2] - option.bmin[2]) * quantFactor), 0, int.MaxValue);
|
it.bmin[2] = clamp((int)((bmin.z - option.bmin.z) * quantFactor), 0, int.MaxValue);
|
||||||
|
|
||||||
it.bmax[0] = clamp((int)((bmax[0] - option.bmin[0]) * quantFactor), 0, int.MaxValue);
|
it.bmax[0] = clamp((int)((bmax.x - option.bmin.x) * quantFactor), 0, int.MaxValue);
|
||||||
it.bmax[1] = clamp((int)((bmax[1] - option.bmin[1]) * quantFactor), 0, int.MaxValue);
|
it.bmax[1] = clamp((int)((bmax.y - option.bmin.y) * quantFactor), 0, int.MaxValue);
|
||||||
it.bmax[2] = clamp((int)((bmax[2] - option.bmin[2]) * quantFactor), 0, int.MaxValue);
|
it.bmax[2] = clamp((int)((bmax.z - option.bmin.z) * quantFactor), 0, int.MaxValue);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -257,10 +257,10 @@ namespace DotRecast.Detour
|
||||||
public static int classifyOffMeshPoint(VectorPtr pt, Vector3f bmin, Vector3f bmax)
|
public static int classifyOffMeshPoint(VectorPtr pt, Vector3f bmin, Vector3f bmax)
|
||||||
{
|
{
|
||||||
int outcode = 0;
|
int outcode = 0;
|
||||||
outcode |= (pt.get(0) >= bmax[0]) ? XP : 0;
|
outcode |= (pt.get(0) >= bmax.x) ? XP : 0;
|
||||||
outcode |= (pt.get(2) >= bmax[2]) ? ZP : 0;
|
outcode |= (pt.get(2) >= bmax.z) ? ZP : 0;
|
||||||
outcode |= (pt.get(0) < bmin[0]) ? XM : 0;
|
outcode |= (pt.get(0) < bmin.x) ? XM : 0;
|
||||||
outcode |= (pt.get(2) < bmin[2]) ? ZM : 0;
|
outcode |= (pt.get(2) < bmin.z) ? ZM : 0;
|
||||||
|
|
||||||
switch (outcode)
|
switch (outcode)
|
||||||
{
|
{
|
||||||
|
@ -333,7 +333,7 @@ namespace DotRecast.Detour
|
||||||
for (int i = 0; i < option.vertCount; ++i)
|
for (int i = 0; i < option.vertCount; ++i)
|
||||||
{
|
{
|
||||||
int iv = i * 3;
|
int iv = i * 3;
|
||||||
float h = option.bmin[1] + option.verts[iv + 1] * option.ch;
|
float h = option.bmin.y + option.verts[iv + 1] * option.ch;
|
||||||
hmin = Math.Min(hmin, h);
|
hmin = Math.Min(hmin, h);
|
||||||
hmax = Math.Max(hmax, h);
|
hmax = Math.Max(hmax, h);
|
||||||
}
|
}
|
||||||
|
@ -345,8 +345,8 @@ namespace DotRecast.Detour
|
||||||
Vector3f bmax = new Vector3f();
|
Vector3f bmax = new Vector3f();
|
||||||
bmin = option.bmin;
|
bmin = option.bmin;
|
||||||
bmax = option.bmax;
|
bmax = option.bmax;
|
||||||
bmin[1] = hmin;
|
bmin.y = hmin;
|
||||||
bmax[1] = hmax;
|
bmax.y = hmax;
|
||||||
|
|
||||||
for (int i = 0; i < option.offMeshConCount; ++i)
|
for (int i = 0; i < option.offMeshConCount; ++i)
|
||||||
{
|
{
|
||||||
|
@ -360,7 +360,7 @@ namespace DotRecast.Detour
|
||||||
// potentially touching the mesh.
|
// potentially touching the mesh.
|
||||||
if (offMeshConClass[i * 2 + 0] == 0xff)
|
if (offMeshConClass[i * 2 + 0] == 0xff)
|
||||||
{
|
{
|
||||||
if (p0.get(1) < bmin[1] || p0.get(1) > bmax[1])
|
if (p0.get(1) < bmin.y || p0.get(1) > bmax.y)
|
||||||
offMeshConClass[i * 2 + 0] = 0;
|
offMeshConClass[i * 2 + 0] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -489,9 +489,9 @@ namespace DotRecast.Detour
|
||||||
{
|
{
|
||||||
int iv = i * 3;
|
int iv = i * 3;
|
||||||
int v = i * 3;
|
int v = i * 3;
|
||||||
navVerts[v] = option.bmin[0] + option.verts[iv] * option.cs;
|
navVerts[v] = option.bmin.x + option.verts[iv] * option.cs;
|
||||||
navVerts[v + 1] = option.bmin[1] + option.verts[iv + 1] * option.ch;
|
navVerts[v + 1] = option.bmin.y + option.verts[iv + 1] * option.ch;
|
||||||
navVerts[v + 2] = option.bmin[2] + option.verts[iv + 2] * option.cs;
|
navVerts[v + 2] = option.bmin.z + option.verts[iv + 2] * option.cs;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Off-mesh link vertices.
|
// Off-mesh link vertices.
|
||||||
|
@ -674,4 +674,4 @@ namespace DotRecast.Detour
|
||||||
return nmd;
|
return nmd;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -542,7 +542,7 @@ namespace DotRecast.Detour
|
||||||
i = poly.verts[1] * 3;
|
i = poly.verts[1] * 3;
|
||||||
var v1 = new Vector3f { x = tile.data.verts[i], y = tile.data.verts[i + 1], z = tile.data.verts[i + 2] };
|
var v1 = new Vector3f { x = tile.data.verts[i], y = tile.data.verts[i + 1], z = tile.data.verts[i + 2] };
|
||||||
var dt = distancePtSegSqr2D(pos, v0, v1);
|
var dt = distancePtSegSqr2D(pos, v0, v1);
|
||||||
return Results.Success(v0[1] + (v1[1] - v0[1]) * dt.Item2);
|
return Results.Success(v0.y + (v1.y - v0.y) * dt.Item2);
|
||||||
}
|
}
|
||||||
|
|
||||||
float? height = m_nav.getPolyHeight(tile, poly, pos);
|
float? height = m_nav.getPolyHeight(tile, poly, pos);
|
||||||
|
@ -587,12 +587,12 @@ namespace DotRecast.Detour
|
||||||
int[] bmin = new int[3];
|
int[] bmin = new int[3];
|
||||||
int[] bmax = new int[3];
|
int[] bmax = new int[3];
|
||||||
// dtClamp query box to world box.
|
// dtClamp query box to world box.
|
||||||
float minx = clamp(qmin[0], tbmin[0], tbmax[0]) - tbmin[0];
|
float minx = clamp(qmin.x, tbmin.x, tbmax.x) - tbmin.x;
|
||||||
float miny = clamp(qmin[1], tbmin[1], tbmax[1]) - tbmin[1];
|
float miny = clamp(qmin.y, tbmin.y, tbmax.y) - tbmin.y;
|
||||||
float minz = clamp(qmin[2], tbmin[2], tbmax[2]) - tbmin[2];
|
float minz = clamp(qmin.z, tbmin.z, tbmax.z) - tbmin.z;
|
||||||
float maxx = clamp(qmax[0], tbmin[0], tbmax[0]) - tbmin[0];
|
float maxx = clamp(qmax.x, tbmin.x, tbmax.x) - tbmin.x;
|
||||||
float maxy = clamp(qmax[1], tbmin[1], tbmax[1]) - tbmin[1];
|
float maxy = clamp(qmax.y, tbmin.y, tbmax.y) - tbmin.y;
|
||||||
float maxz = clamp(qmax[2], tbmin[2], tbmax[2]) - tbmin[2];
|
float maxz = clamp(qmax.z, tbmin.z, tbmax.z) - tbmin.z;
|
||||||
// Quantize
|
// Quantize
|
||||||
bmin[0] = (int)(qfac * minx) & 0x7ffffffe;
|
bmin[0] = (int)(qfac * minx) & 0x7ffffffe;
|
||||||
bmin[1] = (int)(qfac * miny) & 0x7ffffffe;
|
bmin[1] = (int)(qfac * miny) & 0x7ffffffe;
|
||||||
|
@ -2049,13 +2049,13 @@ namespace DotRecast.Detour
|
||||||
if (fromTile.links[i].refs == to)
|
if (fromTile.links[i].refs == to)
|
||||||
{
|
{
|
||||||
int v = fromTile.links[i].edge;
|
int v = fromTile.links[i].edge;
|
||||||
left[0] = fromTile.data.verts[fromPoly.verts[v] * 3];
|
left.x = fromTile.data.verts[fromPoly.verts[v] * 3];
|
||||||
left[1] = fromTile.data.verts[fromPoly.verts[v] * 3 + 1];
|
left.y = fromTile.data.verts[fromPoly.verts[v] * 3 + 1];
|
||||||
left[2] = fromTile.data.verts[fromPoly.verts[v] * 3 + 2];
|
left.z = fromTile.data.verts[fromPoly.verts[v] * 3 + 2];
|
||||||
|
|
||||||
right[0] = fromTile.data.verts[fromPoly.verts[v] * 3];
|
right.x = fromTile.data.verts[fromPoly.verts[v] * 3];
|
||||||
right[1] = fromTile.data.verts[fromPoly.verts[v] * 3 + 1];
|
right.y = fromTile.data.verts[fromPoly.verts[v] * 3 + 1];
|
||||||
right[2] = fromTile.data.verts[fromPoly.verts[v] * 3 + 2];
|
right.z = fromTile.data.verts[fromPoly.verts[v] * 3 + 2];
|
||||||
return Results.Success(new PortalResult(left, right, fromType, toType));
|
return Results.Success(new PortalResult(left, right, fromType, toType));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2070,13 +2070,13 @@ namespace DotRecast.Detour
|
||||||
if (toTile.links[i].refs == from)
|
if (toTile.links[i].refs == from)
|
||||||
{
|
{
|
||||||
int v = toTile.links[i].edge;
|
int v = toTile.links[i].edge;
|
||||||
left[0] = toTile.data.verts[toPoly.verts[v] * 3];
|
left.x = toTile.data.verts[toPoly.verts[v] * 3];
|
||||||
left[1] = toTile.data.verts[toPoly.verts[v] * 3 + 1];
|
left.y = toTile.data.verts[toPoly.verts[v] * 3 + 1];
|
||||||
left[2] = toTile.data.verts[toPoly.verts[v] * 3 + 2];
|
left.z = toTile.data.verts[toPoly.verts[v] * 3 + 2];
|
||||||
|
|
||||||
right[0] = toTile.data.verts[toPoly.verts[v] * 3];
|
right.x = toTile.data.verts[toPoly.verts[v] * 3];
|
||||||
right[1] = toTile.data.verts[toPoly.verts[v] * 3 + 1];
|
right.y = toTile.data.verts[toPoly.verts[v] * 3 + 1];
|
||||||
right[2] = toTile.data.verts[toPoly.verts[v] * 3 + 2];
|
right.z = toTile.data.verts[toPoly.verts[v] * 3 + 2];
|
||||||
|
|
||||||
return Results.Success(new PortalResult(left, right, fromType, toType));
|
return Results.Success(new PortalResult(left, right, fromType, toType));
|
||||||
}
|
}
|
||||||
|
@ -2088,13 +2088,13 @@ namespace DotRecast.Detour
|
||||||
// Find portal vertices.
|
// Find portal vertices.
|
||||||
int v0 = fromPoly.verts[link.edge];
|
int v0 = fromPoly.verts[link.edge];
|
||||||
int v1 = fromPoly.verts[(link.edge + 1) % fromPoly.vertCount];
|
int v1 = fromPoly.verts[(link.edge + 1) % fromPoly.vertCount];
|
||||||
left[0] = fromTile.data.verts[v0 * 3];
|
left.x = fromTile.data.verts[v0 * 3];
|
||||||
left[1] = fromTile.data.verts[v0 * 3 + 1];
|
left.y = fromTile.data.verts[v0 * 3 + 1];
|
||||||
left[2] = fromTile.data.verts[v0 * 3 + 2];
|
left.z = fromTile.data.verts[v0 * 3 + 2];
|
||||||
|
|
||||||
right[0] = fromTile.data.verts[v1 * 3];
|
right.x = fromTile.data.verts[v1 * 3];
|
||||||
right[1] = fromTile.data.verts[v1 * 3 + 1];
|
right.y = fromTile.data.verts[v1 * 3 + 1];
|
||||||
right[2] = fromTile.data.verts[v1 * 3 + 2];
|
right.z = fromTile.data.verts[v1 * 3 + 2];
|
||||||
|
|
||||||
// If the link is at tile boundary, dtClamp the vertices to
|
// If the link is at tile boundary, dtClamp the vertices to
|
||||||
// the link width.
|
// the link width.
|
||||||
|
@ -2126,9 +2126,9 @@ namespace DotRecast.Detour
|
||||||
var left = ppoints.result.left;
|
var left = ppoints.result.left;
|
||||||
var right = ppoints.result.right;
|
var right = ppoints.result.right;
|
||||||
Vector3f mid = new Vector3f();
|
Vector3f mid = new Vector3f();
|
||||||
mid[0] = (left[0] + right[0]) * 0.5f;
|
mid.x = (left.x + right.x) * 0.5f;
|
||||||
mid[1] = (left[1] + right[1]) * 0.5f;
|
mid.y = (left.y + right.y) * 0.5f;
|
||||||
mid[2] = (left[2] + right[2]) * 0.5f;
|
mid.z = (left.z + right.z) * 0.5f;
|
||||||
return Results.Success(mid);
|
return Results.Success(mid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2355,7 +2355,7 @@ namespace DotRecast.Detour
|
||||||
}
|
}
|
||||||
|
|
||||||
// Find Z intersection.
|
// Find Z intersection.
|
||||||
float z = startPos[2] + (endPos[2] - startPos[2]) * iresult.tmax;
|
float z = startPos.z + (endPos.z - startPos.z) * iresult.tmax;
|
||||||
if (z >= lmin && z <= lmax)
|
if (z >= lmin && z <= lmax)
|
||||||
{
|
{
|
||||||
nextRef = link.refs;
|
nextRef = link.refs;
|
||||||
|
@ -2375,7 +2375,7 @@ namespace DotRecast.Detour
|
||||||
}
|
}
|
||||||
|
|
||||||
// Find X intersection.
|
// Find X intersection.
|
||||||
float x = startPos[0] + (endPos[0] - startPos[0]) * iresult.tmax;
|
float x = startPos.x + (endPos.x - startPos.x) * iresult.tmax;
|
||||||
if (x >= lmin && x <= lmax)
|
if (x >= lmin && x <= lmax)
|
||||||
{
|
{
|
||||||
nextRef = link.refs;
|
nextRef = link.refs;
|
||||||
|
@ -2395,8 +2395,8 @@ namespace DotRecast.Detour
|
||||||
VectorPtr e2 = new VectorPtr(verts, ((iresult.segMax + 1) % nv) * 3);
|
VectorPtr e2 = new VectorPtr(verts, ((iresult.segMax + 1) % nv) * 3);
|
||||||
Vector3f eDir = vSub(e2, e1);
|
Vector3f eDir = vSub(e2, e1);
|
||||||
Vector3f diff = vSub(curPos, e1);
|
Vector3f diff = vSub(curPos, e1);
|
||||||
float s = sqr(eDir[0]) > sqr(eDir[2]) ? diff[0] / eDir[0] : diff[2] / eDir[2];
|
float s = sqr(eDir.x) > sqr(eDir.z) ? diff.x / eDir.x : diff.z / eDir.z;
|
||||||
curPos[1] = e1.get(1) + eDir[1] * s;
|
curPos.y = e1.get(1) + eDir.y * s;
|
||||||
|
|
||||||
hit.pathCost += filter.getCost(lastPos, curPos, prevRef, prevTile, prevPoly, curRef, tile, poly,
|
hit.pathCost += filter.getCost(lastPos, curPos, prevRef, prevTile, prevPoly, curRef, tile, poly,
|
||||||
nextRef, nextTile, nextPoly);
|
nextRef, nextTile, nextPoly);
|
||||||
|
@ -2413,9 +2413,9 @@ namespace DotRecast.Detour
|
||||||
int vb = b * 3;
|
int vb = b * 3;
|
||||||
float dx = verts[vb] - verts[va];
|
float dx = verts[vb] - verts[va];
|
||||||
float dz = verts[vb + 2] - verts[va + 2];
|
float dz = verts[vb + 2] - verts[va + 2];
|
||||||
hit.hitNormal[0] = dz;
|
hit.hitNormal.x = dz;
|
||||||
hit.hitNormal[1] = 0;
|
hit.hitNormal.y = 0;
|
||||||
hit.hitNormal[2] = -dx;
|
hit.hitNormal.z = -dx;
|
||||||
vNormalize(ref hit.hitNormal);
|
vNormalize(ref hit.hitNormal);
|
||||||
return Results.Success(hit);
|
return Results.Success(hit);
|
||||||
}
|
}
|
||||||
|
@ -2673,15 +2673,15 @@ namespace DotRecast.Detour
|
||||||
Vector3f centerPos = Vector3f.Zero;
|
Vector3f centerPos = Vector3f.Zero;
|
||||||
for (int i = 0; i < nverts; ++i)
|
for (int i = 0; i < nverts; ++i)
|
||||||
{
|
{
|
||||||
centerPos[0] += verts[i * 3];
|
centerPos.x += verts[i * 3];
|
||||||
centerPos[1] += verts[i * 3 + 1];
|
centerPos.y += verts[i * 3 + 1];
|
||||||
centerPos[2] += verts[i * 3 + 2];
|
centerPos.z += verts[i * 3 + 2];
|
||||||
}
|
}
|
||||||
|
|
||||||
float scale = 1.0f / nverts;
|
float scale = 1.0f / nverts;
|
||||||
centerPos[0] *= scale;
|
centerPos.x *= scale;
|
||||||
centerPos[1] *= scale;
|
centerPos.y *= scale;
|
||||||
centerPos[2] *= scale;
|
centerPos.z *= scale;
|
||||||
|
|
||||||
Node startNode = m_nodePool.getNode(startRef);
|
Node startNode = m_nodePool.getNode(startRef);
|
||||||
startNode.pos = centerPos;
|
startNode.pos = centerPos;
|
||||||
|
@ -3303,10 +3303,10 @@ namespace DotRecast.Detour
|
||||||
// Hit wall, update radius.
|
// Hit wall, update radius.
|
||||||
radiusSqr = distSqr;
|
radiusSqr = distSqr;
|
||||||
// Calculate hit pos.
|
// Calculate hit pos.
|
||||||
hitPos[0] = bestTile.data.verts[vj] + (bestTile.data.verts[vi] - bestTile.data.verts[vj]) * tseg;
|
hitPos.x = bestTile.data.verts[vj] + (bestTile.data.verts[vi] - bestTile.data.verts[vj]) * tseg;
|
||||||
hitPos[1] = bestTile.data.verts[vj + 1]
|
hitPos.y = bestTile.data.verts[vj + 1]
|
||||||
+ (bestTile.data.verts[vi + 1] - bestTile.data.verts[vj + 1]) * tseg;
|
+ (bestTile.data.verts[vi + 1] - bestTile.data.verts[vj + 1]) * tseg;
|
||||||
hitPos[2] = bestTile.data.verts[vj + 2]
|
hitPos.z = bestTile.data.verts[vj + 2]
|
||||||
+ (bestTile.data.verts[vi + 2] - bestTile.data.verts[vj + 2]) * tseg;
|
+ (bestTile.data.verts[vi + 2] - bestTile.data.verts[vj + 2]) * tseg;
|
||||||
bestvj = new VectorPtr(bestTile.data.verts, vj);
|
bestvj = new VectorPtr(bestTile.data.verts, vj);
|
||||||
bestvi = new VectorPtr(bestTile.data.verts, vi);
|
bestvi = new VectorPtr(bestTile.data.verts, vi);
|
||||||
|
@ -3397,9 +3397,9 @@ namespace DotRecast.Detour
|
||||||
if (bestvi != null && bestvj != null)
|
if (bestvi != null && bestvj != null)
|
||||||
{
|
{
|
||||||
var tangent = vSub(bestvi, bestvj);
|
var tangent = vSub(bestvi, bestvj);
|
||||||
hitNormal[0] = tangent[2];
|
hitNormal.x = tangent.z;
|
||||||
hitNormal[1] = 0;
|
hitNormal.y = 0;
|
||||||
hitNormal[2] = -tangent[0];
|
hitNormal.z = -tangent.x;
|
||||||
vNormalize(ref hitNormal);
|
vNormalize(ref hitNormal);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3523,4 +3523,4 @@ namespace DotRecast.Detour
|
||||||
return m_nodePool;
|
return m_nodePool;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,15 +67,15 @@ namespace DotRecast.Detour
|
||||||
int v = tile.data.detailTris[t + k];
|
int v = tile.data.detailTris[t + k];
|
||||||
if (v < p.vertCount)
|
if (v < p.vertCount)
|
||||||
{
|
{
|
||||||
verts[k][0] = tile.data.verts[p.verts[v] * 3];
|
verts[k].x = tile.data.verts[p.verts[v] * 3];
|
||||||
verts[k][1] = tile.data.verts[p.verts[v] * 3 + 1];
|
verts[k].y = tile.data.verts[p.verts[v] * 3 + 1];
|
||||||
verts[k][2] = tile.data.verts[p.verts[v] * 3 + 2];
|
verts[k].z = tile.data.verts[p.verts[v] * 3 + 2];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
verts[k][0] = tile.data.detailVerts[(pd.vertBase + v - p.vertCount) * 3];
|
verts[k].x = tile.data.detailVerts[(pd.vertBase + v - p.vertCount) * 3];
|
||||||
verts[k][1] = tile.data.detailVerts[(pd.vertBase + v - p.vertCount) * 3 + 1];
|
verts[k].y = tile.data.detailVerts[(pd.vertBase + v - p.vertCount) * 3 + 1];
|
||||||
verts[k][2] = tile.data.detailVerts[(pd.vertBase + v - p.vertCount) * 3 + 2];
|
verts[k].z = tile.data.detailVerts[(pd.vertBase + v - p.vertCount) * 3 + 2];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -95,4 +95,4 @@ namespace DotRecast.Detour
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,12 +35,12 @@ namespace DotRecast.Detour
|
||||||
{
|
{
|
||||||
for (int i = 0; i < tile.data.verts.Length; i += 3)
|
for (int i = 0; i < tile.data.verts.Length; i += 3)
|
||||||
{
|
{
|
||||||
bmin.x = Math.Min(bmin[0], tile.data.verts[i]);
|
bmin.x = Math.Min(bmin.x, tile.data.verts[i]);
|
||||||
bmin.y = Math.Min(bmin[1], tile.data.verts[i + 1]);
|
bmin.y = Math.Min(bmin.y, tile.data.verts[i + 1]);
|
||||||
bmin.z = Math.Min(bmin[2], tile.data.verts[i + 2]);
|
bmin.z = Math.Min(bmin.z, tile.data.verts[i + 2]);
|
||||||
bmax.x = Math.Max(bmax[0], tile.data.verts[i]);
|
bmax.x = Math.Max(bmax.x, tile.data.verts[i]);
|
||||||
bmax.y = Math.Max(bmax[1], tile.data.verts[i + 1]);
|
bmax.y = Math.Max(bmax.y, tile.data.verts[i + 1]);
|
||||||
bmax.z = Math.Max(bmax[2], tile.data.verts[i + 2]);
|
bmax.z = Math.Max(bmax.z, tile.data.verts[i + 2]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -117,4 +117,4 @@ namespace DotRecast.Detour
|
||||||
return m_map;
|
return m_map;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,9 +44,9 @@ namespace DotRecast.Detour
|
||||||
float[] steerPoints = new float[straightPath.Count * 3];
|
float[] steerPoints = new float[straightPath.Count * 3];
|
||||||
for (int i = 0; i < straightPath.Count; i++)
|
for (int i = 0; i < straightPath.Count; i++)
|
||||||
{
|
{
|
||||||
steerPoints[i * 3] = straightPath[i].getPos()[0];
|
steerPoints[i * 3] = straightPath[i].getPos().x;
|
||||||
steerPoints[i * 3 + 1] = straightPath[i].getPos()[1];
|
steerPoints[i * 3 + 1] = straightPath[i].getPos().y;
|
||||||
steerPoints[i * 3 + 2] = straightPath[i].getPos()[2];
|
steerPoints[i * 3 + 2] = straightPath[i].getPos().z;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Find vertex far enough to steer to.
|
// Find vertex far enough to steer to.
|
||||||
|
@ -65,9 +65,9 @@ namespace DotRecast.Detour
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
Vector3f steerPos = Vector3f.Of(
|
Vector3f steerPos = Vector3f.Of(
|
||||||
straightPath[ns].getPos()[0],
|
straightPath[ns].getPos().x,
|
||||||
startPos[1],
|
startPos.y,
|
||||||
straightPath[ns].getPos()[2]
|
straightPath[ns].getPos().z
|
||||||
);
|
);
|
||||||
int steerPosFlag = straightPath[ns].getFlags();
|
int steerPosFlag = straightPath[ns].getFlags();
|
||||||
long steerPosRef = straightPath[ns].getRef();
|
long steerPosRef = straightPath[ns].getRef();
|
||||||
|
@ -78,9 +78,9 @@ namespace DotRecast.Detour
|
||||||
|
|
||||||
public static bool inRange(Vector3f v1, Vector3f v2, float r, float h)
|
public static bool inRange(Vector3f v1, Vector3f v2, float r, float h)
|
||||||
{
|
{
|
||||||
float dx = v2[0] - v1[0];
|
float dx = v2.x - v1.x;
|
||||||
float dy = v2[1] - v1[1];
|
float dy = v2.y - v1.y;
|
||||||
float dz = v2[2] - v1[2];
|
float dz = v2.z - v1.z;
|
||||||
return (dx * dx + dz * dz) < r * r && Math.Abs(dy) < h;
|
return (dx * dx + dz * dz) < r * r && Math.Abs(dy) < h;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -198,4 +198,4 @@ namespace DotRecast.Detour
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -100,9 +100,9 @@ namespace DotRecast.Detour
|
||||||
float[] circle = new float[12 * 3];
|
float[] circle = new float[12 * 3];
|
||||||
for (int i = 0; i < CIRCLE_SEGMENTS * 3; i += 3)
|
for (int i = 0; i < CIRCLE_SEGMENTS * 3; i += 3)
|
||||||
{
|
{
|
||||||
circle[i] = unitCircle[i] * radius + center[0];
|
circle[i] = unitCircle[i] * radius + center.x;
|
||||||
circle[i + 1] = center[1];
|
circle[i + 1] = center.y;
|
||||||
circle[i + 2] = unitCircle[i + 2] * radius + center[2];
|
circle[i + 2] = unitCircle[i + 2] * radius + center.z;
|
||||||
}
|
}
|
||||||
|
|
||||||
return circle;
|
return circle;
|
||||||
|
|
Loading…
Reference in New Issue