This commit is contained in:
Daniel Mills 2020-08-02 16:17:02 -04:00
parent 7863660a47
commit b6592582b3
8 changed files with 99 additions and 15 deletions

View File

@ -101,16 +101,18 @@ public abstract class BiomeChunkGenerator extends DimensionChunkGenerator
return getDimension().isInverted() ? ceilingGenerators : generators;
}
protected double getBiomeHeight(double rx, double rz)
protected double getBiomeHeight(double rx, double rz, int x, int z)
{
double h = 0;
IrisRegion region = glBiome.getRegion(rx, rz);
BiomeResult r = glBiome.generateRegionData(rx, rz, x, z, region);
for(IrisGenerator i : getGenerators().values())
{
h += interpolateGenerator(rx, rz, i);
}
return h;
return h + r.getHeightOffset();
}
protected double interpolateGenerator(double rx, double rz, IrisGenerator gen)

View File

@ -40,14 +40,14 @@ public abstract class TerrainChunkGenerator extends ParallelChunkGenerator
private GenLayerCarve glCarve;
private RNG rockRandom;
private int[] cacheHeightMap;
private IrisBiome[] cacheTrueBiome;
private BiomeResult[] cacheTrueBiome;
private ReentrantLock cacheLock;
public TerrainChunkGenerator(String dimensionName, int threads)
{
super(dimensionName, threads);
cacheHeightMap = new int[256];
cacheTrueBiome = new IrisBiome[256];
cacheTrueBiome = new BiomeResult[256];
cachingAllowed = true;
cacheLock = new ReentrantLock();
}
@ -87,7 +87,9 @@ public abstract class TerrainChunkGenerator extends ParallelChunkGenerator
int height = (int) Math.round(noise) + fluidHeight;
boolean carvable = getDimension().isCarving() && height > getDimension().getCarvingMin();
IrisRegion region = sampleRegion(rx, rz);
IrisBiome biome = sampleTrueBiome(rx, rz).getBiome();
BiomeResult biomeResult = sampleTrueBiome(rx, rz);
IrisBiome biome = biomeResult.getBiome();
double airReversal = biomeResult.getHeightOffset();
if(biome == null)
{
@ -98,7 +100,7 @@ public abstract class TerrainChunkGenerator extends ParallelChunkGenerator
{
try
{
cacheTrueBiome[(z << 4) | x] = biome;
cacheTrueBiome[(z << 4) | x] = biomeResult;
cacheHeightMap[(z << 4) | x] = height;
}
@ -115,7 +117,18 @@ public abstract class TerrainChunkGenerator extends ParallelChunkGenerator
KList<Integer> cavernHeights = new KList<>();
int lastCavernHeight = -1;
for(int k = Math.max(height, fluidHeight); k < Math.max(height, fluidHeight) + 3; k++)
if(height > fluidHeight && airReversal < 0 && biomeResult.getAir() != null && biomeResult.getAir().getBlockData().isNotEmpty())
{
RNG randomx = masterRandom.nextParallelRNG(95288);
int realHeight = (int) Math.floor(height - airReversal);
for(int k = height + 1; k < realHeight; k++)
{
sliver.set(k, biomeResult.getAir().get(randomx, wx, k, wz));
}
}
for(int k = Math.max(height, fluidHeight); k < Math.max(height, fluidHeight) + 3 + Math.abs(airReversal); k++)
{
if(k < Math.max(height, fluidHeight) + 3)
{
@ -474,7 +487,7 @@ public abstract class TerrainChunkGenerator extends ParallelChunkGenerator
double wx = getZoomed(rx);
double wz = getZoomed(rz);
return getBiomeHeight(wx, wz);
return getBiomeHeight(wx, wz, rx, rz);
}
public BiomeResult sampleTrueBiomeBase(int x, int z)
@ -552,7 +565,7 @@ public abstract class TerrainChunkGenerator extends ParallelChunkGenerator
if(isSafe() && x >> 4 == cacheX && z >> 4 == cacheZ)
{
return new BiomeResult(cacheTrueBiome[((z & 15) << 4) | (x & 15)], 0);
return cacheTrueBiome[((z & 15) << 4) | (x & 15)];
}
double wx = getModifiedX(x, z);

View File

@ -147,7 +147,7 @@ public class GenLayerBiome extends GenLayer
{
if(i.getType().equals(type) && i.isRidge(rng, rawX, rawZ))
{
return new BiomeResult(Iris.data.getBiomeLoader().load(i.getBiome()).infer(i.getAs(), type), 0.5);
return new BiomeResult(Iris.data.getBiomeLoader().load(i.getBiome()).infer(i.getAs(), type), 0.5, i.getRidgeHeight(rng, rawX, rawZ), i.getAir());
}
}
@ -155,7 +155,7 @@ public class GenLayerBiome extends GenLayer
{
if(i.getType().equals(type) && i.isSpot(rng, rawX, rawZ))
{
return new BiomeResult(Iris.data.getBiomeLoader().load(i.getBiome()).infer(i.getAs(), type), 0.5);
return new BiomeResult(Iris.data.getBiomeLoader().load(i.getBiome()).infer(i.getAs(), type), 0.5, i.getSpotHeight(rng, rawX, rawZ), i.getAir());
}
}

View File

@ -6,7 +6,7 @@ public enum Dispersion
{
@DontObfuscate
SCATTER,
@DontObfuscate
WISPY,
WISPY;
}

View File

@ -176,7 +176,7 @@ public class IrisDepositGenerator
int x = rng.i(af, bf);
int z = rng.i(af, bf);
int height = (int) (Math.round(g.getTerrainWaterHeight(x, z))) - 5;
int height = (int) (Math.round(g.getTerrainWaterHeight(x, z))) - 2;
if(height <= 0)
{
@ -204,7 +204,7 @@ public class IrisDepositGenerator
int ny = j.getBlockY() + h;
int nz = j.getBlockZ() + z;
if(nx > 15 || nx < 0 || ny > 255 || ny < 0 || nz < 0 || nz > 15)
if(ny > height || nx > 15 || nx < 0 || ny > 255 || ny < 0 || nz < 0 || nz > 15)
{
continue;
}

View File

@ -23,6 +23,10 @@ public class IrisRegionRidge
@Desc("What type this spot is (i.e. target SEA but as LAND) like an island. Default matches the target type")
private InferredType as = InferredType.DEFER;
@DontObfuscate
@Desc("Use the distance from cell value to add or remove noise value. (Forces depth or height)")
private double noiseMultiplier = 0;
@DontObfuscate
@Desc("The chance this biome will be placed in a given spot")
private double chance = 0.75;
@ -47,6 +51,10 @@ public class IrisRegionRidge
@Desc("The thickness of the vein")
private double thickness = 0.125;
@DontObfuscate
@Desc("If the noise multiplier is below zero, what should the air be filled with?")
private IrisBiomePaletteLayer air = new IrisBiomePaletteLayer().zero();
private transient CellGenerator spot;
private transient CellGenerator ridge;
@ -55,6 +63,30 @@ public class IrisRegionRidge
}
public double getRidgeHeight(RNG rng, double x, double z)
{
if(getNoiseMultiplier() == 0)
{
return 0;
}
if(ridge == null)
{
ridge = new CellGenerator(rng.nextParallelRNG((int) (465583 * getChance())));
ridge.setCellScale(scale);
ridge.setShuffle(shuffle);
}
if(spot == null)
{
spot = new CellGenerator(rng.nextParallelRNG((int) (198523 * getChance())));
spot.setCellScale(chanceScale);
spot.setShuffle(shuffle);
}
return spot.getDistance(x, z) * ridge.getDistance(x, z) * getNoiseMultiplier();
}
public boolean isRidge(RNG rng, double x, double z)
{
if(ridge == null)

View File

@ -23,6 +23,10 @@ public class IrisRegionSpot
@Desc("What type this spot is (i.e. target SEA but as LAND) like an island. Default matches the target type")
private InferredType as = InferredType.DEFER;
@DontObfuscate
@Desc("Use the distance from cell value to add or remove noise value. (Forces depth or height)")
private double noiseMultiplier = 0;
@DontObfuscate
@Desc("The scale of splotches")
private double scale = 1;
@ -35,6 +39,10 @@ public class IrisRegionSpot
@Desc("The shuffle or how natural the splotch looks like (anti-polygon)")
private double shuffle = 128;
@DontObfuscate
@Desc("If the noise multiplier is below zero, what should the air be filled with?")
private IrisBiomePaletteLayer air = new IrisBiomePaletteLayer().zero();
private transient CellGenerator spot;
public IrisRegionSpot()
@ -42,6 +50,23 @@ public class IrisRegionSpot
}
public double getSpotHeight(RNG rng, double x, double z)
{
if(getNoiseMultiplier() == 0)
{
return 0;
}
if(spot == null)
{
spot = new CellGenerator(rng.nextParallelRNG((int) (168583 * (shuffle + 102) + rarity + (scale * 10465) + biome.length() + type.ordinal() + as.ordinal())));
spot.setCellScale(scale);
spot.setShuffle(shuffle);
}
return spot.getDistance(x, z) * getNoiseMultiplier();
}
public boolean isSpot(RNG rng, double x, double z)
{
if(spot == null)

View File

@ -1,6 +1,7 @@
package com.volmit.iris.util;
import com.volmit.iris.object.IrisBiome;
import com.volmit.iris.object.IrisBiomePaletteLayer;
import lombok.Data;
@ -8,12 +9,23 @@ import lombok.Data;
public class BiomeResult
{
private IrisBiome biome;
private IrisBiomePaletteLayer air;
private double heightOffset;
private double distance;
public BiomeResult(IrisBiome biome, double distance)
{
this.biome = biome;
this.distance = distance;
this.heightOffset = 0;
}
public BiomeResult(IrisBiome biome, double distance, double height, IrisBiomePaletteLayer air)
{
this.biome = biome;
this.distance = distance;
this.heightOffset = height;
this.air = air;
}
public boolean is(BiomeResult r)