mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-10-25 21:40:05 +00:00
c
This commit is contained in:
1 parent
d20b3af9b9
commit
cf2e7df298
3 files changed
+34
-3
No files matched your search
@@ -963,6 +963,7 @@ public class IrisObject extends IrisRegistrant {
|
|||||||
int lowest = Integer.MAX_VALUE;
|
int lowest = Integer.MAX_VALUE;
|
||||||
int topLayer = Integer.MIN_VALUE;
|
int topLayer = Integer.MIN_VALUE;
|
||||||
int vacuumLowest = Integer.MAX_VALUE;
|
int vacuumLowest = Integer.MAX_VALUE;
|
||||||
|
int vacuumHighest = Integer.MIN_VALUE;
|
||||||
y += yrand;
|
y += yrand;
|
||||||
readLock.lock();
|
readLock.lock();
|
||||||
|
|
||||||
@@ -1132,6 +1133,9 @@ public class IrisObject extends IrisRegistrant {
|
|||||||
if (vacuuming && yy < vacuumLowest) {
|
if (vacuuming && yy < vacuumLowest) {
|
||||||
vacuumLowest = yy;
|
vacuumLowest = yy;
|
||||||
}
|
}
|
||||||
|
if (vacuuming && yy > vacuumHighest) {
|
||||||
|
vacuumHighest = yy;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
@@ -1370,7 +1374,7 @@ public class IrisObject extends IrisRegistrant {
|
|||||||
int highZ = IrisObjectVacuum.footprintHigh(rotDim.getBlockZ());
|
int highZ = IrisObjectVacuum.footprintHigh(rotDim.getBlockZ());
|
||||||
int centerX = x + config.getTranslate().getX();
|
int centerX = x + config.getTranslate().getX();
|
||||||
int centerZ = z + config.getTranslate().getZ();
|
int centerZ = z + config.getTranslate().getZ();
|
||||||
vacuumTerrain(placer, config, centerX, centerZ, lowX, highX, lowZ, highZ, vacuumLowest);
|
vacuumTerrain(placer, config, centerX, centerZ, lowX, highX, lowZ, highZ, vacuumLowest, vacuumHighest);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (heightmap != null) {
|
if (heightmap != null) {
|
||||||
@@ -1409,7 +1413,7 @@ public class IrisObject extends IrisRegistrant {
|
|||||||
+ "(forcePlace=false, fromBottom=false, mode!=FLOATING). Skipping to protect bedrock.");
|
+ "(forcePlace=false, fromBottom=false, mode!=FLOATING). Skipping to protect bedrock.");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void vacuumTerrain(IObjectPlacer placer, IrisObjectPlacement config, int centerX, int centerZ, int lowX, int highX, int lowZ, int highZ, int baseY) {
|
private void vacuumTerrain(IObjectPlacer placer, IrisObjectPlacement config, int centerX, int centerZ, int lowX, int highX, int lowZ, int highZ, int baseY, int topY) {
|
||||||
ObjectPlaceMode mode = config.getMode();
|
ObjectPlaceMode mode = config.getMode();
|
||||||
IrisVacuumSettings settings = config.getVacuumSettings();
|
IrisVacuumSettings settings = config.getVacuumSettings();
|
||||||
int radius = IrisObjectVacuum.resolveRadius(mode, settings);
|
int radius = IrisObjectVacuum.resolveRadius(mode, settings);
|
||||||
@@ -1448,7 +1452,9 @@ public class IrisObject extends IrisRegistrant {
|
|||||||
placer.set(cx, yy, cz, fill);
|
placer.set(cx, yy, cz, fill);
|
||||||
}
|
}
|
||||||
} else if (targetY < origY) {
|
} else if (targetY < origY) {
|
||||||
for (int yy = origY; yy > targetY; yy--) {
|
boolean inside = IrisObjectVacuum.outset(dx, lowX, highX) == 0 && IrisObjectVacuum.outset(dz, lowZ, highZ) == 0;
|
||||||
|
int carveFloor = IrisObjectVacuum.carveFloorY(targetY, topY, inside);
|
||||||
|
for (int yy = origY; yy >= carveFloor; yy--) {
|
||||||
placer.set(cx, yy, cz, AIR);
|
placer.set(cx, yy, cz, AIR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -90,4 +90,12 @@ public final class IrisObjectVacuum {
|
|||||||
double factor = Math.pow(t, Math.max(0.25, falloff));
|
double factor = Math.pow(t, Math.max(0.25, falloff));
|
||||||
return (int) Math.round(originalY + ((meetY - originalY) * factor));
|
return (int) Math.round(originalY + ((meetY - originalY) * factor));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static int carveFloorY(int targetY, int objectTopY, boolean insideFootprint) {
|
||||||
|
int floor = targetY + 1;
|
||||||
|
if (insideFootprint) {
|
||||||
|
floor = Math.max(floor, objectTopY + 1);
|
||||||
|
}
|
||||||
|
return floor;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -126,4 +126,21 @@ public class IrisObjectVacuumTest {
|
|||||||
assertFalse(IrisObjectVacuum.isVacuumMode(ObjectPlaceMode.PAINT));
|
assertFalse(IrisObjectVacuum.isVacuumMode(ObjectPlaceMode.PAINT));
|
||||||
assertFalse(IrisObjectVacuum.isVacuumMode(ObjectPlaceMode.FLOATING));
|
assertFalse(IrisObjectVacuum.isVacuumMode(ObjectPlaceMode.FLOATING));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void carveFloorPreservesBuriedObjectInsideFootprint() {
|
||||||
|
int surfaceY = 122;
|
||||||
|
int baseY = 110;
|
||||||
|
int topY = 119;
|
||||||
|
int meetY = baseY - 1;
|
||||||
|
|
||||||
|
int insideFloor = IrisObjectVacuum.carveFloorY(meetY, topY, true);
|
||||||
|
assertEquals("inside the footprint the carve must stop one above the object top", topY + 1, insideFloor);
|
||||||
|
assertTrue("inside carve must not reach the object's blocks", insideFloor > topY);
|
||||||
|
assertTrue("inside carve still removes the terrain burying the object", insideFloor <= surfaceY + 1);
|
||||||
|
|
||||||
|
int ringFloor = IrisObjectVacuum.carveFloorY(meetY, topY, false);
|
||||||
|
assertEquals("the ring carves down to the deformation target (the crater floor)", meetY + 1, ringFloor);
|
||||||
|
assertTrue("ring crater is deeper than the object-protected inside floor", ringFloor < insideFloor);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user