mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-04-07 08:16:31 +00:00
Insane Loader Propagation
This commit is contained in:
@@ -304,11 +304,11 @@ public class IrisBiome extends IrisRegistrant implements IRare {
|
||||
|
||||
public CNG getBiomeGenerator(RNG random) {
|
||||
return biomeGenerator.aquire(() ->
|
||||
biomeStyle.create(random.nextParallelRNG(213949 + 228888 + getRarity() + getName().length())));
|
||||
biomeStyle.create(random.nextParallelRNG(213949 + 228888 + getRarity() + getName().length()), getLoader()));
|
||||
}
|
||||
|
||||
public CNG getChildrenGenerator(RNG random, int sig, double scale) {
|
||||
return childrenCell.aquire(() -> getChildStyle().create(random.nextParallelRNG(sig * 2137)).bake().scale(scale).bake());
|
||||
return childrenCell.aquire(() -> getChildStyle().create(random.nextParallelRNG(sig * 2137), getLoader()).bake().scale(scale).bake());
|
||||
}
|
||||
|
||||
public KList<BlockData> generateLayers(double wx, double wz, RNG random, int maxDepth, int height, IrisData rdata, IrisComplex complex) {
|
||||
|
||||
@@ -90,7 +90,7 @@ public class IrisBiomePaletteLayer {
|
||||
return layerGenerator.aquire(() ->
|
||||
{
|
||||
RNG rngx = rng.nextParallelRNG(minHeight + maxHeight + getBlockData(data).size());
|
||||
return style.create(rngx);
|
||||
return style.create(rngx, data);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package com.volmit.iris.engine.object;
|
||||
|
||||
import com.volmit.iris.core.project.loader.IrisData;
|
||||
import com.volmit.iris.engine.cache.AtomicCache;
|
||||
import com.volmit.iris.engine.interpolation.IrisInterpolation;
|
||||
import com.volmit.iris.engine.noise.CNG;
|
||||
@@ -68,30 +69,30 @@ public class IrisCarveLayer {
|
||||
private final transient AtomicCache<ProceduralStream<Double>> rawStreamCache = new AtomicCache<>();
|
||||
private final transient AtomicCache<CNG> cng = new AtomicCache<>();
|
||||
|
||||
public boolean isCarved(RNG rng, double x, double y, double z) {
|
||||
public boolean isCarved(RNG rng, IrisData data, double x, double y, double z) {
|
||||
if (y > getMaxHeight() || y < getMinHeight()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
double opacity = Math.pow(IrisInterpolation.sinCenter(M.lerpInverse(getMinHeight(), getMaxHeight(), y)), 4);
|
||||
return getCng(rng).fitDouble(0D, 1D, x, y, z) * opacity > getThreshold();
|
||||
return getCng(rng, data).fitDouble(0D, 1D, x, y, z) * opacity > getThreshold();
|
||||
}
|
||||
|
||||
public ProceduralStream<Boolean> stream(RNG rng) {
|
||||
return streamCache.aquire(() -> ProceduralStream.of((x, y, z) -> isCarved(rng, x, y, z), Interpolated.BOOLEAN));
|
||||
public ProceduralStream<Boolean> stream(RNG rng, IrisData data) {
|
||||
return streamCache.aquire(() -> ProceduralStream.of((x, y, z) -> isCarved(rng, data, x, y, z), Interpolated.BOOLEAN));
|
||||
}
|
||||
|
||||
public ProceduralStream<Double> rawStream(RNG rng) {
|
||||
public ProceduralStream<Double> rawStream(RNG rng, IrisData data) {
|
||||
return rawStreamCache.aquire(() -> ProceduralStream.of((x, y, z) -> {
|
||||
return getCng(rng).fitDouble(0D, 1D, x, y, z) * Math.pow(IrisInterpolation.sinCenter(M.lerpInverse(getMinHeight(), getMaxHeight(), y)), 4);
|
||||
return getCng(rng, data).fitDouble(0D, 1D, x, y, z) * Math.pow(IrisInterpolation.sinCenter(M.lerpInverse(getMinHeight(), getMaxHeight(), y)), 4);
|
||||
}, Interpolated.DOUBLE));
|
||||
}
|
||||
|
||||
public CNG getCng(RNG rng) {
|
||||
return cng.aquire(() -> getStyle().create(rng.nextParallelRNG(-2340 * getMaxHeight() * getMinHeight())));
|
||||
public CNG getCng(RNG rng, IrisData data) {
|
||||
return cng.aquire(() -> getStyle().create(rng.nextParallelRNG(-2340 * getMaxHeight() * getMinHeight()), data));
|
||||
}
|
||||
|
||||
public boolean isCarved2(RNG rng, double x, double y, double z) {
|
||||
public boolean isCarved2(RNG rng, IrisData data, double x, double y, double z) {
|
||||
if (y > getMaxHeight() || y < getMinHeight()) {
|
||||
return false;
|
||||
}
|
||||
@@ -105,6 +106,6 @@ public class IrisCarveLayer {
|
||||
opacity = IrisInterpolation.bezier(1D - M.lerpInverse(maxHeight - innerRange, getMaxHeight(), y));
|
||||
}
|
||||
|
||||
return cng.aquire(() -> getStyle().create(rng.nextParallelRNG(-2340 * getMaxHeight() * getMinHeight()))).fitDouble(0D, 1D, x, y, z) * opacity > getThreshold();
|
||||
return cng.aquire(() -> getStyle().create(rng.nextParallelRNG(-2340 * getMaxHeight() * getMinHeight()), data)).fitDouble(0D, 1D, x, y, z) * opacity > getThreshold();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package com.volmit.iris.engine.object;
|
||||
|
||||
import com.volmit.iris.core.project.loader.IrisData;
|
||||
import com.volmit.iris.engine.cache.AtomicCache;
|
||||
import com.volmit.iris.engine.object.annotations.Desc;
|
||||
import com.volmit.iris.engine.object.annotations.MaxNumber;
|
||||
@@ -49,17 +50,17 @@ public class IrisCavernZone implements IRare {
|
||||
|
||||
private transient AtomicCache<ProceduralStream<Boolean>> carveCache = new AtomicCache<>();
|
||||
|
||||
public boolean isCarved(RNG rng, double xx, double yy, double zz) {
|
||||
public boolean isCarved(RNG rng, IrisData data, double xx, double yy, double zz) {
|
||||
if (carver != null) {
|
||||
return carver.isCarved(rng, xx, yy, zz);
|
||||
return carver.isCarved(rng, data, xx, yy, zz);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public double getCarved(RNG rng, double xx, double yy, double zz) {
|
||||
public double getCarved(RNG rng, IrisData data, double xx, double yy, double zz) {
|
||||
if (carver != null) {
|
||||
return carver.rawStream(rng).get(xx, yy, zz) / (carver.getThreshold() * 2);
|
||||
return carver.rawStream(rng, data).get(xx, yy, zz) / (carver.getThreshold() * 2);
|
||||
}
|
||||
|
||||
return -1;
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package com.volmit.iris.engine.object;
|
||||
|
||||
import com.volmit.iris.core.project.loader.IrisData;
|
||||
import com.volmit.iris.engine.cache.AtomicCache;
|
||||
import com.volmit.iris.engine.object.annotations.ArrayType;
|
||||
import com.volmit.iris.engine.object.annotations.Desc;
|
||||
@@ -58,8 +59,8 @@ public class IrisCaverns {
|
||||
private transient AtomicCache<ProceduralStream<IrisCavernZone>> zonesRarity = new AtomicCache<>();
|
||||
private transient AtomicCache<ProceduralStream<Double>> streamCache = new AtomicCache<>();
|
||||
|
||||
public IrisCavernZone getZone(double x, double y, double z, RNG rng) {
|
||||
return zonesRarity.aquire(() -> zoneStyle.create(rng)
|
||||
public IrisCavernZone getZone(double x, double y, double z, RNG rng, IrisData data) {
|
||||
return zonesRarity.aquire(() -> zoneStyle.create(rng, data)
|
||||
.stream().selectRarity(getZones())).get(x, y, z);
|
||||
}
|
||||
|
||||
@@ -67,26 +68,26 @@ public class IrisCaverns {
|
||||
return 0.5;
|
||||
}
|
||||
|
||||
public ProceduralStream<Double> stream(RNG rng) {
|
||||
public ProceduralStream<Double> stream(RNG rng, IrisData data) {
|
||||
if (preThresholdInterpolation) {
|
||||
return streamCache.aquire(() -> ProceduralStream.of((xx, yy, zz)
|
||||
-> (getZone(xx, yy, zz, rng)
|
||||
.getCarved(rng, xx, yy, zz)), Interpolated.DOUBLE)
|
||||
-> (getZone(xx, yy, zz, rng, data)
|
||||
.getCarved(rng, data, xx, yy, zz)), Interpolated.DOUBLE)
|
||||
.cache3D(65535));
|
||||
}
|
||||
|
||||
return streamCache.aquire(() -> ProceduralStream.of((xx, yy, zz)
|
||||
-> (getZone(xx, yy, zz, rng)
|
||||
.isCarved(rng, xx, yy, zz) ? 1D : 0D), Interpolated.DOUBLE)
|
||||
-> (getZone(xx, yy, zz, rng, data)
|
||||
.isCarved(rng, data, xx, yy, zz) ? 1D : 0D), Interpolated.DOUBLE)
|
||||
.cache3D(65535));
|
||||
}
|
||||
|
||||
public boolean isCavern(RNG rng, double x, double y, double z, double height) {
|
||||
public boolean isCavern(RNG rng, double x, double y, double z, double height, IrisData data) {
|
||||
if (zones.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return getInterpolator().interpolate(x, y, z, (xx, yy, zz)
|
||||
-> stream(rng).get(xx, yy, zz)) > threshold(height);
|
||||
-> stream(rng, data).get(xx, yy, zz)) > threshold(height);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -108,18 +108,17 @@ public class IrisDecorator {
|
||||
|
||||
public CNG getHeightGenerator(RNG rng, IrisData data) {
|
||||
return heightGenerator.aquire(() ->
|
||||
heightVariance.create(rng.nextParallelRNG(getBlockData(data).size() + stackMax + stackMin)));
|
||||
heightVariance.create(rng.nextParallelRNG(getBlockData(data).size() + stackMax + stackMin), data));
|
||||
}
|
||||
|
||||
public CNG getGenerator(RNG rng, IrisData data) {
|
||||
return layerGenerator.aquire(() -> style.create(rng.nextParallelRNG(getBlockData(data).size())));
|
||||
return layerGenerator.aquire(() -> style.create(rng.nextParallelRNG(getBlockData(data).size()), data));
|
||||
}
|
||||
|
||||
public CNG getVarianceGenerator(RNG rng, IrisData data) {
|
||||
return varianceGenerator.aquire(() ->
|
||||
variance.create(
|
||||
rng.nextParallelRNG(getBlockData(data).size()))
|
||||
|
||||
rng.nextParallelRNG(getBlockData(data).size()), data)
|
||||
.scale(1D / variance.getZoom()));
|
||||
}
|
||||
|
||||
|
||||
@@ -326,10 +326,10 @@ public class IrisDimension extends IrisRegistrant {
|
||||
return rad.aquire(() -> Math.toRadians(dimensionAngleDeg));
|
||||
}
|
||||
|
||||
public boolean isCarved(int x, int y, int z, RNG rng, int terrainHeight) {
|
||||
public boolean isCarved(IrisData data, int x, int y, int z, RNG rng, int terrainHeight) {
|
||||
if (isCarving() && terrainHeight > getFluidHeight() || y < terrainHeight) {
|
||||
for (IrisCarveLayer j : getCarveLayers()) {
|
||||
if (j.isCarved(rng, x, y, z)) {
|
||||
if (j.isCarved(rng, data, x, y, z)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -95,7 +95,7 @@ public class IrisExpression extends IrisRegistrant {
|
||||
double[] g = new double[3 + getVariables().size()];
|
||||
int m = 0;
|
||||
for (IrisExpressionLoad i : getVariables()) {
|
||||
g[m++] = i.getValue(rng, x, z);
|
||||
g[m++] = i.getValue(rng, getLoader(), x, z);
|
||||
}
|
||||
|
||||
g[m++] = x;
|
||||
@@ -109,7 +109,7 @@ public class IrisExpression extends IrisRegistrant {
|
||||
double[] g = new double[3 + getVariables().size()];
|
||||
int m = 0;
|
||||
for (IrisExpressionLoad i : getVariables()) {
|
||||
g[m++] = i.getValue(rng, x, y, z);
|
||||
g[m++] = i.getValue(rng, getLoader(), x, y, z);
|
||||
}
|
||||
|
||||
g[m++] = x;
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package com.volmit.iris.engine.object;
|
||||
|
||||
import com.volmit.iris.core.project.loader.IrisData;
|
||||
import com.volmit.iris.engine.object.annotations.Desc;
|
||||
import com.volmit.iris.engine.object.annotations.Required;
|
||||
import com.volmit.iris.util.math.RNG;
|
||||
@@ -45,17 +46,17 @@ public class IrisExpressionLoad {
|
||||
@Desc("If defined, this variable will use a generator style as it's result")
|
||||
private IrisGeneratorStyle styleValue = null;
|
||||
|
||||
public double getValue(RNG rng, double x, double z) {
|
||||
public double getValue(RNG rng, IrisData data, double x, double z) {
|
||||
if (styleValue != null) {
|
||||
return styleValue.create(rng).noise(x, z);
|
||||
return styleValue.create(rng, data).noise(x, z);
|
||||
}
|
||||
|
||||
return staticValue;
|
||||
}
|
||||
|
||||
public double getValue(RNG rng, double x, double y, double z) {
|
||||
public double getValue(RNG rng, IrisData data, double x, double y, double z) {
|
||||
if (styleValue != null) {
|
||||
return styleValue.create(rng).noise(x, y, z);
|
||||
return styleValue.create(rng, data).noise(x, y, z);
|
||||
}
|
||||
|
||||
return staticValue;
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
package com.volmit.iris.engine.object;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.volmit.iris.core.project.loader.IrisData;
|
||||
import com.volmit.iris.engine.cache.AtomicCache;
|
||||
import com.volmit.iris.engine.interpolation.IrisInterpolation;
|
||||
import com.volmit.iris.engine.object.annotations.Desc;
|
||||
@@ -69,9 +70,9 @@ public class IrisFeaturePositional {
|
||||
}
|
||||
|
||||
@BlockCoordinates
|
||||
public boolean shouldFilter(double x, double z, RNG rng) {
|
||||
public boolean shouldFilter(double x, double z, RNG rng, IrisData data) {
|
||||
double actualRadius = getFeature().getActualRadius();
|
||||
double dist2 = distance2(x, z, rng);
|
||||
double dist2 = distance2(x, z, rng, data);
|
||||
|
||||
if (getFeature().isInvertZone()) {
|
||||
if (dist2 < Math.pow(getFeature().getBlockRadius() - actualRadius, 2)) {
|
||||
@@ -82,16 +83,16 @@ public class IrisFeaturePositional {
|
||||
return !(dist2 > Math.pow(getFeature().getBlockRadius() + actualRadius, 2));
|
||||
}
|
||||
|
||||
public double getStrength(double x, double z, RNG rng) {
|
||||
public double getStrength(double x, double z, RNG rng, IrisData data) {
|
||||
double actualRadius = getFeature().getActualRadius();
|
||||
double dist2 = distance2(x, z, rng);
|
||||
double dist2 = distance2(x, z, rng, data);
|
||||
|
||||
if (getFeature().isInvertZone()) {
|
||||
if (dist2 < Math.pow(getFeature().getBlockRadius() - actualRadius, 2)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
NoiseProvider d = provider.aquire(() -> getNoiseProvider(rng));
|
||||
NoiseProvider d = provider.aquire(() -> getNoiseProvider(rng, data));
|
||||
double s = IrisInterpolation.getNoise(getFeature().getInterpolator(), (int) x, (int) z, getFeature().getInterpolationRadius(), d);
|
||||
|
||||
if (s <= 0) {
|
||||
@@ -104,7 +105,7 @@ public class IrisFeaturePositional {
|
||||
return 0;
|
||||
}
|
||||
|
||||
NoiseProvider d = provider.aquire(() -> getNoiseProvider(rng));
|
||||
NoiseProvider d = provider.aquire(() -> getNoiseProvider(rng, data));
|
||||
double s = IrisInterpolation.getNoise(getFeature().getInterpolator(), (int) x, (int) z, getFeature().getInterpolationRadius(), d);
|
||||
|
||||
if (s <= 0) {
|
||||
@@ -115,17 +116,17 @@ public class IrisFeaturePositional {
|
||||
}
|
||||
}
|
||||
|
||||
public double getObjectChanceModifier(double x, double z, RNG rng) {
|
||||
public double getObjectChanceModifier(double x, double z, RNG rng, IrisData data) {
|
||||
if (getFeature().getObjectChance() >= 1) {
|
||||
return getFeature().getObjectChance();
|
||||
}
|
||||
|
||||
return M.lerp(1, getFeature().getObjectChance(), getStrength(x, z, rng));
|
||||
return M.lerp(1, getFeature().getObjectChance(), getStrength(x, z, rng, data));
|
||||
}
|
||||
|
||||
public IrisBiome filter(double x, double z, IrisBiome biome, RNG rng) {
|
||||
if (getFeature().getCustomBiome() != null) {
|
||||
if (getStrength(x, z, rng) >= getFeature().getBiomeStrengthThreshold()) {
|
||||
if (getStrength(x, z, rng, biome.getLoader()) >= getFeature().getBiomeStrengthThreshold()) {
|
||||
IrisBiome b = biome.getLoader().getBiomeLoader().load(getFeature().getCustomBiome());
|
||||
b.setInferredType(biome.getInferredType());
|
||||
return b;
|
||||
@@ -135,8 +136,8 @@ public class IrisFeaturePositional {
|
||||
return null;
|
||||
}
|
||||
|
||||
public double filter(double x, double z, double noise, RNG rng) {
|
||||
double s = getStrength(x, z, rng);
|
||||
public double filter(double x, double z, double noise, RNG rng, IrisData data) {
|
||||
double s = getStrength(x, z, rng, data);
|
||||
|
||||
if (s <= 0) {
|
||||
return noise;
|
||||
@@ -154,24 +155,24 @@ public class IrisFeaturePositional {
|
||||
return M.lerp(noise, fx, s);
|
||||
}
|
||||
|
||||
public double distance(double x, double z, RNG rng) {
|
||||
public double distance(double x, double z, RNG rng, IrisData data) {
|
||||
double mul = getFeature().getFractureRadius() != null ? getFeature().getFractureRadius().getMultiplier() / 2 : 1;
|
||||
double mod = getFeature().getFractureRadius() != null ? getFeature().getFractureRadius().create(rng).fitDouble(-mul, mul, x, z) : 0;
|
||||
double mod = getFeature().getFractureRadius() != null ? getFeature().getFractureRadius().create(rng, data).fitDouble(-mul, mul, x, z) : 0;
|
||||
return Math.sqrt(Math.pow(this.x - (x + mod), 2) + Math.pow(this.z - (z + mod), 2));
|
||||
}
|
||||
|
||||
public double distance2(double x, double z, RNG rng) {
|
||||
public double distance2(double x, double z, RNG rng, IrisData data) {
|
||||
double mul = getFeature().getFractureRadius() != null ? getFeature().getFractureRadius().getMultiplier() / 2 : 1;
|
||||
double mod = getFeature().getFractureRadius() != null ? getFeature().getFractureRadius().create(rng).fitDouble(-mul, mul, x, z) : 0;
|
||||
double mod = getFeature().getFractureRadius() != null ? getFeature().getFractureRadius().create(rng, data).fitDouble(-mul, mul, x, z) : 0;
|
||||
|
||||
return Math.pow(this.x - (x + mod), 2) + Math.pow(this.z - (z + mod), 2);
|
||||
}
|
||||
|
||||
private NoiseProvider getNoiseProvider(RNG rng) {
|
||||
private NoiseProvider getNoiseProvider(RNG rng, IrisData data) {
|
||||
if (getFeature().isInvertZone()) {
|
||||
return (x, z) -> distance(x, z, rng) > getFeature().getBlockRadius() ? 1D : 0D;
|
||||
return (x, z) -> distance(x, z, rng, data) > getFeature().getBlockRadius() ? 1D : 0D;
|
||||
} else {
|
||||
return (x, z) -> distance(x, z, rng) < getFeature().getBlockRadius() ? 1D : 0D;
|
||||
return (x, z) -> distance(x, z, rng, data) < getFeature().getBlockRadius() ? 1D : 0D;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -225,10 +225,10 @@ public class IrisGenerator extends IrisRegistrant {
|
||||
|
||||
for (IrisNoiseGenerator i : composite) {
|
||||
if (multiplicitive) {
|
||||
h *= i.getNoise(seed + superSeed + hc, (rx + offsetX) / zoom, (rz + offsetZ) / zoom);
|
||||
h *= i.getNoise(seed + superSeed + hc, (rx + offsetX) / zoom, (rz + offsetZ) / zoom, getLoader());
|
||||
} else {
|
||||
tp += i.getOpacity();
|
||||
h += i.getNoise(seed + superSeed + hc, (rx + offsetX) / zoom, (rz + offsetZ) / zoom);
|
||||
h += i.getNoise(seed + superSeed + hc, (rx + offsetX) / zoom, (rz + offsetZ) / zoom, getLoader());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -255,7 +255,7 @@ public class IrisGenerator extends IrisRegistrant {
|
||||
|
||||
public double getCliffHeight(double rx, double rz, double superSeed) {
|
||||
int hc = (int) ((cliffHeightMin * 10) + 10 + cliffHeightMax * seed + offsetX + offsetZ);
|
||||
double h = cliffHeightGenerator.getNoise((long) (seed + superSeed + hc), (rx + offsetX) / zoom, (rz + offsetZ) / zoom);
|
||||
double h = cliffHeightGenerator.getNoise((long) (seed + superSeed + hc), (rx + offsetX) / zoom, (rz + offsetZ) / zoom, getLoader());
|
||||
return IrisInterpolation.lerp(cliffHeightMin, cliffHeightMax, h);
|
||||
}
|
||||
|
||||
|
||||
@@ -18,12 +18,11 @@
|
||||
|
||||
package com.volmit.iris.engine.object;
|
||||
|
||||
import com.volmit.iris.core.project.loader.IrisData;
|
||||
import com.volmit.iris.engine.cache.AtomicCache;
|
||||
import com.volmit.iris.engine.noise.CNG;
|
||||
import com.volmit.iris.engine.object.annotations.Desc;
|
||||
import com.volmit.iris.engine.object.annotations.MaxNumber;
|
||||
import com.volmit.iris.engine.object.annotations.MinNumber;
|
||||
import com.volmit.iris.engine.object.annotations.Required;
|
||||
import com.volmit.iris.engine.noise.ExpressionNoise;
|
||||
import com.volmit.iris.engine.object.annotations.*;
|
||||
import com.volmit.iris.util.math.RNG;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
@@ -36,14 +35,17 @@ import lombok.experimental.Accessors;
|
||||
@Desc("A gen style")
|
||||
@Data
|
||||
public class IrisGeneratorStyle {
|
||||
@Required
|
||||
@Desc("The chance is 1 in CHANCE per interval")
|
||||
private NoiseStyle style = NoiseStyle.IRIS;
|
||||
private NoiseStyle style = NoiseStyle.FLAT;
|
||||
|
||||
@MinNumber(0.00001)
|
||||
@Desc("The zoom of this style")
|
||||
private double zoom = 1;
|
||||
|
||||
@Desc("Instead of using the style property, use a custom expression to represent this style.")
|
||||
@RegistryListResource(IrisExpression.class)
|
||||
private String expression = null;
|
||||
|
||||
@MinNumber(0.00001)
|
||||
@Desc("The Output multiplier. Only used if parent is fracture.")
|
||||
private double multiplier = 1;
|
||||
@@ -70,14 +72,30 @@ public class IrisGeneratorStyle {
|
||||
return this;
|
||||
}
|
||||
|
||||
public CNG create(RNG rng) {
|
||||
public CNG create(RNG rng, IrisData data) {
|
||||
return cng.aquire(() ->
|
||||
{
|
||||
if(getExpression() != null)
|
||||
{
|
||||
IrisExpression e = data.getExpressionLoader().load(getExpression());
|
||||
|
||||
if(e != null)
|
||||
{
|
||||
CNG cng = new CNG(rng, new ExpressionNoise(rng, e), 1D, 1)
|
||||
.bake().scale(1D / zoom).pow(exponent).bake();
|
||||
cng.setTrueFracturing(axialFracturing);
|
||||
|
||||
if (fracture != null) {
|
||||
cng.fractureWith(fracture.create(rng.nextParallelRNG(2934), data), fracture.getMultiplier());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CNG cng = style.create(rng).bake().scale(1D / zoom).pow(exponent).bake();
|
||||
cng.setTrueFracturing(axialFracturing);
|
||||
|
||||
if (fracture != null) {
|
||||
cng.fractureWith(fracture.create(rng.nextParallelRNG(2934)), fracture.getMultiplier());
|
||||
cng.fractureWith(fracture.create(rng.nextParallelRNG(2934), data), fracture.getMultiplier());
|
||||
}
|
||||
|
||||
return cng;
|
||||
|
||||
@@ -71,7 +71,7 @@ public class IrisMaterialPalette {
|
||||
return layerGenerator.aquire(() ->
|
||||
{
|
||||
RNG rngx = rng.nextParallelRNG(-23498896 + getBlockData(rdata).size());
|
||||
return style.create(rngx);
|
||||
return style.create(rngx, rdata);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package com.volmit.iris.engine.object;
|
||||
|
||||
import com.volmit.iris.core.project.loader.IrisData;
|
||||
import com.volmit.iris.engine.cache.AtomicCache;
|
||||
import com.volmit.iris.engine.interpolation.IrisInterpolation;
|
||||
import com.volmit.iris.engine.noise.CNG;
|
||||
@@ -94,15 +95,15 @@ public class IrisNoiseGenerator {
|
||||
this.enabled = enabled;
|
||||
}
|
||||
|
||||
protected CNG getGenerator(long superSeed) {
|
||||
return generator.aquire(() -> style.create(new RNG(superSeed + 33955677 - seed)).oct(octaves));
|
||||
protected CNG getGenerator(long superSeed, IrisData data) {
|
||||
return generator.aquire(() -> style.create(new RNG(superSeed + 33955677 - seed), data).oct(octaves));
|
||||
}
|
||||
|
||||
public double getMax() {
|
||||
return getOffsetY() + opacity;
|
||||
}
|
||||
|
||||
public double getNoise(long superSeed, double xv, double zv) {
|
||||
public double getNoise(long superSeed, double xv, double zv, IrisData data) {
|
||||
if (!enabled) {
|
||||
return offsetY;
|
||||
}
|
||||
@@ -113,13 +114,13 @@ public class IrisNoiseGenerator {
|
||||
|
||||
for (IrisNoiseGenerator i : fracture) {
|
||||
if (i.isEnabled()) {
|
||||
x += i.getNoise(superSeed + seed + g, xv, zv) - (opacity / 2D);
|
||||
z -= i.getNoise(superSeed + seed + g, zv, xv) - (opacity / 2D);
|
||||
x += i.getNoise(superSeed + seed + g, xv, zv, data) - (opacity / 2D);
|
||||
z -= i.getNoise(superSeed + seed + g, zv, xv, data) - (opacity / 2D);
|
||||
}
|
||||
g += 819;
|
||||
}
|
||||
|
||||
double n = getGenerator(superSeed).fitDouble(0, opacity, (x / zoom) + offsetX, (z / zoom) + offsetZ);
|
||||
double n = getGenerator(superSeed, data).fitDouble(0, opacity, (x / zoom) + offsetX, (z / zoom) + offsetZ);
|
||||
n = negative ? (-n + opacity) : n;
|
||||
n = (exponent != 1 ? n < 0 ? -Math.pow(-n, exponent) : Math.pow(n, exponent) : n) + offsetY;
|
||||
n = parametric ? IrisInterpolation.parametric(n, 1) : n;
|
||||
|
||||
@@ -448,14 +448,14 @@ public class IrisObject extends IrisRegistrant {
|
||||
|
||||
if (yv < 0) {
|
||||
if (config.getMode().equals(ObjectPlaceMode.CENTER_HEIGHT)) {
|
||||
y = (c != null ? c.getSurface() : placer.getHighest(x, z, config.isUnderwater())) + rty;
|
||||
y = (c != null ? c.getSurface() : placer.getHighest(x, z, getLoader(), config.isUnderwater())) + rty;
|
||||
} else if (config.getMode().equals(ObjectPlaceMode.MAX_HEIGHT) || config.getMode().equals(ObjectPlaceMode.STILT)) {
|
||||
BlockVector offset = new BlockVector(config.getTranslate().getX(), config.getTranslate().getY(), config.getTranslate().getZ());
|
||||
BlockVector rotatedDimensions = config.getRotation().rotate(new BlockVector(getW(), getH(), getD()), spinx, spiny, spinz).clone();
|
||||
|
||||
for (int i = x - (rotatedDimensions.getBlockX() / 2) + offset.getBlockX(); i <= x + (rotatedDimensions.getBlockX() / 2) + offset.getBlockX(); i++) {
|
||||
for (int j = z - (rotatedDimensions.getBlockZ() / 2) + offset.getBlockZ(); j <= z + (rotatedDimensions.getBlockZ() / 2) + offset.getBlockZ(); j++) {
|
||||
int h = placer.getHighest(i, j, config.isUnderwater()) + rty;
|
||||
int h = placer.getHighest(i, j, getLoader(), config.isUnderwater()) + rty;
|
||||
|
||||
if (h > y) {
|
||||
y = h;
|
||||
@@ -468,7 +468,7 @@ public class IrisObject extends IrisRegistrant {
|
||||
|
||||
for (int i = x - (rotatedDimensions.getBlockX() / 2) + offset.getBlockX(); i <= x + (rotatedDimensions.getBlockX() / 2) + offset.getBlockX(); i += (rotatedDimensions.getBlockX() / 2) + 1) {
|
||||
for (int j = z - (rotatedDimensions.getBlockZ() / 2) + offset.getBlockZ(); j <= z + (rotatedDimensions.getBlockZ() / 2) + offset.getBlockZ(); j += (rotatedDimensions.getBlockZ() / 2) + 1) {
|
||||
int h = placer.getHighest(i, j, config.isUnderwater()) + rty;
|
||||
int h = placer.getHighest(i, j, getLoader(), config.isUnderwater()) + rty;
|
||||
|
||||
if (h > y) {
|
||||
y = h;
|
||||
@@ -482,7 +482,7 @@ public class IrisObject extends IrisRegistrant {
|
||||
|
||||
for (int i = x - (rotatedDimensions.getBlockX() / 2) + offset.getBlockX(); i <= x + (rotatedDimensions.getBlockX() / 2) + offset.getBlockX(); i++) {
|
||||
for (int j = z - (rotatedDimensions.getBlockZ() / 2) + offset.getBlockZ(); j <= z + (rotatedDimensions.getBlockZ() / 2) + offset.getBlockZ(); j++) {
|
||||
int h = placer.getHighest(i, j, config.isUnderwater()) + rty;
|
||||
int h = placer.getHighest(i, j, getLoader(), config.isUnderwater()) + rty;
|
||||
|
||||
if (h < y) {
|
||||
y = h;
|
||||
@@ -496,7 +496,7 @@ public class IrisObject extends IrisRegistrant {
|
||||
|
||||
for (int i = x - (rotatedDimensions.getBlockX() / 2) + offset.getBlockX(); i <= x + (rotatedDimensions.getBlockX() / 2) + offset.getBlockX(); i += (rotatedDimensions.getBlockX() / 2) + 1) {
|
||||
for (int j = z - (rotatedDimensions.getBlockZ() / 2) + offset.getBlockZ(); j <= z + (rotatedDimensions.getBlockZ() / 2) + offset.getBlockZ(); j += (rotatedDimensions.getBlockZ() / 2) + 1) {
|
||||
int h = placer.getHighest(i, j, config.isUnderwater()) + rty;
|
||||
int h = placer.getHighest(i, j, getLoader(), config.isUnderwater()) + rty;
|
||||
|
||||
if (h < y) {
|
||||
y = h;
|
||||
@@ -504,7 +504,7 @@ public class IrisObject extends IrisRegistrant {
|
||||
}
|
||||
}
|
||||
} else if (config.getMode().equals(ObjectPlaceMode.PAINT)) {
|
||||
y = placer.getHighest(x, z, config.isUnderwater()) + rty;
|
||||
y = placer.getHighest(x, z, getLoader(), config.isUnderwater()) + rty;
|
||||
}
|
||||
} else {
|
||||
y = yv;
|
||||
@@ -600,12 +600,12 @@ public class IrisObject extends IrisRegistrant {
|
||||
zz = z + (int) Math.round(i.getZ());
|
||||
|
||||
if (warped) {
|
||||
xx += config.warp(rng, i.getX() + x, i.getY() + y, i.getZ() + z);
|
||||
zz += config.warp(rng, i.getZ() + z, i.getY() + y, i.getX() + x);
|
||||
xx += config.warp(rng, i.getX() + x, i.getY() + y, i.getZ() + z, getLoader());
|
||||
zz += config.warp(rng, i.getZ() + z, i.getY() + y, i.getX() + x, getLoader());
|
||||
}
|
||||
|
||||
if (yv < 0 && (config.getMode().equals(ObjectPlaceMode.PAINT))) {
|
||||
yy = (int) Math.round(i.getY()) + Math.floorDiv(h, 2) + placer.getHighest(xx, zz, config.isUnderwater());
|
||||
yy = (int) Math.round(i.getY()) + Math.floorDiv(h, 2) + placer.getHighest(xx, zz, getLoader(), config.isUnderwater());
|
||||
}
|
||||
|
||||
if (heightmap != null) {
|
||||
@@ -680,11 +680,11 @@ public class IrisObject extends IrisRegistrant {
|
||||
zz = z + (int) Math.round(i.getZ());
|
||||
|
||||
if (warped) {
|
||||
xx += config.warp(rng, i.getX() + x, i.getY() + y, i.getZ() + z);
|
||||
zz += config.warp(rng, i.getZ() + z, i.getY() + y, i.getX() + x);
|
||||
xx += config.warp(rng, i.getX() + x, i.getY() + y, i.getZ() + z, getLoader());
|
||||
zz += config.warp(rng, i.getZ() + z, i.getY() + y, i.getX() + x, getLoader());
|
||||
}
|
||||
|
||||
int yg = placer.getHighest(xx, zz, config.isUnderwater());
|
||||
int yg = placer.getHighest(xx, zz, getLoader(), config.isUnderwater());
|
||||
|
||||
if (yv >= 0 && config.isBottom()) {
|
||||
y += Math.floorDiv(h, 2);
|
||||
|
||||
@@ -180,13 +180,13 @@ public class IrisObjectPlacement {
|
||||
|
||||
private final transient AtomicCache<CNG> surfaceWarp = new AtomicCache<>();
|
||||
|
||||
public CNG getSurfaceWarp(RNG rng) {
|
||||
public CNG getSurfaceWarp(RNG rng, IrisData data) {
|
||||
return surfaceWarp.aquire(() ->
|
||||
getWarp().create(rng));
|
||||
getWarp().create(rng, data));
|
||||
}
|
||||
|
||||
public double warp(RNG rng, double x, double y, double z) {
|
||||
return getSurfaceWarp(rng).fitDouble(-(getWarp().getMultiplier() / 2D), (getWarp().getMultiplier() / 2D), x, y, z);
|
||||
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 int getTriesForChunk(RNG random) {
|
||||
|
||||
@@ -269,11 +269,11 @@ public class IrisRegion extends IrisRegistrant implements IRare {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (getRiverChanceGen().aquire(() -> getRiverChanceStyle().create(rng)).fit(1, getRiverRarity(), x, z) != 1) {
|
||||
if (getRiverChanceGen().aquire(() -> getRiverChanceStyle().create(rng, getLoader())).fit(1, getRiverRarity(), x, z) != 1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return getRiverGen().aquire(() -> getRiverStyle().create(rng)).fitDouble(0, 1, x, z) < getRiverThickness();
|
||||
return getRiverGen().aquire(() -> getRiverStyle().create(rng, getLoader())).fitDouble(0, 1, x, z) < getRiverThickness();
|
||||
}
|
||||
|
||||
public boolean isLake(RNG rng, double x, double z) {
|
||||
@@ -285,7 +285,7 @@ public class IrisRegion extends IrisRegistrant implements IRare {
|
||||
return false;
|
||||
}
|
||||
|
||||
return getLakeGen().aquire(() -> getLakeStyle().create(rng)).fit(1, getLakeRarity(), x, z) == 1;
|
||||
return getLakeGen().aquire(() -> getLakeStyle().create(rng, getLoader())).fit(1, getLakeRarity(), x, z) == 1;
|
||||
}
|
||||
|
||||
public double getBiomeZoom(InferredType t) {
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package com.volmit.iris.engine.object;
|
||||
|
||||
import com.volmit.iris.core.project.loader.IrisData;
|
||||
import com.volmit.iris.engine.object.annotations.Desc;
|
||||
import com.volmit.iris.engine.object.annotations.MaxNumber;
|
||||
import com.volmit.iris.engine.object.annotations.MinNumber;
|
||||
@@ -50,8 +51,8 @@ public class IrisShapedGeneratorStyle {
|
||||
@Desc("The max block value")
|
||||
private int max = 0;
|
||||
|
||||
public double get(RNG rng, double... dim) {
|
||||
return generator.create(rng).fitDouble(min, max, dim);
|
||||
public double get(RNG rng, IrisData data, double... dim) {
|
||||
return generator.create(rng, data).fitDouble(min, max, dim);
|
||||
}
|
||||
|
||||
public IrisShapedGeneratorStyle(NoiseStyle style, int min, int max) {
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package com.volmit.iris.engine.object;
|
||||
|
||||
import com.volmit.iris.core.project.loader.IrisData;
|
||||
import com.volmit.iris.engine.object.annotations.Desc;
|
||||
import com.volmit.iris.engine.stream.ProceduralStream;
|
||||
import com.volmit.iris.engine.stream.interpolation.Interpolated;
|
||||
@@ -43,7 +44,7 @@ public class IrisStyledRange {
|
||||
@Desc("The style to pick the range")
|
||||
private IrisGeneratorStyle style = new IrisGeneratorStyle(NoiseStyle.STATIC);
|
||||
|
||||
public double get(RNG rng, double x, double z) {
|
||||
public double get(RNG rng, double x, double z, IrisData data) {
|
||||
if (min == max) {
|
||||
return min;
|
||||
}
|
||||
@@ -52,10 +53,10 @@ public class IrisStyledRange {
|
||||
return M.lerp(min, max, 0.5);
|
||||
}
|
||||
|
||||
return style.create(rng).fitDouble(min, max, x, z);
|
||||
return style.create(rng, data).fitDouble(min, max, x, z);
|
||||
}
|
||||
|
||||
public ProceduralStream<Double> stream(RNG rng) {
|
||||
return ProceduralStream.of((x, z) -> get(rng, x, z), Interpolated.DOUBLE);
|
||||
public ProceduralStream<Double> stream(RNG rng, IrisData data) {
|
||||
return ProceduralStream.of((x, z) -> get(rng, x, z, data), Interpolated.DOUBLE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,14 +18,15 @@
|
||||
|
||||
package com.volmit.iris.engine.object.common;
|
||||
|
||||
import com.volmit.iris.core.project.loader.IrisData;
|
||||
import com.volmit.iris.engine.object.tile.TileData;
|
||||
import org.bukkit.block.TileState;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
|
||||
public interface IObjectPlacer {
|
||||
int getHighest(int x, int z);
|
||||
int getHighest(int x, int z, IrisData data);
|
||||
|
||||
int getHighest(int x, int z, boolean ignoreFluid);
|
||||
int getHighest(int x, int z, IrisData data, boolean ignoreFluid);
|
||||
|
||||
void set(int x, int y, int z, BlockData d);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user