mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-12-03 11:41:37 +00:00
Open water under falls
- Estuary and inlet columns that a higher neighbouring water column falls into skip the sea layers, so falling water lands in open sea water instead of spreading over sea ice - Fall check compares the unclamped water head with the 4-neighbour wet heads, the rule the mantle uses to place falls - IrisTerrainNormalActuatorHydrologyTest.aFallIntoAFrozenMouthLandsInOpenWater pins the open plunge and keeps ice beside level water and dry banks
This commit is contained in:
1 parent
2ddc9f1106
commit
2ed13f9b7f
2 files changed
+51
-5
No files matched your search
@@ -215,10 +215,8 @@ public class IrisTerrainNormalActuator extends EngineAssignedActuator<NativeBloc
|
|||||||
IrisBiome biome = biomeCache.get(xf, zf);
|
IrisBiome biome = biomeCache.get(xf, zf);
|
||||||
IrisRegion region = regionCache.get(xf, zf);
|
IrisRegion region = regionCache.get(xf, zf);
|
||||||
int he = Math.min(chunkHeight, context.getRoundedHeight(xf, zf));
|
int he = Math.min(chunkHeight, context.getRoundedHeight(xf, zf));
|
||||||
int surfaceFluidHeight = Math.min(
|
int waterHead = (int) Math.round(waterHeadStream.getDouble(realX, realZ));
|
||||||
chunkHeight,
|
int surfaceFluidHeight = Math.min(chunkHeight, waterHead);
|
||||||
(int) Math.round(waterHeadStream.getDouble(realX, realZ))
|
|
||||||
);
|
|
||||||
int hf = Math.max(surfaceFluidHeight, he);
|
int hf = Math.max(surfaceFluidHeight, he);
|
||||||
if (hf < 0) {
|
if (hf < 0) {
|
||||||
return;
|
return;
|
||||||
@@ -229,6 +227,7 @@ public class IrisTerrainNormalActuator extends EngineAssignedActuator<NativeBloc
|
|||||||
boolean wet = role.wet();
|
boolean wet = role.wet();
|
||||||
boolean submerged = wet && he < surfaceFluidHeight;
|
boolean submerged = wet && he < surfaceFluidHeight;
|
||||||
boolean seaFloor = !wet || role == WaterRole.INLET || role == WaterRole.MOUTH;
|
boolean seaFloor = !wet || role == WaterRole.INLET || role == WaterRole.MOUTH;
|
||||||
|
boolean openUnderFall = wet && seaFloor && receivesFall(realX, realZ, waterHead);
|
||||||
IrisHydrologyMaterials materials = role == WaterRole.NONE || role == WaterRole.INLET ? null
|
IrisHydrologyMaterials materials = role == WaterRole.NONE || role == WaterRole.INLET ? null
|
||||||
: complex.resolveWaterMaterials(realX, realZ);
|
: complex.resolveWaterMaterials(realX, realZ);
|
||||||
Terrain3DColumn terrainColumn = complex.terrainColumn(realX, realZ);
|
Terrain3DColumn terrainColumn = complex.terrainColumn(realX, realZ);
|
||||||
@@ -298,7 +297,7 @@ public class IrisTerrainNormalActuator extends EngineAssignedActuator<NativeBloc
|
|||||||
fblocks,
|
fblocks,
|
||||||
fdepth,
|
fdepth,
|
||||||
fluid,
|
fluid,
|
||||||
!seaFloor
|
!seaFloor || openUnderFall
|
||||||
));
|
));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -364,6 +363,15 @@ public class IrisTerrainNormalActuator extends EngineAssignedActuator<NativeBloc
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean receivesFall(int realX, int realZ, int head) {
|
||||||
|
return fallsFrom(realX + 1, realZ, head) || fallsFrom(realX - 1, realZ, head)
|
||||||
|
|| fallsFrom(realX, realZ + 1, head) || fallsFrom(realX, realZ - 1, head);
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean fallsFrom(int realX, int realZ, int head) {
|
||||||
|
return waterRoleStream.get(realX, realZ).wet() && Math.round(waterHeadStream.getDouble(realX, realZ)) > head;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Paints the solid run from {@code top} down to {@code floor}, which lies below every biome
|
* Paints the solid run from {@code top} down to {@code floor}, which lies below every biome
|
||||||
* layer, river material, mapped surface and cave ceiling of its span: only ores or rock land there.
|
* layer, river material, mapped surface and cave ceiling of its span: only ores or rock land there.
|
||||||
|
|||||||
+38
@@ -189,6 +189,32 @@ public class IrisTerrainNormalActuatorHydrologyTest {
|
|||||||
assertSame(frozenMouth.ice, frozenEstuary.get(0, HEAD, 0));
|
assertSame(frozenMouth.ice, frozenEstuary.get(0, HEAD, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void aFallIntoAFrozenMouthLandsInOpenWater() {
|
||||||
|
Painter fall = frozenMouth();
|
||||||
|
fall.neighbour(12, -4, WaterRole.CHANNEL, HEAD + 1);
|
||||||
|
Hunk<NativeBlockState> plunge = fall.paint();
|
||||||
|
for (int y = GROUND + 1; y <= HEAD; y++) {
|
||||||
|
assertSame("the fall lands in open sea water at y " + y, fall.sea, plunge.get(0, y, 0));
|
||||||
|
}
|
||||||
|
|
||||||
|
Painter level = frozenMouth();
|
||||||
|
level.neighbour(11, -3, WaterRole.CHANNEL, HEAD);
|
||||||
|
assertSame("water beside the mouth at its own level is no fall", level.ice, level.paint().get(0, HEAD, 0));
|
||||||
|
|
||||||
|
Painter dry = frozenMouth();
|
||||||
|
dry.neighbour(10, -4, WaterRole.BANK, HEAD + 4);
|
||||||
|
assertSame("a higher dry bank is no fall", dry.ice, dry.paint().get(0, HEAD, 0));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Painter frozenMouth() {
|
||||||
|
Painter painter = new Painter(WaterRole.MOUTH, HEAD);
|
||||||
|
when(painter.complex.resolveWaterFluid(11, -4)).thenReturn(painter.sea);
|
||||||
|
when(painter.complex.naturalTrueHeight(11, -4)).thenReturn(GROUND);
|
||||||
|
painter.thickSeaLayers();
|
||||||
|
return painter;
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void dryColumnsBelowTheSeaKeepTheSeaFillAndItsLayers() {
|
public void dryColumnsBelowTheSeaKeepTheSeaFillAndItsLayers() {
|
||||||
for (WaterRole role : List.of(WaterRole.NONE, WaterRole.BANK, WaterRole.SHORE)) {
|
for (WaterRole role : List.of(WaterRole.NONE, WaterRole.BANK, WaterRole.SHORE)) {
|
||||||
@@ -368,8 +394,12 @@ public class IrisTerrainNormalActuatorHydrologyTest {
|
|||||||
private final NativeBlockState bed = state("minecraft:gravel_bed");
|
private final NativeBlockState bed = state("minecraft:gravel_bed");
|
||||||
private final NativeBlockState shore = state("minecraft:clay");
|
private final NativeBlockState shore = state("minecraft:clay");
|
||||||
private final NativeBlockState bank = state("minecraft:coarse_dirt");
|
private final NativeBlockState bank = state("minecraft:coarse_dirt");
|
||||||
|
private final WaterRole role;
|
||||||
|
private final int head;
|
||||||
|
|
||||||
private Painter(WaterRole role, int head) {
|
private Painter(WaterRole role, int head) {
|
||||||
|
this.role = role;
|
||||||
|
this.head = head;
|
||||||
when(engine.getDimension()).thenReturn(dimension);
|
when(engine.getDimension()).thenReturn(dimension);
|
||||||
when(engine.getComplex()).thenReturn(complex);
|
when(engine.getComplex()).thenReturn(complex);
|
||||||
when(engine.getData()).thenReturn(data);
|
when(engine.getData()).thenReturn(data);
|
||||||
@@ -392,6 +422,14 @@ public class IrisTerrainNormalActuatorHydrologyTest {
|
|||||||
layers(grass, dirt);
|
layers(grass, dirt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void neighbour(int neighbourX, int neighbourZ, WaterRole neighbourRole, int neighbourHead) {
|
||||||
|
when(complex.getWaterHeadStream()).thenReturn(ProceduralStream.ofDouble((x, z) ->
|
||||||
|
(int) Math.floor(x) == neighbourX && (int) Math.floor(z) == neighbourZ ? neighbourHead : (double) head));
|
||||||
|
when(complex.getWaterRoleStream()).thenReturn(ProceduralStream.of((x, z) ->
|
||||||
|
(int) Math.floor(x) == neighbourX && (int) Math.floor(z) == neighbourZ ? neighbourRole : role,
|
||||||
|
Interpolated.of(value -> 0D, value -> role)));
|
||||||
|
}
|
||||||
|
|
||||||
private void thickSeaLayers() {
|
private void thickSeaLayers() {
|
||||||
when(biome.generateSeaLayers(anyDouble(), anyDouble(), any(RNG.class), anyInt(), eq(data))).thenAnswer(invocation -> {
|
when(biome.generateSeaLayers(anyDouble(), anyDouble(), any(RNG.class), anyInt(), eq(data))).thenAnswer(invocation -> {
|
||||||
KList<NativeBlockState> layers = new KList<>();
|
KList<NativeBlockState> layers = new KList<>();
|
||||||
|
|||||||
Reference in new issue
Block a user