forked from mirror/DotRecast
remove tuple<float, float> 1st
This commit is contained in:
parent
5f20b565b1
commit
11f023969f
|
@ -0,0 +1,8 @@
|
|||
namespace DotRecast.Core
|
||||
{
|
||||
public struct DistSeg
|
||||
{
|
||||
public float DistSqr;
|
||||
public float Seg;
|
||||
}
|
||||
}
|
|
@ -239,9 +239,9 @@ namespace DotRecast.Core
|
|||
c = !c;
|
||||
}
|
||||
|
||||
Tuple<float, float> edet = DistancePtSegSqr2D(pt, verts, vj, vi);
|
||||
ed[j] = edet.Item1;
|
||||
et[j] = edet.Item2;
|
||||
var edet = DistancePtSegSqr2D(pt, verts, vj, vi);
|
||||
ed[j] = edet.DistSqr;
|
||||
et[j] = edet.Seg;
|
||||
}
|
||||
|
||||
return c;
|
||||
|
@ -482,7 +482,7 @@ namespace DotRecast.Core
|
|||
}
|
||||
|
||||
|
||||
public static Tuple<float, float> DistancePtSegSqr2D(Vector3f pt, float[] verts, int p, int q)
|
||||
public static DistSeg DistancePtSegSqr2D(Vector3f pt, float[] verts, int p, int q)
|
||||
{
|
||||
float pqx = verts[q + 0] - verts[p + 0];
|
||||
float pqz = verts[q + 2] - verts[p + 2];
|
||||
|
@ -506,7 +506,12 @@ namespace DotRecast.Core
|
|||
|
||||
dx = verts[p + 0] + t * pqx - pt.x;
|
||||
dz = verts[p + 2] + t * pqz - pt.z;
|
||||
return Tuple.Create(dx * dx + dz * dz, t);
|
||||
|
||||
return new DistSeg()
|
||||
{
|
||||
DistSqr = dx * dx + dz * dz,
|
||||
Seg = t,
|
||||
};
|
||||
}
|
||||
|
||||
public static int OppositeTile(int side)
|
||||
|
|
|
@ -738,9 +738,9 @@ namespace DotRecast.Detour
|
|||
// Calc distance to the edge.
|
||||
int vj = bestPoly.verts[j] * 3;
|
||||
int vi = bestPoly.verts[i] * 3;
|
||||
Tuple<float, float> distseg = DistancePtSegSqr2D(centerPos, bestTile.data.verts, vj, vi);
|
||||
float distSqr = distseg.Item1;
|
||||
float tseg = distseg.Item2;
|
||||
var distseg = DistancePtSegSqr2D(centerPos, bestTile.data.verts, vj, vi);
|
||||
float distSqr = distseg.DistSqr;
|
||||
float tseg = distseg.Seg;
|
||||
|
||||
// Edge is too far, skip.
|
||||
if (distSqr > radiusSqr)
|
||||
|
@ -784,8 +784,8 @@ namespace DotRecast.Detour
|
|||
// Calc distance to the edge.
|
||||
int va = bestPoly.verts[link.edge] * 3;
|
||||
int vb = bestPoly.verts[(link.edge + 1) % bestPoly.vertCount] * 3;
|
||||
Tuple<float, float> distseg = DistancePtSegSqr2D(centerPos, bestTile.data.verts, va, vb);
|
||||
float distSqr = distseg.Item1;
|
||||
var distseg = DistancePtSegSqr2D(centerPos, bestTile.data.verts, va, vb);
|
||||
float distSqr = distseg.DistSqr;
|
||||
// If the circle is not touching the next polygon, skip it.
|
||||
if (distSqr > radiusSqr)
|
||||
{
|
||||
|
|
|
@ -1906,9 +1906,9 @@ namespace DotRecast.Detour
|
|||
// Wall edge, calc distance.
|
||||
int vj = j * 3;
|
||||
int vi = i * 3;
|
||||
Tuple<float, float> distSeg = DistancePtSegSqr2D(endPos, verts, vj, vi);
|
||||
float distSqr = distSeg.Item1;
|
||||
float tseg = distSeg.Item2;
|
||||
var distSeg = DistancePtSegSqr2D(endPos, verts, vj, vi);
|
||||
float distSqr = distSeg.DistSqr;
|
||||
float tseg = distSeg.Seg;
|
||||
if (distSqr < bestDist)
|
||||
{
|
||||
// Update nearest distance.
|
||||
|
@ -1932,8 +1932,8 @@ namespace DotRecast.Detour
|
|||
// TODO: Maybe should use GetPortalPoints(), but this one is way faster.
|
||||
int vj = j * 3;
|
||||
int vi = i * 3;
|
||||
Tuple<float, float> distseg = DistancePtSegSqr2D(searchPos, verts, vj, vi);
|
||||
float distSqr = distseg.Item1;
|
||||
var distseg = DistancePtSegSqr2D(searchPos, verts, vj, vi);
|
||||
float distSqr = distseg.DistSqr;
|
||||
if (distSqr > searchRadSqr)
|
||||
{
|
||||
continue;
|
||||
|
@ -3261,9 +3261,9 @@ namespace DotRecast.Detour
|
|||
// Calc distance to the edge.
|
||||
int vj = bestPoly.verts[j] * 3;
|
||||
int vi = bestPoly.verts[i] * 3;
|
||||
Tuple<float, float> distseg = DistancePtSegSqr2D(centerPos, bestTile.data.verts, vj, vi);
|
||||
float distSqr = distseg.Item1;
|
||||
float tseg = distseg.Item2;
|
||||
var distseg = DistancePtSegSqr2D(centerPos, bestTile.data.verts, vj, vi);
|
||||
float distSqr = distseg.DistSqr;
|
||||
float tseg = distseg.Seg;
|
||||
|
||||
// Edge is too far, skip.
|
||||
if (distSqr > radiusSqr)
|
||||
|
@ -3307,8 +3307,8 @@ namespace DotRecast.Detour
|
|||
// Calc distance to the edge.
|
||||
int va = bestPoly.verts[link.edge] * 3;
|
||||
int vb = bestPoly.verts[(link.edge + 1) % bestPoly.vertCount] * 3;
|
||||
Tuple<float, float> distseg = DistancePtSegSqr2D(centerPos, bestTile.data.verts, va, vb);
|
||||
float distSqr = distseg.Item1;
|
||||
var distseg = DistancePtSegSqr2D(centerPos, bestTile.data.verts, va, vb);
|
||||
float distSqr = distseg.DistSqr;
|
||||
// If the circle is not touching the next polygon, skip it.
|
||||
if (distSqr > radiusSqr)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue