forked from mirror/DotRecast
fix - new float[3] -> Vector3f
This commit is contained in:
parent
c86b30a35a
commit
f157ee53e2
|
@ -135,13 +135,13 @@ namespace DotRecast.Core
|
||||||
/// @param[in] v1 The starting vector.
|
/// @param[in] v1 The starting vector.
|
||||||
/// @param[in] v2 The destination vector.
|
/// @param[in] v2 The destination vector.
|
||||||
/// @param[in] t The interpolation factor. [Limits: 0 <= value <= 1.0]
|
/// @param[in] t The interpolation factor. [Limits: 0 <= value <= 1.0]
|
||||||
public static float[] vLerp(float[] verts, int v1, int v2, float t)
|
public static Vector3f vLerp(float[] verts, int v1, int v2, float t)
|
||||||
{
|
{
|
||||||
Vector3f dest = new Vector3f();
|
Vector3f dest = new Vector3f();
|
||||||
dest[0] = verts[v1 + 0] + (verts[v2 + 0] - verts[v1 + 0]) * t;
|
dest[0] = verts[v1 + 0] + (verts[v2 + 0] - verts[v1 + 0]) * t;
|
||||||
dest[1] = verts[v1 + 1] + (verts[v2 + 1] - verts[v1 + 1]) * t;
|
dest[1] = verts[v1 + 1] + (verts[v2 + 1] - verts[v1 + 1]) * t;
|
||||||
dest[2] = verts[v1 + 2] + (verts[v2 + 2] - verts[v1 + 2]) * t;
|
dest[2] = verts[v1 + 2] + (verts[v2 + 2] - verts[v1 + 2]) * t;
|
||||||
return dest.ToArray();
|
return dest;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Vector3f vLerp(Vector3f v1, Vector3f v2, float t)
|
public static Vector3f vLerp(Vector3f v1, Vector3f v2, float t)
|
||||||
|
|
|
@ -519,7 +519,7 @@ namespace DotRecast.Detour
|
||||||
|
|
||||||
int va = imin * 3;
|
int va = imin * 3;
|
||||||
int vb = ((imin + 1) % nv) * 3;
|
int vb = ((imin + 1) % nv) * 3;
|
||||||
closest = Vector3f.Of(vLerp(verts, va, vb, edget[imin]));
|
closest = vLerp(verts, va, vb, edget[imin]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Results.success(closest);
|
return Results.success(closest);
|
||||||
|
@ -1566,7 +1566,7 @@ namespace DotRecast.Detour
|
||||||
{
|
{
|
||||||
List<StraightPathItem> straightPath = new List<StraightPathItem>();
|
List<StraightPathItem> straightPath = new List<StraightPathItem>();
|
||||||
if (!vIsFinite(startPos) || !vIsFinite(endPos)
|
if (!vIsFinite(startPos) || !vIsFinite(endPos)
|
||||||
|| null == path || 0 == path.Count || path[0] == 0 || maxStraightPath <= 0)
|
|| null == path || 0 == path.Count || path[0] == 0 || maxStraightPath <= 0)
|
||||||
{
|
{
|
||||||
return Results.invalidParam<List<StraightPathItem>>();
|
return Results.invalidParam<List<StraightPathItem>>();
|
||||||
}
|
}
|
||||||
|
@ -1823,7 +1823,7 @@ namespace DotRecast.Detour
|
||||||
{
|
{
|
||||||
// Validate input
|
// Validate input
|
||||||
if (!m_nav.isValidPolyRef(startRef) || !vIsFinite(startPos)
|
if (!m_nav.isValidPolyRef(startRef) || !vIsFinite(startPos)
|
||||||
|| !vIsFinite(endPos) || null == filter)
|
|| !vIsFinite(endPos) || null == filter)
|
||||||
{
|
{
|
||||||
return Results.invalidParam<MoveAlongSurfaceResult>();
|
return Results.invalidParam<MoveAlongSurfaceResult>();
|
||||||
}
|
}
|
||||||
|
@ -1932,7 +1932,7 @@ namespace DotRecast.Detour
|
||||||
if (distSqr < bestDist)
|
if (distSqr < bestDist)
|
||||||
{
|
{
|
||||||
// Update nearest distance.
|
// Update nearest distance.
|
||||||
bestPos = Vector3f.Of(vLerp(verts, vj, vi, tseg));
|
bestPos = vLerp(verts, vj, vi, tseg);
|
||||||
bestDist = distSqr;
|
bestDist = distSqr;
|
||||||
bestNode = curNode;
|
bestNode = curNode;
|
||||||
}
|
}
|
||||||
|
@ -2125,8 +2125,8 @@ namespace DotRecast.Detour
|
||||||
float s = 1.0f / 255.0f;
|
float s = 1.0f / 255.0f;
|
||||||
float tmin = link.bmin * s;
|
float tmin = link.bmin * s;
|
||||||
float tmax = link.bmax * s;
|
float tmax = link.bmax * s;
|
||||||
left = Vector3f.Of(vLerp(fromTile.data.verts, v0 * 3, v1 * 3, tmin));
|
left = vLerp(fromTile.data.verts, v0 * 3, v1 * 3, tmin);
|
||||||
right = Vector3f.Of(vLerp(fromTile.data.verts, v0 * 3, v1 * 3, tmax));
|
right = vLerp(fromTile.data.verts, v0 * 3, v1 * 3, tmax);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3172,8 +3172,14 @@ namespace DotRecast.Detour
|
||||||
float tmin = ints[k].tmin / 255.0f;
|
float tmin = ints[k].tmin / 255.0f;
|
||||||
float tmax = ints[k].tmax / 255.0f;
|
float tmax = ints[k].tmax / 255.0f;
|
||||||
float[] seg = new float[6];
|
float[] seg = new float[6];
|
||||||
Array.Copy(vLerp(tile.data.verts, vj, vi, tmin), 0, seg, 0, 3);
|
var vmin = vLerp(tile.data.verts, vj, vi, tmin);
|
||||||
Array.Copy(vLerp(tile.data.verts, vj, vi, tmax), 0, seg, 3, 3);
|
var vmax = vLerp(tile.data.verts, vj, vi, tmax);
|
||||||
|
seg[0] = vmin[0];
|
||||||
|
seg[1] = vmin[1];
|
||||||
|
seg[2] = vmin[2];
|
||||||
|
seg[3] = vmax[0];
|
||||||
|
seg[4] = vmax[1];
|
||||||
|
seg[5] = vmax[2];
|
||||||
segmentVerts.Add(seg);
|
segmentVerts.Add(seg);
|
||||||
segmentRefs.Add(ints[k].refs);
|
segmentRefs.Add(ints[k].refs);
|
||||||
}
|
}
|
||||||
|
@ -3186,8 +3192,14 @@ namespace DotRecast.Detour
|
||||||
float tmin = imin / 255.0f;
|
float tmin = imin / 255.0f;
|
||||||
float tmax = imax / 255.0f;
|
float tmax = imax / 255.0f;
|
||||||
float[] seg = new float[6];
|
float[] seg = new float[6];
|
||||||
Array.Copy(vLerp(tile.data.verts, vj, vi, tmin), 0, seg, 0, 3);
|
var vmin = vLerp(tile.data.verts, vj, vi, tmin);
|
||||||
Array.Copy(vLerp(tile.data.verts, vj, vi, tmax), 0, seg, 3, 3);
|
var vmax = vLerp(tile.data.verts, vj, vi, tmax);
|
||||||
|
seg[0] = vmin[0];
|
||||||
|
seg[1] = vmin[1];
|
||||||
|
seg[2] = vmin[2];
|
||||||
|
seg[3] = vmax[0];
|
||||||
|
seg[4] = vmax[1];
|
||||||
|
seg[5] = vmax[2];
|
||||||
segmentVerts.Add(seg);
|
segmentVerts.Add(seg);
|
||||||
segmentRefs.Add(0L);
|
segmentRefs.Add(0L);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue