Remove Caves, Carving & Ravines

This commit is contained in:
cyberpwn
2021-08-27 04:48:00 -04:00
parent a51f5fefc4
commit 3dcfacfeed
16 changed files with 11 additions and 1286 deletions

View File

@@ -1,112 +0,0 @@
/*
* Iris is a World Generator for Minecraft Bukkit Servers
* Copyright (c) 2021 Arcane Arts (Volmit Software)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.volmit.iris.engine.object.carve;
import com.volmit.iris.core.loader.IrisData;
import com.volmit.iris.engine.data.cache.AtomicCache;
import com.volmit.iris.engine.object.annotations.Desc;
import com.volmit.iris.engine.object.annotations.MaxNumber;
import com.volmit.iris.engine.object.annotations.MinNumber;
import com.volmit.iris.engine.object.annotations.Required;
import com.volmit.iris.engine.object.noise.IrisGeneratorStyle;
import com.volmit.iris.util.interpolation.IrisInterpolation;
import com.volmit.iris.util.math.M;
import com.volmit.iris.util.math.RNG;
import com.volmit.iris.util.noise.CNG;
import com.volmit.iris.util.stream.ProceduralStream;
import com.volmit.iris.util.stream.interpolation.Interpolated;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
@Accessors(chain = true)
@NoArgsConstructor
@AllArgsConstructor
@Desc("Translate objects")
@Data
public class IrisCarveLayer {
@Required
@Desc("The 4d slope this carve layer follows")
private IrisGeneratorStyle style = new IrisGeneratorStyle();
@MaxNumber(512)
@MinNumber(-128)
@Desc("The max height")
private int maxHeight = 220;
@MinNumber(0.0)
@MaxNumber(1.0)
@Desc("The full percentage means the 4D opacity of this carver will decay from 100% to 0% at the min & max vertical ranges. Setting the percent to 1.0 will make a very drastic & charp change at the edge of the vertical min & max. Where as 0.15 means only 15% of the vertical range will actually be 100% opacity.")
private double fullPercent = 0.5;
@MaxNumber(512)
@MinNumber(-128)
@Desc("The min height")
private int minHeight = 147;
@MaxNumber(1)
@MinNumber(0)
@Desc("The threshold used as: \n\ncarved = noise(x,y,z) > threshold")
private double threshold = 0.5;
private final transient AtomicCache<ProceduralStream<Boolean>> streamCache = new AtomicCache<>();
private final transient AtomicCache<ProceduralStream<Double>> rawStreamCache = new AtomicCache<>();
private final transient AtomicCache<CNG> cng = new AtomicCache<>();
public boolean isCarved(RNG rng, IrisData data, 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 getCng(rng, data).fitDouble(0D, 1D, x, y, z) * opacity > getThreshold();
}
public ProceduralStream<Boolean> stream(RNG rng, IrisData data) {
return streamCache.aquire(() -> ProceduralStream.of((x, y, z) -> isCarved(rng, data, x, y, z), Interpolated.BOOLEAN));
}
public ProceduralStream<Double> rawStream(RNG rng, IrisData data) {
return rawStreamCache.aquire(() -> ProceduralStream.of((x, y, z) -> {
return getCng(rng, data).fitDouble(0D, 1D, x, y, z) * Math.pow(IrisInterpolation.sinCenter(M.lerpInverse(getMinHeight(), getMaxHeight(), y)), 4);
}, Interpolated.DOUBLE));
}
public CNG getCng(RNG rng, IrisData data) {
return cng.aquire(() -> getStyle().create(rng.nextParallelRNG(-2340 * getMaxHeight() * getMinHeight()), data));
}
public boolean isCarved2(RNG rng, IrisData data, double x, double y, double z) {
if (y > getMaxHeight() || y < getMinHeight()) {
return false;
}
double innerRange = fullPercent * (maxHeight - minHeight);
double opacity = 1D;
if (y <= minHeight + innerRange) {
opacity = IrisInterpolation.bezier(M.lerpInverse(getMinHeight(), minHeight + innerRange, y));
} else if (y >= maxHeight - innerRange) {
opacity = IrisInterpolation.bezier(1D - M.lerpInverse(maxHeight - innerRange, getMaxHeight(), y));
}
return cng.aquire(() -> getStyle().create(rng.nextParallelRNG(-2340 * getMaxHeight() * getMinHeight()), data)).fitDouble(0D, 1D, x, y, z) * opacity > getThreshold();
}
}

View File

@@ -1,72 +0,0 @@
/*
* Iris is a World Generator for Minecraft Bukkit Servers
* Copyright (c) 2021 Arcane Arts (Volmit Software)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.volmit.iris.engine.object.carve;
import com.volmit.iris.core.loader.IrisData;
import com.volmit.iris.engine.data.cache.AtomicCache;
import com.volmit.iris.engine.object.annotations.Desc;
import com.volmit.iris.engine.object.annotations.MaxNumber;
import com.volmit.iris.engine.object.annotations.MinNumber;
import com.volmit.iris.engine.object.annotations.Required;
import com.volmit.iris.engine.object.block.IrisBlockData;
import com.volmit.iris.util.data.B;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import org.bukkit.block.data.BlockData;
@Accessors(chain = true)
@NoArgsConstructor
@AllArgsConstructor
@Desc("Translate objects")
@Data
public class IrisCaveFluid {
@Required
@MaxNumber(255)
@MinNumber(0)
@Desc("The fluid height of the cave")
private int fluidHeight = 35;
@Desc("Insead of fluidHeight & below being fluid, turning inverse height on will simply spawn fluid in this cave layer from min(max_height, cave_height) to the fluid height. Basically, fluid will spawn above the fluidHeight value instead of below the fluidHeight.")
private boolean inverseHeight = false;
@Required
@Desc("The fluid type that should spawn here")
private IrisBlockData fluidType = new IrisBlockData("CAVE_AIR");
private final transient AtomicCache<BlockData> fluidData = new AtomicCache<>();
public boolean hasFluid(IrisData rdata) {
return !B.isAir(getFluid(rdata));
}
public BlockData getFluid(IrisData rdata) {
return fluidData.aquire(() ->
{
BlockData b = getFluidType().getBlockData(rdata);
if (b != null) {
return b;
}
return B.get("CAVE_AIR");
});
}
}

View File

@@ -1,58 +0,0 @@
/*
* Iris is a World Generator for Minecraft Bukkit Servers
* Copyright (c) 2021 Arcane Arts (Volmit Software)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.volmit.iris.engine.object.carve;
import com.volmit.iris.engine.object.annotations.Desc;
import com.volmit.iris.engine.object.annotations.MinNumber;
import com.volmit.iris.engine.object.annotations.Required;
import com.volmit.iris.engine.object.noise.IrisShapedGeneratorStyle;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
@Accessors(chain = true)
@NoArgsConstructor
@AllArgsConstructor
@Desc("Translate objects")
@Data
public class IrisCaveLayer {
@Required
@Desc("The vertical slope this cave layer follows")
private IrisShapedGeneratorStyle verticalSlope = new IrisShapedGeneratorStyle();
@Required
@Desc("The horizontal slope this cave layer follows")
private IrisShapedGeneratorStyle horizontalSlope = new IrisShapedGeneratorStyle();
@Desc("If defined, a cave fluid will fill this cave below (or above) the specified fluidHeight in this object.")
private IrisCaveFluid fluid = new IrisCaveFluid();
@MinNumber(0.001)
@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)
@Desc("The cave thickness.")
private double caveThickness = 1D;
@Desc("If set to true, this cave layer can break the surface")
private boolean canBreakSurface = false;
}

View File

@@ -1,69 +0,0 @@
/*
* Iris is a World Generator for Minecraft Bukkit Servers
* Copyright (c) 2021 Arcane Arts (Volmit Software)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.volmit.iris.engine.object.carve;
import com.volmit.iris.core.loader.IrisData;
import com.volmit.iris.engine.data.cache.AtomicCache;
import com.volmit.iris.engine.object.annotations.Desc;
import com.volmit.iris.engine.object.annotations.MaxNumber;
import com.volmit.iris.engine.object.annotations.MinNumber;
import com.volmit.iris.engine.object.common.IRare;
import com.volmit.iris.engine.object.noise.IrisGeneratorStyle;
import com.volmit.iris.util.math.RNG;
import com.volmit.iris.util.stream.ProceduralStream;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
@Accessors(chain = true)
@NoArgsConstructor
@AllArgsConstructor
@Desc("Represents a cavern zone")
@Data
public class IrisCavernZone implements IRare {
@Desc("Use carving in this zone if defined")
private IrisCarveLayer carver = null;
@Desc("Use worley styled caves if defined")
private IrisGeneratorStyle worley = null;
@MinNumber(1)
@MaxNumber(100)
@Desc("The rarity of this zone")
private int rarity = 1;
private transient AtomicCache<ProceduralStream<Boolean>> carveCache = new AtomicCache<>();
public boolean isCarved(RNG rng, IrisData data, double xx, double yy, double zz) {
if (carver != null) {
return carver.isCarved(rng, data, xx, yy, zz);
}
return false;
}
public double getCarved(RNG rng, IrisData data, double xx, double yy, double zz) {
if (carver != null) {
return carver.rawStream(rng, data).get(xx, yy, zz) / (carver.getThreshold() * 2);
}
return -1;
}
}

View File

@@ -1,96 +0,0 @@
/*
* Iris is a World Generator for Minecraft Bukkit Servers
* Copyright (c) 2021 Arcane Arts (Volmit Software)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.volmit.iris.engine.object.carve;
import com.volmit.iris.core.loader.IrisData;
import com.volmit.iris.engine.data.cache.AtomicCache;
import com.volmit.iris.engine.object.annotations.ArrayType;
import com.volmit.iris.engine.object.annotations.Desc;
import com.volmit.iris.engine.object.noise.IrisGeneratorStyle;
import com.volmit.iris.engine.object.noise.IrisInterpolator3D;
import com.volmit.iris.engine.object.noise.NoiseStyle;
import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.math.RNG;
import com.volmit.iris.util.stream.ProceduralStream;
import com.volmit.iris.util.stream.interpolation.Interpolated;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
@Accessors(chain = true)
@NoArgsConstructor
@AllArgsConstructor
@Desc("Represents a cavern system")
@Data
public class IrisCaverns {
@ArrayType(type = IrisCavernZone.class, min = 1)
@Desc("Define different cavern zones")
private KList<IrisCavernZone> zones = new KList<>();
@Desc("The 3D interpolator to connect caverns")
private IrisInterpolator3D interpolator = new IrisInterpolator3D();
@Desc("Defines how cavern zones are placed in the world")
private IrisGeneratorStyle zoneStyle = new IrisGeneratorStyle(NoiseStyle.CELLULAR);
@Desc("Threshold defined")
private double bottomBleed = 16;
@Desc("Threshold defined")
private double topBleed = 16;
@Desc("If set to true (default) iris will interpolate the noise before checking if it meets the threshold.")
private boolean preThresholdInterpolation = true;
private transient AtomicCache<ProceduralStream<IrisCavernZone>> zonesRarity = new AtomicCache<>();
private transient AtomicCache<ProceduralStream<Double>> streamCache = new AtomicCache<>();
public IrisCavernZone getZone(double x, double y, double z, RNG rng, IrisData data) {
return zonesRarity.aquire(() -> zoneStyle.create(rng, data)
.stream().selectRarity(getZones())).get(x, y, z);
}
private double threshold(double y) {
return 0.5;
}
public ProceduralStream<Double> stream(RNG rng, IrisData data) {
if (preThresholdInterpolation) {
return streamCache.aquire(() -> ProceduralStream.of((xx, yy, zz)
-> (getZone(xx, yy, zz, rng, data)
.getCarved(rng, data, xx, yy, zz)), Interpolated.DOUBLE)
.cache3D(65535));
}
return streamCache.aquire(() -> ProceduralStream.of((xx, yy, zz)
-> (getZone(xx, yy, zz, rng, data)
.isCarved(rng, data, xx, yy, zz) ? 1D : 0D), Interpolated.DOUBLE)
.cache3D(65535));
}
public boolean isCavern(RNG rng, double x, double y, double z, double height, IrisData data) {
if (zones.isEmpty()) {
return false;
}
return getInterpolator().interpolate(x, y, z, (xx, yy, zz)
-> stream(rng, data).get(xx, yy, zz)) > threshold(height);
}
}

View File

@@ -28,10 +28,6 @@ import com.volmit.iris.engine.object.biome.IrisBiome;
import com.volmit.iris.engine.object.biome.IrisBiomeCustom;
import com.volmit.iris.engine.object.block.IrisBlockDrops;
import com.volmit.iris.engine.object.block.IrisMaterialPalette;
import com.volmit.iris.engine.object.carve.IrisCarveLayer;
import com.volmit.iris.engine.object.carve.IrisCaveFluid;
import com.volmit.iris.engine.object.carve.IrisCaveLayer;
import com.volmit.iris.engine.object.carve.IrisCaverns;
import com.volmit.iris.engine.object.deposits.IrisDepositGenerator;
import com.volmit.iris.engine.object.feature.IrisFeaturePositional;
import com.volmit.iris.engine.object.feature.IrisFeaturePotential;
@@ -117,9 +113,6 @@ public class IrisDimension extends IrisRegistrant {
@Desc("Tree growth override settings")
private IrisTreeSettings treeSettings = new IrisTreeSettings();
@Desc("Define iris cavern zones")
private IrisCaverns caverns = new IrisCaverns();
@Desc("Upon joining this world, Iris will send a resource pack request to the client. If they have previously selected yes, it will auto-switch depending on which dimension they go to.")
private String resourcePack = "";
@@ -182,9 +175,6 @@ public class IrisDimension extends IrisRegistrant {
@Desc("Carve terrain or not")
private boolean carving = true;
@Desc("If defined, If air is defined below the area, this fluid will always place")
private IrisCaveFluid forceFluid = new IrisCaveFluid();
@Desc("Generate decorations or not")
private boolean decorate = true;
@@ -297,14 +287,6 @@ public class IrisDimension extends IrisRegistrant {
@Desc("Overlay additional noise on top of the interoplated terrain.")
private KList<IrisShapedGeneratorStyle> overlayNoise = new KList<>();
@ArrayType(min = 1, type = IrisCaveLayer.class)
@Desc("Define cave layers")
private KList<IrisCaveLayer> caveLayers = new KList<>();
@ArrayType(min = 1, type = IrisCarveLayer.class)
@Desc("Define carve layers")
private KList<IrisCarveLayer> carveLayers = new KList<>();
@Desc("If true, the spawner system has infinite energy. This is NOT recommended because it would allow for mobs to keep spawning over and over without a rate limit")
private boolean infiniteEnergy = false;
@@ -363,18 +345,6 @@ public class IrisDimension extends IrisRegistrant {
return rad.aquire(() -> Math.toRadians(dimensionAngleDeg));
}
public boolean isCarved(IrisData data, int x, int y, int z, RNG rng, int terrainHeight) {
if (isCarving() && terrainHeight > getFluidHeight() || y < terrainHeight) {
for (IrisCarveLayer j : getCarveLayers()) {
if (j.isCarved(rng, data, x, y, z)) {
return true;
}
}
}
return false;
}
public Environment getEnvironment() {
return environment;
}

View File

@@ -22,7 +22,6 @@ import com.volmit.iris.Iris;
import com.volmit.iris.engine.IrisComplex;
import com.volmit.iris.engine.data.cache.AtomicCache;
import com.volmit.iris.engine.framework.Engine;
import com.volmit.iris.engine.modifier.IrisCaveModifier;
import com.volmit.iris.engine.object.annotations.Desc;
import com.volmit.iris.engine.object.annotations.MinNumber;
import com.volmit.iris.engine.object.annotations.RegistryListResource;
@@ -88,15 +87,7 @@ public class IrisEntitySpawn implements IRare {
IrisComplex comp = gen.getComplex();
IrisBiome cave = comp.getCaveBiomeStream().get(x, z);
KList<Location> r = new KList<>();
if (cave != null) {
for (CaveResult i : ((IrisCaveModifier) gen.getCaveModifier()).genCaves(x, z)) {
if (i.getCeiling() >= gen.getHeight() || i.getFloor() < 0 || i.getCeiling() - 2 <= i.getFloor()) {
continue;
}
r.add(new Location(c.getWorld(), x, i.getFloor(), z));
}
}
r.add( new Location(c.getWorld(), x, hf + 1, z)); // TODO CAVE HEIGHT
yield r.getRandom(rng);
}

View File

@@ -265,7 +265,7 @@ public class IrisRegion extends IrisRegistrant implements IRare {
return 1;
}
public CNG getShoreHeightGenerator() {
return shoreHeightGenerator.aquire(() ->
CNG.signature(new RNG((long) (getName().length() + getLandBiomeZoom() + getLandBiomes().size() + 3458612))));