mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-28 00:34:19 +00:00
Move object placement runtime state into the pack runtime
- Keep surface warp generators per seed in the pack runtime - Pass the pack runtime to placement density, surface warp and heightmap sampling - Remove the surface warp cache, its key and the unused replace generator cache - Cover surface warp scoping with engine and standalone runtimes
This commit is contained in:
1 parent
4f084a7d7a
commit
66b4ab8bd2
16 files changed
+63
-89
No files matched your search
+4
-3
@@ -18,6 +18,7 @@
|
||||
|
||||
package art.arcane.iris.generation.mantle;
|
||||
|
||||
import art.arcane.iris.generation.runtime.PackRuntime;
|
||||
import java.io.UncheckedIOException;
|
||||
import art.arcane.iris.pack.loading.IrisData;
|
||||
import art.arcane.iris.generation.runtime.GenerationFailures;
|
||||
@@ -180,7 +181,7 @@ public class MantleFloatingObjectComponent extends IrisMantleComponent {
|
||||
if (placement.isCompatExcluded(data)) {
|
||||
return;
|
||||
}
|
||||
int density = placement.getDensity(rng, minX, minZ, data);
|
||||
int density = placement.getDensity(rng, minX, minZ, PackRuntime.of(getEngineMantle().getEngine(), data));
|
||||
double perAttempt = placement.getChance();
|
||||
for (int i = 0; i < density; i++) {
|
||||
if (!rng.chance(perAttempt + rng.d(-0.005, 0.005))) {
|
||||
@@ -249,7 +250,7 @@ public class MantleFloatingObjectComponent extends IrisMantleComponent {
|
||||
if (placement.isCompatExcluded(data)) {
|
||||
return;
|
||||
}
|
||||
int density = placement.getDensity(rng, minX, minZ, data);
|
||||
int density = placement.getDensity(rng, minX, minZ, PackRuntime.of(getEngineMantle().getEngine(), data));
|
||||
double perAttempt = placement.getChance();
|
||||
|
||||
for (int i = 0; i < density; i++) {
|
||||
@@ -345,7 +346,7 @@ public class MantleFloatingObjectComponent extends IrisMantleComponent {
|
||||
if (placement.isCompatExcluded(data)) {
|
||||
return;
|
||||
}
|
||||
int density = placement.getDensity(rng, minX, minZ, data);
|
||||
int density = placement.getDensity(rng, minX, minZ, PackRuntime.of(getEngineMantle().getEngine(), data));
|
||||
double perAttempt = placement.getChance();
|
||||
|
||||
for (int i = 0; i < density; i++) {
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
package art.arcane.iris.generation.mantle;
|
||||
|
||||
|
||||
import art.arcane.iris.generation.runtime.PackRuntime;
|
||||
import art.arcane.iris.configuration.IrisSettings;
|
||||
import art.arcane.iris.generation.block.B;
|
||||
import art.arcane.iris.generation.cache.Cache;
|
||||
@@ -959,7 +960,7 @@ public class MantleObjectComponent extends IrisMantleComponent {
|
||||
int rejected = 0;
|
||||
int nullObjects = 0;
|
||||
int errors = 0;
|
||||
int density = objectPlacement.getDensity(rng, x, z, getData());
|
||||
int density = objectPlacement.getDensity(rng, x, z, PackRuntime.of(getEngineMantle().getEngine(), getData()));
|
||||
boolean golden = GoldenDebugObjectPlacer.isGoldenDebugChunk(chunkX, chunkZ);
|
||||
|
||||
for (int i = 0; i < density; i++) {
|
||||
@@ -1094,7 +1095,7 @@ public class MantleObjectComponent extends IrisMantleComponent {
|
||||
int errors = 0;
|
||||
int minX = chunkX << 4;
|
||||
int minZ = chunkZ << 4;
|
||||
int density = objectPlacement.getDensity(rng, minX, minZ, getData());
|
||||
int density = objectPlacement.getDensity(rng, minX, minZ, PackRuntime.of(getEngineMantle().getEngine(), getData()));
|
||||
IrisCaveAnchorMode anchorMode = resolveAnchorMode(objectPlacement, caveProfile);
|
||||
if (objectPlacement.getMode() == ObjectPlaceMode.CEILING_HANG) {
|
||||
anchorMode = IrisCaveAnchorMode.CEILING;
|
||||
@@ -1328,7 +1329,7 @@ public class MantleObjectComponent extends IrisMantleComponent {
|
||||
int chunkHeight = getEngineMantle().getEngine().getHeight();
|
||||
int minX = chunkX << 4;
|
||||
int minZ = chunkZ << 4;
|
||||
int density = objectPlacement.getDensity(rng, minX, minZ, getData());
|
||||
int density = objectPlacement.getDensity(rng, minX, minZ, PackRuntime.of(getEngineMantle().getEngine(), getData()));
|
||||
|
||||
for (int i = 0; i < density; i++) {
|
||||
IrisObject v = objectPlacement.scaleObject(rng, objectPlacement.getObject(upperCtx, rng), upperCtx.getDimension());
|
||||
@@ -1734,7 +1735,7 @@ public class MantleObjectComponent extends IrisMantleComponent {
|
||||
@BlockCoordinates
|
||||
private Set<String> guessPlacedKeys(RNG rng, int x, int z, IrisObjectPlacement objectPlacement) {
|
||||
Set<String> f = new KSet<>();
|
||||
for (int i = 0; i < objectPlacement.getDensity(rng, x, z, getData()); i++) {
|
||||
for (int i = 0; i < objectPlacement.getDensity(rng, x, z, PackRuntime.of(getEngineMantle().getEngine(), getData())); i++) {
|
||||
IrisObject v = objectPlacement.scaleObject(rng, objectPlacement.getObject(getComplex(), rng), getDimension());
|
||||
if (v == null) {
|
||||
continue;
|
||||
|
||||
@@ -56,7 +56,7 @@ public final class GenerationCacheWarmer {
|
||||
KList<IrisBiome> biomes = engine.getAllBiomes();
|
||||
biomes.sort(Comparator.comparing(IrisBiome::getLoadKey));
|
||||
for (IrisBiome biome : biomes) {
|
||||
warmPlacements(biome.getObjects(), root, counter, data, engine);
|
||||
warmPlacements(biome.getObjects(), root, counter, runtime);
|
||||
warmDecorators(biome.getDecorators(), engine.getSeedManager().getComponent(), counter, runtime);
|
||||
warmOres(biome.getOres(), engine.getSeedManager().getTerrain(), counter, runtime);
|
||||
collectProcedural(biome.getProceduralObjects(), root, counter, proceduralTasks);
|
||||
@@ -65,7 +65,7 @@ public final class GenerationCacheWarmer {
|
||||
KList<IrisRegion> regions = engine.getDimension().getAllRegions(engine);
|
||||
regions.sort(Comparator.comparing(IrisRegion::getLoadKey));
|
||||
for (IrisRegion region : regions) {
|
||||
warmPlacements(region.getObjects(), root, counter, data, engine);
|
||||
warmPlacements(region.getObjects(), root, counter, runtime);
|
||||
warmOres(region.getOres(), engine.getSeedManager().getTerrain(), counter, runtime);
|
||||
collectProcedural(region.getProceduralObjects(), root, counter, proceduralTasks);
|
||||
}
|
||||
@@ -77,7 +77,7 @@ public final class GenerationCacheWarmer {
|
||||
}
|
||||
|
||||
private static void warmPlacements(KList<IrisObjectPlacement> placements, RNG root, int[] counter,
|
||||
IrisData data, Engine engine) {
|
||||
PackRuntime runtime) {
|
||||
if (placements == null) {
|
||||
return;
|
||||
}
|
||||
@@ -86,8 +86,8 @@ public final class GenerationCacheWarmer {
|
||||
continue;
|
||||
}
|
||||
RNG rng = root.nextParallelRNG(counter[0]++);
|
||||
placement.getSurfaceWarp(rng, data, engine);
|
||||
placement.getDensity(rng, 0, 0, data);
|
||||
placement.getSurfaceWarp(rng, runtime);
|
||||
placement.getDensity(rng, 0, 0, runtime);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -38,6 +38,7 @@ import art.arcane.iris.generation.noise.IrisGeneratorStyle;
|
||||
import art.arcane.iris.generation.noise.IrisNoiseGenerator;
|
||||
import art.arcane.iris.generation.terrain.IrisDimensionCarvingEntry;
|
||||
import art.arcane.iris.generation.terrain.IrisMaterialPalette;
|
||||
import art.arcane.iris.structure.object.IrisObjectPlacement;
|
||||
import art.arcane.iris.pack.loading.IrisData;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
import art.arcane.volmlib.util.noise.CNG;
|
||||
@@ -55,6 +56,7 @@ public final class PackRuntime {
|
||||
private static final int MATERIAL_PALETTE_SEED_CAPACITY = 32;
|
||||
private static final int CARVING_CHILD_SEED_CAPACITY = 8;
|
||||
private static final int ORE_CHANCE_SEED_CAPACITY = 32;
|
||||
private static final int SURFACE_WARP_SEED_CAPACITY = 8;
|
||||
|
||||
private final Engine engine;
|
||||
private final IrisData data;
|
||||
@@ -69,6 +71,8 @@ public final class PackRuntime {
|
||||
entry -> new SeedTable<>(CARVING_CHILD_SEED_CAPACITY, seed -> entry.createChildrenGenerator(seed, this)));
|
||||
private final RuntimeTable<IrisOreGenerator, SeedTable<IrisOreGenerator.OreChance>> oreChances = new RuntimeTable<>(
|
||||
ore -> new SeedTable<>(ORE_CHANCE_SEED_CAPACITY, seed -> ore.createChance(seed, this)));
|
||||
private final RuntimeTable<IrisObjectPlacement, SeedTable<CNG>> surfaceWarps = new RuntimeTable<>(
|
||||
placement -> new SeedTable<>(SURFACE_WARP_SEED_CAPACITY, seed -> placement.createSurfaceWarp(seed, this)));
|
||||
private final RuntimeTable<IrisDecorator, DecoratorRuntime> decorators =
|
||||
new RuntimeTable<>(decorator -> new DecoratorRuntime(decorator, this));
|
||||
private final RuntimeTable<IrisDepositGenerator, DepositRuntime> deposits =
|
||||
@@ -174,6 +178,11 @@ public final class PackRuntime {
|
||||
return oreChances.get(ore).get(seed);
|
||||
}
|
||||
|
||||
/** Object placements warp by the engine's component seed, so a placement keeps one warp generator per seed. */
|
||||
public CNG surfaceWarp(IrisObjectPlacement placement, long seed) {
|
||||
return surfaceWarps.get(placement).get(seed);
|
||||
}
|
||||
|
||||
public DecoratorRuntime decorator(IrisDecorator decorator) {
|
||||
return decorators.get(decorator);
|
||||
}
|
||||
|
||||
@@ -30,19 +30,22 @@ public class HeightmapObjectPlacer implements IObjectPlacer {
|
||||
private final long s;
|
||||
private final IrisObjectPlacement config;
|
||||
private final IObjectPlacer oplacer;
|
||||
private final PackRuntime runtime;
|
||||
|
||||
public HeightmapObjectPlacer(RNG rng, int x, int yv, int z, IrisObjectPlacement config, IObjectPlacer oplacer) {
|
||||
public HeightmapObjectPlacer(RNG rng, int x, int yv, int z, IrisObjectPlacement config, IObjectPlacer oplacer,
|
||||
PackRuntime runtime) {
|
||||
s = rng.nextLong() + yv + z - x;
|
||||
this.config = config;
|
||||
this.oplacer = oplacer;
|
||||
this.runtime = runtime;
|
||||
}
|
||||
|
||||
public int getHighest(int param1Int1, int param1Int2, IrisData data) {
|
||||
return (int) Math.round(config.getHeightmap().getNoise(this.s, param1Int1, param1Int2, PackRuntime.forContext(data)));
|
||||
return (int) Math.round(config.getHeightmap().getNoise(this.s, param1Int1, param1Int2, runtime.scopeFor(data)));
|
||||
}
|
||||
|
||||
public int getHighest(int param1Int1, int param1Int2, IrisData data, boolean param1Boolean) {
|
||||
return (int) Math.round(config.getHeightmap().getNoise(this.s, param1Int1, param1Int2, PackRuntime.forContext(data)));
|
||||
return (int) Math.round(config.getHeightmap().getNoise(this.s, param1Int1, param1Int2, runtime.scopeFor(data)));
|
||||
}
|
||||
|
||||
public void set(int param1Int1, int param1Int2, int param1Int3, NativeBlockState param1BlockData) {
|
||||
|
||||
@@ -44,7 +44,6 @@ import art.arcane.iris.pack.validation.ContentGate;
|
||||
import art.arcane.iris.pack.validation.PackCompatReport;
|
||||
import art.arcane.iris.pack.loading.IrisData;
|
||||
import art.arcane.volmlib.util.cache.AtomicCache;
|
||||
import art.arcane.iris.generation.cache.LazyBoundedCache;
|
||||
import art.arcane.iris.generation.runtime.Engine;
|
||||
import art.arcane.iris.structure.placement.LootResolver;
|
||||
import art.arcane.iris.pack.schema.annotation.ArrayType;
|
||||
@@ -88,11 +87,6 @@ import java.util.function.Function;
|
||||
@Description("Represents an iris object placer. It places objects.")
|
||||
@Data
|
||||
public class IrisObjectPlacement {
|
||||
private static final int SURFACE_WARP_CACHE_SIZE = 8;
|
||||
@Getter(AccessLevel.NONE)
|
||||
@Setter(AccessLevel.NONE)
|
||||
private final transient LazyBoundedCache<SurfaceWarpCacheKey, CNG> surfaceWarpCache =
|
||||
new LazyBoundedCache<>(SURFACE_WARP_CACHE_SIZE);
|
||||
@RegistryListResource(IrisObject.class)
|
||||
@Required
|
||||
@ArrayType(min = 1, type = String.class)
|
||||
@@ -360,19 +354,19 @@ public class IrisObjectPlacement {
|
||||
return p;
|
||||
}
|
||||
|
||||
public CNG getSurfaceWarp(RNG rng, IrisData data) {
|
||||
return getSurfaceWarp(rng, data, data.getEngine());
|
||||
}
|
||||
|
||||
public CNG getSurfaceWarp(RNG rng, IrisData data, @Nullable Engine engine) {
|
||||
/** Engines seed the surface warp from their component seed; engine-less tools use the caller's seed. */
|
||||
public CNG getSurfaceWarp(RNG rng, PackRuntime runtime) {
|
||||
Engine engine = runtime.engine();
|
||||
long seed = engine == null ? rng.getSeed() : engine.getSeedManager().getComponent() + 1024L;
|
||||
SurfaceWarpCacheKey key = new SurfaceWarpCacheKey(data, engine, seed);
|
||||
return surfaceWarpCache.computeIfAbsent(key,
|
||||
ignored -> getWarp().create(new RNG(seed), PackRuntime.of(engine, data)));
|
||||
return runtime.surfaceWarp(this, seed);
|
||||
}
|
||||
|
||||
public double warp(RNG rng, double x, double y, double z, IrisData data) {
|
||||
return getSurfaceWarp(rng, data).fitDouble(-(getWarp().getMultiplier() / 2D), (getWarp().getMultiplier() / 2D), x, y, z);
|
||||
public CNG createSurfaceWarp(long seed, PackRuntime runtime) {
|
||||
return getWarp().create(new RNG(seed), runtime);
|
||||
}
|
||||
|
||||
public double warp(RNG rng, double x, double y, double z, PackRuntime runtime) {
|
||||
return getSurfaceWarp(rng, runtime).fitDouble(-(getWarp().getMultiplier() / 2D), (getWarp().getMultiplier() / 2D), x, y, z);
|
||||
}
|
||||
|
||||
public IrisObject getObject(DataProvider g, RNG random) {
|
||||
@@ -415,12 +409,12 @@ public class IrisObjectPlacement {
|
||||
return densityStyle.getMid();
|
||||
}
|
||||
|
||||
public int getDensity(RNG rng, double x, double z, IrisData data) {
|
||||
public int getDensity(RNG rng, double x, double z, PackRuntime runtime) {
|
||||
if (densityStyle == null) {
|
||||
return density;
|
||||
}
|
||||
|
||||
return (int) Math.round(densityStyle.get(rng, x, z, PackRuntime.forContext(data)));
|
||||
return (int) Math.round(densityStyle.get(rng, x, z, runtime));
|
||||
}
|
||||
|
||||
private TableCache getCache(IrisData manager) {
|
||||
@@ -516,36 +510,6 @@ public class IrisObjectPlacement {
|
||||
return null;
|
||||
}
|
||||
|
||||
private static final class SurfaceWarpCacheKey {
|
||||
private final IrisData data;
|
||||
private final Engine engine;
|
||||
private final long seed;
|
||||
|
||||
private SurfaceWarpCacheKey(IrisData data, Engine engine, long seed) {
|
||||
this.data = data;
|
||||
this.engine = engine;
|
||||
this.seed = seed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object other) {
|
||||
if (this == other) {
|
||||
return true;
|
||||
}
|
||||
if (!(other instanceof SurfaceWarpCacheKey key)) {
|
||||
return false;
|
||||
}
|
||||
return data == key.data && engine == key.engine && seed == key.seed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = System.identityHashCode(data);
|
||||
result = 31 * result + System.identityHashCode(engine);
|
||||
return 31 * result + Long.hashCode(seed);
|
||||
}
|
||||
}
|
||||
|
||||
private static class TableCache {
|
||||
final transient WeightedTables global = new WeightedTables();
|
||||
final transient KMap<Material, WeightedTables> basic = new KMap<>();
|
||||
|
||||
@@ -50,7 +50,6 @@ import java.util.Map;
|
||||
@Description("Find and replace object materials")
|
||||
@Data
|
||||
public class IrisObjectReplace {
|
||||
private final transient AtomicCache<CNG> replaceGen = new AtomicCache<>();
|
||||
private final transient AtomicCache<KList<NativeBlockState>> findData = new AtomicCache<>();
|
||||
private final transient AtomicCache<KList<NativeBlockState>> replaceData = new AtomicCache<>();
|
||||
@ArrayType(min = 1, type = IrisBlockData.class)
|
||||
|
||||
@@ -44,7 +44,7 @@ final class ObjectBlockPass {
|
||||
void process() {
|
||||
boolean warped = !state.config.getWarp().isFlat();
|
||||
boolean hasEdits = !state.config.getEdit().isEmpty();
|
||||
CNG surfaceWarp = warped ? state.config.getSurfaceWarp(context.rng, context.self.getLoader()) : null;
|
||||
CNG surfaceWarp = warped ? state.config.getSurfaceWarp(context.rng, context.runtime.scopeFor(context.self.getLoader())) : null;
|
||||
double warpHalf = warped ? state.config.getWarp().getMultiplier() / 2D : 0D;
|
||||
boolean waterlogCandidate = state.config.isWaterloggable() || state.config.isUnderwater();
|
||||
double[] exact = warped || hasEdits ? bake.exact(context.self, state.spin) : null;
|
||||
|
||||
+2
-1
@@ -1,5 +1,6 @@
|
||||
package art.arcane.iris.structure.object;
|
||||
|
||||
import art.arcane.iris.generation.runtime.PackRuntime;
|
||||
import art.arcane.iris.generation.block.B;
|
||||
|
||||
import art.arcane.iris.generation.runtime.Engine;
|
||||
@@ -38,7 +39,7 @@ final class PlacementModuleNativeStructureProtection implements PlacementModule
|
||||
int z = context.z;
|
||||
var bounds = state.bounds;
|
||||
var projection = state.paintProjection;
|
||||
var surfaceWarp = config.getWarp().isFlat() ? null : config.getSurfaceWarp(context.rng, self.getLoader());
|
||||
var surfaceWarp = config.getWarp().isFlat() ? null : config.getSurfaceWarp(context.rng, context.runtime.scopeFor(self.getLoader()));
|
||||
double warpHalf = config.getWarp().isFlat() ? 0 : config.getWarp().getMultiplier() / 2D;
|
||||
int randomY = state.yrand;
|
||||
Engine engine = placer.getEngine();
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package art.arcane.iris.structure.object;
|
||||
|
||||
import art.arcane.iris.generation.runtime.PackRuntime;
|
||||
import art.arcane.iris.generation.geometry.IrisBlockVector;
|
||||
import art.arcane.volmlib.util.collection.KList;
|
||||
import art.arcane.volmlib.util.noise.CNG;
|
||||
@@ -40,7 +41,7 @@ public final class PlacementModulePaint implements PlacementModule {
|
||||
state.reject("paint-projection");
|
||||
return;
|
||||
}
|
||||
var warp = state.config.getWarp().isFlat() ? null : state.config.getSurfaceWarp(context.rng, context.self.getLoader());
|
||||
var warp = state.config.getWarp().isFlat() ? null : state.config.getSurfaceWarp(context.rng, context.runtime.scopeFor(context.self.getLoader()));
|
||||
double half = state.config.getWarp().isFlat() ? 0 : state.config.getWarp().getMultiplier() / 2D;
|
||||
state.paintSupport = transformedPaintSupport(context.self, state.spin, state.translateOffset, warp, half,
|
||||
context.x, state.y + state.yrand, context.z);
|
||||
|
||||
@@ -14,7 +14,7 @@ final class PlacementModulePreparation implements PlacementModule {
|
||||
lifecycle.add(PLACER, PlacementStage.PREPARE, (context, state, ignored) -> {
|
||||
if (state.config.getHeightmap() != null) {
|
||||
state.placer = new HeightmapObjectPlacer(context.rng, context.x, context.yv, context.z,
|
||||
state.config, context.placer);
|
||||
state.config, context.placer, context.runtime);
|
||||
}
|
||||
});
|
||||
lifecycle.add(TRANSFORMS, PlacementStage.PREPARE, PlacementModulePreparation::prepare,
|
||||
|
||||
@@ -244,7 +244,7 @@ public final class PlacementModuleStilt implements PlacementModule {
|
||||
boolean hasEdits = !config.getEdit().isEmpty();
|
||||
boolean warped = !config.getWarp().isFlat();
|
||||
boolean waterlogCandidate = config.isWaterloggable() || config.isUnderwater();
|
||||
CNG surfaceWarp = warped ? config.getSurfaceWarp(rng, self.getLoader()) : null;
|
||||
CNG surfaceWarp = warped ? config.getSurfaceWarp(rng, context.runtime.scopeFor(self.getLoader())) : null;
|
||||
double warpHalf = warped ? config.getWarp().getMultiplier() / 2D : 0D;
|
||||
double[] exact = warped || hasEdits || eroding ? bake.exact(self, state.spin) : null;
|
||||
int count = bake.count();
|
||||
|
||||
@@ -196,8 +196,6 @@ public class PackRuntimeStateGateTest {
|
||||
);
|
||||
|
||||
private static final List<Entry> PENDING_MIGRATION = List.of(
|
||||
pending("art.arcane.iris.structure.object.IrisObjectPlacement", "surfaceWarpCache", Kind.RUNTIME),
|
||||
pending("art.arcane.iris.structure.object.IrisObjectReplace", "replaceGen", Kind.RUNTIME),
|
||||
pending("art.arcane.iris.world.entity.IrisEffect", "latch", Kind.RUNTIME),
|
||||
pending("art.arcane.iris.generation.bake.ChunkBakeCache", "recent", Kind.THREAD),
|
||||
pending("art.arcane.iris.generation.hydrology.engine.HydrologyRuntime", "last", Kind.THREAD),
|
||||
@@ -223,7 +221,6 @@ public class PackRuntimeStateGateTest {
|
||||
pending("art.arcane.iris.world.history.TransitionBandIndex", "lastRegion", Kind.THREAD),
|
||||
pending("art.arcane.iris.world.history.TransitionBoundarySampler", "cache", Kind.THREAD),
|
||||
pending("art.arcane.iris.world.history.TransitionDisplacementField", "local", Kind.THREAD),
|
||||
pending("art.arcane.iris.structure.object.IrisObjectPlacement$SurfaceWarpCacheKey", "engine", Kind.RUNTIME),
|
||||
pending("art.arcane.iris.generation.bake.ChunkBakeCache", "SPARSE", Kind.SCRATCH),
|
||||
pending("art.arcane.iris.generation.context.IrisContext", "OVERFLOW", Kind.SCRATCH),
|
||||
pending("art.arcane.iris.generation.decoration.DecoratorCore", "SCRATCH_OPTS", Kind.SCRATCH),
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package art.arcane.iris.structure.object;
|
||||
|
||||
import art.arcane.iris.generation.runtime.PackRuntime;
|
||||
import art.arcane.iris.generation.runtime.Engine;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
import org.junit.Test;
|
||||
@@ -15,11 +16,11 @@ public class HeightmapObjectPlacerTest {
|
||||
Engine engine = mock(Engine.class);
|
||||
IObjectPlacer ownedDelegate = mock(IObjectPlacer.class);
|
||||
when(ownedDelegate.getEngine()).thenReturn(engine);
|
||||
HeightmapObjectPlacer owned = new HeightmapObjectPlacer(mock(RNG.class), 1, 2, 3, new IrisObjectPlacement(), ownedDelegate);
|
||||
HeightmapObjectPlacer owned = new HeightmapObjectPlacer(mock(RNG.class), 1, 2, 3, new IrisObjectPlacement(), ownedDelegate, PackRuntime.standalone(null));
|
||||
assertSame(engine, owned.getEngine());
|
||||
|
||||
IObjectPlacer unownedDelegate = mock(IObjectPlacer.class);
|
||||
HeightmapObjectPlacer unowned = new HeightmapObjectPlacer(mock(RNG.class), 1, 2, 3, new IrisObjectPlacement(), unownedDelegate);
|
||||
HeightmapObjectPlacer unowned = new HeightmapObjectPlacer(mock(RNG.class), 1, 2, 3, new IrisObjectPlacement(), unownedDelegate, PackRuntime.standalone(null));
|
||||
assertNull(unowned.getEngine());
|
||||
}
|
||||
}
|
||||
+2
-1
@@ -1,5 +1,6 @@
|
||||
package art.arcane.iris.structure.object;
|
||||
|
||||
import art.arcane.iris.testsupport.MockPackData;
|
||||
import art.arcane.iris.generation.terrain.IrisSlopeClip;
|
||||
|
||||
import art.arcane.iris.generation.noise.IrisNoiseGenerator;
|
||||
@@ -74,7 +75,7 @@ public class IrisObjectPlacementLifecycleRegressionTest {
|
||||
|
||||
engine = mock(Engine.class);
|
||||
when(engine.getHeight()).thenReturn(256);
|
||||
data = mock(IrisData.class);
|
||||
data = MockPackData.create();
|
||||
when(data.getEngine()).thenReturn(engine);
|
||||
solid = state("minecraft:stone", true);
|
||||
schematicAir = state("minecraft:air", false);
|
||||
|
||||
+10
-14
@@ -1,5 +1,6 @@
|
||||
package art.arcane.iris.structure.object;
|
||||
|
||||
import art.arcane.iris.generation.runtime.PackRuntime;
|
||||
import art.arcane.iris.testsupport.MockPackData;
|
||||
import art.arcane.iris.generation.noise.IrisGeneratorStyle;
|
||||
import art.arcane.iris.generation.noise.NoiseStyle;
|
||||
@@ -11,8 +12,6 @@ import art.arcane.volmlib.util.noise.CNG;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
import static org.junit.Assert.assertNotSame;
|
||||
import static org.junit.Assert.assertSame;
|
||||
import static org.mockito.Mockito.mock;
|
||||
@@ -21,29 +20,26 @@ import static org.mockito.Mockito.when;
|
||||
public class IrisObjectPlacementSurfaceWarpCacheTest {
|
||||
@Test
|
||||
public void surfaceWarpSeparatesEngineSeeds() {
|
||||
Engine first = engine(100L);
|
||||
Engine second = engine(200L);
|
||||
AtomicReference<Engine> active = new AtomicReference<>(first);
|
||||
IrisData data = MockPackData.create();
|
||||
when(data.getEngine()).thenAnswer(ignored -> active.get());
|
||||
PackRuntime first = PackRuntime.forEngine(engine(100L), data);
|
||||
PackRuntime second = PackRuntime.forEngine(engine(200L), data);
|
||||
IrisObjectPlacement placement = placement();
|
||||
|
||||
CNG firstWarp = placement.getSurfaceWarp(new RNG(1L), data);
|
||||
assertSame(firstWarp, placement.getSurfaceWarp(new RNG(999L), data));
|
||||
active.set(second);
|
||||
CNG firstWarp = placement.getSurfaceWarp(new RNG(1L), first);
|
||||
assertSame(firstWarp, placement.getSurfaceWarp(new RNG(999L), first));
|
||||
|
||||
assertNotSame(firstWarp, placement.getSurfaceWarp(new RNG(1L), data));
|
||||
assertNotSame(firstWarp, placement.getSurfaceWarp(new RNG(1L), second));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void standaloneSurfaceWarpUsesSuppliedSeed() {
|
||||
IrisData data = MockPackData.create();
|
||||
PackRuntime runtime = PackRuntime.standalone(MockPackData.create());
|
||||
IrisObjectPlacement placement = placement();
|
||||
|
||||
CNG first = placement.getSurfaceWarp(new RNG(1L), data);
|
||||
CNG first = placement.getSurfaceWarp(new RNG(1L), runtime);
|
||||
|
||||
assertSame(first, placement.getSurfaceWarp(new RNG(1L), data));
|
||||
assertNotSame(first, placement.getSurfaceWarp(new RNG(2L), data));
|
||||
assertSame(first, placement.getSurfaceWarp(new RNG(1L), runtime));
|
||||
assertNotSame(first, placement.getSurfaceWarp(new RNG(2L), runtime));
|
||||
}
|
||||
|
||||
private IrisObjectPlacement placement() {
|
||||
|
||||
Reference in new issue
Block a user