Remove region assumptions from fast shroud tests.

This commit is contained in:
Paul Chote
2015-05-03 19:28:07 +12:00
parent da3abb4e2e
commit aee951c86f
7 changed files with 66 additions and 49 deletions

View File

@@ -30,7 +30,6 @@ namespace OpenRA.Mods.Common.Traits
readonly bool startsRevealed;
readonly MPos[] footprint;
readonly CellRegion footprintRegion;
readonly Lazy<IToolTip> tooltip;
readonly Lazy<Health> health;
@@ -46,7 +45,6 @@ namespace OpenRA.Mods.Common.Traits
startsRevealed = info.StartsRevealed && !init.Contains<ParentActorInit>();
var footprintCells = FootprintUtils.Tiles(init.Self).ToList();
footprint = footprintCells.Select(cell => cell.ToMPos(init.World.Map)).ToArray();
footprintRegion = CellRegion.BoundingRegion(init.World.Map.TileShape, footprintCells);
tooltip = Exts.Lazy(() => init.Self.TraitsImplementing<IToolTip>().FirstOrDefault());
health = Exts.Lazy(() => init.Self.TraitOrDefault<Health>());
@@ -71,7 +69,7 @@ namespace OpenRA.Mods.Common.Traits
FrozenActor frozenActor;
if (!initialized)
{
frozen[player] = frozenActor = new FrozenActor(self, footprint, footprintRegion, player.Shroud);
frozen[player] = frozenActor = new FrozenActor(self, footprint, player.Shroud);
frozen[player].NeedRenderables = frozenActor.NeedRenderables = startsRevealed;
player.PlayerActor.Trait<FrozenActorLayer>().Add(frozenActor);
isVisible = visible[player] |= startsRevealed;

View File

@@ -33,7 +33,7 @@ namespace OpenRA.Mods.Common.Traits
public void Render(WorldRenderer wr)
{
var shroudObscured = world.ShroudObscuresTest(wr.Viewport.VisibleCells);
var shroudObscured = world.ShroudObscuresTest;
foreach (var uv in wr.Viewport.VisibleCells.MapCoords)
{
if (shroudObscured(uv))

View File

@@ -122,6 +122,9 @@ namespace OpenRA.Mods.Common.Widgets
void UpdateShroudCell(CPos cell)
{
if (!world.Map.Contains(cell))
return;
var stride = radarSheet.Size.Width;
var uv = cell.ToMPos(world.Map);
var dx = shroudSprite.Bounds.Left - world.Map.Bounds.Left;