forked from mirror/DotRecast
remove new int[] in GetPolyMergeValue
This commit is contained in:
parent
1d46fe20f1
commit
695fe15a6e
|
@ -461,16 +461,16 @@ namespace DotRecast.Recast
|
|||
- (verts[c + 0] - verts[a + 0]) * (verts[b + 2] - verts[a + 2]) < 0;
|
||||
}
|
||||
|
||||
private static int[] GetPolyMergeValue(int[] polys, int pa, int pb, int[] verts, int nvp)
|
||||
private static int GetPolyMergeValue(int[] polys, int pa, int pb, int[] verts, out int ea, out int eb, int nvp)
|
||||
{
|
||||
int ea = -1;
|
||||
int eb = -1;
|
||||
ea = -1;
|
||||
eb = -1;
|
||||
int na = CountPolyVerts(polys, pa, nvp);
|
||||
int nb = CountPolyVerts(polys, pb, nvp);
|
||||
|
||||
// If the merged polygon would be too big, do not merge.
|
||||
if (na + nb - 2 > nvp)
|
||||
return new int[] { -1, ea, eb };
|
||||
return -1;
|
||||
|
||||
// Check if the polygons share an edge.
|
||||
|
||||
|
@ -480,9 +480,7 @@ namespace DotRecast.Recast
|
|||
int va1 = polys[pa + (i + 1) % na];
|
||||
if (va0 > va1)
|
||||
{
|
||||
int temp = va0;
|
||||
va0 = va1;
|
||||
va1 = temp;
|
||||
(va0, va1) = (va1, va0);
|
||||
}
|
||||
|
||||
for (int j = 0; j < nb; ++j)
|
||||
|
@ -491,9 +489,7 @@ namespace DotRecast.Recast
|
|||
int vb1 = polys[pb + (j + 1) % nb];
|
||||
if (vb0 > vb1)
|
||||
{
|
||||
int temp = vb0;
|
||||
vb0 = vb1;
|
||||
vb1 = temp;
|
||||
(vb0, vb1) = (vb1, vb0);
|
||||
}
|
||||
|
||||
if (va0 == vb0 && va1 == vb1)
|
||||
|
@ -507,7 +503,7 @@ namespace DotRecast.Recast
|
|||
|
||||
// No common edge, cannot merge.
|
||||
if (ea == -1 || eb == -1)
|
||||
return new int[] { -1, ea, eb };
|
||||
return -1;
|
||||
|
||||
// Check to see if the merged polygon would be convex.
|
||||
int va, vb, vc;
|
||||
|
@ -516,13 +512,13 @@ namespace DotRecast.Recast
|
|||
vb = polys[pa + ea];
|
||||
vc = polys[pb + (eb + 2) % nb];
|
||||
if (!Uleft(verts, va * 3, vb * 3, vc * 3))
|
||||
return new int[] { -1, ea, eb };
|
||||
return -1;
|
||||
|
||||
va = polys[pb + (eb + nb - 1) % nb];
|
||||
vb = polys[pb + eb];
|
||||
vc = polys[pa + (ea + 2) % na];
|
||||
if (!Uleft(verts, va * 3, vb * 3, vc * 3))
|
||||
return new int[] { -1, ea, eb };
|
||||
return -1;
|
||||
|
||||
va = polys[pa + ea];
|
||||
vb = polys[pa + (ea + 1) % na];
|
||||
|
@ -530,7 +526,7 @@ namespace DotRecast.Recast
|
|||
int dx = verts[va * 3 + 0] - verts[vb * 3 + 0];
|
||||
int dy = verts[va * 3 + 2] - verts[vb * 3 + 2];
|
||||
|
||||
return new int[] { dx * dx + dy * dy, ea, eb };
|
||||
return (dx * dx) + (dy * dy);
|
||||
}
|
||||
|
||||
private static void MergePolyVerts(int[] polys, int pa, int pb, int ea, int eb, int tmp, int nvp)
|
||||
|
@ -901,10 +897,7 @@ namespace DotRecast.Recast
|
|||
for (int k = j + 1; k < npolys; ++k)
|
||||
{
|
||||
int pk = k * nvp;
|
||||
int[] veaeb = GetPolyMergeValue(polys, pj, pk, mesh.verts, nvp);
|
||||
int v = veaeb[0];
|
||||
int ea = veaeb[1];
|
||||
int eb = veaeb[2];
|
||||
var v = GetPolyMergeValue(polys, pj, pk, mesh.verts, out var ea, out var eb, nvp);
|
||||
if (v > bestMergeVal)
|
||||
{
|
||||
bestMergeVal = v;
|
||||
|
@ -1087,10 +1080,7 @@ namespace DotRecast.Recast
|
|||
for (int k = j + 1; k < npolys; ++k)
|
||||
{
|
||||
int pk = k * nvp;
|
||||
int[] veaeb = GetPolyMergeValue(polys, pj, pk, mesh.verts, nvp);
|
||||
int v = veaeb[0];
|
||||
int ea = veaeb[1];
|
||||
int eb = veaeb[2];
|
||||
var v = GetPolyMergeValue(polys, pj, pk, mesh.verts, out var ea, out var eb, nvp);
|
||||
if (v > bestMergeVal)
|
||||
{
|
||||
bestMergeVal = v;
|
||||
|
|
Loading…
Reference in New Issue