don't thrash the GC quite so hard in SpatialBins
This commit is contained in:
@@ -33,13 +33,17 @@ namespace OpenRA.Traits
|
||||
self.World.Map.MapSize.Y / info.BinSize];
|
||||
|
||||
scale = Game.CellSize * info.BinSize;
|
||||
|
||||
for (var j = 0; j <= bins.GetUpperBound(1); j++)
|
||||
for (var i = 0; i <= bins.GetUpperBound(0); i++)
|
||||
bins[i, j] = new List<Actor>();
|
||||
}
|
||||
|
||||
public void Tick(Actor self)
|
||||
{
|
||||
for (var j = 0; j <= bins.GetUpperBound(1); j++)
|
||||
for (var i = 0; i <= bins.GetUpperBound(0); i++)
|
||||
bins[i, j] = new List<Actor>();
|
||||
bins[i, j].Clear();
|
||||
|
||||
foreach (var a in self.World.Actors)
|
||||
{
|
||||
@@ -63,8 +67,6 @@ namespace OpenRA.Traits
|
||||
|
||||
IEnumerable<Actor> ActorsInBins(int i1, int i2, int j1, int j2)
|
||||
{
|
||||
if (bins[0, 0] == null) yield break; // hack
|
||||
|
||||
j1 = Math.Max(0, j1); j2 = Math.Min(j2, bins.GetUpperBound(1));
|
||||
i1 = Math.Max(0, i1); i2 = Math.Min(i2, bins.GetUpperBound(0));
|
||||
for (var j = j1; j <= j2; j++)
|
||||
|
||||
Reference in New Issue
Block a user