use spatial index for whatever we can
This commit is contained in:
@@ -53,14 +53,13 @@ namespace OpenRA.Orders
|
|||||||
|
|
||||||
string ChooseCursor(World world, MouseInput mi)
|
string ChooseCursor(World world, MouseInput mi)
|
||||||
{
|
{
|
||||||
|
using (new PerfSample("cursor"))
|
||||||
|
{
|
||||||
var p = Game.controller.MousePosition;
|
var p = Game.controller.MousePosition;
|
||||||
var c = Order(world, p.ToInt2(), mi)
|
var c = Order(world, p.ToInt2(), mi)
|
||||||
.Select(o => CursorForOrderString(o.OrderString, o.Subject, o.TargetLocation))
|
.Select(o => CursorForOrderString(o.OrderString, o.Subject, o.TargetLocation))
|
||||||
.FirstOrDefault(a => a != null);
|
.FirstOrDefault(a => a != null);
|
||||||
|
|
||||||
using (new PerfSample("cursor"))
|
|
||||||
{
|
|
||||||
return c ??
|
return c ??
|
||||||
(world.SelectActorsInBox(Game.CellSize * p,
|
(world.SelectActorsInBox(Game.CellSize * p,
|
||||||
Game.CellSize * p).Any()
|
Game.CellSize * p).Any()
|
||||||
|
|||||||
@@ -82,13 +82,7 @@ namespace OpenRA
|
|||||||
|
|
||||||
public static IEnumerable<Actor> FindUnits(this World world, float2 a, float2 b)
|
public static IEnumerable<Actor> FindUnits(this World world, float2 a, float2 b)
|
||||||
{
|
{
|
||||||
var min = float2.Min(a, b);
|
return world.WorldActor.traits.Get<SpatialBins>().ActorsInBox(a.ToInt2(), b.ToInt2());
|
||||||
var max = float2.Max(a, b);
|
|
||||||
|
|
||||||
var rect = new RectangleF(min.X, min.Y, max.X - min.X, max.Y - min.Y);
|
|
||||||
|
|
||||||
return world.Actors
|
|
||||||
.Where(x => x.GetBounds(true).IntersectsWith(rect));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IEnumerable<Actor> FindUnitsInCircle(this World world, float2 a, float r)
|
public static IEnumerable<Actor> FindUnitsInCircle(this World world, float2 a, float r)
|
||||||
|
|||||||
@@ -222,3 +222,4 @@ World:
|
|||||||
UnitLost: unitlost.aud
|
UnitLost: unitlost.aud
|
||||||
NavalUnitLost: unitlost.aud
|
NavalUnitLost: unitlost.aud
|
||||||
PrimaryBuildingSelected: pribldg1.aud
|
PrimaryBuildingSelected: pribldg1.aud
|
||||||
|
SpatialBins:
|
||||||
Reference in New Issue
Block a user