mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-27 00:04:42 +00:00
Cover an object's declared size in its placement area
Boring and terrain bends cover the object's declared size, which can be larger than the bounds of its blocks, so the placement area now reaches whichever of the two is farther from the anchor.
This commit is contained in:
1 parent
f052960e2f
commit
5f30e27485
3 files changed
+29
-4
No files matched your search
@@ -72,7 +72,7 @@ public final class ModuleObjectPlacement {
|
||||
Objects.requireNonNull(data, "Object placement data is required.");
|
||||
ResolvedGraph graph = data.getModules().pack().placement();
|
||||
GeneratedObject geometry = geometryOf(object, config);
|
||||
BlockBox area = PlacementArea.around(geometry, config, x, z, graph.reach().blocks());
|
||||
BlockBox area = PlacementArea.around(object, geometry, config, x, z, graph.reach().blocks());
|
||||
PlatformBlockStates states = new PlatformBlockStates(ModuleObjectPlacement::platformState);
|
||||
ObjectPlacerEdit edit = new ObjectPlacerEdit(placer, area, states, listener);
|
||||
IrisPlacement placement = new IrisPlacement(object, config, placer, cave, x, requestedY, z, data, states, edit);
|
||||
|
||||
@@ -20,6 +20,7 @@ package art.arcane.iris.core.modules;
|
||||
|
||||
import art.arcane.iris.engine.object.noise.IrisGeneratorStyle;
|
||||
import art.arcane.iris.engine.object.placement.IrisObjectPlacement;
|
||||
import art.arcane.iris.engine.object.prefab.IrisObject;
|
||||
import art.arcane.iris.engine.object.prefab.IrisObjectTranslate;
|
||||
import com.volmit.mantle.BlockBox;
|
||||
import com.volmit.object.GeneratedObject;
|
||||
@@ -27,7 +28,9 @@ import com.volmit.object.GeneratedObject;
|
||||
/**
|
||||
* The columns one object placement may read and write: every column the object reaches in any rotation
|
||||
* around its anchor, moved by its translation and surface warp, widened by one block for neighbor reads and
|
||||
* by the placement pipeline's reach. Heights are not bounded; the placer keeps writes inside its world.
|
||||
* by the placement pipeline's reach. The object reaches as far as its blocks or its declared size, whichever
|
||||
* is larger, since boring and terrain bends cover the declared size. Heights are not bounded; the placer
|
||||
* keeps writes inside its world.
|
||||
*/
|
||||
final class PlacementArea {
|
||||
private static final int NEIGHBOR_READ_BLOCKS = 1;
|
||||
@@ -35,12 +38,23 @@ final class PlacementArea {
|
||||
private PlacementArea() {
|
||||
}
|
||||
|
||||
static BlockBox around(GeneratedObject object, IrisObjectPlacement config, int x, int z, int pipelineReachBlocks) {
|
||||
int reach = rotationRadius(object.bounds()) + translationLength(config.getTranslate())
|
||||
static BlockBox around(IrisObject object, GeneratedObject geometry, IrisObjectPlacement config, int x, int z,
|
||||
int pipelineReachBlocks) {
|
||||
int objectRadius = Math.max(rotationRadius(geometry.bounds()), rotationRadius(declaredBox(object)));
|
||||
int reach = objectRadius + translationLength(config.getTranslate())
|
||||
+ warpMargin(config.getWarp()) + NEIGHBOR_READ_BLOCKS + pipelineReachBlocks;
|
||||
return new BlockBox(x - reach, Integer.MIN_VALUE, z - reach, x + reach + 1, Integer.MAX_VALUE, z + reach + 1);
|
||||
}
|
||||
|
||||
/** The object's declared size around its center, which its block offsets count from. */
|
||||
private static BlockBox declaredBox(IrisObject object) {
|
||||
int centerX = object.getCenter().getBlockX();
|
||||
int centerY = object.getCenter().getBlockY();
|
||||
int centerZ = object.getCenter().getBlockZ();
|
||||
return new BlockBox(-centerX, -centerY, -centerZ,
|
||||
Math.max(1, object.getW()) - centerX, Math.max(1, object.getH()) - centerY, Math.max(1, object.getD()) - centerZ);
|
||||
}
|
||||
|
||||
/** The farthest any block of {@code bounds} lies from the origin, which rotations turn around. */
|
||||
private static int rotationRadius(BlockBox bounds) {
|
||||
long x = farthest(bounds.minX(), bounds.maxX());
|
||||
|
||||
+11
@@ -149,6 +149,17 @@ public class IrisObjectPlacementRegressionTest {
|
||||
assertTrue(airWrites.stream().allMatch(write -> write.z() <= -3 && write.z() >= -5));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void boreCoversTheDeclaredSizeBeyondTheObjectsBlocks() {
|
||||
RecordingPlacer placer = new RecordingPlacer(null);
|
||||
IrisObject object = new IrisObject(5, 1, 5);
|
||||
object.setUnsigned(2, 0, 2, solid);
|
||||
|
||||
assertEquals(ANCHOR_Y, object.place(0, ANCHOR_Y, 0, placer, placement().setBore(true), new RNG(2L), data));
|
||||
|
||||
assertEquals(24, placer.writesOf(keyOf(IrisObject.States.AIR)).size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void collisionCheckUsesTheTransformedBounds() {
|
||||
PlacedObject forbidden = new PlacedObject(null, object("forbidden"), 1, 0, 0);
|
||||
|
||||
Reference in new issue
Block a user