9
0
mirror of https://github.com/VolmitSoftware/Iris.git synced 2025-12-30 12:29:20 +00:00

Supercarves

This commit is contained in:
Daniel Mills
2020-09-03 03:59:03 -04:00
parent 3663b9f957
commit 607a7be337
13 changed files with 274 additions and 99 deletions

View File

@@ -0,0 +1,60 @@
package com.volmit.iris.object;
import com.volmit.iris.gen.atomics.AtomicCache;
import com.volmit.iris.noise.CNG;
import com.volmit.iris.util.Desc;
import com.volmit.iris.util.DontObfuscate;
import com.volmit.iris.util.IrisInterpolation;
import com.volmit.iris.util.M;
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("Translate objects")
@Data
public class IrisCarveLayer
{
@Required
@DontObfuscate
@Desc("The 4d slope this carve layer follows")
private IrisGeneratorStyle style = new IrisGeneratorStyle();
@MaxNumber(512)
@MinNumber(-128)
@DontObfuscate
@Desc("The max height")
private int maxHeight = 220;
@MaxNumber(512)
@MinNumber(-128)
@DontObfuscate
@Desc("The min height")
private int minHeight = 147;
@MaxNumber(1)
@MinNumber(0)
@DontObfuscate
@Desc("The threshold used as: \n\ncarved = noise(x,y,z) > threshold")
private double threshold = 0.5;
private transient AtomicCache<CNG> cng = new AtomicCache<>();
public IrisCarveLayer()
{
}
public boolean isCarved(RNG rng, double x, double y, double z)
{
if(y > getMaxHeight() || y < getMinHeight())
{
return false;
}
double opacity = Math.pow(IrisInterpolation.sinCenter(M.lerpInverse(getMinHeight(), getMaxHeight(), y)), 4);
return cng.aquire(() -> getStyle().create(rng.nextParallelRNG(-2340 * getMaxHeight() * getMinHeight()))).fitDouble(0D, 1D, x, y, z) * opacity > getThreshold();
}
}

View File

@@ -170,7 +170,7 @@ public class IrisDepositGenerator
int x = rng.i(af, bf);
int z = rng.i(af, bf);
int height = (int) (Math.round(g.getTerrainHeight((cx << 4) + x, (cz << 4) + z))) - 7;
int height = (int) (Math.round(g.getCarvedWaterHeight((cx << 4) + x, (cz << 4) + z))) - 7;
if(height <= 0)
{

View File

@@ -130,40 +130,6 @@ public class IrisDimension extends IrisRegistrant
@Desc("Generate caves or not.")
private boolean caves = true;
@DontObfuscate
@Desc("Carve terrain or not")
private double carvingZoom = 3.5;
@MinNumber(-256)
@MaxNumber(256)
@DontObfuscate
@Desc("Carving starts at this height")
private int carvingMin = 115;
@MinNumber(-256)
@MaxNumber(256)
@DontObfuscate
@Desc("The maximum height carving happens at")
private int carvingMax = 239;
@MinNumber(0.0001)
@MaxNumber(256)
@DontObfuscate
@Desc("The thickness of carvings (vertical)")
private double carvingSliverThickness = 5.5D;
@MinNumber(0.0001)
@MaxNumber(512)
@DontObfuscate
@Desc("The thickness of ripples on carved walls")
private double carvingRippleThickness = 3D;
@MinNumber(0.0001)
@MaxNumber(512)
@DontObfuscate
@Desc("How much of 3D space is carved out. Higher values make carvings cross into 3d space more often (bigger)")
private double carvingEnvelope = 0.335D;
@DontObfuscate
@Desc("Carve terrain or not")
private boolean carving = true;
@@ -290,6 +256,11 @@ public class IrisDimension extends IrisRegistrant
@Desc("Define cave layers")
private KList<IrisCaveLayer> caveLayers = new KList<>();
@ArrayType(min = 1, type = IrisCarveLayer.class)
@DontObfuscate
@Desc("Define carve layers")
private KList<IrisCarveLayer> carveLayers = new KList<>();
@DontObfuscate
@Desc("The noise style for fluid types")
private IrisGeneratorStyle fluidStyle = NoiseStyle.STATIC.style();

View File

@@ -120,7 +120,7 @@ public class IrisStructurePlacement
public void placeLayer(ParallaxChunkGenerator g, RNG rng, RNG rnp, int i, int k, int j, int s, int sh)
{
if(!hasStructure(rng, i, k, j))
if(!hasStructure(g, rng, i, k, j))
{
return;
}
@@ -176,8 +176,13 @@ public class IrisStructurePlacement
return structure.aquire(() -> (g == null ? Iris.globaldata : g.getData()).getStructureLoader().load(getTileset()));
}
public boolean hasStructure(RNG random, double x, double y, double z)
public boolean hasStructure(ParallaxChunkGenerator g, RNG random, double x, double y, double z)
{
if(g.getGlCarve().isCarved((int) x, (int) y, (int) z))
{
return false;
}
if(getChanceGenerator(random).getIndex(x / zoom, y / zoom, z / zoom, getRarity()) == getRarity() / 2)
{
return ratio > 0 ? getChanceGenerator(random).getDistance(x / zoom, z / zoom) > ratio : getChanceGenerator(random).getDistance(x / zoom, z / zoom) < Math.abs(ratio);