diff --git a/TerraForgedApp/src/main/java/com/terraforged/app/renderer/Renderer.java b/TerraForgedApp/src/main/java/com/terraforged/app/renderer/Renderer.java index 15d277f..6ca4278 100644 --- a/TerraForgedApp/src/main/java/com/terraforged/app/renderer/Renderer.java +++ b/TerraForgedApp/src/main/java/com/terraforged/app/renderer/Renderer.java @@ -64,7 +64,7 @@ public abstract class Renderer { float sat = 70; float bri = 70; applet.fill(hue, 65, 70); - return cell.regionEdge * el; + return height * el; } else if(applet.controller.getColorMode() == Applet.EROSION) { float change = cell.sediment + cell.erosion; float value = Math.abs(cell.sediment * 250); diff --git a/TerraForgedCore/src/main/java/com/terraforged/core/cell/Cell.java b/TerraForgedCore/src/main/java/com/terraforged/core/cell/Cell.java index 143d1f8..ecd1d09 100644 --- a/TerraForgedCore/src/main/java/com/terraforged/core/cell/Cell.java +++ b/TerraForgedCore/src/main/java/com/terraforged/core/cell/Cell.java @@ -1,9 +1,9 @@ package com.terraforged.core.cell; -import me.dags.noise.util.NoiseUtil; import com.terraforged.core.util.concurrent.ObjectPool; import com.terraforged.core.world.biome.BiomeType; import com.terraforged.core.world.terrain.Terrain; +import me.dags.noise.util.NoiseUtil; public class Cell { diff --git a/TerraForgedCore/src/main/java/com/terraforged/core/decorator/DesertStacks.java b/TerraForgedCore/src/main/java/com/terraforged/core/decorator/DesertStacks.java index 935ed31..4901f85 100644 --- a/TerraForgedCore/src/main/java/com/terraforged/core/decorator/DesertStacks.java +++ b/TerraForgedCore/src/main/java/com/terraforged/core/decorator/DesertStacks.java @@ -1,12 +1,12 @@ 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.util.Seed; import com.terraforged.core.world.biome.BiomeType; import com.terraforged.core.world.heightmap.Levels; import com.terraforged.core.world.terrain.Terrain; +import me.dags.noise.Module; +import me.dags.noise.Source; 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 scale = Source.perlin(seed.next(), 400, 1) - .clamp(20F / 255F, 25F / 255F); + .clamp(levels.scale(20), levels.scale(35)); Module stack = (x, y) -> { float value = shape.getValue(x, y); diff --git a/TerraForgedCore/src/main/java/com/terraforged/core/decorator/SwampPools.java b/TerraForgedCore/src/main/java/com/terraforged/core/decorator/SwampPools.java index 3ee7909..3592021 100644 --- a/TerraForgedCore/src/main/java/com/terraforged/core/decorator/SwampPools.java +++ b/TerraForgedCore/src/main/java/com/terraforged/core/decorator/SwampPools.java @@ -1,13 +1,13 @@ 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.util.Seed; import com.terraforged.core.world.heightmap.Levels; import com.terraforged.core.world.terrain.Terrain; 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 { diff --git a/TerraForgedCore/src/main/java/com/terraforged/core/filter/Erosion.java b/TerraForgedCore/src/main/java/com/terraforged/core/filter/Erosion.java index 04b3e77..6da3deb 100644 --- a/TerraForgedCore/src/main/java/com/terraforged/core/filter/Erosion.java +++ b/TerraForgedCore/src/main/java/com/terraforged/core/filter/Erosion.java @@ -3,7 +3,6 @@ package com.terraforged.core.filter; import com.terraforged.core.cell.Cell; import com.terraforged.core.region.Size; import com.terraforged.core.settings.Settings; -import com.terraforged.core.util.PosIterator; import com.terraforged.core.world.heightmap.Levels; import me.dags.noise.util.NoiseUtil; diff --git a/TerraForgedCore/src/main/java/com/terraforged/core/filter/Smoothing.java b/TerraForgedCore/src/main/java/com/terraforged/core/filter/Smoothing.java index a26671d..67092a7 100644 --- a/TerraForgedCore/src/main/java/com/terraforged/core/filter/Smoothing.java +++ b/TerraForgedCore/src/main/java/com/terraforged/core/filter/Smoothing.java @@ -1,9 +1,9 @@ package com.terraforged.core.filter; -import me.dags.noise.util.NoiseUtil; import com.terraforged.core.cell.Cell; import com.terraforged.core.settings.Settings; import com.terraforged.core.world.heightmap.Levels; +import me.dags.noise.util.NoiseUtil; public class Smoothing implements Filter { diff --git a/TerraForgedCore/src/main/java/com/terraforged/core/module/Blender.java b/TerraForgedCore/src/main/java/com/terraforged/core/module/Blender.java index f9947d0..de2ea9a 100644 --- a/TerraForgedCore/src/main/java/com/terraforged/core/module/Blender.java +++ b/TerraForgedCore/src/main/java/com/terraforged/core/module/Blender.java @@ -1,11 +1,11 @@ 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.Populator; 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 { diff --git a/TerraForgedCore/src/main/java/com/terraforged/core/module/MultiBlender.java b/TerraForgedCore/src/main/java/com/terraforged/core/module/MultiBlender.java index f39dd79..41543d1 100644 --- a/TerraForgedCore/src/main/java/com/terraforged/core/module/MultiBlender.java +++ b/TerraForgedCore/src/main/java/com/terraforged/core/module/MultiBlender.java @@ -1,11 +1,11 @@ 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.Populator; import com.terraforged.core.world.climate.Climate; 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 { diff --git a/TerraForgedCore/src/main/java/com/terraforged/core/module/Select.java b/TerraForgedCore/src/main/java/com/terraforged/core/module/Select.java index 0e16c79..483911b 100644 --- a/TerraForgedCore/src/main/java/com/terraforged/core/module/Select.java +++ b/TerraForgedCore/src/main/java/com/terraforged/core/module/Select.java @@ -1,8 +1,8 @@ package com.terraforged.core.module; -import me.dags.noise.Module; import com.terraforged.core.cell.Cell; import com.terraforged.core.world.terrain.Terrain; +import me.dags.noise.Module; public class Select { diff --git a/TerraForgedCore/src/main/java/com/terraforged/core/region/Region.java b/TerraForgedCore/src/main/java/com/terraforged/core/region/Region.java index 9084088..69db60e 100644 --- a/TerraForgedCore/src/main/java/com/terraforged/core/region/Region.java +++ b/TerraForgedCore/src/main/java/com/terraforged/core/region/Region.java @@ -167,15 +167,30 @@ public class Region implements Extent { public void decorateZoom(Collection decorators, float offsetX, float offsetZ, float zoom) { float translateX = offsetX - ((blockSize.total * zoom) / 2F); float translateZ = offsetZ - ((blockSize.total * zoom) / 2F); - 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); - } + for (int cz = 0; cz < chunkSize.total; cz++) { + for (int cx = 0; cx < chunkSize.total; cx++) { + int index = chunkSize.indexOf(cx, cz); + GenChunk chunk = computeChunk(index, cx, cz); + chunk.iterate((cell, dx, 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 consumer) { diff --git a/TerraForgedCore/src/main/java/com/terraforged/core/region/RegionCache.java b/TerraForgedCore/src/main/java/com/terraforged/core/region/RegionCache.java index 78c0dc2..c6bc3db 100644 --- a/TerraForgedCore/src/main/java/com/terraforged/core/region/RegionCache.java +++ b/TerraForgedCore/src/main/java/com/terraforged/core/region/RegionCache.java @@ -1,10 +1,10 @@ package com.terraforged.core.region; -import me.dags.noise.util.NoiseUtil; import com.terraforged.core.region.chunk.ChunkReader; import com.terraforged.core.util.Cache; import com.terraforged.core.util.FutureValue; import com.terraforged.core.world.heightmap.RegionExtent; +import me.dags.noise.util.NoiseUtil; import java.util.concurrent.ExecutionException; import java.util.concurrent.Future; diff --git a/TerraForgedCore/src/main/java/com/terraforged/core/settings/GeneratorSettings.java b/TerraForgedCore/src/main/java/com/terraforged/core/settings/GeneratorSettings.java index fb033c0..0463629 100644 --- a/TerraForgedCore/src/main/java/com/terraforged/core/settings/GeneratorSettings.java +++ b/TerraForgedCore/src/main/java/com/terraforged/core/settings/GeneratorSettings.java @@ -1,10 +1,10 @@ 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.Range; import com.terraforged.core.util.serialization.annotation.Serializable; +import me.dags.noise.Module; +import me.dags.noise.Source; @Serializable public class GeneratorSettings { diff --git a/TerraForgedCore/src/main/java/com/terraforged/core/settings/TerrainSettings.java b/TerraForgedCore/src/main/java/com/terraforged/core/settings/TerrainSettings.java index 79dc2d9..7e18f32 100644 --- a/TerraForgedCore/src/main/java/com/terraforged/core/settings/TerrainSettings.java +++ b/TerraForgedCore/src/main/java/com/terraforged/core/settings/TerrainSettings.java @@ -3,48 +3,57 @@ package com.terraforged.core.settings; import com.terraforged.core.util.serialization.annotation.Comment; import com.terraforged.core.util.serialization.annotation.Range; import com.terraforged.core.util.serialization.annotation.Serializable; +import me.dags.noise.Module; @Serializable public class TerrainSettings { - public transient float deepOcean = 1F; - public transient float ocean = 1F; - public transient float coast = 1F; - public transient float river = 1F; + public Terrain steppe = new Terrain(5F, 1F, 1F); + public Terrain plains = new Terrain(5F, 1F, 1F); + public Terrain hills = new Terrain(2F, 1F, 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) - @Comment("Controls how common this terrain type is") - public float steppe = 5F; + @Serializable + public static class Terrain { - @Range(min = 0, max = 10) - @Comment("Controls how common this terrain type is") - public float plains = 5F; + @Range(min = 0, max = 10) + @Comment("Controls how common this terrain type is") + public float weight = 1F; - @Range(min = 0, max = 10) - @Comment("Controls how common this terrain type is") - public float hills = 2F; + @Range(min = 0, max = 2) + @Comment("Controls the base height of this terrain") + public float baseScale = 1F; - @Range(min = 0, max = 10) - @Comment("Controls how common this terrain type is") - public float dales = 2F; + @Range(min = 0F, max = 10F) + @Comment("Stretches or compresses the terrain vertically") + public float verticalScale = 1F; - @Range(min = 0, max = 10) - @Comment("Controls how common this terrain type is") - public float plateau = 2F; + @Range(min = 0F, max = 10F) + @Comment("Stretches or compresses the terrain horizontally") + public float horizontalScale = 1F; - @Range(min = 0, max = 10) - @Comment("Controls how common this terrain type is") - public float badlands = 2F; + public Terrain() { - @Range(min = 0, max = 10) - @Comment("Controls how common this terrain type is") - public float torridonian = 0.5F; + } - @Range(min = 0, max = 10) - @Comment("Controls how common this terrain type is") - public float mountains = 0.5F; + public Terrain(float weight, float vertical, float horizontal) { + this.weight = weight; + this.verticalScale = vertical; + this.horizontalScale = horizontal; + } - @Range(min = 0, max = 10) - @Comment("Controls how common this terrain type is") - public float volcano = 1F; + public Module apply(double bias, double scale, Module module) { + double moduleBias = bias * baseScale; + double moduleScale = scale * verticalScale; + if (moduleBias + moduleScale > 1) { + return module.scale(moduleScale).bias(moduleBias).clamp(0, 1); + } + return module.scale(moduleScale).bias(moduleBias); + } + } } diff --git a/TerraForgedCore/src/main/java/com/terraforged/core/util/VariablePredicate.java b/TerraForgedCore/src/main/java/com/terraforged/core/util/VariablePredicate.java index e67e18c..4e8e4e7 100644 --- a/TerraForgedCore/src/main/java/com/terraforged/core/util/VariablePredicate.java +++ b/TerraForgedCore/src/main/java/com/terraforged/core/util/VariablePredicate.java @@ -1,10 +1,10 @@ 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.world.heightmap.Levels; import com.terraforged.core.world.terrain.Terrain; +import me.dags.noise.Module; +import me.dags.noise.Source; import java.util.function.BiPredicate; diff --git a/TerraForgedCore/src/main/java/com/terraforged/core/util/concurrent/ThreadPool.java b/TerraForgedCore/src/main/java/com/terraforged/core/util/concurrent/ThreadPool.java index 34903e4..0ae7952 100644 --- a/TerraForgedCore/src/main/java/com/terraforged/core/util/concurrent/ThreadPool.java +++ b/TerraForgedCore/src/main/java/com/terraforged/core/util/concurrent/ThreadPool.java @@ -2,7 +2,11 @@ package com.terraforged.core.util.concurrent; import java.util.ArrayList; 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 { diff --git a/TerraForgedCore/src/main/java/com/terraforged/core/util/grid/FixedGrid.java b/TerraForgedCore/src/main/java/com/terraforged/core/util/grid/FixedGrid.java index b7a93d3..d89d1d2 100644 --- a/TerraForgedCore/src/main/java/com/terraforged/core/util/grid/FixedGrid.java +++ b/TerraForgedCore/src/main/java/com/terraforged/core/util/grid/FixedGrid.java @@ -2,7 +2,11 @@ package com.terraforged.core.util.grid; 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.Supplier; diff --git a/TerraForgedCore/src/main/java/com/terraforged/core/util/grid/FixedList.java b/TerraForgedCore/src/main/java/com/terraforged/core/util/grid/FixedList.java index 4a4ff73..2f6010e 100644 --- a/TerraForgedCore/src/main/java/com/terraforged/core/util/grid/FixedList.java +++ b/TerraForgedCore/src/main/java/com/terraforged/core/util/grid/FixedList.java @@ -2,7 +2,11 @@ package com.terraforged.core.util.grid; 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 implements Iterable { diff --git a/TerraForgedCore/src/main/java/com/terraforged/core/world/WorldDecorators.java b/TerraForgedCore/src/main/java/com/terraforged/core/world/WorldDecorators.java index 0f2dab5..f9ea02a 100644 --- a/TerraForgedCore/src/main/java/com/terraforged/core/world/WorldDecorators.java +++ b/TerraForgedCore/src/main/java/com/terraforged/core/world/WorldDecorators.java @@ -1,7 +1,6 @@ package com.terraforged.core.world; import com.terraforged.core.decorator.Decorator; -import com.terraforged.core.decorator.DesertDunes; import com.terraforged.core.decorator.DesertStacks; import com.terraforged.core.decorator.SwampPools; diff --git a/TerraForgedCore/src/main/java/com/terraforged/core/world/climate/ClimateModule.java b/TerraForgedCore/src/main/java/com/terraforged/core/world/climate/ClimateModule.java index 48414d2..e413202 100644 --- a/TerraForgedCore/src/main/java/com/terraforged/core/world/climate/ClimateModule.java +++ b/TerraForgedCore/src/main/java/com/terraforged/core/world/climate/ClimateModule.java @@ -1,16 +1,16 @@ 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.Source; import me.dags.noise.func.DistanceFunc; import me.dags.noise.func.EdgeFunc; import me.dags.noise.util.NoiseUtil; 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 { diff --git a/TerraForgedCore/src/main/java/com/terraforged/core/world/continent/ContinentLerper3.java b/TerraForgedCore/src/main/java/com/terraforged/core/world/continent/ContinentLerper3.java index ba2cab7..df52e30 100644 --- a/TerraForgedCore/src/main/java/com/terraforged/core/world/continent/ContinentLerper3.java +++ b/TerraForgedCore/src/main/java/com/terraforged/core/world/continent/ContinentLerper3.java @@ -2,7 +2,6 @@ package com.terraforged.core.world.continent; import com.terraforged.core.cell.Cell; import com.terraforged.core.cell.Populator; -import com.terraforged.core.module.MultiBlender; import com.terraforged.core.world.climate.Climate; import com.terraforged.core.world.terrain.Terrain; import me.dags.noise.func.Interpolation; diff --git a/TerraForgedCore/src/main/java/com/terraforged/core/world/continent/ContinentModule.java b/TerraForgedCore/src/main/java/com/terraforged/core/world/continent/ContinentModule.java index cd20374..746fe46 100644 --- a/TerraForgedCore/src/main/java/com/terraforged/core/world/continent/ContinentModule.java +++ b/TerraForgedCore/src/main/java/com/terraforged/core/world/continent/ContinentModule.java @@ -1,5 +1,10 @@ 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.Source; 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.util.NoiseUtil; 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 { diff --git a/TerraForgedCore/src/main/java/com/terraforged/core/world/geology/Strata.java b/TerraForgedCore/src/main/java/com/terraforged/core/world/geology/Strata.java index ed775f9..76638c8 100644 --- a/TerraForgedCore/src/main/java/com/terraforged/core/world/geology/Strata.java +++ b/TerraForgedCore/src/main/java/com/terraforged/core/world/geology/Strata.java @@ -1,9 +1,9 @@ package com.terraforged.core.world.geology; +import com.terraforged.core.util.Seed; import me.dags.noise.Module; import me.dags.noise.Source; import me.dags.noise.util.NoiseUtil; -import com.terraforged.core.util.Seed; import java.util.ArrayList; import java.util.LinkedList; diff --git a/TerraForgedCore/src/main/java/com/terraforged/core/world/heightmap/Levels.java b/TerraForgedCore/src/main/java/com/terraforged/core/world/heightmap/Levels.java index b2f1391..279e9cd 100644 --- a/TerraForgedCore/src/main/java/com/terraforged/core/world/heightmap/Levels.java +++ b/TerraForgedCore/src/main/java/com/terraforged/core/world/heightmap/Levels.java @@ -1,7 +1,7 @@ package com.terraforged.core.world.heightmap; -import me.dags.noise.util.NoiseUtil; import com.terraforged.core.settings.GeneratorSettings; +import me.dags.noise.util.NoiseUtil; public class Levels { diff --git a/TerraForgedCore/src/main/java/com/terraforged/core/world/heightmap/WorldHeightmap.java b/TerraForgedCore/src/main/java/com/terraforged/core/world/heightmap/WorldHeightmap.java index 863d607..51b8643 100644 --- a/TerraForgedCore/src/main/java/com/terraforged/core/world/heightmap/WorldHeightmap.java +++ b/TerraForgedCore/src/main/java/com/terraforged/core/world/heightmap/WorldHeightmap.java @@ -11,14 +11,14 @@ import com.terraforged.core.world.climate.Climate; import com.terraforged.core.world.continent.ContinentLerper2; import com.terraforged.core.world.continent.ContinentLerper3; 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.terrain.Terrain; import com.terraforged.core.world.terrain.TerrainPopulator; import com.terraforged.core.world.terrain.Terrains; 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.Source; import me.dags.noise.func.EdgeFunc; diff --git a/TerraForgedCore/src/main/java/com/terraforged/core/world/river/Lake.java b/TerraForgedCore/src/main/java/com/terraforged/core/world/river/Lake.java index 2a9b977..c8f3b6c 100644 --- a/TerraForgedCore/src/main/java/com/terraforged/core/world/river/Lake.java +++ b/TerraForgedCore/src/main/java/com/terraforged/core/world/river/Lake.java @@ -1,12 +1,12 @@ 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.world.terrain.Terrain; import com.terraforged.core.world.terrain.TerrainPopulator; 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 { diff --git a/TerraForgedCore/src/main/java/com/terraforged/core/world/river/PosGenerator.java b/TerraForgedCore/src/main/java/com/terraforged/core/world/river/PosGenerator.java index 926c84e..5d93be2 100644 --- a/TerraForgedCore/src/main/java/com/terraforged/core/world/river/PosGenerator.java +++ b/TerraForgedCore/src/main/java/com/terraforged/core/world/river/PosGenerator.java @@ -1,10 +1,10 @@ package com.terraforged.core.world.river; +import com.terraforged.core.cell.Cell; import com.terraforged.core.world.heightmap.Heightmap; +import com.terraforged.core.world.terrain.Terrain; import me.dags.noise.domain.Domain; import me.dags.noise.util.Vec2i; -import com.terraforged.core.cell.Cell; -import com.terraforged.core.world.terrain.Terrain; import java.util.Random; diff --git a/TerraForgedCore/src/main/java/com/terraforged/core/world/river/River.java b/TerraForgedCore/src/main/java/com/terraforged/core/world/river/River.java index 179f259..96286f5 100644 --- a/TerraForgedCore/src/main/java/com/terraforged/core/world/river/River.java +++ b/TerraForgedCore/src/main/java/com/terraforged/core/world/river/River.java @@ -1,13 +1,13 @@ 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.world.terrain.Terrain; import com.terraforged.core.world.terrain.TerrainPopulator; 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 { diff --git a/TerraForgedCore/src/main/java/com/terraforged/core/world/river/RiverManager.java b/TerraForgedCore/src/main/java/com/terraforged/core/world/river/RiverManager.java index c0c954f..3cf6625 100644 --- a/TerraForgedCore/src/main/java/com/terraforged/core/world/river/RiverManager.java +++ b/TerraForgedCore/src/main/java/com/terraforged/core/world/river/RiverManager.java @@ -1,11 +1,11 @@ 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.util.Cache; import com.terraforged.core.world.GeneratorContext; +import com.terraforged.core.world.heightmap.Heightmap; import com.terraforged.core.world.terrain.Terrain; +import me.dags.noise.util.NoiseUtil; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.TimeUnit; diff --git a/TerraForgedCore/src/main/java/com/terraforged/core/world/river/RiverRegion.java b/TerraForgedCore/src/main/java/com/terraforged/core/world/river/RiverRegion.java index ec6078d..8e9a982 100644 --- a/TerraForgedCore/src/main/java/com/terraforged/core/world/river/RiverRegion.java +++ b/TerraForgedCore/src/main/java/com/terraforged/core/world/river/RiverRegion.java @@ -1,15 +1,15 @@ 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.terrain.Terrain; +import com.terraforged.core.world.terrain.Terrains; import me.dags.noise.domain.Domain; import me.dags.noise.util.NoiseUtil; import me.dags.noise.util.Vec2f; 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.LinkedList; diff --git a/TerraForgedCore/src/main/java/com/terraforged/core/world/terrain/LandForms.java b/TerraForgedCore/src/main/java/com/terraforged/core/world/terrain/LandForms.java index 1c1bdcf..bcd854d 100644 --- a/TerraForgedCore/src/main/java/com/terraforged/core/world/terrain/LandForms.java +++ b/TerraForgedCore/src/main/java/com/terraforged/core/world/terrain/LandForms.java @@ -1,10 +1,11 @@ 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.Source; import me.dags.noise.func.EdgeFunc; -import com.terraforged.core.util.Seed; -import com.terraforged.core.world.heightmap.Levels; public class LandForms { @@ -14,10 +15,6 @@ public class LandForms { public static final int PLATEAU_H = 500; 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 double HILLS1_V = 0.6; 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 double MOUNTAINS2_V = 0.645; + private final TerrainSettings settings; private final float terrainHorizontalScale; private final float terrainVerticalScale; private final float groundLevel; private final float seaLevel; - public LandForms(Levels levels) { + public LandForms(TerrainSettings settings, Levels levels) { + this.settings = settings; terrainHorizontalScale = 1.025F; terrainVerticalScale = 1F; groundLevel = levels.ground; @@ -57,24 +56,23 @@ public class LandForms { } 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; 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 warpY = Source.build(seed.next(), scaleH / 4, 3).lacunarity(3).perlin(); - - return Source.perlin(seed.next(), scaleH, 1) + Module module = Source.perlin(seed.next(), scaleH, 1) .mult(erosion) .warp(warpX, warpY, Source.constant(scaleH / 4F)) - .warp(seed.next(), 256, 1, 200) - .scale(0.125 * terrainVerticalScale) - .bias(groundLevel); + .warp(seed.next(), 256, 1, 200); + + return settings.steppe.apply(groundLevel, 0.125 * terrainVerticalScale, module); } 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; @@ -82,12 +80,12 @@ public class LandForms { 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(); - return Source.perlin(seed.next(), scaleH, 1) + Module module = Source.perlin(seed.next(), scaleH, 1) .mult(erosion) .warp(warpX, warpY, Source.constant(scaleH / 4F)) - .warp(seed.next(), 256, 1, 256) - .scale(PLAINS_V * terrainVerticalScale) - .bias(groundLevel); + .warp(seed.next(), 256, 1, 256); + + return settings.plains.apply(groundLevel, PLAINS_V * terrainVerticalScale, module); } public Module plateau(Seed seed) { @@ -104,37 +102,32 @@ public class LandForms { Module surface = Source.perlin(seed.next(), 20, 3).scale(0.05) .warp(seed.next(), 40, 2, 20); - return valley - .mult(Source.cubic(seed.next(), 500, 1).scale(0.6).bias(0.3)) - .add(top) - .terrace( - Source.perlin(seed.next(), 20, 1).scale(0.3).bias(0.2), - Source.perlin(seed.next(), 20, 2).scale(0.1).bias(0.2), - 4, - 0.4 - ) - .add(surface) - .scale(PLATEAU_V * terrainVerticalScale) - .bias(groundLevel); + return settings.plateau.apply(groundLevel, PLATEAU_V * terrainVerticalScale, + valley + .mult(Source.cubic(seed.next(), 500, 1).scale(0.6).bias(0.3)) + .add(top) + .terrace( + Source.perlin(seed.next(), 20, 1).scale(0.3).bias(0.2), + Source.perlin(seed.next(), 20, 2).scale(0.1).bias(0.2), + 4, + 0.4 + ) + .add(surface)); } 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)) .warp(seed.next(), 30, 3, 20) - .warp(seed.next(), 400, 3, 200) - .scale(HILLS1_V * terrainVerticalScale) - .bias(groundLevel); + .warp(seed.next(), 400, 3, 200)); } 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)) .warp(seed.next(), 30, 3, 20) .warp(seed.next(), 400, 3, 200) - .mult(Source.ridge(seed.next(), 512, 2).alpha(0.8)) - .scale(HILLS2_V * terrainVerticalScale) - .bias(groundLevel); + .mult(Source.ridge(seed.next(), 512, 2).alpha(0.8))); } public Module dales(Seed seed) { @@ -149,16 +142,18 @@ public class LandForms { Module hills = combined .pow(1.125) .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) { - int scaleH = Math.round(MOUNTAINS_H * terrainHorizontalScale); - return Source.build(seed.next(), scaleH, 4).gain(1.15).lacunarity(2.35).ridge() + int scaleH = Math.round(MOUNTAINS_H * terrainHorizontalScale * settings.mountains.horizontalScale); + + 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)) - .warp(seed.next(), 350, 1, 150) - .scale(MOUNTAINS_V * terrainVerticalScale) - .bias(groundLevel); + .warp(seed.next(), 350, 1, 150); + + return settings.mountains.apply(groundLevel, MOUNTAINS_V * terrainVerticalScale, module); } public Module mountains2(Seed seed) { @@ -168,7 +163,7 @@ public class LandForms { Module blur = Source.perlin(seed.next(), 10, 1).alpha(0.025); Module surface = Source.ridge(seed.next(), 125, 4).alpha(0.37); 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) { @@ -190,7 +185,7 @@ public class LandForms { 1 ); - return terraced.scale(scale).bias(groundLevel); + return settings.mountains.apply(groundLevel, scale, terraced); } public Module badlands(Seed seed) { @@ -213,7 +208,7 @@ public class LandForms { .add(mod2) .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) { @@ -239,6 +234,6 @@ public class LandForms { 1 ).boost(); - return test.scale(0.5).bias(groundLevel); + return settings.torridonian.apply(groundLevel, 0.5, test); } } diff --git a/TerraForgedCore/src/main/java/com/terraforged/core/world/terrain/Terrain.java b/TerraForgedCore/src/main/java/com/terraforged/core/world/terrain/Terrain.java index 1c8f998..989f9db 100644 --- a/TerraForgedCore/src/main/java/com/terraforged/core/world/terrain/Terrain.java +++ b/TerraForgedCore/src/main/java/com/terraforged/core/world/terrain/Terrain.java @@ -110,42 +110,42 @@ public class Terrain implements Tag { } 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) { - return new Terrain("plains", 5, settings.terrain.plains); + return new Terrain("plains", 5, settings.terrain.plains.weight); } 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) { - return new Terrain("badlands", 7, settings.terrain.badlands); + return new Terrain("badlands", 7, settings.terrain.badlands.weight); } 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) { - return new Terrain("dales", 9, settings.terrain.hills); + return new Terrain("dales", 9, settings.terrain.dales.weight); } 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) { - return new Terrain("mountains", 11, settings.terrain.mountains); + return new Terrain("mountains", 11, settings.terrain.mountains.weight); } 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) { - return new Terrain("volcano_pipe", 13, settings.terrain.volcano); + return new Terrain("volcano_pipe", 13, settings.terrain.volcano.weight); } } diff --git a/TerraForgedCore/src/main/java/com/terraforged/core/world/terrain/TerrainPopulator.java b/TerraForgedCore/src/main/java/com/terraforged/core/world/terrain/TerrainPopulator.java index 1185802..7fc43ee 100644 --- a/TerraForgedCore/src/main/java/com/terraforged/core/world/terrain/TerrainPopulator.java +++ b/TerraForgedCore/src/main/java/com/terraforged/core/world/terrain/TerrainPopulator.java @@ -1,10 +1,10 @@ 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.Populator; import com.terraforged.core.util.Seed; +import me.dags.noise.Module; +import me.dags.noise.Source; import java.util.Arrays; import java.util.function.BiFunction; diff --git a/TerraForgedCore/src/main/java/com/terraforged/core/world/terrain/VolcanoPopulator.java b/TerraForgedCore/src/main/java/com/terraforged/core/world/terrain/VolcanoPopulator.java index 0fb6c46..5b26906 100644 --- a/TerraForgedCore/src/main/java/com/terraforged/core/world/terrain/VolcanoPopulator.java +++ b/TerraForgedCore/src/main/java/com/terraforged/core/world/terrain/VolcanoPopulator.java @@ -1,12 +1,12 @@ 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.util.Seed; import com.terraforged.core.world.heightmap.Levels; 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 { diff --git a/TerraForgedCore/src/main/java/com/terraforged/core/world/terrain/provider/StandardTerrainProvider.java b/TerraForgedCore/src/main/java/com/terraforged/core/world/terrain/provider/StandardTerrainProvider.java index 82359cd..92e5f11 100644 --- a/TerraForgedCore/src/main/java/com/terraforged/core/world/terrain/provider/StandardTerrainProvider.java +++ b/TerraForgedCore/src/main/java/com/terraforged/core/world/terrain/provider/StandardTerrainProvider.java @@ -1,7 +1,5 @@ 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.util.Seed; 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.TerrainPopulator; import com.terraforged.core.world.terrain.VolcanoPopulator; +import me.dags.noise.Module; +import me.dags.noise.Source; import java.util.ArrayList; import java.util.HashMap; @@ -31,7 +31,7 @@ public class StandardTerrainProvider implements TerrainProvider { public StandardTerrainProvider(GeneratorContext context, RegionConfig config, Populator defaultPopulator) { this.config = config; this.context = context; - this.landForms = new LandForms(context.levels); + this.landForms = new LandForms(context.settings.terrain, context.levels); this.defaultPopulator = defaultPopulator; init(); } diff --git a/TerraForgedCore/src/main/java/com/terraforged/core/world/terrain/provider/TerrainProvider.java b/TerraForgedCore/src/main/java/com/terraforged/core/world/terrain/provider/TerrainProvider.java index 137b18b..90a1ae3 100644 --- a/TerraForgedCore/src/main/java/com/terraforged/core/world/terrain/provider/TerrainProvider.java +++ b/TerraForgedCore/src/main/java/com/terraforged/core/world/terrain/provider/TerrainProvider.java @@ -1,10 +1,10 @@ package com.terraforged.core.world.terrain.provider; -import me.dags.noise.Module; import com.terraforged.core.cell.Populator; import com.terraforged.core.world.terrain.LandForms; import com.terraforged.core.world.terrain.Terrain; import com.terraforged.core.world.terrain.TerrainPopulator; +import me.dags.noise.Module; import java.util.List; diff --git a/TerraForgedCore/src/main/java/com/terraforged/core/world/terrain/region/RegionSelector.java b/TerraForgedCore/src/main/java/com/terraforged/core/world/terrain/region/RegionSelector.java index 9f1d08b..7e0cc4c 100644 --- a/TerraForgedCore/src/main/java/com/terraforged/core/world/terrain/region/RegionSelector.java +++ b/TerraForgedCore/src/main/java/com/terraforged/core/world/terrain/region/RegionSelector.java @@ -57,6 +57,10 @@ public class RegionSelector implements Populator { } } + if (result.isEmpty()) { + return modules.toArray(new Populator[0]); + } + return result.toArray(new Populator[0]); } } diff --git a/TerraForgedMod b/TerraForgedMod index fbfbdfe..39012b5 160000 --- a/TerraForgedMod +++ b/TerraForgedMod @@ -1 +1 @@ -Subproject commit fbfbdfec2824f1640c6ec4df9682b07ce97e1982 +Subproject commit 39012b51fb49d214c85332f00cf353c1f6e727c7