tweaks to sea-level dependent functions (treeline + beach line)
This commit is contained in:
parent
97a1089f57
commit
7803122ea1
@ -26,26 +26,23 @@
|
||||
package com.terraforged.core.filter;
|
||||
|
||||
import com.terraforged.core.cell.Cell;
|
||||
import com.terraforged.core.world.heightmap.Levels;
|
||||
import com.terraforged.core.world.terrain.Terrains;
|
||||
|
||||
public class Steepness implements Filter, Filter.Visitor {
|
||||
|
||||
private final int radius;
|
||||
private final float scaler;
|
||||
private final float waterLevel;
|
||||
private final float maxBeachLevel;
|
||||
private final Terrains terrains;
|
||||
|
||||
public Steepness(Terrains terrains) {
|
||||
this(2, 16F, terrains);
|
||||
}
|
||||
|
||||
public Steepness(float scaler, Terrains terrains) {
|
||||
this(2, scaler, terrains);
|
||||
}
|
||||
|
||||
public Steepness(int radius, float scaler, Terrains terrains) {
|
||||
public Steepness(int radius, float scaler, Terrains terrains, Levels levels) {
|
||||
this.radius = radius;
|
||||
this.scaler = scaler;
|
||||
this.terrains = terrains;
|
||||
this.waterLevel = levels.water;
|
||||
this.maxBeachLevel = levels.water(6);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -69,13 +66,13 @@ public class Steepness implements Filter, Filter.Visitor {
|
||||
continue;
|
||||
}
|
||||
|
||||
float height = Math.max(neighbour.value, 62 / 256F);
|
||||
float height = Math.max(neighbour.value, waterLevel);
|
||||
|
||||
totalHeightDif += (Math.abs(cell.value - height) / radius);
|
||||
}
|
||||
}
|
||||
cell.steepness = Math.min(1, totalHeightDif * scaler);
|
||||
if (cell.tag == terrains.coast && cell.steepness < 0.22F) {
|
||||
if (cell.tag == terrains.coast && cell.steepness < 0.225F && cell.value < maxBeachLevel) {
|
||||
cell.tag = terrains.beach;
|
||||
}
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ public class WorldFilters {
|
||||
this.settings = context.settings.filters;
|
||||
this.erosion = new Erosion(context.settings, context.levels);
|
||||
this.smoothing = new Smoothing(context.settings, context.levels);
|
||||
this.steepness = new Steepness(1, 10F, context.terrain);
|
||||
this.steepness = new Steepness(1, 10F, context.terrain, context.levels);
|
||||
}
|
||||
|
||||
public void apply(Region region) {
|
||||
|
@ -53,7 +53,9 @@ public class Climate {
|
||||
this.biomeNoise = new ClimateModule(context.seed, context.settings);
|
||||
|
||||
this.treeLine = Source.perlin(context.seed.next(), context.settings.generator.biome.biomeSize * 2, 1)
|
||||
.scale(0.1).bias(0.4);
|
||||
.scale(context.levels.scale(25)) // 30 units worth of variance
|
||||
.bias(context.levels.ground(40)) // start at-least 30 units above ground level
|
||||
.clamp(0, 1);
|
||||
|
||||
this.rand = new Rand(Source.builder().seed(context.seed.next()));
|
||||
this.offsetX = context.settings.generator.biomeEdgeNoise.build(context.seed.next());
|
||||
|
Loading…
Reference in New Issue
Block a user