mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-07-18 10:12:53 +00:00
Island mode improvements
This commit is contained in:
parent
55521afe35
commit
6728703473
@ -24,6 +24,8 @@ import com.volmit.iris.core.IrisDataManager;
|
||||
import com.volmit.iris.engine.actuator.IrisTerrainNormalActuator;
|
||||
import com.volmit.iris.engine.data.DataProvider;
|
||||
import com.volmit.iris.engine.framework.Engine;
|
||||
import com.volmit.iris.engine.interpolation.InterpolationMethod;
|
||||
import com.volmit.iris.engine.interpolation.IrisInterpolation;
|
||||
import com.volmit.iris.engine.modifier.IrisCaveModifier;
|
||||
import com.volmit.iris.engine.noise.CNG;
|
||||
import com.volmit.iris.engine.object.*;
|
||||
@ -77,6 +79,8 @@ public class IrisComplex implements DataProvider {
|
||||
private ProceduralStream<Double> heightFluidStream;
|
||||
private ProceduralStream<Integer> trueHeightStream;
|
||||
private ProceduralStream<Double> slopeStream;
|
||||
private ProceduralStream<Integer> islandTopStream;
|
||||
private ProceduralStream<Integer> islandBottomStream;
|
||||
private ProceduralStream<RNG> rngStream;
|
||||
private ProceduralStream<RNG> chunkRngStream;
|
||||
private ProceduralStream<IrisDecorator> terrainSurfaceDecoration;
|
||||
@ -157,7 +161,7 @@ public class IrisComplex implements DataProvider {
|
||||
.convertCached((s) -> data.getRegionLoader().load(s)).cache2D(cacheSize);
|
||||
islandStream = regionStyleStream
|
||||
.seededChance(rng.nextParallelRNG(29349), 23968888888L,
|
||||
engine.getDimension().getIslandMode().getIslandChance());
|
||||
1D/engine.getDimension().getIslandMode().getIslandChance());
|
||||
islandHeightStream = regionIdentityStream.style(rng.nextParallelRNG(330466), engine.getDimension().getIslandMode().getHeight());
|
||||
islandDepthStream = engine.getDimension().getIslandMode().getIslandDepth().stream(rng.nextParallelRNG(-39578888));
|
||||
regionIDStream = regionIdentityStream.convertCached((i) -> new UUID(Double.doubleToLongBits(i), String.valueOf(i * 38445).hashCode() * 3245556666L));
|
||||
@ -356,9 +360,29 @@ public class IrisComplex implements DataProvider {
|
||||
d.hashCode());
|
||||
})
|
||||
.cache2D(cacheSize);
|
||||
islandTopStream = islandStream.convertAware2D((i, x, z) ->
|
||||
i ? heightStream.round()
|
||||
.subtract(fluidHeight)
|
||||
.add((xx, zz) -> getIslandHeight(xx.intValue(), zz.intValue(), engine.getDimension()
|
||||
.getIslandMode().getIslandEdgeInterpolator()))
|
||||
.get(x, z) : 0);
|
||||
islandBottomStream = islandStream.convertAware2D((i, x, z) ->
|
||||
i ? islandHeightStream.subtract(islandDepthStream).round().get(x, z) : 0);
|
||||
//@done
|
||||
}
|
||||
|
||||
private double getIslandHeight(int x, int z, IrisInterpolator interp)
|
||||
{
|
||||
return interp.interpolate(x, z, (xx, zz) -> {
|
||||
if(getIslandStream().get(xx, zz))
|
||||
{
|
||||
return getIslandHeightStream().get(xx, zz);
|
||||
}
|
||||
|
||||
return 0;
|
||||
});
|
||||
}
|
||||
|
||||
private IrisRegion findRegion(IrisBiome focus, Engine engine) {
|
||||
for (IrisRegion i : engine.getDimension().getAllRegions(engine)) {
|
||||
if (i.getAllBiomeIds().contains(focus.getLoadKey())) {
|
||||
|
@ -221,6 +221,7 @@ public class IrisEngine extends BlockPopulator implements Engine {
|
||||
}
|
||||
case ISLANDS -> {
|
||||
getFramework().getTerrainActuator().actuate(x, z, vblocks, multicore);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -21,6 +21,8 @@ package com.volmit.iris.engine.actuator;
|
||||
import com.volmit.iris.engine.framework.Engine;
|
||||
import com.volmit.iris.engine.framework.EngineAssignedActuator;
|
||||
import com.volmit.iris.engine.hunk.Hunk;
|
||||
import com.volmit.iris.engine.interpolation.InterpolationMethod;
|
||||
import com.volmit.iris.engine.interpolation.IrisInterpolation;
|
||||
import com.volmit.iris.engine.object.IrisBiome;
|
||||
import com.volmit.iris.util.collection.KList;
|
||||
import com.volmit.iris.util.documentation.BlockCoordinates;
|
||||
@ -58,6 +60,8 @@ public class IrisTerrainIslandActuator extends EngineAssignedActuator<BlockData>
|
||||
int i, zf, depth, surface, realX, realZ;
|
||||
IrisBiome biome;
|
||||
KList<BlockData> blocks, fblocks;
|
||||
int hi,lo;
|
||||
double hh;
|
||||
|
||||
for (int xf = 0; xf < h.getWidth(); xf++) {
|
||||
for (zf = 0; zf < h.getDepth(); zf++) {
|
||||
@ -65,11 +69,26 @@ public class IrisTerrainIslandActuator extends EngineAssignedActuator<BlockData>
|
||||
realZ = (int) modZ(zf + z);
|
||||
|
||||
if (getComplex().getIslandStream().get(realX, realZ)) {
|
||||
surface = getComplex().getIslandHeightStream().get(realX, realZ).intValue();
|
||||
depth = getComplex().getIslandDepthStream().get(realX, realZ).intValue();
|
||||
biome = getComplex().getTrueBiomeStream().get(realX, realZ);
|
||||
hh = getComplex().getTrueHeightStream().get(realX, realZ) - getComplex().getFluidHeight();
|
||||
depth = (int) (getComplex().getIslandDepthStream().get(realX, realZ).intValue() + hh);
|
||||
blocks = biome.generateLayers(realX, realZ, rng, depth, depth, getData(), getComplex());
|
||||
hi = getComplex().getIslandTopStream().get(realX, realZ);
|
||||
lo = getComplex().getIslandBottomStream().get(realX, realZ);
|
||||
|
||||
for (i = surface - depth; i < surface; i++) {
|
||||
h.set(xf, i, zf, BEDROCK);
|
||||
// 10
|
||||
// 6
|
||||
|
||||
// hf = 4
|
||||
|
||||
for (i = hi; i >= lo; i--) {
|
||||
int hf = (i - hi);
|
||||
if (blocks.hasIndex(hf)) {
|
||||
h.set(xf, i, zf, blocks.get(hf));
|
||||
continue;
|
||||
}
|
||||
|
||||
h.set(xf, i, zf, getComplex().getRockStream().get(realX, realZ));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -42,4 +42,7 @@ public class IrisTerrainIsland {
|
||||
@MaxNumber(10000)
|
||||
@Desc("How often are regions islands instead of nothing?")
|
||||
private double islandChance = 0.5;
|
||||
|
||||
@Desc("Interpolate the edges of islands")
|
||||
private IrisInterpolator islandEdgeInterpolator = new IrisInterpolator();
|
||||
}
|
||||
|
@ -98,10 +98,22 @@ public interface ProceduralStream<T> extends ProceduralLayer, Interpolated<T> {
|
||||
return new AddingStream<>(this, a);
|
||||
}
|
||||
|
||||
default ProceduralStream<T> add(ProceduralStream<Double> a) {
|
||||
return add2D((x, z) -> a.get(x, z));
|
||||
}
|
||||
|
||||
default ProceduralStream<T> subtract(ProceduralStream<Double> a) {
|
||||
return subtract2D((x, z) -> a.get(x, z));
|
||||
}
|
||||
|
||||
default ProceduralStream<T> add2D(Function2<Double, Double, Double> a) {
|
||||
return new AddingStream<>(this, a);
|
||||
}
|
||||
|
||||
default ProceduralStream<T> subtract2D(Function2<Double, Double, Double> a) {
|
||||
return new SubtractingStream<T>(this, a);
|
||||
}
|
||||
|
||||
default ProceduralStream<T> add(double a) {
|
||||
return new AddingStream<>(this, a);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user