mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-28 08:44:50 +00:00
Merge tiling
This commit is contained in:
commit
04649aedbc
17 files changed
+633
-290
No files matched your search
+6
-67
@@ -34,26 +34,18 @@ import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
public class IrisTerrainNormalActuatorStrataCutTest {
|
||||
public class IrisTerrainNormalActuatorBankCutTest {
|
||||
@Rule
|
||||
public final PlatformBinding platform = PlatformBinding.mockPlatform();
|
||||
|
||||
@Test
|
||||
public void exposedBankCutDeeperThanThePaletteShowsTheDeepestAuthoredLayer() {
|
||||
public void aBankCutPaintsTheBiomeLayersFromItsNewSurface() {
|
||||
Fixture fixture = new Fixture(WaterRole.BANK);
|
||||
|
||||
Hunk<NativeBlockState> output = fixture.actuate();
|
||||
|
||||
assertBlock(fixture.dirt, output.get(0, 40, 0));
|
||||
assertBlock(fixture.grass, output.get(0, 40, 0));
|
||||
assertBlock(fixture.dirt, output.get(0, 39, 0));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void exposedBankBelowTheAuthoredSoilStillFallsThroughToRock() {
|
||||
Fixture fixture = new Fixture(WaterRole.BANK);
|
||||
|
||||
Hunk<NativeBlockState> output = fixture.actuate();
|
||||
|
||||
assertBlock(fixture.rock, output.get(0, 38, 0));
|
||||
}
|
||||
|
||||
@@ -69,21 +61,9 @@ public class IrisTerrainNormalActuatorStrataCutTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void everyDryWaterRoleExposesItsCutStrata() {
|
||||
for (WaterRole role : List.of(WaterRole.BANK, WaterRole.SHORE, WaterRole.POND_SHORE, WaterRole.DAM)) {
|
||||
Fixture fixture = new Fixture(role);
|
||||
|
||||
Hunk<NativeBlockState> output = fixture.actuate();
|
||||
|
||||
assertBlock(fixture.dirt, output.get(0, 40, 0));
|
||||
assertBlock(fixture.dirt, output.get(0, 39, 0));
|
||||
assertBlock(fixture.rock, output.get(0, 38, 0));
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void wetAndNaturalColumnsKeepTheirPaletteAtTheCut() {
|
||||
for (WaterRole role : List.of(WaterRole.NONE, WaterRole.CHANNEL, WaterRole.POND)) {
|
||||
public void everyRoleKeepsItsPaletteAtTheCut() {
|
||||
for (WaterRole role : List.of(WaterRole.NONE, WaterRole.CHANNEL, WaterRole.POND,
|
||||
WaterRole.BANK, WaterRole.SHORE, WaterRole.POND_SHORE, WaterRole.DAM)) {
|
||||
Fixture fixture = new Fixture(role);
|
||||
|
||||
Hunk<NativeBlockState> output = fixture.actuate();
|
||||
@@ -94,47 +74,6 @@ public class IrisTerrainNormalActuatorStrataCutTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void aSolidCutBankMeasuresItsCutFromTheNaturalHeight() {
|
||||
Fixture fixture = new Fixture(WaterRole.BANK);
|
||||
when(fixture.complex.terrainColumn(11, -4)).thenReturn(null);
|
||||
when(fixture.complex.naturalTerrainColumn(11, -4)).thenReturn(null);
|
||||
when(fixture.complex.naturalTrueHeight(11, -4)).thenReturn(62);
|
||||
|
||||
Hunk<NativeBlockState> output = fixture.actuate();
|
||||
|
||||
assertBlock(fixture.dirt, output.get(0, 60, 0));
|
||||
assertBlock(fixture.dirt, output.get(0, 59, 0));
|
||||
assertBlock(fixture.rock, output.get(0, 58, 0));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void aCutClampsToTheDeepestAuthoredLayerAndNoFurther() {
|
||||
assertEquals(3, IrisTerrainNormalActuator.strataIndex(0, 6, 4));
|
||||
assertEquals(3, IrisTerrainNormalActuator.strataIndex(1, 6, 4));
|
||||
assertEquals(3, IrisTerrainNormalActuator.strataIndex(2, 6, 4));
|
||||
assertEquals(3, IrisTerrainNormalActuator.strataIndex(3, 6, 4));
|
||||
assertEquals(4, IrisTerrainNormalActuator.strataIndex(4, 6, 4));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void aModestCutStillShiftsTheStrataInsteadOfClamping() {
|
||||
assertEquals(1, IrisTerrainNormalActuator.strataIndex(0, 1, 4));
|
||||
assertEquals(2, IrisTerrainNormalActuator.strataIndex(1, 1, 4));
|
||||
assertEquals(3, IrisTerrainNormalActuator.strataIndex(2, 1, 4));
|
||||
assertEquals(3, IrisTerrainNormalActuator.strataIndex(3, 1, 4));
|
||||
assertEquals(4, IrisTerrainNormalActuator.strataIndex(4, 1, 4));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void aZeroCutIndexesTheBiomePaletteByDepthAlone() {
|
||||
for (int paletteSize = 0; paletteSize <= 16; paletteSize++) {
|
||||
for (int depth = 0; depth <= 32; depth++) {
|
||||
assertEquals(depth, IrisTerrainNormalActuator.strataIndex(depth, 0, paletteSize));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void assertBlock(NativeBlockState expected, NativeBlockState actual) {
|
||||
assertEquals(expected.key(), actual == null ? null : actual.key());
|
||||
assertSame(expected, actual);
|
||||
+2
-10
@@ -252,9 +252,6 @@ public class IrisTerrainNormalActuatorColumnParityTest {
|
||||
int terrainSpan = terrainColumn == null ? -1 : terrainColumn.spanCount() - 1;
|
||||
int layerSurfaceY = he;
|
||||
int layerCeilingY = 0;
|
||||
boolean exposeStrata = role != WaterRole.NONE && seaFloor;
|
||||
Terrain3DColumn naturalColumn = exposeStrata ? terrainColumn : null;
|
||||
int cut = 0;
|
||||
boolean keepGravityAway = materials != null && !materials.isAllowGravityBlocks();
|
||||
String paletteName = materials == null ? null : rolePalette(role);
|
||||
NativeBlockState paletteBlock = paletteName == null ? null : palettes.get(paletteName);
|
||||
@@ -321,12 +318,8 @@ public class IrisTerrainNormalActuatorColumnParityTest {
|
||||
continue;
|
||||
}
|
||||
if (blocks == null) {
|
||||
if (exposeStrata) {
|
||||
int naturalSurfaceY = naturalColumn == null ? he + 5 : naturalColumn.surfaceY(layerSurfaceY);
|
||||
cut = Math.max(0, naturalSurfaceY - layerSurfaceY);
|
||||
}
|
||||
blocks = biome.generateLayers(dimension, realX, realZ, rng,
|
||||
layerSurfaceY + cut, layerSurfaceY + cut, data, complex);
|
||||
layerSurfaceY, layerSurfaceY, data, complex);
|
||||
}
|
||||
if (layerCeilingY > 0 && depth >= 2 && i - layerCeilingY < 2) {
|
||||
if (ceilingBlocks == null) {
|
||||
@@ -336,9 +329,8 @@ public class IrisTerrainNormalActuatorColumnParityTest {
|
||||
h.setRaw(xf, i, zf, ceilingBlocks.hasIndex(ceilingDepth) ? ceilingBlocks.get(ceilingDepth) : rock);
|
||||
continue;
|
||||
}
|
||||
int strataIndex = IrisTerrainNormalActuator.strataIndex(depth, cut, blocks.size());
|
||||
NativeBlockState layerBlock = paletteBlock != null && depth < paintDepth ? paletteBlock
|
||||
: blocks.hasIndex(strataIndex) ? blocks.get(strataIndex) : null;
|
||||
: blocks.hasIndex(depth) ? blocks.get(depth) : null;
|
||||
if (layerBlock != null) {
|
||||
if (keepGravityAway && IrisProceduralBlocks.isGravityAffected(layerBlock)) {
|
||||
layerBlock = rock;
|
||||
|
||||
+8
-15
@@ -137,23 +137,16 @@ public class IrisTerrainNormalActuatorHydrologyTest {
|
||||
|
||||
Painter cliff = new Painter(WaterRole.INLET, HEAD);
|
||||
when(cliff.complex.naturalTrueHeight(11, -4)).thenReturn(GROUND + 20);
|
||||
assertSame("a slot cut through the cliff shows the strata below the old surface", cliff.dirt, cliff.paint().get(0, GROUND, 0));
|
||||
assertSame("a slot cut through the cliff keeps the submerged soil top", submergedDirt, cliff.paint().get(0, GROUND, 0));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shallowTidalBankCutsKeepTheBiomeSurfaceLayer() {
|
||||
Painter cut = new Painter(WaterRole.BANK, 0);
|
||||
when(cut.complex.naturalTrueHeight(11, -4)).thenReturn(GROUND + 3);
|
||||
NativeBlockState stripped = cut.paint().get(0, GROUND, 0);
|
||||
Painter tidal = new Painter(WaterRole.BANK, 0);
|
||||
when(tidal.complex.naturalTrueHeight(11, -4)).thenReturn(GROUND + 3);
|
||||
when(tidal.complex.isTidalBank(11, -4)).thenReturn(true);
|
||||
assertSame("the shallow tidal cut is resurfaced", tidal.grass, tidal.paint().get(0, GROUND, 0));
|
||||
assertSame("a river bank keeps its strata", cut.dirt, stripped);
|
||||
Painter deep = new Painter(WaterRole.BANK, 0);
|
||||
when(deep.complex.naturalTrueHeight(11, -4)).thenReturn(GROUND + 20);
|
||||
when(deep.complex.isTidalBank(11, -4)).thenReturn(true);
|
||||
assertSame("a deep tidal cut shows the strata", deep.dirt, deep.paint().get(0, GROUND, 0));
|
||||
public void bankCutsOfAnyDepthKeepTheBiomeSurfaceLayer() {
|
||||
for (int cut : new int[]{1, 3, 16, 20, 60}) {
|
||||
Painter bank = new Painter(WaterRole.BANK, 0);
|
||||
when(bank.complex.naturalTrueHeight(11, -4)).thenReturn(GROUND + cut);
|
||||
assertSame("a cut of " + cut, bank.grass, bank.paint().get(0, GROUND, 0));
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -395,7 +388,7 @@ public class IrisTerrainNormalActuatorHydrologyTest {
|
||||
materials.setShore(null).setBank(null);
|
||||
output = painter.paint();
|
||||
assertSame(role.name(), painter.grass, output.get(0, 60, 0));
|
||||
assertSame(role.name(), painter.dirt, output.get(0, 40, 0));
|
||||
assertSame(role.name(), painter.grass, output.get(0, 40, 0));
|
||||
assertSame(role.name(), painter.rock, output.get(0, 38, 0));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,127 @@
|
||||
package art.arcane.iris.structure.placement;
|
||||
|
||||
import art.arcane.iris.generation.biome.IrisBiome;
|
||||
import art.arcane.iris.generation.decoration.IrisOreBands;
|
||||
import art.arcane.iris.generation.image.IrisImageMapRuntime;
|
||||
import art.arcane.iris.generation.runtime.Engine;
|
||||
import art.arcane.iris.generation.runtime.IrisComplex;
|
||||
import art.arcane.iris.generation.runtime.SeedManager;
|
||||
import art.arcane.iris.generation.stage.IrisTerrainNormalActuator;
|
||||
import art.arcane.iris.generation.terrain.IrisDimension;
|
||||
import art.arcane.iris.generation.terrain.IrisRegion;
|
||||
import art.arcane.iris.pack.loading.IrisData;
|
||||
import art.arcane.iris.testsupport.PlatformBinding;
|
||||
import art.arcane.volmlib.nativelib.terrain.NativeBlockState;
|
||||
import art.arcane.volmlib.nativelib.terrain.structure.StructureStrata;
|
||||
import art.arcane.volmlib.util.collection.KList;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
import art.arcane.volmlib.util.stream.ProceduralStream;
|
||||
import art.arcane.volmlib.util.stream.interpolation.Interpolated;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertSame;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.anyDouble;
|
||||
import static org.mockito.ArgumentMatchers.anyInt;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
public class IrisStructureStrataTest {
|
||||
private static final int MIN_HEIGHT = -64;
|
||||
|
||||
@Rule
|
||||
public final PlatformBinding platform = PlatformBinding.mockPlatform();
|
||||
|
||||
private final NativeBlockState rock = state("minecraft:stone");
|
||||
private final NativeBlockState grass = state("minecraft:grass_block");
|
||||
private final NativeBlockState dirt = state("minecraft:dirt");
|
||||
private final Engine engine = mock(Engine.class);
|
||||
private final IrisComplex complex = mock(IrisComplex.class);
|
||||
private final IrisBiome biome = mock(IrisBiome.class);
|
||||
private final IrisImageMapRuntime imageMap = mock(IrisImageMapRuntime.class);
|
||||
private final IrisData data = mock(IrisData.class);
|
||||
private final IrisDimension dimension = new IrisDimension().setBedrock(true).setHideOresForHiddenOre(true);
|
||||
|
||||
@Before
|
||||
public void wireEngine() {
|
||||
IrisRegion region = new IrisRegion();
|
||||
when(engine.getComplex()).thenReturn(complex);
|
||||
when(engine.getDimension()).thenReturn(dimension);
|
||||
when(engine.getData()).thenReturn(data);
|
||||
when(engine.getSeedManager()).thenReturn(mock(SeedManager.class));
|
||||
when(engine.getMinHeight()).thenReturn(MIN_HEIGHT);
|
||||
when(complex.getTrueBiomeStream()).thenReturn(ProceduralStream.of((x, z) -> biome, Interpolated.of(value -> 0D, value -> biome)));
|
||||
when(complex.getRegionStream()).thenReturn(ProceduralStream.of((x, z) -> region, Interpolated.of(value -> 0D, value -> region)));
|
||||
when(complex.getRockStream()).thenReturn(ProceduralStream.of((x, z) -> rock, Interpolated.of(value -> 0D, value -> rock)));
|
||||
when(complex.getImageMapRuntime()).thenReturn(imageMap);
|
||||
when(biome.generateLayersWithSlope(eq(dimension), anyDouble(), anyDouble(), any(RNG.class),
|
||||
anyInt(), anyInt(), eq(data), any())).thenReturn(new KList<>(List.of(grass, dirt, dirt)));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void aColumnPaintsTheBiomeSurfaceThenSoilThenRockDownFromItsSurface() {
|
||||
StructureStrata.Column column = IrisStructureStrata.world(engine).column(3, 5, 90, false);
|
||||
|
||||
assertSame(grass, column.block(90));
|
||||
assertSame(dirt, column.block(89));
|
||||
assertSame(dirt, column.block(88));
|
||||
assertSame(rock, column.block(87));
|
||||
assertSame(rock, column.block(40));
|
||||
assertEquals(3, column.soilDepth());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void layersComeFromTheInternalSurfaceHeight() {
|
||||
IrisStructureStrata.world(engine).column(3, 5, 90, false);
|
||||
|
||||
verify(biome).generateLayersWithSlope(eq(dimension), eq(3D), eq(5D), any(RNG.class),
|
||||
eq(90 - MIN_HEIGHT), eq(90 - MIN_HEIGHT), eq(data), any());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void aMappedSurfaceReplacesOnlyTheTopBlock() {
|
||||
NativeBlockState mapped = state("minecraft:podzol");
|
||||
when(imageMap.sampleSurfaceBlock(3, 5)).thenReturn(mapped);
|
||||
|
||||
StructureStrata.Column column = IrisStructureStrata.world(engine).column(3, 5, 90, false);
|
||||
|
||||
assertSame(mapped, column.block(90));
|
||||
assertSame(dirt, column.block(89));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void aSubmergedSurfaceTakesSoilInsteadOfLivingGrass() {
|
||||
StructureStrata.Column column = IrisStructureStrata.world(engine).column(3, 5, 50, true);
|
||||
|
||||
assertSame(IrisTerrainNormalActuator.submergedSoil(grass), column.block(50));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void oreBandsAreSampledAtEachHeightSoAFillNeverStretchesOneOreBlock() {
|
||||
dimension.setHideOresForHiddenOre(false);
|
||||
NativeBlockState coal = state("minecraft:coal_ore");
|
||||
IrisOreBands bands = mock(IrisOreBands.class);
|
||||
when(biome.getSurfaceOreBands()).thenReturn(IrisOreBands.EMPTY);
|
||||
when(biome.getUndergroundOreBands()).thenReturn(bands);
|
||||
when(bands.contains(anyInt())).thenReturn(true);
|
||||
when(bands.generate(eq(3), eq(40 - MIN_HEIGHT), eq(5), any(RNG.class), eq(data), any())).thenReturn(coal);
|
||||
|
||||
StructureStrata.Column column = IrisStructureStrata.world(engine).column(3, 5, 90, false);
|
||||
|
||||
assertSame(coal, column.block(40));
|
||||
assertSame(rock, column.block(41));
|
||||
}
|
||||
|
||||
private static NativeBlockState state(String key) {
|
||||
NativeBlockState state = mock(NativeBlockState.class);
|
||||
when(state.key()).thenReturn(key);
|
||||
return state;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user