From 0d5b6eb9954ab4c019c42f49156762827ff666df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Hru=C5=A1ka?= Date: Mon, 21 Apr 2014 16:46:15 +0200 Subject: [PATCH] tiledrect more efficient --- src/mightypork/rogue/world/map/MapAccess.java | 3 +++ .../rogue/world/map/TileRenderContext.java | 5 ++++- .../util/constraints/rect/builders/TiledRect.java | 13 ++++++++++++- 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/mightypork/rogue/world/map/MapAccess.java b/src/mightypork/rogue/world/map/MapAccess.java index 4172818..aa4f3b6 100644 --- a/src/mightypork/rogue/world/map/MapAccess.java +++ b/src/mightypork/rogue/world/map/MapAccess.java @@ -40,5 +40,8 @@ public interface MapAccess { long getSeed(); + /** + * @return level-specific noise generator + */ NoiseGen getNoiseGen(); } diff --git a/src/mightypork/rogue/world/map/TileRenderContext.java b/src/mightypork/rogue/world/map/TileRenderContext.java index 625dff0..eca6b92 100644 --- a/src/mightypork/rogue/world/map/TileRenderContext.java +++ b/src/mightypork/rogue/world/map/TileRenderContext.java @@ -27,6 +27,9 @@ public final class TileRenderContext implements RectBound { { this.map = map; this.tiler = drawArea.tiles(map.getWidth(), map.getHeight()); + + this.tiler.setOverlap(0.001); + this.noise = map.getNoiseGen(); } @@ -59,7 +62,7 @@ public final class TileRenderContext implements RectBound { @Override public Rect getRect() { - return tiler.tile(x, y).grow(0.01); // important to avoid gaps b/w tiles when scaled. + return tiler.tile(x, y); } diff --git a/src/mightypork/util/constraints/rect/builders/TiledRect.java b/src/mightypork/util/constraints/rect/builders/TiledRect.java index 244a328..de8a200 100644 --- a/src/mightypork/util/constraints/rect/builders/TiledRect.java +++ b/src/mightypork/util/constraints/rect/builders/TiledRect.java @@ -21,7 +21,7 @@ public class TiledRect extends RectProxy { final private Num perCol; /** Left top tile */ - final private Rect aTile; + private Rect aTile; public TiledRect(Rect source, int horizontal, int vertical) @@ -37,6 +37,17 @@ public class TiledRect extends RectProxy { } + /** + * Set tile overlap. Applies only to tile, not span. + * + * @param overlap how far to overlap to neighbouring tiles on all sides + */ + public void setOverlap(double overlap) + { + aTile = aTile.grow(overlap); + } + + /** * Get a tile. *