mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-12-01 18:24:06 +00:00
Stop rescaling the cached style generator for continents and child biomes
IrisGeneratorStyle.create returns a generator cached per data and engine, and baking and scaling it in place applied the continent zoom and child scale again whenever a complex was rebuilt against the same data. Continents and child biomes now scale a fresh generator, and the continent assembly shared by IrisComplex and UpperDimensionContext lives in ContinentGenerator. Upstream:41664fc60d80fcedd9a0aa62b8cb7e6259a00b6ac19fa5bffa6eb0f07dfb7a8789644b93bda770650ba4708f2ba9df19caecf7ebcece0d16f8e575c4f7bb52700dc53551544c34f499cc2383d
This commit is contained in:
1 parent
a81a3abb9f
commit
b9d8125180
6 files changed
+136
-6
No files matched your search
@@ -0,0 +1,26 @@
|
||||
package art.arcane.iris.engine;
|
||||
|
||||
import art.arcane.iris.core.loader.IrisData;
|
||||
import art.arcane.iris.engine.object.world.dimension.IrisDimension;
|
||||
import art.arcane.iris.util.project.noise.CNG;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
|
||||
public final class ContinentGenerator {
|
||||
private static final int CONTINENT_SEED_SALT = 234234565;
|
||||
|
||||
private ContinentGenerator() {
|
||||
}
|
||||
|
||||
public static CNG create(IrisDimension dimension, RNG parentSeedSource, IrisData packData) {
|
||||
return dimension.getContinentalStyle()
|
||||
.createScaledGenerator(deriveContinentSeed(parentSeedSource), packData, inverseContinentZoom(dimension));
|
||||
}
|
||||
|
||||
static RNG deriveContinentSeed(RNG parentSeedSource) {
|
||||
return parentSeedSource.nextParallelRNG(CONTINENT_SEED_SALT);
|
||||
}
|
||||
|
||||
private static double inverseContinentZoom(IrisDimension dimension) {
|
||||
return 1D / dimension.getContinentZoom();
|
||||
}
|
||||
}
|
||||
@@ -248,8 +248,7 @@ public class IrisComplex implements DataProvider {
|
||||
inferredStreams.put(InferredType.SHORE, shoreBiomeStream);
|
||||
bridgeStream = focusBiome != null ? ProceduralStream.of((x, z) -> focusBiome.getInferredType(),
|
||||
Interpolated.of(a -> 0D, a -> focusBiome.getInferredType())) :
|
||||
engine.getDimension().getContinentalStyle().create(rng.nextParallelRNG(234234565), getData())
|
||||
.bake().scale(1D / engine.getDimension().getContinentZoom()).bake().stream()
|
||||
ContinentGenerator.create(engine.getDimension(), rng, getData()).stream()
|
||||
.convert((v) -> v >= engine.getDimension().getLandChance() ? InferredType.SEA : InferredType.LAND)
|
||||
.cache2D("bridgeStream", engine, cacheSize);
|
||||
ProceduralStream<IrisBiome> proceduralBaseBiomeStream = focusBiome != null ? ProceduralStream.of((x, z) -> implode(focusBiome, x, z),
|
||||
|
||||
@@ -166,9 +166,7 @@ public class UpperDimensionContext implements DataProvider {
|
||||
inferredStreams.put(InferredType.SEA, seaBiomeStream);
|
||||
inferredStreams.put(InferredType.SHORE, shoreBiomeStream);
|
||||
|
||||
ProceduralStream<InferredType> bridgeStream = upperDim.getContinentalStyle()
|
||||
.create(rng.nextParallelRNG(234234565), upperData)
|
||||
.bake().scale(1D / upperDim.getContinentZoom()).bake().stream()
|
||||
ProceduralStream<InferredType> bridgeStream = ContinentGenerator.create(upperDim, rng, upperData).stream()
|
||||
.convert(v -> v >= upperDim.getLandChance() ? InferredType.SEA : InferredType.LAND);
|
||||
|
||||
ProceduralStream<IrisBiome> proceduralBaseBiomeStream = bridgeStream
|
||||
|
||||
@@ -104,6 +104,10 @@ public class IrisGeneratorStyle {
|
||||
return createNoCache(rng, data, false, 0, false, resolveEngine(data));
|
||||
}
|
||||
|
||||
public CNG createScaledGenerator(RNG rng, IrisData data, double scaleFactor) {
|
||||
return createNoCache(rng, data).bake().scale(scaleFactor).bake();
|
||||
}
|
||||
|
||||
public CNG createForPrebake(RNG rng, IrisData data, int fallbackCacheSize) {
|
||||
return createNoCache(rng, data, false, Math.max(0, fallbackCacheSize), true, resolveEngine(data));
|
||||
}
|
||||
|
||||
@@ -73,6 +73,7 @@ import java.util.Objects;
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class IrisBiome extends IrisRegistrant implements IRare {
|
||||
private static final int BIOME_GENERATOR_CACHE_SIZE = 8;
|
||||
private static final int CHILDREN_SEED_SALT = 2137;
|
||||
|
||||
private final transient AtomicCache<KMap<String, IrisBiomeGeneratorLink>> genCache = new AtomicCache<>();
|
||||
private final transient AtomicCache<KMap<String, Integer>> genCacheMax = new AtomicCache<>();
|
||||
@@ -296,7 +297,7 @@ public class IrisBiome extends IrisRegistrant implements IRare {
|
||||
|
||||
public CNG getChildrenGenerator(RNG random, int sig, double scale) {
|
||||
double childScale = getChildStyle().isSeeded() ? 1 : scale;
|
||||
return childrenCell.aquire(() -> getChildStyle().create(random.nextParallelRNG(sig * 2137), getLoader()).bake().scale(childScale).bake());
|
||||
return childrenCell.aquire(() -> getChildStyle().createScaledGenerator(random.nextParallelRNG(sig * CHILDREN_SEED_SALT), getLoader(), childScale));
|
||||
}
|
||||
|
||||
public boolean isLand() {
|
||||
|
||||
Reference in new issue
Block a user