mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-07-01 07:25:51 +00:00
add toggle for legacy rarity calculation
This commit is contained in:
parent
4ef5a7d780
commit
54b7d2e755
@ -26,8 +26,8 @@ import java.util.List;
|
||||
|
||||
public interface IRare {
|
||||
static <T extends IRare> ProceduralStream<T> stream(ProceduralStream<Double> noise, List<T> possibilities) {
|
||||
return ProceduralStream.of((x, z) -> pick(possibilities, noise.get(x, z)),
|
||||
(x, y, z) -> pick(possibilities, noise.get(x, y, z)),
|
||||
return ProceduralStream.of(noise.isLegacyRarity() ? (x, z) -> pickLegacy(possibilities, noise.get(x, z)) : (x, z) -> pick(possibilities, noise.get(x, z)),
|
||||
noise.isLegacyRarity() ? (x, y, z) -> pickLegacy(possibilities, noise.get(x, y, z)) : (x, y, z) -> pick(possibilities, noise.get(x, y, z)),
|
||||
new Interpolated<T>() {
|
||||
@Override
|
||||
public double toDouble(T t) {
|
||||
@ -38,7 +38,7 @@ public interface IRare {
|
||||
public T fromDouble(double d) {
|
||||
return null;
|
||||
}
|
||||
});
|
||||
}).setLegacyRarity(noise.isLegacyRarity());
|
||||
}
|
||||
|
||||
|
||||
|
@ -59,6 +59,9 @@ public class IrisExpression extends IrisRegistrant {
|
||||
@Desc("The expression. Inherited variables are x, y and z. Avoid using those variable names.")
|
||||
private String expression;
|
||||
|
||||
@Desc("Use legacy rarity calculation")
|
||||
private boolean legacyRarity = true;
|
||||
|
||||
private transient AtomicCache<Expression> expressionCache = new AtomicCache<>();
|
||||
private transient AtomicCache<ProceduralStream<Double>> streamCache = new AtomicCache<>();
|
||||
|
||||
@ -99,7 +102,8 @@ public class IrisExpression extends IrisRegistrant {
|
||||
|
||||
public ProceduralStream<Double> stream(RNG rng) {
|
||||
return streamCache.aquire(() -> ProceduralStream.of((x, z) -> evaluate(rng, x, z),
|
||||
(x, y, z) -> evaluate(rng, x, y, z), Interpolated.DOUBLE));
|
||||
(x, y, z) -> evaluate(rng, x, y, z), Interpolated.DOUBLE)
|
||||
.setLegacyRarity(legacyRarity));
|
||||
}
|
||||
|
||||
public double evaluate(RNG rng, double x, double z) {
|
||||
|
@ -62,6 +62,9 @@ public class IrisImageMap {
|
||||
@Desc("Center 0,0 to the center of the image instead of the top left.")
|
||||
private boolean centered = true;
|
||||
|
||||
@Desc("Use legacy rarity calculation")
|
||||
private boolean legacyRarity = true;
|
||||
|
||||
private transient AtomicCache<IrisImage> imageCache = new AtomicCache<IrisImage>();
|
||||
|
||||
public double getNoise(IrisData data, int x, int z) {
|
||||
|
@ -59,7 +59,8 @@ public class IrisStyledRange {
|
||||
}
|
||||
|
||||
public ProceduralStream<Double> stream(RNG rng, IrisData data) {
|
||||
return ProceduralStream.of((x, z) -> get(rng, x, z, data), Interpolated.DOUBLE);
|
||||
return ProceduralStream.of((x, z) -> get(rng, x, z, data), Interpolated.DOUBLE)
|
||||
.setLegacyRarity(style.create(rng, data).isLegacyRarity());
|
||||
}
|
||||
|
||||
public boolean isFlat() {
|
||||
|
@ -524,4 +524,8 @@ public class CNG {
|
||||
public boolean isStatic() {
|
||||
return generator != null && generator.isStatic();
|
||||
}
|
||||
|
||||
public boolean isLegacyRarity() {
|
||||
return generator != null && generator.isLegacyRarity();
|
||||
}
|
||||
}
|
||||
|
@ -44,4 +44,9 @@ public class ExpressionNoise implements NoiseGenerator {
|
||||
public double noise(double x, double y, double z) {
|
||||
return expression.evaluate(rng, x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLegacyRarity() {
|
||||
return expression.isLegacyRarity();
|
||||
}
|
||||
}
|
||||
|
@ -44,4 +44,9 @@ public class ImageNoise implements NoiseGenerator {
|
||||
public double noise(double x, double y, double z) {
|
||||
return noise(x, z + y);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLegacyRarity() {
|
||||
return expression.isLegacyRarity();
|
||||
}
|
||||
}
|
||||
|
@ -36,7 +36,12 @@ public interface NoiseGenerator {
|
||||
return false;
|
||||
}
|
||||
|
||||
default boolean isLegacyRarity() {
|
||||
return false;
|
||||
}
|
||||
|
||||
default ProceduralStream<Double> stream() {
|
||||
return ProceduralStream.of(this::noise, this::noise, Interpolated.DOUBLE);
|
||||
return ProceduralStream.of(this::noise, this::noise, Interpolated.DOUBLE)
|
||||
.setLegacyRarity(isLegacyRarity());
|
||||
}
|
||||
}
|
||||
|
@ -52,4 +52,9 @@ public abstract class BasicStream<T> extends BasicLayer implements ProceduralStr
|
||||
|
||||
@Override
|
||||
public abstract T fromDouble(double d);
|
||||
|
||||
@Override
|
||||
public boolean isLegacyRarity() {
|
||||
return source != null && source.isLegacyRarity();
|
||||
}
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ import java.util.function.Function;
|
||||
|
||||
@SuppressWarnings("ALL")
|
||||
public interface ProceduralStream<T> extends ProceduralLayer, Interpolated<T> {
|
||||
static ProceduralStream<Double> ofDouble(Function2<Double, Double, Double> f) {
|
||||
static FunctionStream<Double> ofDouble(Function2<Double, Double, Double> f) {
|
||||
try {
|
||||
return of(f, Interpolated.DOUBLE);
|
||||
} catch (IncompatibleClassChangeError e) {
|
||||
@ -56,27 +56,27 @@ public interface ProceduralStream<T> extends ProceduralLayer, Interpolated<T> {
|
||||
}
|
||||
}
|
||||
|
||||
static ProceduralStream<Double> ofDouble(Function3<Double, Double, Double, Double> f) {
|
||||
static FunctionStream<Double> ofDouble(Function3<Double, Double, Double, Double> f) {
|
||||
return of(f, Interpolated.DOUBLE);
|
||||
}
|
||||
|
||||
static <T> ProceduralStream<T> of(Function2<Double, Double, T> f, Interpolated<T> helper) {
|
||||
static <T> FunctionStream<T> of(Function2<Double, Double, T> f, Interpolated<T> helper) {
|
||||
return of(f, (x, y, z) -> f.apply(x, z), helper);
|
||||
}
|
||||
|
||||
static <T> ProceduralStream<T> of(Function3<Double, Double, Double, T> f, Interpolated<T> helper) {
|
||||
static <T> FunctionStream<T> of(Function3<Double, Double, Double, T> f, Interpolated<T> helper) {
|
||||
return of((x, z) -> f.apply(x, 0D, z), f, helper);
|
||||
}
|
||||
|
||||
static <T> ProceduralStream<T> of(Function2<Double, Double, T> f, Function3<Double, Double, Double, T> f2, Interpolated<T> helper) {
|
||||
static <T> FunctionStream<T> of(Function2<Double, Double, T> f, Function3<Double, Double, Double, T> f2, Interpolated<T> helper) {
|
||||
return new FunctionStream<>(f, f2, helper);
|
||||
}
|
||||
|
||||
default ProceduralStream<Boolean> chance(double chance) {
|
||||
default FunctionStream<Boolean> chance(double chance) {
|
||||
return of((x, z) -> getDouble(x, z) < chance, Interpolated.BOOLEAN);
|
||||
}
|
||||
|
||||
default ProceduralStream<Boolean> seededChance(RNG brng, long rootSeed, double chance) {
|
||||
default FunctionStream<Boolean> seededChance(RNG brng, long rootSeed, double chance) {
|
||||
RNG rng = brng.nextParallelRNG(rootSeed - 3995L);
|
||||
return of((x, z) -> {
|
||||
double ch = getDouble(x, z);
|
||||
@ -388,7 +388,7 @@ public interface ProceduralStream<T> extends ProceduralLayer, Interpolated<T> {
|
||||
return ProceduralStream.of((x, z) -> {
|
||||
double d = getDouble(x, z);
|
||||
return range.get(rng, d, -d, data);
|
||||
}, Interpolated.DOUBLE);
|
||||
}, Interpolated.DOUBLE).setLegacyRarity(range.getStyle().create(rng, data).isLegacyRarity());
|
||||
}
|
||||
|
||||
default Hunk<T> fastFill2DParallel(int x, int z) {
|
||||
@ -577,4 +577,8 @@ public interface ProceduralStream<T> extends ProceduralLayer, Interpolated<T> {
|
||||
T get(double x, double z);
|
||||
|
||||
T get(double x, double y, double z);
|
||||
|
||||
default boolean isLegacyRarity() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -53,4 +53,8 @@ public class RoundingDoubleStream extends BasicStream<Double> {
|
||||
return round(stream.getDouble(x, y, z));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLegacyRarity() {
|
||||
return stream.isLegacyRarity();
|
||||
}
|
||||
}
|
||||
|
@ -60,4 +60,9 @@ public class AwareConversionStream2D<T, V> extends BasicStream<V> {
|
||||
public V get(double x, double y, double z) {
|
||||
return converter.apply(stream.get(x, y, z), x, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLegacyRarity() {
|
||||
return stream.isLegacyRarity();
|
||||
}
|
||||
}
|
||||
|
@ -62,4 +62,9 @@ public class AwareConversionStream3D<T, V> extends BasicStream<V> {
|
||||
public V get(double x, double y, double z) {
|
||||
return converter.apply(stream.get(x, y, z), x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLegacyRarity() {
|
||||
return stream.isLegacyRarity();
|
||||
}
|
||||
}
|
||||
|
@ -65,4 +65,9 @@ public class CachedConversionStream<T, V> extends BasicLayer implements Procedur
|
||||
public V get(double x, double y, double z) {
|
||||
return cache.computeIfAbsent(stream.get(x, y, z), converter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLegacyRarity() {
|
||||
return stream.isLegacyRarity();
|
||||
}
|
||||
}
|
||||
|
@ -66,4 +66,9 @@ public class ConversionStream<T, V> extends BasicLayer implements ProceduralStre
|
||||
public V get(double x, double y, double z) {
|
||||
return converter.apply(stream.get(x, y, z));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLegacyRarity() {
|
||||
return stream.isLegacyRarity();
|
||||
}
|
||||
}
|
||||
|
@ -49,4 +49,8 @@ public class ForceDoubleStream extends BasicStream<Double> {
|
||||
return stream.getDouble(x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLegacyRarity() {
|
||||
return stream.isLegacyRarity();
|
||||
}
|
||||
}
|
||||
|
@ -52,4 +52,9 @@ public class RoundingStream extends BasicStream<Integer> {
|
||||
public Integer get(double x, double y, double z) {
|
||||
return round(stream.getDouble(x, y, z));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLegacyRarity() {
|
||||
return stream.isLegacyRarity();
|
||||
}
|
||||
}
|
||||
|
@ -66,4 +66,9 @@ public class SelectionStream<T> extends BasicStream<T> {
|
||||
return options[stream.get(x, y, z)];
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLegacyRarity() {
|
||||
return stream.isLegacyRarity();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -82,4 +82,9 @@ public class SignificanceStream<K extends Significance<T>, T> extends BasicStrea
|
||||
public K get(double x, double y, double z) {
|
||||
return get(x, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLegacyRarity() {
|
||||
return stream.isLegacyRarity();
|
||||
}
|
||||
}
|
||||
|
@ -69,4 +69,8 @@ public class CNGStream extends BasicLayer implements ProceduralStream<Double> {
|
||||
return cng.noise((x + getOffsetX()) / getZoom(), (y + getOffsetY()) / getZoom(), (z + getOffsetZ()) * getZoom());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLegacyRarity() {
|
||||
return cng.isLegacyRarity();
|
||||
}
|
||||
}
|
||||
|
@ -27,6 +27,7 @@ public class FunctionStream<T> extends BasicStream<T> {
|
||||
private final Function2<Double, Double, T> f2;
|
||||
private final Function3<Double, Double, Double, T> f3;
|
||||
private final Interpolated<T> helper;
|
||||
private volatile boolean legacyRarity = false;
|
||||
|
||||
public FunctionStream(Function2<Double, Double, T> f2, Function3<Double, Double, Double, T> f3, Interpolated<T> helper) {
|
||||
super();
|
||||
@ -54,4 +55,14 @@ public class FunctionStream<T> extends BasicStream<T> {
|
||||
public T get(double x, double y, double z) {
|
||||
return f3.apply(x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLegacyRarity() {
|
||||
return legacyRarity;
|
||||
}
|
||||
|
||||
public FunctionStream<T> setLegacyRarity(boolean legacyRarity) {
|
||||
this.legacyRarity = legacyRarity;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
@ -81,4 +81,9 @@ public class CachedStream2D<T> extends BasicStream<T> implements ProceduralStrea
|
||||
public boolean isClosed() {
|
||||
return engine.isClosed();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLegacyRarity() {
|
||||
return stream.isLegacyRarity();
|
||||
}
|
||||
}
|
||||
|
@ -79,4 +79,9 @@ public class CachedStream3D<T> extends BasicStream<T> implements ProceduralStrea
|
||||
public boolean isClosed() {
|
||||
return engine.isClosed();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLegacyRarity() {
|
||||
return stream.isLegacyRarity();
|
||||
}
|
||||
}
|
||||
|
@ -62,4 +62,9 @@ public class NullSafeStream<T> extends BasicStream<T> implements ProceduralStrea
|
||||
|
||||
return t;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLegacyRarity() {
|
||||
return stream.isLegacyRarity();
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user