Reach slope-tilted objects as far as a vertical rotation

A placement that turns towards the slope can tilt a tall object even when its configured rotation is disabled, so its reach counted only the horizontal footprint and the write and read windows cut it off at chunk seams. Count it like a vertical rotation: the tallest dimension as footprint and the full translation vector.

Upstream: 7aaf346ce b34e5e767
This commit is contained in:
piexel committed 2026-11-10 01:10:32 +01:00
1 parent 971cad0463
commit 867851366d
2 files changed
+19 -6

No files matched your search

@@ -60,6 +60,18 @@ public class PlacementReachTest {
assertEquals(53, PlacementReach.of(new ObjectSize(5, 48, 7), placement)); assertEquals(53, PlacementReach.of(new ObjectSize(5, 48, 7), placement));
} }
@Test
public void slopeTiltReachesAsFarAsAVerticalRotationEvenWhenTheRotationIsDisabled() {
String disabledRotation = "\"rotation\":{\"enabled\":false}";
ObjectPlacement flat = TestSettings.of(ObjectPlacement.class, "{" + disabledRotation + ",\"translate\":{\"x\":3,\"y\":4}}");
ObjectPlacement tilted = TestSettings.of(ObjectPlacement.class,
"{" + disabledRotation + ",\"rotateTowardsSlope\":true,\"translate\":{\"x\":3,\"y\":4}}");
ObjectSize tallObject = new ObjectSize(5, 48, 7);
assertEquals(10, PlacementReach.of(tallObject, flat));
assertEquals(53, PlacementReach.of(tallObject, tilted));
}
@Test @Test
public void scaleWarpAndVacuumExpandPlacementReach() { public void scaleWarpAndVacuumExpandPlacementReach() {
ObjectPlacement placement = TestSettings.of(ObjectPlacement.class, ObjectPlacement placement = TestSettings.of(ObjectPlacement.class,
@@ -111,21 +111,22 @@ final class PlacementReach {
} }
static int of(ObjectSize size, ObjectPlacement placement) { static int of(ObjectSize size, ObjectPlacement placement) {
return of(size, placement.mode().placeMode(), placement.scale().maxScale(), placement.rotation(), placement.translate(), return of(size, placement.mode().placeMode(), placement.scale().maxScale(), placement.rotation(), placement.rotateTowardsSlope(),
placement.warp() == null || placement.warp().isFlat() ? 0 : placement.warp().multiplier(), placement.translate(), placement.warp() == null || placement.warp().isFlat() ? 0 : placement.warp().multiplier(),
placement.vacuumSettings().orElse(null)); placement.vacuumSettings().orElse(null));
} }
private static int of(ObjectSize size, PlaceMode mode, Double maxScale, ObjectRotation rotation, ObjectTranslate translate, private static int of(ObjectSize size, PlaceMode mode, Double maxScale, ObjectRotation rotation, boolean rotatesTowardsSlope,
Double warpMultiplier, VacuumSettings vacuum) { ObjectTranslate translate, Double warpMultiplier, VacuumSettings vacuum) {
double scale = maxScale == null ? 1D : Math.max(1D, maxScale); double scale = maxScale == null ? 1D : Math.max(1D, maxScale);
int width = scaledDimension(size.width(), scale); int width = scaledDimension(size.width(), scale);
int height = scaledDimension(size.height(), scale); int height = scaledDimension(size.height(), scale);
int depth = scaledDimension(size.depth(), scale); int depth = scaledDimension(size.depth(), scale);
boolean rotateX = rotation != null && rotation.enabled() && rotation.xAxis() != null && rotation.xAxis().enabled(); boolean rotateX = rotation != null && rotation.enabled() && rotation.xAxis() != null && rotation.xAxis().enabled();
boolean rotateZ = rotation != null && rotation.enabled() && rotation.zAxis() != null && rotation.zAxis().enabled(); boolean rotateZ = rotation != null && rotation.enabled() && rotation.zAxis() != null && rotation.zAxis().enabled();
int footprint = rotateX || rotateZ ? Math.max(width, Math.max(height, depth)) : Math.max(width, depth); boolean tiltsVertically = rotatesTowardsSlope || rotateX || rotateZ;
int translation = translationReach(translate, rotation, rotateX || rotateZ); int footprint = tiltsVertically ? Math.max(width, Math.max(height, depth)) : Math.max(width, depth);
int translation = translationReach(translate, rotation, tiltsVertically);
int warp = warpMultiplier == null ? 0 : (int) Math.ceil(Math.abs(warpMultiplier) / 2D); int warp = warpMultiplier == null ? 0 : (int) Math.ceil(Math.abs(warpMultiplier) / 2D);
int vacuumReach = mode.bendsTerrain() ? 2 * vacuumRadius(mode, vacuum) : 0; int vacuumReach = mode.bendsTerrain() ? 2 * vacuumRadius(mode, vacuum) : 0;
long reach = (long) footprint + translation + warp + vacuumReach; long reach = (long) footprint + translation + warp + vacuumReach;