little performance gain in world render

This commit is contained in:
ondra
2014-04-21 15:09:23 +02:00
parent f8f49b81ff
commit 0619f83bfb
4 changed files with 25 additions and 6 deletions
+12
View File
@@ -13,6 +13,7 @@ import mightypork.rogue.world.tile.Tiles;
import mightypork.util.files.ion.Ion;
import mightypork.util.files.ion.IonConstructor;
import mightypork.util.files.ion.Ionizable;
import mightypork.util.math.noise.NoiseGen;
/**
@@ -31,6 +32,8 @@ public class Level implements MapAccess, Ionizable {
/** Level seed (used for generation and tile variation) */
public long seed;
private NoiseGen noiseGen;
@IonConstructor
@@ -190,4 +193,13 @@ public class Level implements MapAccess, Ionizable {
}
}
@Override
public NoiseGen getNoiseGen()
{
if (noiseGen == null) {
noiseGen = new NoiseGen(0.2, 0, 0.5, 1, seed);
}
return noiseGen;
}
}
@@ -2,6 +2,7 @@ package mightypork.rogue.world.map;
import mightypork.rogue.world.tile.Tile;
import mightypork.util.math.noise.NoiseGen;
/**
@@ -37,4 +38,7 @@ public interface MapAccess {
* @return map seed
*/
long getSeed();
NoiseGen getNoiseGen();
}
@@ -27,7 +27,7 @@ public final class TileRenderContext implements RectBound {
{
this.map = map;
this.tiler = drawArea.tiles(map.getWidth(), map.getHeight());
this.noise = new NoiseGen(0.2, 0, 0.5, 1, map.getSeed());
this.noise = map.getNoiseGen();
}