Make sure connecting rivers aren't wider than the river they're connecting to at the point of connection
This commit is contained in:
parent
22d3f8db2c
commit
5633ec9cdd
@ -54,6 +54,7 @@ public class River extends TerrainPopulator {
|
||||
private final Line bed;
|
||||
private final Line banks;
|
||||
private final Line valley;
|
||||
public final RiverConfig config;
|
||||
public final RiverBounds bounds;
|
||||
|
||||
private final Terrains terrains;
|
||||
@ -72,6 +73,7 @@ public class River extends TerrainPopulator {
|
||||
Module bankWidth = Source.constant(config.bankWidth * config.bankWidth);
|
||||
Module valleyWidth = Source.constant(VALLEY_WIDTH * VALLEY_WIDTH);
|
||||
this.bounds = bounds;
|
||||
this.config = config;
|
||||
this.main = config.main;
|
||||
this.terrains = terrains;
|
||||
this.connecting = connecting;
|
||||
|
@ -26,6 +26,7 @@
|
||||
package com.terraforged.core.world.river;
|
||||
|
||||
import com.terraforged.core.world.heightmap.Levels;
|
||||
import me.dags.noise.util.NoiseUtil;
|
||||
|
||||
public class RiverConfig {
|
||||
|
||||
@ -49,6 +50,35 @@ public class RiverConfig {
|
||||
fade = builder.fade;
|
||||
}
|
||||
|
||||
private RiverConfig(boolean main, int bedWidth, int bankWidth, float bedHeight, float minBankHeight, float maxBankHeight, int length2, double fade) {
|
||||
this.main = main;
|
||||
this.bedWidth = bedWidth;
|
||||
this.bankWidth = bankWidth;
|
||||
this.bedHeight = bedHeight;
|
||||
this.minBankHeight = minBankHeight;
|
||||
this.maxBankHeight = maxBankHeight;
|
||||
this.length2 = length2;
|
||||
this.fade = fade;
|
||||
}
|
||||
|
||||
public RiverConfig createFork(float connectWidth) {
|
||||
if (bankWidth < connectWidth) {
|
||||
return this;
|
||||
}
|
||||
|
||||
float scale = bankWidth / connectWidth;
|
||||
return new RiverConfig(
|
||||
false,
|
||||
NoiseUtil.round(bedWidth / scale),
|
||||
NoiseUtil.round(bankWidth / scale),
|
||||
bedHeight,
|
||||
minBankHeight,
|
||||
maxBankHeight,
|
||||
length2,
|
||||
fade
|
||||
);
|
||||
}
|
||||
|
||||
public static Builder builder(Levels levels) {
|
||||
return new Builder(levels);
|
||||
}
|
||||
|
@ -95,15 +95,15 @@ public class RiverRegion {
|
||||
generateRiver(x, z, pos, primary, random, rivers);
|
||||
}
|
||||
|
||||
for (int i = 0; rivers.size() < 10 && i < 50; i++) {
|
||||
for (int i = 0; rivers.size() < 15 && i < 100; i++) {
|
||||
generateRiver(x, z, pos, secondary, random, rivers);
|
||||
}
|
||||
|
||||
for (int i = 0; rivers.size() < 20 && i < 50; i++) {
|
||||
for (int i = 0; rivers.size() < 25 && i < 75; i++) {
|
||||
generateRiverFork(x, z, pos, tertiary, random, rivers);
|
||||
}
|
||||
|
||||
for (int i = 0; rivers.size() < 30 && i < 50; i++) {
|
||||
for (int i = 0; rivers.size() < 40 && i < 50; i++) {
|
||||
generateRiver(x, z, pos, tertiary, random, rivers);
|
||||
}
|
||||
|
||||
@ -211,7 +211,11 @@ public class RiverRegion {
|
||||
|
||||
generateLake(bounds, random);
|
||||
|
||||
return rivers.add(new River(bounds, config, terrains, config.fade, 0, true));
|
||||
// scale the connecting river's width down so that it's narrower than the one it's connecting to
|
||||
float forkWidth = closest.config.bankWidth * distance * 0.6F;
|
||||
RiverConfig forkConfig = config.createFork(forkWidth);
|
||||
|
||||
return rivers.add(new River(bounds, forkConfig, terrains, forkConfig.fade, 0, true));
|
||||
}
|
||||
|
||||
private void generateLake(RiverBounds bounds, Random random) {
|
||||
|
Loading…
Reference in New Issue
Block a user