tweaks to sea-level dependent functions (treeline + beach line)

This commit is contained in:
dags- 2020-03-26 22:49:19 +00:00
parent 97a1089f57
commit 7803122ea1
3 changed files with 12 additions and 13 deletions

View File

@ -26,26 +26,23 @@
package com.terraforged.core.filter; package com.terraforged.core.filter;
import com.terraforged.core.cell.Cell; import com.terraforged.core.cell.Cell;
import com.terraforged.core.world.heightmap.Levels;
import com.terraforged.core.world.terrain.Terrains; import com.terraforged.core.world.terrain.Terrains;
public class Steepness implements Filter, Filter.Visitor { public class Steepness implements Filter, Filter.Visitor {
private final int radius; private final int radius;
private final float scaler; private final float scaler;
private final float waterLevel;
private final float maxBeachLevel;
private final Terrains terrains; private final Terrains terrains;
public Steepness(Terrains terrains) { public Steepness(int radius, float scaler, Terrains terrains, Levels levels) {
this(2, 16F, terrains);
}
public Steepness(float scaler, Terrains terrains) {
this(2, scaler, terrains);
}
public Steepness(int radius, float scaler, Terrains terrains) {
this.radius = radius; this.radius = radius;
this.scaler = scaler; this.scaler = scaler;
this.terrains = terrains; this.terrains = terrains;
this.waterLevel = levels.water;
this.maxBeachLevel = levels.water(6);
} }
@Override @Override
@ -69,13 +66,13 @@ public class Steepness implements Filter, Filter.Visitor {
continue; continue;
} }
float height = Math.max(neighbour.value, 62 / 256F); float height = Math.max(neighbour.value, waterLevel);
totalHeightDif += (Math.abs(cell.value - height) / radius); totalHeightDif += (Math.abs(cell.value - height) / radius);
} }
} }
cell.steepness = Math.min(1, totalHeightDif * scaler); 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; cell.tag = terrains.beach;
} }
} }

View File

@ -45,7 +45,7 @@ public class WorldFilters {
this.settings = context.settings.filters; this.settings = context.settings.filters;
this.erosion = new Erosion(context.settings, context.levels); this.erosion = new Erosion(context.settings, context.levels);
this.smoothing = new Smoothing(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) { public void apply(Region region) {

View File

@ -53,7 +53,9 @@ public class Climate {
this.biomeNoise = new ClimateModule(context.seed, context.settings); this.biomeNoise = new ClimateModule(context.seed, context.settings);
this.treeLine = Source.perlin(context.seed.next(), context.settings.generator.biome.biomeSize * 2, 1) 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.rand = new Rand(Source.builder().seed(context.seed.next()));
this.offsetX = context.settings.generator.biomeEdgeNoise.build(context.seed.next()); this.offsetX = context.settings.generator.biomeEdgeNoise.build(context.seed.next());