mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-12-30 12:29:20 +00:00
Fix Interpolation
This commit is contained in:
@@ -10,9 +10,44 @@ public enum InterpolationMethod
|
||||
@DontObfuscate
|
||||
BILINEAR,
|
||||
|
||||
@DontObfuscate
|
||||
BILINEAR_BEZIER,
|
||||
|
||||
@DontObfuscate
|
||||
BILINEAR_PARAMETRIC_2,
|
||||
|
||||
@DontObfuscate
|
||||
BILINEAR_PARAMETRIC_4,
|
||||
|
||||
@DontObfuscate
|
||||
BILINEAR_PARAMETRIC_1_5,
|
||||
|
||||
@DontObfuscate
|
||||
BICUBIC,
|
||||
|
||||
@DontObfuscate
|
||||
HERMITE
|
||||
HERMITE,
|
||||
|
||||
@DontObfuscate
|
||||
CATMULL_ROM_SPLINE,
|
||||
|
||||
@DontObfuscate
|
||||
HERMITE_TENSE,
|
||||
|
||||
@DontObfuscate
|
||||
HERMITE_LOOSE,
|
||||
|
||||
@DontObfuscate
|
||||
HERMITE_LOOSE_HALF_POSITIVE_BIAS,
|
||||
|
||||
@DontObfuscate
|
||||
HERMITE_LOOSE_HALF_NEGATIVE_BIAS,
|
||||
|
||||
@DontObfuscate
|
||||
HERMITE_LOOSE_FULL_POSITIVE_BIAS,
|
||||
|
||||
@DontObfuscate
|
||||
HERMITE_LOOSE_FULL_NEGATIVE_BIAS,
|
||||
|
||||
;
|
||||
}
|
||||
|
||||
@@ -153,7 +153,7 @@ public class IrisDepositGenerator
|
||||
});
|
||||
}
|
||||
|
||||
public void generate(ChunkData data, RNG rng, TerrainChunkGenerator g)
|
||||
public void generate(ChunkData data, RNG rng, TerrainChunkGenerator g, int cx, int cz)
|
||||
{
|
||||
for(int l = 0; l < rng.i(getMinPerChunk(), getMaxPerChunk()); l++)
|
||||
{
|
||||
@@ -170,7 +170,7 @@ public class IrisDepositGenerator
|
||||
|
||||
int x = rng.i(af, bf);
|
||||
int z = rng.i(af, bf);
|
||||
int height = (int) (Math.round(g.getTerrainHeight(x, z))) - 7;
|
||||
int height = (int) (Math.round(g.getTerrainHeight((cx << 4) + x, (cz << 4) + z))) - 7;
|
||||
|
||||
if(height <= 0)
|
||||
{
|
||||
@@ -187,7 +187,7 @@ public class IrisDepositGenerator
|
||||
|
||||
int h = rng.i(i, a);
|
||||
|
||||
if(h > maxHeight || h < minHeight || h > height - 7)
|
||||
if(h > maxHeight || h < minHeight || h > height - 2)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -198,14 +198,14 @@ public class IrisDepositGenerator
|
||||
int ny = j.getBlockY() + h;
|
||||
int nz = j.getBlockZ() + z;
|
||||
|
||||
if(ny > height - 7 || nx > 15 || nx < 0 || ny > 255 || ny < 0 || nz < 0 || nz > 15)
|
||||
if(ny > height - 2 || nx > 15 || nx < 0 || ny > 255 || ny < 0 || nz < 0 || nz > 15)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
BlockData b = data.getBlockData(nx, ny, nz);
|
||||
|
||||
if(b.getMaterial().equals(Material.ICE) || b.getMaterial().equals(Material.PACKED_ICE) || b.getMaterial().equals(B.mat("BLUE_ICE")) || b.getMaterial().equals(B.mat("FROSTED_ICE")) || b.getMaterial().equals(Material.SAND) || b.getMaterial().equals(Material.RED_SAND) || !b.getMaterial().isSolid())
|
||||
if(b.getMaterial().equals(Material.ICE) || b.getMaterial().equals(Material.PACKED_ICE) || b.getMaterial().equals(B.mat("BLUE_ICE")) || b.getMaterial().equals(B.mat("FROSTED_ICE")) || b.getMaterial().equals(Material.SAND) || b.getMaterial().equals(Material.RED_SAND) || !B.isSolid(b.getMaterial()))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -22,7 +22,8 @@ import lombok.EqualsAndHashCode;
|
||||
@Desc("Represents a composite generator of noise gens")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class IrisGenerator extends IrisRegistrant {
|
||||
public class IrisGenerator extends IrisRegistrant
|
||||
{
|
||||
@MinNumber(0.001)
|
||||
@DontObfuscate
|
||||
@Desc("The zoom or frequency.")
|
||||
@@ -101,91 +102,114 @@ public class IrisGenerator extends IrisRegistrant {
|
||||
|
||||
private transient AtomicCache<CellGenerator> cellGen = new AtomicCache<>();
|
||||
|
||||
public IrisGenerator() {
|
||||
public IrisGenerator()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public double getMax() {
|
||||
public double getMax()
|
||||
{
|
||||
return opacity;
|
||||
}
|
||||
|
||||
public boolean hasCliffs() {
|
||||
public boolean hasCliffs()
|
||||
{
|
||||
return cliffHeightMax > 0;
|
||||
}
|
||||
|
||||
public CellGenerator getCellGenerator(long seed) {
|
||||
public CellGenerator getCellGenerator(long seed)
|
||||
{
|
||||
return cellGen.aquire(() -> new CellGenerator(new RNG(seed + 239466)));
|
||||
}
|
||||
|
||||
public <T extends IRare> T fitRarity(KList<T> b, long superSeed, double rx, double rz) {
|
||||
if (b.size() == 0) {
|
||||
public <T extends IRare> T fitRarity(KList<T> b, long superSeed, double rx, double rz)
|
||||
{
|
||||
if(b.size() == 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
if (b.size() == 1) {
|
||||
if(b.size() == 1)
|
||||
{
|
||||
return b.get(0);
|
||||
}
|
||||
|
||||
KList<T> rarityMapped = new KList<>();
|
||||
boolean o = false;
|
||||
int max = 1;
|
||||
for (T i : b) {
|
||||
if (i.getRarity() > max) {
|
||||
for(T i : b)
|
||||
{
|
||||
if(i.getRarity() > max)
|
||||
{
|
||||
max = i.getRarity();
|
||||
}
|
||||
}
|
||||
|
||||
max++;
|
||||
|
||||
for (T i : b) {
|
||||
for (int j = 0; j < max - i.getRarity(); j++) {
|
||||
if (o = !o) {
|
||||
for(T i : b)
|
||||
{
|
||||
for(int j = 0; j < max - i.getRarity(); j++)
|
||||
{
|
||||
if(o = !o)
|
||||
{
|
||||
rarityMapped.add(i);
|
||||
}
|
||||
|
||||
else {
|
||||
else
|
||||
{
|
||||
rarityMapped.add(0, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (rarityMapped.size() == 1) {
|
||||
if(rarityMapped.size() == 1)
|
||||
{
|
||||
return rarityMapped.get(0);
|
||||
}
|
||||
|
||||
if (rarityMapped.isEmpty()) {
|
||||
if(rarityMapped.isEmpty())
|
||||
{
|
||||
throw new RuntimeException("BAD RARITY MAP! RELATED TO: " + b.toString(", or possibly "));
|
||||
}
|
||||
|
||||
return fit(rarityMapped, superSeed, rx, rz);
|
||||
}
|
||||
|
||||
public <T> T fit(T[] v, long superSeed, double rx, double rz) {
|
||||
if (v.length == 0) {
|
||||
public <T> T fit(T[] v, long superSeed, double rx, double rz)
|
||||
{
|
||||
if(v.length == 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
if (v.length == 1) {
|
||||
if(v.length == 1)
|
||||
{
|
||||
return v[0];
|
||||
}
|
||||
|
||||
return v[fit(0, v.length - 1, superSeed, rx, rz)];
|
||||
}
|
||||
|
||||
public <T> T fit(List<T> v, long superSeed, double rx, double rz) {
|
||||
if (v.size() == 0) {
|
||||
public <T> T fit(List<T> v, long superSeed, double rx, double rz)
|
||||
{
|
||||
if(v.size() == 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
if (v.size() == 1) {
|
||||
if(v.size() == 1)
|
||||
{
|
||||
return v.get(0);
|
||||
}
|
||||
|
||||
return v.get(fit(0, v.size() - 1, superSeed, rx, rz));
|
||||
}
|
||||
|
||||
public int fit(int min, int max, long superSeed, double rx, double rz) {
|
||||
if (min == max) {
|
||||
public int fit(int min, int max, long superSeed, double rx, double rz)
|
||||
{
|
||||
if(min == max)
|
||||
{
|
||||
return min;
|
||||
}
|
||||
|
||||
@@ -194,8 +218,10 @@ public class IrisGenerator extends IrisRegistrant {
|
||||
return (int) Math.round(IrisInterpolation.lerp(min, max, noise));
|
||||
}
|
||||
|
||||
public int fit(double min, double max, long superSeed, double rx, double rz) {
|
||||
if (min == max) {
|
||||
public int fit(double min, double max, long superSeed, double rx, double rz)
|
||||
{
|
||||
if(min == max)
|
||||
{
|
||||
return (int) Math.round(min);
|
||||
}
|
||||
|
||||
@@ -204,8 +230,10 @@ public class IrisGenerator extends IrisRegistrant {
|
||||
return (int) Math.round(IrisInterpolation.lerp(min, max, noise));
|
||||
}
|
||||
|
||||
public double fitDouble(double min, double max, long superSeed, double rx, double rz) {
|
||||
if (min == max) {
|
||||
public double fitDouble(double min, double max, long superSeed, double rx, double rz)
|
||||
{
|
||||
if(min == max)
|
||||
{
|
||||
return min;
|
||||
}
|
||||
|
||||
@@ -214,12 +242,15 @@ public class IrisGenerator extends IrisRegistrant {
|
||||
return IrisInterpolation.lerp(min, max, noise);
|
||||
}
|
||||
|
||||
public double getHeight(double rx, double rz, long superSeed) {
|
||||
public double getHeight(double rx, double rz, long superSeed)
|
||||
{
|
||||
return getHeight(rx, 0, rz, superSeed);
|
||||
}
|
||||
|
||||
public double getHeight(double rx, double ry, double rz, long superSeed) {
|
||||
if (composite.isEmpty()) {
|
||||
public double getHeight(double rx, double ry, double rz, long superSeed)
|
||||
{
|
||||
if(composite.isEmpty())
|
||||
{
|
||||
Iris.warn("Useless Generator: Composite is empty in " + getLoadKey());
|
||||
return 0;
|
||||
}
|
||||
@@ -228,16 +259,17 @@ public class IrisGenerator extends IrisRegistrant {
|
||||
double h = 0;
|
||||
double tp = 0;
|
||||
|
||||
for (IrisNoiseGenerator i : composite) {
|
||||
for(IrisNoiseGenerator i : composite)
|
||||
{
|
||||
tp += i.getOpacity();
|
||||
h += i.getNoise(seed + superSeed + hc, (rx + offsetX) / zoom, (rz + offsetZ) / zoom);
|
||||
}
|
||||
|
||||
double v = (h / tp) * opacity;
|
||||
|
||||
if (Double.isNaN(v)) {
|
||||
Iris.warn("Nan value on gen: " + getLoadKey() + ": H = " + h + " TP = " + tp + " OPACITY = " + opacity
|
||||
+ " ZOOM = " + zoom);
|
||||
if(Double.isNaN(v))
|
||||
{
|
||||
Iris.warn("Nan value on gen: " + getLoadKey() + ": H = " + h + " TP = " + tp + " OPACITY = " + opacity + " ZOOM = " + zoom);
|
||||
}
|
||||
|
||||
v = hasCliffs() ? cliff(rx, rz, v, superSeed + 294596 + hc) : v;
|
||||
@@ -246,29 +278,32 @@ public class IrisGenerator extends IrisRegistrant {
|
||||
return v;
|
||||
}
|
||||
|
||||
public double cell(double rx, double rz, double v, double superSeed) {
|
||||
public double cell(double rx, double rz, double v, double superSeed)
|
||||
{
|
||||
getCellGenerator(seed + 46222).setShuffle(getCellFractureShuffle());
|
||||
return getCellGenerator(seed + 46222).getDistance(rx / getCellFractureZoom(),
|
||||
rz / getCellFractureZoom()) > getCellPercentSize() ? (v * getCellFractureHeight()) : v;
|
||||
return getCellGenerator(seed + 46222).getDistance(rx / getCellFractureZoom(), rz / getCellFractureZoom()) > getCellPercentSize() ? (v * getCellFractureHeight()) : v;
|
||||
}
|
||||
|
||||
private boolean hasCellCracks() {
|
||||
private boolean hasCellCracks()
|
||||
{
|
||||
return getCellFractureHeight() != 0;
|
||||
}
|
||||
|
||||
public double getCliffHeight(double rx, double rz, double superSeed) {
|
||||
public double getCliffHeight(double rx, double rz, double superSeed)
|
||||
{
|
||||
int hc = (int) ((cliffHeightMin * 10) + 10 + cliffHeightMax + interpolationScale * 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);
|
||||
return IrisInterpolation.lerp(cliffHeightMin, cliffHeightMax, h);
|
||||
}
|
||||
|
||||
public double cliff(double rx, double rz, double v, double superSeed) {
|
||||
public double cliff(double rx, double rz, double v, double superSeed)
|
||||
{
|
||||
double cliffHeight = getCliffHeight(rx, rz, superSeed - 34857);
|
||||
return (Math.round((v * 255D) / cliffHeight) * cliffHeight) / 255D;
|
||||
}
|
||||
|
||||
public IrisGenerator rescale(double scale) {
|
||||
public IrisGenerator rescale(double scale)
|
||||
{
|
||||
zoom /= scale;
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -223,7 +223,7 @@ public class IrisObject extends IrisRegistrant
|
||||
continue;
|
||||
}
|
||||
|
||||
if(yy <= placer.getFluidHeight() && data instanceof Waterlogged)
|
||||
if(config.isWaterloggable() && yy <= placer.getFluidHeight() && data instanceof Waterlogged)
|
||||
{
|
||||
((Waterlogged) data).setWaterlogged(true);
|
||||
}
|
||||
|
||||
@@ -64,6 +64,10 @@ public class IrisObjectPlacement
|
||||
@Desc("If set to true, objects will place on the terrain height, ignoring the water surface.")
|
||||
private boolean underwater = false;
|
||||
|
||||
@DontObfuscate
|
||||
@Desc("If set to true, Blocks placed underwater that could be waterlogged are waterlogged.")
|
||||
private boolean waterloggable = true;
|
||||
|
||||
@DontObfuscate
|
||||
@Desc("If set to true, objects will place on the fluid height level Such as boats.")
|
||||
private boolean onwater = false;
|
||||
|
||||
@@ -120,7 +120,11 @@ public class IrisStructurePlacement
|
||||
|
||||
private IrisObjectPlacement getConfig()
|
||||
{
|
||||
return config.aquire(() -> new IrisObjectPlacement());
|
||||
return config.aquire(() -> {
|
||||
IrisObjectPlacement p = new IrisObjectPlacement();
|
||||
p.setWaterloggable(false);
|
||||
return p;
|
||||
});
|
||||
}
|
||||
|
||||
public IrisObject load(ContextualChunkGenerator g, String s)
|
||||
|
||||
Reference in New Issue
Block a user