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
|
||||
{
|
||||
/** 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. */
|
||||
public int index;
|
||||
public readonly int index;
|
||||
|
||||
/** 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.spans = new RcCompactSpan[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++)
|
||||
{
|
||||
|
@ -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 (s == null)
|
||||
continue;
|
||||
RcCompactCell c = chf.cells[x + y * w];
|
||||
c.index = idx;
|
||||
c.count = 0;
|
||||
|
||||
int tmpIdx = idx;
|
||||
int tmpCount = 0;
|
||||
while (s != null)
|
||||
{
|
||||
if (s.area != RC_NULL_AREA)
|
||||
|
@ -97,11 +93,13 @@ namespace DotRecast.Recast
|
|||
chf.spans[idx].h = Clamp(top - bot, 0, MAX_HEIGHT);
|
||||
chf.areas[idx] = s.area;
|
||||
idx++;
|
||||
c.count++;
|
||||
tmpCount++;
|
||||
}
|
||||
|
||||
s = s.next;
|
||||
}
|
||||
|
||||
chf.cells[x + y * w] = new RcCompactCell(tmpIdx, tmpCount);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue