mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-10-26 14:00:26 +00:00
Bound slope placement rotation
- Use the radial three-dimensional bound whenever rotateTowardsSlope is set, including placements whose configured rotation is disabled - Group the support read margin helper with the other static factories
This commit is contained in:
1 parent
7aaf346ce3
commit
b34e5e7676
2 files changed
+20
-9
No files matched your search
@@ -61,6 +61,10 @@ public record PlacementReach(int horizontal, int readMargin) {
|
||||
return new Profile(Objects.requireNonNull(placement, "placement"));
|
||||
}
|
||||
|
||||
public static int supportReadMargin(int surfaceSupportBuffer) {
|
||||
return 1 + Math.max(0, surfaceSupportBuffer);
|
||||
}
|
||||
|
||||
public int input() {
|
||||
return saturate((long) horizontal + readMargin);
|
||||
}
|
||||
@@ -75,10 +79,6 @@ public record PlacementReach(int horizontal, int readMargin) {
|
||||
return minimumReadMargin <= readMargin ? this : new PlacementReach(horizontal, minimumReadMargin);
|
||||
}
|
||||
|
||||
public static int supportReadMargin(int surfaceSupportBuffer) {
|
||||
return 1 + Math.max(0, surfaceSupportBuffer);
|
||||
}
|
||||
|
||||
private static int roundedBound(double maximumMagnitude) {
|
||||
return saturate((long) Math.floor(maximumMagnitude + 0.5D + ROUNDING_SLACK));
|
||||
}
|
||||
@@ -99,6 +99,7 @@ public record PlacementReach(int horizontal, int readMargin) {
|
||||
private final IrisBlockVector translation;
|
||||
private final boolean rotating;
|
||||
private final boolean radial;
|
||||
private final boolean vertical;
|
||||
private final int[] spinsX;
|
||||
private final int[] spinsY;
|
||||
private final int[] spinsZ;
|
||||
@@ -117,7 +118,9 @@ public record PlacementReach(int horizontal, int readMargin) {
|
||||
this.spinsY = rotating ? distinctSpins(configuredRotation, Axis.Y) : new int[]{0};
|
||||
this.spinsZ = rotating ? distinctSpins(configuredRotation, Axis.Z) : new int[]{0};
|
||||
long kernels = (long) spinsX.length * spinsY.length * spinsZ.length;
|
||||
this.radial = rotating && (placement.isRotateTowardsSlope() || kernels > MAXIMUM_ROTATION_KERNELS);
|
||||
this.radial = placement.isRotateTowardsSlope() || (rotating && kernels > MAXIMUM_ROTATION_KERNELS);
|
||||
this.vertical = placement.isRotateTowardsSlope()
|
||||
|| (rotating && (configuredRotation.canRotateX() || configuredRotation.canRotateZ()));
|
||||
this.additive = saturate((long) warpReach(placement.getWarp()) + vacuumReach(placement));
|
||||
this.readMargin = supportReadMargin(placement.getSurfaceSupportBuffer());
|
||||
}
|
||||
@@ -134,12 +137,12 @@ public record PlacementReach(int horizontal, int readMargin) {
|
||||
}
|
||||
|
||||
private int rotatedReach(Extent extent) {
|
||||
if (!rotating) {
|
||||
return unrotatedReach(extent);
|
||||
}
|
||||
if (radial) {
|
||||
return radialReach(extent);
|
||||
}
|
||||
if (!rotating) {
|
||||
return unrotatedReach(extent);
|
||||
}
|
||||
double maximum = 0D;
|
||||
for (int spinX : spinsX) {
|
||||
for (int spinY : spinsY) {
|
||||
@@ -172,7 +175,6 @@ public record PlacementReach(int horizontal, int readMargin) {
|
||||
}
|
||||
|
||||
private int radialReach(Extent extent) {
|
||||
boolean vertical = rotation.canRotateX() || rotation.canRotateZ();
|
||||
double translateX = translation == null ? 0D : translation.getX();
|
||||
double translateY = translation == null ? 0D : translation.getY();
|
||||
double translateZ = translation == null ? 0D : translation.getZ();
|
||||
|
||||
@@ -107,6 +107,15 @@ public class PlacementReachTest {
|
||||
assertEquals(14, PlacementReach.of(object, placement, 1D).horizontal());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void slopeRotationIsBoundedEvenWhenTheConfiguredRotationIsDisabled() {
|
||||
IrisObject object = singleBlockObject(21, 9, 21);
|
||||
IrisObjectPlacement placement = new IrisObjectPlacement().setRotation(IrisObjectRotation.of(0D, 0D, 0D));
|
||||
|
||||
assertEquals(10, PlacementReach.of(object, placement, 1D).horizontal());
|
||||
assertEquals(15, PlacementReach.of(object, placement.setRotateTowardsSlope(true), 1D).horizontal());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void unionKeepsTheLargestReachAndTheLargestInput() {
|
||||
PlacementReach union = new PlacementReach(10, 2).union(new PlacementReach(4, 12));
|
||||
|
||||
Reference in new issue
Block a user