mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-27 00:04:42 +00:00
Batch 7 stage 3: objects and placement through the api
The api describes a pack's objects and lets a module place one through the pack's placement graph: PlaceableObject, PackObjects (PackResources.objects()), ScaleMethod, and Placements.place(PlacementRun) on PackWorld with PlacementTerrain, StructureVolumes and PlacementOutcome, which moves here from the host. Stages read PlacementContext.placementTerrain() and input(type); mantle stages get MantleGenerationContext.placementTerrain(). BlockRegistry gains rotate (BlockTurn), merge, withProperty and matches; BlockTrait gains STORAGE; ModuleLog gains debugging(); PackSettings gains resources(); RunningWorld gains placementAt. README, DESIGN and CONTRACTS describe them, and the extension ledger drops ObjectHost and ObjectPlacement.
This commit is contained in:
1 parent
398f3879ae
commit
f1eb619344
34 files changed
+423
-27
No files matched your search
@@ -0,0 +1,35 @@
|
||||
package com.volmit.object;
|
||||
|
||||
import com.volmit.geometry.BlockBox;
|
||||
import com.volmit.resource.ResourceId;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* The pack's objects, ready to place, and the objects made from them: scaled variants and objects a module builds block
|
||||
* by block. The host loads, scales and keeps them for the pack snapshot, so asking again is cheap. Reached through
|
||||
* {@link com.volmit.resource.PackResources#objects()}; safe for concurrent calls.
|
||||
*/
|
||||
public interface PackObjects {
|
||||
/** The pack object {@code id} names, as {@link com.volmit.resource.PackResources#idOf} gives it for the key; empty when the pack has none. */
|
||||
Optional<PlaceableObject> object(ResourceId id);
|
||||
|
||||
/** The pack object's size, read without loading its blocks: from the origin to its width, height and depth; empty when the pack has none. */
|
||||
Optional<BlockBox> sizeOf(ResourceId id);
|
||||
|
||||
/**
|
||||
* {@code object} resized by {@code factor}, filling between its blocks with {@code method}. Built once per object,
|
||||
* factor and method, and kept within a memory budget.
|
||||
*/
|
||||
PlaceableObject scaled(PlaceableObject object, double factor, ScaleMethod method);
|
||||
|
||||
/**
|
||||
* {@code object} with air in the rooms and pockets a placement should clear, found by casting rays through it. Done
|
||||
* once per object; the object itself keeps the air, so later placements of it see it too.
|
||||
*/
|
||||
PlaceableObject smartBored(PlaceableObject object);
|
||||
|
||||
/** An object of {@code blocks}, at their offsets from its center, declared {@code width} by {@code height} by {@code depth} with its center in the middle; placeable like the pack's. */
|
||||
PlaceableObject build(String name, int width, int height, int depth, List<ObjectBlock> blocks);
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.volmit.object;
|
||||
|
||||
import com.volmit.geometry.BlockPosition;
|
||||
|
||||
/**
|
||||
* An object ready to be placed: one of the pack's, a scaled variant of one, or one a module built
|
||||
* ({@link PackObjects}). Its size is the size it was declared with, which boring and terrain bends cover even where it
|
||||
* has no block. Immutable; safe to share between threads.
|
||||
*/
|
||||
public interface PlaceableObject {
|
||||
/**
|
||||
* The object's name: the key the pack's files name it by, such as {@code trees/oak}, also for its scaled variants, or
|
||||
* the name the module that built it gave it.
|
||||
*/
|
||||
String name();
|
||||
|
||||
int width();
|
||||
|
||||
int height();
|
||||
|
||||
int depth();
|
||||
|
||||
/** The block the object's offsets count from, relative to its corner. */
|
||||
BlockPosition center();
|
||||
|
||||
/** The object's blocks at their offsets from {@link #center()}, so the geometry's anchor is the origin. */
|
||||
GeneratedObject geometry();
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.volmit.object;
|
||||
|
||||
/** How a scaled object fills the blocks between its source blocks when it grows ({@link PackObjects#scaled}). */
|
||||
public enum ScaleMethod {
|
||||
/** Each source block becomes a box of blocks. */
|
||||
NONE,
|
||||
/** Linear interpolation in three dimensions. */
|
||||
TRILINEAR,
|
||||
/** Cubic spline interpolation in three dimensions; smoother, much slower. */
|
||||
TRICUBIC,
|
||||
/** Hermite spline interpolation in three dimensions; smoother, much slower. */
|
||||
TRIHERMITE
|
||||
}
|
||||
Reference in new issue
Block a user