diff --git a/src/main/java/ninja/bytecode/iris/IrisDataManager.java b/src/main/java/ninja/bytecode/iris/IrisDataManager.java index 6037ec298..c49328cd0 100644 --- a/src/main/java/ninja/bytecode/iris/IrisDataManager.java +++ b/src/main/java/ninja/bytecode/iris/IrisDataManager.java @@ -5,36 +5,32 @@ import java.io.File; import org.bukkit.World.Environment; import org.bukkit.block.Biome; -import com.google.gson.Gson; - -import lombok.Getter; -import ninja.bytecode.iris.object.Dispersion; +import lombok.Data; import ninja.bytecode.iris.object.IrisBiome; -import ninja.bytecode.iris.object.IrisBiomePaletteLayer; import ninja.bytecode.iris.object.IrisDimension; +import ninja.bytecode.iris.object.IrisRegion; import ninja.bytecode.iris.util.IO; -import ninja.bytecode.iris.util.JSONObject; import ninja.bytecode.iris.util.ResourceLoader; +@Data public class IrisDataManager { private File dataFolder; private File packs; - @Getter private ResourceLoader biomeLoader; - - @Getter + private ResourceLoader regionLoader; private ResourceLoader dimensionLoader; - + public void hotloaded() { packs.mkdirs(); + this.regionLoader = new ResourceLoader<>(packs, "regions", "Region", IrisRegion.class); this.biomeLoader = new ResourceLoader<>(packs, "biomes", "Biome", IrisBiome.class); this.dimensionLoader = new ResourceLoader<>(packs, "dimensions", "Dimension", IrisDimension.class); writeExamples(); } - + public IrisDataManager(File dataFolder) { this.dataFolder = dataFolder; @@ -46,32 +42,6 @@ public class IrisDataManager { File examples = new File(dataFolder, "example"); examples.mkdirs(); - - IrisBiome biome = new IrisBiome(); - biome.getLayers().clear(); - IrisBiomePaletteLayer grass = new IrisBiomePaletteLayer(); - grass.add("GRASS_BLOCK"); - grass.setDispersion(Dispersion.SCATTER); - grass.setMinHeight(1); - grass.setMaxHeight(1); - IrisBiomePaletteLayer dirt = new IrisBiomePaletteLayer(); - grass.add("DIRT"); - grass.setDispersion(Dispersion.SCATTER); - grass.setMinHeight(1); - grass.setMaxHeight(2); - IrisBiomePaletteLayer dirtThick = new IrisBiomePaletteLayer(); - grass.add("DIRT"); - grass.add("COARSE_DIRT"); - grass.setDispersion(Dispersion.WISPY); - grass.setMinHeight(1); - grass.setMaxHeight(3); - - biome.getLayers().add(dirtThick); - biome.getLayers().add(dirt); - biome.getLayers().add(grass); - - IrisDimension dim = new IrisDimension(); - dim.getBiomes().add("a_biome"); String biomes = ""; String envs = ""; @@ -91,14 +61,11 @@ public class IrisDataManager new File(examples, "example-pack/dimensions").mkdirs(); IO.writeAll(new File(examples, "biome-list.txt"), biomes); IO.writeAll(new File(examples, "environment-list.txt"), envs); - IO.writeAll(new File(examples, "example-pack/biomes/a_biome.json"), new JSONObject(new Gson().toJson(biome)).toString(4)); - IO.writeAll(new File(examples, "example-pack/dimensions/a_dimension.json"), new JSONObject(new Gson().toJson(dim)).toString(4)); } catch(Throwable e) { } - } } \ No newline at end of file diff --git a/src/main/java/ninja/bytecode/iris/IrisGenerator.java b/src/main/java/ninja/bytecode/iris/IrisGenerator.java index e457583a2..6d9ef8a2f 100644 --- a/src/main/java/ninja/bytecode/iris/IrisGenerator.java +++ b/src/main/java/ninja/bytecode/iris/IrisGenerator.java @@ -15,6 +15,7 @@ import org.bukkit.generator.ChunkGenerator; import ninja.bytecode.iris.layer.GenLayerBiome; import ninja.bytecode.iris.object.IrisBiome; import ninja.bytecode.iris.object.IrisDimension; +import ninja.bytecode.iris.object.IrisRegion; import ninja.bytecode.iris.util.BiomeResult; import ninja.bytecode.iris.util.CNG; import ninja.bytecode.iris.util.IrisInterpolation; @@ -25,6 +26,7 @@ public class IrisGenerator extends ChunkGenerator { // TODO REMOVE OR FIND A BETTER PLACE private BlockData STONE = Material.STONE.createBlockData(); + private BlockData WATER = Material.WATER.createBlockData(); private String dimensionName; private GenLayerBiome glBiome; private CNG terrainNoise; @@ -64,44 +66,74 @@ public class IrisGenerator extends ChunkGenerator { Iris.hotloader.check(); int i, j, k, height, depth; - double wx, wz, rx, rz, heightLow, heightHigh, heightExponent; + double wx, wz, rx, rz, noise, ox, oz; + boolean underwater; + BlockData block; int fluidHeight = getDimension().getFluidHeight(); BiomeResult biomeResult; IrisBiome biome; + IrisRegion region; RNG random = new RNG(world.getSeed()); onInit(world, random.nextParallelRNG(0)); ChunkData data = Bukkit.createChunkData(world); for(i = 0; i < 16; i++) { - rx = (x * 16) + i; - wx = ((double) (x * 16) + i) / getDimension().getTerrainZoom(); + for(j = 0; j < 16; j++) { + rx = (x * 16) + i; rz = (z * 16) + j; - wz = ((double) (z * 16) + j) / getDimension().getTerrainZoom(); + ox = (getDimension().cosRotate() * rx) + (-getDimension().sinRotate() * rz) + getDimension().getCoordFracture(random, 39392).fitDoubleD(-getDimension().getCoordFractureDistance() / 2, getDimension().getCoordFractureDistance() / 2, rx, rz); + oz = (getDimension().sinRotate() * rx) + (getDimension().cosRotate() * rz) + getDimension().getCoordFracture(random, 39392).fitDoubleD(-getDimension().getCoordFractureDistance() / 2, getDimension().getCoordFractureDistance() / 2, rx, rz); + wx = (double) (ox) / getDimension().getTerrainZoom(); + wz = (double) (oz) / getDimension().getTerrainZoom(); depth = 0; - biomeResult = glBiome.generateData(wx, wz); + region = glBiome.getRegion(wx, wz); + biomeResult = glBiome.generateRegionData(wx, wz, region); biome = biomeResult.getBiome(); - heightLow = interpolate(rx, rz, (b) -> b.getLowHeight()); - heightHigh = interpolate(rx, rz, (b) -> b.getHighHeight()); - heightExponent = interpolate(rx, rz, (b) -> b.getHeightExponent()); - height = (int) Math.round(terrainNoise.fitDoubleExponent(heightLow, heightHigh, heightExponent, wx, wz)) + fluidHeight; + double lo = interpolateHeight(ox, oz, (b) -> b.getLowHeight()); + double hi = interpolateSurface(ox, oz, (b) -> b.getHighHeight()); + noise = lo + (terrainNoise.fitDoubleD(0, hi - lo, wx, wz)); + height = (int) Math.round(noise) + fluidHeight; + + // Remove Land biome surfaces from underwater + if(height < fluidHeight + 1) + { + if(biome.isLand()) + { + biome = glBiome.generateShoreData(wx, wz, region).getBiome(); + } + } + KList layers = biome.generateLayers(wx, wz, random, height); for(k = Math.max(height, fluidHeight); k >= 0; k--) { + underwater = k > height && k <= fluidHeight; biomeGrid.setBiome(i, k, j, biome.getDerivative()); - data.setBlock(i, k, j, layers.hasIndex(depth) ? layers.get(depth) : STONE); - depth++; + + if(underwater) + { + block = WATER; + } + + else + { + block = layers.hasIndex(depth) ? layers.get(depth) : STONE; + depth++; + } + + data.setBlock(i, k, j, block); } } } + Iris.verbose("Generated " + x + " " + z); return data; } - public double interpolate(double rx, double rz, Function property) + public double interpolateHeight(double rx, double rz, Function property) { return IrisInterpolation.getNoise(getDimension().getInterpolationFunction(), (int) Math.round(rx), (int) Math.round(rz), getDimension().getInterpolationScale(), (xx, zz) -> { @@ -110,6 +142,15 @@ public class IrisGenerator extends ChunkGenerator }); } + public double interpolateSurface(double rx, double rz, Function property) + { + return IrisInterpolation.getNoise(getDimension().getInterpolationSurfaceFunction(), (int) Math.round(rx), (int) Math.round(rz), getDimension().getInterpolationSurfaceScale(), (xx, zz) -> + { + BiomeResult neighborResult = glBiome.generateData(xx / getDimension().getTerrainZoom(), zz / getDimension().getTerrainZoom()); + return property.apply(neighborResult.getBiome()); + }); + } + @Override public List getDefaultPopulators(World world) { diff --git a/src/main/java/ninja/bytecode/iris/layer/GenLayerBiome.java b/src/main/java/ninja/bytecode/iris/layer/GenLayerBiome.java index d78b03630..c152e6f59 100644 --- a/src/main/java/ninja/bytecode/iris/layer/GenLayerBiome.java +++ b/src/main/java/ninja/bytecode/iris/layer/GenLayerBiome.java @@ -1,31 +1,141 @@ package ninja.bytecode.iris.layer; +import ninja.bytecode.iris.Iris; import ninja.bytecode.iris.IrisGenerator; +import ninja.bytecode.iris.object.InferredType; import ninja.bytecode.iris.object.IrisBiome; +import ninja.bytecode.iris.object.IrisRegion; import ninja.bytecode.iris.util.BiomeResult; -import ninja.bytecode.iris.util.CellGenerator2D; +import ninja.bytecode.iris.util.CellGenerator; import ninja.bytecode.iris.util.GenLayer; import ninja.bytecode.iris.util.KList; import ninja.bytecode.iris.util.RNG; public class GenLayerBiome extends GenLayer { - private CellGenerator2D cells; + private CellGenerator region; + private CellGenerator bridge; + private CellGenerator land; + private CellGenerator shore; + private CellGenerator sea; public GenLayerBiome(IrisGenerator iris, RNG rng) { super(iris, rng); - cells = new CellGenerator2D(rng.nextParallelRNG(2045662)); + region = new CellGenerator(rng.nextParallelRNG(1188519)); + bridge = new CellGenerator(rng.nextParallelRNG(1541462)); + land = new CellGenerator(rng.nextParallelRNG(9045162)); + shore = new CellGenerator(rng.nextParallelRNG(2342812)); + sea = new CellGenerator(rng.nextParallelRNG(6135621)); } - public KList getBiomes() + public IrisRegion getRegion(double bx, double bz) { - return iris.getDimension().buildBiomeList(); + region.setShuffle(32); + region.setCellScale(0.33 / iris.getDimension().getRegionZoom()); + double x = bx / iris.getDimension().getBiomeZoom(); + double z = bz / iris.getDimension().getBiomeZoom(); + String regionId = iris.getDimension().getRegions().get(region.getIndex(x, z, iris.getDimension().getRegions().size())); + + return Iris.data.getRegionLoader().load(regionId); } - public BiomeResult generateData(double x, double z) + public BiomeResult generateData(double bx, double bz) { - return new BiomeResult(getBiomes().get(cells.getIndex(x / iris.getDimension().getBiomeZoom(), z / iris.getDimension().getBiomeZoom(), getBiomes().size())), cells.getDistance(x / iris.getDimension().getBiomeZoom(), z / iris.getDimension().getBiomeZoom())); + return generateRegionData(bx, bz, getRegion(bx, bz)); + } + + public BiomeResult generateRegionData(double bx, double bz, IrisRegion regionData) + { + bridge.setShuffle(32); + bridge.setCellScale(0.33 / iris.getDimension().getContinentZoom()); + double x = bx / iris.getDimension().getBiomeZoom(); + double z = bz / iris.getDimension().getBiomeZoom(); + + // Beach + if(bridge.getDistance(x, z) < regionData.getShoreRatio()) + { + return generateShoreData(bx, bz, regionData); + } + + // Sea + else if(bridge.getIndex(x, z, 5) == 1) + { + return generateSeaData(bx, bz, regionData); + } + + // Land + else + { + return generateLandData(bx, bz, regionData); + } + } + + public BiomeResult generateBiomeData(double bx, double bz, IrisRegion regionData, CellGenerator cell, KList biomes, InferredType inferredType) + { + double x = bx / iris.getDimension().getBiomeZoom(); + double z = bz / iris.getDimension().getBiomeZoom(); + IrisBiome biome = Iris.data.getBiomeLoader().load(biomes.get(sea.getIndex(x, z, biomes.size()))); + biome.setInferredType(inferredType); + + return implode(bx, bz, regionData, cell, new BiomeResult(biome, cell.getDistance(x, z))); + } + + public BiomeResult generateSeaData(double bx, double bz, IrisRegion regionData) + { + sea.setShuffle(32); + sea.setCellScale(0.56 / iris.getDimension().getSeaZoom()); + return generateBiomeData(bx, bz, regionData, sea, regionData.getSeaBiomes(), InferredType.SEA); + } + + public BiomeResult generateLandData(double bx, double bz, IrisRegion regionData) + { + land.setShuffle(32); + land.setCellScale(0.6 / iris.getDimension().getLandZoom()); + return generateBiomeData(bx, bz, regionData, land, regionData.getLandBiomes(), InferredType.LAND); + } + + public BiomeResult generateShoreData(double bx, double bz, IrisRegion regionData) + { + shore.setShuffle(32); + shore.setCellScale(0.8 / iris.getDimension().getShoreZoom()); + return generateBiomeData(bx, bz, regionData, shore, regionData.getShoreBiomes(), InferredType.SHORE); + } + + public BiomeResult implode(double bx, double bz, IrisRegion regionData, CellGenerator parentCell, BiomeResult parent) + { + return implode(bx, bz, regionData, parentCell, parent, 1); + } + + public BiomeResult implode(double bx, double bz, IrisRegion regionData, CellGenerator parentCell, BiomeResult parent, int hits) + { + if(hits > 9) + { + return parent; + } + + double x = bx / iris.getDimension().getBiomeZoom(); + double z = bz / iris.getDimension().getBiomeZoom(); + if(parent.getDistance() > regionData.getBiomeImplosionRatio()) + { + if(!parent.getBiome().getChildren().isEmpty()) + { + CellGenerator childCell = parent.getBiome().getChildrenGenerator(rng, 123, parentCell.getCellScale() * parent.getBiome().getChildShrinkFactor()); + int r = childCell.getIndex(x, z, parent.getBiome().getChildren().size() + 1); + + if(r == parent.getBiome().getChildren().size()) + { + return new BiomeResult(parent.getBiome(), childCell.getDistance(x, z)); + } + + IrisBiome biome = Iris.data.getBiomeLoader().load(parent.getBiome().getChildren().get(r)); + biome.setInferredType(parent.getBiome().getInferredType()); + + return implode(bx, bz, regionData, childCell, new BiomeResult(biome, childCell.getDistance(x, z)), hits + 1); + } + } + + return parent; } @Override diff --git a/src/main/java/ninja/bytecode/iris/object/InferredType.java b/src/main/java/ninja/bytecode/iris/object/InferredType.java new file mode 100644 index 000000000..0f9bd0137 --- /dev/null +++ b/src/main/java/ninja/bytecode/iris/object/InferredType.java @@ -0,0 +1,8 @@ +package ninja.bytecode.iris.object; + +public enum InferredType +{ + SHORE, + LAND, + SEA +} diff --git a/src/main/java/ninja/bytecode/iris/object/IrisBiome.java b/src/main/java/ninja/bytecode/iris/object/IrisBiome.java index f099d1ac7..eb5893f8a 100644 --- a/src/main/java/ninja/bytecode/iris/object/IrisBiome.java +++ b/src/main/java/ninja/bytecode/iris/object/IrisBiome.java @@ -7,6 +7,7 @@ import org.bukkit.block.data.BlockData; import lombok.Data; import ninja.bytecode.iris.util.CNG; +import ninja.bytecode.iris.util.CellGenerator; import ninja.bytecode.iris.util.KList; import ninja.bytecode.iris.util.RNG; @@ -17,12 +18,27 @@ public class IrisBiome private Biome derivative = Biome.THE_VOID; private double highHeight = 7; private double lowHeight = 1; - private double heightExponent = 1; + private double childShrinkFactor = 1.5; + private KList children = new KList<>(); private KList layers = new KList().qadd(new IrisBiomePaletteLayer()); + private KList decorators = new KList(); + private transient CellGenerator childrenCell; + private transient InferredType inferredType; private transient KList layerHeightGenerators; private transient KList layerSurfaceGenerators; + public CellGenerator getChildrenGenerator(RNG random, int sig, double scale) + { + if(childrenCell == null) + { + childrenCell = new CellGenerator(random.nextParallelRNG(sig * 213)); + childrenCell.setCellScale(scale); + } + + return childrenCell; + } + public KList generateLayers(double wx, double wz, RNG random, int maxDepth) { KList data = new KList<>(); @@ -61,21 +77,15 @@ public class IrisBiome public KList getLayerSurfaceGenerators(RNG rng) { - synchronized(this) + if(layerSurfaceGenerators == null) { - if(layerSurfaceGenerators == null) + layerSurfaceGenerators = new KList<>(); + + int m = 91235; + + for(IrisBiomePaletteLayer i : getLayers()) { - layerSurfaceGenerators = new KList<>(); - - synchronized(layerSurfaceGenerators) - { - int m = 91235; - - for(IrisBiomePaletteLayer i : getLayers()) - { - layerSurfaceGenerators.add(i.getGenerator(rng.nextParallelRNG((m += 3) * m * m * m))); - } - } + layerSurfaceGenerators.add(i.getGenerator(rng.nextParallelRNG((m += 3) * m * m * m))); } } @@ -84,24 +94,33 @@ public class IrisBiome public KList getLayerHeightGenerators(RNG rng) { - synchronized(this) + if(layerHeightGenerators == null) { - if(layerHeightGenerators == null) + layerHeightGenerators = new KList<>(); + + int m = 7235; + + for(IrisBiomePaletteLayer i : getLayers()) { - layerHeightGenerators = new KList<>(); - - synchronized(layerHeightGenerators) - { - int m = 7235; - - for(IrisBiomePaletteLayer i : getLayers()) - { - layerHeightGenerators.add(i.getGenerator(rng.nextParallelRNG((m++) * m * m * m))); - } - } + layerHeightGenerators.add(i.getGenerator(rng.nextParallelRNG((m++) * m * m * m))); } } return layerHeightGenerators; } + + public boolean isLand() + { + return inferredType.equals(InferredType.LAND); + } + + public boolean isSea() + { + return inferredType.equals(InferredType.SEA); + } + + public boolean isShore() + { + return inferredType.equals(InferredType.SHORE); + } } diff --git a/src/main/java/ninja/bytecode/iris/object/IrisBiomeDecorator.java b/src/main/java/ninja/bytecode/iris/object/IrisBiomeDecorator.java new file mode 100644 index 000000000..2a049b9c6 --- /dev/null +++ b/src/main/java/ninja/bytecode/iris/object/IrisBiomeDecorator.java @@ -0,0 +1,72 @@ +package ninja.bytecode.iris.object; + +import org.bukkit.Material; +import org.bukkit.block.data.BlockData; + +import lombok.Data; +import ninja.bytecode.iris.util.CNG; +import ninja.bytecode.iris.util.KList; +import ninja.bytecode.iris.util.KMap; +import ninja.bytecode.iris.util.RNG; + +@Data +public class IrisBiomeDecorator +{ + private Dispersion dispersion = Dispersion.ZEBRA; + private int iterations = 5; + private double zoom = 1; + private KList palette = new KList().qadd("GRASS"); + + private transient KMap layerGenerators; + private transient KList blockData; + + public CNG getGenerator(RNG rng) + { + long key = rng.nextParallelRNG(1).nextLong(); + + if(layerGenerators == null) + { + layerGenerators = new KMap<>(); + } + + if(!layerGenerators.containsKey(key)) + { + layerGenerators.put(key, CNG.signature(rng.nextParallelRNG(iterations + getBlockData().size()))); + } + + return layerGenerators.get(key); + } + + public KList add(String b) + { + palette.add(b); + + return palette; + } + + public KList getBlockData() + { + if(blockData == null) + { + blockData = new KList<>(); + for(String i : palette) + { + try + { + Material m = Material.valueOf(i); + + if(m != null) + { + blockData.add(m.createBlockData()); + } + } + catch(Throwable e) + { + + } + } + } + + return blockData; + } +} diff --git a/src/main/java/ninja/bytecode/iris/object/IrisBiomePaletteLayer.java b/src/main/java/ninja/bytecode/iris/object/IrisBiomePaletteLayer.java index a4126cc97..f96709bfd 100644 --- a/src/main/java/ninja/bytecode/iris/object/IrisBiomePaletteLayer.java +++ b/src/main/java/ninja/bytecode/iris/object/IrisBiomePaletteLayer.java @@ -23,25 +23,19 @@ public class IrisBiomePaletteLayer public CNG getGenerator(RNG rng) { - synchronized(this) + long key = rng.nextParallelRNG(1).nextLong(); + + if(layerGenerators == null) { - long key = rng.nextParallelRNG(1).nextLong(); - - if(layerGenerators == null) - { - layerGenerators = new KMap<>(); - } - - if(!layerGenerators.containsKey(key)) - { - synchronized(layerGenerators) - { - layerGenerators.put(key, CNG.signature(rng.nextParallelRNG(minHeight + maxHeight + getBlockData().size()))); - } - } - - return layerGenerators.get(key); + layerGenerators = new KMap<>(); } + + if(!layerGenerators.containsKey(key)) + { + layerGenerators.put(key, CNG.signature(rng.nextParallelRNG(minHeight + maxHeight + getBlockData().size()))); + } + + return layerGenerators.get(key); } public KList add(String b) @@ -53,30 +47,24 @@ public class IrisBiomePaletteLayer public KList getBlockData() { - synchronized(this) + if(blockData == null) { - if(blockData == null) + blockData = new KList<>(); + for(String i : palette) { - blockData = new KList<>(); - synchronized(blockData) + try { - for(String i : palette) + Material m = Material.valueOf(i); + + if(m != null) { - try - { - Material m = Material.valueOf(i); - - if(m != null) - { - blockData.add(m.createBlockData()); - } - } - catch(Throwable e) - { - - } + blockData.add(m.createBlockData()); } } + catch(Throwable e) + { + + } } } diff --git a/src/main/java/ninja/bytecode/iris/object/IrisDimension.java b/src/main/java/ninja/bytecode/iris/object/IrisDimension.java index 502762380..d1b1851ac 100644 --- a/src/main/java/ninja/bytecode/iris/object/IrisDimension.java +++ b/src/main/java/ninja/bytecode/iris/object/IrisDimension.java @@ -3,46 +3,77 @@ package ninja.bytecode.iris.object; import org.bukkit.World.Environment; import lombok.Data; -import ninja.bytecode.iris.Iris; +import ninja.bytecode.iris.util.CNG; import ninja.bytecode.iris.util.KList; +import ninja.bytecode.iris.util.RNG; @Data public class IrisDimension { private String name = "A Dimension"; - private InterpolationMethod interpolationFunction = InterpolationMethod.BILINEAR; - private double interpolationScale = 5.6; + private InterpolationMethod interpolationFunction = InterpolationMethod.BICUBIC; + private double interpolationScale = 63; + private InterpolationMethod interpolationSurfaceFunction = InterpolationMethod.BICUBIC; + private double interpolationSurfaceScale = 4; private Environment environment = Environment.NORMAL; - private KList biomes = new KList<>(); + private KList regions = new KList<>(); private int fluidHeight = 127; private double biomeZoom = 5D; private double terrainZoom = 2D; + private double dimensionAngleDeg = 0; private double roughnessZoom = 2D; private int roughnessHeight = 3; - private transient KList biomeCache; + private double coordFractureDistance = 20; + private double coordFractureZoom = 8; + private double landZoom = 1; + private double shoreZoom = 1; + private double seaZoom = 1; + private double continentZoom = 1; + private double regionZoom = 1; - public KList buildBiomeList() + private transient CNG coordFracture; + private transient Double sinr; + private transient Double cosr; + private transient Double rad; + + public CNG getCoordFracture(RNG rng, int signature) { - if(biomeCache == null) + if(coordFracture == null) { - synchronized(this) - { - biomeCache = new KList<>(); - - synchronized(biomeCache) - { - for(String i : biomes) - { - IrisBiome biome = Iris.data.getBiomeLoader().load(i); - if(biome != null) - { - biomeCache.add(biome); - } - } - } - } + coordFracture = CNG.signature(rng.nextParallelRNG(signature)); + coordFracture.scale(0.012 / coordFractureZoom); } - return biomeCache; + return coordFracture; + } + + public double getDimensionAngle() + { + if(rad == null) + { + rad = Math.toRadians(dimensionAngleDeg); + } + + return rad; + } + + public double sinRotate() + { + if(sinr == null) + { + sinr = Math.sin(getDimensionAngle()); + } + + return sinr; + } + + public double cosRotate() + { + if(cosr == null) + { + cosr = Math.cos(getDimensionAngle()); + } + + return cosr; } } diff --git a/src/main/java/ninja/bytecode/iris/object/IrisRegion.java b/src/main/java/ninja/bytecode/iris/object/IrisRegion.java new file mode 100644 index 000000000..0153c006f --- /dev/null +++ b/src/main/java/ninja/bytecode/iris/object/IrisRegion.java @@ -0,0 +1,15 @@ +package ninja.bytecode.iris.object; + +import lombok.Data; +import ninja.bytecode.iris.util.KList; + +@Data +public class IrisRegion +{ + private String name = "A Region"; + private double shoreRatio = 0.13; + private double biomeImplosionRatio = 0.4; + private KList landBiomes = new KList<>(); + private KList seaBiomes = new KList<>(); + private KList shoreBiomes = new KList<>(); +} diff --git a/src/main/java/ninja/bytecode/iris/util/CNG.java b/src/main/java/ninja/bytecode/iris/util/CNG.java index c41df5b6c..154e0a11b 100644 --- a/src/main/java/ninja/bytecode/iris/util/CNG.java +++ b/src/main/java/ninja/bytecode/iris/util/CNG.java @@ -166,6 +166,18 @@ public class CNG return (int) Math.round(IrisInterpolation.lerp(min, max, noise)); } + public double fitDoubleD(double min, double max, double... dim) + { + if(min == max) + { + return min; + } + + double noise = noise(dim); + + return IrisInterpolation.lerp(min, max, noise); + } + public int fitDoubleExponent(double min, double max, double exponent, double... dim) { if(min == max) diff --git a/src/main/java/ninja/bytecode/iris/util/CellGenerator2D.java b/src/main/java/ninja/bytecode/iris/util/CellGenerator.java similarity index 96% rename from src/main/java/ninja/bytecode/iris/util/CellGenerator2D.java rename to src/main/java/ninja/bytecode/iris/util/CellGenerator.java index 0c7b5157e..2745cd21d 100644 --- a/src/main/java/ninja/bytecode/iris/util/CellGenerator2D.java +++ b/src/main/java/ninja/bytecode/iris/util/CellGenerator.java @@ -6,7 +6,7 @@ import ninja.bytecode.iris.util.FastNoise.CellularDistanceFunction; import ninja.bytecode.iris.util.FastNoise.CellularReturnType; import ninja.bytecode.iris.util.FastNoise.NoiseType; -public class CellGenerator2D +public class CellGenerator { private FastNoise fn; private FastNoise fd; @@ -20,7 +20,7 @@ public class CellGenerator2D @Setter private double shuffle; - public CellGenerator2D(RNG rng) + public CellGenerator(RNG rng) { shuffle = 128; cellScale = 0.73; diff --git a/src/main/java/ninja/bytecode/iris/util/IrisInterpolation.java b/src/main/java/ninja/bytecode/iris/util/IrisInterpolation.java index 277b53fe8..949939e3b 100644 --- a/src/main/java/ninja/bytecode/iris/util/IrisInterpolation.java +++ b/src/main/java/ninja/bytecode/iris/util/IrisInterpolation.java @@ -1,6 +1,7 @@ package ninja.bytecode.iris.util; import ninja.bytecode.iris.object.InterpolationMethod; +import ninja.bytecode.iris.object.IrisDimension; public class IrisInterpolation { @@ -188,26 +189,6 @@ public class IrisInterpolation //@done } - public static double getNoise(InterpolationMethod method, int x, int z, double rad, NoiseProvider n) - { - if(method.equals(InterpolationMethod.BILINEAR)) - { - return getBilinearNoise(x, z, rad, n); - } - - else if(method.equals(InterpolationMethod.BICUBIC)) - { - return getBicubicNoise(x, z, rad, n); - } - - else if(method.equals(InterpolationMethod.HERMITE)) - { - return getHermiteNoise(x, z, rad, n); - } - - return n.noise(x, z); - } - public static double getHermiteNoise(int x, int z, double rad, NoiseProvider n) { int fx = (int) Math.floor(x / rad); @@ -240,10 +221,30 @@ public class IrisInterpolation n.noise(x3, z1), n.noise(x3, z2), n.noise(x3, z3), - px, pz, 0.00001, 0.5); + px, pz, 0.0000000001, 0.5); //@done } + public static double getNoise(InterpolationMethod method, int x, int z, double rad, NoiseProvider n) + { + if(method.equals(InterpolationMethod.BILINEAR)) + { + return getBilinearNoise(x, z, rad, n); + } + + else if(method.equals(InterpolationMethod.BICUBIC)) + { + return getBicubicNoise(x, z, rad, n); + } + + else if(method.equals(InterpolationMethod.HERMITE)) + { + return getHermiteNoise(x, z, rad, n); + } + + return n.noise(x, z); + } + public static double rangeScale(double amin, double amax, double bmin, double bmax, double b) { return amin + ((amax - amin) * ((b - bmin) / (bmax - bmin)));