forked from bit/DotRecastNetSim
change class RcCompactCell -> readonly struct RcCompactCell
This commit is contained in:
parent
898cf33dbb
commit
3aefd2c378
|
@ -21,12 +21,18 @@ freely, subject to the following restrictions:
|
||||||
namespace DotRecast.Recast
|
namespace DotRecast.Recast
|
||||||
{
|
{
|
||||||
/** Provides information on the content of a cell column in a compact heightfield. */
|
/** Provides information on the content of a cell column in a compact heightfield. */
|
||||||
public class RcCompactCell
|
public readonly struct RcCompactCell
|
||||||
{
|
{
|
||||||
/** Index to the first span in the column. */
|
/** Index to the first span in the column. */
|
||||||
public int index;
|
public readonly int index;
|
||||||
|
|
||||||
/** Number of spans in the column. */
|
/** Number of spans in the column. */
|
||||||
public int count;
|
public readonly int count;
|
||||||
|
|
||||||
|
public RcCompactCell(int index, int count)
|
||||||
|
{
|
||||||
|
this.index = index;
|
||||||
|
this.count = count;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -64,10 +64,6 @@ namespace DotRecast.Recast
|
||||||
chf.cells = new RcCompactCell[w * h];
|
chf.cells = new RcCompactCell[w * h];
|
||||||
chf.spans = new RcCompactSpan[spanCount];
|
chf.spans = new RcCompactSpan[spanCount];
|
||||||
chf.areas = new int[spanCount];
|
chf.areas = new int[spanCount];
|
||||||
for (int i = 0; i < chf.cells.Length; i++)
|
|
||||||
{
|
|
||||||
chf.cells[i] = new RcCompactCell();
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = 0; i < chf.spans.Length; i++)
|
for (int i = 0; i < chf.spans.Length; i++)
|
||||||
{
|
{
|
||||||
|
@ -84,9 +80,9 @@ namespace DotRecast.Recast
|
||||||
// If there are no spans at this cell, just leave the data to index=0, count=0.
|
// If there are no spans at this cell, just leave the data to index=0, count=0.
|
||||||
if (s == null)
|
if (s == null)
|
||||||
continue;
|
continue;
|
||||||
RcCompactCell c = chf.cells[x + y * w];
|
|
||||||
c.index = idx;
|
int tmpIdx = idx;
|
||||||
c.count = 0;
|
int tmpCount = 0;
|
||||||
while (s != null)
|
while (s != null)
|
||||||
{
|
{
|
||||||
if (s.area != RC_NULL_AREA)
|
if (s.area != RC_NULL_AREA)
|
||||||
|
@ -97,11 +93,13 @@ namespace DotRecast.Recast
|
||||||
chf.spans[idx].h = Clamp(top - bot, 0, MAX_HEIGHT);
|
chf.spans[idx].h = Clamp(top - bot, 0, MAX_HEIGHT);
|
||||||
chf.areas[idx] = s.area;
|
chf.areas[idx] = s.area;
|
||||||
idx++;
|
idx++;
|
||||||
c.count++;
|
tmpCount++;
|
||||||
}
|
}
|
||||||
|
|
||||||
s = s.next;
|
s = s.next;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
chf.cells[x + y * w] = new RcCompactCell(tmpIdx, tmpCount);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue