refactor: use ref readonly RcCompactCell c = ref ...

This commit is contained in:
ikpil 2023-11-02 00:11:54 +09:00
parent 8ff17f43a2
commit 5b2e9591c2
7 changed files with 36 additions and 36 deletions

View File

@ -486,7 +486,7 @@ public class RecastDebugDraw : DebugDraw
{
float fx = chf.bmin.X + x * cs;
float fz = chf.bmin.Z + y * cs;
RcCompactCell c = chf.cells[x + y * chf.width];
ref readonly RcCompactCell c = ref chf.cells[x + y * chf.width];
for (int i = c.index, ni = c.index + c.count; i < ni; ++i)
{
@ -859,7 +859,7 @@ public class RecastDebugDraw : DebugDraw
{
float fx = chf.bmin.X + x * cs;
float fz = chf.bmin.Z + y * cs;
RcCompactCell c = chf.cells[x + y * chf.width];
ref readonly RcCompactCell c = ref chf.cells[x + y * chf.width];
for (int i = c.index, ni = c.index + c.count; i < ni; ++i)
{
@ -912,7 +912,7 @@ public class RecastDebugDraw : DebugDraw
{
float fx = chf.bmin.X + x * cs;
float fz = chf.bmin.Z + y * cs;
RcCompactCell c = chf.cells[x + y * chf.width];
ref readonly RcCompactCell c = ref chf.cells[x + y * chf.width];
for (int i = c.index, ni = c.index + c.count; i < ni; ++i)
{

View File

@ -60,7 +60,7 @@ namespace DotRecast.Recast
{
for (int x = 0; x < xSize; ++x)
{
RcCompactCell cell = compactHeightfield.cells[x + z * zStride];
ref readonly RcCompactCell cell = ref compactHeightfield.cells[x + z * zStride];
for (int spanIndex = cell.index, maxSpanIndex = cell.index + cell.count; spanIndex < maxSpanIndex; ++spanIndex)
{
if (compactHeightfield.areas[spanIndex] == RC_NULL_AREA)
@ -109,7 +109,7 @@ namespace DotRecast.Recast
{
for (int x = 0; x < xSize; ++x)
{
RcCompactCell cell = compactHeightfield.cells[x + z * zStride];
ref readonly RcCompactCell cell = ref compactHeightfield.cells[x + z * zStride];
int maxSpanIndex = cell.index + cell.count;
for (int spanIndex = cell.index; spanIndex < maxSpanIndex; ++spanIndex)
{
@ -177,7 +177,7 @@ namespace DotRecast.Recast
{
for (int x = xSize - 1; x >= 0; --x)
{
RcCompactCell cell = compactHeightfield.cells[x + z * zStride];
ref readonly RcCompactCell cell = ref compactHeightfield.cells[x + z * zStride];
int maxSpanIndex = cell.index + cell.count;
for (int i = cell.index; i < maxSpanIndex; ++i)
{
@ -275,7 +275,7 @@ namespace DotRecast.Recast
{
for (int x = 0; x < xSize; ++x)
{
RcCompactCell cell = compactHeightfield.cells[x + z * zStride];
ref readonly RcCompactCell cell = ref compactHeightfield.cells[x + z * zStride];
int maxSpanIndex = cell.index + cell.count;
for (int spanIndex = cell.index; spanIndex < maxSpanIndex; ++spanIndex)
{
@ -404,7 +404,7 @@ namespace DotRecast.Recast
{
for (int x = minX; x <= maxX; ++x)
{
RcCompactCell cell = compactHeightfield.cells[x + z * zStride];
ref readonly RcCompactCell cell = ref compactHeightfield.cells[x + z * zStride];
int maxSpanIndex = cell.index + cell.count;
for (int spanIndex = cell.index; spanIndex < maxSpanIndex; ++spanIndex)
{
@ -523,7 +523,7 @@ namespace DotRecast.Recast
{
for (int x = minx; x <= maxx; ++x)
{
RcCompactCell cell = compactHeightfield.cells[x + z * zStride];
ref readonly RcCompactCell cell = ref compactHeightfield.cells[x + z * zStride];
int maxSpanIndex = cell.index + cell.count;
for (int spanIndex = cell.index; spanIndex < maxSpanIndex; ++spanIndex)
{
@ -644,7 +644,7 @@ namespace DotRecast.Recast
{
for (int x = minx; x <= maxx; ++x)
{
RcCompactCell cell = compactHeightfield.cells[x + z * zStride];
ref readonly RcCompactCell cell = ref compactHeightfield.cells[x + z * zStride];
int maxSpanIndex = cell.index + cell.count;
float cellX = compactHeightfield.bmin.X + ((float)x + 0.5f) * compactHeightfield.cs;

View File

@ -112,7 +112,7 @@ namespace DotRecast.Recast
{
for (int x = 0; x < w; ++x)
{
RcCompactCell c = chf.cells[x + y * w];
ref readonly RcCompactCell c = ref chf.cells[x + y * w];
for (int i = c.index, ni = c.index + c.count; i < ni; ++i)
{
RcCompactSpan s = chf.spans[i];
@ -128,7 +128,7 @@ namespace DotRecast.Recast
// Iterate over all neighbour spans and check if any of the is
// accessible from current cell.
RcCompactCell nc = chf.cells[nx + ny * w];
ref readonly RcCompactCell nc = ref chf.cells[nx + ny * w];
for (int k = nc.index, nk = nc.index + nc.count; k < nk; ++k)
{
RcCompactSpan ns = chf.spans[k];

View File

@ -177,7 +177,7 @@ namespace DotRecast.Recast
RcCompactSpan s = chf.spans[i];
if (GetCon(s, dir) != RC_NOT_CONNECTED)
{
RcCompactCell nc = chf.cells[nx + ny * chf.width];
ref readonly RcCompactCell nc = ref chf.cells[nx + ny * chf.width];
ni = nc.index + GetCon(s, dir);
}
@ -660,7 +660,7 @@ namespace DotRecast.Recast
{
int dx = outline.verts[j * 4 + 0] - hole.verts[corner + 0];
int dz = outline.verts[j * 4 + 2] - hole.verts[corner + 2];
diags[ndiags] = new RcPotentialDiagonal(j, dx * dx + dz * dz);
diags[ndiags] = new RcPotentialDiagonal(j, dx * dx + dz * dz);
ndiags++;
}
}
@ -753,7 +753,7 @@ namespace DotRecast.Recast
{
for (int x = 0; x < w; ++x)
{
RcCompactCell c = chf.cells[x + y * w];
ref readonly RcCompactCell c = ref chf.cells[x + y * w];
for (int i = c.index, ni = c.index + c.count; i < ni; ++i)
{
int res = 0;
@ -793,7 +793,7 @@ namespace DotRecast.Recast
{
for (int x = 0; x < w; ++x)
{
RcCompactCell c = chf.cells[x + y * w];
ref readonly RcCompactCell c = ref chf.cells[x + y * w];
for (int i = c.index, ni = c.index + c.count; i < ni; ++i)
{
if (flags[i] == 0 || flags[i] == 0xf)

View File

@ -80,7 +80,7 @@ namespace DotRecast.Recast
for (int x = borderSize; x < w - borderSize; ++x)
{
RcCompactCell c = chf.cells[x + y * w];
ref readonly RcCompactCell c = ref chf.cells[x + y * w];
for (int i = c.index, ni = c.index + c.count; i < ni; ++i)
{
@ -165,7 +165,7 @@ namespace DotRecast.Recast
// Remap local sweep ids to region ids.
for (int x = borderSize; x < w - borderSize; ++x)
{
RcCompactCell c = chf.cells[x + y * w];
ref readonly RcCompactCell c = ref chf.cells[x + y * w];
for (int i = c.index, ni = c.index + c.count; i < ni; ++i)
{
if (srcReg[i] != 0xff)
@ -189,7 +189,7 @@ namespace DotRecast.Recast
{
for (int x = 0; x < w; ++x)
{
RcCompactCell c = chf.cells[x + y * w];
ref readonly RcCompactCell c = ref chf.cells[x + y * w];
lregs.Clear();
@ -475,7 +475,7 @@ namespace DotRecast.Recast
{
int cx = borderSize + x;
int cy = borderSize + y;
RcCompactCell c = chf.cells[cx + cy * w];
ref readonly RcCompactCell c = ref chf.cells[cx + cy * w];
for (int j = c.index, nj = c.index + c.count; j < nj; ++j)
{
RcCompactSpan s = chf.spans[j];

View File

@ -1131,7 +1131,7 @@ namespace DotRecast.Recast
continue;
}
RcCompactCell c = chf.cells[(ax + bs) + (az + bs) * chf.width];
ref readonly RcCompactCell c = ref chf.cells[(ax + bs) + (az + bs) * chf.width];
for (int i = c.index, ni = c.index + c.count; i < ni && dmin > 0; ++i)
{
RcCompactSpan s = chf.spans[i];
@ -1290,7 +1290,7 @@ namespace DotRecast.Recast
for (int hx = 0; hx < hp.width; hx++)
{
int x = hp.xmin + hx + bs;
RcCompactCell c = chf.cells[x + y * chf.width];
ref readonly RcCompactCell c = ref chf.cells[x + y * chf.width];
for (int i = c.index, ni = c.index + c.count; i < ni; ++i)
{
RcCompactSpan s = chf.spans[i];

View File

@ -49,7 +49,7 @@ namespace DotRecast.Recast
{
for (int x = 0; x < w; ++x)
{
RcCompactCell c = chf.cells[x + y * w];
ref readonly RcCompactCell c = ref chf.cells[x + y * w];
for (int i = c.index, ni = c.index + c.count; i < ni; ++i)
{
RcCompactSpan s = chf.spans[i];
@ -83,7 +83,7 @@ namespace DotRecast.Recast
{
for (int x = 0; x < w; ++x)
{
RcCompactCell c = chf.cells[x + y * w];
ref readonly RcCompactCell c = ref chf.cells[x + y * w];
for (int i = c.index, ni = c.index + c.count; i < ni; ++i)
{
RcCompactSpan s = chf.spans[i];
@ -146,7 +146,7 @@ namespace DotRecast.Recast
{
for (int x = w - 1; x >= 0; --x)
{
RcCompactCell c = chf.cells[x + y * w];
ref readonly RcCompactCell c = ref chf.cells[x + y * w];
for (int i = c.index, ni = c.index + c.count; i < ni; ++i)
{
RcCompactSpan s = chf.spans[i];
@ -225,7 +225,7 @@ namespace DotRecast.Recast
{
for (int x = 0; x < w; ++x)
{
RcCompactCell c = chf.cells[x + y * w];
ref readonly RcCompactCell c = ref chf.cells[x + y * w];
for (int i = c.index, ni = c.index + c.count; i < ni; ++i)
{
RcCompactSpan s = chf.spans[i];
@ -406,7 +406,7 @@ namespace DotRecast.Recast
{
for (int x = 0; x < w; ++x)
{
RcCompactCell c = chf.cells[x + y * w];
ref readonly RcCompactCell c = ref chf.cells[x + y * w];
for (int i = c.index, ni = c.index + c.count; i < ni; ++i)
{
if (chf.dist[i] >= level && srcReg[i] == 0 && chf.areas[i] != RC_NULL_AREA)
@ -535,7 +535,7 @@ namespace DotRecast.Recast
{
for (int x = 0; x < w; ++x)
{
RcCompactCell c = chf.cells[x + y * w];
ref readonly RcCompactCell c = ref chf.cells[x + y * w];
for (int i = c.index, ni = c.index + c.count; i < ni; ++i)
{
if (chf.areas[i] == RC_NULL_AREA || srcReg[i] != 0)
@ -807,7 +807,7 @@ namespace DotRecast.Recast
int ny = y + GetDirOffsetY(dir);
if (GetCon(s, dir) != RC_NOT_CONNECTED)
{
RcCompactCell nc = chf.cells[nx + ny * chf.width];
ref readonly RcCompactCell nc = ref chf.cells[nx + ny * chf.width];
ni = nc.index + GetCon(s, dir);
}
@ -867,7 +867,7 @@ namespace DotRecast.Recast
{
for (int x = 0; x < w; ++x)
{
RcCompactCell c = chf.cells[x + y * w];
ref readonly RcCompactCell c = ref chf.cells[x + y * w];
for (int i = c.index, ni = c.index + c.count; i < ni; ++i)
{
int r = srcReg[i];
@ -1190,7 +1190,7 @@ namespace DotRecast.Recast
{
for (int x = 0; x < w; ++x)
{
RcCompactCell c = chf.cells[x + y * w];
ref readonly RcCompactCell c = ref chf.cells[x + y * w];
lregs.Clear();
@ -1445,7 +1445,7 @@ namespace DotRecast.Recast
{
for (int x = minx; x < maxx; ++x)
{
RcCompactCell c = chf.cells[x + y * w];
ref readonly RcCompactCell c = ref chf.cells[x + y * w];
for (int i = c.index, ni = c.index + c.count; i < ni; ++i)
{
if (chf.areas[i] != RC_NULL_AREA)
@ -1531,7 +1531,7 @@ namespace DotRecast.Recast
for (int x = borderSize; x < w - borderSize; ++x)
{
RcCompactCell c = chf.cells[x + y * w];
ref readonly RcCompactCell c = ref chf.cells[x + y * w];
for (int i = c.index, ni = c.index + c.count; i < ni; ++i)
{
@ -1609,7 +1609,7 @@ namespace DotRecast.Recast
// Remap IDs
for (int x = borderSize; x < w - borderSize; ++x)
{
RcCompactCell c = chf.cells[x + y * w];
ref readonly RcCompactCell c = ref chf.cells[x + y * w];
for (int i = c.index, ni = c.index + c.count; i < ni; ++i)
{
@ -1831,7 +1831,7 @@ namespace DotRecast.Recast
for (int x = borderSize; x < w - borderSize; ++x)
{
RcCompactCell c = chf.cells[x + y * w];
ref readonly RcCompactCell c = ref chf.cells[x + y * w];
for (int i = c.index, ni = c.index + c.count; i < ni; ++i)
{
@ -1909,7 +1909,7 @@ namespace DotRecast.Recast
// Remap IDs
for (int x = borderSize; x < w - borderSize; ++x)
{
RcCompactCell c = chf.cells[x + y * w];
ref readonly RcCompactCell c = ref chf.cells[x + y * w];
for (int i = c.index, ni = c.index + c.count; i < ni; ++i)
{