fix - new float[3] -> Vector3f

This commit is contained in:
ikpil 2023-04-12 23:22:11 +09:00
parent c86b30a35a
commit f157ee53e2
2 changed files with 24 additions and 12 deletions

View File

@ -135,13 +135,13 @@ namespace DotRecast.Core
/// @param[in] v1 The starting vector.
/// @param[in] v2 The destination vector.
/// @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();
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[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)

View File

@ -519,7 +519,7 @@ namespace DotRecast.Detour
int va = imin * 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);
@ -1932,7 +1932,7 @@ namespace DotRecast.Detour
if (distSqr < bestDist)
{
// Update nearest distance.
bestPos = Vector3f.Of(vLerp(verts, vj, vi, tseg));
bestPos = vLerp(verts, vj, vi, tseg);
bestDist = distSqr;
bestNode = curNode;
}
@ -2125,8 +2125,8 @@ namespace DotRecast.Detour
float s = 1.0f / 255.0f;
float tmin = link.bmin * s;
float tmax = link.bmax * s;
left = Vector3f.Of(vLerp(fromTile.data.verts, v0 * 3, v1 * 3, tmin));
right = Vector3f.Of(vLerp(fromTile.data.verts, v0 * 3, v1 * 3, tmax));
left = vLerp(fromTile.data.verts, v0 * 3, v1 * 3, tmin);
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 tmax = ints[k].tmax / 255.0f;
float[] seg = new float[6];
Array.Copy(vLerp(tile.data.verts, vj, vi, tmin), 0, seg, 0, 3);
Array.Copy(vLerp(tile.data.verts, vj, vi, tmax), 0, seg, 3, 3);
var vmin = vLerp(tile.data.verts, vj, vi, tmin);
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);
segmentRefs.Add(ints[k].refs);
}
@ -3186,8 +3192,14 @@ namespace DotRecast.Detour
float tmin = imin / 255.0f;
float tmax = imax / 255.0f;
float[] seg = new float[6];
Array.Copy(vLerp(tile.data.verts, vj, vi, tmin), 0, seg, 0, 3);
Array.Copy(vLerp(tile.data.verts, vj, vi, tmax), 0, seg, 3, 3);
var vmin = vLerp(tile.data.verts, vj, vi, tmin);
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);
segmentRefs.Add(0L);
}