mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2025-07-04 00:45:57 +00:00
Remove 2d base eq options. Closes #70.
This commit is contained in:
parent
a8266f99b1
commit
dddf644c34
@ -109,7 +109,15 @@ public final class MathUtil {
|
|||||||
return FastMath.min(FastMath.max(in, -1), 1);
|
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)
|
if(p < 0 || p > 1)
|
||||||
throw new IllegalArgumentException("Probability must be in range [0, 1]");
|
throw new IllegalArgumentException("Probability must be in range [0, 1]");
|
||||||
if(sigma < 0)
|
if(sigma < 0)
|
||||||
@ -159,7 +167,7 @@ public final class MathUtil {
|
|||||||
.14810397642748007459) * r + .68976733498510000455) *
|
.14810397642748007459) * r + .68976733498510000455) *
|
||||||
r + 1.6763848301838038494) * r +
|
r + 1.6763848301838038494) * r +
|
||||||
2.05319162663775882187) * r + 1);
|
2.05319162663775882187) * r + 1);
|
||||||
} else { /* very close to 0 or 1 */
|
} else {
|
||||||
r += -5;
|
r += -5;
|
||||||
val = (((((((r * 2.01033439929228813265e-7 +
|
val = (((((((r * 2.01033439929228813265e-7 +
|
||||||
2.71155556874348757815e-5) * r +
|
2.71155556874348757815e-5) * r +
|
||||||
|
@ -13,9 +13,8 @@ public class NormalNormalizer extends Normalizer {
|
|||||||
this.lookup = new double[buckets];
|
this.lookup = new double[buckets];
|
||||||
|
|
||||||
for(int i = 0; i < buckets; i++) {
|
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
|
@Override
|
||||||
|
@ -37,10 +37,6 @@ public interface Generator {
|
|||||||
*/
|
*/
|
||||||
Palette<BlockData> getPalette(int y);
|
Palette<BlockData> getPalette(int y);
|
||||||
|
|
||||||
boolean is2d();
|
|
||||||
|
|
||||||
double get2dBase();
|
|
||||||
|
|
||||||
NoiseSampler getBiomeNoise();
|
NoiseSampler getBiomeNoise();
|
||||||
|
|
||||||
double getElevationWeight();
|
double getElevationWeight();
|
||||||
|
@ -34,10 +34,6 @@ public class GeneratorBuilder {
|
|||||||
|
|
||||||
private boolean interpolateElevation;
|
private boolean interpolateElevation;
|
||||||
|
|
||||||
private boolean noise2d;
|
|
||||||
|
|
||||||
private double base;
|
|
||||||
|
|
||||||
private NoiseBuilder biomeNoise;
|
private NoiseBuilder biomeNoise;
|
||||||
|
|
||||||
private double elevationWeight;
|
private double elevationWeight;
|
||||||
@ -61,7 +57,7 @@ public class GeneratorBuilder {
|
|||||||
} catch(ParseException e) {
|
} catch(ParseException e) {
|
||||||
throw new RuntimeException(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;
|
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) {
|
public void setElevationWeight(double elevationWeight) {
|
||||||
this.elevationWeight = elevationWeight;
|
this.elevationWeight = elevationWeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getNoiseEquation() {
|
|
||||||
return noiseEquation;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setNoiseEquation(String noiseEquation) {
|
public void setNoiseEquation(String noiseEquation) {
|
||||||
this.noiseEquation = noiseEquation;
|
this.noiseEquation = noiseEquation;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getElevationEquation() {
|
|
||||||
return elevationEquation;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setElevationEquation(String elevationEquation) {
|
public void setElevationEquation(String elevationEquation) {
|
||||||
this.elevationEquation = elevationEquation;
|
this.elevationEquation = elevationEquation;
|
||||||
}
|
}
|
||||||
|
@ -30,8 +30,6 @@ public class BiomeFactory implements TerraFactory<BiomeTemplate, TerraBiome> {
|
|||||||
generatorBuilder.setVarScope(vars);
|
generatorBuilder.setVarScope(vars);
|
||||||
|
|
||||||
generatorBuilder.setInterpolateElevation(template.interpolateElevation());
|
generatorBuilder.setInterpolateElevation(template.interpolateElevation());
|
||||||
generatorBuilder.setNoise2d(template.isNoise2d());
|
|
||||||
generatorBuilder.setBase(template.getNoise2dBase());
|
|
||||||
generatorBuilder.setElevationWeight(template.getElevationWeight());
|
generatorBuilder.setElevationWeight(template.getElevationWeight());
|
||||||
generatorBuilder.setBiomeNoise(template.getBiomeNoise());
|
generatorBuilder.setBiomeNoise(template.getBiomeNoise());
|
||||||
generatorBuilder.setBlendDistance(template.getBlendDistance());
|
generatorBuilder.setBlendDistance(template.getBlendDistance());
|
||||||
|
@ -53,16 +53,6 @@ public class BiomeTemplate extends AbstractableTemplate implements ValidatedConf
|
|||||||
@Default
|
@Default
|
||||||
private String carvingEquation = "0";
|
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")
|
@Value("palette")
|
||||||
@Abstractable
|
@Abstractable
|
||||||
private PaletteHolder palette;
|
private PaletteHolder palette;
|
||||||
@ -298,14 +288,6 @@ public class BiomeTemplate extends AbstractableTemplate implements ValidatedConf
|
|||||||
return oreHolder;
|
return oreHolder;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isNoise2d() {
|
|
||||||
return noise2d;
|
|
||||||
}
|
|
||||||
|
|
||||||
public double getNoise2dBase() {
|
|
||||||
return noise2dBase;
|
|
||||||
}
|
|
||||||
|
|
||||||
public double getElevationWeight() {
|
public double getElevationWeight() {
|
||||||
return elevationWeight;
|
return elevationWeight;
|
||||||
}
|
}
|
||||||
|
@ -16,23 +16,19 @@ public class WorldGenerator implements Generator {
|
|||||||
private final NoiseSampler elevation;
|
private final NoiseSampler elevation;
|
||||||
private final NoiseSampler carving;
|
private final NoiseSampler carving;
|
||||||
|
|
||||||
private final boolean noise2d;
|
|
||||||
private final double base;
|
|
||||||
private final NoiseSampler biomeNoise;
|
private final NoiseSampler biomeNoise;
|
||||||
private final double elevationWeight;
|
private final double elevationWeight;
|
||||||
private final int blendDistance;
|
private final int blendDistance;
|
||||||
private final int blendStep;
|
private final int blendStep;
|
||||||
private final double blendWeight;
|
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.palettes = palettes;
|
||||||
this.slantPalettes = slantPalettes;
|
this.slantPalettes = slantPalettes;
|
||||||
this.noise = noise;
|
this.noise = noise;
|
||||||
this.elevation = elevation;
|
this.elevation = elevation;
|
||||||
this.carving = carving;
|
this.carving = carving;
|
||||||
|
|
||||||
this.noise2d = noise2d;
|
|
||||||
this.base = base;
|
|
||||||
this.biomeNoise = biomeNoise;
|
this.biomeNoise = biomeNoise;
|
||||||
this.elevationWeight = elevationWeight;
|
this.elevationWeight = elevationWeight;
|
||||||
this.blendDistance = blendDistance;
|
this.blendDistance = blendDistance;
|
||||||
@ -75,16 +71,6 @@ public class WorldGenerator implements Generator {
|
|||||||
return palettes.getPalette(y);
|
return palettes.getPalette(y);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean is2d() {
|
|
||||||
return noise2d;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public double get2dBase() {
|
|
||||||
return base;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public NoiseSampler getBiomeNoise() {
|
public NoiseSampler getBiomeNoise() {
|
||||||
return biomeNoise;
|
return biomeNoise;
|
||||||
|
@ -11,11 +11,7 @@ public class Sampler {
|
|||||||
private final ElevationInterpolator elevationInterpolator;
|
private final ElevationInterpolator elevationInterpolator;
|
||||||
|
|
||||||
public Sampler(int x, int z, BiomeProvider provider, World world, int elevationSmooth) {
|
public Sampler(int x, int z, BiomeProvider provider, World world, int elevationSmooth) {
|
||||||
this.interpolator = new BiomeChunkInterpolator(world, x, z, provider, (generator, coord) -> {
|
this.interpolator = new BiomeChunkInterpolator(world, x, z, provider, (generator, coord) -> generator.getBaseSampler().getNoise(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.elevationInterpolator = new ElevationInterpolator(world, x, z, provider, elevationSmooth);
|
this.elevationInterpolator = new ElevationInterpolator(world, x, z, provider, elevationSmooth);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user