forked from mirror/DotRecast
parent
daf552b4b7
commit
9e9a3f0dc2
|
@ -14,7 +14,7 @@ namespace DotRecast.Core.Numerics
|
||||||
}
|
}
|
||||||
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public static RcVec3f Create(float[] values, int n)
|
public static RcVec3f Create(Span<float> values, int n)
|
||||||
{
|
{
|
||||||
return new RcVec3f(values[n + 0], values[n + 1], values[n + 2]);
|
return new RcVec3f(values[n + 0], values[n + 1], values[n + 2]);
|
||||||
}
|
}
|
||||||
|
@ -63,7 +63,7 @@ namespace DotRecast.Core.Numerics
|
||||||
}
|
}
|
||||||
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public static float Dot2D(this RcVec3f @this, float[] v, int vi)
|
public static float Dot2D(this RcVec3f @this, Span<float> v, int vi)
|
||||||
{
|
{
|
||||||
return @this.X * v[vi] +
|
return @this.X * v[vi] +
|
||||||
@this.Z * v[vi + 2];
|
@this.Z * v[vi + 2];
|
||||||
|
@ -262,7 +262,7 @@ namespace DotRecast.Core.Numerics
|
||||||
/// @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]
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public static RcVec3f Lerp(float[] verts, int v1, int v2, float t)
|
public static RcVec3f Lerp(Span<float> verts, int v1, int v2, float t)
|
||||||
{
|
{
|
||||||
return new RcVec3f(
|
return new RcVec3f(
|
||||||
verts[v1 + 0] + (verts[v2 + 0] - verts[v1 + 0]) * t,
|
verts[v1 + 0] + (verts[v2 + 0] - verts[v1 + 0]) * t,
|
||||||
|
|
|
@ -457,13 +457,13 @@ namespace DotRecast.Detour
|
||||||
}
|
}
|
||||||
|
|
||||||
// Collect vertices.
|
// Collect vertices.
|
||||||
float[] verts = new float[m_nav.GetMaxVertsPerPoly() * 3];
|
Span<float> verts = stackalloc float[m_nav.GetMaxVertsPerPoly() * 3];
|
||||||
float[] edged = new float[m_nav.GetMaxVertsPerPoly()];
|
Span<float> edged = stackalloc float[m_nav.GetMaxVertsPerPoly()];
|
||||||
float[] edget = new float[m_nav.GetMaxVertsPerPoly()];
|
Span<float> edget = stackalloc float[m_nav.GetMaxVertsPerPoly()];
|
||||||
int nv = poly.vertCount;
|
int nv = poly.vertCount;
|
||||||
for (int i = 0; i < nv; ++i)
|
for (int i = 0; i < nv; ++i)
|
||||||
{
|
{
|
||||||
RcArrays.Copy(tile.data.verts, poly.verts[i] * 3, verts, i * 3, 3);
|
RcSpans.Copy(tile.data.verts, poly.verts[i] * 3, verts, i * 3, 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DtUtils.DistancePtPolyEdgesSqr(pos, verts, nv, edged, edget))
|
if (DtUtils.DistancePtPolyEdgesSqr(pos, verts, nv, edged, edget))
|
||||||
|
@ -1822,7 +1822,7 @@ namespace DotRecast.Detour
|
||||||
var searchPos = RcVec3f.Lerp(startPos, endPos, 0.5f);
|
var searchPos = RcVec3f.Lerp(startPos, endPos, 0.5f);
|
||||||
float searchRadSqr = RcMath.Sqr(RcVec3f.Distance(startPos, endPos) / 2.0f + 0.001f);
|
float searchRadSqr = RcMath.Sqr(RcVec3f.Distance(startPos, endPos) / 2.0f + 0.001f);
|
||||||
|
|
||||||
float[] verts = new float[m_nav.GetMaxVertsPerPoly() * 3];
|
Span<float> verts = stackalloc float[m_nav.GetMaxVertsPerPoly() * 3];
|
||||||
|
|
||||||
const int MAX_NEIS = 8;
|
const int MAX_NEIS = 8;
|
||||||
Span<long> neis = stackalloc long[MAX_NEIS];
|
Span<long> neis = stackalloc long[MAX_NEIS];
|
||||||
|
@ -1842,7 +1842,7 @@ namespace DotRecast.Detour
|
||||||
int nverts = curPoly.vertCount;
|
int nverts = curPoly.vertCount;
|
||||||
for (int i = 0; i < nverts; ++i)
|
for (int i = 0; i < nverts; ++i)
|
||||||
{
|
{
|
||||||
RcArrays.Copy(curTile.data.verts, curPoly.verts[i] * 3, verts, i * 3, 3);
|
RcSpans.Copy(curTile.data.verts, curPoly.verts[i] * 3, verts, i * 3, 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
// If target is inside the poly, stop search.
|
// If target is inside the poly, stop search.
|
||||||
|
@ -2874,8 +2874,8 @@ namespace DotRecast.Detour
|
||||||
|
|
||||||
float radiusSqr = RcMath.Sqr(radius);
|
float radiusSqr = RcMath.Sqr(radius);
|
||||||
|
|
||||||
float[] pa = new float[m_nav.GetMaxVertsPerPoly() * 3];
|
Span<float> pa = stackalloc float[m_nav.GetMaxVertsPerPoly() * 3];
|
||||||
float[] pb = new float[m_nav.GetMaxVertsPerPoly() * 3];
|
Span<float> pb = stackalloc float[m_nav.GetMaxVertsPerPoly() * 3];
|
||||||
|
|
||||||
while (0 < stack.Count)
|
while (0 < stack.Count)
|
||||||
{
|
{
|
||||||
|
@ -2946,7 +2946,7 @@ namespace DotRecast.Detour
|
||||||
int npa = neighbourPoly.vertCount;
|
int npa = neighbourPoly.vertCount;
|
||||||
for (int k = 0; k < npa; ++k)
|
for (int k = 0; k < npa; ++k)
|
||||||
{
|
{
|
||||||
RcArrays.Copy(neighbourTile.data.verts, neighbourPoly.verts[k] * 3, pa, k * 3, 3);
|
RcSpans.Copy(neighbourTile.data.verts, neighbourPoly.verts[k] * 3, pa, k * 3, 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool overlap = false;
|
bool overlap = false;
|
||||||
|
@ -2977,7 +2977,7 @@ namespace DotRecast.Detour
|
||||||
int npb = pastPoly.vertCount;
|
int npb = pastPoly.vertCount;
|
||||||
for (int k = 0; k < npb; ++k)
|
for (int k = 0; k < npb; ++k)
|
||||||
{
|
{
|
||||||
RcArrays.Copy(pastTile.data.verts, pastPoly.verts[k] * 3, pb, k * 3, 3);
|
RcSpans.Copy(pastTile.data.verts, pastPoly.verts[k] * 3, pb, k * 3, 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DtUtils.OverlapPolyPoly2D(pa, npa, pb, npb))
|
if (DtUtils.OverlapPolyPoly2D(pa, npa, pb, npb))
|
||||||
|
|
|
@ -97,7 +97,7 @@ namespace DotRecast.Detour
|
||||||
/// @par
|
/// @par
|
||||||
///
|
///
|
||||||
/// All vertices are projected onto the xz-plane, so the y-values are ignored.
|
/// All vertices are projected onto the xz-plane, so the y-values are ignored.
|
||||||
public static bool OverlapPolyPoly2D(float[] polya, int npolya, float[] polyb, int npolyb)
|
public static bool OverlapPolyPoly2D(Span<float> polya, int npolya, Span<float> polyb, int npolyb)
|
||||||
{
|
{
|
||||||
const float eps = 1e-4f;
|
const float eps = 1e-4f;
|
||||||
for (int i = 0, j = npolya - 1; i < npolya; j = i++)
|
for (int i = 0, j = npolya - 1; i < npolya; j = i++)
|
||||||
|
@ -246,7 +246,7 @@ namespace DotRecast.Detour
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static RcVec2f ProjectPoly(RcVec3f axis, float[] poly, int npoly)
|
public static RcVec2f ProjectPoly(RcVec3f axis, Span<float> poly, int npoly)
|
||||||
{
|
{
|
||||||
float rmin, rmax;
|
float rmin, rmax;
|
||||||
rmin = rmax = axis.Dot2D(poly, 0);
|
rmin = rmax = axis.Dot2D(poly, 0);
|
||||||
|
@ -286,7 +286,7 @@ namespace DotRecast.Detour
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool DistancePtPolyEdgesSqr(RcVec3f pt, float[] verts, int nverts, float[] ed, float[] et)
|
public static bool DistancePtPolyEdgesSqr(RcVec3f pt, Span<float> verts, int nverts, Span<float> ed, Span<float> et)
|
||||||
{
|
{
|
||||||
// TODO: Replace pnpoly with triArea2D tests?
|
// TODO: Replace pnpoly with triArea2D tests?
|
||||||
int i, j;
|
int i, j;
|
||||||
|
@ -307,7 +307,7 @@ namespace DotRecast.Detour
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static float DistancePtSegSqr2D(RcVec3f pt, float[] verts, int p, int q, out float t)
|
public static float DistancePtSegSqr2D(RcVec3f pt, Span<float> verts, int p, int q, out float t)
|
||||||
{
|
{
|
||||||
var vp = RcVecUtils.Create(verts, p);
|
var vp = RcVecUtils.Create(verts, p);
|
||||||
var vq = RcVecUtils.Create(verts, q);
|
var vq = RcVecUtils.Create(verts, q);
|
||||||
|
|
Loading…
Reference in New Issue