mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-10-21 15:57:38 +00:00
adding mroe of this
This commit is contained in:
1 parent
03746468ec
commit
4adef4576f
17 files changed
+576
-35
No files matched your search
@@ -125,6 +125,19 @@ public class CarveOrphanSweepTest {
|
||||
assertTrue(fixture.wasMarked(6, 30, 6));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void protectedSurfaceFluidSupportIsNotMarkedCarved() {
|
||||
Fixture fixture = new Fixture();
|
||||
fixture.carveBox(1, 14, 25, 35, 1, 14);
|
||||
fixture.uncarve(7, 30, 7);
|
||||
fixture.protect(7, 30, 7);
|
||||
|
||||
int marked = fixture.sweep();
|
||||
|
||||
assertEquals(0, marked);
|
||||
assertFalse(fixture.wasMarked(7, 30, 7));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void sweepIsDeterministicAndIdempotent() {
|
||||
Fixture first = new Fixture();
|
||||
@@ -166,6 +179,7 @@ public class CarveOrphanSweepTest {
|
||||
private final boolean[] carved = new boolean[16 * WORLD_HEIGHT * 16];
|
||||
private final int[] surfaceHeights = new int[256];
|
||||
private final List<Integer> marks = new ArrayList<>();
|
||||
private int protectedCell = -1;
|
||||
|
||||
private Fixture() {
|
||||
Arrays.fill(surfaceHeights, SURFACE_Y);
|
||||
@@ -193,6 +207,10 @@ public class CarveOrphanSweepTest {
|
||||
return marks.contains(index(localX, y, localZ));
|
||||
}
|
||||
|
||||
private void protect(int localX, int y, int localZ) {
|
||||
protectedCell = index(localX, y, localZ);
|
||||
}
|
||||
|
||||
private List<Integer> marks() {
|
||||
return marks;
|
||||
}
|
||||
@@ -215,5 +233,10 @@ public class CarveOrphanSweepTest {
|
||||
carved[index(localX, y, localZ)] = true;
|
||||
marks.add(index(localX, y, localZ));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isProtected(int localX, int y, int localZ) {
|
||||
return protectedCell == index(localX, y, localZ);
|
||||
}
|
||||
}
|
||||
}
|
||||
+47
-3
@@ -286,6 +286,13 @@ public class IrisCaveCarver3DNearParityTest {
|
||||
assertTrue(containsLiquidInRange(capture.carvedLiquids, 65, 70, (byte) 0));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void surfaceFluidBoundaryProtectsReservoirWithoutFloodingDeeperCaves() {
|
||||
assertSurfaceFluidBoundaryForProfile(createFluidProfile().setAdaptiveSampling(false).setSampleStep(1));
|
||||
assertSurfaceFluidBoundaryForProfile(createFluidProfile().setAdaptiveSampling(true).setSampleStep(1));
|
||||
assertSurfaceFluidBoundaryForProfile(createFluidProfile().setAdaptiveSampling(false).setSampleStep(4));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void floorRequiredFluidResolvesAfterTheCompleteCarveMask() {
|
||||
Engine engine = createEngine(80, 70);
|
||||
@@ -301,7 +308,7 @@ public class IrisCaveCarver3DNearParityTest {
|
||||
WriterCapture firstCapture = createWriterCapture(80);
|
||||
CaveFluidSupportPlan supportPlan = new CaveFluidSupportPlan();
|
||||
new IrisCaveCarver3D(engine, supportedProfile).carve(
|
||||
firstCapture.writer, chunkX, chunkZ, fullWeights(), 0D, 0D, null, surfaceHeights, null, supportPlan);
|
||||
firstCapture.writer, chunkX, chunkZ, fullWeights(), 0D, 0D, null, surfaceHeights, null, null, supportPlan);
|
||||
int candidateCount = countLiquid(firstCapture, (byte) 1);
|
||||
supportPlan.resolve(firstCapture.writer.acquireChunk(chunkX, chunkZ));
|
||||
|
||||
@@ -362,13 +369,13 @@ public class IrisCaveCarver3DNearParityTest {
|
||||
|
||||
new IrisCaveCarver3D(engine, fluidProfile).carve(
|
||||
capture.writer, 0, 0, fullWeights(), 0D, 0D, null, surfaceHeights,
|
||||
new IrisRange(20D, 64D), fluidSupportPlan);
|
||||
null, new IrisRange(20D, 64D), fluidSupportPlan);
|
||||
String fluidCell = firstCellWithLiquid(capture, (byte) 1);
|
||||
assertTrue(fluidCell != null);
|
||||
int fluidY = coordinate(fluidCell, 1);
|
||||
new IrisCaveCarver3D(engine, airProfile).carve(
|
||||
capture.writer, 0, 0, fullWeights(), 0D, 0D, null, surfaceHeights,
|
||||
new IrisRange(fluidY - 1D, fluidY - 1D), fluidSupportPlan);
|
||||
null, new IrisRange(fluidY - 1D, fluidY - 1D), fluidSupportPlan);
|
||||
|
||||
assertEquals(Byte.valueOf((byte) 1), capture.carvedLiquids.get(fluidCell));
|
||||
fluidSupportPlan.resolve(capture.writer.acquireChunk(0, 0));
|
||||
@@ -732,6 +739,43 @@ public class IrisCaveCarver3DNearParityTest {
|
||||
.setAllowLava(true);
|
||||
}
|
||||
|
||||
private void assertSurfaceFluidBoundaryForProfile(IrisCaveProfile profile) {
|
||||
Engine engine = createEngine(80, 70);
|
||||
int[] surfaceHeights = filledHeights(70);
|
||||
surfaceHeights[0] = 60;
|
||||
int[] boundaryStartY = new int[256];
|
||||
Arrays.fill(boundaryStartY, SurfaceFluidBoundaryPlan.NO_BOUNDARY);
|
||||
boundaryStartY[0] = 60;
|
||||
boundaryStartY[16] = 61;
|
||||
WriterCapture capture = createWriterCapture(80);
|
||||
CaveFluidSupportPlan supportPlan = new CaveFluidSupportPlan();
|
||||
|
||||
new IrisCaveCarver3D(engine, profile.setFluidMinDepthBelowSurface(0).setFluidRequiresFloor(false)).carve(
|
||||
capture.writer,
|
||||
0,
|
||||
0,
|
||||
fullWeights(),
|
||||
0D,
|
||||
0D,
|
||||
null,
|
||||
surfaceHeights,
|
||||
boundaryStartY,
|
||||
null,
|
||||
supportPlan
|
||||
);
|
||||
|
||||
assertTrue(capture.carvedCells.contains(cellKey(0, 56, 0)));
|
||||
assertFalse(capture.carvedCells.contains(cellKey(0, 60, 0)));
|
||||
assertTrue(capture.carvedCells.contains(cellKey(1, 60, 0)));
|
||||
for (int y = 61; y <= 64; y++) {
|
||||
assertFalse(capture.carvedCells.contains(cellKey(1, y, 0)));
|
||||
}
|
||||
assertTrue(capture.carvedCells.contains(cellKey(1, 65, 0)));
|
||||
assertTrue(capture.carvedCells.contains(cellKey(2, 64, 0)));
|
||||
assertTrue(countLiquid(capture, (byte) 1) > 0);
|
||||
assertTrue(countLiquid(capture, (byte) 0) > 0);
|
||||
}
|
||||
|
||||
private WriterCapture createWriterCapture(int worldHeight) {
|
||||
MantleWriter writer = mock(MantleWriter.class);
|
||||
@SuppressWarnings("unchecked")
|
||||
|
||||
+54
@@ -0,0 +1,54 @@
|
||||
package art.arcane.iris.engine.mantle.components;
|
||||
|
||||
import art.arcane.iris.engine.object.IrisBiome;
|
||||
import art.arcane.volmlib.util.matter.MatterCavern;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
public class MantleObjectComponentCaveAnchorTest {
|
||||
@Test
|
||||
public void biomeOwnedPlacementsRejectForeignCaveBands() {
|
||||
IrisBiome frozen = biome("carving/ice");
|
||||
IrisBiome deepDark = biome("carving/standard-deepdark");
|
||||
IrisBiome surface = biome("frozen/ice-spikes");
|
||||
|
||||
assertFalse(MantleObjectComponent.caveAnchorBiomeConflicts(frozen, surface, "carving/ice"));
|
||||
assertTrue(MantleObjectComponent.caveAnchorBiomeConflicts(deepDark, surface, "carving/ice"));
|
||||
assertFalse(MantleObjectComponent.caveAnchorBiomeConflicts(deepDark, surface, null));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void dryPlacementsRejectFluidAndDefaultLavaCells() {
|
||||
MatterCavern air = new MatterCavern(true, "", (byte) 0);
|
||||
MatterCavern water = new MatterCavern(true, "", (byte) 1);
|
||||
MatterCavern lava = new MatterCavern(true, "", (byte) 2);
|
||||
|
||||
assertFalse(MantleObjectComponent.acceptsCaveAnchorFluid(false, water, 20, 8));
|
||||
assertFalse(MantleObjectComponent.acceptsCaveAnchorFluid(false, lava, 20, 8));
|
||||
assertFalse(MantleObjectComponent.acceptsCaveAnchorFluid(false, air, 8, 8));
|
||||
assertTrue(MantleObjectComponent.acceptsCaveAnchorFluid(false, air, 9, 8));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void explicitWetAndForcedAirPlacementsRemainEligible() {
|
||||
MatterCavern water = new MatterCavern(true, "", (byte) 1);
|
||||
MatterCavern forcedAir = new MatterCavern(true, "", (byte) 3);
|
||||
|
||||
assertTrue(MantleObjectComponent.acceptsCaveAnchorFluid(true, water, 20, 8));
|
||||
assertTrue(MantleObjectComponent.acceptsCaveAnchorFluid(false, forcedAir, 0, 8));
|
||||
assertFalse(MantleObjectComponent.acceptsCaveAnchorFluid(
|
||||
true,
|
||||
new MatterCavern(false, "", (byte) 0),
|
||||
20,
|
||||
8
|
||||
));
|
||||
}
|
||||
|
||||
private static IrisBiome biome(String loadKey) {
|
||||
IrisBiome biome = new IrisBiome();
|
||||
biome.setLoadKey(loadKey);
|
||||
return biome;
|
||||
}
|
||||
}
|
||||
+160
@@ -0,0 +1,160 @@
|
||||
package art.arcane.iris.engine.mantle.components;
|
||||
|
||||
import art.arcane.volmlib.util.math.PowerOfTwoCoordinates;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertThrows;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
public class SurfaceFluidBoundaryPlanTest {
|
||||
private static final int CHUNK_SIZE = 16;
|
||||
private static final int FIELD_SIZE = 22;
|
||||
private static final int PADDING = 3;
|
||||
private static final int FLUID_HEIGHT = 64;
|
||||
|
||||
@Test
|
||||
public void submergedColumnProtectsItsSeabedWithoutBlockingTheCaveBelow() {
|
||||
Fixture fixture = new Fixture();
|
||||
fixture.setChunkSurface(8, 8, 60);
|
||||
|
||||
fixture.resolve();
|
||||
|
||||
int boundaryY = fixture.boundary(8, 8);
|
||||
assertEquals(60, boundaryY);
|
||||
assertFalse(SurfaceFluidBoundaryPlan.protects(fixture.boundaryStartY, fixture.index(8, 8), 59, FLUID_HEIGHT));
|
||||
assertTrue(SurfaceFluidBoundaryPlan.protects(fixture.boundaryStartY, fixture.index(8, 8), 60, FLUID_HEIGHT));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void dryCoastProtectsOnlyTheAdjacentFluidBand() {
|
||||
Fixture fixture = new Fixture();
|
||||
fixture.setFieldSurface(7, 8, 60D);
|
||||
|
||||
fixture.resolve();
|
||||
|
||||
int columnIndex = fixture.index(8, 8);
|
||||
assertEquals(61, fixture.boundary(8, 8));
|
||||
assertFalse(SurfaceFluidBoundaryPlan.protects(fixture.boundaryStartY, columnIndex, 60, FLUID_HEIGHT));
|
||||
assertTrue(SurfaceFluidBoundaryPlan.protects(fixture.boundaryStartY, columnIndex, 61, FLUID_HEIGHT));
|
||||
assertTrue(SurfaceFluidBoundaryPlan.protects(fixture.boundaryStartY, columnIndex, 64, FLUID_HEIGHT));
|
||||
assertFalse(SurfaceFluidBoundaryPlan.protects(fixture.boundaryStartY, columnIndex, 65, FLUID_HEIGHT));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void lowestCardinalReservoirBoundaryWins() {
|
||||
Fixture fixture = new Fixture();
|
||||
fixture.setFieldSurface(7, 8, 62D);
|
||||
fixture.setFieldSurface(9, 8, 58D);
|
||||
|
||||
fixture.resolve();
|
||||
|
||||
assertEquals(59, fixture.boundary(8, 8));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void roundedWaterlineAndDiagonalReservoirDoNotOverprotect() {
|
||||
Fixture wetRoundedDown = new Fixture();
|
||||
wetRoundedDown.setFieldSurface(7, 8, 63.49D);
|
||||
wetRoundedDown.resolve();
|
||||
assertEquals(64, wetRoundedDown.boundary(8, 8));
|
||||
|
||||
Fixture dryRoundedUp = new Fixture();
|
||||
dryRoundedUp.setFieldSurface(7, 8, 63.5D);
|
||||
dryRoundedUp.setFieldSurface(7, 7, 40D);
|
||||
dryRoundedUp.resolve();
|
||||
assertEquals(SurfaceFluidBoundaryPlan.NO_BOUNDARY, dryRoundedUp.boundary(8, 8));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void nonFluidPaletteDoesNotCreateAReservoirBoundary() {
|
||||
Fixture fixture = new Fixture();
|
||||
fixture.setFieldSurface(7, 8, 40D);
|
||||
fixture.setFieldHasFluid(7, 8, false);
|
||||
|
||||
fixture.resolve();
|
||||
|
||||
assertEquals(SurfaceFluidBoundaryPlan.NO_BOUNDARY, fixture.boundary(8, 8));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void paddedHaloProtectsEveryChunkEdge() {
|
||||
assertEdgeBoundary(0, 8, -1, 8);
|
||||
assertEdgeBoundary(15, 8, 16, 8);
|
||||
assertEdgeBoundary(8, 0, 8, -1);
|
||||
assertEdgeBoundary(8, 15, 8, 16);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void invalidFieldShapeIsRejected() {
|
||||
assertThrows(IllegalArgumentException.class, () -> SurfaceFluidBoundaryPlan.fill(
|
||||
new int[CHUNK_SIZE * CHUNK_SIZE],
|
||||
new double[FIELD_SIZE * FIELD_SIZE],
|
||||
new boolean[FIELD_SIZE * FIELD_SIZE],
|
||||
FIELD_SIZE,
|
||||
0,
|
||||
FLUID_HEIGHT,
|
||||
new int[CHUNK_SIZE * CHUNK_SIZE]
|
||||
));
|
||||
}
|
||||
|
||||
private void assertEdgeBoundary(int localX, int localZ, int neighborLocalX, int neighborLocalZ) {
|
||||
Fixture fixture = new Fixture();
|
||||
fixture.setFieldSurface(neighborLocalX, neighborLocalZ, 60D);
|
||||
fixture.resolve();
|
||||
assertEquals(61, fixture.boundary(localX, localZ));
|
||||
}
|
||||
|
||||
private static final class Fixture {
|
||||
private final int[] chunkSurfaceHeights = new int[CHUNK_SIZE * CHUNK_SIZE];
|
||||
private final double[] fieldSurfaceHeights = new double[FIELD_SIZE * FIELD_SIZE];
|
||||
private final boolean[] fieldHasFluid = new boolean[FIELD_SIZE * FIELD_SIZE];
|
||||
private final int[] boundaryStartY = new int[CHUNK_SIZE * CHUNK_SIZE];
|
||||
|
||||
private Fixture() {
|
||||
Arrays.fill(chunkSurfaceHeights, 70);
|
||||
Arrays.fill(fieldSurfaceHeights, 70D);
|
||||
Arrays.fill(fieldHasFluid, true);
|
||||
}
|
||||
|
||||
private void setChunkSurface(int localX, int localZ, int surfaceY) {
|
||||
chunkSurfaceHeights[index(localX, localZ)] = surfaceY;
|
||||
setFieldSurface(localX, localZ, surfaceY);
|
||||
}
|
||||
|
||||
private void setFieldSurface(int localX, int localZ, double surfaceY) {
|
||||
int fieldX = localX + PADDING;
|
||||
int fieldZ = localZ + PADDING;
|
||||
fieldSurfaceHeights[(fieldX * FIELD_SIZE) + fieldZ] = surfaceY;
|
||||
}
|
||||
|
||||
private void setFieldHasFluid(int localX, int localZ, boolean hasFluid) {
|
||||
int fieldX = localX + PADDING;
|
||||
int fieldZ = localZ + PADDING;
|
||||
fieldHasFluid[(fieldX * FIELD_SIZE) + fieldZ] = hasFluid;
|
||||
}
|
||||
|
||||
private void resolve() {
|
||||
SurfaceFluidBoundaryPlan.fill(
|
||||
chunkSurfaceHeights,
|
||||
fieldSurfaceHeights,
|
||||
fieldHasFluid,
|
||||
FIELD_SIZE,
|
||||
PADDING,
|
||||
FLUID_HEIGHT,
|
||||
boundaryStartY
|
||||
);
|
||||
}
|
||||
|
||||
private int boundary(int localX, int localZ) {
|
||||
return boundaryStartY[index(localX, localZ)];
|
||||
}
|
||||
|
||||
private int index(int localX, int localZ) {
|
||||
return PowerOfTwoCoordinates.packLocal16(localX, localZ);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,18 +1,44 @@
|
||||
package art.arcane.iris.engine.object;
|
||||
|
||||
import art.arcane.iris.core.loader.IrisData;
|
||||
import art.arcane.iris.engine.object.annotations.Desc;
|
||||
import art.arcane.iris.spi.PlatformBlockState;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
public class IrisDepositTuningTest {
|
||||
@Test
|
||||
public void everyDepositEnumAndValueHasSchemaDescription() throws ReflectiveOperationException {
|
||||
for (Field modelField : IrisDepositGenerator.class.getDeclaredFields()) {
|
||||
Class<?> enumType = modelField.getType();
|
||||
if (!enumType.isEnum()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Desc typeDescription = enumType.getAnnotation(Desc.class);
|
||||
assertNotNull(enumType.getSimpleName(), typeDescription);
|
||||
assertFalse(typeDescription.value().isBlank());
|
||||
|
||||
Object[] constants = enumType.getEnumConstants();
|
||||
for (Object constant : constants) {
|
||||
String constantName = ((Enum<?>) constant).name();
|
||||
Desc constantDescription = enumType.getField(constantName).getAnnotation(Desc.class);
|
||||
assertNotNull(enumType.getSimpleName() + "." + constantName, constantDescription);
|
||||
assertFalse(constantDescription.value().isBlank());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void depositSizesScaleAndRemainWithinSchemaLimit() {
|
||||
assertEquals(8, IrisDepositGenerator.scaledDepositSize(4, 2D));
|
||||
|
||||
Reference in new issue
Block a user