Remove 2d base eq options. Closes #70.

This commit is contained in:
dfsek 2021-01-29 00:46:55 -07:00
parent a8266f99b1
commit dddf644c34
8 changed files with 14 additions and 77 deletions

View File

@ -109,7 +109,15 @@ public final class MathUtil {
return FastMath.min(FastMath.max(in, -1), 1);
}
public static double compute(double p, double mu, double sigma) {
/**
* Compute the value in a normally distributed data set that has probability p.
*
* @param p Probability of value
* @param mu Mean of data
* @param sigma Standard deviation of data
* @return Value corresponding to input probability
*/
public static double normalInverse(double p, double mu, double sigma) {
if(p < 0 || p > 1)
throw new IllegalArgumentException("Probability must be in range [0, 1]");
if(sigma < 0)
@ -159,7 +167,7 @@ public final class MathUtil {
.14810397642748007459) * r + .68976733498510000455) *
r + 1.6763848301838038494) * r +
2.05319162663775882187) * r + 1);
} else { /* very close to 0 or 1 */
} else {
r += -5;
val = (((((((r * 2.01033439929228813265e-7 +
2.71155556874348757815e-5) * r +

View File

@ -13,9 +13,8 @@ public class NormalNormalizer extends Normalizer {
this.lookup = new double[buckets];
for(int i = 0; i < buckets; i++) {
lookup[i] = MathUtil.compute((double) i / buckets, mean, standardDeviation);
lookup[i] = MathUtil.normalInverse((double) i / buckets, mean, standardDeviation);
}
}
@Override

View File

@ -37,10 +37,6 @@ public interface Generator {
*/
Palette<BlockData> getPalette(int y);
boolean is2d();
double get2dBase();
NoiseSampler getBiomeNoise();
double getElevationWeight();

View File

@ -34,10 +34,6 @@ public class GeneratorBuilder {
private boolean interpolateElevation;
private boolean noise2d;
private double base;
private NoiseBuilder biomeNoise;
private double elevationWeight;
@ -61,7 +57,7 @@ public class GeneratorBuilder {
} catch(ParseException e) {
throw new RuntimeException(e);
}
return new WorldGenerator(palettes, slantPalettes, noise, elevation, carving, noise2d, base, biomeNoise.build((int) seed), elevationWeight, blendDistance, blendStep, blendWeight);
return new WorldGenerator(palettes, slantPalettes, noise, elevation, carving, biomeNoise.build((int) seed), elevationWeight, blendDistance, blendStep, blendWeight);
});
}
}
@ -82,38 +78,14 @@ public class GeneratorBuilder {
this.biomeNoise = biomeNoise;
}
public boolean isNoise2d() {
return noise2d;
}
public void setNoise2d(boolean noise2d) {
this.noise2d = noise2d;
}
public double getBase() {
return base;
}
public void setBase(double base) {
this.base = base;
}
public void setElevationWeight(double elevationWeight) {
this.elevationWeight = elevationWeight;
}
public String getNoiseEquation() {
return noiseEquation;
}
public void setNoiseEquation(String noiseEquation) {
this.noiseEquation = noiseEquation;
}
public String getElevationEquation() {
return elevationEquation;
}
public void setElevationEquation(String elevationEquation) {
this.elevationEquation = elevationEquation;
}

View File

@ -30,8 +30,6 @@ public class BiomeFactory implements TerraFactory<BiomeTemplate, TerraBiome> {
generatorBuilder.setVarScope(vars);
generatorBuilder.setInterpolateElevation(template.interpolateElevation());
generatorBuilder.setNoise2d(template.isNoise2d());
generatorBuilder.setBase(template.getNoise2dBase());
generatorBuilder.setElevationWeight(template.getElevationWeight());
generatorBuilder.setBiomeNoise(template.getBiomeNoise());
generatorBuilder.setBlendDistance(template.getBlendDistance());

View File

@ -53,16 +53,6 @@ public class BiomeTemplate extends AbstractableTemplate implements ValidatedConf
@Default
private String carvingEquation = "0";
@Value("noise-2d.enable")
@Default
@Abstractable
private boolean noise2d = false;
@Value("noise-2d.base")
@Default
@Abstractable
private double noise2dBase = 64;
@Value("palette")
@Abstractable
private PaletteHolder palette;
@ -298,14 +288,6 @@ public class BiomeTemplate extends AbstractableTemplate implements ValidatedConf
return oreHolder;
}
public boolean isNoise2d() {
return noise2d;
}
public double getNoise2dBase() {
return noise2dBase;
}
public double getElevationWeight() {
return elevationWeight;
}

View File

@ -16,23 +16,19 @@ public class WorldGenerator implements Generator {
private final NoiseSampler elevation;
private final NoiseSampler carving;
private final boolean noise2d;
private final double base;
private final NoiseSampler biomeNoise;
private final double elevationWeight;
private final int blendDistance;
private final int blendStep;
private final double blendWeight;
public WorldGenerator(PaletteHolder palettes, PaletteHolder slantPalettes, NoiseSampler noise, NoiseSampler elevation, NoiseSampler carving, boolean noise2d, double base, NoiseSampler biomeNoise, double elevationWeight, int blendDistance, int blendStep, double blendWeight) {
public WorldGenerator(PaletteHolder palettes, PaletteHolder slantPalettes, NoiseSampler noise, NoiseSampler elevation, NoiseSampler carving, NoiseSampler biomeNoise, double elevationWeight, int blendDistance, int blendStep, double blendWeight) {
this.palettes = palettes;
this.slantPalettes = slantPalettes;
this.noise = noise;
this.elevation = elevation;
this.carving = carving;
this.noise2d = noise2d;
this.base = base;
this.biomeNoise = biomeNoise;
this.elevationWeight = elevationWeight;
this.blendDistance = blendDistance;
@ -75,16 +71,6 @@ public class WorldGenerator implements Generator {
return palettes.getPalette(y);
}
@Override
public boolean is2d() {
return noise2d;
}
@Override
public double get2dBase() {
return base;
}
@Override
public NoiseSampler getBiomeNoise() {
return biomeNoise;

View File

@ -11,11 +11,7 @@ public class Sampler {
private final ElevationInterpolator elevationInterpolator;
public Sampler(int x, int z, BiomeProvider provider, World world, int elevationSmooth) {
this.interpolator = new BiomeChunkInterpolator(world, x, z, provider, (generator, coord) -> {
if(generator.is2d())
return generator.getBaseSampler().getNoise(coord.getX(), 0, coord.getZ()) + noise2dExtrude(coord.getY(), generator.get2dBase());
else return generator.getBaseSampler().getNoise(coord);
});
this.interpolator = new BiomeChunkInterpolator(world, x, z, provider, (generator, coord) -> generator.getBaseSampler().getNoise(coord));
this.elevationInterpolator = new ElevationInterpolator(world, x, z, provider, elevationSmooth);
}