mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-28 00:34:19 +00:00
Procedural object settings as module-owned IrisApi types: coral, crystal, formation, fungus, ruin and the tree profile classes; ResolvedProceduralPlacement bakes and places them
This commit is contained in:
1 parent
feaa1e88c4
commit
1f3e1c9aba
62 files changed
+2309
-1003
No files matched your search
@@ -19,6 +19,14 @@
|
||||
package art.arcane.iris.engine.mantle.components;
|
||||
|
||||
import art.arcane.iris.builtin.IrisStages;
|
||||
import art.arcane.iris.builtin.objects.coral.Coral;
|
||||
import art.arcane.iris.builtin.objects.crystal.Crystal;
|
||||
import art.arcane.iris.builtin.objects.formation.Formation;
|
||||
import art.arcane.iris.builtin.objects.fungi.Fungus;
|
||||
import art.arcane.iris.builtin.objects.ruin.Ruin;
|
||||
import art.arcane.iris.builtin.objects.tree.TreeCanopy;
|
||||
import art.arcane.iris.builtin.objects.tree.TreeDecorator;
|
||||
import art.arcane.iris.builtin.objects.tree.TreeSecondaryLeaf;
|
||||
import art.arcane.iris.core.modules.IrisMantleChunk;
|
||||
import art.arcane.iris.core.modules.IrisPackSettings;
|
||||
import art.arcane.iris.core.modules.IrisPackWorld;
|
||||
@@ -56,6 +64,14 @@ public final class ObjectModule implements IrisModule {
|
||||
@Override
|
||||
public void register(FeatureRegistry registry) {
|
||||
registry.registerService(ObjectsAt.class, ObjectModule::objectsAt);
|
||||
registry.registerHeldType(TreeCanopy.class);
|
||||
registry.registerHeldType(TreeDecorator.class);
|
||||
registry.registerHeldType(TreeSecondaryLeaf.class);
|
||||
registry.registerHeldType(Coral.class);
|
||||
registry.registerHeldType(Crystal.class);
|
||||
registry.registerHeldType(Formation.class);
|
||||
registry.registerHeldType(Fungus.class);
|
||||
registry.registerHeldType(Ruin.class);
|
||||
}
|
||||
|
||||
private static void place(MantleStageContext context) {
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
|
||||
package art.arcane.iris.engine.object.procedural;
|
||||
|
||||
import art.arcane.iris.engine.object.material.IrisMaterialPalette;
|
||||
import art.arcane.iris.engine.object.prefab.IrisObject;
|
||||
import art.arcane.iris.core.loader.IrisData;
|
||||
import art.arcane.iris.spi.PlatformBlockState;
|
||||
@@ -26,8 +25,10 @@ import art.arcane.iris.util.common.data.B;
|
||||
import art.arcane.iris.util.common.math.IrisBlockVector;
|
||||
import art.arcane.iris.util.common.math.Vector3i;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
import com.volmit.block.PaletteSpec;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* Shared low-level helpers for building procedural objects in memory: resolving a
|
||||
@@ -52,13 +53,26 @@ public final class IrisProceduralBlocks {
|
||||
};
|
||||
}
|
||||
|
||||
public static boolean paletteSet(IrisMaterialPalette palette) {
|
||||
return palette != null && palette.getPalette() != null && !palette.getPalette().isEmpty();
|
||||
public static boolean paletteSet(PaletteSpec palette) {
|
||||
return palette != null && !palette.palette().isEmpty();
|
||||
}
|
||||
|
||||
public static PlatformBlockState resolve(String block, IrisMaterialPalette palette, IrisData data, int x, int y, int z, RNG paletteRng) {
|
||||
public static boolean paletteSet(Optional<PaletteSpec> palette) {
|
||||
return palette.filter(IrisProceduralBlocks::paletteSet).isPresent();
|
||||
}
|
||||
|
||||
public static PlatformBlockState resolve(String block, Optional<PaletteSpec> palette, IrisData data, int x, int y, int z, RNG paletteRng) {
|
||||
return resolve(block, palette.orElse(null), data, x, y, z, paletteRng);
|
||||
}
|
||||
|
||||
public static PlatformBlockState resolve(Optional<String> block, Optional<PaletteSpec> palette, IrisData data, int x, int y, int z, RNG paletteRng) {
|
||||
return resolve(block.orElse(null), palette.orElse(null), data, x, y, z, paletteRng);
|
||||
}
|
||||
|
||||
/** The block of {@code palette} at the position, picked with the seed of {@code paletteRng} as the palette's old class did; else {@code block}. */
|
||||
public static PlatformBlockState resolve(String block, PaletteSpec palette, IrisData data, int x, int y, int z, RNG paletteRng) {
|
||||
if (paletteSet(palette)) {
|
||||
return palette.get(paletteRng, x, y, z, data);
|
||||
return pick(palette, data, paletteRng.getSeed(), x, y, z);
|
||||
}
|
||||
if (block != null && !block.isEmpty()) {
|
||||
return B.getStateOrNull(block, false);
|
||||
@@ -66,6 +80,11 @@ public final class IrisProceduralBlocks {
|
||||
return null;
|
||||
}
|
||||
|
||||
/** The block {@code palette} gives at the position when its noise is seeded with {@code seed}. */
|
||||
public static PlatformBlockState pick(PaletteSpec palette, IrisData data, long seed, int x, int y, int z) {
|
||||
return B.getState(data.getPackResources().blocks().palette(palette, seed).at(x, y, z).key());
|
||||
}
|
||||
|
||||
public static boolean hasProperty(PlatformBlockState state, String property) {
|
||||
String key = state.key();
|
||||
int start = propertyStart(key, property);
|
||||
|
||||
@@ -18,18 +18,31 @@
|
||||
|
||||
package art.arcane.iris.engine.object.procedural;
|
||||
|
||||
import art.arcane.iris.engine.object.procedural.coral.IrisCoral;
|
||||
import art.arcane.iris.engine.object.procedural.crystal.IrisCrystal;
|
||||
import art.arcane.iris.engine.object.procedural.formation.IrisFormation;
|
||||
import art.arcane.iris.engine.object.procedural.fungi.IrisFungus;
|
||||
import art.arcane.iris.engine.object.procedural.ruin.IrisRuin;
|
||||
import art.arcane.iris.builtin.objects.ruin.Ruin;
|
||||
import art.arcane.iris.engine.object.procedural.ruin.ResolvedRuin;
|
||||
import art.arcane.iris.builtin.objects.fungi.Fungus;
|
||||
import art.arcane.iris.engine.object.procedural.fungi.ResolvedFungus;
|
||||
import art.arcane.iris.builtin.objects.formation.Formation;
|
||||
import art.arcane.iris.engine.object.procedural.formation.ResolvedFormation;
|
||||
import art.arcane.iris.builtin.objects.crystal.Crystal;
|
||||
import art.arcane.iris.engine.object.procedural.crystal.ResolvedCrystal;
|
||||
import art.arcane.iris.builtin.objects.coral.Coral;
|
||||
import art.arcane.iris.engine.object.procedural.coral.ResolvedCoral;
|
||||
import art.arcane.iris.engine.object.procedural.tree.IrisProceduralTree;
|
||||
import art.arcane.iris.engine.object.annotations.ArrayType;
|
||||
import art.arcane.iris.engine.object.annotations.Desc;
|
||||
import art.arcane.iris.engine.object.annotations.Snippet;
|
||||
import art.arcane.volmlib.util.collection.KList;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.function.Function;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
@@ -40,53 +53,59 @@ import lombok.experimental.Accessors;
|
||||
@Desc("Procedurally generated objects placed in a biome or region. Unlike the objects block (which loads iob files), these are generated from scratch at world-gen time.")
|
||||
@Data
|
||||
public class IrisProceduralObjects {
|
||||
@Getter(AccessLevel.NONE)
|
||||
@Setter(AccessLevel.NONE)
|
||||
@EqualsAndHashCode.Exclude
|
||||
private final transient Map<Object, ResolvedProceduralPlacement> placeables = new ConcurrentHashMap<>();
|
||||
|
||||
@ArrayType(min = 1, type = IrisProceduralTree.class)
|
||||
@Desc("Procedurally generated trees.")
|
||||
private KList<IrisProceduralTree> trees = new KList<>();
|
||||
|
||||
@ArrayType(min = 1, type = IrisRuin.class)
|
||||
@ArrayType(min = 1, type = Ruin.class)
|
||||
@Desc("Procedurally generated ruins (crumbling pillars, walls, arches, rubble).")
|
||||
private KList<IrisRuin> ruins = new KList<>();
|
||||
private KList<Ruin> ruins = new KList<>();
|
||||
|
||||
@ArrayType(min = 1, type = IrisFormation.class)
|
||||
@ArrayType(min = 1, type = Formation.class)
|
||||
@Desc("Procedurally generated natural rock formations (spires, hoodoos, arches, sea stacks, boulders, basalt columns).")
|
||||
private KList<IrisFormation> formations = new KList<>();
|
||||
private KList<Formation> formations = new KList<>();
|
||||
|
||||
@ArrayType(min = 1, type = IrisCoral.class)
|
||||
@ArrayType(min = 1, type = Coral.class)
|
||||
@Desc("Procedurally generated underwater coral structures.")
|
||||
private KList<IrisCoral> coral = new KList<>();
|
||||
private KList<Coral> coral = new KList<>();
|
||||
|
||||
@ArrayType(min = 1, type = IrisFungus.class)
|
||||
@ArrayType(min = 1, type = Fungus.class)
|
||||
@Desc("Procedurally generated mushrooms and shelf fungi.")
|
||||
private KList<IrisFungus> fungi = new KList<>();
|
||||
private KList<Fungus> fungi = new KList<>();
|
||||
|
||||
@ArrayType(min = 1, type = IrisCrystal.class)
|
||||
@ArrayType(min = 1, type = Crystal.class)
|
||||
@Desc("Procedurally generated crystal clusters (usually placed in caves).")
|
||||
private KList<IrisCrystal> crystals = new KList<>();
|
||||
private KList<Crystal> crystals = new KList<>();
|
||||
|
||||
public KList<IrisProceduralPlacement> getAllPlacements() {
|
||||
KList<IrisProceduralPlacement> all = new KList<>();
|
||||
if (trees != null) {
|
||||
all.addAll(trees);
|
||||
}
|
||||
if (ruins != null) {
|
||||
all.addAll(ruins);
|
||||
}
|
||||
if (formations != null) {
|
||||
all.addAll(formations);
|
||||
}
|
||||
if (coral != null) {
|
||||
all.addAll(coral);
|
||||
}
|
||||
if (fungi != null) {
|
||||
all.addAll(fungi);
|
||||
}
|
||||
if (crystals != null) {
|
||||
all.addAll(crystals);
|
||||
}
|
||||
addPlaceable(all, ruins, ResolvedRuin::new);
|
||||
addPlaceable(all, formations, ResolvedFormation::new);
|
||||
addPlaceable(all, coral, ResolvedCoral::new);
|
||||
addPlaceable(all, fungi, ResolvedFungus::new);
|
||||
addPlaceable(all, crystals, ResolvedCrystal::new);
|
||||
return all;
|
||||
}
|
||||
|
||||
/** The settings in {@code settings}, each made placeable once, in order. */
|
||||
@SuppressWarnings("unchecked")
|
||||
private <S> void addPlaceable(KList<IrisProceduralPlacement> all, KList<S> settings, Function<S, ResolvedProceduralPlacement> resolve) {
|
||||
if (settings == null) {
|
||||
return;
|
||||
}
|
||||
for (S entry : settings) {
|
||||
all.add(placeables.computeIfAbsent(entry, key -> resolve.apply((S) key)));
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isEmpty() {
|
||||
return getAllPlacements().isEmpty();
|
||||
}
|
||||
|
||||
+158
@@ -0,0 +1,158 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Servers
|
||||
* Copyright (c) 2026 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.engine.object.procedural;
|
||||
|
||||
import art.arcane.iris.builtin.anchor.ObjectPlaceMode;
|
||||
import art.arcane.iris.builtin.carve.CarvingMode;
|
||||
import art.arcane.iris.builtin.prepare.ObjectRotation;
|
||||
import art.arcane.iris.builtin.prepare.ObjectTranslate;
|
||||
import art.arcane.iris.builtin.stilt.StiltSettings;
|
||||
import art.arcane.iris.builtin.vacuum.VacuumSettings;
|
||||
import art.arcane.iris.builtin.validate.ObjectLimit;
|
||||
import art.arcane.iris.core.loader.IrisData;
|
||||
import art.arcane.iris.engine.data.cache.AtomicCache;
|
||||
import art.arcane.iris.engine.object.placement.IrisObjectPlacement;
|
||||
import art.arcane.iris.engine.object.prefab.IrisObject;
|
||||
import art.arcane.iris.engine.object.prefab.IrisObjectRotation;
|
||||
import art.arcane.iris.engine.object.prefab.IrisObjectTranslate;
|
||||
import art.arcane.volmlib.util.collection.KList;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
|
||||
/**
|
||||
* A procedural object's settings made placeable: bakes a deterministic pool of variants from them, once, and turns
|
||||
* the placement options into the object placement the engine scatters. The settings classes held the same cache
|
||||
* and methods before they became module settings.
|
||||
*/
|
||||
public abstract class ResolvedProceduralPlacement implements IrisProceduralPlacement {
|
||||
private static final long VARIANT_SEED_STRIDE = 7919L;
|
||||
|
||||
/** The options every procedural placement shares with an object placement. */
|
||||
public record Shape(String name, double chance, int density, long seed, int variants, ObjectPlaceMode mode,
|
||||
ObjectRotation rotation, ObjectLimit clamp, CarvingMode carvingSupport, boolean underwater,
|
||||
ObjectTranslate translate, StiltSettings stiltSettings, VacuumSettings vacuumSettings) {
|
||||
}
|
||||
|
||||
private final Shape shape;
|
||||
private final AtomicCache<KList<IrisObject>> variantCache = new AtomicCache<>();
|
||||
|
||||
protected ResolvedProceduralPlacement(Shape shape) {
|
||||
this.shape = shape;
|
||||
}
|
||||
|
||||
/** The object variant {@code index} is baked as, from its own seeded stream. */
|
||||
protected abstract IrisObject generate(int index, RNG rng, IrisData data);
|
||||
|
||||
/** The number of variants to bake; the settings' count, at least one. */
|
||||
protected int variantCount() {
|
||||
return Math.max(1, shape.variants());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return shape.name();
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getChance() {
|
||||
return shape.chance();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDensity() {
|
||||
return shape.density();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPlausible() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public KList<IrisObject> getVariantObjects(IrisData data) {
|
||||
return variantCache.aquire(() -> bake(data));
|
||||
}
|
||||
|
||||
/** Bakes every variant; the default draws variant {@code i} from {@code seed + i * stride}. */
|
||||
protected KList<IrisObject> bake(IrisData data) {
|
||||
KList<IrisObject> baked = new KList<>();
|
||||
int count = variantCount();
|
||||
|
||||
for (int i = 0; i < count; i++) {
|
||||
IrisObject object = generate(i, variantRng(i), data);
|
||||
if (object == null || object.getBlocks().isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
object.setLoadKey("procedural/" + shape.name() + "#" + i);
|
||||
object.setLoader(data);
|
||||
baked.add(object);
|
||||
}
|
||||
|
||||
return baked;
|
||||
}
|
||||
|
||||
protected final RNG variantRng(int index) {
|
||||
return new RNG(shape.seed() + (index * VARIANT_SEED_STRIDE));
|
||||
}
|
||||
|
||||
protected final long seed() {
|
||||
return shape.seed();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IrisObject getVariantObject(IrisData data, RNG rng) {
|
||||
KList<IrisObject> baked = getVariantObjects(data);
|
||||
if (baked == null || baked.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
return baked.get(rng.i(baked.size()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public IrisObjectPlacement asPlacement() {
|
||||
IrisObjectPlacement placement = new IrisObjectPlacement();
|
||||
placement.setMode(shape.mode());
|
||||
placement.setRotation(irisRotation(shape.rotation()));
|
||||
placement.setClamp(shape.clamp());
|
||||
placement.setCarvingSupport(shape.carvingSupport());
|
||||
placement.setUnderwater(shape.underwater());
|
||||
placement.setTranslate(irisTranslate(shape.translate()));
|
||||
placement.setStiltSettings(shape.stiltSettings());
|
||||
placement.setVacuumSettings(shape.vacuumSettings());
|
||||
placement.setChance(shape.chance());
|
||||
placement.setDensity(shape.density());
|
||||
customize(placement);
|
||||
return placement;
|
||||
}
|
||||
|
||||
/** Sets what this kind of placement adds to the common options. */
|
||||
protected void customize(IrisObjectPlacement placement) {
|
||||
}
|
||||
|
||||
private static IrisObjectRotation irisRotation(ObjectRotation rotation) {
|
||||
return new IrisObjectRotation()
|
||||
.setEnabled(rotation.enabled())
|
||||
.setXAxis(rotation.xAxis())
|
||||
.setYAxis(rotation.yAxis())
|
||||
.setZAxis(rotation.zAxis());
|
||||
}
|
||||
|
||||
private static IrisObjectTranslate irisTranslate(ObjectTranslate translate) {
|
||||
return new IrisObjectTranslate(translate.x(), translate.y(), translate.yRandom(), translate.z());
|
||||
}
|
||||
}
|
||||
@@ -18,8 +18,8 @@
|
||||
|
||||
package art.arcane.iris.engine.object.procedural.coral;
|
||||
|
||||
import art.arcane.iris.builtin.objects.coral.Coral;
|
||||
import art.arcane.iris.core.loader.IrisData;
|
||||
import art.arcane.iris.engine.object.procedural.coral.IrisCoral;
|
||||
import art.arcane.iris.engine.object.prefab.IrisObject;
|
||||
import art.arcane.iris.engine.object.procedural.IrisProceduralBlocks;
|
||||
import art.arcane.iris.engine.object.procedural.tree.TreeFunctions;
|
||||
@@ -36,14 +36,14 @@ public final class CoralGenerator {
|
||||
private CoralGenerator() {
|
||||
}
|
||||
|
||||
public static IrisObject generate(IrisCoral coral, int variantIndex, RNG rng, IrisData data) {
|
||||
int lo = Math.min(coral.getHeightMin(), coral.getHeightMax());
|
||||
int hi = Math.max(coral.getHeightMin(), coral.getHeightMax());
|
||||
public static IrisObject generate(Coral coral, int variantIndex, RNG rng, IrisData data) {
|
||||
int lo = Math.min(coral.heightMin(), coral.heightMax());
|
||||
int hi = Math.max(coral.heightMin(), coral.heightMax());
|
||||
int height = Math.max(2, rng.i(lo, hi + 1));
|
||||
long shapeSeed = rng.getSeed() + variantIndex * 31L;
|
||||
|
||||
CoralCanvas canvas = new CoralCanvas();
|
||||
switch (coral.getForm()) {
|
||||
switch (coral.form()) {
|
||||
case BRANCHING -> buildBranching(canvas, coral, height, shapeSeed, rng);
|
||||
case FAN -> buildFan(canvas, coral, height, shapeSeed);
|
||||
case BRAIN -> buildBrain(canvas, coral, height, shapeSeed);
|
||||
@@ -55,39 +55,39 @@ public final class CoralGenerator {
|
||||
return IrisProceduralBlocks.assemble(resolved);
|
||||
}
|
||||
|
||||
private static void buildBranching(CoralCanvas canvas, IrisCoral coral, int height, long seed, RNG rng) {
|
||||
private static void buildBranching(CoralCanvas canvas, Coral coral, int height, long seed, RNG rng) {
|
||||
int stalkTop = Math.max(1, (int) Math.round(height * 0.5));
|
||||
for (int y = 0; y < stalkTop; y++) {
|
||||
placeWavy(canvas, coral, 0, y, 0, y, seed, CoralCanvas.Role.STRUCTURE);
|
||||
}
|
||||
|
||||
int count = Math.max(1, coral.getBranchCount());
|
||||
int count = Math.max(1, coral.branchCount());
|
||||
for (int b = 0; b < count; b++) {
|
||||
double az = branchAzimuth(coral, b, count, rng);
|
||||
int startY = stalkTop - 1 + (int) Math.round((b % 2) * 1.0);
|
||||
double[] tip = rasterizeArm(canvas, coral, 0, startY, 0, az,
|
||||
coral.getBranchElevation(), coral.getBranchLength(), seed + b * 131L);
|
||||
coral.branchElevation(), coral.branchLength(), seed + b * 131L);
|
||||
|
||||
placeTipCluster(canvas, coral, (int) Math.round(tip[0]), (int) Math.round(tip[1]), (int) Math.round(tip[2]),
|
||||
coral.getTipClusterRadius(), seed + b * 977L);
|
||||
coral.tipClusterRadius(), seed + b * 977L);
|
||||
|
||||
if (coral.isSubBranches()) {
|
||||
int subCount = Math.max(1, coral.getSubBranchCount());
|
||||
if (coral.subBranches()) {
|
||||
int subCount = Math.max(1, coral.subBranchCount());
|
||||
for (int s = 0; s < subCount; s++) {
|
||||
double subAz = az + (s - (subCount - 1) / 2.0) * 35.0;
|
||||
double subLen = coral.getBranchLength() * coral.getSubBranchScale();
|
||||
double subLen = coral.branchLength() * coral.subBranchScale();
|
||||
double[] subTip = rasterizeArm(canvas, coral,
|
||||
(int) Math.round(tip[0]), (int) Math.round(tip[1]), (int) Math.round(tip[2]),
|
||||
subAz, coral.getBranchElevation() + 10.0, subLen, seed + b * 131L + s * 17L + 5000L);
|
||||
subAz, coral.branchElevation() + 10.0, subLen, seed + b * 131L + s * 17L + 5000L);
|
||||
placeTipCluster(canvas, coral, (int) Math.round(subTip[0]), (int) Math.round(subTip[1]), (int) Math.round(subTip[2]),
|
||||
Math.max(0, coral.getTipClusterRadius() - 1), seed + b * 977L + s * 53L);
|
||||
Math.max(0, coral.tipClusterRadius() - 1), seed + b * 977L + s * 53L);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void buildFan(CoralCanvas canvas, IrisCoral coral, int height, long seed) {
|
||||
int half = Math.max(1, coral.getFanWidth());
|
||||
private static void buildFan(CoralCanvas canvas, Coral coral, int height, long seed) {
|
||||
int half = Math.max(1, coral.fanWidth());
|
||||
for (int y = 0; y < height; y++) {
|
||||
double t = y / (double) Math.max(1, height - 1);
|
||||
double profile = Math.sin(Math.PI * t);
|
||||
@@ -101,10 +101,10 @@ public final class CoralGenerator {
|
||||
}
|
||||
}
|
||||
|
||||
private static void buildBrain(CoralCanvas canvas, IrisCoral coral, int height, long seed) {
|
||||
int r = Math.max(1, coral.getBrainRadius());
|
||||
private static void buildBrain(CoralCanvas canvas, Coral coral, int height, long seed) {
|
||||
int r = Math.max(1, coral.brainRadius());
|
||||
int ry = Math.max(1, Math.min(r, (int) Math.round(height * 0.6)));
|
||||
double rough = coral.getBrainRoughness();
|
||||
double rough = coral.brainRoughness();
|
||||
for (int dx = -r; dx <= r; dx++) {
|
||||
for (int dz = -r; dz <= r; dz++) {
|
||||
for (int dy = 0; dy <= ry * 2; dy++) {
|
||||
@@ -121,8 +121,8 @@ public final class CoralGenerator {
|
||||
}
|
||||
}
|
||||
|
||||
private static void buildPillar(CoralCanvas canvas, IrisCoral coral, int height, long seed) {
|
||||
int r = Math.max(1, coral.getPillarRadius());
|
||||
private static void buildPillar(CoralCanvas canvas, Coral coral, int height, long seed) {
|
||||
int r = Math.max(1, coral.pillarRadius());
|
||||
for (int y = 0; y < height; y++) {
|
||||
for (int dx = -r; dx <= r; dx++) {
|
||||
for (int dz = -r; dz <= r; dz++) {
|
||||
@@ -132,12 +132,12 @@ public final class CoralGenerator {
|
||||
}
|
||||
}
|
||||
}
|
||||
placeTipCluster(canvas, coral, 0, height - 1, 0, coral.getTipClusterRadius(), seed);
|
||||
placeTipCluster(canvas, coral, 0, height - 1, 0, coral.tipClusterRadius(), seed);
|
||||
}
|
||||
|
||||
private static void buildTendril(CoralCanvas canvas, IrisCoral coral, int height, long seed, RNG rng) {
|
||||
int count = Math.max(1, coral.getTendrilCount());
|
||||
double radius = Math.max(0.0, coral.getSpread());
|
||||
private static void buildTendril(CoralCanvas canvas, Coral coral, int height, long seed, RNG rng) {
|
||||
int count = Math.max(1, coral.tendrilCount());
|
||||
double radius = Math.max(0.0, coral.spread());
|
||||
for (int c = 0; c < count; c++) {
|
||||
double az = Math.toRadians(c * (360.0 / count));
|
||||
double bx = Math.cos(az) * radius * 0.5;
|
||||
@@ -153,7 +153,7 @@ public final class CoralGenerator {
|
||||
}
|
||||
}
|
||||
|
||||
private static double[] rasterizeArm(CoralCanvas canvas, IrisCoral coral, int ox, int oy, int oz,
|
||||
private static double[] rasterizeArm(CoralCanvas canvas, Coral coral, int ox, int oy, int oz,
|
||||
double azimuthDeg, double elevationDeg, double length, long seed) {
|
||||
double azRad = Math.toRadians(azimuthDeg);
|
||||
double elRad = Math.toRadians(elevationDeg);
|
||||
@@ -175,23 +175,23 @@ public final class CoralGenerator {
|
||||
return tip;
|
||||
}
|
||||
|
||||
private static void placeWavy(CoralCanvas canvas, IrisCoral coral, int x, int y, int z, double phase, long seed, CoralCanvas.Role role) {
|
||||
private static void placeWavy(CoralCanvas canvas, Coral coral, int x, int y, int z, double phase, long seed, CoralCanvas.Role role) {
|
||||
double sway = swayOffset(coral, phase, seed);
|
||||
int sx = (int) Math.round(sway);
|
||||
int sz = (int) Math.round(swayOffset(coral, phase + 53.0, seed + 7L));
|
||||
canvas.set(x + sx, y, z + sz, role);
|
||||
}
|
||||
|
||||
private static double swayOffset(IrisCoral coral, double phase, long seed) {
|
||||
double amount = Math.max(0.0, Math.min(1.0, coral.getSway()));
|
||||
private static double swayOffset(Coral coral, double phase, long seed) {
|
||||
double amount = Math.max(0.0, Math.min(1.0, coral.sway()));
|
||||
if (amount <= 0.0) {
|
||||
return 0.0;
|
||||
}
|
||||
double n = TreeFunctions.valueNoise1D(phase * 0.35, seed) - 0.5;
|
||||
return n * 2.0 * amount * (1.0 + coral.getSpread() * 0.25);
|
||||
return n * 2.0 * amount * (1.0 + coral.spread() * 0.25);
|
||||
}
|
||||
|
||||
private static void placeTipCluster(CoralCanvas canvas, IrisCoral coral, int cx, int cy, int cz, int radius, long seed) {
|
||||
private static void placeTipCluster(CoralCanvas canvas, Coral coral, int cx, int cy, int cz, int radius, long seed) {
|
||||
if (radius <= 0) {
|
||||
placeTip(canvas, coral, cx, cy, cz, seed);
|
||||
return;
|
||||
@@ -208,31 +208,31 @@ public final class CoralGenerator {
|
||||
placeTip(canvas, coral, cx, cy + radius + 1, cz, seed);
|
||||
}
|
||||
|
||||
private static void placeTip(CoralCanvas canvas, IrisCoral coral, int x, int y, int z, long seed) {
|
||||
private static void placeTip(CoralCanvas canvas, Coral coral, int x, int y, int z, long seed) {
|
||||
if (!hasTip(coral)) {
|
||||
return;
|
||||
}
|
||||
if (TreeFunctions.valueNoise1D(x * 31.0 + y * 17.0 + z * 13.0, seed) <= coral.getTipChance()) {
|
||||
if (TreeFunctions.valueNoise1D(x * 31.0 + y * 17.0 + z * 13.0, seed) <= coral.tipChance()) {
|
||||
canvas.set(x, y, z, CoralCanvas.Role.TIP);
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean hasTip(IrisCoral coral) {
|
||||
return IrisProceduralBlocks.paletteSet(coral.getTipPalette())
|
||||
|| (coral.getTipBlock() != null && !coral.getTipBlock().isEmpty());
|
||||
private static boolean hasTip(Coral coral) {
|
||||
return IrisProceduralBlocks.paletteSet(coral.tipPalette())
|
||||
|| (coral.tipBlock() != null && !coral.tipBlock().isEmpty());
|
||||
}
|
||||
|
||||
private static double branchAzimuth(IrisCoral coral, int index, int count, RNG rng) {
|
||||
return switch (coral.getBranchAzimuth()) {
|
||||
private static double branchAzimuth(Coral coral, int index, int count, RNG rng) {
|
||||
return switch (coral.branchAzimuth()) {
|
||||
case GOLDEN_ANGLE -> index * GOLDEN_ANGLE;
|
||||
case EVEN -> index * (360.0 / count);
|
||||
case RANDOM -> rng.d(0.0, 360.0);
|
||||
};
|
||||
}
|
||||
|
||||
private static Map<Vector3i, PlatformBlockState> resolve(CoralCanvas canvas, IrisCoral coral, IrisData data) {
|
||||
private static Map<Vector3i, PlatformBlockState> resolve(CoralCanvas canvas, Coral coral, IrisData data) {
|
||||
Map<Vector3i, PlatformBlockState> out = new HashMap<>();
|
||||
RNG paletteRng = new RNG(coral.getSeed());
|
||||
RNG paletteRng = new RNG(coral.seed());
|
||||
for (Map.Entry<Long, CoralCanvas.Role> entry : canvas.getCells().entrySet()) {
|
||||
int[] xyz = CoralCanvas.decode(entry.getKey());
|
||||
int x = xyz[0];
|
||||
@@ -240,17 +240,17 @@ public final class CoralGenerator {
|
||||
int z = xyz[2];
|
||||
PlatformBlockState state;
|
||||
if (entry.getValue() == CoralCanvas.Role.TIP) {
|
||||
state = IrisProceduralBlocks.resolve(coral.getTipBlock(), coral.getTipPalette(), data, x, y, z, paletteRng);
|
||||
state = IrisProceduralBlocks.resolve(coral.tipBlock(), coral.tipPalette(), data, x, y, z, paletteRng);
|
||||
if (state == null) {
|
||||
state = IrisProceduralBlocks.resolve(coral.getBlock(), coral.getBlockPalette(), data, x, y, z, paletteRng);
|
||||
state = IrisProceduralBlocks.resolve(coral.block(), coral.blockPalette(), data, x, y, z, paletteRng);
|
||||
}
|
||||
} else {
|
||||
state = IrisProceduralBlocks.resolve(coral.getBlock(), coral.getBlockPalette(), data, x, y, z, paletteRng);
|
||||
state = IrisProceduralBlocks.resolve(coral.block(), coral.blockPalette(), data, x, y, z, paletteRng);
|
||||
}
|
||||
if (state == null) {
|
||||
continue;
|
||||
}
|
||||
if (coral.isWaterlogged() && IrisProceduralBlocks.hasProperty(state, "waterlogged")) {
|
||||
if (coral.waterlogged() && IrisProceduralBlocks.hasProperty(state, "waterlogged")) {
|
||||
try {
|
||||
state = state.withProperty("waterlogged", "true");
|
||||
} catch (IllegalArgumentException ignored) {
|
||||
|
||||
@@ -1,249 +0,0 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2022 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.engine.object.procedural.coral;
|
||||
|
||||
import art.arcane.iris.builtin.carve.CarvingMode;
|
||||
import art.arcane.iris.builtin.anchor.ObjectPlaceMode;
|
||||
import art.arcane.iris.builtin.stilt.StiltSettings;
|
||||
import art.arcane.iris.builtin.vacuum.VacuumSettings;
|
||||
import art.arcane.iris.builtin.validate.ObjectLimit;
|
||||
import art.arcane.iris.engine.object.material.IrisMaterialPalette;
|
||||
import art.arcane.iris.engine.object.placement.IrisObjectPlacement;
|
||||
import art.arcane.iris.engine.object.prefab.IrisObject;
|
||||
import art.arcane.iris.engine.object.prefab.IrisObjectRotation;
|
||||
import art.arcane.iris.engine.object.prefab.IrisObjectTranslate;
|
||||
import art.arcane.iris.engine.object.procedural.IrisProceduralPlacement;
|
||||
import art.arcane.iris.core.loader.IrisData;
|
||||
import art.arcane.iris.engine.data.cache.AtomicCache;
|
||||
import art.arcane.iris.engine.object.annotations.Desc;
|
||||
import art.arcane.iris.engine.object.annotations.MaxNumber;
|
||||
import art.arcane.iris.engine.object.annotations.MinNumber;
|
||||
import art.arcane.iris.engine.object.annotations.RegistryListBlockType;
|
||||
import art.arcane.iris.engine.object.annotations.Required;
|
||||
import art.arcane.iris.engine.object.annotations.Snippet;
|
||||
import art.arcane.iris.engine.object.procedural.coral.CoralGenerator;
|
||||
import art.arcane.volmlib.util.collection.KList;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
@Snippet("coral")
|
||||
@Accessors(chain = true)
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Desc("A single procedurally generated coral reef structure. Iris bakes a pool of deterministic variants from these settings and scatters them across the seafloor at world-gen time, exactly like an object placement but generated from scratch instead of loaded from an iob file. Mirrors the procedural tree system but tuned for underwater reefs: structural blocks are waterlogged so the coral stays alive, and placement defaults to anchoring on the terrain beneath the water surface.")
|
||||
@Data
|
||||
public class IrisCoral implements IrisProceduralPlacement {
|
||||
private final transient AtomicCache<KList<IrisObject>> variantCache = new AtomicCache<>();
|
||||
|
||||
@Desc("A human readable name used in logs and as the variant load key.")
|
||||
private String name = "coral";
|
||||
|
||||
@MinNumber(0)
|
||||
@MaxNumber(1)
|
||||
@Desc("The chance per chunk for this coral to attempt placement. Use density for multiple per chunk.")
|
||||
private double chance = 0.4;
|
||||
|
||||
@MinNumber(1)
|
||||
@Desc("If the chance check passes, attempt this many placements in the chunk.")
|
||||
private int density = 1;
|
||||
|
||||
@MinNumber(1)
|
||||
@MaxNumber(64)
|
||||
@Desc("How many distinct variants to pre-bake for this coral. Higher means more variety at a small memory cost.")
|
||||
private int variants = 6;
|
||||
|
||||
@Desc("The base seed for deterministic generation. The same seed and settings always bake the same variants.")
|
||||
private long seed = 1337;
|
||||
|
||||
@Desc("The placement mode used to anchor the coral to the seafloor.")
|
||||
private ObjectPlaceMode mode = ObjectPlaceMode.CENTER_HEIGHT;
|
||||
|
||||
@Desc("Rotate this coral's placement.")
|
||||
private IrisObjectRotation rotation = new IrisObjectRotation();
|
||||
|
||||
@Desc("Limit the max or min height of placement.")
|
||||
private ObjectLimit clamp = new ObjectLimit();
|
||||
|
||||
@Desc("Whether this coral may place on the terrain surface, under carvings, or both.")
|
||||
private CarvingMode carvingSupport = CarvingMode.SURFACE_ONLY;
|
||||
|
||||
@Desc("If true (default for coral), the coral anchors on the terrain height beneath the water, so it grows up from the seafloor rather than floating at the water surface.")
|
||||
private boolean underwater = true;
|
||||
|
||||
@Desc("Translate (offset) this placement along each axis; for example set a negative y to sink it into the seafloor.")
|
||||
private IrisObjectTranslate translate = new IrisObjectTranslate();
|
||||
|
||||
@Desc("Settings for the stilt place modes (STILT, MIN_STILT, FAST_STILT, CENTER_STILT, ERODE_STILT, ORGANIC_STILT).")
|
||||
private StiltSettings stiltSettings;
|
||||
|
||||
@Desc("Settings for the vacuum place modes (VACUUM, VACUUM_HIGH, VACUUM_FAST, VACUUM_ORGANIC).")
|
||||
private VacuumSettings vacuumSettings;
|
||||
|
||||
@Desc("If true (default), every resolved coral block that is waterloggable is forced waterlogged so the coral does not die in water (coral fans, sea pickles and kelp also waterlog). Set false to place dead/dry coral.")
|
||||
private boolean waterlogged = true;
|
||||
|
||||
@Desc("The overall silhouette this coral grows into (branching, fan, brain, pillar, tendril). Each form runs a different generation routine.")
|
||||
private IrisCoralForm form = IrisCoralForm.BRANCHING;
|
||||
|
||||
@Required
|
||||
@Desc("The structural coral block (the living wood of the reef), e.g. minecraft:tube_coral_block. Ignored when blockPalette is set.")
|
||||
@RegistryListBlockType
|
||||
private String block = "minecraft:tube_coral_block";
|
||||
|
||||
@Desc("A noise-driven palette for the structural coral block. When set this overrides the single block, letting the reef mix tube/brain/bubble/fire/horn coral_block tones across its body.")
|
||||
private IrisMaterialPalette blockPalette = null;
|
||||
|
||||
@Desc("Optional tip block placed at branch tips and at the very top of the structure, e.g. coral fans or minecraft:sea_pickle. Ignored when tipPalette is set. Null disables tips.")
|
||||
@RegistryListBlockType
|
||||
private String tipBlock = null;
|
||||
|
||||
@Desc("A noise-driven palette for the tip block. When set this overrides the single tipBlock, letting tips mix fan / pickle decorations.")
|
||||
private IrisMaterialPalette tipPalette = null;
|
||||
|
||||
@MinNumber(0)
|
||||
@MaxNumber(1)
|
||||
@Desc("The chance per eligible tip position to place a tip block (coral fan / sea pickle).")
|
||||
private double tipChance = 0.6;
|
||||
|
||||
@MinNumber(1)
|
||||
@Desc("Minimum overall height of the coral in blocks.")
|
||||
private int heightMin = 4;
|
||||
|
||||
@MinNumber(1)
|
||||
@Desc("Maximum overall height of the coral in blocks.")
|
||||
private int heightMax = 8;
|
||||
|
||||
@MinNumber(0)
|
||||
@Desc("Horizontal spread of the structure in blocks. For BRANCHING this is how far arms reach out, for BRAIN/PILLAR/FAN it widens the base footprint.")
|
||||
private double spread = 3;
|
||||
|
||||
@MinNumber(0)
|
||||
@MaxNumber(1)
|
||||
@Desc("Lateral noise wobble (0-1) applied to branches and tendrils so they are not ruler-straight. 0 is perfectly straight, 1 is heavily wandering.")
|
||||
private double sway = 0.5;
|
||||
|
||||
@MinNumber(1)
|
||||
@MaxNumber(12)
|
||||
@Desc("BRANCHING only: how many arms sprout from the central stalk.")
|
||||
private int branchCount = 4;
|
||||
|
||||
@MinNumber(1)
|
||||
@Desc("BRANCHING only: the length of each arm in blocks before reaching its tip.")
|
||||
private double branchLength = 3;
|
||||
|
||||
@MinNumber(0)
|
||||
@MaxNumber(90)
|
||||
@Desc("BRANCHING only: the upward elevation in degrees of each arm from horizontal. 90 is straight up, 0 is flat out.")
|
||||
private double branchElevation = 55;
|
||||
|
||||
@Desc("BRANCHING only: how the arms are distributed around the stalk by azimuth.")
|
||||
private IrisCoralBranchAzimuth branchAzimuth = IrisCoralBranchAzimuth.GOLDEN_ANGLE;
|
||||
|
||||
@Desc("BRANCHING only: if true, each arm splits once into a small fan of sub-arms for a bushier reef.")
|
||||
private boolean subBranches = true;
|
||||
|
||||
@MinNumber(1)
|
||||
@MaxNumber(5)
|
||||
@Desc("BRANCHING only: how many sub-arms each arm splits into when subBranches is true.")
|
||||
private int subBranchCount = 2;
|
||||
|
||||
@MinNumber(0)
|
||||
@MaxNumber(1)
|
||||
@Desc("BRANCHING only: the length of each sub-arm as a fraction of its parent arm.")
|
||||
private double subBranchScale = 0.5;
|
||||
|
||||
@MinNumber(0)
|
||||
@MaxNumber(4)
|
||||
@Desc("BRANCHING and PILLAR only: the radius of the small coral tip cluster grown at each tip.")
|
||||
private int tipClusterRadius = 1;
|
||||
|
||||
@MinNumber(1)
|
||||
@MaxNumber(8)
|
||||
@Desc("BRAIN only: the horizontal radius of the brain-coral blob in blocks.")
|
||||
private int brainRadius = 3;
|
||||
|
||||
@MinNumber(0)
|
||||
@MaxNumber(1)
|
||||
@Desc("BRAIN only: how strongly 3D value noise perturbs the ellipsoid surface, for a wrinkled organic blob. 0 is a smooth dome.")
|
||||
private double brainRoughness = 0.35;
|
||||
|
||||
@MinNumber(1)
|
||||
@MaxNumber(12)
|
||||
@Desc("PILLAR only: the radius of the stout vertical column in blocks.")
|
||||
private int pillarRadius = 1;
|
||||
|
||||
@MinNumber(1)
|
||||
@MaxNumber(8)
|
||||
@Desc("FAN only: the half-width of the upright fan plane in blocks (the disc widens toward its mid-height).")
|
||||
private int fanWidth = 3;
|
||||
|
||||
@MinNumber(1)
|
||||
@MaxNumber(12)
|
||||
@Desc("TENDRIL only: how many thin wavy stalks rise from the base.")
|
||||
private int tendrilCount = 4;
|
||||
|
||||
public KList<IrisObject> getVariantObjects(IrisData data) {
|
||||
return variantCache.aquire(() -> {
|
||||
KList<IrisObject> baked = new KList<>();
|
||||
int count = Math.max(1, variants);
|
||||
|
||||
for (int i = 0; i < count; i++) {
|
||||
IrisObject object = CoralGenerator.generate(this, i, new RNG(seed + (i * 7919L)), data);
|
||||
if (object == null || object.getBlocks().isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
object.setLoadKey("procedural/" + name + "#" + i);
|
||||
object.setLoader(data);
|
||||
baked.add(object);
|
||||
}
|
||||
|
||||
return baked;
|
||||
});
|
||||
}
|
||||
|
||||
public IrisObject getVariantObject(IrisData data, RNG rng) {
|
||||
KList<IrisObject> baked = getVariantObjects(data);
|
||||
if (baked == null || baked.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
return baked.get(rng.i(baked.size()));
|
||||
}
|
||||
|
||||
public IrisObjectPlacement asPlacement() {
|
||||
IrisObjectPlacement placement = new IrisObjectPlacement();
|
||||
placement.setMode(mode);
|
||||
placement.setRotation(rotation);
|
||||
placement.setClamp(clamp);
|
||||
placement.setCarvingSupport(carvingSupport);
|
||||
placement.setUnderwater(underwater);
|
||||
placement.setTranslate(translate);
|
||||
placement.setStiltSettings(stiltSettings);
|
||||
placement.setVacuumSettings(vacuumSettings);
|
||||
placement.setChance(chance);
|
||||
placement.setDensity(density);
|
||||
return placement;
|
||||
}
|
||||
|
||||
public boolean isPlausible() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
-33
@@ -1,33 +0,0 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2022 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.engine.object.procedural.coral;
|
||||
|
||||
import art.arcane.iris.engine.object.annotations.Desc;
|
||||
|
||||
@Desc("How the arms of a BRANCHING coral are distributed around the central stalk by compass azimuth.")
|
||||
public enum IrisCoralBranchAzimuth {
|
||||
@Desc("Distribute arms by the golden angle (about 137.5 degrees per arm) for a natural phyllotactic spiral where no two arms overlap.")
|
||||
GOLDEN_ANGLE,
|
||||
|
||||
@Desc("Distribute arms in evenly spaced spokes, dividing 360 degrees equally between them like a radial whorl.")
|
||||
EVEN,
|
||||
|
||||
@Desc("Place each arm at a fully random azimuth using the deterministic per-variant RNG, for an irregular wild reef.")
|
||||
RANDOM
|
||||
}
|
||||
@@ -1,39 +0,0 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2022 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.engine.object.procedural.coral;
|
||||
|
||||
import art.arcane.iris.engine.object.annotations.Desc;
|
||||
|
||||
@Desc("The overall silhouette a procedural coral grows into. Each form drives a completely different generation routine in the coral generator, from tree-like branching arms to rounded brain blobs and thin wavy tendrils.")
|
||||
public enum IrisCoralForm {
|
||||
@Desc("A tree-like coral built from a stout central stalk that sprouts several upward-leaning arms (distributed by golden angle or randomly), each optionally splitting once into sub-arms, with small coral tip clusters (fans / sea pickles) at the ends. The most structurally complex form and the closest analogue to a procedural tree.")
|
||||
BRANCHING,
|
||||
|
||||
@Desc("A thin, single-block-thick vertical fan plane that rises and widens with height like a sheet of fire or horn coral. Reads as a flat decorative blade rather than a volume.")
|
||||
FAN,
|
||||
|
||||
@Desc("A rounded, noise-perturbed ellipsoid blob of brain coral that bulges out of the seafloor like a boulder, with an irregular wrinkled surface driven by 3D value noise.")
|
||||
BRAIN,
|
||||
|
||||
@Desc("A stout, thick vertical column of coral block topped with a dense tip cluster. Wider and blunter than a tendril, reading as a solid coral pillar or stack.")
|
||||
PILLAR,
|
||||
|
||||
@Desc("Several very thin (one block wide) wavy stalks that rise upward and wander laterally using value noise, like a clump of swaying coral whips or kelp-thin growths.")
|
||||
TENDRIL
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Servers
|
||||
* Copyright (c) 2026 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.engine.object.procedural.coral;
|
||||
|
||||
import art.arcane.iris.builtin.objects.coral.Coral;
|
||||
import art.arcane.iris.core.loader.IrisData;
|
||||
import art.arcane.iris.engine.object.prefab.IrisObject;
|
||||
import art.arcane.iris.engine.object.procedural.ResolvedProceduralPlacement;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
|
||||
/** A coral reef made placeable: its variants are baked by {@link CoralGenerator}. */
|
||||
public final class ResolvedCoral extends ResolvedProceduralPlacement {
|
||||
private final Coral settings;
|
||||
|
||||
public ResolvedCoral(Coral settings) {
|
||||
super(new Shape(settings.name(), settings.chance(), settings.density(), settings.seed(), settings.variants(), settings.mode(),
|
||||
settings.rotation(), settings.clamp(), settings.carvingSupport(), settings.underwater(), settings.translate(),
|
||||
settings.stiltSettings().orElse(null), settings.vacuumSettings().orElse(null)));
|
||||
this.settings = settings;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected IrisObject generate(int index, RNG rng, IrisData data) {
|
||||
return CoralGenerator.generate(settings, index, rng, data);
|
||||
}
|
||||
}
|
||||
+4
-4
@@ -18,21 +18,21 @@
|
||||
|
||||
package art.arcane.iris.engine.object.procedural.crystal;
|
||||
|
||||
import art.arcane.iris.engine.object.procedural.crystal.IrisCrystal;
|
||||
import art.arcane.iris.builtin.objects.crystal.Crystal;
|
||||
import art.arcane.iris.engine.object.procedural.tree.TreeFunctions;
|
||||
|
||||
public final class CrystalBaseBuilder {
|
||||
private CrystalBaseBuilder() {
|
||||
}
|
||||
|
||||
public static void build(CrystalCanvas canvas, IrisCrystal crystal, long seed) {
|
||||
double radius = crystal.getBaseRadius();
|
||||
public static void build(CrystalCanvas canvas, Crystal crystal, long seed) {
|
||||
double radius = crystal.baseRadius();
|
||||
if (radius <= 0.0) {
|
||||
canvas.set(0, 0, 0, CrystalRole.BASE);
|
||||
return;
|
||||
}
|
||||
|
||||
double noiseStrength = crystal.getBaseNoise();
|
||||
double noiseStrength = crystal.baseNoise();
|
||||
int reach = (int) Math.ceil(radius + 1.0);
|
||||
for (int x = -reach; x <= reach; x++) {
|
||||
for (int y = -reach; y <= reach; y++) {
|
||||
|
||||
+20
-19
@@ -18,8 +18,9 @@
|
||||
|
||||
package art.arcane.iris.engine.object.procedural.crystal;
|
||||
|
||||
import art.arcane.iris.builtin.objects.crystal.Crystal;
|
||||
import com.volmit.block.PaletteSpec;
|
||||
import art.arcane.iris.core.loader.IrisData;
|
||||
import art.arcane.iris.engine.object.procedural.crystal.IrisCrystal;
|
||||
import art.arcane.iris.engine.object.prefab.IrisObject;
|
||||
import art.arcane.iris.engine.object.procedural.IrisProceduralBlocks;
|
||||
import art.arcane.iris.spi.PlatformBlockState;
|
||||
@@ -33,7 +34,7 @@ public final class CrystalGenerator {
|
||||
private CrystalGenerator() {
|
||||
}
|
||||
|
||||
public static IrisObject generate(IrisCrystal crystal, int variantIndex, RNG rng, IrisData data) {
|
||||
public static IrisObject generate(Crystal crystal, int variantIndex, RNG rng, IrisData data) {
|
||||
CrystalCanvas canvas = new CrystalCanvas();
|
||||
long structureSeed = rng.getSeed();
|
||||
|
||||
@@ -41,8 +42,8 @@ public final class CrystalGenerator {
|
||||
CrystalShardBuilder.build(canvas, crystal, rng);
|
||||
|
||||
Map<Vector3i, PlatformBlockState> resolved = new HashMap<>();
|
||||
RNG paletteRng = new RNG(crystal.getSeed());
|
||||
RNG tipRng = new RNG(crystal.getSeed() + (variantIndex * 31337L) + 4099L);
|
||||
RNG paletteRng = new RNG(crystal.seed());
|
||||
RNG tipRng = new RNG(crystal.seed() + (variantIndex * 31337L) + 4099L);
|
||||
|
||||
for (Map.Entry<Vector3i, CrystalRole> entry : canvas.getCells().entrySet()) {
|
||||
Vector3i position = entry.getKey();
|
||||
@@ -59,7 +60,7 @@ public final class CrystalGenerator {
|
||||
return IrisProceduralBlocks.assemble(resolved);
|
||||
}
|
||||
|
||||
private static PlatformBlockState resolveRole(IrisCrystal crystal, CrystalRole role, IrisData data, int x, int y, int z, RNG paletteRng, RNG tipRng) {
|
||||
private static PlatformBlockState resolveRole(Crystal crystal, CrystalRole role, IrisData data, int x, int y, int z, RNG paletteRng, RNG tipRng) {
|
||||
return switch (role) {
|
||||
case BASE -> resolveBase(crystal, data, x, y, z, paletteRng);
|
||||
case SHARD -> resolveShard(crystal, data, x, y, z, paletteRng);
|
||||
@@ -67,11 +68,11 @@ public final class CrystalGenerator {
|
||||
};
|
||||
}
|
||||
|
||||
private static PlatformBlockState resolveBase(IrisCrystal crystal, IrisData data, int x, int y, int z, RNG paletteRng) {
|
||||
boolean hasBase = IrisProceduralBlocks.paletteSet(crystal.getBasePalette())
|
||||
|| (crystal.getBaseBlock() != null && !crystal.getBaseBlock().isEmpty());
|
||||
private static PlatformBlockState resolveBase(Crystal crystal, IrisData data, int x, int y, int z, RNG paletteRng) {
|
||||
boolean hasBase = IrisProceduralBlocks.paletteSet(crystal.basePalette())
|
||||
|| (crystal.baseBlock() != null && !crystal.baseBlock().isEmpty());
|
||||
if (hasBase) {
|
||||
PlatformBlockState base = IrisProceduralBlocks.resolve(crystal.getBaseBlock(), crystal.getBasePalette(), data, x, y, z, paletteRng);
|
||||
PlatformBlockState base = IrisProceduralBlocks.resolve(crystal.baseBlock(), crystal.basePalette(), data, x, y, z, paletteRng);
|
||||
if (base != null) {
|
||||
return base;
|
||||
}
|
||||
@@ -79,17 +80,17 @@ public final class CrystalGenerator {
|
||||
return resolveShard(crystal, data, x, y, z, paletteRng);
|
||||
}
|
||||
|
||||
private static PlatformBlockState resolveShard(IrisCrystal crystal, IrisData data, int x, int y, int z, RNG paletteRng) {
|
||||
return IrisProceduralBlocks.resolve(crystal.getBlock(), crystal.getBlockPalette(), data, x, y, z, paletteRng);
|
||||
private static PlatformBlockState resolveShard(Crystal crystal, IrisData data, int x, int y, int z, RNG paletteRng) {
|
||||
return IrisProceduralBlocks.resolve(crystal.block(), crystal.blockPalette(), data, x, y, z, paletteRng);
|
||||
}
|
||||
|
||||
private static PlatformBlockState resolveTip(IrisCrystal crystal, IrisData data, int x, int y, int z, RNG paletteRng, RNG tipRng) {
|
||||
boolean hasTip = IrisProceduralBlocks.paletteSet(crystal.getTipPalette())
|
||||
|| (crystal.getTipBlock() != null && !crystal.getTipBlock().isEmpty());
|
||||
private static PlatformBlockState resolveTip(Crystal crystal, IrisData data, int x, int y, int z, RNG paletteRng, RNG tipRng) {
|
||||
boolean hasTip = IrisProceduralBlocks.paletteSet(crystal.tipPalette())
|
||||
|| (crystal.tipBlock() != null && !crystal.tipBlock().isEmpty());
|
||||
|
||||
if (hasTip) {
|
||||
if (tipRng.chance(crystal.getTipChance())) {
|
||||
PlatformBlockState tip = IrisProceduralBlocks.resolve(crystal.getTipBlock(), crystal.getTipPalette(), data, x, y, z, paletteRng);
|
||||
if (tipRng.chance(crystal.tipChance())) {
|
||||
PlatformBlockState tip = IrisProceduralBlocks.resolve(crystal.tipBlock(), crystal.tipPalette(), data, x, y, z, paletteRng);
|
||||
if (tip != null) {
|
||||
return tip;
|
||||
}
|
||||
@@ -97,9 +98,9 @@ public final class CrystalGenerator {
|
||||
return resolveShard(crystal, data, x, y, z, paletteRng);
|
||||
}
|
||||
|
||||
if (crystal.isGlow() && crystal.getGlowBlock() != null && !crystal.getGlowBlock().isEmpty()) {
|
||||
if (tipRng.chance(crystal.getTipChance())) {
|
||||
PlatformBlockState glow = IrisProceduralBlocks.resolve(crystal.getGlowBlock(), null, data, x, y, z, paletteRng);
|
||||
if (crystal.glow() && crystal.glowBlock() != null && !crystal.glowBlock().isEmpty()) {
|
||||
if (tipRng.chance(crystal.tipChance())) {
|
||||
PlatformBlockState glow = IrisProceduralBlocks.resolve(crystal.glowBlock(), (PaletteSpec) null, data, x, y, z, paletteRng);
|
||||
if (glow != null) {
|
||||
return glow;
|
||||
}
|
||||
|
||||
@@ -18,13 +18,14 @@
|
||||
|
||||
package art.arcane.iris.engine.object.procedural.crystal;
|
||||
|
||||
import art.arcane.iris.engine.object.procedural.crystal.IrisCrystalSurface;
|
||||
import art.arcane.iris.builtin.objects.crystal.CrystalSurface;
|
||||
|
||||
|
||||
public final class CrystalGeometry {
|
||||
private CrystalGeometry() {
|
||||
}
|
||||
|
||||
public static double[] surfaceNormal(IrisCrystalSurface surface) {
|
||||
public static double[] surfaceNormal(CrystalSurface surface) {
|
||||
return switch (surface) {
|
||||
case FLOOR -> new double[]{0.0, 1.0, 0.0};
|
||||
case CEILING -> new double[]{0.0, -1.0, 0.0};
|
||||
|
||||
+17
-17
@@ -18,8 +18,8 @@
|
||||
|
||||
package art.arcane.iris.engine.object.procedural.crystal;
|
||||
|
||||
import art.arcane.iris.engine.object.procedural.crystal.IrisCrystal;
|
||||
import art.arcane.iris.engine.object.procedural.crystal.IrisCrystalDistribution;
|
||||
import art.arcane.iris.builtin.objects.crystal.CrystalDistribution;
|
||||
import art.arcane.iris.builtin.objects.crystal.Crystal;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
|
||||
public final class CrystalShardBuilder {
|
||||
@@ -28,24 +28,24 @@ public final class CrystalShardBuilder {
|
||||
private CrystalShardBuilder() {
|
||||
}
|
||||
|
||||
public static void build(CrystalCanvas canvas, IrisCrystal crystal, RNG rng) {
|
||||
double[] normal = CrystalGeometry.surfaceNormal(crystal.getGrowthSurface());
|
||||
public static void build(CrystalCanvas canvas, Crystal crystal, RNG rng) {
|
||||
double[] normal = CrystalGeometry.surfaceNormal(crystal.growthSurface());
|
||||
double[] u = CrystalGeometry.orthonormalBasisU(normal);
|
||||
double[] v = CrystalGeometry.orthonormalBasisV(normal, u);
|
||||
|
||||
int countLo = Math.min(crystal.getShardCountMin(), crystal.getShardCountMax());
|
||||
int countHi = Math.max(crystal.getShardCountMin(), crystal.getShardCountMax());
|
||||
int countLo = Math.min(crystal.shardCountMin(), crystal.shardCountMax());
|
||||
int countHi = Math.max(crystal.shardCountMin(), crystal.shardCountMax());
|
||||
int shardCount = Math.max(1, rng.i(countLo, countHi + 1));
|
||||
|
||||
int lengthLo = Math.min(crystal.getShardLengthMin(), crystal.getShardLengthMax());
|
||||
int lengthHi = Math.max(crystal.getShardLengthMin(), crystal.getShardLengthMax());
|
||||
int lengthLo = Math.min(crystal.shardLengthMin(), crystal.shardLengthMax());
|
||||
int lengthHi = Math.max(crystal.shardLengthMin(), crystal.shardLengthMax());
|
||||
|
||||
double spreadRadians = Math.toRadians(Math.max(0.0, Math.min(90.0, crystal.getSpreadAngle())));
|
||||
double jitterAmount = Math.max(0.0, Math.min(1.0, crystal.getJitter()));
|
||||
double emitRadius = Math.max(0.0, crystal.getBaseRadius() * 0.6);
|
||||
double spreadRadians = Math.toRadians(Math.max(0.0, Math.min(90.0, crystal.spreadAngle())));
|
||||
double jitterAmount = Math.max(0.0, Math.min(1.0, crystal.jitter()));
|
||||
double emitRadius = Math.max(0.0, crystal.baseRadius() * 0.6);
|
||||
|
||||
for (int i = 0; i < shardCount; i++) {
|
||||
double azimuth = azimuth(crystal.getDistribution(), i, rng);
|
||||
double azimuth = azimuth(crystal.distribution(), i, rng);
|
||||
azimuth += rng.d(-Math.PI, Math.PI) * jitterAmount * 0.5;
|
||||
|
||||
double cone = spreadRadians * fanFraction(shardCount, i, rng);
|
||||
@@ -63,9 +63,9 @@ public final class CrystalShardBuilder {
|
||||
}
|
||||
}
|
||||
|
||||
private static void rasterizeShard(CrystalCanvas canvas, IrisCrystal crystal, double ox, double oy, double oz, double[] direction, int length) {
|
||||
double baseRadius = Math.max(0.5, crystal.getShardBaseRadius());
|
||||
double taper = Math.max(0.0, Math.min(1.0, crystal.getShardTaper()));
|
||||
private static void rasterizeShard(CrystalCanvas canvas, Crystal crystal, double ox, double oy, double oz, double[] direction, int length) {
|
||||
double baseRadius = Math.max(0.5, crystal.shardBaseRadius());
|
||||
double taper = Math.max(0.0, Math.min(1.0, crystal.shardTaper()));
|
||||
|
||||
int samples = Math.max(1, length * 3);
|
||||
|
||||
@@ -108,8 +108,8 @@ public final class CrystalShardBuilder {
|
||||
canvas.set(tipX, tipY, tipZ, CrystalRole.TIP);
|
||||
}
|
||||
|
||||
private static double azimuth(IrisCrystalDistribution distribution, int index, RNG rng) {
|
||||
if (distribution == IrisCrystalDistribution.GOLDEN_ANGLE) {
|
||||
private static double azimuth(CrystalDistribution distribution, int index, RNG rng) {
|
||||
if (distribution == CrystalDistribution.GOLDEN_ANGLE) {
|
||||
return Math.toRadians(index * GOLDEN_ANGLE);
|
||||
}
|
||||
return rng.d(0.0, Math.PI * 2.0);
|
||||
|
||||
@@ -1,230 +0,0 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2022 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.engine.object.procedural.crystal;
|
||||
|
||||
import art.arcane.iris.builtin.carve.CarvingMode;
|
||||
import art.arcane.iris.builtin.anchor.ObjectPlaceMode;
|
||||
import art.arcane.iris.builtin.stilt.StiltSettings;
|
||||
import art.arcane.iris.builtin.vacuum.VacuumSettings;
|
||||
import art.arcane.iris.builtin.validate.ObjectLimit;
|
||||
import art.arcane.iris.engine.object.material.IrisMaterialPalette;
|
||||
import art.arcane.iris.engine.object.placement.IrisObjectPlacement;
|
||||
import art.arcane.iris.engine.object.prefab.IrisObject;
|
||||
import art.arcane.iris.engine.object.prefab.IrisObjectRotation;
|
||||
import art.arcane.iris.engine.object.prefab.IrisObjectTranslate;
|
||||
import art.arcane.iris.engine.object.procedural.IrisProceduralPlacement;
|
||||
import art.arcane.iris.core.loader.IrisData;
|
||||
import art.arcane.iris.engine.data.cache.AtomicCache;
|
||||
import art.arcane.iris.engine.object.annotations.Desc;
|
||||
import art.arcane.iris.engine.object.annotations.MaxNumber;
|
||||
import art.arcane.iris.engine.object.annotations.MinNumber;
|
||||
import art.arcane.iris.engine.object.annotations.RegistryListBlockType;
|
||||
import art.arcane.iris.engine.object.annotations.Required;
|
||||
import art.arcane.iris.engine.object.annotations.Snippet;
|
||||
import art.arcane.iris.engine.object.procedural.crystal.CrystalGenerator;
|
||||
import art.arcane.volmlib.util.collection.KList;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
@Snippet("crystal")
|
||||
@Accessors(chain = true)
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Desc("A single procedurally generated crystal cluster: a budding base blob with faceted, tapered shards radiating from it (geode / amethyst-style). Iris bakes a pool of deterministic variants from these settings and scatters them at world-gen time, exactly like an object placement but generated from scratch instead of loaded from an iob file. Built for caves.")
|
||||
@Data
|
||||
public class IrisCrystal implements IrisProceduralPlacement {
|
||||
private final transient AtomicCache<KList<IrisObject>> variantCache = new AtomicCache<>();
|
||||
|
||||
@Desc("A human readable name used in logs and as the variant load key.")
|
||||
private String name = "crystal";
|
||||
|
||||
@MinNumber(0)
|
||||
@MaxNumber(1)
|
||||
@Desc("The chance per chunk for this crystal cluster to attempt placement. Use density for multiple per chunk.")
|
||||
private double chance = 0.2;
|
||||
|
||||
@MinNumber(1)
|
||||
@Desc("If the chance check passes, attempt this many placements in the chunk.")
|
||||
private int density = 1;
|
||||
|
||||
@MinNumber(1)
|
||||
@MaxNumber(64)
|
||||
@Desc("How many distinct variants to pre-bake for this crystal cluster. Higher means more variety at a small memory cost.")
|
||||
private int variants = 6;
|
||||
|
||||
@Desc("The base seed for deterministic generation. The same seed and settings always bake the same variants.")
|
||||
private long seed = 1337;
|
||||
|
||||
@Desc("The placement mode used to anchor the crystal cluster to the terrain.")
|
||||
private ObjectPlaceMode mode = ObjectPlaceMode.CENTER_HEIGHT;
|
||||
|
||||
@Desc("Rotate this crystal cluster's placement.")
|
||||
private IrisObjectRotation rotation = new IrisObjectRotation();
|
||||
|
||||
@Desc("Limit the max or min height of placement.")
|
||||
private ObjectLimit clamp = new ObjectLimit();
|
||||
|
||||
@Desc("Whether this crystal cluster may place on the terrain surface, under carvings, or both. Crystals are meant for caves, so this defaults to CARVING_ONLY.")
|
||||
private CarvingMode carvingSupport = CarvingMode.CARVING_ONLY;
|
||||
|
||||
@Desc("If true, the crystal cluster anchors on the terrain height ignoring the water surface.")
|
||||
private boolean underwater = false;
|
||||
|
||||
@Desc("Translate (offset) this placement along each axis; for example set a negative y to sink it into the ground.")
|
||||
private IrisObjectTranslate translate = new IrisObjectTranslate();
|
||||
|
||||
@Desc("Settings for the stilt place modes (STILT, MIN_STILT, FAST_STILT, CENTER_STILT, ERODE_STILT, ORGANIC_STILT).")
|
||||
private StiltSettings stiltSettings;
|
||||
|
||||
@Desc("Settings for the vacuum place modes (VACUUM, VACUUM_HIGH, VACUUM_FAST, VACUUM_ORGANIC).")
|
||||
private VacuumSettings vacuumSettings;
|
||||
|
||||
@Desc("The surface this crystal grows from (FLOOR shards up, CEILING shards down, WALL shards outward). This orients the baked geometry only.")
|
||||
private IrisCrystalSurface growthSurface = IrisCrystalSurface.FLOOR;
|
||||
|
||||
@Required
|
||||
@Desc("The primary crystal shard block, e.g. minecraft:amethyst_block. Ignored when blockPalette is set.")
|
||||
@RegistryListBlockType
|
||||
private String block = "minecraft:amethyst_block";
|
||||
|
||||
@Desc("A noise-driven palette for the crystal shards (a prismatic mix, e.g. amethyst_block, calcite, tinted_glass). When set this overrides the single block, letting the shards mix blocks by noise. Palette wins.")
|
||||
private IrisMaterialPalette blockPalette = null;
|
||||
|
||||
@Desc("Optional block placed at the very tip of each shard for a different colored or sparkling point (e.g. minecraft:amethyst_cluster or glowstone). Ignored when tipPalette is set. If unset and glow is true, a light-emitting block is sprinkled among the tips instead.")
|
||||
@RegistryListBlockType
|
||||
private String tipBlock = null;
|
||||
|
||||
@Desc("A noise-driven palette for the shard tips. When set this overrides the single tipBlock. Palette wins.")
|
||||
private IrisMaterialPalette tipPalette = null;
|
||||
|
||||
@MinNumber(0)
|
||||
@MaxNumber(1)
|
||||
@Desc("The chance per shard that its very tip is replaced by the tip block (or glow block).")
|
||||
private double tipChance = 0.6;
|
||||
|
||||
@Desc("If true and no tipBlock/tipPalette is set, sprinkle a light-emitting block (the glowBlock) among the shard tips for a sparkling geode.")
|
||||
private boolean glow = false;
|
||||
|
||||
@Desc("The light-emitting block sprinkled among the tips when glow is true and no tip block is configured.")
|
||||
@RegistryListBlockType
|
||||
private String glowBlock = "minecraft:glowstone";
|
||||
|
||||
@Desc("Optional block for the budding base blob the shards grow from, e.g. minecraft:budding_amethyst or calcite. Ignored when basePalette is set. If unset, the base is built from the primary shard block.")
|
||||
@RegistryListBlockType
|
||||
private String baseBlock = "minecraft:budding_amethyst";
|
||||
|
||||
@Desc("A noise-driven palette for the budding base blob. When set this overrides the single baseBlock. Palette wins.")
|
||||
private IrisMaterialPalette basePalette = null;
|
||||
|
||||
@MinNumber(0)
|
||||
@Desc("Radius in blocks of the budding base blob the shards radiate from. 0 places no base blob (shards spring from a single point).")
|
||||
private double baseRadius = 1.6;
|
||||
|
||||
@MinNumber(0)
|
||||
@MaxNumber(1)
|
||||
@Desc("How strongly value noise perturbs the surface of the base blob, for a lumpy organic budding base rather than a clean sphere.")
|
||||
private double baseNoise = 0.35;
|
||||
|
||||
@MinNumber(1)
|
||||
@Desc("Minimum number of shards radiating from the base.")
|
||||
private int shardCountMin = 5;
|
||||
|
||||
@MinNumber(1)
|
||||
@Desc("Maximum number of shards radiating from the base.")
|
||||
private int shardCountMax = 11;
|
||||
|
||||
@MinNumber(1)
|
||||
@Desc("Minimum length in blocks of a shard, measured from the base out to its pointed tip.")
|
||||
private int shardLengthMin = 3;
|
||||
|
||||
@MinNumber(1)
|
||||
@Desc("Maximum length in blocks of a shard, measured from the base out to its pointed tip.")
|
||||
private int shardLengthMax = 8;
|
||||
|
||||
@MinNumber(0.5)
|
||||
@Desc("Starting radius in blocks of a shard at its thick base end. The shard tapers from this down to a single block at the tip.")
|
||||
private double shardBaseRadius = 1.4;
|
||||
|
||||
@MinNumber(0)
|
||||
@MaxNumber(1)
|
||||
@Desc("How aggressively each shard narrows from base to tip. 0 keeps a near-constant column; 1 tapers fully to a sharp point at the very tip. Each shard always ends in a single pointed block.")
|
||||
private double shardTaper = 0.85;
|
||||
|
||||
@MinNumber(0)
|
||||
@MaxNumber(90)
|
||||
@Desc("The half-angle in degrees of the cone the shards fan within around the surface normal. 0 makes all shards parallel to the normal; larger values splay them outward into a starburst.")
|
||||
private double spreadAngle = 45;
|
||||
|
||||
@Desc("How the shard azimuths are distributed around the normal (RANDOM for a chaotic clump, GOLDEN_ANGLE for an evenly spaced rosette).")
|
||||
private IrisCrystalDistribution distribution = IrisCrystalDistribution.GOLDEN_ANGLE;
|
||||
|
||||
@MinNumber(0)
|
||||
@MaxNumber(1)
|
||||
@Desc("Per-shard angular randomness (0-1) added on top of the chosen distribution so the cluster never looks mechanically regular. 0 is perfectly distributed; 1 is heavily jittered.")
|
||||
private double jitter = 0.25;
|
||||
|
||||
public KList<IrisObject> getVariantObjects(IrisData data) {
|
||||
return variantCache.aquire(() -> {
|
||||
KList<IrisObject> baked = new KList<>();
|
||||
int count = Math.max(1, variants);
|
||||
|
||||
for (int i = 0; i < count; i++) {
|
||||
IrisObject object = CrystalGenerator.generate(this, i, new RNG(seed + (i * 7919L)), data);
|
||||
if (object == null || object.getBlocks().isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
object.setLoadKey("procedural/" + name + "#" + i);
|
||||
object.setLoader(data);
|
||||
baked.add(object);
|
||||
}
|
||||
|
||||
return baked;
|
||||
});
|
||||
}
|
||||
|
||||
public IrisObject getVariantObject(IrisData data, RNG rng) {
|
||||
KList<IrisObject> baked = getVariantObjects(data);
|
||||
if (baked == null || baked.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
return baked.get(rng.i(baked.size()));
|
||||
}
|
||||
|
||||
public IrisObjectPlacement asPlacement() {
|
||||
IrisObjectPlacement placement = new IrisObjectPlacement();
|
||||
placement.setMode(mode);
|
||||
placement.setRotation(rotation);
|
||||
placement.setClamp(clamp);
|
||||
placement.setCarvingSupport(carvingSupport);
|
||||
placement.setUnderwater(underwater);
|
||||
placement.setTranslate(translate);
|
||||
placement.setStiltSettings(stiltSettings);
|
||||
placement.setVacuumSettings(vacuumSettings);
|
||||
placement.setChance(chance);
|
||||
placement.setDensity(density);
|
||||
return placement;
|
||||
}
|
||||
|
||||
public boolean isPlausible() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
-30
@@ -1,30 +0,0 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2022 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.engine.object.procedural.crystal;
|
||||
|
||||
import art.arcane.iris.engine.object.annotations.Desc;
|
||||
|
||||
@Desc("How the shards of a crystal cluster are angularly distributed around the surface normal.")
|
||||
public enum IrisCrystalDistribution {
|
||||
@Desc("Each shard gets a uniformly random azimuth around the normal. Produces a chaotic, naturally clumped cluster.")
|
||||
RANDOM,
|
||||
|
||||
@Desc("Each shard's azimuth advances by the golden angle (~137.5 degrees) from the previous one. Produces an evenly spaced sunflower-like fan with no two shards overlapping, ideal for a geode rosette.")
|
||||
GOLDEN_ANGLE
|
||||
}
|
||||
-33
@@ -1,33 +0,0 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2022 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.engine.object.procedural.crystal;
|
||||
|
||||
import art.arcane.iris.engine.object.annotations.Desc;
|
||||
|
||||
@Desc("The surface a crystal cluster grows from. This only orients the baked geometry (which way the shards point); placement of the object into a cave is handled by the placement system, not here.")
|
||||
public enum IrisCrystalSurface {
|
||||
@Desc("Grows from a cave floor. The budding base sits at the bottom and the shards point upward, fanning within the spread cone around the up axis. Built with positive py so the cluster grows up from the base layer.")
|
||||
FLOOR,
|
||||
|
||||
@Desc("Grows from a cave ceiling. The budding base sits at the top and the shards point downward like stalactites, fanning within the spread cone around the down axis. Built with negative py so the cluster grows down from the ceiling.")
|
||||
CEILING,
|
||||
|
||||
@Desc("Grows from a cave wall. The budding base hugs the wall and the shards point outward and slightly upward, fanning within the spread cone around a tilted normal so the cluster reads as a wall sconce of shards.")
|
||||
WALL
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Servers
|
||||
* Copyright (c) 2026 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.engine.object.procedural.crystal;
|
||||
|
||||
import art.arcane.iris.builtin.objects.crystal.Crystal;
|
||||
import art.arcane.iris.core.loader.IrisData;
|
||||
import art.arcane.iris.engine.object.prefab.IrisObject;
|
||||
import art.arcane.iris.engine.object.procedural.ResolvedProceduralPlacement;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
|
||||
/** A crystal cluster made placeable: its variants are baked by {@link CrystalGenerator}. */
|
||||
public final class ResolvedCrystal extends ResolvedProceduralPlacement {
|
||||
private final Crystal settings;
|
||||
|
||||
public ResolvedCrystal(Crystal settings) {
|
||||
super(new Shape(settings.name(), settings.chance(), settings.density(), settings.seed(), settings.variants(), settings.mode(),
|
||||
settings.rotation(), settings.clamp(), settings.carvingSupport(), settings.underwater(), settings.translate(),
|
||||
settings.stiltSettings().orElse(null), settings.vacuumSettings().orElse(null)));
|
||||
this.settings = settings;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected IrisObject generate(int index, RNG rng, IrisData data) {
|
||||
return CrystalGenerator.generate(settings, index, rng, data);
|
||||
}
|
||||
}
|
||||
+14
-12
@@ -18,8 +18,10 @@
|
||||
|
||||
package art.arcane.iris.engine.object.procedural.formation;
|
||||
|
||||
import com.volmit.block.PaletteSpec;
|
||||
import java.util.Optional;
|
||||
import art.arcane.iris.builtin.objects.formation.Formation;
|
||||
import art.arcane.iris.core.loader.IrisData;
|
||||
import art.arcane.iris.engine.object.procedural.formation.IrisFormation;
|
||||
import art.arcane.iris.engine.object.material.IrisMaterialPalette;
|
||||
import art.arcane.iris.engine.object.procedural.IrisProceduralBlocks;
|
||||
import art.arcane.iris.spi.PlatformBlockState;
|
||||
@@ -30,37 +32,37 @@ public final class FormationBlockResolver {
|
||||
private FormationBlockResolver() {
|
||||
}
|
||||
|
||||
public static PlatformBlockState resolve(IrisFormation f, IrisData data, FormationCanvas.Role role, Vector3i raw) {
|
||||
public static PlatformBlockState resolve(Formation f, IrisData data, FormationCanvas.Role role, Vector3i raw) {
|
||||
int x = raw.getBlockX();
|
||||
int y = raw.getBlockY();
|
||||
int z = raw.getBlockZ();
|
||||
RNG paletteRng = new RNG(f.getSeed());
|
||||
RNG paletteRng = new RNG(f.seed());
|
||||
|
||||
if (role == FormationCanvas.Role.CAP && capDefined(f)) {
|
||||
PlatformBlockState cap = IrisProceduralBlocks.resolve(f.getCapBlock(), f.getCapPalette(), data, x, y, z, paletteRng);
|
||||
PlatformBlockState cap = IrisProceduralBlocks.resolve(f.capBlock(), f.capPalette(), data, x, y, z, paletteRng);
|
||||
if (cap != null) {
|
||||
return cap;
|
||||
}
|
||||
}
|
||||
|
||||
if (strataDefined(f)) {
|
||||
IrisMaterialPalette strata = f.getStrataPalette();
|
||||
int thickness = Math.max(1, f.getStrataThickness());
|
||||
PaletteSpec strata = f.strataPalette().orElseThrow();
|
||||
int thickness = Math.max(1, f.strataThickness());
|
||||
int band = Math.floorDiv(y, thickness);
|
||||
PlatformBlockState strataState = strata.get(new RNG(f.getSeed() + (band * 31L)), x, band, z, data);
|
||||
PlatformBlockState strataState = IrisProceduralBlocks.pick(strata, data, f.seed() + (band * 31L), x, band, z);
|
||||
if (strataState != null) {
|
||||
return strataState;
|
||||
}
|
||||
}
|
||||
|
||||
return IrisProceduralBlocks.resolve(f.getBlock(), f.getBlockPalette(), data, x, y, z, paletteRng);
|
||||
return IrisProceduralBlocks.resolve(f.block(), f.blockPalette(), data, x, y, z, paletteRng);
|
||||
}
|
||||
|
||||
private static boolean capDefined(IrisFormation f) {
|
||||
return IrisProceduralBlocks.paletteSet(f.getCapPalette()) || (f.getCapBlock() != null && !f.getCapBlock().isEmpty());
|
||||
private static boolean capDefined(Formation f) {
|
||||
return IrisProceduralBlocks.paletteSet(f.capPalette()) || f.capBlock().filter(block -> !block.isEmpty()).isPresent();
|
||||
}
|
||||
|
||||
private static boolean strataDefined(IrisFormation f) {
|
||||
return IrisProceduralBlocks.paletteSet(f.getStrataPalette());
|
||||
private static boolean strataDefined(Formation f) {
|
||||
return IrisProceduralBlocks.paletteSet(f.strataPalette());
|
||||
}
|
||||
}
|
||||
+7
-7
@@ -18,8 +18,8 @@
|
||||
|
||||
package art.arcane.iris.engine.object.procedural.formation;
|
||||
|
||||
import art.arcane.iris.builtin.objects.formation.Formation;
|
||||
import art.arcane.iris.core.loader.IrisData;
|
||||
import art.arcane.iris.engine.object.procedural.formation.IrisFormation;
|
||||
import art.arcane.iris.engine.object.prefab.IrisObject;
|
||||
import art.arcane.iris.engine.object.procedural.IrisProceduralBlocks;
|
||||
import art.arcane.iris.spi.PlatformBlockState;
|
||||
@@ -33,18 +33,18 @@ public final class FormationGenerator {
|
||||
private FormationGenerator() {
|
||||
}
|
||||
|
||||
public static IrisObject generate(IrisFormation f, int variantIndex, RNG rng, IrisData data) {
|
||||
int lo = Math.min(f.getHeightMin(), f.getHeightMax());
|
||||
int hi = Math.max(f.getHeightMin(), f.getHeightMax());
|
||||
public static IrisObject generate(Formation f, int variantIndex, RNG rng, IrisData data) {
|
||||
int lo = Math.min(f.heightMin(), f.heightMax());
|
||||
int hi = Math.max(f.heightMin(), f.heightMax());
|
||||
int height = Math.max(3, rng.i(lo, hi + 1));
|
||||
|
||||
int wLo = Math.min(f.getBaseWidthMin(), f.getBaseWidthMax());
|
||||
int wHi = Math.max(f.getBaseWidthMin(), f.getBaseWidthMax());
|
||||
int wLo = Math.min(f.baseWidthMin(), f.baseWidthMax());
|
||||
int wHi = Math.max(f.baseWidthMin(), f.baseWidthMax());
|
||||
double baseRadius = Math.max(1, rng.i(wLo, wHi + 1));
|
||||
|
||||
FormationCanvas canvas = new FormationCanvas();
|
||||
|
||||
switch (f.getForm()) {
|
||||
switch (f.form()) {
|
||||
case SPIRE -> FormationShapeBuilder.spire(canvas, f, height, baseRadius, rng);
|
||||
case HOODOO -> FormationShapeBuilder.hoodoo(canvas, f, height, baseRadius, rng);
|
||||
case ARCH -> FormationShapeBuilder.arch(canvas, f, height, baseRadius, rng);
|
||||
|
||||
+7
-6
@@ -18,15 +18,16 @@
|
||||
|
||||
package art.arcane.iris.engine.object.procedural.formation;
|
||||
|
||||
import art.arcane.iris.engine.object.procedural.formation.IrisFormation;
|
||||
import art.arcane.iris.builtin.objects.formation.Formation;
|
||||
|
||||
|
||||
public final class FormationProfiles {
|
||||
private FormationProfiles() {
|
||||
}
|
||||
|
||||
public static double radiusAt(IrisFormation f, double baseRadius, double topRadius, double t) {
|
||||
public static double radiusAt(Formation f, double baseRadius, double topRadius, double t) {
|
||||
double clamped = Math.max(0.0, Math.min(1.0, t));
|
||||
return switch (f.getProfile()) {
|
||||
return switch (f.profile()) {
|
||||
case CONSTANT -> baseRadius;
|
||||
case LINEAR -> baseRadius + (topRadius - baseRadius) * clamped;
|
||||
case TAPER -> baseRadius + (topRadius - baseRadius) * smoothstep(clamped);
|
||||
@@ -35,9 +36,9 @@ public final class FormationProfiles {
|
||||
};
|
||||
}
|
||||
|
||||
private static double parabolic(IrisFormation f, double baseRadius, double topRadius, double t) {
|
||||
double waist = Math.max(0.0, Math.min(1.0, f.getProfileWaist()));
|
||||
double floor = Math.max(0.0, Math.min(1.0, f.getProfileWaistFloor()));
|
||||
private static double parabolic(Formation f, double baseRadius, double topRadius, double t) {
|
||||
double waist = Math.max(0.0, Math.min(1.0, f.profileWaist()));
|
||||
double floor = Math.max(0.0, Math.min(1.0, f.profileWaistFloor()));
|
||||
double denom = Math.pow(Math.max(waist, 1.0 - waist), 2);
|
||||
if (denom == 0) {
|
||||
denom = 1;
|
||||
|
||||
+53
-53
@@ -18,7 +18,7 @@
|
||||
|
||||
package art.arcane.iris.engine.object.procedural.formation;
|
||||
|
||||
import art.arcane.iris.engine.object.procedural.formation.IrisFormation;
|
||||
import art.arcane.iris.builtin.objects.formation.Formation;
|
||||
import art.arcane.iris.engine.object.procedural.tree.TreeFunctions;
|
||||
import art.arcane.iris.util.common.math.Vector3i;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
@@ -30,11 +30,11 @@ public final class FormationShapeBuilder {
|
||||
private FormationShapeBuilder() {
|
||||
}
|
||||
|
||||
public static void spire(FormationCanvas canvas, IrisFormation f, int height, double baseRadius, RNG rng) {
|
||||
double topRadius = f.getTopWidth();
|
||||
public static void spire(FormationCanvas canvas, Formation f, int height, double baseRadius, RNG rng) {
|
||||
double topRadius = f.topWidth();
|
||||
column(canvas, f, height, baseRadius, topRadius, 0, 0, rng, true);
|
||||
double lean = Math.toRadians(f.getLean());
|
||||
double azimuth = Math.toRadians(f.getLeanAzimuth());
|
||||
double lean = Math.toRadians(f.lean());
|
||||
double azimuth = Math.toRadians(f.leanAzimuth());
|
||||
int previousX = 0;
|
||||
int previousZ = 0;
|
||||
for (int y = 0; y < height; y++) {
|
||||
@@ -53,25 +53,25 @@ public final class FormationShapeBuilder {
|
||||
}
|
||||
}
|
||||
|
||||
public static void seaStack(FormationCanvas canvas, IrisFormation f, int height, double baseRadius, RNG rng) {
|
||||
public static void seaStack(FormationCanvas canvas, Formation f, int height, double baseRadius, RNG rng) {
|
||||
double topRadius = Math.max(1.0, baseRadius * 0.55);
|
||||
if (f.getTopWidth() > 0) {
|
||||
topRadius = f.getTopWidth();
|
||||
if (f.topWidth() > 0) {
|
||||
topRadius = f.topWidth();
|
||||
}
|
||||
column(canvas, f, height, baseRadius, topRadius, 0, 0, rng, true);
|
||||
}
|
||||
|
||||
public static void hoodoo(FormationCanvas canvas, IrisFormation f, int height, double baseRadius, RNG rng) {
|
||||
double topRadius = f.getTopWidth() > 0 ? f.getTopWidth() : Math.max(1.0, baseRadius * 0.7);
|
||||
public static void hoodoo(FormationCanvas canvas, Formation f, int height, double baseRadius, RNG rng) {
|
||||
double topRadius = f.topWidth() > 0 ? f.topWidth() : Math.max(1.0, baseRadius * 0.7);
|
||||
column(canvas, f, height, baseRadius, topRadius, 0, 0, rng, false);
|
||||
|
||||
int capRadius = f.getHoodooCapRadius();
|
||||
int capRadius = f.hoodooCapRadius();
|
||||
if (capRadius <= 0) {
|
||||
return;
|
||||
}
|
||||
int capHeight = Math.max(1, f.getHoodooCapHeight());
|
||||
double lean = Math.toRadians(f.getLean());
|
||||
double azimuth = Math.toRadians(f.getLeanAzimuth());
|
||||
int capHeight = Math.max(1, f.hoodooCapHeight());
|
||||
double lean = Math.toRadians(f.lean());
|
||||
double azimuth = Math.toRadians(f.leanAzimuth());
|
||||
double shear = Math.tan(lean) * height;
|
||||
double topOffX = Math.cos(azimuth) * shear;
|
||||
double topOffZ = Math.sin(azimuth) * shear;
|
||||
@@ -85,12 +85,12 @@ public final class FormationShapeBuilder {
|
||||
}
|
||||
}
|
||||
|
||||
public static void boulder(FormationCanvas canvas, IrisFormation f, int height, double baseRadius, RNG rng) {
|
||||
public static void boulder(FormationCanvas canvas, Formation f, int height, double baseRadius, RNG rng) {
|
||||
double rx = baseRadius;
|
||||
double ry = Math.max(2.0, height * 0.5);
|
||||
double rz = baseRadius * (0.8 + rng.d(0.0, 0.3));
|
||||
double roughness = Math.max(0.0, Math.min(1.0, f.getRoughness()));
|
||||
long noiseSeed = f.getSeed() + 4201L;
|
||||
double roughness = Math.max(0.0, Math.min(1.0, f.roughness()));
|
||||
long noiseSeed = f.seed() + 4201L;
|
||||
|
||||
int maxR = (int) Math.ceil(Math.max(rx, Math.max(ry, rz))) + 2;
|
||||
for (int x = -maxR; x <= maxR; x++) {
|
||||
@@ -109,10 +109,10 @@ public final class FormationShapeBuilder {
|
||||
}
|
||||
}
|
||||
|
||||
public static void arch(FormationCanvas canvas, IrisFormation f, int height, double baseRadius, RNG rng) {
|
||||
double span = Math.max(2.0, f.getArchSpan());
|
||||
double tubeRadius = Math.max(0.75, f.getArchThickness() * 0.5);
|
||||
double asymmetry = Math.max(0.0, Math.min(1.0, f.getArchAsymmetry()));
|
||||
public static void arch(FormationCanvas canvas, Formation f, int height, double baseRadius, RNG rng) {
|
||||
double span = Math.max(2.0, f.archSpan());
|
||||
double tubeRadius = Math.max(0.75, f.archThickness() * 0.5);
|
||||
double asymmetry = Math.max(0.0, Math.min(1.0, f.archAsymmetry()));
|
||||
double leftFootX = -span * 0.5 - tubeRadius - rng.d(0.0, span * 0.16) * asymmetry;
|
||||
double rightFootX = span * 0.5 + tubeRadius + rng.d(0.0, span * 0.16) * asymmetry;
|
||||
double leftFootZ = rng.d(-tubeRadius * 0.45, tubeRadius * 0.45) * asymmetry;
|
||||
@@ -164,10 +164,10 @@ public final class FormationShapeBuilder {
|
||||
}
|
||||
}
|
||||
|
||||
public static void basaltColumns(FormationCanvas canvas, IrisFormation f, int height, double baseRadius, RNG rng) {
|
||||
int count = Math.max(2, f.getBasaltColumns());
|
||||
int colRadius = Math.max(1, f.getBasaltColumnRadius());
|
||||
double variance = Math.max(0.0, Math.min(1.0, f.getBasaltHeightVariance()));
|
||||
public static void basaltColumns(FormationCanvas canvas, Formation f, int height, double baseRadius, RNG rng) {
|
||||
int count = Math.max(2, f.basaltColumns());
|
||||
int colRadius = Math.max(1, f.basaltColumnRadius());
|
||||
double variance = Math.max(0.0, Math.min(1.0, f.basaltHeightVariance()));
|
||||
int spread = (int) Math.ceil(baseRadius);
|
||||
|
||||
for (int c = 0; c < count; c++) {
|
||||
@@ -194,14 +194,14 @@ public final class FormationShapeBuilder {
|
||||
}
|
||||
}
|
||||
|
||||
public static void iceberg(FormationCanvas canvas, IrisFormation f, int height, double baseRadius, RNG rng) {
|
||||
public static void iceberg(FormationCanvas canvas, Formation f, int height, double baseRadius, RNG rng) {
|
||||
long noiseSeed = rng.nextLong();
|
||||
double bodyHeight = Math.max(2.0, height * 0.42);
|
||||
double radiusX = baseRadius * rng.d(1.15, 1.5);
|
||||
double radiusZ = baseRadius * rng.d(1.0, 1.35);
|
||||
ellipsoid(canvas, radiusX, bodyHeight, radiusZ, bodyHeight * 0.36, noiseSeed, f.getRoughness());
|
||||
ellipsoid(canvas, radiusX, bodyHeight, radiusZ, bodyHeight * 0.36, noiseSeed, f.roughness());
|
||||
|
||||
int peaks = Math.max(1, f.getIcebergPeaks());
|
||||
int peaks = Math.max(1, f.icebergPeaks());
|
||||
double phase = rng.d(0.0, Math.PI * 2.0);
|
||||
for (int i = 0; i < peaks; i++) {
|
||||
double angle = phase + (Math.PI * 2.0 * i / peaks) + rng.d(-0.35, 0.35);
|
||||
@@ -215,9 +215,9 @@ public final class FormationShapeBuilder {
|
||||
}
|
||||
}
|
||||
|
||||
public static void fissure(FormationCanvas canvas, IrisFormation f, int height, double baseRadius, RNG rng) {
|
||||
int count = Math.max(2, f.getFractureCount());
|
||||
double separation = Math.max(1.0, f.getFractureSeparation());
|
||||
public static void fissure(FormationCanvas canvas, Formation f, int height, double baseRadius, RNG rng) {
|
||||
int count = Math.max(2, f.fractureCount());
|
||||
double separation = Math.max(1.0, f.fractureSeparation());
|
||||
double shardRadius = Math.max(1.0, baseRadius / Math.max(1.6, count * 0.72));
|
||||
double phase = rng.d(0.0, Math.PI * 2.0);
|
||||
|
||||
@@ -233,11 +233,11 @@ public final class FormationShapeBuilder {
|
||||
}
|
||||
}
|
||||
|
||||
public static void spiral(FormationCanvas canvas, IrisFormation f, int height, double baseRadius, RNG rng) {
|
||||
public static void spiral(FormationCanvas canvas, Formation f, int height, double baseRadius, RNG rng) {
|
||||
int steps = Math.max(12, height * 4);
|
||||
double turns = Math.max(0.25, f.getSpiralTurns());
|
||||
double startRadius = Math.max(1.0, f.getSpiralRadius());
|
||||
double startThickness = Math.max(1.0, f.getSpiralThickness());
|
||||
double turns = Math.max(0.25, f.spiralTurns());
|
||||
double startRadius = Math.max(1.0, f.spiralRadius());
|
||||
double startThickness = Math.max(1.0, f.spiralThickness());
|
||||
double phase = rng.d(0.0, Math.PI * 2.0);
|
||||
long noiseSeed = rng.nextLong();
|
||||
|
||||
@@ -257,11 +257,11 @@ public final class FormationShapeBuilder {
|
||||
(int) Math.round(Math.sin(phase) * startRadius), footRadius, false, rng);
|
||||
}
|
||||
|
||||
public static void overhang(FormationCanvas canvas, IrisFormation f, int height, double baseRadius, RNG rng) {
|
||||
public static void overhang(FormationCanvas canvas, Formation f, int height, double baseRadius, RNG rng) {
|
||||
int steps = Math.max(12, height * 4);
|
||||
double reach = Math.max(1.0, f.getOverhangReach());
|
||||
double drop = Math.max(0.0, f.getOverhangDrop());
|
||||
double phase = Math.toRadians(f.getLeanAzimuth()) + rng.d(-0.18, 0.18);
|
||||
double reach = Math.max(1.0, f.overhangReach());
|
||||
double drop = Math.max(0.0, f.overhangDrop());
|
||||
double phase = Math.toRadians(f.leanAzimuth()) + rng.d(-0.18, 0.18);
|
||||
double trunkHeight = Math.max(3.0, height * 0.62);
|
||||
long noiseSeed = rng.nextLong();
|
||||
|
||||
@@ -285,12 +285,12 @@ public final class FormationShapeBuilder {
|
||||
}
|
||||
}
|
||||
|
||||
private static void column(FormationCanvas canvas, IrisFormation f, int height, double baseRadius, double topRadius, int extraBaseX, int extraBaseZ, RNG rng, boolean capTop) {
|
||||
double lean = Math.toRadians(f.getLean());
|
||||
double azimuth = Math.toRadians(f.getLeanAzimuth());
|
||||
double roughness = Math.max(0.0, Math.min(1.0, f.getRoughness()));
|
||||
double jitter = Math.max(0.0, Math.min(1.0, f.getJitter()));
|
||||
long noiseSeed = f.getSeed() + 9001L;
|
||||
private static void column(FormationCanvas canvas, Formation f, int height, double baseRadius, double topRadius, int extraBaseX, int extraBaseZ, RNG rng, boolean capTop) {
|
||||
double lean = Math.toRadians(f.lean());
|
||||
double azimuth = Math.toRadians(f.leanAzimuth());
|
||||
double roughness = Math.max(0.0, Math.min(1.0, f.roughness()));
|
||||
double jitter = Math.max(0.0, Math.min(1.0, f.jitter()));
|
||||
long noiseSeed = f.seed() + 9001L;
|
||||
|
||||
for (int y = 0; y < height; y++) {
|
||||
double t = height <= 1 ? 1.0 : (y / (double) (height - 1));
|
||||
@@ -311,7 +311,7 @@ public final class FormationShapeBuilder {
|
||||
}
|
||||
}
|
||||
|
||||
private static void ringDisc(FormationCanvas canvas, IrisFormation f, int cx, int y, int cz, double radius, double roughness, double jitter, long noiseSeed, boolean cap, RNG rng) {
|
||||
private static void ringDisc(FormationCanvas canvas, Formation f, int cx, int y, int cz, double radius, double roughness, double jitter, long noiseSeed, boolean cap, RNG rng) {
|
||||
int r = (int) Math.ceil(radius) + 1;
|
||||
for (int x = -r; x <= r; x++) {
|
||||
for (int z = -r; z <= r; z++) {
|
||||
@@ -332,7 +332,7 @@ public final class FormationShapeBuilder {
|
||||
}
|
||||
}
|
||||
|
||||
private static void disc(FormationCanvas canvas, IrisFormation f, int cx, int y, int cz, double radius, boolean cap, RNG rng) {
|
||||
private static void disc(FormationCanvas canvas, Formation f, int cx, int y, int cz, double radius, boolean cap, RNG rng) {
|
||||
int r = (int) Math.ceil(radius) + 1;
|
||||
for (int x = -r; x <= r; x++) {
|
||||
for (int z = -r; z <= r; z++) {
|
||||
@@ -347,11 +347,11 @@ public final class FormationShapeBuilder {
|
||||
}
|
||||
}
|
||||
|
||||
private static void taperedPeak(FormationCanvas canvas, IrisFormation f, int height, double radius,
|
||||
private static void taperedPeak(FormationCanvas canvas, Formation f, int height, double radius,
|
||||
int offsetX, int offsetZ, double leanAngle, double leanDistance, RNG rng) {
|
||||
long noiseSeed = rng.nextLong();
|
||||
double roughness = Math.max(0.0, Math.min(1.0, f.getRoughness()));
|
||||
double jitter = Math.max(0.0, Math.min(1.0, f.getJitter()));
|
||||
double roughness = Math.max(0.0, Math.min(1.0, f.roughness()));
|
||||
double jitter = Math.max(0.0, Math.min(1.0, f.jitter()));
|
||||
for (int y = 0; y < height; y++) {
|
||||
double t = height <= 1 ? 1.0 : y / (double) (height - 1);
|
||||
int x = offsetX + (int) Math.round(Math.cos(leanAngle) * leanDistance * t * t);
|
||||
@@ -383,11 +383,11 @@ public final class FormationShapeBuilder {
|
||||
}
|
||||
}
|
||||
|
||||
private static void ball(FormationCanvas canvas, IrisFormation f, int centerX, int centerY, int centerZ,
|
||||
private static void ball(FormationCanvas canvas, Formation f, int centerX, int centerY, int centerZ,
|
||||
double radius, boolean cap, long noiseSeed, RNG rng) {
|
||||
int extent = (int) Math.ceil(radius);
|
||||
double roughness = Math.max(0.0, Math.min(1.0, f.getRoughness()));
|
||||
double jitter = Math.max(0.0, Math.min(1.0, f.getJitter()));
|
||||
double roughness = Math.max(0.0, Math.min(1.0, f.roughness()));
|
||||
double jitter = Math.max(0.0, Math.min(1.0, f.jitter()));
|
||||
for (int x = -extent; x <= extent; x++) {
|
||||
for (int y = -extent; y <= extent; y++) {
|
||||
for (int z = -extent; z <= extent; z++) {
|
||||
|
||||
@@ -1,304 +0,0 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2022 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.engine.object.procedural.formation;
|
||||
|
||||
import art.arcane.iris.builtin.carve.CarvingMode;
|
||||
import art.arcane.iris.builtin.anchor.ObjectPlaceMode;
|
||||
import art.arcane.iris.builtin.stilt.StiltSettings;
|
||||
import art.arcane.iris.builtin.vacuum.VacuumSettings;
|
||||
import art.arcane.iris.builtin.validate.ObjectLimit;
|
||||
import art.arcane.iris.engine.object.material.IrisMaterialPalette;
|
||||
import art.arcane.iris.engine.object.placement.IrisObjectPlacement;
|
||||
import art.arcane.iris.engine.object.prefab.IrisObject;
|
||||
import art.arcane.iris.engine.object.prefab.IrisObjectRotation;
|
||||
import art.arcane.iris.engine.object.prefab.IrisObjectTranslate;
|
||||
import art.arcane.iris.engine.object.procedural.IrisProceduralPlacement;
|
||||
import art.arcane.iris.core.loader.IrisData;
|
||||
import art.arcane.iris.engine.data.cache.AtomicCache;
|
||||
import art.arcane.iris.engine.object.annotations.Desc;
|
||||
import art.arcane.iris.engine.object.annotations.MaxNumber;
|
||||
import art.arcane.iris.engine.object.annotations.MinNumber;
|
||||
import art.arcane.iris.engine.object.annotations.RegistryListBlockType;
|
||||
import art.arcane.iris.engine.object.annotations.Required;
|
||||
import art.arcane.iris.engine.object.annotations.Snippet;
|
||||
import art.arcane.iris.engine.object.procedural.formation.FormationGenerator;
|
||||
import art.arcane.volmlib.util.collection.KList;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
@Snippet("formation")
|
||||
@Accessors(chain = true)
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Desc("A single procedurally generated natural formation, including rock landmarks and magical glacial silhouettes. Iris bakes a pool of deterministic variants from these settings and scatters them at world-gen time, exactly like an object placement but generated from scratch instead of loaded from an iob file.")
|
||||
@Data
|
||||
public class IrisFormation implements IrisProceduralPlacement {
|
||||
private final transient AtomicCache<KList<IrisObject>> variantCache = new AtomicCache<>();
|
||||
|
||||
@Desc("A human readable name used in logs and as the variant load key.")
|
||||
private String name = "formation";
|
||||
|
||||
@MinNumber(0)
|
||||
@MaxNumber(1)
|
||||
@Desc("The chance per chunk for this formation to attempt placement. Use density for multiple per chunk.")
|
||||
private double chance = 0.02;
|
||||
|
||||
@MinNumber(1)
|
||||
@Desc("If the chance check passes, attempt this many placements in the chunk.")
|
||||
private int density = 1;
|
||||
|
||||
@MinNumber(1)
|
||||
@MaxNumber(64)
|
||||
@Desc("How many distinct variants to pre-bake for this formation. Higher means more variety at a small memory cost.")
|
||||
private int variants = 6;
|
||||
|
||||
@Desc("The base seed for deterministic generation. The same seed and settings always bake the same variants.")
|
||||
private long seed = 1337;
|
||||
|
||||
@Desc("The placement mode used to anchor the formation to the terrain.")
|
||||
private ObjectPlaceMode mode = ObjectPlaceMode.CENTER_HEIGHT;
|
||||
|
||||
@Desc("Rotate this formation's placement.")
|
||||
private IrisObjectRotation rotation = new IrisObjectRotation();
|
||||
|
||||
@Desc("Limit the max or min height of placement.")
|
||||
private ObjectLimit clamp = new ObjectLimit();
|
||||
|
||||
@Desc("Whether this formation may place on the terrain surface, under carvings, or both.")
|
||||
private CarvingMode carvingSupport = CarvingMode.SURFACE_ONLY;
|
||||
|
||||
@MinNumber(0)
|
||||
@MaxNumber(16)
|
||||
@Desc("Horizontal buffer, in blocks, beyond each lowest solid foundation block that must also be solid, un-carved ground.")
|
||||
private int surfaceSupportBuffer = 3;
|
||||
|
||||
@Desc("If true, the formation anchors on the terrain height ignoring the water surface.")
|
||||
private boolean underwater = false;
|
||||
|
||||
@Desc("Translate (offset) this placement along each axis; for example set a negative y to sink it into the ground.")
|
||||
private IrisObjectTranslate translate = new IrisObjectTranslate();
|
||||
|
||||
@Desc("Settings for the stilt place modes (STILT, MIN_STILT, FAST_STILT, CENTER_STILT, ERODE_STILT, ORGANIC_STILT).")
|
||||
private StiltSettings stiltSettings;
|
||||
|
||||
@Desc("Settings for the vacuum place modes (VACUUM, VACUUM_HIGH, VACUUM_FAST, VACUUM_ORGANIC).")
|
||||
private VacuumSettings vacuumSettings;
|
||||
|
||||
@Desc("The overall silhouette of the formation. Drives which sculpting routine the generator uses.")
|
||||
private IrisFormationForm form = IrisFormationForm.SPIRE;
|
||||
|
||||
@Required
|
||||
@Desc("The main rock block, e.g. minecraft:stone. Ignored when blockPalette is set.")
|
||||
@RegistryListBlockType
|
||||
private String block = "minecraft:stone";
|
||||
|
||||
@Desc("A noise-driven palette for the main rock body. When set this overrides the single block, letting the body mix blocks by noise.")
|
||||
private IrisMaterialPalette blockPalette = null;
|
||||
|
||||
@Desc("Optional caprock block placed on the top crown of the formation (and the wide overhanging cap for HOODOO). Ignored when capPalette is set. When null and capPalette is unset, the formation uses its main rock everywhere.")
|
||||
@RegistryListBlockType
|
||||
private String capBlock = null;
|
||||
|
||||
@Desc("A noise-driven palette for the caprock. When set this overrides the single capBlock.")
|
||||
private IrisMaterialPalette capPalette = null;
|
||||
|
||||
@Desc("Optional palette of strata (horizontal colored bands) blended into the rock body by y level. When set, every strataThickness blocks of height switches to the next strata block, producing the signature banded look. Falls back to the main block where unset.")
|
||||
private IrisMaterialPalette strataPalette = null;
|
||||
|
||||
@MinNumber(1)
|
||||
@MaxNumber(32)
|
||||
@Desc("The thickness in blocks of each horizontal strata band when strataPalette is set.")
|
||||
private int strataThickness = 3;
|
||||
|
||||
@MinNumber(1)
|
||||
@Desc("Minimum total height of the formation in blocks.")
|
||||
private int heightMin = 14;
|
||||
|
||||
@MinNumber(1)
|
||||
@Desc("Maximum total height of the formation in blocks.")
|
||||
private int heightMax = 26;
|
||||
|
||||
@MinNumber(1)
|
||||
@Desc("Minimum base radius (half-width) of the formation in blocks.")
|
||||
private int baseWidthMin = 3;
|
||||
|
||||
@MinNumber(1)
|
||||
@Desc("Maximum base radius (half-width) of the formation in blocks.")
|
||||
private int baseWidthMax = 6;
|
||||
|
||||
@MinNumber(0)
|
||||
@Desc("The target radius (half-width) at the very top of the formation in blocks, before the profile is applied. 0 means taper to a point.")
|
||||
private int topWidth = 0;
|
||||
|
||||
@Desc("The function used to shape the formation radius over its height.")
|
||||
private IrisFormationProfile profile = IrisFormationProfile.TAPER;
|
||||
|
||||
@MinNumber(0)
|
||||
@MaxNumber(1)
|
||||
@Desc("The normalized height (0 base, 1 top) of the pinched waist for the PARABOLIC profile (used by HOODOO).")
|
||||
private double profileWaist = 0.55;
|
||||
|
||||
@MinNumber(0)
|
||||
@MaxNumber(1)
|
||||
@Desc("The minimum radius fraction at the waist for the PARABOLIC profile. Lower values pinch the waist tighter.")
|
||||
private double profileWaistFloor = 0.35;
|
||||
|
||||
@MinNumber(0)
|
||||
@Desc("How far the formation leans, in degrees from vertical. 0 is perfectly upright. The whole body is sheared by this amount over its height.")
|
||||
private double lean = 0;
|
||||
|
||||
@Desc("Compass direction in degrees the formation leans toward when lean is non-zero.")
|
||||
private double leanAzimuth = 0;
|
||||
|
||||
@MinNumber(0)
|
||||
@MaxNumber(1)
|
||||
@Desc("Surface roughness from 0 (a clean smooth solid) to 1 (heavily eroded and pitted). Driven by 3D value noise that perturbs the radius so the formation never reads as a clean cylinder.")
|
||||
private double roughness = 0.3;
|
||||
|
||||
@MinNumber(0)
|
||||
@MaxNumber(1)
|
||||
@Desc("Per-block surface jitter from 0 (none) to 1 (maximum). Randomly carves and adds isolated edge blocks to break up the silhouette.")
|
||||
private double jitter = 0.15;
|
||||
|
||||
@MinNumber(0)
|
||||
@Desc("Extra wide cap radius in blocks added on top for the HOODOO form, producing the overhanging mushroom caprock. 0 disables the overhang.")
|
||||
private int hoodooCapRadius = 3;
|
||||
|
||||
@MinNumber(1)
|
||||
@MaxNumber(6)
|
||||
@Desc("The height in blocks of the HOODOO overhanging caprock slab.")
|
||||
private int hoodooCapHeight = 3;
|
||||
|
||||
@MinNumber(0)
|
||||
@Desc("How wide the ARCH opening is in blocks (the gap between the two legs). The arch span is rasterized over this width.")
|
||||
private int archSpan = 10;
|
||||
|
||||
@MinNumber(1)
|
||||
@Desc("The thickness in blocks of the ARCH legs and spanning curve.")
|
||||
private int archThickness = 3;
|
||||
|
||||
@MinNumber(0)
|
||||
@MaxNumber(1)
|
||||
@Desc("How strongly an ARCH varies its leg steepness, crown position, depth bow and tube width between deterministic variants. 0 is symmetric and 1 is highly organic.")
|
||||
private double archAsymmetry = 0.35;
|
||||
|
||||
@MinNumber(2)
|
||||
@MaxNumber(12)
|
||||
@Desc("How many separate columns make up a BASALT_COLUMN cluster. Each column gets a randomized height around the formation height range.")
|
||||
private int basaltColumns = 5;
|
||||
|
||||
@MinNumber(1)
|
||||
@Desc("The radius (half-width) in blocks of each individual column in a BASALT_COLUMN cluster.")
|
||||
private int basaltColumnRadius = 1;
|
||||
|
||||
@MinNumber(0)
|
||||
@MaxNumber(1)
|
||||
@Desc("How much the heights of individual BASALT_COLUMN columns vary from each other, from 0 (all equal) to 1 (highly varied).")
|
||||
private double basaltHeightVariance = 0.45;
|
||||
|
||||
@MinNumber(1)
|
||||
@MaxNumber(12)
|
||||
@Desc("How many tapered summits crown an ICEBERG formation.")
|
||||
private int icebergPeaks = 3;
|
||||
|
||||
@MinNumber(2)
|
||||
@MaxNumber(8)
|
||||
@Desc("How many separated shards form a FISSURE.")
|
||||
private int fractureCount = 3;
|
||||
|
||||
@MinNumber(1)
|
||||
@MaxNumber(16)
|
||||
@Desc("Open-air separation in blocks between the shards of a FISSURE.")
|
||||
private int fractureSeparation = 2;
|
||||
|
||||
@MinNumber(0.25)
|
||||
@MaxNumber(6)
|
||||
@Desc("How many complete turns a SPIRAL makes from base to tip.")
|
||||
private double spiralTurns = 1.5;
|
||||
|
||||
@MinNumber(1)
|
||||
@MaxNumber(32)
|
||||
@Desc("The starting distance in blocks between a SPIRAL and its open center.")
|
||||
private int spiralRadius = 4;
|
||||
|
||||
@MinNumber(1)
|
||||
@MaxNumber(8)
|
||||
@Desc("The radius in blocks of the tube swept along a SPIRAL.")
|
||||
private int spiralThickness = 2;
|
||||
|
||||
@MinNumber(1)
|
||||
@MaxNumber(32)
|
||||
@Desc("How far the hooked arm of an OVERHANG projects from its base.")
|
||||
private int overhangReach = 8;
|
||||
|
||||
@MinNumber(0)
|
||||
@MaxNumber(16)
|
||||
@Desc("How many blocks the tip of an OVERHANG curls downward.")
|
||||
private int overhangDrop = 3;
|
||||
|
||||
public KList<IrisObject> getVariantObjects(IrisData data) {
|
||||
return variantCache.aquire(() -> {
|
||||
KList<IrisObject> baked = new KList<>();
|
||||
int count = Math.max(1, variants);
|
||||
|
||||
for (int i = 0; i < count; i++) {
|
||||
IrisObject object = FormationGenerator.generate(this, i, new RNG(seed + (i * 7919L)), data);
|
||||
if (object == null || object.getBlocks().isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
object.setLoadKey("procedural/" + name + "#" + i);
|
||||
object.setLoader(data);
|
||||
baked.add(object);
|
||||
}
|
||||
|
||||
return baked;
|
||||
});
|
||||
}
|
||||
|
||||
public IrisObject getVariantObject(IrisData data, RNG rng) {
|
||||
KList<IrisObject> baked = getVariantObjects(data);
|
||||
if (baked == null || baked.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
return baked.get(rng.i(baked.size()));
|
||||
}
|
||||
|
||||
public IrisObjectPlacement asPlacement() {
|
||||
IrisObjectPlacement placement = new IrisObjectPlacement();
|
||||
placement.setMode(mode);
|
||||
placement.setRotation(rotation);
|
||||
placement.setClamp(clamp);
|
||||
placement.setCarvingSupport(carvingSupport);
|
||||
placement.setSurfaceSupportBuffer(surfaceSupportBuffer);
|
||||
placement.setUnderwater(underwater);
|
||||
placement.setTranslate(translate);
|
||||
placement.setStiltSettings(stiltSettings);
|
||||
placement.setVacuumSettings(vacuumSettings);
|
||||
placement.setChance(chance);
|
||||
placement.setDensity(density);
|
||||
return placement;
|
||||
}
|
||||
|
||||
public boolean isPlausible() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
-45
@@ -1,45 +0,0 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2022 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.engine.object.procedural.formation;
|
||||
|
||||
import art.arcane.iris.engine.object.annotations.Desc;
|
||||
|
||||
@Desc("The overall silhouette of a procedural natural formation. Each form drives a distinct sculpting routine in the formation generator.")
|
||||
public enum IrisFormationForm {
|
||||
@Desc("A tall, slender needle of rock that tapers smoothly to a point at the top (a sharp pinnacle or stone spire).")
|
||||
SPIRE,
|
||||
@Desc("A column with a pinched, eroded waist and a wide overhanging caprock balanced on top (the classic desert hoodoo / mushroom rock).")
|
||||
HOODOO,
|
||||
@Desc("Two stout legs joined by a spanning curved bridge of rock overhead (a natural stone arch).")
|
||||
ARCH,
|
||||
@Desc("A chunky, blocky stack that tapers gently as it rises, like an isolated pillar of rock standing in water (a sea stack).")
|
||||
SEA_STACK,
|
||||
@Desc("A rounded, lumpy boulder formed from a noise-perturbed ellipsoid that sits low on the terrain.")
|
||||
BOULDER,
|
||||
@Desc("A tightly packed cluster of several vertical, near-hexagonal columns of varying height (a basalt column formation / giant's causeway).")
|
||||
BASALT_COLUMN,
|
||||
@Desc("A broad, faceted mound crowned by several irregular tapered peaks, suitable for icebergs and glacial outcrops.")
|
||||
ICEBERG,
|
||||
@Desc("Several separated, outward-leaning shards divided by open cracks.")
|
||||
FISSURE,
|
||||
@Desc("A tapered tube swept around a tightening helix, leaving open air through its curled center.")
|
||||
SPIRAL,
|
||||
@Desc("A grounded pillar that bends into a long hooked cantilever and curls downward at its tip.")
|
||||
OVERHANG
|
||||
}
|
||||
-35
@@ -1,35 +0,0 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2022 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.engine.object.procedural.formation;
|
||||
|
||||
import art.arcane.iris.engine.object.annotations.Desc;
|
||||
|
||||
@Desc("A width-shaping function evaluated over normalized height (0 at the base, 1 at the top). Controls how the formation radius scales between baseWidth at the bottom and topWidth at the top.")
|
||||
public enum IrisFormationProfile {
|
||||
@Desc("Same radius at every height (a straight cylinder of constant baseWidth).")
|
||||
CONSTANT,
|
||||
@Desc("Radius ramps straight from baseWidth at the bottom to topWidth at the top.")
|
||||
LINEAR,
|
||||
@Desc("Radius shrinks smoothly toward a point as height increases (an ease that drives the SPIRE needle and gentle SEA_STACK taper).")
|
||||
TAPER,
|
||||
@Desc("Radius pinches to a narrow waist near profileWaist then widens again toward the top (the eroded waist used by HOODOO columns).")
|
||||
PARABOLIC,
|
||||
@Desc("Radius bulges out to its maximum in the middle of the height range and narrows at both ends (a barrel / bulged column).")
|
||||
BULGE
|
||||
}
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Servers
|
||||
* Copyright (c) 2026 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.engine.object.procedural.formation;
|
||||
|
||||
import art.arcane.iris.builtin.objects.formation.Formation;
|
||||
import art.arcane.iris.core.loader.IrisData;
|
||||
import art.arcane.iris.engine.object.placement.IrisObjectPlacement;
|
||||
import art.arcane.iris.engine.object.prefab.IrisObject;
|
||||
import art.arcane.iris.engine.object.procedural.ResolvedProceduralPlacement;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
|
||||
/** A rock formation made placeable: its variants are baked by {@link FormationGenerator}. */
|
||||
public final class ResolvedFormation extends ResolvedProceduralPlacement {
|
||||
private final Formation settings;
|
||||
|
||||
public ResolvedFormation(Formation settings) {
|
||||
super(new Shape(settings.name(), settings.chance(), settings.density(), settings.seed(), settings.variants(), settings.mode(),
|
||||
settings.rotation(), settings.clamp(), settings.carvingSupport(), settings.underwater(), settings.translate(),
|
||||
settings.stiltSettings().orElse(null), settings.vacuumSettings().orElse(null)));
|
||||
this.settings = settings;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void customize(IrisObjectPlacement placement) {
|
||||
placement.setSurfaceSupportBuffer(settings.surfaceSupportBuffer());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected IrisObject generate(int index, RNG rng, IrisData data) {
|
||||
return FormationGenerator.generate(settings, index, rng, data);
|
||||
}
|
||||
}
|
||||
+18
-16
@@ -18,8 +18,10 @@
|
||||
|
||||
package art.arcane.iris.engine.object.procedural.fungi;
|
||||
|
||||
import art.arcane.iris.engine.object.procedural.fungi.IrisFungus;
|
||||
import art.arcane.iris.engine.object.procedural.fungi.IrisFungusCapShape;
|
||||
import com.volmit.block.PaletteSpec;
|
||||
import java.util.Optional;
|
||||
import art.arcane.iris.builtin.objects.fungi.FungusCapShape;
|
||||
import art.arcane.iris.builtin.objects.fungi.Fungus;
|
||||
import art.arcane.iris.engine.object.material.IrisMaterialPalette;
|
||||
import art.arcane.iris.engine.object.procedural.IrisProceduralBlocks;
|
||||
import art.arcane.iris.engine.object.procedural.tree.TreeFunctions;
|
||||
@@ -31,17 +33,17 @@ public final class FungusCapBuilder {
|
||||
private FungusCapBuilder() {
|
||||
}
|
||||
|
||||
public static void build(Map<Vector3i, FungusCellRole> roles, IrisFungus fungus, int baseRadius, double cx, int baseY, double cz, long seed) {
|
||||
int radius = (int) Math.round(baseRadius + Math.max(0.0, fungus.getCapOverhang()));
|
||||
int thickness = Math.max(1, Math.min(3, fungus.getCapThickness()));
|
||||
double squish = Math.max(0.0, Math.min(1.0, fungus.getCapSquish()));
|
||||
double droop = Math.max(0.0, fungus.getCapDroop());
|
||||
IrisFungusCapShape shape = fungus.getCapShape() == null ? IrisFungusCapShape.DOME : fungus.getCapShape();
|
||||
public static void build(Map<Vector3i, FungusCellRole> roles, Fungus fungus, int baseRadius, double cx, int baseY, double cz, long seed) {
|
||||
int radius = (int) Math.round(baseRadius + Math.max(0.0, fungus.capOverhang()));
|
||||
int thickness = Math.max(1, Math.min(3, fungus.capThickness()));
|
||||
double squish = Math.max(0.0, Math.min(1.0, fungus.capSquish()));
|
||||
double droop = Math.max(0.0, fungus.capDroop());
|
||||
FungusCapShape shape = fungus.capShape() == null ? FungusCapShape.DOME : fungus.capShape();
|
||||
int icx = (int) Math.round(cx);
|
||||
int icz = (int) Math.round(cz);
|
||||
|
||||
boolean hasGill = blockOrPaletteSet(fungus.getGillBlock(), fungus.getGillPalette());
|
||||
boolean hasSpot = blockOrPaletteSet(fungus.getSpotBlock(), fungus.getSpotPalette());
|
||||
boolean hasGill = blockOrPaletteSet(fungus.gillBlock(), fungus.gillPalette());
|
||||
boolean hasSpot = blockOrPaletteSet(fungus.spotBlock(), fungus.spotPalette());
|
||||
|
||||
double apexRise = apexRise(shape, radius) * (1.0 - 0.6 * squish);
|
||||
double droopReach = Math.tan(Math.toRadians(droop)) * radius;
|
||||
@@ -68,9 +70,9 @@ public final class FungusCapBuilder {
|
||||
boolean underside = layer == thickness - 1;
|
||||
boolean topFace = layer == 0;
|
||||
|
||||
if (underside && hasGill && rollNoise(icx + dx, y, icz + dz, seed + 4111L) <= fungus.getGillChance()) {
|
||||
if (underside && hasGill && rollNoise(icx + dx, y, icz + dz, seed + 4111L) <= fungus.gillChance()) {
|
||||
role = FungusCellRole.GILL;
|
||||
} else if (topFace && hasSpot && spotNoise(icx + dx, y, icz + dz, seed + 9311L) <= fungus.getSpotChance()) {
|
||||
} else if (topFace && hasSpot && spotNoise(icx + dx, y, icz + dz, seed + 9311L) <= fungus.spotChance()) {
|
||||
role = FungusCellRole.SPOT;
|
||||
}
|
||||
|
||||
@@ -80,7 +82,7 @@ public final class FungusCapBuilder {
|
||||
}
|
||||
}
|
||||
|
||||
private static double apexRise(IrisFungusCapShape shape, int radius) {
|
||||
private static double apexRise(FungusCapShape shape, int radius) {
|
||||
return switch (shape) {
|
||||
case DOME -> radius * 0.85;
|
||||
case CONICAL -> radius * 1.4;
|
||||
@@ -90,7 +92,7 @@ public final class FungusCapBuilder {
|
||||
};
|
||||
}
|
||||
|
||||
private static double capSurface(IrisFungusCapShape shape, double normalized, double apexRise) {
|
||||
private static double capSurface(FungusCapShape shape, double normalized, double apexRise) {
|
||||
double n = Math.max(0.0, Math.min(1.0, normalized));
|
||||
return switch (shape) {
|
||||
case DOME -> apexRise * Math.sqrt(Math.max(0.0, 1.0 - n * n));
|
||||
@@ -109,10 +111,10 @@ public final class FungusCapBuilder {
|
||||
return TreeFunctions.valueNoise3D(Math.floorDiv(x, 2), y, Math.floorDiv(z, 2), seed);
|
||||
}
|
||||
|
||||
static boolean blockOrPaletteSet(String block, IrisMaterialPalette palette) {
|
||||
static boolean blockOrPaletteSet(Optional<String> block, Optional<PaletteSpec> palette) {
|
||||
if (IrisProceduralBlocks.paletteSet(palette)) {
|
||||
return true;
|
||||
}
|
||||
return block != null && !block.isEmpty();
|
||||
return block.filter(name -> !name.isEmpty()).isPresent();
|
||||
}
|
||||
}
|
||||
@@ -18,8 +18,8 @@
|
||||
|
||||
package art.arcane.iris.engine.object.procedural.fungi;
|
||||
|
||||
import art.arcane.iris.builtin.objects.fungi.Fungus;
|
||||
import art.arcane.iris.core.loader.IrisData;
|
||||
import art.arcane.iris.engine.object.procedural.fungi.IrisFungus;
|
||||
import art.arcane.iris.engine.object.prefab.IrisObject;
|
||||
import art.arcane.iris.engine.object.procedural.IrisProceduralBlocks;
|
||||
import art.arcane.iris.spi.PlatformBlockState;
|
||||
@@ -33,11 +33,11 @@ public final class FungusGenerator {
|
||||
private FungusGenerator() {
|
||||
}
|
||||
|
||||
public static IrisObject generate(IrisFungus fungus, int height, RNG rng, IrisData data) {
|
||||
public static IrisObject generate(Fungus fungus, int height, RNG rng, IrisData data) {
|
||||
Map<Vector3i, FungusCellRole> roles = new HashMap<>();
|
||||
long baseSeed = rng.getSeed();
|
||||
|
||||
if (fungus.isShelf()) {
|
||||
if (fungus.shelf()) {
|
||||
FungusShelfBuilder.build(roles, fungus, rng, baseSeed);
|
||||
} else {
|
||||
buildUpright(roles, fungus, height, rng, baseSeed);
|
||||
@@ -47,7 +47,7 @@ public final class FungusGenerator {
|
||||
return null;
|
||||
}
|
||||
|
||||
RNG paletteRng = new RNG(fungus.getSeed());
|
||||
RNG paletteRng = new RNG(fungus.seed());
|
||||
Map<Vector3i, PlatformBlockState> resolved = new HashMap<>();
|
||||
for (Map.Entry<Vector3i, FungusCellRole> entry : roles.entrySet()) {
|
||||
Vector3i pos = entry.getKey();
|
||||
@@ -61,7 +61,7 @@ public final class FungusGenerator {
|
||||
return IrisProceduralBlocks.assemble(resolved);
|
||||
}
|
||||
|
||||
private static void buildUpright(Map<Vector3i, FungusCellRole> roles, IrisFungus fungus, int height, RNG rng, long baseSeed) {
|
||||
private static void buildUpright(Map<Vector3i, FungusCellRole> roles, Fungus fungus, int height, RNG rng, long baseSeed) {
|
||||
int stemHeight = Math.max(1, height);
|
||||
Map<Vector3i, PlatformBlockState> stemCells = new HashMap<>();
|
||||
double[] top = FungusStemBuilder.build(stemCells, fungus, stemHeight, baseSeed);
|
||||
@@ -76,28 +76,28 @@ public final class FungusGenerator {
|
||||
FungusCapBuilder.build(roles, fungus, radius, cx, capBaseY, cz, baseSeed + 5557L);
|
||||
}
|
||||
|
||||
private static int pickRadius(IrisFungus fungus, RNG rng) {
|
||||
int lo = Math.min(fungus.getCapRadiusMin(), fungus.getCapRadiusMax());
|
||||
int hi = Math.max(fungus.getCapRadiusMin(), fungus.getCapRadiusMax());
|
||||
private static int pickRadius(Fungus fungus, RNG rng) {
|
||||
int lo = Math.min(fungus.capRadiusMin(), fungus.capRadiusMax());
|
||||
int hi = Math.max(fungus.capRadiusMin(), fungus.capRadiusMax());
|
||||
lo = Math.max(1, lo);
|
||||
hi = Math.max(lo, hi);
|
||||
return rng.i(lo, hi + 1);
|
||||
}
|
||||
|
||||
private static PlatformBlockState resolveRole(IrisFungus fungus, FungusCellRole role, IrisData data, Vector3i pos, RNG paletteRng) {
|
||||
private static PlatformBlockState resolveRole(Fungus fungus, FungusCellRole role, IrisData data, Vector3i pos, RNG paletteRng) {
|
||||
int x = pos.getBlockX();
|
||||
int y = pos.getBlockY();
|
||||
int z = pos.getBlockZ();
|
||||
return switch (role) {
|
||||
case STEM -> IrisProceduralBlocks.resolve(fungus.getStem(), fungus.getStemPalette(), data, x, y, z, paletteRng);
|
||||
case CAP -> IrisProceduralBlocks.resolve(fungus.getCap(), fungus.getCapPalette(), data, x, y, z, paletteRng);
|
||||
case STEM -> IrisProceduralBlocks.resolve(fungus.stem(), fungus.stemPalette(), data, x, y, z, paletteRng);
|
||||
case CAP -> IrisProceduralBlocks.resolve(fungus.cap(), fungus.capPalette(), data, x, y, z, paletteRng);
|
||||
case GILL -> {
|
||||
PlatformBlockState gill = IrisProceduralBlocks.resolve(fungus.getGillBlock(), fungus.getGillPalette(), data, x, y, z, paletteRng);
|
||||
yield gill != null ? gill : IrisProceduralBlocks.resolve(fungus.getCap(), fungus.getCapPalette(), data, x, y, z, paletteRng);
|
||||
PlatformBlockState gill = IrisProceduralBlocks.resolve(fungus.gillBlock(), fungus.gillPalette(), data, x, y, z, paletteRng);
|
||||
yield gill != null ? gill : IrisProceduralBlocks.resolve(fungus.cap(), fungus.capPalette(), data, x, y, z, paletteRng);
|
||||
}
|
||||
case SPOT -> {
|
||||
PlatformBlockState spot = IrisProceduralBlocks.resolve(fungus.getSpotBlock(), fungus.getSpotPalette(), data, x, y, z, paletteRng);
|
||||
yield spot != null ? spot : IrisProceduralBlocks.resolve(fungus.getCap(), fungus.getCapPalette(), data, x, y, z, paletteRng);
|
||||
PlatformBlockState spot = IrisProceduralBlocks.resolve(fungus.spotBlock(), fungus.spotPalette(), data, x, y, z, paletteRng);
|
||||
yield spot != null ? spot : IrisProceduralBlocks.resolve(fungus.cap(), fungus.capPalette(), data, x, y, z, paletteRng);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
+8
-8
@@ -18,7 +18,7 @@
|
||||
|
||||
package art.arcane.iris.engine.object.procedural.fungi;
|
||||
|
||||
import art.arcane.iris.engine.object.procedural.fungi.IrisFungus;
|
||||
import art.arcane.iris.builtin.objects.fungi.Fungus;
|
||||
import art.arcane.iris.engine.object.procedural.tree.TreeFunctions;
|
||||
import art.arcane.iris.util.common.math.Vector3i;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
@@ -29,20 +29,20 @@ public final class FungusShelfBuilder {
|
||||
private FungusShelfBuilder() {
|
||||
}
|
||||
|
||||
public static void build(Map<Vector3i, FungusCellRole> roles, IrisFungus fungus, RNG rng, long seed) {
|
||||
int radius = Math.max(1, fungus.getShelfRadius());
|
||||
public static void build(Map<Vector3i, FungusCellRole> roles, Fungus fungus, RNG rng, long seed) {
|
||||
int radius = Math.max(1, fungus.shelfRadius());
|
||||
double azimuth = rng.d(0.0, Math.PI * 2.0);
|
||||
double fanX = Math.sin(azimuth);
|
||||
double fanZ = Math.cos(azimuth);
|
||||
int stubHeight = Math.max(0, Math.min(2, fungus.getStemWidth()));
|
||||
int stubHeight = Math.max(0, Math.min(2, fungus.stemWidth()));
|
||||
|
||||
for (int y = 0; y < stubHeight; y++) {
|
||||
roles.put(new Vector3i(0, y, 0), FungusCellRole.STEM);
|
||||
}
|
||||
|
||||
int fanY = stubHeight;
|
||||
boolean hasGill = FungusCapBuilder.blockOrPaletteSet(fungus.getGillBlock(), fungus.getGillPalette());
|
||||
boolean hasSpot = FungusCapBuilder.blockOrPaletteSet(fungus.getSpotBlock(), fungus.getSpotPalette());
|
||||
boolean hasGill = FungusCapBuilder.blockOrPaletteSet(fungus.gillBlock(), fungus.gillPalette());
|
||||
boolean hasSpot = FungusCapBuilder.blockOrPaletteSet(fungus.spotBlock(), fungus.spotPalette());
|
||||
|
||||
for (int dx = -radius; dx <= radius; dx++) {
|
||||
for (int dz = -radius; dz <= radius; dz++) {
|
||||
@@ -59,12 +59,12 @@ public final class FungusShelfBuilder {
|
||||
int y = fanY + lift;
|
||||
|
||||
FungusCellRole role = FungusCellRole.CAP;
|
||||
if (hasSpot && spotNoise(dx, y, dz, seed + 9311L) <= fungus.getSpotChance()) {
|
||||
if (hasSpot && spotNoise(dx, y, dz, seed + 9311L) <= fungus.spotChance()) {
|
||||
role = FungusCellRole.SPOT;
|
||||
}
|
||||
roles.putIfAbsent(new Vector3i(dx, y, dz), role);
|
||||
|
||||
if (hasGill && rollNoise(dx, y - 1, dz, seed + 4111L) <= fungus.getGillChance()) {
|
||||
if (hasGill && rollNoise(dx, y - 1, dz, seed + 4111L) <= fungus.gillChance()) {
|
||||
roles.putIfAbsent(new Vector3i(dx, y - 1, dz), FungusCellRole.GILL);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
|
||||
package art.arcane.iris.engine.object.procedural.fungi;
|
||||
|
||||
import art.arcane.iris.engine.object.procedural.fungi.IrisFungus;
|
||||
import art.arcane.iris.builtin.objects.fungi.Fungus;
|
||||
import art.arcane.iris.engine.object.procedural.tree.TreeFunctions;
|
||||
import art.arcane.iris.spi.PlatformBlockState;
|
||||
import art.arcane.iris.util.common.math.Vector3i;
|
||||
@@ -29,15 +29,15 @@ public final class FungusStemBuilder {
|
||||
private FungusStemBuilder() {
|
||||
}
|
||||
|
||||
public static double[] build(Map<Vector3i, PlatformBlockState> stemCells, IrisFungus fungus, int stemHeight, long seed) {
|
||||
int width = Math.max(1, Math.min(3, fungus.getStemWidth()));
|
||||
double maxLean = stemHeight * Math.tan(Math.toRadians(Math.max(0.0, fungus.getStemCurve())));
|
||||
double leanRad = Math.toRadians(fungus.getStemLeanAzimuth());
|
||||
public static double[] build(Map<Vector3i, PlatformBlockState> stemCells, Fungus fungus, int stemHeight, long seed) {
|
||||
int width = Math.max(1, Math.min(3, fungus.stemWidth()));
|
||||
double maxLean = stemHeight * Math.tan(Math.toRadians(Math.max(0.0, fungus.stemCurve())));
|
||||
double leanRad = Math.toRadians(fungus.stemLeanAzimuth());
|
||||
double leanX = Math.sin(leanRad);
|
||||
double leanZ = Math.cos(leanRad);
|
||||
double waveAmp = Math.max(0.0, fungus.getStemWaveAmplitude());
|
||||
double wavePeriods = fungus.getStemWavePeriods() == 0 ? 1.0 : fungus.getStemWavePeriods();
|
||||
double waveAzimuth = Math.toRadians(fungus.getStemLeanAzimuth() + 90.0);
|
||||
double waveAmp = Math.max(0.0, fungus.stemWaveAmplitude());
|
||||
double wavePeriods = fungus.stemWavePeriods() == 0 ? 1.0 : fungus.stemWavePeriods();
|
||||
double waveAzimuth = Math.toRadians(fungus.stemLeanAzimuth() + 90.0);
|
||||
double waveX = Math.sin(waveAzimuth);
|
||||
double waveZ = Math.cos(waveAzimuth);
|
||||
|
||||
|
||||
@@ -1,262 +0,0 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2022 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.engine.object.procedural.fungi;
|
||||
|
||||
import art.arcane.iris.builtin.carve.CarvingMode;
|
||||
import art.arcane.iris.builtin.anchor.ObjectPlaceMode;
|
||||
import art.arcane.iris.builtin.stilt.StiltSettings;
|
||||
import art.arcane.iris.builtin.vacuum.VacuumSettings;
|
||||
import art.arcane.iris.builtin.validate.ObjectLimit;
|
||||
import art.arcane.iris.engine.object.material.IrisMaterialPalette;
|
||||
import art.arcane.iris.engine.object.placement.IrisObjectPlacement;
|
||||
import art.arcane.iris.engine.object.prefab.IrisObject;
|
||||
import art.arcane.iris.engine.object.prefab.IrisObjectRotation;
|
||||
import art.arcane.iris.engine.object.prefab.IrisObjectTranslate;
|
||||
import art.arcane.iris.engine.object.procedural.IrisProceduralPlacement;
|
||||
import art.arcane.iris.core.loader.IrisData;
|
||||
import art.arcane.iris.engine.data.cache.AtomicCache;
|
||||
import art.arcane.iris.engine.object.annotations.Desc;
|
||||
import art.arcane.iris.engine.object.annotations.MaxNumber;
|
||||
import art.arcane.iris.engine.object.annotations.MinNumber;
|
||||
import art.arcane.iris.engine.object.annotations.RegistryListBlockType;
|
||||
import art.arcane.iris.engine.object.annotations.Required;
|
||||
import art.arcane.iris.engine.object.annotations.Snippet;
|
||||
import art.arcane.iris.engine.object.procedural.fungi.FungusGenerator;
|
||||
import art.arcane.volmlib.util.collection.KList;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
@Snippet("fungus")
|
||||
@Accessors(chain = true)
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Desc("A single procedurally generated fungus (giant mushroom or shelf fungus). Iris bakes a pool of deterministic variants from these settings and scatters them at world-gen time, exactly like an object placement but generated from scratch instead of loaded from an iob file. The fungus is built as a stem column with a cap dome grown on top, mirroring the trunk-and-canopy model used by procedural trees.")
|
||||
@Data
|
||||
public class IrisFungus implements IrisProceduralPlacement {
|
||||
private final transient AtomicCache<KList<IrisObject>> variantCache = new AtomicCache<>();
|
||||
|
||||
@Desc("A human readable name used in logs and as the variant load key.")
|
||||
private String name = "fungus";
|
||||
|
||||
@MinNumber(0)
|
||||
@MaxNumber(1)
|
||||
@Desc("The chance per chunk for this fungus to attempt placement. Use density for multiple per chunk.")
|
||||
private double chance = 0.4;
|
||||
|
||||
@MinNumber(1)
|
||||
@Desc("If the chance check passes, attempt this many placements in the chunk.")
|
||||
private int density = 1;
|
||||
|
||||
@MinNumber(1)
|
||||
@MaxNumber(64)
|
||||
@Desc("How many distinct variants to pre-bake for this fungus. Higher means more variety at a small memory cost.")
|
||||
private int variants = 6;
|
||||
|
||||
@Desc("The base seed for deterministic generation. The same seed and settings always bake the same variants.")
|
||||
private long seed = 1337;
|
||||
|
||||
@Desc("The placement mode used to anchor the fungus to the terrain.")
|
||||
private ObjectPlaceMode mode = ObjectPlaceMode.CENTER_HEIGHT;
|
||||
|
||||
@Desc("Rotate this fungus's placement.")
|
||||
private IrisObjectRotation rotation = new IrisObjectRotation();
|
||||
|
||||
@Desc("Limit the max or min height of placement.")
|
||||
private ObjectLimit clamp = new ObjectLimit();
|
||||
|
||||
@Desc("Whether this fungus may place on the terrain surface, under carvings, or both.")
|
||||
private CarvingMode carvingSupport = CarvingMode.SURFACE_ONLY;
|
||||
|
||||
@Desc("If true, the fungus anchors on the terrain height ignoring the water surface.")
|
||||
private boolean underwater = false;
|
||||
|
||||
@Desc("Translate (offset) this placement along each axis; for example set a negative y to sink it into the ground.")
|
||||
private IrisObjectTranslate translate = new IrisObjectTranslate();
|
||||
|
||||
@Desc("Settings for the stilt place modes (STILT, MIN_STILT, FAST_STILT, CENTER_STILT, ERODE_STILT, ORGANIC_STILT).")
|
||||
private StiltSettings stiltSettings;
|
||||
|
||||
@Desc("Settings for the vacuum place modes (VACUUM, VACUUM_HIGH, VACUUM_FAST, VACUUM_ORGANIC).")
|
||||
private VacuumSettings vacuumSettings;
|
||||
|
||||
@Required
|
||||
@Desc("The stem block, e.g. minecraft:mushroom_stem. Ignored when stemPalette is set.")
|
||||
@RegistryListBlockType
|
||||
private String stem = "minecraft:mushroom_stem";
|
||||
|
||||
@Desc("A noise-driven palette for the stem. When set this overrides the single stem block, letting the stem mix blocks by noise.")
|
||||
private IrisMaterialPalette stemPalette = null;
|
||||
|
||||
@Required
|
||||
@Desc("The cap block, e.g. minecraft:red_mushroom_block. Ignored when capPalette is set.")
|
||||
@RegistryListBlockType
|
||||
private String cap = "minecraft:red_mushroom_block";
|
||||
|
||||
@Desc("A noise-driven palette for the cap. When set this overrides the single cap block, letting the cap mix blocks by noise.")
|
||||
private IrisMaterialPalette capPalette = null;
|
||||
|
||||
@MinNumber(1)
|
||||
@Desc("Minimum total stem height in blocks. Variants spread between this and stemHeightMax.")
|
||||
private int stemHeightMin = 5;
|
||||
|
||||
@MinNumber(1)
|
||||
@Desc("Maximum total stem height in blocks. Variants spread between stemHeightMin and this.")
|
||||
private int stemHeightMax = 9;
|
||||
|
||||
@MinNumber(1)
|
||||
@MaxNumber(3)
|
||||
@Desc("Base stem width in blocks. 1 is a single column, 2 is a 2x2 stem, 3 is a chunky 3x3 trunk.")
|
||||
private int stemWidth = 1;
|
||||
|
||||
@Desc("How far the stem leans away from vertical, in degrees. 0 is perfectly upright; small values give an organic tilt.")
|
||||
private double stemCurve = 0;
|
||||
|
||||
@Desc("Compass direction in degrees the stem leans toward when stemCurve is non-zero.")
|
||||
private double stemLeanAzimuth = 0;
|
||||
|
||||
@MinNumber(0)
|
||||
@Desc("Amplitude in blocks of a gentle sideways wave applied up the stem so it is not a perfectly straight ruler.")
|
||||
private double stemWaveAmplitude = 0.4;
|
||||
|
||||
@MinNumber(0.0001)
|
||||
@Desc("The number of full sine wobbles applied over the stem height for the stem wave.")
|
||||
private double stemWavePeriods = 1;
|
||||
|
||||
@Desc("The silhouette of the cap (dome, flat umbrella, funnel, cone, or wide shallow slab).")
|
||||
private IrisFungusCapShape capShape = IrisFungusCapShape.DOME;
|
||||
|
||||
@MinNumber(1)
|
||||
@Desc("Minimum cap radius in blocks (measured from the cap center to its rim).")
|
||||
private int capRadiusMin = 3;
|
||||
|
||||
@MinNumber(1)
|
||||
@Desc("Maximum cap radius in blocks (measured from the cap center to its rim).")
|
||||
private int capRadiusMax = 5;
|
||||
|
||||
@MinNumber(1)
|
||||
@MaxNumber(3)
|
||||
@Desc("How many blocks thick the cap shell is. 1 is a thin skin, 3 is a fleshy slab.")
|
||||
private int capThickness = 1;
|
||||
|
||||
@MinNumber(0)
|
||||
@MaxNumber(1)
|
||||
@Desc("Vertical flatten factor for the cap. 0 leaves the cap at full height, 1 squashes it flat into a disc.")
|
||||
private double capSquish = 0.4;
|
||||
|
||||
@MinNumber(0)
|
||||
@Desc("How far the cap rim droops downward, in degrees, curling the edge of the cap toward the ground.")
|
||||
private double capDroop = 20;
|
||||
|
||||
@MinNumber(0)
|
||||
@Desc("How far the cap radius extends past the stem before the rim begins, in blocks. Larger values make the cap overhang the stem more.")
|
||||
private double capOverhang = 2;
|
||||
|
||||
@Desc("Optional block forming the gill layer on the underside of the cap (gills or a glow layer), e.g. minecraft:brown_mushroom_block or minecraft:shroomlight. Ignored when gillPalette is set or left null.")
|
||||
@RegistryListBlockType
|
||||
private String gillBlock = null;
|
||||
|
||||
@Desc("A noise-driven palette for the underside gill layer. When set this overrides the single gillBlock.")
|
||||
private IrisMaterialPalette gillPalette = null;
|
||||
|
||||
@MinNumber(0)
|
||||
@MaxNumber(1)
|
||||
@Desc("The fraction of underside cap blocks replaced by the gill block when a gill block or palette is set.")
|
||||
private double gillChance = 0.85;
|
||||
|
||||
@Desc("Optional block speckled across the top of the cap by noise (white toadstool dots, warts, glowing spots), e.g. minecraft:bone_block or minecraft:white_concrete. Ignored when spotPalette is set or left null.")
|
||||
@RegistryListBlockType
|
||||
private String spotBlock = null;
|
||||
|
||||
@Desc("A noise-driven palette for the cap top spots. When set this overrides the single spotBlock.")
|
||||
private IrisMaterialPalette spotPalette = null;
|
||||
|
||||
@MinNumber(0)
|
||||
@MaxNumber(1)
|
||||
@Desc("The fraction of top cap blocks replaced by the spot block, selected by value noise so spots cluster naturally.")
|
||||
private double spotChance = 0.18;
|
||||
|
||||
@Desc("If true, generate a bracket / shelf fungus instead of an upright mushroom: a small flat fan that grows sideways off a very short or absent stem, like a polypore clinging to a trunk.")
|
||||
private boolean shelf = false;
|
||||
|
||||
@MinNumber(1)
|
||||
@Desc("The radius in blocks of the sideways fan when shelf is true.")
|
||||
private int shelfRadius = 3;
|
||||
|
||||
public KList<IrisObject> getVariantObjects(IrisData data) {
|
||||
return variantCache.aquire(() -> {
|
||||
KList<IrisObject> baked = new KList<>();
|
||||
int count = Math.max(1, variants);
|
||||
int lo = Math.min(stemHeightMin, stemHeightMax);
|
||||
int hi = Math.max(stemHeightMin, stemHeightMax);
|
||||
RNG heightRng = new RNG(seed);
|
||||
|
||||
for (int i = 0; i < count; i++) {
|
||||
int height;
|
||||
if (count == 1 || lo == hi) {
|
||||
height = heightRng.i(lo, hi + 1);
|
||||
} else {
|
||||
double step = (hi - lo) / (double) (count - 1);
|
||||
double base = lo + step * i;
|
||||
double jitter = heightRng.d(-step * 0.3, step * 0.3);
|
||||
height = (int) Math.round(Math.max(lo, Math.min(hi, base + jitter)));
|
||||
}
|
||||
|
||||
IrisObject object = FungusGenerator.generate(this, Math.max(1, height), new RNG(seed + (i * 7919L)), data);
|
||||
if (object == null || object.getBlocks().isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
object.setLoadKey("procedural/" + name + "#" + i);
|
||||
object.setLoader(data);
|
||||
baked.add(object);
|
||||
}
|
||||
|
||||
return baked;
|
||||
});
|
||||
}
|
||||
|
||||
public IrisObject getVariantObject(IrisData data, RNG rng) {
|
||||
KList<IrisObject> baked = getVariantObjects(data);
|
||||
if (baked == null || baked.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
return baked.get(rng.i(baked.size()));
|
||||
}
|
||||
|
||||
public IrisObjectPlacement asPlacement() {
|
||||
IrisObjectPlacement placement = new IrisObjectPlacement();
|
||||
placement.setMode(mode);
|
||||
placement.setRotation(rotation);
|
||||
placement.setClamp(clamp);
|
||||
placement.setCarvingSupport(carvingSupport);
|
||||
placement.setUnderwater(underwater);
|
||||
placement.setTranslate(translate);
|
||||
placement.setStiltSettings(stiltSettings);
|
||||
placement.setVacuumSettings(vacuumSettings);
|
||||
placement.setChance(chance);
|
||||
placement.setDensity(density);
|
||||
return placement;
|
||||
}
|
||||
|
||||
public boolean isPlausible() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2022 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.engine.object.procedural.fungi;
|
||||
|
||||
import art.arcane.iris.engine.object.annotations.Desc;
|
||||
|
||||
@Desc("The silhouette of the mushroom cap. Each shape drives how the cap radius and thickness vary from its apex down to the rim, giving the fungus a distinct profile.")
|
||||
public enum IrisFungusCapShape {
|
||||
@Desc("A rounded hemisphere cap that bulges up and curls slightly under at the rim, the classic red toadstool dome.")
|
||||
DOME,
|
||||
@Desc("A wide, nearly flat umbrella that holds its full radius almost to the edge before dropping, the brown-mushroom plate look.")
|
||||
FLAT,
|
||||
@Desc("An upturned bowl whose rim lifts higher than its center, cupping upward like a chanterelle or funnel mushroom.")
|
||||
FUNNEL,
|
||||
@Desc("A tall pointed cone that tapers from a broad base to a sharp apex, the witch-hat parasol silhouette.")
|
||||
CONICAL,
|
||||
@Desc("A very wide but shallow slab, a low overhanging shelf-like roof that spreads far past the stem with minimal vertical rise.")
|
||||
FLAT_WIDE
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Servers
|
||||
* Copyright (c) 2026 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.engine.object.procedural.fungi;
|
||||
|
||||
import art.arcane.iris.builtin.objects.fungi.Fungus;
|
||||
import art.arcane.iris.core.loader.IrisData;
|
||||
import art.arcane.iris.engine.object.prefab.IrisObject;
|
||||
import art.arcane.iris.engine.object.procedural.ResolvedProceduralPlacement;
|
||||
import art.arcane.volmlib.util.collection.KList;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
|
||||
/** A fungus made placeable: its variants are baked by {@link FungusGenerator}. */
|
||||
public final class ResolvedFungus extends ResolvedProceduralPlacement {
|
||||
private final Fungus settings;
|
||||
|
||||
public ResolvedFungus(Fungus settings) {
|
||||
super(new Shape(settings.name(), settings.chance(), settings.density(), settings.seed(), settings.variants(), settings.mode(),
|
||||
settings.rotation(), settings.clamp(), settings.carvingSupport(), settings.underwater(), settings.translate(),
|
||||
settings.stiltSettings().orElse(null), settings.vacuumSettings().orElse(null)));
|
||||
this.settings = settings;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected IrisObject generate(int index, RNG rng, IrisData data) {
|
||||
throw new UnsupportedOperationException("A fungus bakes its variants itself, from the stem heights");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected KList<IrisObject> bake(IrisData data) {
|
||||
KList<IrisObject> baked = new KList<>();
|
||||
int count = variantCount();
|
||||
int lo = Math.min(settings.stemHeightMin(), settings.stemHeightMax());
|
||||
int hi = Math.max(settings.stemHeightMin(), settings.stemHeightMax());
|
||||
RNG heightRng = new RNG(seed());
|
||||
|
||||
for (int i = 0; i < count; i++) {
|
||||
int height;
|
||||
if (count == 1 || lo == hi) {
|
||||
height = heightRng.i(lo, hi + 1);
|
||||
} else {
|
||||
double step = (hi - lo) / (double) (count - 1);
|
||||
double base = lo + step * i;
|
||||
double jitter = heightRng.d(-step * 0.3, step * 0.3);
|
||||
height = (int) Math.round(Math.max(lo, Math.min(hi, base + jitter)));
|
||||
}
|
||||
|
||||
IrisObject object = FungusGenerator.generate(settings, Math.max(1, height), variantRng(i), data);
|
||||
if (object == null || object.getBlocks().isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
object.setLoadKey("procedural/" + getName() + "#" + i);
|
||||
object.setLoader(data);
|
||||
baked.add(object);
|
||||
}
|
||||
|
||||
return baked;
|
||||
}
|
||||
}
|
||||
@@ -1,219 +0,0 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2022 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.engine.object.procedural.ruin;
|
||||
|
||||
import art.arcane.iris.builtin.carve.CarvingMode;
|
||||
import art.arcane.iris.builtin.anchor.ObjectPlaceMode;
|
||||
import art.arcane.iris.builtin.stilt.StiltSettings;
|
||||
import art.arcane.iris.builtin.vacuum.VacuumSettings;
|
||||
import art.arcane.iris.builtin.validate.ObjectLimit;
|
||||
import art.arcane.iris.engine.object.material.IrisMaterialPalette;
|
||||
import art.arcane.iris.engine.object.placement.IrisObjectPlacement;
|
||||
import art.arcane.iris.engine.object.prefab.IrisObject;
|
||||
import art.arcane.iris.engine.object.prefab.IrisObjectRotation;
|
||||
import art.arcane.iris.engine.object.prefab.IrisObjectTranslate;
|
||||
import art.arcane.iris.engine.object.procedural.IrisProceduralBlocks;
|
||||
import art.arcane.iris.engine.object.procedural.IrisProceduralPlacement;
|
||||
import art.arcane.iris.core.loader.IrisData;
|
||||
import art.arcane.iris.engine.data.cache.AtomicCache;
|
||||
import art.arcane.iris.engine.object.annotations.ArrayType;
|
||||
import art.arcane.iris.engine.object.annotations.Desc;
|
||||
import art.arcane.iris.engine.object.annotations.MaxNumber;
|
||||
import art.arcane.iris.engine.object.annotations.MinNumber;
|
||||
import art.arcane.iris.engine.object.annotations.RegistryListBlockType;
|
||||
import art.arcane.iris.engine.object.annotations.Required;
|
||||
import art.arcane.iris.engine.object.annotations.Snippet;
|
||||
import art.arcane.iris.engine.object.procedural.ruin.RuinGenerator;
|
||||
import art.arcane.volmlib.util.collection.KList;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
@Snippet("ruin")
|
||||
@Accessors(chain = true)
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Desc("A single procedurally generated ruin: a crumbling man-made structure (pillar, wall, arch, foundation slab, or rubble pile). Iris bakes a pool of deterministic variants from these settings and scatters them at world-gen time, exactly like an object placement but generated from scratch instead of loaded from an iob file. Weathering swaps blocks for mossy or cracked variants by noise, erosion deletes blocks so the shape reads as collapsed, and a buried fraction sinks the ruin into the terrain.")
|
||||
@Data
|
||||
public class IrisRuin implements IrisProceduralPlacement {
|
||||
private final transient AtomicCache<KList<IrisObject>> variantCache = new AtomicCache<>();
|
||||
|
||||
@Desc("A human readable name used in logs and as the variant load key (procedural/<name>#<index>).")
|
||||
private String name = "ruin";
|
||||
|
||||
@MinNumber(0)
|
||||
@MaxNumber(1)
|
||||
@Desc("The chance (0-1) per chunk for this ruin to attempt placement. Use density to attempt more than one per chunk once the chance check passes.")
|
||||
private double chance = 0.05;
|
||||
|
||||
@MinNumber(1)
|
||||
@Desc("If the chance check passes, attempt this many placements in the chunk. Defaults to a single ruin per qualifying chunk.")
|
||||
private int density = 1;
|
||||
|
||||
@MinNumber(1)
|
||||
@MaxNumber(64)
|
||||
@Desc("How many distinct variants to pre-bake for this ruin. Higher means more variety (different heights, gap patterns, erosion seeds) at a small memory cost.")
|
||||
private int variants = 6;
|
||||
|
||||
@Desc("The base seed for deterministic generation. The same seed and settings always bake the same variants. Every random choice (size, weathering mask, erosion mask, accents) is derived from this.")
|
||||
private long seed = 1337;
|
||||
|
||||
@Desc("The placement mode used to anchor the ruin to the terrain. MIN_HEIGHT plants the lowest footprint corner on the ground (good for slabs and rubble on slopes); CENTER_HEIGHT averages the footprint (good for tall pillars and arches).")
|
||||
private ObjectPlaceMode mode = ObjectPlaceMode.MIN_HEIGHT;
|
||||
|
||||
@Desc("Rotate this ruin's placement so variants do not all face the same way.")
|
||||
private IrisObjectRotation rotation = new IrisObjectRotation();
|
||||
|
||||
@Desc("Limit the max or min terrain height at which this ruin may place.")
|
||||
private ObjectLimit clamp = new ObjectLimit();
|
||||
|
||||
@Desc("Whether this ruin may place on the terrain surface, under carvings (caves), or both. SURFACE_ONLY keeps ruins above ground.")
|
||||
private CarvingMode carvingSupport = CarvingMode.SURFACE_ONLY;
|
||||
|
||||
@Desc("If true the ruin anchors on the terrain height ignoring the water surface, so it can sit submerged. If false (default) it anchors to the surface and avoids water.")
|
||||
private boolean underwater = false;
|
||||
|
||||
@Desc("Translate (offset) this placement along each axis; for example set a negative y to sink it into the ground.")
|
||||
private IrisObjectTranslate translate = new IrisObjectTranslate();
|
||||
|
||||
@Desc("Settings for the stilt place modes (STILT, MIN_STILT, FAST_STILT, CENTER_STILT, ERODE_STILT, ORGANIC_STILT).")
|
||||
private StiltSettings stiltSettings;
|
||||
|
||||
@Desc("Settings for the vacuum place modes (VACUUM, VACUUM_HIGH, VACUUM_FAST, VACUUM_ORGANIC).")
|
||||
private VacuumSettings vacuumSettings;
|
||||
|
||||
@Required
|
||||
@Desc("The primary structural block, e.g. minecraft:cobblestone or minecraft:stone_bricks. Ignored when blockPalette is set. This is the bulk material of the ruin before weathering swaps some of it out.")
|
||||
@RegistryListBlockType
|
||||
private String block = "minecraft:cobblestone";
|
||||
|
||||
@Desc("A noise-driven palette for the primary block. When set this overrides the single block, letting the structure mix materials by noise. Palette wins over the block string via IrisProceduralBlocks.resolve.")
|
||||
private IrisMaterialPalette blockPalette = null;
|
||||
|
||||
@Desc("The overall silhouette of the ruin: PILLAR (broken column), WALL (gapped segment), ARCH (two legs plus a curved span), FLOOR_SLAB (foundation patch), or RUBBLE (low scattered pile).")
|
||||
private IrisRuinForm form = IrisRuinForm.PILLAR;
|
||||
|
||||
@MinNumber(1)
|
||||
@Desc("Minimum structure height in blocks (PILLAR/WALL/ARCH height, slab thickness for FLOOR_SLAB, mound height for RUBBLE). Variants interpolate between this and heightMax.")
|
||||
private int heightMin = 4;
|
||||
|
||||
@MinNumber(1)
|
||||
@Desc("Maximum structure height in blocks. Variants interpolate between heightMin and this so taller and shorter ruins coexist.")
|
||||
private int heightMax = 9;
|
||||
|
||||
@MinNumber(1)
|
||||
@Desc("Minimum footprint width (X axis) in blocks: column/leg thickness for PILLAR/ARCH, wall thickness for WALL, slab width for FLOOR_SLAB, blob width for RUBBLE.")
|
||||
private int widthMin = 1;
|
||||
|
||||
@MinNumber(1)
|
||||
@Desc("Maximum footprint width (X axis) in blocks. Variants interpolate between widthMin and this.")
|
||||
private int widthMax = 3;
|
||||
|
||||
@MinNumber(1)
|
||||
@Desc("Minimum footprint length (Z axis) in blocks: wall run length, arch leg spacing, slab length, rubble blob length.")
|
||||
private int lengthMin = 3;
|
||||
|
||||
@MinNumber(1)
|
||||
@Desc("Maximum footprint length (Z axis) in blocks. Variants interpolate between lengthMin and this.")
|
||||
private int lengthMax = 7;
|
||||
|
||||
@Desc("A palette of weathered variants (mossy/cracked block ids) blended over the structure by noise. When set this drives weathering; otherwise weatheredBlock is used.")
|
||||
private IrisMaterialPalette weatheringPalette = null;
|
||||
|
||||
@Desc("A single weathered block id used when weatheringPalette is not set, e.g. minecraft:mossy_cobblestone. Applied to a noise-selected fraction of the structure, biased toward the lower rows.")
|
||||
@RegistryListBlockType
|
||||
private String weatheredBlock = "minecraft:mossy_cobblestone";
|
||||
|
||||
@MinNumber(0)
|
||||
@MaxNumber(1)
|
||||
@Desc("How much of the structure is replaced by weathered blocks (0 none, 1 nearly all). The replacement mask is value-noise driven and weighted so lower rows weather more than upper rows, mimicking moss climbing from the ground.")
|
||||
private double mossiness = 0.45;
|
||||
|
||||
@MinNumber(0)
|
||||
@MaxNumber(8)
|
||||
@Desc("The scale of the weathering noise. Higher values produce smaller, busier moss/crack patches; lower values produce broad continuous weathered zones.")
|
||||
private double weatheringScale = 1.0;
|
||||
|
||||
@MinNumber(0)
|
||||
@MaxNumber(1)
|
||||
@Desc("How crumbled the ruin is (0 intact, 1 mostly gone). Blocks whose value-noise falls below this threshold are deleted, so the shape reads as collapsed. Structural integrity is preserved: the bottom row and core legs are never eroded away.")
|
||||
private double erosion = 0.25;
|
||||
|
||||
@MinNumber(0)
|
||||
@MaxNumber(8)
|
||||
@Desc("The scale of the erosion noise. Higher values knock out small speckled holes; lower values carve larger missing chunks out of the silhouette.")
|
||||
private double erosionScale = 1.5;
|
||||
|
||||
@MinNumber(0)
|
||||
@MaxNumber(1)
|
||||
@Desc("How far the structure extends below the surface as a fraction of its height (0 sits fully on top, 1 sinks it a full height into the ground). The buried rows live at negative y so the ruin reads as settled and partly swallowed by the terrain.")
|
||||
private double buriedFraction = 0.2;
|
||||
|
||||
@ArrayType(min = 1, type = IrisRuinDecorator.class)
|
||||
@Desc("Accent decorators applied after the ruin is built and eroded (moss carpets and lanterns on broken tops, vines and lichen on the faces, rubble and growth scattered around the base).")
|
||||
private KList<IrisRuinDecorator> accents = new KList<>();
|
||||
|
||||
public KList<IrisObject> getVariantObjects(IrisData data) {
|
||||
return variantCache.aquire(() -> {
|
||||
KList<IrisObject> baked = new KList<>();
|
||||
int count = Math.max(1, variants);
|
||||
|
||||
for (int i = 0; i < count; i++) {
|
||||
IrisObject object = RuinGenerator.generate(this, i, new RNG(seed + (i * 7919L)), data);
|
||||
if (object == null || object.getBlocks().isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
object.setLoadKey("procedural/" + name + "#" + i);
|
||||
object.setLoader(data);
|
||||
baked.add(object);
|
||||
}
|
||||
|
||||
return baked;
|
||||
});
|
||||
}
|
||||
|
||||
public IrisObject getVariantObject(IrisData data, RNG rng) {
|
||||
KList<IrisObject> baked = getVariantObjects(data);
|
||||
if (baked == null || baked.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
return baked.get(rng.i(baked.size()));
|
||||
}
|
||||
|
||||
public IrisObjectPlacement asPlacement() {
|
||||
IrisObjectPlacement placement = new IrisObjectPlacement();
|
||||
placement.setMode(mode);
|
||||
placement.setRotation(rotation);
|
||||
placement.setClamp(clamp);
|
||||
placement.setCarvingSupport(carvingSupport);
|
||||
placement.setUnderwater(underwater);
|
||||
placement.setTranslate(translate);
|
||||
placement.setStiltSettings(stiltSettings);
|
||||
placement.setVacuumSettings(vacuumSettings);
|
||||
placement.setChance(chance);
|
||||
placement.setDensity(density);
|
||||
return placement;
|
||||
}
|
||||
|
||||
public boolean isPlausible() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -1,60 +0,0 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2022 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.engine.object.procedural.ruin;
|
||||
|
||||
import art.arcane.iris.engine.object.material.IrisMaterialPalette;
|
||||
import art.arcane.iris.engine.object.procedural.IrisProceduralBlocks;
|
||||
import art.arcane.iris.engine.object.annotations.Desc;
|
||||
import art.arcane.iris.engine.object.annotations.MaxNumber;
|
||||
import art.arcane.iris.engine.object.annotations.MinNumber;
|
||||
import art.arcane.iris.engine.object.annotations.RegistryListBlockType;
|
||||
import art.arcane.iris.engine.object.annotations.Required;
|
||||
import art.arcane.iris.engine.object.annotations.Snippet;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
@Snippet("ruin-decorator")
|
||||
@Accessors(chain = true)
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Desc("An accent block applied to a generated ruin after it is built and eroded, such as moss carpets on broken tops, vines on the faces, or rubble scattered around the base.")
|
||||
@Data
|
||||
public class IrisRuinDecorator {
|
||||
@Desc("Where on the ruin this accent is placed. TOP sits on the highest block of each column, SURFACE clings to air-facing vertical faces, BASE_SCATTER rings the ground footprint around the base.")
|
||||
private IrisRuinDecoratorTarget target = IrisRuinDecoratorTarget.TOP;
|
||||
|
||||
@Required
|
||||
@Desc("The block id to place, e.g. minecraft:moss_carpet or minecraft:vine. Ignored when palette is set.")
|
||||
@RegistryListBlockType
|
||||
private String block = "";
|
||||
|
||||
@Desc("A noise-driven palette for this decorator. When set this overrides the single block, letting the accent mix blocks by noise. Resolved through IrisProceduralBlocks.resolve so the palette wins over the string.")
|
||||
private IrisMaterialPalette palette = null;
|
||||
|
||||
@MinNumber(0)
|
||||
@MaxNumber(1)
|
||||
@Desc("The chance (0-1) per candidate position for this decorator to actually place. 1 covers every candidate, lower values leave sparse, patchy accents.")
|
||||
private double chance = 0.4;
|
||||
|
||||
@MinNumber(1)
|
||||
@Desc("For the BASE_SCATTER target, how many blocks beyond the ruin footprint the scatter ring extends outward in each direction. Higher values fling rubble and growth further from the structure.")
|
||||
private int scatterRadius = 2;
|
||||
}
|
||||
-31
@@ -1,31 +0,0 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2022 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.engine.object.procedural.ruin;
|
||||
|
||||
import art.arcane.iris.engine.object.annotations.Desc;
|
||||
|
||||
@Desc("Where a ruin accent block is placed after the ruin has been built and eroded.")
|
||||
public enum IrisRuinDecoratorTarget {
|
||||
@Desc("On top of the highest surviving block in each column (moss carpets, snow, sculk, lanterns on broken tops).")
|
||||
TOP,
|
||||
@Desc("On air-facing vertical sides of any surviving block (vines, glow lichen, climbing growth on the ruin faces).")
|
||||
SURFACE,
|
||||
@Desc("Scattered across the ground footprint around the y=0 base ring, wider than the structure itself (loose rubble, mushrooms, grass tufts ringing the ruin).")
|
||||
BASE_SCATTER
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2022 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.engine.object.procedural.ruin;
|
||||
|
||||
import art.arcane.iris.engine.object.annotations.Desc;
|
||||
|
||||
@Desc("The overall silhouette of a procedural ruin. Each form rasterizes a different crumbling man-made shape from the same size, weathering, and erosion settings.")
|
||||
public enum IrisRuinForm {
|
||||
@Desc("A broken vertical column. A square trunk (widthMin..widthMax footprint) rises to a randomized height then snaps off with a jagged crown, leaving a toppled stub. Use for ancient pillars and obelisk stumps.")
|
||||
PILLAR,
|
||||
@Desc("A standing wall segment. A flat slab spanning lengthMin..lengthMax long and heightMin..heightMax tall, thickness widthMin..widthMax, punched through with noise-driven gaps and a ragged top edge. Use for collapsed building sides and fortifications.")
|
||||
WALL,
|
||||
@Desc("A freestanding arch. Two legs spaced by lengthMin..lengthMax joined at the top by a rasterized semicircular span (the lintel), so the structure literally arches. Use for gateways, aqueduct bays, and ruined doorways.")
|
||||
ARCH,
|
||||
@Desc("A flat foundation patch. A single (or few) block-thick slab covering a widthMin..lengthMax footprint at ground level, heavily eroded into an irregular outline. Use for floor remnants, plazas, and building foundations.")
|
||||
FLOOR_SLAB,
|
||||
@Desc("A low scattered debris pile. A noise blob of partial blocks mounded near the ground, tallest at the center and thinning toward the edges. Use for collapsed-structure rubble and scree.")
|
||||
RUBBLE
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Servers
|
||||
* Copyright (c) 2026 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.engine.object.procedural.ruin;
|
||||
|
||||
import art.arcane.iris.builtin.objects.ruin.Ruin;
|
||||
import art.arcane.iris.core.loader.IrisData;
|
||||
import art.arcane.iris.engine.object.prefab.IrisObject;
|
||||
import art.arcane.iris.engine.object.procedural.ResolvedProceduralPlacement;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
|
||||
/** A ruin made placeable: its variants are baked by {@link RuinGenerator}. */
|
||||
public final class ResolvedRuin extends ResolvedProceduralPlacement {
|
||||
private final Ruin settings;
|
||||
|
||||
public ResolvedRuin(Ruin settings) {
|
||||
super(new Shape(settings.name(), settings.chance(), settings.density(), settings.seed(), settings.variants(), settings.mode(),
|
||||
settings.rotation(), settings.clamp(), settings.carvingSupport(), settings.underwater(), settings.translate(),
|
||||
settings.stiltSettings().orElse(null), settings.vacuumSettings().orElse(null)));
|
||||
this.settings = settings;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected IrisObject generate(int index, RNG rng, IrisData data) {
|
||||
return RuinGenerator.generate(settings, index, rng, data);
|
||||
}
|
||||
}
|
||||
+6
-6
@@ -18,10 +18,10 @@
|
||||
|
||||
package art.arcane.iris.engine.object.procedural.ruin;
|
||||
|
||||
import art.arcane.iris.builtin.objects.ruin.RuinDecorator;
|
||||
import art.arcane.iris.core.loader.IrisData;
|
||||
import art.arcane.iris.engine.object.procedural.IrisProceduralBlocks;
|
||||
import art.arcane.iris.spi.PlatformBlockState;
|
||||
import art.arcane.iris.engine.object.procedural.ruin.IrisRuinDecorator;
|
||||
import art.arcane.iris.util.common.math.Vector3i;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
|
||||
@@ -36,19 +36,19 @@ final class RuinDecoratorApplier {
|
||||
private RuinDecoratorApplier() {
|
||||
}
|
||||
|
||||
static void apply(RuinBlockCanvas canvas, IrisRuinDecorator decorator, IrisData data, long seed, RNG rng) {
|
||||
List<Vector3i> candidates = switch (decorator.getTarget()) {
|
||||
static void apply(RuinBlockCanvas canvas, RuinDecorator decorator, IrisData data, long seed, RNG rng) {
|
||||
List<Vector3i> candidates = switch (decorator.target()) {
|
||||
case TOP -> topCandidates(canvas);
|
||||
case SURFACE -> surfaceCandidates(canvas);
|
||||
case BASE_SCATTER -> baseScatterCandidates(canvas, Math.max(1, decorator.getScatterRadius()));
|
||||
case BASE_SCATTER -> baseScatterCandidates(canvas, Math.max(1, decorator.scatterRadius()));
|
||||
};
|
||||
|
||||
RNG paletteRng = new RNG(seed);
|
||||
for (Vector3i v : candidates) {
|
||||
if (!rng.chance(decorator.getChance())) {
|
||||
if (!rng.chance(decorator.chance())) {
|
||||
continue;
|
||||
}
|
||||
PlatformBlockState bd = IrisProceduralBlocks.resolve(decorator.getBlock(), decorator.getPalette(), data, v.getBlockX(), v.getBlockY(), v.getBlockZ(), paletteRng);
|
||||
PlatformBlockState bd = IrisProceduralBlocks.resolve(decorator.block(), decorator.palette(), data, v.getBlockX(), v.getBlockY(), v.getBlockZ(), paletteRng);
|
||||
if (bd != null) {
|
||||
canvas.accent(v.getBlockX(), v.getBlockY(), v.getBlockZ(), bd);
|
||||
}
|
||||
|
||||
@@ -18,11 +18,12 @@
|
||||
|
||||
package art.arcane.iris.engine.object.procedural.ruin;
|
||||
|
||||
import art.arcane.iris.builtin.objects.ruin.RuinDecorator;
|
||||
import art.arcane.iris.builtin.objects.ruin.Ruin;
|
||||
import art.arcane.iris.core.loader.IrisData;
|
||||
import art.arcane.iris.engine.object.prefab.IrisObject;
|
||||
import art.arcane.iris.engine.object.procedural.IrisProceduralBlocks;
|
||||
import art.arcane.iris.spi.PlatformBlockState;
|
||||
import art.arcane.iris.engine.object.procedural.ruin.IrisRuin;
|
||||
import art.arcane.iris.engine.object.procedural.tree.TreeFunctions;
|
||||
import art.arcane.iris.util.common.math.Vector3i;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
@@ -36,14 +37,14 @@ public final class RuinGenerator {
|
||||
private RuinGenerator() {
|
||||
}
|
||||
|
||||
public static IrisObject generate(IrisRuin ruin, int variantIndex, RNG rng, IrisData data) {
|
||||
int count = Math.max(1, ruin.getVariants());
|
||||
int height = pick(ruin.getHeightMin(), ruin.getHeightMax(), variantIndex, count, rng);
|
||||
int width = pick(ruin.getWidthMin(), ruin.getWidthMax(), variantIndex, count, rng);
|
||||
int length = pick(ruin.getLengthMin(), ruin.getLengthMax(), variantIndex, count, rng);
|
||||
public static IrisObject generate(Ruin ruin, int variantIndex, RNG rng, IrisData data) {
|
||||
int count = Math.max(1, ruin.variants());
|
||||
int height = pick(ruin.heightMin(), ruin.heightMax(), variantIndex, count, rng);
|
||||
int width = pick(ruin.widthMin(), ruin.widthMax(), variantIndex, count, rng);
|
||||
int length = pick(ruin.lengthMin(), ruin.lengthMax(), variantIndex, count, rng);
|
||||
|
||||
RuinBlockCanvas canvas = new RuinBlockCanvas();
|
||||
switch (ruin.getForm()) {
|
||||
switch (ruin.form()) {
|
||||
case PILLAR -> RuinShapes.pillar(canvas, Math.max(1, width), Math.max(2, height), rng);
|
||||
case WALL -> RuinShapes.wall(canvas, Math.max(1, width), Math.max(2, length), Math.max(2, height), rng);
|
||||
case ARCH -> RuinShapes.arch(canvas, Math.max(1, width), Math.max(3, length), Math.max(3, height), rng);
|
||||
@@ -70,8 +71,8 @@ public final class RuinGenerator {
|
||||
return (int) Math.round(Math.max(min, Math.min(max, base + jitter)));
|
||||
}
|
||||
|
||||
private static void applyBurial(IrisRuin ruin, RuinBlockCanvas canvas, int height) {
|
||||
double fraction = clamp01(ruin.getBuriedFraction());
|
||||
private static void applyBurial(Ruin ruin, RuinBlockCanvas canvas, int height) {
|
||||
double fraction = clamp01(ruin.buriedFraction());
|
||||
if (fraction <= 0.0) {
|
||||
return;
|
||||
}
|
||||
@@ -88,13 +89,13 @@ public final class RuinGenerator {
|
||||
canvas.cells().putAll(moved);
|
||||
}
|
||||
|
||||
private static void applyErosion(IrisRuin ruin, RuinBlockCanvas canvas) {
|
||||
double erosion = clamp01(ruin.getErosion());
|
||||
private static void applyErosion(Ruin ruin, RuinBlockCanvas canvas) {
|
||||
double erosion = clamp01(ruin.erosion());
|
||||
if (erosion <= 0.0) {
|
||||
return;
|
||||
}
|
||||
double scale = Math.max(0.0001, ruin.getErosionScale());
|
||||
long erosionSeed = ruin.getSeed() * 0x2545F4914F6CDD1DL + 17L;
|
||||
double scale = Math.max(0.0001, ruin.erosionScale());
|
||||
long erosionSeed = ruin.seed() * 0x2545F4914F6CDD1DL + 17L;
|
||||
int minY = Integer.MAX_VALUE;
|
||||
for (Vector3i v : canvas.cells().keySet()) {
|
||||
minY = Math.min(minY, v.getBlockY());
|
||||
@@ -120,25 +121,25 @@ public final class RuinGenerator {
|
||||
}
|
||||
}
|
||||
|
||||
private static void applyAccents(IrisRuin ruin, RuinBlockCanvas canvas, RNG rng, IrisData data) {
|
||||
if (ruin.getAccents() == null || ruin.getAccents().isEmpty()) {
|
||||
private static void applyAccents(Ruin ruin, RuinBlockCanvas canvas, RNG rng, IrisData data) {
|
||||
if (ruin.accents() == null || ruin.accents().isEmpty()) {
|
||||
return;
|
||||
}
|
||||
int decoratorIndex = 0;
|
||||
for (art.arcane.iris.engine.object.procedural.ruin.IrisRuinDecorator decorator : ruin.getAccents()) {
|
||||
RuinDecoratorApplier.apply(canvas, decorator, data, ruin.getSeed() + decoratorIndex * 911L, rng.nextParallelRNG(decoratorIndex + 1));
|
||||
for (art.arcane.iris.builtin.objects.ruin.RuinDecorator decorator : ruin.accents()) {
|
||||
RuinDecoratorApplier.apply(canvas, decorator, data, ruin.seed() + decoratorIndex * 911L, rng.nextParallelRNG(decoratorIndex + 1));
|
||||
decoratorIndex++;
|
||||
}
|
||||
}
|
||||
|
||||
private static IrisObject resolve(IrisRuin ruin, RuinBlockCanvas canvas, IrisData data) {
|
||||
private static IrisObject resolve(Ruin ruin, RuinBlockCanvas canvas, IrisData data) {
|
||||
if (canvas.cells().isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
double scale = Math.max(0.0001, ruin.getWeatheringScale());
|
||||
double mossiness = clamp01(ruin.getMossiness());
|
||||
long weatherSeed = ruin.getSeed() * 0x9E3779B97F4A7C15L + 101L;
|
||||
RNG paletteRng = new RNG(ruin.getSeed());
|
||||
double scale = Math.max(0.0001, ruin.weatheringScale());
|
||||
double mossiness = clamp01(ruin.mossiness());
|
||||
long weatherSeed = ruin.seed() * 0x9E3779B97F4A7C15L + 101L;
|
||||
RNG paletteRng = new RNG(ruin.seed());
|
||||
|
||||
int minY = Integer.MAX_VALUE;
|
||||
int maxY = Integer.MIN_VALUE;
|
||||
@@ -166,7 +167,7 @@ public final class RuinGenerator {
|
||||
return IrisProceduralBlocks.assemble(blocks);
|
||||
}
|
||||
|
||||
private static PlatformBlockState structuralBlock(IrisRuin ruin, RuinBlockCanvas.Cell cell, Vector3i v, IrisData data, RNG paletteRng, double scale, double mossiness, long weatherSeed, int minY, int span) {
|
||||
private static PlatformBlockState structuralBlock(Ruin ruin, RuinBlockCanvas.Cell cell, Vector3i v, IrisData data, RNG paletteRng, double scale, double mossiness, long weatherSeed, int minY, int span) {
|
||||
boolean weathered = false;
|
||||
if (mossiness > 0.0) {
|
||||
int sx = (int) Math.round(v.getBlockX() * scale);
|
||||
@@ -179,12 +180,12 @@ public final class RuinGenerator {
|
||||
}
|
||||
|
||||
if (weathered) {
|
||||
PlatformBlockState wd = IrisProceduralBlocks.resolve(ruin.getWeatheredBlock(), ruin.getWeatheringPalette(), data, v.getBlockX(), v.getBlockY(), v.getBlockZ(), paletteRng);
|
||||
PlatformBlockState wd = IrisProceduralBlocks.resolve(ruin.weatheredBlock(), ruin.weatheringPalette(), data, v.getBlockX(), v.getBlockY(), v.getBlockZ(), paletteRng);
|
||||
if (wd != null) {
|
||||
return wd;
|
||||
}
|
||||
}
|
||||
return IrisProceduralBlocks.resolve(ruin.getBlock(), ruin.getBlockPalette(), data, v.getBlockX(), v.getBlockY(), v.getBlockZ(), paletteRng);
|
||||
return IrisProceduralBlocks.resolve(ruin.block(), ruin.blockPalette(), data, v.getBlockX(), v.getBlockY(), v.getBlockZ(), paletteRng);
|
||||
}
|
||||
|
||||
private static double clamp01(double value) {
|
||||
|
||||
+17
-10
@@ -18,6 +18,13 @@
|
||||
|
||||
package art.arcane.iris.engine.object.procedural.tree;
|
||||
|
||||
import art.arcane.iris.builtin.objects.tree.TreeSecondaryLeaf;
|
||||
import art.arcane.iris.builtin.objects.tree.TreeDecorator;
|
||||
import art.arcane.iris.builtin.objects.tree.TreeCanopy;
|
||||
import art.arcane.iris.builtin.objects.tree.TreeRootStyle;
|
||||
import art.arcane.iris.builtin.objects.tree.TreeProfile;
|
||||
import art.arcane.iris.builtin.objects.tree.TreeFunction;
|
||||
import art.arcane.iris.builtin.objects.tree.TreeAzimuthMode;
|
||||
import art.arcane.iris.builtin.carve.CarvingMode;
|
||||
import art.arcane.iris.builtin.anchor.ObjectPlaceMode;
|
||||
import art.arcane.iris.builtin.stilt.StiltSettings;
|
||||
@@ -120,7 +127,7 @@ public class IrisProceduralTree implements IrisProceduralPlacement {
|
||||
private IrisMaterialPalette leavesPalette = null;
|
||||
|
||||
@Desc("The named canopy profile that drives default crown radii and shape.")
|
||||
private IrisTreeProfile profile = IrisTreeProfile.OAK;
|
||||
private TreeProfile profile = TreeProfile.OAK;
|
||||
|
||||
@MinNumber(1)
|
||||
@Desc("Minimum trunk height in blocks.")
|
||||
@@ -135,7 +142,7 @@ public class IrisProceduralTree implements IrisProceduralPlacement {
|
||||
private int trunkWidth = 1;
|
||||
|
||||
@Desc("The function used to shape trunk width over height.")
|
||||
private IrisTreeFunction trunkShape = IrisTreeFunction.CONSTANT;
|
||||
private TreeFunction trunkShape = TreeFunction.CONSTANT;
|
||||
|
||||
@Desc("Width multiplier at the base for the LINEAR trunk shape.")
|
||||
private double shapeStart = 1;
|
||||
@@ -168,13 +175,13 @@ public class IrisProceduralTree implements IrisProceduralPlacement {
|
||||
private double leanAngle = 0;
|
||||
|
||||
@Desc("How the lean accumulates over height.")
|
||||
private IrisTreeFunction trunkCurve = IrisTreeFunction.LINEAR;
|
||||
private TreeFunction trunkCurve = TreeFunction.LINEAR;
|
||||
|
||||
@Desc("Steepness for the SIGMOID trunk curve.")
|
||||
private double curveSteepness = 8;
|
||||
|
||||
@Desc("How the lean azimuth itself changes over height (for spiraling or wandering trunks).")
|
||||
private IrisTreeAzimuthMode leanAzimuthMode = IrisTreeAzimuthMode.CONSTANT;
|
||||
private TreeAzimuthMode leanAzimuthMode = TreeAzimuthMode.CONSTANT;
|
||||
|
||||
@Desc("Azimuth at the base for the LINEAR azimuth mode.")
|
||||
private double azimuthStart = 0;
|
||||
@@ -210,9 +217,9 @@ public class IrisProceduralTree implements IrisProceduralPlacement {
|
||||
@Desc("The fraction of leaves replaced by the secondary leaf block(s).")
|
||||
private double secondaryLeafFraction = 0.35;
|
||||
|
||||
@ArrayType(min = 1, type = IrisTreeSecondaryLeaf.class)
|
||||
@ArrayType(min = 1, type = TreeSecondaryLeaf.class)
|
||||
@Desc("Optional weighted set of accent leaf blocks. When set this overrides the single secondaryLeaves block.")
|
||||
private KList<IrisTreeSecondaryLeaf> weightedSecondaryLeaves = new KList<>();
|
||||
private KList<TreeSecondaryLeaf> weightedSecondaryLeaves = new KList<>();
|
||||
|
||||
@Desc("A noise-driven palette for the secondary (accent) leaves. When set this overrides both secondaryLeaves and weightedSecondaryLeaves.")
|
||||
private IrisMaterialPalette secondaryLeavesPalette = null;
|
||||
@@ -238,7 +245,7 @@ public class IrisProceduralTree implements IrisProceduralPlacement {
|
||||
private boolean roots = true;
|
||||
|
||||
@Desc("How the root system is built when roots is true.")
|
||||
private IrisTreeRootStyle rootStyle = IrisTreeRootStyle.BUTTRESS;
|
||||
private TreeRootStyle rootStyle = TreeRootStyle.BUTTRESS;
|
||||
|
||||
@MinNumber(0)
|
||||
@Desc("Override the root depth/reach in blocks. 0 means auto (scales with tree height).")
|
||||
@@ -262,11 +269,11 @@ public class IrisProceduralTree implements IrisProceduralPlacement {
|
||||
private double forkAngle = 25;
|
||||
|
||||
@Desc("The leaf crown configuration.")
|
||||
private IrisTreeCanopy canopy = new IrisTreeCanopy();
|
||||
private TreeCanopy canopy = new TreeCanopy();
|
||||
|
||||
@ArrayType(min = 1, type = IrisTreeDecorator.class)
|
||||
@ArrayType(min = 1, type = TreeDecorator.class)
|
||||
@Desc("Accent decorators applied after the tree is built (fruit, vines, snow, glow).")
|
||||
private KList<IrisTreeDecorator> decorators = new KList<>();
|
||||
private KList<TreeDecorator> decorators = new KList<>();
|
||||
|
||||
public KList<IrisObject> getVariantObjects(IrisData data) {
|
||||
return variantCache.aquire(() -> {
|
||||
|
||||
@@ -1,45 +0,0 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2022 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.engine.object.procedural.tree;
|
||||
|
||||
import art.arcane.iris.engine.object.annotations.Desc;
|
||||
|
||||
@Desc("Controls the compass direction (azimuth) of trunk lean as it rises, or the direction each branch is thrown.")
|
||||
public enum IrisTreeAzimuthMode {
|
||||
@Desc("A single fixed azimuth.")
|
||||
CONSTANT,
|
||||
@Desc("Azimuth ramps straight from start to end with height.")
|
||||
LINEAR,
|
||||
@Desc("Azimuth winds around the trunk a number of turns (corkscrew).")
|
||||
SPIRAL,
|
||||
@Desc("Azimuth oscillates with a sine wave.")
|
||||
SINE,
|
||||
@Desc("Azimuth wanders using deterministic noise.")
|
||||
NOISE,
|
||||
@Desc("Each branch picks a uniformly random azimuth (falls back to constant for trunk lean).")
|
||||
RANDOM,
|
||||
@Desc("Phyllotaxis: each successive branch is offset by the 137.5 degree golden angle for the most natural spiral packing (branches).")
|
||||
GOLDEN_ANGLE,
|
||||
@Desc("Each successive branch is thrown to the opposite side (180 degrees apart).")
|
||||
ALTERNATING,
|
||||
@Desc("Branches are grouped into evenly spaced whorls of azimuthWhorlCount around each ring.")
|
||||
WHORL,
|
||||
@Desc("Azimuth zigzags by +/- amplitude on alternating branches.")
|
||||
ZIGZAG
|
||||
}
|
||||
-47
@@ -1,47 +0,0 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2022 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.engine.object.procedural.tree;
|
||||
|
||||
import art.arcane.iris.engine.object.annotations.Desc;
|
||||
|
||||
@Desc("Controls how the chance of spawning a branch varies with trunk height (0 at the base, 1 at the top).")
|
||||
public enum IrisTreeBranchProbability {
|
||||
@Desc("Same branch chance at every height.")
|
||||
CONSTANT,
|
||||
@Desc("Ramps straight from base chance to crown chance.")
|
||||
LINEAR,
|
||||
@Desc("S-curve that switches on around a midpoint height.")
|
||||
SIGMOID,
|
||||
@Desc("Chance rises with height raised to an exponent, clustering branches near the crown.")
|
||||
TOP_HEAVY,
|
||||
@Desc("Bell curve peaking in a height band.")
|
||||
GAUSSIAN,
|
||||
@Desc("Irregular organic branching from deterministic noise.")
|
||||
NOISE,
|
||||
@Desc("Chance falls with height (1-t)^exponent, clustering branches near the base.")
|
||||
BOTTOM_HEAVY,
|
||||
@Desc("Regular whorl rings of branches at evenly spaced heights (periods controls count).")
|
||||
PERIODIC,
|
||||
@Desc("Branches only within a height window around mean +/- std.")
|
||||
BAND,
|
||||
@Desc("Inverse of GAUSSIAN: branches avoid the mean band and favor base and crown.")
|
||||
INVERSE_GAUSSIAN,
|
||||
@Desc("Exponential decay from the base upward (constant * e^-exponent*t).")
|
||||
EXPONENTIAL_DECAY
|
||||
}
|
||||
@@ -1,131 +0,0 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2022 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.engine.object.procedural.tree;
|
||||
|
||||
import art.arcane.iris.engine.object.annotations.Desc;
|
||||
import art.arcane.iris.engine.object.annotations.MaxNumber;
|
||||
import art.arcane.iris.engine.object.annotations.MinNumber;
|
||||
import art.arcane.iris.engine.object.annotations.Snippet;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
@Snippet("tree-branches")
|
||||
@Accessors(chain = true)
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Desc("A branch system that throws limbs out of the trunk and places a leaf ball at each tip. When present, branches drive the canopy and only the topmost crown disc of the profile is still placed.")
|
||||
@Data
|
||||
public class IrisTreeBranches {
|
||||
@Desc("How branch spawn chance varies over trunk height.")
|
||||
private IrisTreeBranchProbability probabilityFunction = IrisTreeBranchProbability.TOP_HEAVY;
|
||||
|
||||
@MinNumber(0)
|
||||
@Desc("Branch chance for the CONSTANT probability function.")
|
||||
private double probabilityConstant = 0.5;
|
||||
|
||||
@MinNumber(0)
|
||||
@Desc("Branch chance at the base for the LINEAR probability function.")
|
||||
private double probabilityBase = 0;
|
||||
|
||||
@MinNumber(0)
|
||||
@Desc("Branch chance at the crown for the LINEAR probability function.")
|
||||
private double probabilityCrown = 1;
|
||||
|
||||
@Desc("Steepness for the SIGMOID probability function.")
|
||||
private double probabilitySteepness = 10;
|
||||
|
||||
@Desc("Midpoint height (0-1) for the SIGMOID probability function.")
|
||||
private double probabilityMidpoint = 0.7;
|
||||
|
||||
@Desc("Exponent for the TOP_HEAVY probability function.")
|
||||
private double probabilityExponent = 2;
|
||||
|
||||
@Desc("Mean height (0-1) for the GAUSSIAN probability function.")
|
||||
private double probabilityMean = 0.7;
|
||||
|
||||
@Desc("Standard deviation for the GAUSSIAN probability function.")
|
||||
private double probabilityStd = 0.15;
|
||||
|
||||
@Desc("Noise scale for the NOISE probability function.")
|
||||
private double probabilityScale = 1;
|
||||
|
||||
@MinNumber(0)
|
||||
@Desc("Number of whorl rings over the trunk height for the PERIODIC probability function.")
|
||||
private double probabilityPeriods = 5;
|
||||
|
||||
@Desc("How branch length varies over trunk height.")
|
||||
private IrisTreeFunction lengthFunction = IrisTreeFunction.LINEAR;
|
||||
|
||||
@MinNumber(0)
|
||||
@Desc("Branch length at the base for the LINEAR length function.")
|
||||
private double lengthBase = 1;
|
||||
|
||||
@MinNumber(0)
|
||||
@Desc("Branch length at the crown for the LINEAR length function.")
|
||||
private double lengthCrown = 4;
|
||||
|
||||
@MinNumber(0)
|
||||
@Desc("Branch length for the CONSTANT length function.")
|
||||
private double lengthConstant = 3;
|
||||
|
||||
@MinNumber(0)
|
||||
@Desc("Maximum branch length for the SIGMOID, LOG and PARABOLIC length functions.")
|
||||
private double lengthMax = 4;
|
||||
|
||||
@Desc("Steepness for the SIGMOID length function.")
|
||||
private double lengthSteepness = 5;
|
||||
|
||||
@Desc("How the compass direction of each branch is chosen.")
|
||||
private IrisTreeAzimuthMode azimuthMode = IrisTreeAzimuthMode.RANDOM;
|
||||
|
||||
@Desc("Fixed azimuth in degrees when azimuthMode is CONSTANT.")
|
||||
private double azimuth = 0;
|
||||
|
||||
@Desc("Elevation angle in degrees from horizontal. 0 is flat, positive points up, negative droops down.")
|
||||
private double elevation = 0;
|
||||
|
||||
@MinNumber(0)
|
||||
@MaxNumber(1)
|
||||
@Desc("How much each branch sags/droops along its length (catenary). 0 is a straight branch; higher values arc the branch and its tip downward.")
|
||||
private double sag = 0;
|
||||
|
||||
@MinNumber(0)
|
||||
@MaxNumber(6)
|
||||
@Desc("How many recursive levels of sub-branches to grow. 0 is none, 1 is a single level, 2+ produces fractal branching.")
|
||||
private int branchDepth = 1;
|
||||
|
||||
@Desc("If true, branches are clamped to never droop below horizontal (useful for upright species).")
|
||||
private boolean leafStartUp = false;
|
||||
|
||||
@MinNumber(0)
|
||||
@Desc("Leaf ball radius placed at each branch tip.")
|
||||
private int clusterRadius = 2;
|
||||
|
||||
@Desc("How the branch tip leaf cluster fills.")
|
||||
private IrisTreeLeafMode clusterMode = IrisTreeLeafMode.TRIMMED;
|
||||
|
||||
@MinNumber(0)
|
||||
@Desc("Fill density for the branch tip leaf cluster when clusterMode is density or noise.")
|
||||
private double clusterDensity = 0.85;
|
||||
|
||||
@Desc("Optional one level of recursive sub-branches sprouting from each branch tip.")
|
||||
private IrisTreeSubBranches subBranches = null;
|
||||
}
|
||||
@@ -1,71 +0,0 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2022 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.engine.object.procedural.tree;
|
||||
|
||||
import art.arcane.iris.engine.object.annotations.ArrayType;
|
||||
import art.arcane.iris.engine.object.annotations.Desc;
|
||||
import art.arcane.iris.engine.object.annotations.MaxNumber;
|
||||
import art.arcane.iris.engine.object.annotations.MinNumber;
|
||||
import art.arcane.iris.engine.object.annotations.Snippet;
|
||||
import art.arcane.volmlib.util.collection.KList;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
@Snippet("tree-canopy")
|
||||
@Accessors(chain = true)
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Desc("The leaf crown of a procedural tree. Built from stacked dome-shaped discs (driven by the profile or by explicit layers) and optionally a branch system.")
|
||||
@Data
|
||||
public class IrisTreeCanopy {
|
||||
@MinNumber(0)
|
||||
@MaxNumber(180)
|
||||
@Desc("Elevation angle in degrees from vertical for each leaf dome. 90 is a flat disc, below 90 domes downward into a sphere, above 90 flares outward into an umbrella.")
|
||||
private double startAngle = 90;
|
||||
|
||||
@MinNumber(0)
|
||||
@MaxNumber(1)
|
||||
@Desc("Vertical scale of the canopy volume. Lower values flatten the crown.")
|
||||
private double squish = 1;
|
||||
|
||||
@Desc("How leaves fill each canopy disc.")
|
||||
private IrisTreeLeafMode mode = IrisTreeLeafMode.TRIMMED;
|
||||
|
||||
@MinNumber(0)
|
||||
@MaxNumber(1)
|
||||
@Desc("Fill probability used by the density and noise leaf modes.")
|
||||
private double leafDensity = 0.85;
|
||||
|
||||
@MinNumber(0.1)
|
||||
@Desc("Horizontal X stretch of the crown for elliptical or wind-blown shapes. 1 is circular.")
|
||||
private double crownStretchX = 1;
|
||||
|
||||
@MinNumber(0.1)
|
||||
@Desc("Horizontal Z stretch of the crown for elliptical or wind-blown shapes. 1 is circular.")
|
||||
private double crownStretchZ = 1;
|
||||
|
||||
@ArrayType(min = 1, type = IrisTreeLayer.class)
|
||||
@Desc("Optional explicit crown discs. When provided these replace the profile-driven layers and let you sculpt the silhouette by hand.")
|
||||
private KList<IrisTreeLayer> layers = new KList<>();
|
||||
|
||||
@Desc("Optional branch system. When present, branches build most of the canopy and only the topmost profile disc is still placed as a crown.")
|
||||
private IrisTreeBranches branches = null;
|
||||
}
|
||||
@@ -1,62 +0,0 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2022 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.engine.object.procedural.tree;
|
||||
|
||||
import art.arcane.iris.engine.object.material.IrisMaterialPalette;
|
||||
import art.arcane.iris.engine.object.annotations.Desc;
|
||||
import art.arcane.iris.engine.object.annotations.MaxNumber;
|
||||
import art.arcane.iris.engine.object.annotations.MinNumber;
|
||||
import art.arcane.iris.engine.object.annotations.RegistryListBlockType;
|
||||
import art.arcane.iris.engine.object.annotations.Required;
|
||||
import art.arcane.iris.engine.object.annotations.Snippet;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
@Snippet("tree-decorator")
|
||||
@Accessors(chain = true)
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Desc("An accent block applied to a generated tree such as fruit on branch tips, vines on the trunk, snow on the crown, or a glowing underside.")
|
||||
@Data
|
||||
public class IrisTreeDecorator {
|
||||
@Desc("Where this decorator is placed on the tree.")
|
||||
private IrisTreeDecoratorTarget target = IrisTreeDecoratorTarget.BRANCH_TIP;
|
||||
|
||||
@Required
|
||||
@Desc("The block id to place, e.g. minecraft:magma_block. Ignored when palette is set.")
|
||||
@RegistryListBlockType
|
||||
private String block = "";
|
||||
|
||||
@Desc("A noise-driven palette for this decorator. When set this overrides the single block.")
|
||||
private IrisMaterialPalette palette = null;
|
||||
|
||||
@MinNumber(0)
|
||||
@MaxNumber(1)
|
||||
@Desc("The chance per candidate position for this decorator to place.")
|
||||
private double chance = 0.5;
|
||||
|
||||
@MinNumber(1)
|
||||
@Desc("Maximum strand length downward for the CANOPY_HANG target (random 1..length per column).")
|
||||
private int length = 1;
|
||||
|
||||
@Desc("If true the block's facing is oriented away from the trunk (for trunk-mounted fences/gates/banners).")
|
||||
private boolean axisAware = false;
|
||||
}
|
||||
-45
@@ -1,45 +0,0 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2022 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.engine.object.procedural.tree;
|
||||
|
||||
import art.arcane.iris.engine.object.annotations.Desc;
|
||||
|
||||
@Desc("Where a tree decorator block is placed.")
|
||||
public enum IrisTreeDecoratorTarget {
|
||||
@Desc("At the tip of each generated branch (vines, fruit, lanterns).")
|
||||
BRANCH_TIP,
|
||||
@Desc("On air-facing sides of trunk and branch blocks (vines, moss).")
|
||||
TRUNK_SURFACE,
|
||||
@Desc("On top of the highest block in each column (snow, sculk).")
|
||||
CANOPY_TOP,
|
||||
@Desc("One block below the lowest leaf in each column (glowing underside).")
|
||||
CANOPY_BOTTOM,
|
||||
@Desc("Around the y=0 ring at the base of the trunk (roots, mushrooms).")
|
||||
TRUNK_BASE,
|
||||
@Desc("On air-facing sides of leaf blocks (berries, lights nestled in the foliage).")
|
||||
LEAF_SURFACE,
|
||||
@Desc("Hanging strands of up to 'length' blocks below the lowest leaf in each column (vines, icicles).")
|
||||
CANOPY_HANG,
|
||||
@Desc("On the top face of trunk and branch blocks (moss, snow on limbs).")
|
||||
BRANCH_SURFACE,
|
||||
@Desc("One block above the very top of the trunk (nest, beehive, beacon).")
|
||||
TRUNK_TOP,
|
||||
@Desc("Scattered across the ground footprint around the base, wider than the trunk-base ring.")
|
||||
GROUND_SCATTER
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2022 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.engine.object.procedural.tree;
|
||||
|
||||
import art.arcane.iris.engine.object.annotations.Desc;
|
||||
|
||||
@Desc("A shaping function evaluated over normalized height (0 at the base, 1 at the top). Used for trunk width, trunk curve and branch length.")
|
||||
public enum IrisTreeFunction {
|
||||
@Desc("Same value at every height.")
|
||||
CONSTANT,
|
||||
@Desc("Ramps straight from start to end.")
|
||||
LINEAR,
|
||||
@Desc("S-curve transition controlled by steepness.")
|
||||
SIGMOID,
|
||||
@Desc("Logarithmic falloff controlled by base.")
|
||||
LOG,
|
||||
@Desc("Sine ripple controlled by period and amplitude.")
|
||||
SINE,
|
||||
@Desc("Parabolic pinch, narrowest at peakOffset.")
|
||||
PARABOLIC,
|
||||
@Desc("Geometric (exponential) interpolation from start to end.")
|
||||
EXPONENTIAL,
|
||||
@Desc("Square-root ease: fast change low, slow high.")
|
||||
SQRT,
|
||||
@Desc("Hard step that jumps from start to end at the threshold (peakOffset).")
|
||||
STEP,
|
||||
@Desc("Bell bulge peaking in the middle of the height range.")
|
||||
BELL,
|
||||
@Desc("Smoothstep ease-in-out (3t^2 - 2t^3).")
|
||||
EASE_IN_OUT
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2022 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.engine.object.procedural.tree;
|
||||
|
||||
import art.arcane.iris.engine.object.annotations.Desc;
|
||||
import art.arcane.iris.engine.object.annotations.MinNumber;
|
||||
import art.arcane.iris.engine.object.annotations.Snippet;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
@Snippet("tree-layer")
|
||||
@Accessors(chain = true)
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Desc("An explicit canopy disc at a given vertical offset and radius. Define a list of these to bypass the profile and sculpt the crown by hand.")
|
||||
@Data
|
||||
public class IrisTreeLayer {
|
||||
@Desc("The vertical offset of this disc, measured in blocks above the trunk base.")
|
||||
private int yOffset = 0;
|
||||
|
||||
@MinNumber(0.5)
|
||||
@Desc("The radius of this leaf disc in blocks.")
|
||||
private double radius = 2;
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2022 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.engine.object.procedural.tree;
|
||||
|
||||
import art.arcane.iris.engine.object.annotations.Desc;
|
||||
|
||||
@Desc("How leaves fill a disc or cluster.")
|
||||
public enum IrisTreeLeafMode {
|
||||
@Desc("Corner-trimmed disc/sphere for a rounded silhouette.")
|
||||
TRIMMED,
|
||||
@Desc("Completely filled disc/sphere.")
|
||||
FILLED,
|
||||
@Desc("Seeded probabilistic falloff toward the edge controlled by leafDensity.")
|
||||
DENSITY,
|
||||
@Desc("Seeded value-noise mask controlled by leafDensity.")
|
||||
NOISE,
|
||||
@Desc("Only the outer shell is placed, leaving the interior hollow.")
|
||||
HOLLOW,
|
||||
@Desc("Quadratic radial gradient: dense at the center, thinning sharply toward the edge.")
|
||||
GRADIENT,
|
||||
@Desc("Coarse low-frequency noise that forms clumps and gaps of foliage.")
|
||||
CLUMPED,
|
||||
@Desc("Trimmed with heavy random erosion of the outer ring for a ragged, weathered look.")
|
||||
TATTERED,
|
||||
@Desc("Very thin scattering of leaves across the volume.")
|
||||
SPARSE
|
||||
}
|
||||
@@ -1,53 +0,0 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2022 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.engine.object.procedural.tree;
|
||||
|
||||
import art.arcane.iris.engine.object.annotations.Desc;
|
||||
|
||||
@Desc("Named canopy presets that drive default layer radii and shape, scaled to the tree height.")
|
||||
public enum IrisTreeProfile {
|
||||
@Desc("Rounded broadleaf crown.")
|
||||
OAK,
|
||||
@Desc("Slim upright broadleaf crown.")
|
||||
BIRCH,
|
||||
@Desc("Narrow conifer cone.")
|
||||
SPRUCE,
|
||||
@Desc("Tall thin crown concentrated near the very top.")
|
||||
JUNGLE,
|
||||
@Desc("Flat shallow umbrella crown.")
|
||||
ACACIA,
|
||||
@Desc("Dense rounded broadleaf crown.")
|
||||
DARK_OAK,
|
||||
@Desc("Flat wide umbrella crown compressed into the top quarter (vanilla dark oak look).")
|
||||
DARK_OAK_FLAT,
|
||||
@Desc("Extra wide flat umbrella that overlaps into a continuous roofed canopy.")
|
||||
DARK_OAK_FLAT_WIDE,
|
||||
@Desc("Broad rounded blossom crown.")
|
||||
CHERRY,
|
||||
@Desc("Bare trunk with a small tuft of fronds only at the very top.")
|
||||
PALM,
|
||||
@Desc("Broad crown with wide drooping radii, ideal with a low startAngle to make a weeping skirt.")
|
||||
WILLOW,
|
||||
@Desc("Very narrow tall crown hugging the trunk (cypress / lombardy poplar).")
|
||||
COLUMNAR,
|
||||
@Desc("Squat, wide, low crown for shrubs and saplings.")
|
||||
BUSH,
|
||||
@Desc("Giant conifer cone for 2x2 mega spruce trunks.")
|
||||
MEGA_SPRUCE
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2022 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.engine.object.procedural.tree;
|
||||
|
||||
import art.arcane.iris.engine.object.annotations.Desc;
|
||||
|
||||
@Desc("How a procedural tree's root system is built below (and around) the trunk base.")
|
||||
public enum IrisTreeRootStyle {
|
||||
@Desc("A single tapering taproot straight down from the base.")
|
||||
TAPROOT,
|
||||
@Desc("A taproot plus a ring of flared buttress legs that splay outward as they descend (default).")
|
||||
BUTTRESS,
|
||||
@Desc("Visible above-ground prop roots that arch out and down from the lower trunk to the ground (mangrove style).")
|
||||
STILT
|
||||
}
|
||||
-46
@@ -1,46 +0,0 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2022 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.engine.object.procedural.tree;
|
||||
|
||||
import art.arcane.iris.engine.object.annotations.Desc;
|
||||
import art.arcane.iris.engine.object.annotations.MinNumber;
|
||||
import art.arcane.iris.engine.object.annotations.RegistryListBlockType;
|
||||
import art.arcane.iris.engine.object.annotations.Required;
|
||||
import art.arcane.iris.engine.object.annotations.Snippet;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
@Snippet("tree-secondary-leaf")
|
||||
@Accessors(chain = true)
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Desc("A weighted accent leaf or foliage block scattered through the canopy (blossoms, shroomlight, berries).")
|
||||
@Data
|
||||
public class IrisTreeSecondaryLeaf {
|
||||
@Required
|
||||
@Desc("The block id to scatter, e.g. minecraft:shroomlight")
|
||||
@RegistryListBlockType
|
||||
private String block = "";
|
||||
|
||||
@MinNumber(0)
|
||||
@Desc("The relative weight of this block among the secondary leaves.")
|
||||
private int weight = 1;
|
||||
}
|
||||
@@ -1,66 +0,0 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2022 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.engine.object.procedural.tree;
|
||||
|
||||
import art.arcane.iris.engine.object.annotations.Desc;
|
||||
import art.arcane.iris.engine.object.annotations.MaxNumber;
|
||||
import art.arcane.iris.engine.object.annotations.MinNumber;
|
||||
import art.arcane.iris.engine.object.annotations.Snippet;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
@Snippet("tree-sub-branches")
|
||||
@Accessors(chain = true)
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Desc("One recursive level of sub-branches sprouting from each primary branch tip.")
|
||||
@Data
|
||||
public class IrisTreeSubBranches {
|
||||
@MinNumber(1)
|
||||
@Desc("How many sub-branches sprout from each primary branch tip.")
|
||||
private int count = 1;
|
||||
|
||||
@Desc("Pitch deflection in degrees applied to each sub-branch relative to its parent. Positive bends up, negative droops down. Cumulative pitch past 90 makes sub-branches point downward.")
|
||||
private double pitchDelta = 0;
|
||||
|
||||
@Desc("Yaw (horizontal) spread in degrees fanned between sub-branches.")
|
||||
private double yawDelta = 45;
|
||||
|
||||
@MinNumber(0)
|
||||
@Desc("Sub-branch length as a fraction of its parent branch length.")
|
||||
private double lengthScale = 0.5;
|
||||
|
||||
@MinNumber(0)
|
||||
@MaxNumber(1)
|
||||
@Desc("How much each sub-branch sags/droops along its length (catenary).")
|
||||
private double sag = 0;
|
||||
|
||||
@MinNumber(0)
|
||||
@Desc("Leaf ball radius placed at each sub-branch tip.")
|
||||
private int clusterRadius = 1;
|
||||
|
||||
@Desc("How the sub-branch tip leaf cluster fills.")
|
||||
private IrisTreeLeafMode clusterMode = IrisTreeLeafMode.TRIMMED;
|
||||
|
||||
@MinNumber(0)
|
||||
@Desc("Fill density for the sub-branch leaf cluster when clusterMode is density or noise.")
|
||||
private double clusterDensity = 0.85;
|
||||
}
|
||||
@@ -18,11 +18,13 @@
|
||||
|
||||
package art.arcane.iris.engine.object.procedural.tree;
|
||||
|
||||
import art.arcane.iris.builtin.objects.tree.TreeSecondaryLeaf;
|
||||
import art.arcane.iris.builtin.objects.tree.TreeDecorator;
|
||||
import art.arcane.iris.core.loader.IrisData;
|
||||
import art.arcane.iris.engine.object.material.IrisMaterialPalette;
|
||||
import com.volmit.block.PaletteSpec;
|
||||
import art.arcane.iris.engine.object.procedural.IrisProceduralBlocks;
|
||||
import art.arcane.iris.engine.object.procedural.tree.IrisProceduralTree;
|
||||
import art.arcane.iris.engine.object.procedural.tree.IrisTreeDecorator;
|
||||
import art.arcane.iris.spi.PlatformBlockState;
|
||||
import art.arcane.iris.util.common.data.B;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
@@ -62,8 +64,8 @@ public final class TreeBlockResolver {
|
||||
if (index < 0 || tree.getDecorators() == null || index >= tree.getDecorators().size()) {
|
||||
return null;
|
||||
}
|
||||
IrisTreeDecorator dec = tree.getDecorators().get(index);
|
||||
PlatformBlockState state = resolveBlock(dec.getBlock(), dec.getPalette(), data, pos, paletteRng);
|
||||
TreeDecorator dec = tree.getDecorators().get(index);
|
||||
PlatformBlockState state = resolveBlock(dec.block(), dec.palette().orElse(null), data, pos, paletteRng);
|
||||
if (state != null && cell.facing() != null && IrisProceduralBlocks.hasProperty(state, "facing")) {
|
||||
try {
|
||||
state = state.withProperty("facing", cell.facing().toLowerCase());
|
||||
@@ -110,21 +112,25 @@ public final class TreeBlockResolver {
|
||||
|
||||
private static String pickWeighted(IrisProceduralTree tree, RNG rng) {
|
||||
int total = 0;
|
||||
for (art.arcane.iris.engine.object.procedural.tree.IrisTreeSecondaryLeaf s : tree.getWeightedSecondaryLeaves()) {
|
||||
total += Math.max(0, s.getWeight());
|
||||
for (art.arcane.iris.builtin.objects.tree.TreeSecondaryLeaf s : tree.getWeightedSecondaryLeaves()) {
|
||||
total += Math.max(0, s.weight());
|
||||
}
|
||||
if (total <= 0) {
|
||||
return null;
|
||||
}
|
||||
double r = rng.nextDouble() * total;
|
||||
double cumulative = 0;
|
||||
for (art.arcane.iris.engine.object.procedural.tree.IrisTreeSecondaryLeaf s : tree.getWeightedSecondaryLeaves()) {
|
||||
cumulative += Math.max(0, s.getWeight());
|
||||
for (art.arcane.iris.builtin.objects.tree.TreeSecondaryLeaf s : tree.getWeightedSecondaryLeaves()) {
|
||||
cumulative += Math.max(0, s.weight());
|
||||
if (r < cumulative) {
|
||||
return s.getBlock();
|
||||
return s.block();
|
||||
}
|
||||
}
|
||||
return tree.getWeightedSecondaryLeaves().get(tree.getWeightedSecondaryLeaves().size() - 1).getBlock();
|
||||
return tree.getWeightedSecondaryLeaves().get(tree.getWeightedSecondaryLeaves().size() - 1).block();
|
||||
}
|
||||
|
||||
private static PlatformBlockState resolveBlock(String block, PaletteSpec palette, IrisData data, TreeBlockCanvas.Vec pos, RNG paletteRng) {
|
||||
return IrisProceduralBlocks.resolve(block, palette, data, pos.x(), pos.y(), pos.z(), paletteRng);
|
||||
}
|
||||
|
||||
private static PlatformBlockState resolveBlock(String block, IrisMaterialPalette palette, IrisData data, TreeBlockCanvas.Vec pos, RNG paletteRng) {
|
||||
|
||||
+44
-44
@@ -18,13 +18,13 @@
|
||||
|
||||
package art.arcane.iris.engine.object.procedural.tree;
|
||||
|
||||
import art.arcane.iris.builtin.objects.tree.TreeSubBranches;
|
||||
import art.arcane.iris.builtin.objects.tree.TreeLayer;
|
||||
import art.arcane.iris.builtin.objects.tree.TreeCanopy;
|
||||
import art.arcane.iris.builtin.objects.tree.TreeBranches;
|
||||
import art.arcane.iris.builtin.objects.tree.TreeProfile;
|
||||
import art.arcane.iris.builtin.objects.tree.TreeLeafMode;
|
||||
import art.arcane.iris.engine.object.procedural.tree.IrisProceduralTree;
|
||||
import art.arcane.iris.engine.object.procedural.tree.IrisTreeBranches;
|
||||
import art.arcane.iris.engine.object.procedural.tree.IrisTreeCanopy;
|
||||
import art.arcane.iris.engine.object.procedural.tree.IrisTreeLayer;
|
||||
import art.arcane.iris.engine.object.procedural.tree.IrisTreeLeafMode;
|
||||
import art.arcane.iris.engine.object.procedural.tree.IrisTreeProfile;
|
||||
import art.arcane.iris.engine.object.procedural.tree.IrisTreeSubBranches;
|
||||
import art.arcane.volmlib.util.collection.KList;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
|
||||
@@ -36,11 +36,11 @@ public final class TreeCanopyBuilder {
|
||||
|
||||
public static void build(TreeBlockCanvas canvas, IrisProceduralTree tree, int height, double[][] offsets,
|
||||
int branchStartY, long baseSeed, List<int[]> branchEndpoints) {
|
||||
IrisTreeCanopy canopy = tree.getCanopy();
|
||||
TreeCanopy canopy = tree.getCanopy();
|
||||
if (canopy == null) {
|
||||
canopy = new IrisTreeCanopy();
|
||||
canopy = new TreeCanopy();
|
||||
}
|
||||
IrisTreeBranches branches = canopy.getBranches();
|
||||
TreeBranches branches = canopy.branches().orElse(null);
|
||||
|
||||
double[][] layers = resolveLayers(canopy, tree.getProfile(), height, branches != null);
|
||||
|
||||
@@ -69,19 +69,19 @@ public final class TreeCanopyBuilder {
|
||||
maxR = Math.max(maxR, layer[1]);
|
||||
}
|
||||
int capRadius = Math.max(2, Math.min(3, (int) Math.round(maxR * 0.35)));
|
||||
IrisTreeCanopy canopy = tree.getCanopy();
|
||||
IrisTreeLeafMode mode = canopy != null ? canopy.getMode() : IrisTreeLeafMode.TRIMMED;
|
||||
double density = canopy != null ? canopy.getLeafDensity() : 1.0;
|
||||
TreeCanopy canopy = tree.getCanopy();
|
||||
TreeLeafMode mode = canopy != null ? canopy.mode() : TreeLeafMode.TRIMMED;
|
||||
double density = canopy != null ? canopy.leafDensity() : 1.0;
|
||||
placeLeafCluster(canvas, tree, ocx, height - 1, ocz, capRadius, mode, density, baseSeed + 5555L);
|
||||
}
|
||||
|
||||
private static double[][] resolveLayers(IrisTreeCanopy canopy, IrisTreeProfile profile, int height, boolean branchDriven) {
|
||||
KList<IrisTreeLayer> explicit = canopy.getLayers();
|
||||
private static double[][] resolveLayers(TreeCanopy canopy, TreeProfile profile, int height, boolean branchDriven) {
|
||||
KList<TreeLayer> explicit = new KList<>(canopy.layers());
|
||||
if (explicit != null && !explicit.isEmpty()) {
|
||||
double[][] out = new double[explicit.size()][2];
|
||||
for (int i = 0; i < explicit.size(); i++) {
|
||||
out[i][0] = explicit.get(i).getYOffset();
|
||||
out[i][1] = explicit.get(i).getRadius();
|
||||
out[i][0] = explicit.get(i).yOffset();
|
||||
out[i][1] = explicit.get(i).radius();
|
||||
}
|
||||
return out;
|
||||
}
|
||||
@@ -89,7 +89,7 @@ public final class TreeCanopyBuilder {
|
||||
}
|
||||
|
||||
private static void volumeCanopy(TreeBlockCanvas canvas, IrisProceduralTree tree, double[][] layers,
|
||||
IrisTreeCanopy canopy, long baseSeed, double[][] offsets) {
|
||||
TreeCanopy canopy, long baseSeed, double[][] offsets) {
|
||||
int ocx = 0;
|
||||
int ocz = 0;
|
||||
if (offsets != null && offsets.length > 0) {
|
||||
@@ -97,10 +97,10 @@ public final class TreeCanopyBuilder {
|
||||
ocz = (int) Math.round(offsets[offsets.length - 1][1]);
|
||||
}
|
||||
|
||||
double startAngle = canopy.getStartAngle();
|
||||
double squish = canopy.getSquish();
|
||||
IrisTreeLeafMode mode = canopy.getMode();
|
||||
double leafDensity = canopy.getLeafDensity();
|
||||
double startAngle = canopy.startAngle();
|
||||
double squish = canopy.squish();
|
||||
TreeLeafMode mode = canopy.mode();
|
||||
double leafDensity = canopy.leafDensity();
|
||||
|
||||
for (double[] layer : layers) {
|
||||
int yCenter = (int) Math.round(layer[0]);
|
||||
@@ -137,7 +137,7 @@ public final class TreeCanopyBuilder {
|
||||
}
|
||||
|
||||
private static void placeLeafDisc(TreeBlockCanvas canvas, IrisProceduralTree tree, int cx, int cy, int cz,
|
||||
double radius, IrisTreeLeafMode mode, double density, long seed) {
|
||||
double radius, TreeLeafMode mode, double density, long seed) {
|
||||
double sx = stretchX(tree);
|
||||
double sz = stretchZ(tree);
|
||||
RNG rng = new RNG(seed);
|
||||
@@ -158,7 +158,7 @@ public final class TreeCanopyBuilder {
|
||||
}
|
||||
|
||||
private static void placeLeafCluster(TreeBlockCanvas canvas, IrisProceduralTree tree, int cx, int cy, int cz,
|
||||
int radius, IrisTreeLeafMode mode, double density, long seed) {
|
||||
int radius, TreeLeafMode mode, double density, long seed) {
|
||||
double sx = stretchX(tree);
|
||||
double sz = stretchZ(tree);
|
||||
RNG rng = new RNG(seed);
|
||||
@@ -181,16 +181,16 @@ public final class TreeCanopyBuilder {
|
||||
}
|
||||
|
||||
private static double stretchX(IrisProceduralTree tree) {
|
||||
IrisTreeCanopy c = tree.getCanopy();
|
||||
return c == null ? 1.0 : Math.max(0.1, c.getCrownStretchX());
|
||||
TreeCanopy c = tree.getCanopy();
|
||||
return c == null ? 1.0 : Math.max(0.1, c.crownStretchX());
|
||||
}
|
||||
|
||||
private static double stretchZ(IrisProceduralTree tree) {
|
||||
IrisTreeCanopy c = tree.getCanopy();
|
||||
return c == null ? 1.0 : Math.max(0.1, c.getCrownStretchZ());
|
||||
TreeCanopy c = tree.getCanopy();
|
||||
return c == null ? 1.0 : Math.max(0.1, c.crownStretchZ());
|
||||
}
|
||||
|
||||
private static boolean passesLeafTest(IrisTreeLeafMode mode, double dist, double radius, double density,
|
||||
private static boolean passesLeafTest(TreeLeafMode mode, double dist, double radius, double density,
|
||||
RNG rng, int wx, int wy, int wz, long seed, boolean corner) {
|
||||
switch (mode) {
|
||||
case TRIMMED -> {
|
||||
@@ -258,12 +258,12 @@ public final class TreeCanopyBuilder {
|
||||
}
|
||||
|
||||
private static void branchCanopy(TreeBlockCanvas canvas, IrisProceduralTree tree, int height,
|
||||
IrisTreeBranches branches, int branchStartY, long baseSeed, double[][] offsets,
|
||||
TreeBranches branches, int branchStartY, long baseSeed, double[][] offsets,
|
||||
List<int[]> branchEndpoints) {
|
||||
long branchSeed = baseSeed + 9999;
|
||||
RNG branchRng = new RNG(branchSeed);
|
||||
IrisTreeSubBranches sub = branches.getSubBranches();
|
||||
int depth = branches.getBranchDepth();
|
||||
TreeSubBranches sub = branches.subBranches().orElse(null);
|
||||
int depth = branches.branchDepth();
|
||||
int branchIndex = 0;
|
||||
|
||||
for (int y = Math.max(0, branchStartY); y < height; y++) {
|
||||
@@ -280,38 +280,38 @@ public final class TreeCanopyBuilder {
|
||||
oz = (int) Math.round(offsets[y][1]);
|
||||
}
|
||||
|
||||
double az = TreeFunctions.azimuthDegrees(branches.getAzimuthMode(), t, branchIndex, tree, branches.getAzimuth(), branchRng);
|
||||
double az = TreeFunctions.azimuthDegrees(branches.azimuthMode(), t, branchIndex, tree, branches.azimuth(), branchRng);
|
||||
branchIndex++;
|
||||
double branchLen = TreeFunctions.branchLength(branches, t);
|
||||
double effElevation = branches.isLeafStartUp() ? Math.max(0.0, branches.getElevation()) : branches.getElevation();
|
||||
double effElevation = branches.leafStartUp() ? Math.max(0.0, branches.elevation()) : branches.elevation();
|
||||
int[] end = branchEndpoint(ox, y, oz, az, effElevation, branchLen);
|
||||
int[] tip = rasterizeBranch(canvas, ox, y, oz, end[0], end[1], end[2], branches.getSag());
|
||||
int[] tip = rasterizeBranch(canvas, ox, y, oz, end[0], end[1], end[2], branches.sag());
|
||||
|
||||
if (branchEndpoints != null) {
|
||||
branchEndpoints.add(new int[]{tip[0], tip[1], tip[2], ox, oz});
|
||||
}
|
||||
placeLeafCluster(canvas, tree, tip[0], tip[1], tip[2], branches.getClusterRadius(),
|
||||
branches.getClusterMode(), branches.getClusterDensity(), branchSeed + y);
|
||||
placeLeafCluster(canvas, tree, tip[0], tip[1], tip[2], branches.clusterRadius(),
|
||||
branches.clusterMode(), branches.clusterDensity(), branchSeed + y);
|
||||
|
||||
growSubBranches(canvas, tree, tip[0], tip[1], tip[2], az, effElevation, branchLen, sub, depth, branchSeed + y + 1000L);
|
||||
}
|
||||
}
|
||||
|
||||
private static void growSubBranches(TreeBlockCanvas canvas, IrisProceduralTree tree, int ox, int oy, int oz,
|
||||
double az, double el, double len, IrisTreeSubBranches sub, int depth, long seed) {
|
||||
double az, double el, double len, TreeSubBranches sub, int depth, long seed) {
|
||||
if (sub == null || depth <= 0) {
|
||||
return;
|
||||
}
|
||||
int count = Math.max(1, sub.getCount());
|
||||
int count = Math.max(1, sub.count());
|
||||
for (int si = 0; si < count; si++) {
|
||||
double yawOffset = sub.getYawDelta() * (si - (count - 1) / 2.0);
|
||||
double yawOffset = sub.yawDelta() * (si - (count - 1) / 2.0);
|
||||
double subAz = az + yawOffset;
|
||||
double subEl = el + sub.getPitchDelta();
|
||||
double subLen = len * sub.getLengthScale();
|
||||
double subEl = el + sub.pitchDelta();
|
||||
double subLen = len * sub.lengthScale();
|
||||
int[] end = branchEndpoint(ox, oy, oz, subAz, subEl, subLen);
|
||||
int[] tip = rasterizeBranch(canvas, ox, oy, oz, end[0], end[1], end[2], sub.getSag());
|
||||
placeLeafCluster(canvas, tree, tip[0], tip[1], tip[2], sub.getClusterRadius(),
|
||||
sub.getClusterMode(), sub.getClusterDensity(), seed + si * 131L);
|
||||
int[] tip = rasterizeBranch(canvas, ox, oy, oz, end[0], end[1], end[2], sub.sag());
|
||||
placeLeafCluster(canvas, tree, tip[0], tip[1], tip[2], sub.clusterRadius(),
|
||||
sub.clusterMode(), sub.clusterDensity(), seed + si * 131L);
|
||||
growSubBranches(canvas, tree, tip[0], tip[1], tip[2], subAz, subEl, subLen, sub, depth - 1, seed + si * 131L + 17L);
|
||||
}
|
||||
}
|
||||
|
||||
+29
-29
@@ -18,8 +18,8 @@
|
||||
|
||||
package art.arcane.iris.engine.object.procedural.tree;
|
||||
|
||||
import art.arcane.iris.builtin.objects.tree.TreeDecorator;
|
||||
import art.arcane.iris.engine.object.procedural.tree.IrisProceduralTree;
|
||||
import art.arcane.iris.engine.object.procedural.tree.IrisTreeDecorator;
|
||||
import art.arcane.volmlib.util.collection.KList;
|
||||
import art.arcane.volmlib.util.collection.KMap;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
@@ -32,19 +32,19 @@ public final class TreeDecoratorApplier {
|
||||
}
|
||||
|
||||
public static void apply(TreeBlockCanvas canvas, IrisProceduralTree tree, long baseSeed, List<int[]> branchEndpoints) {
|
||||
KList<IrisTreeDecorator> decorators = tree.getDecorators();
|
||||
KList<TreeDecorator> decorators = tree.getDecorators();
|
||||
if (decorators == null || decorators.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
RNG rng = new RNG(baseSeed + 77777L);
|
||||
|
||||
for (int idx = 0; idx < decorators.size(); idx++) {
|
||||
IrisTreeDecorator dec = decorators.get(idx);
|
||||
boolean hasBlock = (dec.getBlock() != null && !dec.getBlock().isEmpty()) || TreeTrunkBuilder.paletteSet(dec.getPalette());
|
||||
TreeDecorator dec = decorators.get(idx);
|
||||
boolean hasBlock = (dec.block() != null && !dec.block().isEmpty()) || dec.palette().isPresent();
|
||||
if (!hasBlock) {
|
||||
continue;
|
||||
}
|
||||
switch (dec.getTarget()) {
|
||||
switch (dec.target()) {
|
||||
case BRANCH_TIP -> branchTip(canvas, dec, idx, branchEndpoints, rng);
|
||||
case TRUNK_SURFACE -> trunkSurface(canvas, dec, idx, rng);
|
||||
case CANOPY_TOP -> canopyTop(canvas, dec, idx, rng);
|
||||
@@ -59,63 +59,63 @@ public final class TreeDecoratorApplier {
|
||||
}
|
||||
}
|
||||
|
||||
private static void branchTip(TreeBlockCanvas canvas, IrisTreeDecorator dec, int idx, List<int[]> branchEndpoints, RNG rng) {
|
||||
private static void branchTip(TreeBlockCanvas canvas, TreeDecorator dec, int idx, List<int[]> branchEndpoints, RNG rng) {
|
||||
if (branchEndpoints == null) {
|
||||
return;
|
||||
}
|
||||
for (int[] e : branchEndpoints) {
|
||||
if (rng.nextDouble() > dec.getChance()) {
|
||||
if (rng.nextDouble() > dec.chance()) {
|
||||
continue;
|
||||
}
|
||||
if (canvas.has(e[0], e[1], e[2])) {
|
||||
continue;
|
||||
}
|
||||
String facing = dec.isAxisAware() ? facingAway(e[3], e[4], e[0], e[2]) : null;
|
||||
String facing = dec.axisAware() ? facingAway(e[3], e[4], e[0], e[2]) : null;
|
||||
canvas.setDecor(e[0], e[1], e[2], idx, facing);
|
||||
}
|
||||
}
|
||||
|
||||
private static void trunkSurface(TreeBlockCanvas canvas, IrisTreeDecorator dec, int idx, RNG rng) {
|
||||
private static void trunkSurface(TreeBlockCanvas canvas, TreeDecorator dec, int idx, RNG rng) {
|
||||
int[][] sides = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};
|
||||
String[] facings = {"west", "east", "north", "south"};
|
||||
for (TreeBlockCanvas.Vec v : new KList<>(canvas.getTrunk())) {
|
||||
for (int i = 0; i < sides.length; i++) {
|
||||
int nx = v.x() + sides[i][0];
|
||||
int nz = v.z() + sides[i][1];
|
||||
if (canvas.has(nx, v.y(), nz) || rng.nextDouble() > dec.getChance()) {
|
||||
if (canvas.has(nx, v.y(), nz) || rng.nextDouble() > dec.chance()) {
|
||||
continue;
|
||||
}
|
||||
canvas.setDecor(nx, v.y(), nz, idx, dec.isAxisAware() ? facings[i] : null);
|
||||
canvas.setDecor(nx, v.y(), nz, idx, dec.axisAware() ? facings[i] : null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void leafSurface(TreeBlockCanvas canvas, IrisTreeDecorator dec, int idx, RNG rng) {
|
||||
private static void leafSurface(TreeBlockCanvas canvas, TreeDecorator dec, int idx, RNG rng) {
|
||||
int[][] sides = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};
|
||||
String[] facings = {"west", "east", "north", "south"};
|
||||
for (TreeBlockCanvas.Vec v : new KList<>(canvas.getLeaf())) {
|
||||
for (int i = 0; i < sides.length; i++) {
|
||||
int nx = v.x() + sides[i][0];
|
||||
int nz = v.z() + sides[i][1];
|
||||
if (canvas.has(nx, v.y(), nz) || rng.nextDouble() > dec.getChance()) {
|
||||
if (canvas.has(nx, v.y(), nz) || rng.nextDouble() > dec.chance()) {
|
||||
continue;
|
||||
}
|
||||
canvas.setDecor(nx, v.y(), nz, idx, dec.isAxisAware() ? facings[i] : null);
|
||||
canvas.setDecor(nx, v.y(), nz, idx, dec.axisAware() ? facings[i] : null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void branchSurface(TreeBlockCanvas canvas, IrisTreeDecorator dec, int idx, RNG rng) {
|
||||
private static void branchSurface(TreeBlockCanvas canvas, TreeDecorator dec, int idx, RNG rng) {
|
||||
for (TreeBlockCanvas.Vec v : new KList<>(canvas.getTrunk())) {
|
||||
int ay = v.y() + 1;
|
||||
if (canvas.has(v.x(), ay, v.z()) || rng.nextDouble() > dec.getChance()) {
|
||||
if (canvas.has(v.x(), ay, v.z()) || rng.nextDouble() > dec.chance()) {
|
||||
continue;
|
||||
}
|
||||
canvas.setDecor(v.x(), ay, v.z(), idx, null);
|
||||
}
|
||||
}
|
||||
|
||||
private static void canopyTop(TreeBlockCanvas canvas, IrisTreeDecorator dec, int idx, RNG rng) {
|
||||
private static void canopyTop(TreeBlockCanvas canvas, TreeDecorator dec, int idx, RNG rng) {
|
||||
KMap<Long, Integer> colTop = new KMap<>();
|
||||
for (TreeBlockCanvas.Vec v : canvas.getCells().keySet()) {
|
||||
long key = pack(v.x(), v.z());
|
||||
@@ -128,31 +128,31 @@ public final class TreeDecoratorApplier {
|
||||
int x = unpackX(e.getKey());
|
||||
int z = unpackZ(e.getKey());
|
||||
int aboveY = e.getValue() + 1;
|
||||
if (canvas.has(x, aboveY, z) || rng.nextDouble() > dec.getChance()) {
|
||||
if (canvas.has(x, aboveY, z) || rng.nextDouble() > dec.chance()) {
|
||||
continue;
|
||||
}
|
||||
canvas.setDecor(x, aboveY, z, idx, null);
|
||||
}
|
||||
}
|
||||
|
||||
private static void canopyBottom(TreeBlockCanvas canvas, IrisTreeDecorator dec, int idx, RNG rng) {
|
||||
private static void canopyBottom(TreeBlockCanvas canvas, TreeDecorator dec, int idx, RNG rng) {
|
||||
KMap<Long, Integer> colBottom = columnLeafBottoms(canvas);
|
||||
for (Map.Entry<Long, Integer> e : colBottom.entrySet()) {
|
||||
int x = unpackX(e.getKey());
|
||||
int z = unpackZ(e.getKey());
|
||||
int belowY = e.getValue() - 1;
|
||||
if (canvas.has(x, belowY, z) || rng.nextDouble() > dec.getChance()) {
|
||||
if (canvas.has(x, belowY, z) || rng.nextDouble() > dec.chance()) {
|
||||
continue;
|
||||
}
|
||||
canvas.setDecor(x, belowY, z, idx, null);
|
||||
}
|
||||
}
|
||||
|
||||
private static void canopyHang(TreeBlockCanvas canvas, IrisTreeDecorator dec, int idx, RNG rng) {
|
||||
int maxLen = Math.max(1, dec.getLength());
|
||||
private static void canopyHang(TreeBlockCanvas canvas, TreeDecorator dec, int idx, RNG rng) {
|
||||
int maxLen = Math.max(1, dec.length());
|
||||
KMap<Long, Integer> colBottom = columnLeafBottoms(canvas);
|
||||
for (Map.Entry<Long, Integer> e : colBottom.entrySet()) {
|
||||
if (rng.nextDouble() > dec.getChance()) {
|
||||
if (rng.nextDouble() > dec.chance()) {
|
||||
continue;
|
||||
}
|
||||
int x = unpackX(e.getKey());
|
||||
@@ -168,7 +168,7 @@ public final class TreeDecoratorApplier {
|
||||
}
|
||||
}
|
||||
|
||||
private static void trunkBase(TreeBlockCanvas canvas, IrisTreeDecorator dec, int idx, RNG rng) {
|
||||
private static void trunkBase(TreeBlockCanvas canvas, TreeDecorator dec, int idx, RNG rng) {
|
||||
int[][] sides = {{-1, 0}, {1, 0}, {0, -1}, {0, 1}};
|
||||
for (TreeBlockCanvas.Vec v : new KList<>(canvas.getTrunk())) {
|
||||
if (v.y() != 0) {
|
||||
@@ -177,7 +177,7 @@ public final class TreeDecoratorApplier {
|
||||
for (int[] side : sides) {
|
||||
int nx = v.x() + side[0];
|
||||
int nz = v.z() + side[1];
|
||||
if (canvas.has(nx, 0, nz) || rng.nextDouble() > dec.getChance()) {
|
||||
if (canvas.has(nx, 0, nz) || rng.nextDouble() > dec.chance()) {
|
||||
continue;
|
||||
}
|
||||
canvas.setDecor(nx, 0, nz, idx, null);
|
||||
@@ -185,7 +185,7 @@ public final class TreeDecoratorApplier {
|
||||
}
|
||||
}
|
||||
|
||||
private static void trunkTop(TreeBlockCanvas canvas, IrisTreeDecorator dec, int idx, RNG rng) {
|
||||
private static void trunkTop(TreeBlockCanvas canvas, TreeDecorator dec, int idx, RNG rng) {
|
||||
int maxY = Integer.MIN_VALUE;
|
||||
for (TreeBlockCanvas.Vec v : canvas.getTrunk()) {
|
||||
maxY = Math.max(maxY, v.y());
|
||||
@@ -198,14 +198,14 @@ public final class TreeDecoratorApplier {
|
||||
continue;
|
||||
}
|
||||
int aboveY = v.y() + 1;
|
||||
if (canvas.has(v.x(), aboveY, v.z()) || rng.nextDouble() > dec.getChance()) {
|
||||
if (canvas.has(v.x(), aboveY, v.z()) || rng.nextDouble() > dec.chance()) {
|
||||
continue;
|
||||
}
|
||||
canvas.setDecor(v.x(), aboveY, v.z(), idx, null);
|
||||
}
|
||||
}
|
||||
|
||||
private static void groundScatter(TreeBlockCanvas canvas, IrisTreeDecorator dec, int idx, RNG rng) {
|
||||
private static void groundScatter(TreeBlockCanvas canvas, TreeDecorator dec, int idx, RNG rng) {
|
||||
double cx = 0;
|
||||
double cz = 0;
|
||||
int count = 0;
|
||||
@@ -237,7 +237,7 @@ public final class TreeDecoratorApplier {
|
||||
}
|
||||
int x = icx + dx;
|
||||
int z = icz + dz;
|
||||
if (canvas.has(x, 0, z) || rng.nextDouble() > dec.getChance()) {
|
||||
if (canvas.has(x, 0, z) || rng.nextDouble() > dec.chance()) {
|
||||
continue;
|
||||
}
|
||||
canvas.setDecor(x, 0, z, idx, null);
|
||||
|
||||
@@ -18,10 +18,10 @@
|
||||
|
||||
package art.arcane.iris.engine.object.procedural.tree;
|
||||
|
||||
import art.arcane.iris.builtin.objects.tree.TreeBranches;
|
||||
import art.arcane.iris.builtin.objects.tree.TreeFunction;
|
||||
import art.arcane.iris.builtin.objects.tree.TreeAzimuthMode;
|
||||
import art.arcane.iris.engine.object.procedural.tree.IrisProceduralTree;
|
||||
import art.arcane.iris.engine.object.procedural.tree.IrisTreeAzimuthMode;
|
||||
import art.arcane.iris.engine.object.procedural.tree.IrisTreeBranches;
|
||||
import art.arcane.iris.engine.object.procedural.tree.IrisTreeFunction;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
|
||||
public final class TreeFunctions {
|
||||
@@ -65,7 +65,7 @@ public final class TreeFunctions {
|
||||
};
|
||||
}
|
||||
|
||||
public static double curveProgress(IrisTreeFunction fn, double t, double steepness) {
|
||||
public static double curveProgress(TreeFunction fn, double t, double steepness) {
|
||||
return switch (fn) {
|
||||
case LINEAR, CONSTANT, SINE -> t;
|
||||
case LOG -> Math.log(1.0 + t * (Math.E - 1.0));
|
||||
@@ -78,14 +78,14 @@ public final class TreeFunctions {
|
||||
};
|
||||
}
|
||||
|
||||
public static double branchLength(IrisTreeBranches b, double t) {
|
||||
double base = b.getLengthBase();
|
||||
double crown = b.getLengthCrown();
|
||||
double max = b.getLengthMax();
|
||||
double v = switch (b.getLengthFunction()) {
|
||||
case CONSTANT -> b.getLengthConstant();
|
||||
public static double branchLength(TreeBranches b, double t) {
|
||||
double base = b.lengthBase();
|
||||
double crown = b.lengthCrown();
|
||||
double max = b.lengthMax();
|
||||
double v = switch (b.lengthFunction()) {
|
||||
case CONSTANT -> b.lengthConstant();
|
||||
case LINEAR, SINE -> base + (crown - base) * t;
|
||||
case SIGMOID -> max / (1.0 + Math.exp(-b.getLengthSteepness() * (t - 0.5)));
|
||||
case SIGMOID -> max / (1.0 + Math.exp(-b.lengthSteepness() * (t - 0.5)));
|
||||
case LOG -> max * Math.log(1.0 + t * (Math.E - 1.0));
|
||||
case PARABOLIC -> max * (1.0 - Math.pow(2.0 * t - 1.0, 2));
|
||||
case EXPONENTIAL -> geometric(base, crown, t);
|
||||
@@ -97,24 +97,24 @@ public final class TreeFunctions {
|
||||
return Math.max(1.0, v);
|
||||
}
|
||||
|
||||
public static double branchProbability(IrisTreeBranches b, double t, long seed) {
|
||||
double std = Math.max(b.getProbabilityStd(), 1e-6);
|
||||
return switch (b.getProbabilityFunction()) {
|
||||
case CONSTANT -> b.getProbabilityConstant();
|
||||
case LINEAR -> b.getProbabilityBase() + (b.getProbabilityCrown() - b.getProbabilityBase()) * t;
|
||||
case SIGMOID -> 1.0 / (1.0 + Math.exp(-b.getProbabilitySteepness() * (t - b.getProbabilityMidpoint())));
|
||||
case TOP_HEAVY -> Math.pow(t, b.getProbabilityExponent());
|
||||
case GAUSSIAN -> Math.exp(-0.5 * Math.pow((t - b.getProbabilityMean()) / std, 2));
|
||||
case NOISE -> valueNoise1D(t * b.getProbabilityScale(), seed);
|
||||
case BOTTOM_HEAVY -> Math.pow(1.0 - t, b.getProbabilityExponent());
|
||||
case PERIODIC -> b.getProbabilityConstant() * Math.pow(Math.max(0.0, Math.sin(2.0 * Math.PI * t * b.getProbabilityPeriods())), 8);
|
||||
case BAND -> Math.abs(t - b.getProbabilityMean()) <= b.getProbabilityStd() ? b.getProbabilityConstant() : 0.0;
|
||||
case INVERSE_GAUSSIAN -> b.getProbabilityConstant() * (1.0 - Math.exp(-0.5 * Math.pow((t - b.getProbabilityMean()) / std, 2)));
|
||||
case EXPONENTIAL_DECAY -> b.getProbabilityConstant() * Math.exp(-b.getProbabilityExponent() * t);
|
||||
public static double branchProbability(TreeBranches b, double t, long seed) {
|
||||
double std = Math.max(b.probabilityStd(), 1e-6);
|
||||
return switch (b.probabilityFunction()) {
|
||||
case CONSTANT -> b.probabilityConstant();
|
||||
case LINEAR -> b.probabilityBase() + (b.probabilityCrown() - b.probabilityBase()) * t;
|
||||
case SIGMOID -> 1.0 / (1.0 + Math.exp(-b.probabilitySteepness() * (t - b.probabilityMidpoint())));
|
||||
case TOP_HEAVY -> Math.pow(t, b.probabilityExponent());
|
||||
case GAUSSIAN -> Math.exp(-0.5 * Math.pow((t - b.probabilityMean()) / std, 2));
|
||||
case NOISE -> valueNoise1D(t * b.probabilityScale(), seed);
|
||||
case BOTTOM_HEAVY -> Math.pow(1.0 - t, b.probabilityExponent());
|
||||
case PERIODIC -> b.probabilityConstant() * Math.pow(Math.max(0.0, Math.sin(2.0 * Math.PI * t * b.probabilityPeriods())), 8);
|
||||
case BAND -> Math.abs(t - b.probabilityMean()) <= b.probabilityStd() ? b.probabilityConstant() : 0.0;
|
||||
case INVERSE_GAUSSIAN -> b.probabilityConstant() * (1.0 - Math.exp(-0.5 * Math.pow((t - b.probabilityMean()) / std, 2)));
|
||||
case EXPONENTIAL_DECAY -> b.probabilityConstant() * Math.exp(-b.probabilityExponent() * t);
|
||||
};
|
||||
}
|
||||
|
||||
public static double azimuthDegrees(IrisTreeAzimuthMode mode, double t, int index, IrisProceduralTree tree, double constantBase, RNG rng) {
|
||||
public static double azimuthDegrees(TreeAzimuthMode mode, double t, int index, IrisProceduralTree tree, double constantBase, RNG rng) {
|
||||
return switch (mode) {
|
||||
case CONSTANT -> constantBase;
|
||||
case LINEAR -> tree.getAzimuthStart() + (tree.getAzimuthEnd() - tree.getAzimuthStart()) * t;
|
||||
|
||||
@@ -18,13 +18,14 @@
|
||||
|
||||
package art.arcane.iris.engine.object.procedural.tree;
|
||||
|
||||
import art.arcane.iris.engine.object.procedural.tree.IrisTreeProfile;
|
||||
import art.arcane.iris.builtin.objects.tree.TreeProfile;
|
||||
|
||||
|
||||
public final class TreeProfiles {
|
||||
private TreeProfiles() {
|
||||
}
|
||||
|
||||
static double radiusScale(IrisTreeProfile profile) {
|
||||
static double radiusScale(TreeProfile profile) {
|
||||
return switch (profile) {
|
||||
case OAK, DARK_OAK, CHERRY -> 1.0;
|
||||
case BIRCH -> 0.7;
|
||||
@@ -41,7 +42,7 @@ public final class TreeProfiles {
|
||||
};
|
||||
}
|
||||
|
||||
static double[][] fractions(IrisTreeProfile profile) {
|
||||
static double[][] fractions(TreeProfile profile) {
|
||||
return switch (profile) {
|
||||
case OAK -> new double[][]{{0.55, 0.6}, {0.65, 0.9}, {0.75, 1.0}, {0.85, 0.9}, {0.92, 0.65}, {0.98, 0.35}};
|
||||
case BIRCH -> new double[][]{{0.6, 0.45}, {0.7, 0.75}, {0.8, 0.85}, {0.88, 0.75}, {0.94, 0.45}, {0.99, 0.2}};
|
||||
@@ -59,7 +60,7 @@ public final class TreeProfiles {
|
||||
};
|
||||
}
|
||||
|
||||
static double[][] presetLayers(IrisTreeProfile profile, int height, boolean branchDriven) {
|
||||
static double[][] presetLayers(TreeProfile profile, int height, boolean branchDriven) {
|
||||
double scale = radiusScale(profile);
|
||||
int baseRadius = Math.max(3, (int) Math.round(height / 2.0 * scale));
|
||||
double[][] fractions = fractions(profile);
|
||||
|
||||
@@ -18,8 +18,8 @@
|
||||
|
||||
package art.arcane.iris.engine.object.procedural.tree;
|
||||
|
||||
import art.arcane.iris.builtin.objects.tree.TreeRootStyle;
|
||||
import art.arcane.iris.engine.object.procedural.tree.IrisProceduralTree;
|
||||
import art.arcane.iris.engine.object.procedural.tree.IrisTreeRootStyle;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -58,7 +58,7 @@ public final class TreeRootBuilder {
|
||||
}
|
||||
double flare = tree.getRootFlare() > 0 ? tree.getRootFlare() : baseRadius + Math.max(2.0, depth * 0.6);
|
||||
|
||||
IrisTreeRootStyle style = tree.getRootStyle();
|
||||
TreeRootStyle style = tree.getRootStyle();
|
||||
switch (style) {
|
||||
case TAPROOT -> taproot(canvas, cells, cx, cz, baseRadius, depth);
|
||||
case BUTTRESS -> {
|
||||
|
||||
@@ -18,9 +18,9 @@
|
||||
|
||||
package art.arcane.iris.engine.object.procedural.tree;
|
||||
|
||||
import art.arcane.iris.builtin.objects.tree.TreeAzimuthMode;
|
||||
import art.arcane.iris.engine.object.material.IrisMaterialPalette;
|
||||
import art.arcane.iris.engine.object.procedural.tree.IrisProceduralTree;
|
||||
import art.arcane.iris.engine.object.procedural.tree.IrisTreeAzimuthMode;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -164,7 +164,7 @@ public final class TreeTrunkBuilder {
|
||||
double progress = TreeFunctions.curveProgress(tree.getTrunkCurve(), t, tree.getCurveSteepness());
|
||||
double maxReach = height * Math.tan(Math.toRadians(tree.getLeanAngle()));
|
||||
double reach = maxReach * progress;
|
||||
double azDeg = tree.getLeanAzimuthMode() == IrisTreeAzimuthMode.CONSTANT
|
||||
double azDeg = tree.getLeanAzimuthMode() == TreeAzimuthMode.CONSTANT
|
||||
? tree.getLeanAzimuth()
|
||||
: TreeFunctions.azimuthDegrees(tree.getLeanAzimuthMode(), t, -1, tree, tree.getLeanAzimuth(), null);
|
||||
double azRad = Math.toRadians(azDeg);
|
||||
|
||||
Reference in new issue
Block a user