This commit is contained in:
Daniel Mills 2020-08-16 21:14:40 -04:00
parent c07b4e9f98
commit 0c5855a82d
5 changed files with 189 additions and 108 deletions

View File

@ -144,11 +144,15 @@ public abstract class TerrainChunkGenerator extends ParallelChunkGenerator
for(int kv = Math.max(height, fluidHeight); kv < Math.min(Math.max(height, fluidHeight) + 16, 255); kv++) for(int kv = Math.max(height, fluidHeight); kv < Math.min(Math.max(height, fluidHeight) + 16, 255); kv++)
{ {
Biome skyBiome = biome.getSkyBiome(masterRandom, rz, kv, rx); Biome skyBiome = biome.getSkyBiome(masterRandom, rz, kv, rx);
sliver.set(kv, biome.getDerivative()); sliver.set(kv, skyBiome);
sliver.set(k, skyBiome);
} }
} }
if(k <= Math.max(height, fluidHeight))
{
sliver.set(k, biome.getGroundBiome(masterRandom, rz, k, rx));
}
// Set Sea Material (water/lava) // Set Sea Material (water/lava)
if(underwater) if(underwater)
{ {

View File

@ -5,11 +5,11 @@ import org.bukkit.block.data.BlockData;
import com.volmit.iris.gen.DimensionChunkGenerator; import com.volmit.iris.gen.DimensionChunkGenerator;
import com.volmit.iris.gen.atomics.AtomicSliver; import com.volmit.iris.gen.atomics.AtomicSliver;
import com.volmit.iris.noise.CNG;
import com.volmit.iris.noise.FastNoise; import com.volmit.iris.noise.FastNoise;
import com.volmit.iris.noise.FastNoise.CellularDistanceFunction; import com.volmit.iris.noise.FastNoise.CellularDistanceFunction;
import com.volmit.iris.noise.FastNoise.CellularReturnType; import com.volmit.iris.noise.FastNoise.CellularReturnType;
import com.volmit.iris.noise.FastNoise.NoiseType; import com.volmit.iris.noise.FastNoise.NoiseType;
import com.volmit.iris.object.IrisCaveLayer;
import com.volmit.iris.util.B; import com.volmit.iris.util.B;
import com.volmit.iris.util.CaveResult; import com.volmit.iris.util.CaveResult;
import com.volmit.iris.util.GenLayer; import com.volmit.iris.util.GenLayer;
@ -21,16 +21,12 @@ public class GenLayerCave extends GenLayer
public static final BlockData CAVE_AIR = B.getBlockData("CAVE_AIR"); public static final BlockData CAVE_AIR = B.getBlockData("CAVE_AIR");
public static final BlockData AIR = B.getBlockData("AIR"); public static final BlockData AIR = B.getBlockData("AIR");
private static final KList<CaveResult> EMPTY = new KList<>(); private static final KList<CaveResult> EMPTY = new KList<>();
private CNG gincline;
private CNG shuffle;
private FastNoise gg; private FastNoise gg;
public GenLayerCave(DimensionChunkGenerator iris, RNG rng) public GenLayerCave(DimensionChunkGenerator iris, RNG rng)
{ {
//@builder //@builder
super(iris, rng); super(iris, rng);
shuffle = CNG.signature(rng.nextParallelRNG(1348566));
gincline = new CNG(rng.nextParallelRNG(26512), 1D, 3).scale(0.00452);
gg = new FastNoise(324895 * rng.nextParallelRNG(49678).imax()); gg = new FastNoise(324895 * rng.nextParallelRNG(49678).imax());
//@done //@done
} }
@ -42,35 +38,41 @@ public class GenLayerCave extends GenLayer
return EMPTY; return EMPTY;
} }
int surface = data.getHighestBlock();
KList<CaveResult> result = new KList<>(); KList<CaveResult> result = new KList<>();
shuffle.scale(0.01);
double shuffleDistance = 72;
gg.SetNoiseType(NoiseType.Cellular); gg.SetNoiseType(NoiseType.Cellular);
gg.SetCellularReturnType(CellularReturnType.Distance2Sub); gg.SetCellularReturnType(CellularReturnType.Distance2Sub);
gg.SetCellularDistanceFunction(CellularDistanceFunction.Natural); gg.SetCellularDistanceFunction(CellularDistanceFunction.Natural);
for(int i = 0; i < 3; i++) for(int i = 0; i < iris.getDimension().getCaveLayers().size(); i++)
{ {
double wx = wxx + (shuffle.noise(wxx, wzz) * shuffleDistance); IrisCaveLayer layer = iris.getDimension().getCaveLayers().get(i);
double wz = wzz + (shuffle.noise(wzz, wxx) * shuffleDistance); generateCave(result, wxx, wzz, x, z, data, layer, i);
double incline = 157; }
double baseWidth = (14 * iris.getDimension().getCaveScale());
return result;
}
public void generateCave(KList<CaveResult> result, double wxx, double wzz, int x, int z, AtomicSliver data, IrisCaveLayer layer, int seed)
{
double scale = layer.getCaveZoom();
int surface = data.getHighestBlock();
double wx = wxx + layer.getHorizontalSlope().get(rng, wxx, wzz);
double wz = wzz + layer.getHorizontalSlope().get(rng, -wzz, -wxx);
double baseWidth = (14 * scale);
double distanceCheck = 0.0132 * baseWidth; double distanceCheck = 0.0132 * baseWidth;
double distanceTake = 0.0022 * baseWidth; double distanceTake = 0.0022 * baseWidth;
double drop = (-i * 17) + 44 + iris.getDimension().getCaveShift(); double caveHeightNoise = layer.getVerticalSlope().get(rng, wxx, wzz);
double caveHeightNoise = incline * gincline.noise((wx + (10000 * i)), (wz - (10000 * i)));
caveHeightNoise += shuffle.fitDouble(-1, 1, wxx - caveHeightNoise, wzz + caveHeightNoise) * 3;
int ceiling = -256; int ceiling = -256;
int floor = 512; int floor = 512;
for(double tunnelHeight = 1; tunnelHeight <= baseWidth; tunnelHeight++) for(double tunnelHeight = 1; tunnelHeight <= baseWidth; tunnelHeight++)
{ {
double distance = (gg.GetCellular((float) wx + (10000 * i), (float) wz - (10000 * i)) + 1D) / 2D; double distance = (gg.GetCellular((float) ((wx + (10000 * seed)) / layer.getCaveZoom()), (float) ((wz - (10000 * seed)) / layer.getCaveZoom())) + 1D) / 2D;
if(distance < distanceCheck - (tunnelHeight * distanceTake)) if(distance < distanceCheck - (tunnelHeight * distanceTake))
{ {
int caveHeight = (int) Math.round(caveHeightNoise - drop); int caveHeight = (int) Math.round(caveHeightNoise);
int pu = (int) (caveHeight + tunnelHeight); int pu = (int) (caveHeight + tunnelHeight);
int pd = (int) (caveHeight - tunnelHeight); int pd = (int) (caveHeight - tunnelHeight);
@ -79,6 +81,11 @@ public class GenLayerCave extends GenLayer
continue; continue;
} }
if(!layer.isCanBreakSurface() && pu > surface - 3)
{
continue;
}
if((pu > 255 && pd > 255) || (pu < 0 && pd < 0)) if((pu > 255 && pd > 255) || (pu < 0 && pd < 0))
{ {
continue; continue;
@ -151,9 +158,6 @@ public class GenLayerCave extends GenLayer
} }
} }
return result;
}
public boolean dig(int x, int y, int z, AtomicSliver data) public boolean dig(int x, int y, int z, AtomicSliver data)
{ {
Material a = data.getType(y); Material a = data.getType(y);

View File

@ -0,0 +1,42 @@
package com.volmit.iris.object;
import com.volmit.iris.util.Desc;
import com.volmit.iris.util.DontObfuscate;
import com.volmit.iris.util.MinNumber;
import com.volmit.iris.util.Required;
import lombok.Data;
@Desc("Translate objects")
@Data
public class IrisCaveLayer
{
@Required
@DontObfuscate
@Desc("The vertical slope this cave layer follows")
private IrisShapedGeneratorStyle verticalSlope = new IrisShapedGeneratorStyle();
@Required
@DontObfuscate
@Desc("The horizontal slope this cave layer follows")
private IrisShapedGeneratorStyle horizontalSlope = new IrisShapedGeneratorStyle();
@MinNumber(0.001)
@DontObfuscate
@Desc("The cave zoom. Higher values makes caves spread out further and branch less often, but are thicker.")
private double caveZoom = 1D;
@MinNumber(0.001)
@DontObfuscate
@Desc("The cave thickness.")
private double caveThickness = 1D;
@DontObfuscate
@Desc("If set to true, this cave layer can break the surface")
private boolean canBreakSurface = false;
public IrisCaveLayer()
{
}
}

View File

@ -43,24 +43,12 @@ public class IrisDimension extends IrisRegistrant
@Desc("The human readable name of this dimension") @Desc("The human readable name of this dimension")
private String name = "A Dimension"; private String name = "A Dimension";
@MinNumber(0.0001)
@MaxNumber(64)
@DontObfuscate
@Desc("The Thickness scale of cave veins")
private double caveThickness = 1D;
@Required @Required
@MinNumber(0) @MinNumber(0)
@DontObfuscate @DontObfuscate
@Desc("The version of this dimension. Changing this will stop users from accidentally upgrading (and breaking their worlds).") @Desc("The version of this dimension. Changing this will stop users from accidentally upgrading (and breaking their worlds).")
private int version = 1; private int version = 1;
@MinNumber(0.0001)
@MaxNumber(512)
@DontObfuscate
@Desc("The cave web scale. Smaller values means scaled up vein networks.")
private double caveScale = 1D;
@DontObfuscate @DontObfuscate
@Desc("The placement style of regions") @Desc("The placement style of regions")
private IrisGeneratorStyle regionStyle = NoiseStyle.CELLULAR_IRIS_DOUBLE.style(); private IrisGeneratorStyle regionStyle = NoiseStyle.CELLULAR_IRIS_DOUBLE.style();
@ -93,12 +81,6 @@ public class IrisDimension extends IrisRegistrant
@Desc("The placement style of biomes") @Desc("The placement style of biomes")
private IrisGeneratorStyle skylandBiomeStyle = NoiseStyle.CELLULAR_IRIS_DOUBLE.style(); private IrisGeneratorStyle skylandBiomeStyle = NoiseStyle.CELLULAR_IRIS_DOUBLE.style();
@MinNumber(-256)
@MaxNumber(256)
@DontObfuscate
@Desc("Shift the Y value of the cave networks up or down.")
private double caveShift = 0D;
@DontObfuscate @DontObfuscate
@Desc("Generate caves or not.") @Desc("Generate caves or not.")
private boolean caves = true; private boolean caves = true;
@ -267,6 +249,11 @@ public class IrisDimension extends IrisRegistrant
@Desc("The noise style for rock types") @Desc("The noise style for rock types")
private IrisGeneratorStyle rockStyle = NoiseStyle.STATIC.style(); private IrisGeneratorStyle rockStyle = NoiseStyle.STATIC.style();
@ArrayType(min = 1, type = IrisCaveLayer.class)
@DontObfuscate
@Desc("Define cave layers")
private KList<IrisCaveLayer> caveLayers = new KList<>();
@DontObfuscate @DontObfuscate
@Desc("The noise style for fluid types") @Desc("The noise style for fluid types")
private IrisGeneratorStyle fluidStyle = NoiseStyle.STATIC.style(); private IrisGeneratorStyle fluidStyle = NoiseStyle.STATIC.style();
@ -509,7 +496,7 @@ public class IrisDimension extends IrisRegistrant
{ {
return rockLayerGenerator.aquire(() -> return rockLayerGenerator.aquire(() ->
{ {
RNG rngx = rng.nextParallelRNG((int) (getRockData().size() * getRegions().size() * getCaveScale() * getLandZoom() * 10357)); RNG rngx = rng.nextParallelRNG((int) (getRockData().size() * getRegions().size() * getLandZoom() * 10357));
return rockStyle.create(rngx); return rockStyle.create(rngx);
}); });
} }
@ -551,7 +538,7 @@ public class IrisDimension extends IrisRegistrant
{ {
return fluidLayerGenerator.aquire(() -> return fluidLayerGenerator.aquire(() ->
{ {
RNG rngx = rng.nextParallelRNG(getFluidData().size() * (int) (getRockData().size() * getRegions().size() * getCaveScale() * getLandZoom() * 10357)); RNG rngx = rng.nextParallelRNG(getFluidData().size() * (int) (getRockData().size() * getRegions().size() * getLandZoom() * 10357));
return fluidStyle.create(rngx); return fluidStyle.create(rngx);
}); });
} }

View File

@ -0,0 +1,44 @@
package com.volmit.iris.object;
import com.volmit.iris.util.Desc;
import com.volmit.iris.util.DontObfuscate;
import com.volmit.iris.util.MaxNumber;
import com.volmit.iris.util.MinNumber;
import com.volmit.iris.util.RNG;
import com.volmit.iris.util.Required;
import lombok.Data;
@Desc("This represents a generator with a min and max height")
@Data
public class IrisShapedGeneratorStyle
{
@Required
@DontObfuscate
@Desc("The generator id")
private IrisGeneratorStyle generator = new IrisGeneratorStyle(NoiseStyle.IRIS);
@Required
@MinNumber(-256)
@MaxNumber(256)
@DontObfuscate
@Desc("The min block value")
private int min = 0;
@Required
@MinNumber(-256)
@MaxNumber(256)
@DontObfuscate
@Desc("The max block value")
private int max = 0;
public double get(RNG rng, double... dim)
{
return generator.create(rng).fitDouble(min, max, dim);
}
public IrisShapedGeneratorStyle()
{
}
}