mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-04-07 00:06:10 +00:00
Total rotation support
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
package com.volmit.iris.layer;
|
||||
|
||||
import com.volmit.iris.object.InferredType;
|
||||
import com.volmit.iris.object.IrisRegion;
|
||||
import com.volmit.iris.util.BiomeRarityCellGenerator;
|
||||
import com.volmit.iris.util.BiomeResult;
|
||||
import com.volmit.iris.util.RNG;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class BiomeDataProvider
|
||||
{
|
||||
private InferredType type;
|
||||
private BiomeRarityCellGenerator generator;
|
||||
private GenLayerBiome layer;
|
||||
|
||||
public BiomeDataProvider(GenLayerBiome layer, InferredType type, RNG rng)
|
||||
{
|
||||
this.type = type;
|
||||
this.layer = layer;
|
||||
generator = new BiomeRarityCellGenerator(rng.nextParallelRNG(4645079 + (type.ordinal() * 23845)));
|
||||
}
|
||||
|
||||
public BiomeResult generatePureData(double bx, double bz, int rawX, int rawZ, IrisRegion regionData)
|
||||
{
|
||||
getGenerator().setShuffle(12);
|
||||
double zoom = (layer.getIris().getDimension().getBiomeZoom() * regionData.getBiomeZoom(getType())) * 3.15;
|
||||
getGenerator().setCellScale(1D / zoom);
|
||||
return layer.generateBiomeData(bx, bz, regionData, getGenerator(), regionData.getBiomes(getType()), getType());
|
||||
}
|
||||
|
||||
public BiomeResult generateData(double bx, double bz, int rawX, int rawZ, IrisRegion regionData)
|
||||
{
|
||||
return layer.generateImpureData(rawX, rawZ, getType(), regionData, generatePureData(bx, bz, rawX, rawZ, regionData));
|
||||
}
|
||||
}
|
||||
202
src/main/java/com/volmit/iris/gen/layer/GenLayerBiome.java
Normal file
202
src/main/java/com/volmit/iris/gen/layer/GenLayerBiome.java
Normal file
@@ -0,0 +1,202 @@
|
||||
package com.volmit.iris.layer;
|
||||
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.generator.DimensionChunkGenerator;
|
||||
import com.volmit.iris.object.InferredType;
|
||||
import com.volmit.iris.object.IrisBiome;
|
||||
import com.volmit.iris.object.IrisRegion;
|
||||
import com.volmit.iris.object.IrisRegionRidge;
|
||||
import com.volmit.iris.object.IrisRegionSpot;
|
||||
import com.volmit.iris.util.BiomeRarityCellGenerator;
|
||||
import com.volmit.iris.util.BiomeResult;
|
||||
import com.volmit.iris.util.CellGenerator;
|
||||
import com.volmit.iris.util.GenLayer;
|
||||
import com.volmit.iris.util.KList;
|
||||
import com.volmit.iris.util.RNG;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class GenLayerBiome extends GenLayer
|
||||
{
|
||||
private CellGenerator regionGenerator;
|
||||
private CellGenerator bridgeGenerator;
|
||||
private BiomeDataProvider seaProvider;
|
||||
private BiomeDataProvider landProvider;
|
||||
private BiomeDataProvider shoreProvider;
|
||||
private BiomeDataProvider caveProvider;
|
||||
private BiomeDataProvider islandProvider;
|
||||
private BiomeDataProvider skylandProvider;
|
||||
private DimensionChunkGenerator iris;
|
||||
|
||||
public GenLayerBiome(DimensionChunkGenerator iris, RNG rng)
|
||||
{
|
||||
super(iris, rng);
|
||||
this.iris = iris;
|
||||
seaProvider = new BiomeDataProvider(this, InferredType.SEA, rng);
|
||||
landProvider = new BiomeDataProvider(this, InferredType.LAND, rng);
|
||||
shoreProvider = new BiomeDataProvider(this, InferredType.SHORE, rng);
|
||||
caveProvider = new BiomeDataProvider(this, InferredType.CAVE, rng);
|
||||
islandProvider = new BiomeDataProvider(this, InferredType.ISLAND, rng);
|
||||
skylandProvider = new BiomeDataProvider(this, InferredType.SKYLAND, rng);
|
||||
regionGenerator = new CellGenerator(rng.nextParallelRNG(1188519));
|
||||
bridgeGenerator = new CellGenerator(rng.nextParallelRNG(1541462));
|
||||
}
|
||||
|
||||
public IrisRegion getRegion(double bx, double bz)
|
||||
{
|
||||
if(iris.getDimension().getRegions().isEmpty())
|
||||
{
|
||||
Iris.error("NO REGIONS!");
|
||||
return null;
|
||||
}
|
||||
|
||||
regionGenerator.setShuffle(8);
|
||||
regionGenerator.setCellScale(0.33 / iris.getDimension().getRegionZoom());
|
||||
double x = bx / iris.getDimension().getBiomeZoom();
|
||||
double z = bz / iris.getDimension().getBiomeZoom();
|
||||
String regionId = iris.getDimension().getRegions().get(regionGenerator.getIndex(x, z, iris.getDimension().getRegions().size()));
|
||||
|
||||
return Iris.data.getRegionLoader().load(regionId);
|
||||
}
|
||||
|
||||
public BiomeResult generateData(double bx, double bz, int rawX, int rawZ)
|
||||
{
|
||||
return generateRegionData(bx, bz, rawX, rawZ, getRegion(bx, bz));
|
||||
}
|
||||
|
||||
public BiomeResult generateData(InferredType type, double bx, double bz, int rawX, int rawZ, IrisRegion regionData)
|
||||
{
|
||||
return getProvider(type).generateData(bx, bz, rawX, rawZ, regionData);
|
||||
}
|
||||
|
||||
public BiomeDataProvider getProvider(InferredType type)
|
||||
{
|
||||
if(type.equals(InferredType.SEA))
|
||||
{
|
||||
return seaProvider;
|
||||
}
|
||||
|
||||
else if(type.equals(InferredType.LAND))
|
||||
{
|
||||
return landProvider;
|
||||
}
|
||||
|
||||
else if(type.equals(InferredType.SHORE))
|
||||
{
|
||||
return shoreProvider;
|
||||
}
|
||||
|
||||
else if(type.equals(InferredType.CAVE))
|
||||
{
|
||||
return caveProvider;
|
||||
}
|
||||
|
||||
else if(type.equals(InferredType.ISLAND))
|
||||
{
|
||||
return islandProvider;
|
||||
}
|
||||
|
||||
else if(type.equals(InferredType.SKYLAND))
|
||||
{
|
||||
return skylandProvider;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
Iris.error("Cannot find a BiomeDataProvider for type " + type.name());
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public BiomeResult generateRegionData(double bx, double bz, int rawX, int rawZ, IrisRegion regionData)
|
||||
{
|
||||
return generateData(getType(bx, bz, regionData), bx, bz, rawX, rawZ, regionData);
|
||||
}
|
||||
|
||||
public InferredType getType(double bx, double bz, IrisRegion regionData)
|
||||
{
|
||||
bridgeGenerator.setShuffle(0);
|
||||
bridgeGenerator.setCellScale(0.33 / iris.getDimension().getContinentZoom());
|
||||
double x = bx / iris.getDimension().getBiomeZoom();
|
||||
double z = bz / iris.getDimension().getBiomeZoom();
|
||||
return bridgeGenerator.getIndex(x, z, 5) == 1 ? InferredType.SEA : InferredType.LAND;
|
||||
}
|
||||
|
||||
public BiomeResult generateBiomeData(double bx, double bz, IrisRegion regionData, BiomeRarityCellGenerator cell, KList<IrisBiome> biomes, InferredType inferredType)
|
||||
{
|
||||
if(biomes.isEmpty())
|
||||
{
|
||||
return new BiomeResult(null, 0);
|
||||
}
|
||||
|
||||
double x = bx / iris.getDimension().getBiomeZoom();
|
||||
double z = bz / iris.getDimension().getBiomeZoom();
|
||||
IrisBiome biome = cell.get(x, z, biomes);
|
||||
biome.setInferredType(inferredType);
|
||||
|
||||
return implode(bx, bz, regionData, cell, new BiomeResult(biome, cell.getDistance(x, z)));
|
||||
}
|
||||
|
||||
public BiomeResult generateImpureData(int rawX, int rawZ, InferredType type, IrisRegion regionData, BiomeResult pureResult)
|
||||
{
|
||||
for(IrisRegionRidge i : regionData.getRidgeBiomes())
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
for(IrisRegionSpot i : regionData.getSpotBiomes())
|
||||
{
|
||||
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 pureResult;
|
||||
}
|
||||
|
||||
public BiomeResult implode(double bx, double bz, IrisRegion regionData, BiomeRarityCellGenerator parentCell, BiomeResult parent)
|
||||
{
|
||||
return implode(bx, bz, regionData, parentCell, parent, 1);
|
||||
}
|
||||
|
||||
public BiomeResult implode(double bx, double bz, IrisRegion regionData, BiomeRarityCellGenerator 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().getRealChildren().isEmpty())
|
||||
{
|
||||
BiomeRarityCellGenerator childCell = parent.getBiome().getChildrenGenerator(rng, 123, parentCell.getCellScale() * parent.getBiome().getChildShrinkFactor());
|
||||
KList<IrisBiome> chx = parent.getBiome().getRealChildren().copy();
|
||||
chx.add(parent.getBiome());
|
||||
IrisBiome biome = childCell.get(x, z, chx);
|
||||
biome.setInferredType(parent.getBiome().getInferredType());
|
||||
|
||||
return implode(bx, bz, regionData, childCell, new BiomeResult(biome, childCell.getDistance(x, z)), hits + 1);
|
||||
}
|
||||
}
|
||||
|
||||
return parent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double generate(double x, double z)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
45
src/main/java/com/volmit/iris/gen/layer/GenLayerCarve.java
Normal file
45
src/main/java/com/volmit/iris/gen/layer/GenLayerCarve.java
Normal file
@@ -0,0 +1,45 @@
|
||||
package com.volmit.iris.layer;
|
||||
|
||||
import com.volmit.iris.generator.DimensionChunkGenerator;
|
||||
import com.volmit.iris.util.CellGenerator;
|
||||
import com.volmit.iris.util.GenLayer;
|
||||
import com.volmit.iris.util.IrisInterpolation;
|
||||
import com.volmit.iris.util.M;
|
||||
import com.volmit.iris.util.RNG;
|
||||
|
||||
public class GenLayerCarve extends GenLayer
|
||||
{
|
||||
private CellGenerator cell;
|
||||
|
||||
public GenLayerCarve(DimensionChunkGenerator iris, RNG rng)
|
||||
{
|
||||
super(iris, rng);
|
||||
cell = new CellGenerator(rng.nextParallelRNG(-135486678));
|
||||
}
|
||||
|
||||
public boolean isCarved(int xc, int y, int zc)
|
||||
{
|
||||
if(y > iris.getDimension().getCarvingMax() || y < iris.getDimension().getCarvingMin())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
double x = ((double) xc / iris.getDimension().getCarvingZoom());
|
||||
double z = ((double) zc / iris.getDimension().getCarvingZoom());
|
||||
|
||||
double opacity = Math.pow(IrisInterpolation.sinCenter(M.lerpInverse(iris.getDimension().getCarvingMin(), iris.getDimension().getCarvingMax(), y)), 4);
|
||||
|
||||
if(cell.getDistance(x - (Math.cos(y / iris.getDimension().getCarvingRippleThickness()) + 0.5D) / 2D, y / iris.getDimension().getCarvingSliverThickness(), z + (Math.sin(y / iris.getDimension().getCarvingRippleThickness()) + 0.5D) / 2D) < opacity * iris.getDimension().getCarvingEnvelope())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double generate(double x, double z)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
187
src/main/java/com/volmit/iris/gen/layer/GenLayerCave.java
Normal file
187
src/main/java/com/volmit/iris/gen/layer/GenLayerCave.java
Normal file
@@ -0,0 +1,187 @@
|
||||
package com.volmit.iris.layer;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
|
||||
import com.volmit.iris.generator.DimensionChunkGenerator;
|
||||
import com.volmit.iris.object.atomics.AtomicSliver;
|
||||
import com.volmit.iris.util.BlockDataTools;
|
||||
import com.volmit.iris.util.CNG;
|
||||
import com.volmit.iris.util.CaveResult;
|
||||
import com.volmit.iris.util.FastNoise;
|
||||
import com.volmit.iris.util.GenLayer;
|
||||
import com.volmit.iris.util.KList;
|
||||
import com.volmit.iris.util.RNG;
|
||||
import com.volmit.iris.util.FastNoise.CellularDistanceFunction;
|
||||
import com.volmit.iris.util.FastNoise.CellularReturnType;
|
||||
import com.volmit.iris.util.FastNoise.NoiseType;
|
||||
|
||||
public class GenLayerCave extends GenLayer
|
||||
{
|
||||
public static final BlockData CAVE_AIR = BlockDataTools.getBlockData("CAVE_AIR");
|
||||
public static final BlockData AIR = BlockDataTools.getBlockData("AIR");
|
||||
private static final KList<CaveResult> EMPTY = new KList<>();
|
||||
private CNG gincline;
|
||||
private CNG shuffle;
|
||||
private FastNoise gg;
|
||||
|
||||
public GenLayerCave(DimensionChunkGenerator iris, RNG rng)
|
||||
{
|
||||
//@builder
|
||||
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());
|
||||
//@done
|
||||
}
|
||||
|
||||
public KList<CaveResult> genCaves(double wxx, double wzz, int x, int z, AtomicSliver data)
|
||||
{
|
||||
if(!iris.getDimension().isCaves())
|
||||
{
|
||||
return EMPTY;
|
||||
}
|
||||
|
||||
int surface = data.getHighestBlock();
|
||||
KList<CaveResult> result = new KList<>();
|
||||
shuffle.scale(0.01);
|
||||
double shuffleDistance = 72;
|
||||
gg.SetNoiseType(NoiseType.Cellular);
|
||||
gg.SetCellularReturnType(CellularReturnType.Distance2Sub);
|
||||
gg.SetCellularDistanceFunction(CellularDistanceFunction.Natural);
|
||||
|
||||
for(int i = 0; i < 3; i++)
|
||||
{
|
||||
double wx = wxx + (shuffle.noise(wxx, wzz) * shuffleDistance);
|
||||
double wz = wzz + (shuffle.noise(wzz, wxx) * shuffleDistance);
|
||||
double incline = 157;
|
||||
double baseWidth = (14 * iris.getDimension().getCaveScale());
|
||||
double distanceCheck = 0.0132 * baseWidth;
|
||||
double distanceTake = 0.0022 * baseWidth;
|
||||
double drop = (-i * 17) + 44 + iris.getDimension().getCaveShift();
|
||||
double caveHeightNoise = incline * gincline.noise((wx + (10000 * i)), (wz - (10000 * i)));
|
||||
caveHeightNoise += shuffle.fitDoubleD(-1, 1, wxx - caveHeightNoise, wzz + caveHeightNoise) * 3;
|
||||
|
||||
int ceiling = -256;
|
||||
int floor = 512;
|
||||
|
||||
for(double tunnelHeight = 1; tunnelHeight <= baseWidth; tunnelHeight++)
|
||||
{
|
||||
double distance = (gg.GetCellular((float) wx + (10000 * i), (float) wz - (10000 * i)) + 1D) / 2D;
|
||||
if(distance < distanceCheck - (tunnelHeight * distanceTake))
|
||||
{
|
||||
int caveHeight = (int) Math.round(caveHeightNoise - drop);
|
||||
int pu = (int) (caveHeight + tunnelHeight);
|
||||
int pd = (int) (caveHeight - tunnelHeight);
|
||||
|
||||
if(pd > surface + 1)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if((pu > 255 && pd > 255) || (pu < 0 && pd < 0))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if(data == null)
|
||||
{
|
||||
ceiling = pu > ceiling ? pu : ceiling;
|
||||
floor = pu < floor ? pu : floor;
|
||||
ceiling = pd > ceiling ? pd : ceiling;
|
||||
floor = pd < floor ? pd : floor;
|
||||
|
||||
if(tunnelHeight == 1)
|
||||
{
|
||||
ceiling = caveHeight > ceiling ? caveHeight : ceiling;
|
||||
floor = caveHeight < floor ? caveHeight : floor;
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
if(dig(x, pu, z, data))
|
||||
{
|
||||
ceiling = pu > ceiling ? pu : ceiling;
|
||||
floor = pu < floor ? pu : floor;
|
||||
|
||||
if(pu > surface - 2)
|
||||
{
|
||||
if(dig(x, pu + 1, z, data))
|
||||
{
|
||||
ceiling = pu + 1 > ceiling ? pu + 1 : ceiling;
|
||||
floor = pu + 1 < floor ? pu + 1 : floor;
|
||||
|
||||
if(dig(x, pu + 2, z, data))
|
||||
{
|
||||
ceiling = pu + 2 > ceiling ? pu + 2 : ceiling;
|
||||
floor = pu + 2 < floor ? pu + 2 : floor;
|
||||
|
||||
if(dig(x, pu + 3, z, data))
|
||||
{
|
||||
ceiling = pu + 3 > ceiling ? pu + 3 : ceiling;
|
||||
floor = pu + 3 < floor ? pu + 3 : floor;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(dig(x, pd, z, data))
|
||||
{
|
||||
ceiling = pd > ceiling ? pd : ceiling;
|
||||
floor = pd < floor ? pd : floor;
|
||||
}
|
||||
|
||||
if(tunnelHeight == 1)
|
||||
{
|
||||
if(dig(x, (int) (caveHeight), z, data))
|
||||
{
|
||||
ceiling = caveHeight > ceiling ? caveHeight : ceiling;
|
||||
floor = caveHeight < floor ? caveHeight : floor;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(floor >= 0 && ceiling <= 255)
|
||||
{
|
||||
result.add(new CaveResult(floor, ceiling));
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public boolean dig(int x, int y, int z, AtomicSliver data)
|
||||
{
|
||||
Material a = data.getType(y);
|
||||
Material c = data.getType(y + 1);
|
||||
Material f = data.getType(y - 1);
|
||||
|
||||
if(can(a) && canAir(c) && canAir(f))
|
||||
{
|
||||
data.set(y, CAVE_AIR);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean canAir(Material m)
|
||||
{
|
||||
return (m.isSolid() || m.equals(Material.AIR) || m.equals(Material.CAVE_AIR)) && !m.equals(Material.BEDROCK);
|
||||
}
|
||||
|
||||
public boolean can(Material m)
|
||||
{
|
||||
return m.isSolid() && !m.equals(Material.BEDROCK);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double generate(double x, double z)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user