Implement erosion

This commit is contained in:
dfsek
2020-10-05 20:56:26 -07:00
parent 0e760ec87e
commit 2659577322
13 changed files with 193 additions and 15 deletions

View File

@@ -0,0 +1,30 @@
package com.dfsek.terra.biome;
import org.polydev.gaea.math.FastNoise;
/**
* Class to hold noise function to determine erosion.
*/
public class ErosionNoise {
private final double thresh;
private final FastNoise noise;
public ErosionNoise(float freq1, double thresh, long seed) {
FastNoise main = new FastNoise((int) (seed+1));
main.setNoiseType(FastNoise.NoiseType.SimplexFractal);
main.setFractalOctaves(2);
main.setFrequency(freq1);
this.thresh = thresh;
this.noise = main;
}
/**
* Get whether a location is eroded
* @param x X coordinate
* @param z Z coordinate
* @return Whether location is eroded
*/
boolean isEroded(int x, int z) {
double abs = Math.pow(noise.getNoise(x, z), 2);
return abs < thresh;
}
}