- per-terrain base, height, width sliders

This commit is contained in:
dags- 2020-02-14 20:14:52 +00:00
parent 0e6c00b1e4
commit 2142c07522
37 changed files with 195 additions and 163 deletions

View File

@ -64,7 +64,7 @@ public abstract class Renderer {
float sat = 70; float sat = 70;
float bri = 70; float bri = 70;
applet.fill(hue, 65, 70); applet.fill(hue, 65, 70);
return cell.regionEdge * el; return height * el;
} else if(applet.controller.getColorMode() == Applet.EROSION) { } else if(applet.controller.getColorMode() == Applet.EROSION) {
float change = cell.sediment + cell.erosion; float change = cell.sediment + cell.erosion;
float value = Math.abs(cell.sediment * 250); float value = Math.abs(cell.sediment * 250);

View File

@ -1,9 +1,9 @@
package com.terraforged.core.cell; package com.terraforged.core.cell;
import me.dags.noise.util.NoiseUtil;
import com.terraforged.core.util.concurrent.ObjectPool; import com.terraforged.core.util.concurrent.ObjectPool;
import com.terraforged.core.world.biome.BiomeType; import com.terraforged.core.world.biome.BiomeType;
import com.terraforged.core.world.terrain.Terrain; import com.terraforged.core.world.terrain.Terrain;
import me.dags.noise.util.NoiseUtil;
public class Cell<T extends Tag> { public class Cell<T extends Tag> {

View File

@ -1,12 +1,12 @@
package com.terraforged.core.decorator; package com.terraforged.core.decorator;
import me.dags.noise.Module;
import me.dags.noise.Source;
import com.terraforged.core.cell.Cell; import com.terraforged.core.cell.Cell;
import com.terraforged.core.util.Seed; import com.terraforged.core.util.Seed;
import com.terraforged.core.world.biome.BiomeType; import com.terraforged.core.world.biome.BiomeType;
import com.terraforged.core.world.heightmap.Levels; import com.terraforged.core.world.heightmap.Levels;
import com.terraforged.core.world.terrain.Terrain; import com.terraforged.core.world.terrain.Terrain;
import me.dags.noise.Module;
import me.dags.noise.Source;
public class DesertStacks implements Decorator { public class DesertStacks implements Decorator {
@ -24,7 +24,7 @@ public class DesertStacks implements Decorator {
Module top = Source.perlin(seed.next(), 4, 1).alpha(0.25); Module top = Source.perlin(seed.next(), 4, 1).alpha(0.25);
Module scale = Source.perlin(seed.next(), 400, 1) Module scale = Source.perlin(seed.next(), 400, 1)
.clamp(20F / 255F, 25F / 255F); .clamp(levels.scale(20), levels.scale(35));
Module stack = (x, y) -> { Module stack = (x, y) -> {
float value = shape.getValue(x, y); float value = shape.getValue(x, y);

View File

@ -1,13 +1,13 @@
package com.terraforged.core.decorator; package com.terraforged.core.decorator;
import me.dags.noise.Module;
import me.dags.noise.Source;
import me.dags.noise.util.NoiseUtil;
import com.terraforged.core.cell.Cell; import com.terraforged.core.cell.Cell;
import com.terraforged.core.util.Seed; import com.terraforged.core.util.Seed;
import com.terraforged.core.world.heightmap.Levels; import com.terraforged.core.world.heightmap.Levels;
import com.terraforged.core.world.terrain.Terrain; import com.terraforged.core.world.terrain.Terrain;
import com.terraforged.core.world.terrain.Terrains; import com.terraforged.core.world.terrain.Terrains;
import me.dags.noise.Module;
import me.dags.noise.Source;
import me.dags.noise.util.NoiseUtil;
public class SwampPools implements Decorator { public class SwampPools implements Decorator {

View File

@ -3,7 +3,6 @@ package com.terraforged.core.filter;
import com.terraforged.core.cell.Cell; import com.terraforged.core.cell.Cell;
import com.terraforged.core.region.Size; import com.terraforged.core.region.Size;
import com.terraforged.core.settings.Settings; import com.terraforged.core.settings.Settings;
import com.terraforged.core.util.PosIterator;
import com.terraforged.core.world.heightmap.Levels; import com.terraforged.core.world.heightmap.Levels;
import me.dags.noise.util.NoiseUtil; import me.dags.noise.util.NoiseUtil;

View File

@ -1,9 +1,9 @@
package com.terraforged.core.filter; package com.terraforged.core.filter;
import me.dags.noise.util.NoiseUtil;
import com.terraforged.core.cell.Cell; import com.terraforged.core.cell.Cell;
import com.terraforged.core.settings.Settings; import com.terraforged.core.settings.Settings;
import com.terraforged.core.world.heightmap.Levels; import com.terraforged.core.world.heightmap.Levels;
import me.dags.noise.util.NoiseUtil;
public class Smoothing implements Filter { public class Smoothing implements Filter {

View File

@ -1,11 +1,11 @@
package com.terraforged.core.module; package com.terraforged.core.module;
import me.dags.noise.Module;
import me.dags.noise.func.Interpolation;
import me.dags.noise.util.NoiseUtil;
import com.terraforged.core.cell.Cell; import com.terraforged.core.cell.Cell;
import com.terraforged.core.cell.Populator; import com.terraforged.core.cell.Populator;
import com.terraforged.core.world.terrain.Terrain; import com.terraforged.core.world.terrain.Terrain;
import me.dags.noise.Module;
import me.dags.noise.func.Interpolation;
import me.dags.noise.util.NoiseUtil;
public class Blender extends Select implements Populator { public class Blender extends Select implements Populator {

View File

@ -1,11 +1,11 @@
package com.terraforged.core.module; package com.terraforged.core.module;
import me.dags.noise.func.Interpolation;
import me.dags.noise.util.NoiseUtil;
import com.terraforged.core.cell.Cell; import com.terraforged.core.cell.Cell;
import com.terraforged.core.cell.Populator; import com.terraforged.core.cell.Populator;
import com.terraforged.core.world.climate.Climate; import com.terraforged.core.world.climate.Climate;
import com.terraforged.core.world.terrain.Terrain; import com.terraforged.core.world.terrain.Terrain;
import me.dags.noise.func.Interpolation;
import me.dags.noise.util.NoiseUtil;
public class MultiBlender extends Select implements Populator { public class MultiBlender extends Select implements Populator {

View File

@ -1,8 +1,8 @@
package com.terraforged.core.module; package com.terraforged.core.module;
import me.dags.noise.Module;
import com.terraforged.core.cell.Cell; import com.terraforged.core.cell.Cell;
import com.terraforged.core.world.terrain.Terrain; import com.terraforged.core.world.terrain.Terrain;
import me.dags.noise.Module;
public class Select { public class Select {

View File

@ -167,15 +167,30 @@ public class Region implements Extent {
public void decorateZoom(Collection<Decorator> decorators, float offsetX, float offsetZ, float zoom) { public void decorateZoom(Collection<Decorator> decorators, float offsetX, float offsetZ, float zoom) {
float translateX = offsetX - ((blockSize.total * zoom) / 2F); float translateX = offsetX - ((blockSize.total * zoom) / 2F);
float translateZ = offsetZ - ((blockSize.total * zoom) / 2F); float translateZ = offsetZ - ((blockSize.total * zoom) / 2F);
for (int dz = 0; dz < blockSize.total; dz++) { for (int cz = 0; cz < chunkSize.total; cz++) {
for (int dx = 0; dx < blockSize.total; dx++) { for (int cx = 0; cx < chunkSize.total; cx++) {
int index = blockSize.indexOf(dx, dz); int index = chunkSize.indexOf(cx, cz);
GenCell cell = blocks[index]; GenChunk chunk = computeChunk(index, cx, cz);
for (Decorator decorator : decorators) { chunk.iterate((cell, dx, dz) -> {
decorator.apply(cell, getBlockX() + translateX + dx, getBlockZ() + translateZ + dz); float x = ((chunk.getBlockX() + dx) * zoom) + translateX;
} float z = ((chunk.getBlockZ() + dz) * zoom) + translateZ;
for (Decorator decorator : decorators) {
decorator.apply(cell, x, z);
}
});
} }
} }
// for (int dz = 0; dz < blockSize.total; dz++) {
// for (int dx = 0; dx < blockSize.total; dx++) {
// int index = blockSize.indexOf(dx, dz);
// GenCell cell = blocks[index];
// for (Decorator decorator : decorators) {
// decorator.apply(cell, getBlockX() + translateX + dx, getBlockZ() + translateZ + dz);
// }
// }
// }
} }
public void iterate(Consumer<ChunkReader> consumer) { public void iterate(Consumer<ChunkReader> consumer) {

View File

@ -1,10 +1,10 @@
package com.terraforged.core.region; package com.terraforged.core.region;
import me.dags.noise.util.NoiseUtil;
import com.terraforged.core.region.chunk.ChunkReader; import com.terraforged.core.region.chunk.ChunkReader;
import com.terraforged.core.util.Cache; import com.terraforged.core.util.Cache;
import com.terraforged.core.util.FutureValue; import com.terraforged.core.util.FutureValue;
import com.terraforged.core.world.heightmap.RegionExtent; import com.terraforged.core.world.heightmap.RegionExtent;
import me.dags.noise.util.NoiseUtil;
import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future; import java.util.concurrent.Future;

View File

@ -1,10 +1,10 @@
package com.terraforged.core.settings; package com.terraforged.core.settings;
import me.dags.noise.Module;
import me.dags.noise.Source;
import com.terraforged.core.util.serialization.annotation.Comment; import com.terraforged.core.util.serialization.annotation.Comment;
import com.terraforged.core.util.serialization.annotation.Range; import com.terraforged.core.util.serialization.annotation.Range;
import com.terraforged.core.util.serialization.annotation.Serializable; import com.terraforged.core.util.serialization.annotation.Serializable;
import me.dags.noise.Module;
import me.dags.noise.Source;
@Serializable @Serializable
public class GeneratorSettings { public class GeneratorSettings {

View File

@ -3,48 +3,57 @@ package com.terraforged.core.settings;
import com.terraforged.core.util.serialization.annotation.Comment; import com.terraforged.core.util.serialization.annotation.Comment;
import com.terraforged.core.util.serialization.annotation.Range; import com.terraforged.core.util.serialization.annotation.Range;
import com.terraforged.core.util.serialization.annotation.Serializable; import com.terraforged.core.util.serialization.annotation.Serializable;
import me.dags.noise.Module;
@Serializable @Serializable
public class TerrainSettings { public class TerrainSettings {
public transient float deepOcean = 1F; public Terrain steppe = new Terrain(5F, 1F, 1F);
public transient float ocean = 1F; public Terrain plains = new Terrain(5F, 1F, 1F);
public transient float coast = 1F; public Terrain hills = new Terrain(2F, 1F, 1F);
public transient float river = 1F; public Terrain dales = new Terrain(2F, 1F, 1F);
public Terrain plateau = new Terrain(1.5F, 1F, 1F);
public Terrain badlands = new Terrain(1.5F, 1F, 1F);
public Terrain torridonian = new Terrain(0.5F, 1F, 1F);
public Terrain mountains = new Terrain(0.5F, 1F, 1F);
public Terrain volcano = new Terrain(1F, 1F, 1F);
@Range(min = 0, max = 10) @Serializable
@Comment("Controls how common this terrain type is") public static class Terrain {
public float steppe = 5F;
@Range(min = 0, max = 10) @Range(min = 0, max = 10)
@Comment("Controls how common this terrain type is") @Comment("Controls how common this terrain type is")
public float plains = 5F; public float weight = 1F;
@Range(min = 0, max = 10) @Range(min = 0, max = 2)
@Comment("Controls how common this terrain type is") @Comment("Controls the base height of this terrain")
public float hills = 2F; public float baseScale = 1F;
@Range(min = 0, max = 10) @Range(min = 0F, max = 10F)
@Comment("Controls how common this terrain type is") @Comment("Stretches or compresses the terrain vertically")
public float dales = 2F; public float verticalScale = 1F;
@Range(min = 0, max = 10) @Range(min = 0F, max = 10F)
@Comment("Controls how common this terrain type is") @Comment("Stretches or compresses the terrain horizontally")
public float plateau = 2F; public float horizontalScale = 1F;
@Range(min = 0, max = 10) public Terrain() {
@Comment("Controls how common this terrain type is")
public float badlands = 2F;
@Range(min = 0, max = 10) }
@Comment("Controls how common this terrain type is")
public float torridonian = 0.5F;
@Range(min = 0, max = 10) public Terrain(float weight, float vertical, float horizontal) {
@Comment("Controls how common this terrain type is") this.weight = weight;
public float mountains = 0.5F; this.verticalScale = vertical;
this.horizontalScale = horizontal;
}
@Range(min = 0, max = 10) public Module apply(double bias, double scale, Module module) {
@Comment("Controls how common this terrain type is") double moduleBias = bias * baseScale;
public float volcano = 1F; double moduleScale = scale * verticalScale;
if (moduleBias + moduleScale > 1) {
return module.scale(moduleScale).bias(moduleBias).clamp(0, 1);
}
return module.scale(moduleScale).bias(moduleBias);
}
}
} }

View File

@ -1,10 +1,10 @@
package com.terraforged.core.util; package com.terraforged.core.util;
import me.dags.noise.Module;
import me.dags.noise.Source;
import com.terraforged.core.cell.Cell; import com.terraforged.core.cell.Cell;
import com.terraforged.core.world.heightmap.Levels; import com.terraforged.core.world.heightmap.Levels;
import com.terraforged.core.world.terrain.Terrain; import com.terraforged.core.world.terrain.Terrain;
import me.dags.noise.Module;
import me.dags.noise.Source;
import java.util.function.BiPredicate; import java.util.function.BiPredicate;

View File

@ -2,7 +2,11 @@ package com.terraforged.core.util.concurrent;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.concurrent.*; import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.ForkJoinPool;
import java.util.concurrent.Future;
public class ThreadPool { public class ThreadPool {

View File

@ -2,7 +2,11 @@ package com.terraforged.core.util.grid;
import me.dags.noise.util.NoiseUtil; import me.dags.noise.util.NoiseUtil;
import java.util.*; import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.function.Function; import java.util.function.Function;
import java.util.function.Supplier; import java.util.function.Supplier;

View File

@ -2,7 +2,11 @@ package com.terraforged.core.util.grid;
import me.dags.noise.util.NoiseUtil; import me.dags.noise.util.NoiseUtil;
import java.util.*; import java.util.Collections;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
public class FixedList<T> implements Iterable<T> { public class FixedList<T> implements Iterable<T> {

View File

@ -1,7 +1,6 @@
package com.terraforged.core.world; package com.terraforged.core.world;
import com.terraforged.core.decorator.Decorator; import com.terraforged.core.decorator.Decorator;
import com.terraforged.core.decorator.DesertDunes;
import com.terraforged.core.decorator.DesertStacks; import com.terraforged.core.decorator.DesertStacks;
import com.terraforged.core.decorator.SwampPools; import com.terraforged.core.decorator.SwampPools;

View File

@ -1,16 +1,16 @@
package com.terraforged.core.world.climate; package com.terraforged.core.world.climate;
import com.terraforged.core.cell.Cell;
import com.terraforged.core.settings.GeneratorSettings;
import com.terraforged.core.util.Seed;
import com.terraforged.core.world.biome.BiomeType;
import com.terraforged.core.world.terrain.Terrain;
import me.dags.noise.Module; import me.dags.noise.Module;
import me.dags.noise.Source; import me.dags.noise.Source;
import me.dags.noise.func.DistanceFunc; import me.dags.noise.func.DistanceFunc;
import me.dags.noise.func.EdgeFunc; import me.dags.noise.func.EdgeFunc;
import me.dags.noise.util.NoiseUtil; import me.dags.noise.util.NoiseUtil;
import me.dags.noise.util.Vec2f; import me.dags.noise.util.Vec2f;
import com.terraforged.core.cell.Cell;
import com.terraforged.core.settings.GeneratorSettings;
import com.terraforged.core.util.Seed;
import com.terraforged.core.world.biome.BiomeType;
import com.terraforged.core.world.terrain.Terrain;
public class ClimateModule { public class ClimateModule {

View File

@ -2,7 +2,6 @@ package com.terraforged.core.world.continent;
import com.terraforged.core.cell.Cell; import com.terraforged.core.cell.Cell;
import com.terraforged.core.cell.Populator; import com.terraforged.core.cell.Populator;
import com.terraforged.core.module.MultiBlender;
import com.terraforged.core.world.climate.Climate; import com.terraforged.core.world.climate.Climate;
import com.terraforged.core.world.terrain.Terrain; import com.terraforged.core.world.terrain.Terrain;
import me.dags.noise.func.Interpolation; import me.dags.noise.func.Interpolation;

View File

@ -1,5 +1,10 @@
package com.terraforged.core.world.continent; package com.terraforged.core.world.continent;
import com.terraforged.core.cell.Cell;
import com.terraforged.core.cell.Populator;
import com.terraforged.core.settings.GeneratorSettings;
import com.terraforged.core.util.Seed;
import com.terraforged.core.world.terrain.Terrain;
import me.dags.noise.Module; import me.dags.noise.Module;
import me.dags.noise.Source; import me.dags.noise.Source;
import me.dags.noise.domain.Domain; import me.dags.noise.domain.Domain;
@ -7,11 +12,6 @@ import me.dags.noise.func.DistanceFunc;
import me.dags.noise.func.EdgeFunc; import me.dags.noise.func.EdgeFunc;
import me.dags.noise.util.NoiseUtil; import me.dags.noise.util.NoiseUtil;
import me.dags.noise.util.Vec2f; import me.dags.noise.util.Vec2f;
import com.terraforged.core.cell.Cell;
import com.terraforged.core.cell.Populator;
import com.terraforged.core.settings.GeneratorSettings;
import com.terraforged.core.util.Seed;
import com.terraforged.core.world.terrain.Terrain;
public class ContinentModule implements Populator { public class ContinentModule implements Populator {

View File

@ -1,9 +1,9 @@
package com.terraforged.core.world.geology; package com.terraforged.core.world.geology;
import com.terraforged.core.util.Seed;
import me.dags.noise.Module; import me.dags.noise.Module;
import me.dags.noise.Source; import me.dags.noise.Source;
import me.dags.noise.util.NoiseUtil; import me.dags.noise.util.NoiseUtil;
import com.terraforged.core.util.Seed;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.LinkedList; import java.util.LinkedList;

View File

@ -1,7 +1,7 @@
package com.terraforged.core.world.heightmap; package com.terraforged.core.world.heightmap;
import me.dags.noise.util.NoiseUtil;
import com.terraforged.core.settings.GeneratorSettings; import com.terraforged.core.settings.GeneratorSettings;
import me.dags.noise.util.NoiseUtil;
public class Levels { public class Levels {

View File

@ -11,14 +11,14 @@ import com.terraforged.core.world.climate.Climate;
import com.terraforged.core.world.continent.ContinentLerper2; import com.terraforged.core.world.continent.ContinentLerper2;
import com.terraforged.core.world.continent.ContinentLerper3; import com.terraforged.core.world.continent.ContinentLerper3;
import com.terraforged.core.world.continent.ContinentModule; import com.terraforged.core.world.continent.ContinentModule;
import com.terraforged.core.world.terrain.region.RegionLerper;
import com.terraforged.core.world.terrain.region.RegionModule;
import com.terraforged.core.world.terrain.region.RegionSelector;
import com.terraforged.core.world.river.RiverManager; import com.terraforged.core.world.river.RiverManager;
import com.terraforged.core.world.terrain.Terrain; import com.terraforged.core.world.terrain.Terrain;
import com.terraforged.core.world.terrain.TerrainPopulator; import com.terraforged.core.world.terrain.TerrainPopulator;
import com.terraforged.core.world.terrain.Terrains; import com.terraforged.core.world.terrain.Terrains;
import com.terraforged.core.world.terrain.provider.TerrainProvider; import com.terraforged.core.world.terrain.provider.TerrainProvider;
import com.terraforged.core.world.terrain.region.RegionLerper;
import com.terraforged.core.world.terrain.region.RegionModule;
import com.terraforged.core.world.terrain.region.RegionSelector;
import me.dags.noise.Module; import me.dags.noise.Module;
import me.dags.noise.Source; import me.dags.noise.Source;
import me.dags.noise.func.EdgeFunc; import me.dags.noise.func.EdgeFunc;

View File

@ -1,12 +1,12 @@
package com.terraforged.core.world.river; package com.terraforged.core.world.river;
import me.dags.noise.Source;
import me.dags.noise.util.NoiseUtil;
import me.dags.noise.util.Vec2f;
import com.terraforged.core.cell.Cell; import com.terraforged.core.cell.Cell;
import com.terraforged.core.world.terrain.Terrain; import com.terraforged.core.world.terrain.Terrain;
import com.terraforged.core.world.terrain.TerrainPopulator; import com.terraforged.core.world.terrain.TerrainPopulator;
import com.terraforged.core.world.terrain.Terrains; import com.terraforged.core.world.terrain.Terrains;
import me.dags.noise.Source;
import me.dags.noise.util.NoiseUtil;
import me.dags.noise.util.Vec2f;
public class Lake extends TerrainPopulator { public class Lake extends TerrainPopulator {

View File

@ -1,10 +1,10 @@
package com.terraforged.core.world.river; package com.terraforged.core.world.river;
import com.terraforged.core.cell.Cell;
import com.terraforged.core.world.heightmap.Heightmap; import com.terraforged.core.world.heightmap.Heightmap;
import com.terraforged.core.world.terrain.Terrain;
import me.dags.noise.domain.Domain; import me.dags.noise.domain.Domain;
import me.dags.noise.util.Vec2i; import me.dags.noise.util.Vec2i;
import com.terraforged.core.cell.Cell;
import com.terraforged.core.world.terrain.Terrain;
import java.util.Random; import java.util.Random;

View File

@ -1,13 +1,13 @@
package com.terraforged.core.world.river; package com.terraforged.core.world.river;
import me.dags.noise.Module;
import me.dags.noise.Source;
import me.dags.noise.source.Line;
import me.dags.noise.util.NoiseUtil;
import com.terraforged.core.cell.Cell; import com.terraforged.core.cell.Cell;
import com.terraforged.core.world.terrain.Terrain; import com.terraforged.core.world.terrain.Terrain;
import com.terraforged.core.world.terrain.TerrainPopulator; import com.terraforged.core.world.terrain.TerrainPopulator;
import com.terraforged.core.world.terrain.Terrains; import com.terraforged.core.world.terrain.Terrains;
import me.dags.noise.Module;
import me.dags.noise.Source;
import me.dags.noise.source.Line;
import me.dags.noise.util.NoiseUtil;
public class River extends TerrainPopulator { public class River extends TerrainPopulator {

View File

@ -1,11 +1,11 @@
package com.terraforged.core.world.river; package com.terraforged.core.world.river;
import com.terraforged.core.world.heightmap.Heightmap;
import me.dags.noise.util.NoiseUtil;
import com.terraforged.core.cell.Cell; import com.terraforged.core.cell.Cell;
import com.terraforged.core.util.Cache; import com.terraforged.core.util.Cache;
import com.terraforged.core.world.GeneratorContext; import com.terraforged.core.world.GeneratorContext;
import com.terraforged.core.world.heightmap.Heightmap;
import com.terraforged.core.world.terrain.Terrain; import com.terraforged.core.world.terrain.Terrain;
import me.dags.noise.util.NoiseUtil;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;

View File

@ -1,15 +1,15 @@
package com.terraforged.core.world.river; package com.terraforged.core.world.river;
import com.terraforged.core.cell.Cell;
import com.terraforged.core.util.concurrent.ObjectPool;
import com.terraforged.core.world.GeneratorContext;
import com.terraforged.core.world.heightmap.Heightmap; import com.terraforged.core.world.heightmap.Heightmap;
import com.terraforged.core.world.terrain.Terrain;
import com.terraforged.core.world.terrain.Terrains;
import me.dags.noise.domain.Domain; import me.dags.noise.domain.Domain;
import me.dags.noise.util.NoiseUtil; import me.dags.noise.util.NoiseUtil;
import me.dags.noise.util.Vec2f; import me.dags.noise.util.Vec2f;
import me.dags.noise.util.Vec2i; import me.dags.noise.util.Vec2i;
import com.terraforged.core.cell.Cell;
import com.terraforged.core.util.concurrent.ObjectPool;
import com.terraforged.core.world.GeneratorContext;
import com.terraforged.core.world.terrain.Terrain;
import com.terraforged.core.world.terrain.Terrains;
import java.util.Collections; import java.util.Collections;
import java.util.LinkedList; import java.util.LinkedList;

View File

@ -1,10 +1,11 @@
package com.terraforged.core.world.terrain; package com.terraforged.core.world.terrain;
import com.terraforged.core.settings.TerrainSettings;
import com.terraforged.core.util.Seed;
import com.terraforged.core.world.heightmap.Levels;
import me.dags.noise.Module; import me.dags.noise.Module;
import me.dags.noise.Source; import me.dags.noise.Source;
import me.dags.noise.func.EdgeFunc; import me.dags.noise.func.EdgeFunc;
import com.terraforged.core.util.Seed;
import com.terraforged.core.world.heightmap.Levels;
public class LandForms { public class LandForms {
@ -14,10 +15,6 @@ public class LandForms {
public static final int PLATEAU_H = 500; public static final int PLATEAU_H = 500;
public static final double PLATEAU_V = 0.475; public static final double PLATEAU_V = 0.475;
public static final int LOESS_H0 = 100;
public static final int LOESS_H1 = 200;
public static final double LOESS_V = 0.5;
private static final int HILLS_H = 500; private static final int HILLS_H = 500;
private static final double HILLS1_V = 0.6; private static final double HILLS1_V = 0.6;
private static final double HILLS2_V = 0.55; private static final double HILLS2_V = 0.55;
@ -28,12 +25,14 @@ public class LandForms {
private static final int MOUNTAINS2_H = 400; private static final int MOUNTAINS2_H = 400;
private static final double MOUNTAINS2_V = 0.645; private static final double MOUNTAINS2_V = 0.645;
private final TerrainSettings settings;
private final float terrainHorizontalScale; private final float terrainHorizontalScale;
private final float terrainVerticalScale; private final float terrainVerticalScale;
private final float groundLevel; private final float groundLevel;
private final float seaLevel; private final float seaLevel;
public LandForms(Levels levels) { public LandForms(TerrainSettings settings, Levels levels) {
this.settings = settings;
terrainHorizontalScale = 1.025F; terrainHorizontalScale = 1.025F;
terrainVerticalScale = 1F; terrainVerticalScale = 1F;
groundLevel = levels.ground; groundLevel = levels.ground;
@ -57,24 +56,23 @@ public class LandForms {
} }
public Module steppe(Seed seed) { public Module steppe(Seed seed) {
int scaleH = Math.round(PLAINS_H * terrainHorizontalScale); int scaleH = Math.round(PLAINS_H * terrainHorizontalScale * settings.steppe.horizontalScale);
double erosionAmount = 0.45; double erosionAmount = 0.45;
Module erosion = Source.build(seed.next(), scaleH * 2, 3).lacunarity(3.75).perlin().alpha(erosionAmount); Module erosion = Source.build(seed.next(), scaleH * 2, 3).lacunarity(3.75).perlin().alpha(erosionAmount);
Module warpX = Source.build(seed.next(), scaleH / 4, 3).lacunarity(3).perlin(); Module warpX = Source.build(seed.next(), scaleH / 4, 3).lacunarity(3).perlin();
Module warpY = Source.build(seed.next(), scaleH / 4, 3).lacunarity(3).perlin(); Module warpY = Source.build(seed.next(), scaleH / 4, 3).lacunarity(3).perlin();
Module module = Source.perlin(seed.next(), scaleH, 1)
return Source.perlin(seed.next(), scaleH, 1)
.mult(erosion) .mult(erosion)
.warp(warpX, warpY, Source.constant(scaleH / 4F)) .warp(warpX, warpY, Source.constant(scaleH / 4F))
.warp(seed.next(), 256, 1, 200) .warp(seed.next(), 256, 1, 200);
.scale(0.125 * terrainVerticalScale)
.bias(groundLevel); return settings.steppe.apply(groundLevel, 0.125 * terrainVerticalScale, module);
} }
public Module plains(Seed seed) { public Module plains(Seed seed) {
int scaleH = Math.round(PLAINS_H * terrainHorizontalScale); int scaleH = Math.round(PLAINS_H * terrainHorizontalScale * settings.plains.horizontalScale);
double erosionAmount = 0.45; double erosionAmount = 0.45;
@ -82,12 +80,12 @@ public class LandForms {
Module warpX = Source.build(seed.next(), scaleH / 4, 3).lacunarity(3.5).perlin(); Module warpX = Source.build(seed.next(), scaleH / 4, 3).lacunarity(3.5).perlin();
Module warpY = Source.build(seed.next(), scaleH / 4, 3).lacunarity(3.5).perlin(); Module warpY = Source.build(seed.next(), scaleH / 4, 3).lacunarity(3.5).perlin();
return Source.perlin(seed.next(), scaleH, 1) Module module = Source.perlin(seed.next(), scaleH, 1)
.mult(erosion) .mult(erosion)
.warp(warpX, warpY, Source.constant(scaleH / 4F)) .warp(warpX, warpY, Source.constant(scaleH / 4F))
.warp(seed.next(), 256, 1, 256) .warp(seed.next(), 256, 1, 256);
.scale(PLAINS_V * terrainVerticalScale)
.bias(groundLevel); return settings.plains.apply(groundLevel, PLAINS_V * terrainVerticalScale, module);
} }
public Module plateau(Seed seed) { public Module plateau(Seed seed) {
@ -104,37 +102,32 @@ public class LandForms {
Module surface = Source.perlin(seed.next(), 20, 3).scale(0.05) Module surface = Source.perlin(seed.next(), 20, 3).scale(0.05)
.warp(seed.next(), 40, 2, 20); .warp(seed.next(), 40, 2, 20);
return valley return settings.plateau.apply(groundLevel, PLATEAU_V * terrainVerticalScale,
.mult(Source.cubic(seed.next(), 500, 1).scale(0.6).bias(0.3)) valley
.add(top) .mult(Source.cubic(seed.next(), 500, 1).scale(0.6).bias(0.3))
.terrace( .add(top)
Source.perlin(seed.next(), 20, 1).scale(0.3).bias(0.2), .terrace(
Source.perlin(seed.next(), 20, 2).scale(0.1).bias(0.2), Source.perlin(seed.next(), 20, 1).scale(0.3).bias(0.2),
4, Source.perlin(seed.next(), 20, 2).scale(0.1).bias(0.2),
0.4 4,
) 0.4
.add(surface) )
.scale(PLATEAU_V * terrainVerticalScale) .add(surface));
.bias(groundLevel);
} }
public Module hills1(Seed seed) { public Module hills1(Seed seed) {
return Source.perlin(seed.next(), 200, 3) return settings.hills.apply(groundLevel, HILLS1_V * terrainVerticalScale, Source.perlin(seed.next(), 200, 3)
.mult(Source.billow(seed.next(), 400, 3).alpha(0.5)) .mult(Source.billow(seed.next(), 400, 3).alpha(0.5))
.warp(seed.next(), 30, 3, 20) .warp(seed.next(), 30, 3, 20)
.warp(seed.next(), 400, 3, 200) .warp(seed.next(), 400, 3, 200));
.scale(HILLS1_V * terrainVerticalScale)
.bias(groundLevel);
} }
public Module hills2(Seed seed) { public Module hills2(Seed seed) {
return Source.cubic(seed.next(), 128, 2) return settings.hills.apply(groundLevel, HILLS2_V * terrainVerticalScale, Source.cubic(seed.next(), 128, 2)
.mult(Source.perlin(seed.next(), 32, 4).alpha(0.075)) .mult(Source.perlin(seed.next(), 32, 4).alpha(0.075))
.warp(seed.next(), 30, 3, 20) .warp(seed.next(), 30, 3, 20)
.warp(seed.next(), 400, 3, 200) .warp(seed.next(), 400, 3, 200)
.mult(Source.ridge(seed.next(), 512, 2).alpha(0.8)) .mult(Source.ridge(seed.next(), 512, 2).alpha(0.8)));
.scale(HILLS2_V * terrainVerticalScale)
.bias(groundLevel);
} }
public Module dales(Seed seed) { public Module dales(Seed seed) {
@ -149,16 +142,18 @@ public class LandForms {
Module hills = combined Module hills = combined
.pow(1.125) .pow(1.125)
.warp(seed.next(), 300, 1, 100); .warp(seed.next(), 300, 1, 100);
return hills.scale(0.24).bias(groundLevel);
return settings.dales.apply(groundLevel, 0.4, hills);
} }
public Module mountains(Seed seed) { public Module mountains(Seed seed) {
int scaleH = Math.round(MOUNTAINS_H * terrainHorizontalScale); int scaleH = Math.round(MOUNTAINS_H * terrainHorizontalScale * settings.mountains.horizontalScale);
return Source.build(seed.next(), scaleH, 4).gain(1.15).lacunarity(2.35).ridge()
Module module = Source.build(seed.next(), scaleH, 4).gain(1.15).lacunarity(2.35).ridge()
.mult(Source.perlin(seed.next(), 24, 4).alpha(0.075)) .mult(Source.perlin(seed.next(), 24, 4).alpha(0.075))
.warp(seed.next(), 350, 1, 150) .warp(seed.next(), 350, 1, 150);
.scale(MOUNTAINS_V * terrainVerticalScale)
.bias(groundLevel); return settings.mountains.apply(groundLevel, MOUNTAINS_V * terrainVerticalScale, module);
} }
public Module mountains2(Seed seed) { public Module mountains2(Seed seed) {
@ -168,7 +163,7 @@ public class LandForms {
Module blur = Source.perlin(seed.next(), 10, 1).alpha(0.025); Module blur = Source.perlin(seed.next(), 10, 1).alpha(0.025);
Module surface = Source.ridge(seed.next(), 125, 4).alpha(0.37); Module surface = Source.ridge(seed.next(), 125, 4).alpha(0.37);
Module mountains = cell.clamp(0, 1).mult(blur).mult(surface).pow(1.1); Module mountains = cell.clamp(0, 1).mult(blur).mult(surface).pow(1.1);
return mountains.scale(scale).bias(groundLevel); return settings.mountains.apply(groundLevel, scale, mountains);
} }
public Module mountains3(Seed seed) { public Module mountains3(Seed seed) {
@ -190,7 +185,7 @@ public class LandForms {
1 1
); );
return terraced.scale(scale).bias(groundLevel); return settings.mountains.apply(groundLevel, scale, terraced);
} }
public Module badlands(Seed seed) { public Module badlands(Seed seed) {
@ -213,7 +208,7 @@ public class LandForms {
.add(mod2) .add(mod2)
.scale(alpha); .scale(alpha);
return shape.mult(detail.alpha(0.5)).scale(0.7).bias(groundLevel); return settings.badlands.apply(groundLevel, 0.7, shape.mult(detail.alpha(0.5)));
} }
public Module torridonian(Seed seed) { public Module torridonian(Seed seed) {
@ -239,6 +234,6 @@ public class LandForms {
1 1
).boost(); ).boost();
return test.scale(0.5).bias(groundLevel); return settings.torridonian.apply(groundLevel, 0.5, test);
} }
} }

View File

@ -110,42 +110,42 @@ public class Terrain implements Tag {
} }
public static Terrain steppe(Settings settings) { public static Terrain steppe(Settings settings) {
return new Terrain("steppe", 5, settings.terrain.steppe); return new Terrain("steppe", 5, settings.terrain.steppe.weight);
} }
public static Terrain plains(Settings settings) { public static Terrain plains(Settings settings) {
return new Terrain("plains", 5, settings.terrain.plains); return new Terrain("plains", 5, settings.terrain.plains.weight);
} }
public static Terrain plateau(Settings settings) { public static Terrain plateau(Settings settings) {
return new Terrain("plateau", 6, settings.terrain.plateau); return new Terrain("plateau", 6, settings.terrain.plateau.weight);
} }
public static Terrain badlands(Settings settings) { public static Terrain badlands(Settings settings) {
return new Terrain("badlands", 7, settings.terrain.badlands); return new Terrain("badlands", 7, settings.terrain.badlands.weight);
} }
public static Terrain hills(Settings settings) { public static Terrain hills(Settings settings) {
return new Terrain("hills", 8, settings.terrain.hills); return new Terrain("hills", 8, settings.terrain.hills.weight);
} }
public static Terrain dales(Settings settings) { public static Terrain dales(Settings settings) {
return new Terrain("dales", 9, settings.terrain.hills); return new Terrain("dales", 9, settings.terrain.dales.weight);
} }
public static Terrain torridonian(Settings settings) { public static Terrain torridonian(Settings settings) {
return new Terrain("torridonian_fells", 10, settings.terrain.torridonian); return new Terrain("torridonian_fells", 10, settings.terrain.torridonian.weight);
} }
public static Terrain mountains(Settings settings) { public static Terrain mountains(Settings settings) {
return new Terrain("mountains", 11, settings.terrain.mountains); return new Terrain("mountains", 11, settings.terrain.mountains.weight);
} }
public static Terrain volcano(Settings settings) { public static Terrain volcano(Settings settings) {
return new Terrain("volcano", 12, settings.terrain.volcano); return new Terrain("volcano", 12, settings.terrain.volcano.weight);
} }
public static Terrain volcanoPipe(Settings settings) { public static Terrain volcanoPipe(Settings settings) {
return new Terrain("volcano_pipe", 13, settings.terrain.volcano); return new Terrain("volcano_pipe", 13, settings.terrain.volcano.weight);
} }
} }

View File

@ -1,10 +1,10 @@
package com.terraforged.core.world.terrain; package com.terraforged.core.world.terrain;
import me.dags.noise.Module;
import me.dags.noise.Source;
import com.terraforged.core.cell.Cell; import com.terraforged.core.cell.Cell;
import com.terraforged.core.cell.Populator; import com.terraforged.core.cell.Populator;
import com.terraforged.core.util.Seed; import com.terraforged.core.util.Seed;
import me.dags.noise.Module;
import me.dags.noise.Source;
import java.util.Arrays; import java.util.Arrays;
import java.util.function.BiFunction; import java.util.function.BiFunction;

View File

@ -1,12 +1,12 @@
package com.terraforged.core.world.terrain; package com.terraforged.core.world.terrain;
import me.dags.noise.Module;
import me.dags.noise.Source;
import me.dags.noise.func.EdgeFunc;
import com.terraforged.core.cell.Cell; import com.terraforged.core.cell.Cell;
import com.terraforged.core.util.Seed; import com.terraforged.core.util.Seed;
import com.terraforged.core.world.heightmap.Levels; import com.terraforged.core.world.heightmap.Levels;
import com.terraforged.core.world.heightmap.RegionConfig; import com.terraforged.core.world.heightmap.RegionConfig;
import me.dags.noise.Module;
import me.dags.noise.Source;
import me.dags.noise.func.EdgeFunc;
public class VolcanoPopulator extends TerrainPopulator { public class VolcanoPopulator extends TerrainPopulator {

View File

@ -1,7 +1,5 @@
package com.terraforged.core.world.terrain.provider; package com.terraforged.core.world.terrain.provider;
import me.dags.noise.Module;
import me.dags.noise.Source;
import com.terraforged.core.cell.Populator; import com.terraforged.core.cell.Populator;
import com.terraforged.core.util.Seed; import com.terraforged.core.util.Seed;
import com.terraforged.core.world.GeneratorContext; import com.terraforged.core.world.GeneratorContext;
@ -10,6 +8,8 @@ import com.terraforged.core.world.terrain.LandForms;
import com.terraforged.core.world.terrain.Terrain; import com.terraforged.core.world.terrain.Terrain;
import com.terraforged.core.world.terrain.TerrainPopulator; import com.terraforged.core.world.terrain.TerrainPopulator;
import com.terraforged.core.world.terrain.VolcanoPopulator; import com.terraforged.core.world.terrain.VolcanoPopulator;
import me.dags.noise.Module;
import me.dags.noise.Source;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
@ -31,7 +31,7 @@ public class StandardTerrainProvider implements TerrainProvider {
public StandardTerrainProvider(GeneratorContext context, RegionConfig config, Populator defaultPopulator) { public StandardTerrainProvider(GeneratorContext context, RegionConfig config, Populator defaultPopulator) {
this.config = config; this.config = config;
this.context = context; this.context = context;
this.landForms = new LandForms(context.levels); this.landForms = new LandForms(context.settings.terrain, context.levels);
this.defaultPopulator = defaultPopulator; this.defaultPopulator = defaultPopulator;
init(); init();
} }

View File

@ -1,10 +1,10 @@
package com.terraforged.core.world.terrain.provider; package com.terraforged.core.world.terrain.provider;
import me.dags.noise.Module;
import com.terraforged.core.cell.Populator; import com.terraforged.core.cell.Populator;
import com.terraforged.core.world.terrain.LandForms; import com.terraforged.core.world.terrain.LandForms;
import com.terraforged.core.world.terrain.Terrain; import com.terraforged.core.world.terrain.Terrain;
import com.terraforged.core.world.terrain.TerrainPopulator; import com.terraforged.core.world.terrain.TerrainPopulator;
import me.dags.noise.Module;
import java.util.List; import java.util.List;

View File

@ -57,6 +57,10 @@ public class RegionSelector implements Populator {
} }
} }
if (result.isEmpty()) {
return modules.toArray(new Populator[0]);
}
return result.toArray(new Populator[0]); return result.toArray(new Populator[0]);
} }
} }

@ -1 +1 @@
Subproject commit fbfbdfec2824f1640c6ec4df9682b07ce97e1982 Subproject commit 39012b51fb49d214c85332f00cf353c1f6e727c7