From 0a0adf99935a87c1cfa5c4c990d23f28f2e11ee1 Mon Sep 17 00:00:00 2001 From: Louis Rosenberg Date: Sun, 28 Jun 2020 11:56:58 -0400 Subject: [PATCH 1/9] Add temperature and humidity values to biome --- .../org/terasology/core/world/CoreBiome.java | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/src/main/java/org/terasology/core/world/CoreBiome.java b/src/main/java/org/terasology/core/world/CoreBiome.java index fe2929a..bf1b4a9 100644 --- a/src/main/java/org/terasology/core/world/CoreBiome.java +++ b/src/main/java/org/terasology/core/world/CoreBiome.java @@ -50,4 +50,37 @@ public String toString() { return this.displayName; } + @Override + public float getHumidity() { + if (displayName.equals("Ocean") || displayName.equals("Snow")) { + return .9f; + } else if (displayName.equals("Beach")) { + return .8f; + } else if (displayName.equals("Forest")) { + return .7f; + } else if (displayName.equals("Plains")) { + return .55f; + } else if (displayName.equals("Mountains")) { + return .3f; + } else if (displayName.equals("Desert")) { + return .15f; + } else { + return .3f; + } + } + + @Override + public float getTemperature() { + if (displayName.equals("Ocean") || displayName.equals("Snow")) { + return .13f; + } else if (displayName.equals("Beach")) { + return .28f; + } else if (displayName.equals("Mountains")) { + return .09f; + } else if (displayName.equals("Desert")) { + return .27f; + } else { + return .22f; + } + } } From f790e136fe3a683a5ffd1e762c1485888775fdee Mon Sep 17 00:00:00 2001 From: Louis Rosenberg Date: Sun, 28 Jun 2020 16:20:27 -0400 Subject: [PATCH 2/9] Make requested changes --- .../org/terasology/core/world/CoreBiome.java | 48 ++++++------------- 1 file changed, 14 insertions(+), 34 deletions(-) diff --git a/src/main/java/org/terasology/core/world/CoreBiome.java b/src/main/java/org/terasology/core/world/CoreBiome.java index bf1b4a9..85526d3 100644 --- a/src/main/java/org/terasology/core/world/CoreBiome.java +++ b/src/main/java/org/terasology/core/world/CoreBiome.java @@ -19,20 +19,24 @@ import org.terasology.naming.Name; public enum CoreBiome implements Biome { - MOUNTAINS("Mountains"), - SNOW("Snow"), - DESERT("Desert"), - FOREST("Forest"), - OCEAN("Ocean"), - BEACH("Beach"), - PLAINS("Plains"); + MOUNTAINS("Mountains", .3f, .09f), + SNOW("Snow", .85f, .05f), + DESERT("Desert", .15f, .26f), + FOREST("Forest", .65f, .22f), + OCEAN("Ocean", .9f, .13f), + BEACH("Beach", .8f, .28f), + PLAINS("Plains", .55f, .22f); private final Name id; private final String displayName; + private final float humidity; + private final float temperature; - CoreBiome(String displayName) { + CoreBiome(String displayName, float humidity, float temperature) { this.id = new Name("CoreWorlds:" + name()); this.displayName = displayName; + this.humidity = humidity; + this.temperature = temperature; } @Override @@ -52,35 +56,11 @@ public String toString() { @Override public float getHumidity() { - if (displayName.equals("Ocean") || displayName.equals("Snow")) { - return .9f; - } else if (displayName.equals("Beach")) { - return .8f; - } else if (displayName.equals("Forest")) { - return .7f; - } else if (displayName.equals("Plains")) { - return .55f; - } else if (displayName.equals("Mountains")) { - return .3f; - } else if (displayName.equals("Desert")) { - return .15f; - } else { - return .3f; - } + return this.humidity; } @Override public float getTemperature() { - if (displayName.equals("Ocean") || displayName.equals("Snow")) { - return .13f; - } else if (displayName.equals("Beach")) { - return .28f; - } else if (displayName.equals("Mountains")) { - return .09f; - } else if (displayName.equals("Desert")) { - return .27f; - } else { - return .22f; - } + return this.temperature; } } From 3ffc925b12cb892657665d1a358d852319cd9c46 Mon Sep 17 00:00:00 2001 From: Louis Rosenberg Date: Sun, 12 Jul 2020 15:25:49 -0400 Subject: [PATCH 3/9] Adjusting temperature facets --- .../facetProviders/BiomeProvider.java | 16 ++-- .../facetProviders/HumidityProvider.java | 45 +++++++++ .../facetProviders/TemperatureProvider.java | 93 +++++++++++++++++++ .../worldGenerators/FlatWorldGenerator.java | 4 + .../HeightMapWorldGenerator.java | 4 + .../PerlinFacetedWorldGenerator.java | 4 + .../SimplexFacetedWorldGenerator.java | 4 + 7 files changed, 164 insertions(+), 6 deletions(-) create mode 100644 src/main/java/org/terasology/core/world/generator/facetProviders/HumidityProvider.java create mode 100644 src/main/java/org/terasology/core/world/generator/facetProviders/TemperatureProvider.java diff --git a/src/main/java/org/terasology/core/world/generator/facetProviders/BiomeProvider.java b/src/main/java/org/terasology/core/world/generator/facetProviders/BiomeProvider.java index 8b8893d..46135f3 100644 --- a/src/main/java/org/terasology/core/world/generator/facetProviders/BiomeProvider.java +++ b/src/main/java/org/terasology/core/world/generator/facetProviders/BiomeProvider.java @@ -15,9 +15,11 @@ */ package org.terasology.core.world.generator.facetProviders; +import org.slf4j.LoggerFactory; import org.terasology.core.world.CoreBiome; import org.terasology.core.world.generator.facets.BiomeFacet; import org.terasology.math.geom.BaseVector2i; +import org.terasology.rendering.nui.properties.Range; import org.terasology.world.generation.Border3D; import org.terasology.world.generation.Facet; import org.terasology.world.generation.FacetProvider; @@ -29,6 +31,8 @@ import org.terasology.world.generation.facets.SurfaceHumidityFacet; import org.terasology.world.generation.facets.SurfaceTemperatureFacet; +import java.awt.Component; + /** * Determines the biome based on temperature and humidity */ @@ -61,17 +65,17 @@ public void process(GeneratingRegion region) { float hum = temp * humidityFacet.get(pos); float height = heightFacet.get(pos); - if (height <= seaLevel) { + if (height <= seaLevel || hum >= .85) { // TODO: remove hum qualifier here and for ocean? biomeFacet.set(pos, CoreBiome.OCEAN); - } else if (height <= seaLevel + 2) { + } else if (height <= seaLevel + 2 || hum >= .75) { biomeFacet.set(pos, CoreBiome.BEACH); - } else if (temp >= 0.5f && hum < 0.3f) { + } else if (hum <= 0.3f) { biomeFacet.set(pos, CoreBiome.DESERT); - } else if (hum >= 0.3f && hum <= 0.6f && temp >= 0.5f) { + } else if (hum <= 0.65f && temp >= 0.25f) { biomeFacet.set(pos, CoreBiome.PLAINS); - } else if (temp <= 0.3f && hum > 0.5f) { + } else if (hum >= .55f && temp <= 0.05f) { biomeFacet.set(pos, CoreBiome.SNOW); - } else if (hum >= 0.2f && hum <= 0.6f && temp < 0.5f) { + } else if (hum <= .55f && temp <= .15f) { biomeFacet.set(pos, CoreBiome.MOUNTAINS); } else { biomeFacet.set(pos, CoreBiome.FOREST); diff --git a/src/main/java/org/terasology/core/world/generator/facetProviders/HumidityProvider.java b/src/main/java/org/terasology/core/world/generator/facetProviders/HumidityProvider.java new file mode 100644 index 0000000..83235ac --- /dev/null +++ b/src/main/java/org/terasology/core/world/generator/facetProviders/HumidityProvider.java @@ -0,0 +1,45 @@ +/* + * Copyright 2020 MovingBlocks + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.terasology.core.world.generator.facetProviders; + +import org.terasology.math.TeraMath; +import org.terasology.math.geom.BaseVector2i; +import org.terasology.math.geom.Rect2i; +import org.terasology.world.generation.Facet; +import org.terasology.world.generation.FacetProvider; +import org.terasology.world.generation.GeneratingRegion; +import org.terasology.world.generation.Updates; +import org.terasology.world.generation.facets.SurfaceHumidityFacet; + +@Updates(@Facet(SurfaceHumidityFacet.class)) +public class HumidityProvider implements FacetProvider { + + @Override + public void setSeed(long seed) { + } + + @Override + public void process(GeneratingRegion region) { + SurfaceHumidityFacet facet = region.getRegionFacet(SurfaceHumidityFacet.class); + + Rect2i processRegion = facet.getWorldRegion(); + for (BaseVector2i position : processRegion.contents()) { + // modify initial noise so that it lies between 0 and 1 + facet.setWorld(position, TeraMath.clamp(facet.getWorld(position.x(), position.y()) / 2 + 1, 0, 1)); + } + } +} diff --git a/src/main/java/org/terasology/core/world/generator/facetProviders/TemperatureProvider.java b/src/main/java/org/terasology/core/world/generator/facetProviders/TemperatureProvider.java new file mode 100644 index 0000000..1be3fe2 --- /dev/null +++ b/src/main/java/org/terasology/core/world/generator/facetProviders/TemperatureProvider.java @@ -0,0 +1,93 @@ +/* + * Copyright 2020 MovingBlocks + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.terasology.core.world.generator.facetProviders; + +import org.terasology.core.world.generator.facets.TreeFacet; +import org.terasology.entitySystem.Component; +import org.terasology.math.TeraMath; +import org.terasology.math.geom.BaseVector2i; +import org.terasology.math.geom.Rect2i; +import org.terasology.math.geom.Vector2f; +import org.terasology.rendering.nui.properties.Range; +import org.terasology.utilities.procedural.BrownianNoise; +import org.terasology.utilities.procedural.Noise; +import org.terasology.utilities.procedural.PerlinNoise; +import org.terasology.utilities.procedural.SimplexNoise; +import org.terasology.utilities.procedural.SubSampledNoise; +import org.terasology.world.generation.Border3D; +import org.terasology.world.generation.ConfigurableFacetProvider; +import org.terasology.world.generation.Facet; +import org.terasology.world.generation.GeneratingRegion; +import org.terasology.world.generation.Requires; +import org.terasology.world.generation.Updates; +import org.terasology.world.generation.facets.SeaLevelFacet; +import org.terasology.world.generation.facets.SurfaceHeightFacet; +import org.terasology.world.generation.facets.SurfaceHumidityFacet; +import org.terasology.world.generation.facets.SurfaceTemperatureFacet; + +@Updates(@Facet(SurfaceTemperatureFacet.class)) + +public class TemperatureProvider implements ConfigurableFacetProvider { + private TemperatureConfiguration configuration = new TemperatureConfiguration(); + private Noise temperatureNoise; + + @Override + public void setSeed(long seed) { + temperatureNoise = new SubSampledNoise(new BrownianNoise(new PerlinNoise(seed + 2), 8), new Vector2f(0.001f, 0.001f), 1); + } + + @Override + public String getConfigurationName() { + return "Temperature"; + } + + @Override + public Component getConfiguration() { + return configuration; + } + + @Override + public void setConfiguration(Component configuration) { + this.configuration = (TemperatureConfiguration)configuration; + } + + @Override + public void process(GeneratingRegion region) { + SurfaceTemperatureFacet facet = region.getRegionFacet(SurfaceTemperatureFacet.class); + SurfaceHeightFacet heightFacet = region.getRegionFacet(SurfaceHeightFacet.class); + SeaLevelFacet seaLevelFacet = region.getRegionFacet(SeaLevelFacet.class); + float temperatureBase = configuration.temperatureBase; + + Rect2i processRegion = facet.getWorldRegion(); + for (BaseVector2i position : processRegion.contents()) { + // modify initial noise so that it falls (almost always) in range and its average is approximately temperatureBase + float noiseAdjusted = temperatureNoise.noise(position.x(), position.y()) / 4 + temperatureBase; + noiseAdjusted += -(heightFacet.getWorld(position) - seaLevelFacet.getSeaLevel()) * .00006f + .07f; + + // clamp to reasonable values + noiseAdjusted = TeraMath.clamp(noiseAdjusted, -.6f, .5f); + facet.setWorld(position, noiseAdjusted); + } + } + + private static class TemperatureConfiguration implements Component + { + @Range(min = -.4f, max = .4f, increment = .001f, precision = 1, description = "Mountain Height") + private float temperatureBase = .22f; + } + +} diff --git a/src/main/java/org/terasology/core/world/generator/worldGenerators/FlatWorldGenerator.java b/src/main/java/org/terasology/core/world/generator/worldGenerators/FlatWorldGenerator.java index 7cc4d4d..fb8c552 100644 --- a/src/main/java/org/terasology/core/world/generator/worldGenerators/FlatWorldGenerator.java +++ b/src/main/java/org/terasology/core/world/generator/worldGenerators/FlatWorldGenerator.java @@ -19,10 +19,12 @@ import org.terasology.core.world.generator.facetProviders.DefaultFloraProvider; import org.terasology.core.world.generator.facetProviders.DefaultTreeProvider; import org.terasology.core.world.generator.facetProviders.FlatSurfaceHeightProvider; +import org.terasology.core.world.generator.facetProviders.HumidityProvider; import org.terasology.core.world.generator.facetProviders.PerlinHumidityProvider; import org.terasology.core.world.generator.facetProviders.PerlinSurfaceTemperatureProvider; import org.terasology.core.world.generator.facetProviders.SeaLevelProvider; import org.terasology.core.world.generator.facetProviders.SurfaceToDensityProvider; +import org.terasology.core.world.generator.facetProviders.TemperatureProvider; import org.terasology.core.world.generator.rasterizers.FloraRasterizer; import org.terasology.core.world.generator.rasterizers.SolidRasterizer; import org.terasology.core.world.generator.rasterizers.TreeRasterizer; @@ -51,6 +53,8 @@ protected WorldBuilder createWorld() { .addProvider(new FlatSurfaceHeightProvider(40)) .addProvider(new PerlinHumidityProvider()) .addProvider(new PerlinSurfaceTemperatureProvider()) + .addProvider(new TemperatureProvider()) + .addProvider(new HumidityProvider()) .addProvider(new BiomeProvider()) .addProvider(new SurfaceToDensityProvider()) .addProvider(new DefaultFloraProvider()) diff --git a/src/main/java/org/terasology/core/world/generator/worldGenerators/HeightMapWorldGenerator.java b/src/main/java/org/terasology/core/world/generator/worldGenerators/HeightMapWorldGenerator.java index 9dd13ad..b546650 100644 --- a/src/main/java/org/terasology/core/world/generator/worldGenerators/HeightMapWorldGenerator.java +++ b/src/main/java/org/terasology/core/world/generator/worldGenerators/HeightMapWorldGenerator.java @@ -19,10 +19,12 @@ import org.terasology.core.world.generator.facetProviders.DefaultFloraProvider; import org.terasology.core.world.generator.facetProviders.DefaultTreeProvider; import org.terasology.core.world.generator.facetProviders.HeightMapSurfaceHeightProvider; +import org.terasology.core.world.generator.facetProviders.HumidityProvider; import org.terasology.core.world.generator.facetProviders.PerlinHumidityProvider; import org.terasology.core.world.generator.facetProviders.PerlinSurfaceTemperatureProvider; import org.terasology.core.world.generator.facetProviders.SeaLevelProvider; import org.terasology.core.world.generator.facetProviders.SurfaceToDensityProvider; +import org.terasology.core.world.generator.facetProviders.TemperatureProvider; import org.terasology.core.world.generator.rasterizers.FloraRasterizer; import org.terasology.core.world.generator.rasterizers.SolidRasterizer; import org.terasology.core.world.generator.rasterizers.TreeRasterizer; @@ -53,6 +55,8 @@ protected WorldBuilder createWorld() { .addProvider(new HeightMapSurfaceHeightProvider()) .addProvider(new PerlinHumidityProvider()) .addProvider(new PerlinSurfaceTemperatureProvider()) + .addProvider(new TemperatureProvider()) + .addProvider(new HumidityProvider()) .addProvider(new BiomeProvider()) .addProvider(new SurfaceToDensityProvider()) .addProvider(new DefaultFloraProvider()) diff --git a/src/main/java/org/terasology/core/world/generator/worldGenerators/PerlinFacetedWorldGenerator.java b/src/main/java/org/terasology/core/world/generator/worldGenerators/PerlinFacetedWorldGenerator.java index 57e1e83..c565698 100644 --- a/src/main/java/org/terasology/core/world/generator/worldGenerators/PerlinFacetedWorldGenerator.java +++ b/src/main/java/org/terasology/core/world/generator/worldGenerators/PerlinFacetedWorldGenerator.java @@ -18,6 +18,7 @@ import org.terasology.core.world.generator.facetProviders.BiomeProvider; import org.terasology.core.world.generator.facetProviders.DefaultFloraProvider; import org.terasology.core.world.generator.facetProviders.DefaultTreeProvider; +import org.terasology.core.world.generator.facetProviders.HumidityProvider; import org.terasology.core.world.generator.facetProviders.PlateauProvider; import org.terasology.core.world.generator.facetProviders.PerlinBaseSurfaceProvider; import org.terasology.core.world.generator.facetProviders.PerlinHillsAndMountainsProvider; @@ -27,6 +28,7 @@ import org.terasology.core.world.generator.facetProviders.PerlinSurfaceTemperatureProvider; import org.terasology.core.world.generator.facetProviders.SeaLevelProvider; import org.terasology.core.world.generator.facetProviders.SurfaceToDensityProvider; +import org.terasology.core.world.generator.facetProviders.TemperatureProvider; import org.terasology.core.world.generator.rasterizers.FloraRasterizer; import org.terasology.core.world.generator.rasterizers.SolidRasterizer; import org.terasology.core.world.generator.rasterizers.TreeRasterizer; @@ -74,6 +76,8 @@ protected WorldBuilder createWorld() { .addProvider(new PerlinRiverProvider()) .addProvider(new PerlinOceanProvider()) .addProvider(new PerlinHillsAndMountainsProvider()) + .addProvider(new TemperatureProvider()) + .addProvider(new HumidityProvider()) .addProvider(new BiomeProvider()) .addProvider(new SurfaceToDensityProvider()) .addProvider(new DefaultFloraProvider()) diff --git a/src/main/java/org/terasology/core/world/generator/worldGenerators/SimplexFacetedWorldGenerator.java b/src/main/java/org/terasology/core/world/generator/worldGenerators/SimplexFacetedWorldGenerator.java index 730a5e9..a1346b3 100644 --- a/src/main/java/org/terasology/core/world/generator/worldGenerators/SimplexFacetedWorldGenerator.java +++ b/src/main/java/org/terasology/core/world/generator/worldGenerators/SimplexFacetedWorldGenerator.java @@ -18,6 +18,7 @@ import org.terasology.core.world.generator.facetProviders.BiomeProvider; import org.terasology.core.world.generator.facetProviders.DefaultFloraProvider; import org.terasology.core.world.generator.facetProviders.DefaultTreeProvider; +import org.terasology.core.world.generator.facetProviders.HumidityProvider; import org.terasology.core.world.generator.facetProviders.PlateauProvider; import org.terasology.core.world.generator.facetProviders.SimplexBaseSurfaceProvider; import org.terasology.core.world.generator.facetProviders.SimplexHillsAndMountainsProvider; @@ -27,6 +28,7 @@ import org.terasology.core.world.generator.facetProviders.SimplexSurfaceTemperatureProvider; import org.terasology.core.world.generator.facetProviders.SeaLevelProvider; import org.terasology.core.world.generator.facetProviders.SurfaceToDensityProvider; +import org.terasology.core.world.generator.facetProviders.TemperatureProvider; import org.terasology.core.world.generator.rasterizers.FloraRasterizer; import org.terasology.core.world.generator.rasterizers.SolidRasterizer; import org.terasology.core.world.generator.rasterizers.TreeRasterizer; @@ -74,6 +76,8 @@ protected WorldBuilder createWorld() { .addProvider(new SimplexRiverProvider()) .addProvider(new SimplexOceanProvider()) .addProvider(new SimplexHillsAndMountainsProvider()) + .addProvider(new TemperatureProvider()) + .addProvider(new HumidityProvider()) .addProvider(new BiomeProvider()) .addProvider(new SurfaceToDensityProvider()) .addProvider(new DefaultFloraProvider()) From dd90b48a811cf91e1c1f6ee8c044a1e778917d81 Mon Sep 17 00:00:00 2001 From: Louis Rosenberg Date: Sat, 8 Aug 2020 00:57:32 -0400 Subject: [PATCH 4/9] Start of using block data for facets --- .../facetProviders/BiomeProvider.java | 8 +++--- .../facetProviders/HumidityProvider.java | 2 +- .../facetProviders/TemperatureProvider.java | 10 ++++--- .../rasterizers/SolidRasterizer.java | 26 +++++++++++++++++++ 4 files changed, 37 insertions(+), 9 deletions(-) diff --git a/src/main/java/org/terasology/core/world/generator/facetProviders/BiomeProvider.java b/src/main/java/org/terasology/core/world/generator/facetProviders/BiomeProvider.java index 46135f3..323a660 100644 --- a/src/main/java/org/terasology/core/world/generator/facetProviders/BiomeProvider.java +++ b/src/main/java/org/terasology/core/world/generator/facetProviders/BiomeProvider.java @@ -67,15 +67,15 @@ public void process(GeneratingRegion region) { if (height <= seaLevel || hum >= .85) { // TODO: remove hum qualifier here and for ocean? biomeFacet.set(pos, CoreBiome.OCEAN); - } else if (height <= seaLevel + 2 || hum >= .75) { + } else if (height <= seaLevel + 2 || hum >= .8) { biomeFacet.set(pos, CoreBiome.BEACH); - } else if (hum <= 0.3f) { + } else if (hum <= 0.15f) { biomeFacet.set(pos, CoreBiome.DESERT); - } else if (hum <= 0.65f && temp >= 0.25f) { + } else if (hum <= 0.6f && temp >= 0.20f) { biomeFacet.set(pos, CoreBiome.PLAINS); } else if (hum >= .55f && temp <= 0.05f) { biomeFacet.set(pos, CoreBiome.SNOW); - } else if (hum <= .55f && temp <= .15f) { + } else if (hum <= .45f && temp <= .15f) { biomeFacet.set(pos, CoreBiome.MOUNTAINS); } else { biomeFacet.set(pos, CoreBiome.FOREST); diff --git a/src/main/java/org/terasology/core/world/generator/facetProviders/HumidityProvider.java b/src/main/java/org/terasology/core/world/generator/facetProviders/HumidityProvider.java index 83235ac..2f59a84 100644 --- a/src/main/java/org/terasology/core/world/generator/facetProviders/HumidityProvider.java +++ b/src/main/java/org/terasology/core/world/generator/facetProviders/HumidityProvider.java @@ -39,7 +39,7 @@ public void process(GeneratingRegion region) { Rect2i processRegion = facet.getWorldRegion(); for (BaseVector2i position : processRegion.contents()) { // modify initial noise so that it lies between 0 and 1 - facet.setWorld(position, TeraMath.clamp(facet.getWorld(position.x(), position.y()) / 2 + 1, 0, 1)); + facet.setWorld(position, TeraMath.clamp(facet.getWorld(position.x(), position.y()), 0, 1)); } } } diff --git a/src/main/java/org/terasology/core/world/generator/facetProviders/TemperatureProvider.java b/src/main/java/org/terasology/core/world/generator/facetProviders/TemperatureProvider.java index 1be3fe2..963df90 100644 --- a/src/main/java/org/terasology/core/world/generator/facetProviders/TemperatureProvider.java +++ b/src/main/java/org/terasology/core/world/generator/facetProviders/TemperatureProvider.java @@ -16,6 +16,7 @@ package org.terasology.core.world.generator.facetProviders; +import org.slf4j.LoggerFactory; import org.terasology.core.world.generator.facets.TreeFacet; import org.terasology.entitySystem.Component; import org.terasology.math.TeraMath; @@ -38,6 +39,7 @@ import org.terasology.world.generation.facets.SurfaceHeightFacet; import org.terasology.world.generation.facets.SurfaceHumidityFacet; import org.terasology.world.generation.facets.SurfaceTemperatureFacet; +import sun.rmi.runtime.Log; @Updates(@Facet(SurfaceTemperatureFacet.class)) @@ -75,10 +77,10 @@ public void process(GeneratingRegion region) { Rect2i processRegion = facet.getWorldRegion(); for (BaseVector2i position : processRegion.contents()) { // modify initial noise so that it falls (almost always) in range and its average is approximately temperatureBase - float noiseAdjusted = temperatureNoise.noise(position.x(), position.y()) / 4 + temperatureBase; + float noiseAdjusted = temperatureNoise.noise(position.x(), position.y()) / 5 + temperatureBase; noiseAdjusted += -(heightFacet.getWorld(position) - seaLevelFacet.getSeaLevel()) * .00006f + .07f; - // clamp to reasonable values + // clamp to reasonable values, just in case noiseAdjusted = TeraMath.clamp(noiseAdjusted, -.6f, .5f); facet.setWorld(position, noiseAdjusted); } @@ -86,8 +88,8 @@ public void process(GeneratingRegion region) { private static class TemperatureConfiguration implements Component { - @Range(min = -.4f, max = .4f, increment = .001f, precision = 1, description = "Mountain Height") - private float temperatureBase = .22f; + @Range(min = -.4f, max = .4f, increment = .001f, precision = 1, description = "Temperature Base") + private float temperatureBase = .20f; } } diff --git a/src/main/java/org/terasology/core/world/generator/rasterizers/SolidRasterizer.java b/src/main/java/org/terasology/core/world/generator/rasterizers/SolidRasterizer.java index 40fa81f..90f9125 100644 --- a/src/main/java/org/terasology/core/world/generator/rasterizers/SolidRasterizer.java +++ b/src/main/java/org/terasology/core/world/generator/rasterizers/SolidRasterizer.java @@ -15,6 +15,7 @@ */ package org.terasology.core.world.generator.rasterizers; +import org.slf4j.LoggerFactory; import org.terasology.biomesAPI.Biome; import org.terasology.biomesAPI.BiomeRegistry; import org.terasology.core.world.CoreBiome; @@ -23,17 +24,23 @@ import org.terasology.math.geom.Vector2i; import org.terasology.math.geom.Vector3i; import org.terasology.registry.CoreRegistry; +import org.terasology.world.WorldProvider; import org.terasology.world.block.Block; import org.terasology.world.block.BlockManager; import org.terasology.world.chunks.ChunkConstants; import org.terasology.world.chunks.CoreChunk; +import org.terasology.world.chunks.blockdata.ExtraDataSystem; +import org.terasology.world.chunks.blockdata.RegisterExtraData; import org.terasology.world.generation.Region; import org.terasology.world.generation.WorldRasterizer; import org.terasology.world.generation.facets.DensityFacet; import org.terasology.world.generation.facets.SeaLevelFacet; import org.terasology.world.generation.facets.SurfaceDepthFacet; import org.terasology.world.generation.facets.SurfaceHeightFacet; +import org.terasology.world.generation.facets.SurfaceHumidityFacet; +import org.terasology.world.generation.facets.SurfaceTemperatureFacet; +@ExtraDataSystem public class SolidRasterizer implements WorldRasterizer { private Block water; @@ -44,10 +51,12 @@ public class SolidRasterizer implements WorldRasterizer { private Block snow; private Block dirt; private BiomeRegistry biomeRegistry; + private WorldProvider worldProvider; @Override public void initialize() { BlockManager blockManager = CoreRegistry.get(BlockManager.class); + worldProvider = CoreRegistry.get(WorldProvider.class); biomeRegistry = CoreRegistry.get(BiomeRegistry.class); stone = blockManager.getBlock("CoreAssets:Stone"); water = blockManager.getBlock("CoreAssets:Water"); @@ -67,6 +76,9 @@ public void generateChunk(CoreChunk chunk, Region chunkRegion) { SeaLevelFacet seaLevelFacet = chunkRegion.getFacet(SeaLevelFacet.class); int seaLevel = seaLevelFacet.getSeaLevel(); + SurfaceHumidityFacet surfaceHumidityFacet = chunkRegion.getFacet(SurfaceHumidityFacet.class); + SurfaceTemperatureFacet surfaceTemperatureFacet = chunkRegion.getFacet(SurfaceTemperatureFacet.class); + Vector2i pos2d = new Vector2i(); for (Vector3i pos : ChunkConstants.CHUNK_REGION) { pos2d.set(pos.x, pos.z); @@ -99,6 +111,11 @@ public void generateChunk(CoreChunk chunk, Region chunkRegion) { // } } } + + // extra data has to be an int, so multiply by 1000, convert to int, and + // convert to float/divide by 1000 once using the block data + worldProvider.setExtraData("coreWorlds.temperature", pos.x, pos.y, pos.z, (int) (surfaceTemperatureFacet.get(pos.x, pos.z) * 1000)); + worldProvider.setExtraData("coreWorlds.humidity", pos.x, pos.y, pos.z, (int) (surfaceHumidityFacet.get(pos.x, pos.z) * 1000)); } } @@ -154,4 +171,13 @@ private Block getSurfaceBlock(int depth, int height, } return dirt; } + + @RegisterExtraData(name="coreWorlds.humidity", bitSize=16) + public static boolean humidityByBlock(Block block) { + return true; + } + @RegisterExtraData(name="coreWorlds.temperature", bitSize=16) + public static boolean temperatureByBlock(Block block) { + return true; + } } From ffc4b24c4b3e1cbbf605cbc27c89030cf5f8b5a7 Mon Sep 17 00:00:00 2001 From: Louis Rosenberg Date: Sun, 9 Aug 2020 15:31:05 -0400 Subject: [PATCH 5/9] More work on block data, still in progress --- .../facetProviders/HumidityProvider.java | 9 +++++++++ .../facetProviders/SimplexHumidityProvider.java | 17 ++++++++++++++++- .../SimplexSurfaceTemperatureProvider.java | 17 ++++++++++++++++- .../facetProviders/TemperatureProvider.java | 13 ++++++++++--- .../generator/rasterizers/SolidRasterizer.java | 7 ++++--- .../worldGenerators/FlatWorldGenerator.java | 2 -- .../HeightMapWorldGenerator.java | 2 -- .../PerlinFacetedWorldGenerator.java | 2 -- .../SimplexFacetedWorldGenerator.java | 2 -- 9 files changed, 55 insertions(+), 16 deletions(-) diff --git a/src/main/java/org/terasology/core/world/generator/facetProviders/HumidityProvider.java b/src/main/java/org/terasology/core/world/generator/facetProviders/HumidityProvider.java index 2f59a84..5ca25ed 100644 --- a/src/main/java/org/terasology/core/world/generator/facetProviders/HumidityProvider.java +++ b/src/main/java/org/terasology/core/world/generator/facetProviders/HumidityProvider.java @@ -19,6 +19,8 @@ import org.terasology.math.TeraMath; import org.terasology.math.geom.BaseVector2i; import org.terasology.math.geom.Rect2i; +import org.terasology.registry.CoreRegistry; +import org.terasology.world.WorldProvider; import org.terasology.world.generation.Facet; import org.terasology.world.generation.FacetProvider; import org.terasology.world.generation.GeneratingRegion; @@ -28,6 +30,13 @@ @Updates(@Facet(SurfaceHumidityFacet.class)) public class HumidityProvider implements FacetProvider { + private WorldProvider worldProvider; + + @Override + public void initialize() { + worldProvider = CoreRegistry.get(WorldProvider.class); + } + @Override public void setSeed(long seed) { } diff --git a/src/main/java/org/terasology/core/world/generator/facetProviders/SimplexHumidityProvider.java b/src/main/java/org/terasology/core/world/generator/facetProviders/SimplexHumidityProvider.java index d37c6c9..2da0201 100644 --- a/src/main/java/org/terasology/core/world/generator/facetProviders/SimplexHumidityProvider.java +++ b/src/main/java/org/terasology/core/world/generator/facetProviders/SimplexHumidityProvider.java @@ -17,21 +17,30 @@ import org.terasology.entitySystem.Component; import org.terasology.math.TeraMath; +import org.terasology.math.geom.BaseVector2i; +import org.terasology.math.geom.Rect2i; import org.terasology.math.geom.Vector2f; +import org.terasology.registry.CoreRegistry; import org.terasology.rendering.nui.properties.Range; import org.terasology.utilities.procedural.BrownianNoise; import org.terasology.utilities.procedural.SimplexNoise; import org.terasology.utilities.procedural.SubSampledNoise; +import org.terasology.world.WorldProvider; +import org.terasology.world.block.Block; +import org.terasology.world.chunks.blockdata.ExtraDataSystem; +import org.terasology.world.chunks.blockdata.RegisterExtraData; import org.terasology.world.generation.Border3D; import org.terasology.world.generation.ConfigurableFacetProvider; import org.terasology.world.generation.GeneratingRegion; import org.terasology.world.generation.Produces; +import org.terasology.world.generation.facets.SurfaceHeightFacet; import org.terasology.world.generation.facets.SurfaceHumidityFacet; /** * Defines surface humidity in the range [0..1] based on random noise. */ @Produces(SurfaceHumidityFacet.class) +@ExtraDataSystem public class SimplexHumidityProvider implements ConfigurableFacetProvider { private static final int SAMPLE_RATE = 4; @@ -66,8 +75,14 @@ public void process(GeneratingRegion region) { float[] noise = humidityNoise.noise(facet.getWorldRegion()); for (int i = 0; i < noise.length; ++i) { noise[i] = TeraMath.clamp((noise[i] * 2.11f + 1f) * 0.5f); + + Rect2i processRegion = facet.getWorldRegion(); + for (BaseVector2i position : processRegion.contents()) { + // clamp to reasonable values, just in case + float noiseAdjusted = TeraMath.clamp(noise[i], 0f,1f); + facet.setWorld(position, noiseAdjusted); + } } - facet.set(noise); region.setRegionFacet(SurfaceHumidityFacet.class, facet); } diff --git a/src/main/java/org/terasology/core/world/generator/facetProviders/SimplexSurfaceTemperatureProvider.java b/src/main/java/org/terasology/core/world/generator/facetProviders/SimplexSurfaceTemperatureProvider.java index d7a87ba..c49468f 100644 --- a/src/main/java/org/terasology/core/world/generator/facetProviders/SimplexSurfaceTemperatureProvider.java +++ b/src/main/java/org/terasology/core/world/generator/facetProviders/SimplexSurfaceTemperatureProvider.java @@ -15,7 +15,10 @@ */ package org.terasology.core.world.generator.facetProviders; +import org.slf4j.LoggerFactory; import org.terasology.math.TeraMath; +import org.terasology.math.geom.BaseVector2i; +import org.terasology.math.geom.Rect2i; import org.terasology.math.geom.Vector2f; import org.terasology.utilities.procedural.BrownianNoise; import org.terasology.utilities.procedural.SimplexNoise; @@ -23,6 +26,8 @@ import org.terasology.world.generation.FacetProvider; import org.terasology.world.generation.GeneratingRegion; import org.terasology.world.generation.Produces; +import org.terasology.world.generation.facets.SeaLevelFacet; +import org.terasology.world.generation.facets.SurfaceHeightFacet; import org.terasology.world.generation.facets.SurfaceTemperatureFacet; /** @@ -30,6 +35,7 @@ @Produces(SurfaceTemperatureFacet.class) public class SimplexSurfaceTemperatureProvider implements FacetProvider { private static final int SAMPLE_RATE = 4; + private static final float TEMPERATURE_BASE = .25f; private SubSampledNoise temperatureNoise; @@ -41,13 +47,22 @@ public void setSeed(long seed) { @Override public void process(GeneratingRegion region) { SurfaceTemperatureFacet facet = new SurfaceTemperatureFacet(region.getRegion(), region.getBorderForFacet(SurfaceTemperatureFacet.class)); + SeaLevelFacet seaLevelFacet = region.getRegionFacet(SeaLevelFacet.class); float[] noise = this.temperatureNoise.noise(facet.getWorldRegion()); + Rect2i processRegion = facet.getWorldRegion(); for (int i = 0; i < noise.length; ++i) { noise[i] = TeraMath.clamp((noise[i] * 2.11f + 1f) * 0.5f); + for (BaseVector2i position : processRegion.contents()) { + // modify initial noise + float noiseAdjusted = noise[i] / 5 + TEMPERATURE_BASE; + + // clamp to reasonable values, just in case + noiseAdjusted = TeraMath.clamp(noiseAdjusted, -.6f, .5f); + facet.setWorld(position, noiseAdjusted); + } } - facet.set(noise); region.setRegionFacet(SurfaceTemperatureFacet.class, facet); } } diff --git a/src/main/java/org/terasology/core/world/generator/facetProviders/TemperatureProvider.java b/src/main/java/org/terasology/core/world/generator/facetProviders/TemperatureProvider.java index 963df90..ad8c995 100644 --- a/src/main/java/org/terasology/core/world/generator/facetProviders/TemperatureProvider.java +++ b/src/main/java/org/terasology/core/world/generator/facetProviders/TemperatureProvider.java @@ -23,12 +23,14 @@ import org.terasology.math.geom.BaseVector2i; import org.terasology.math.geom.Rect2i; import org.terasology.math.geom.Vector2f; +import org.terasology.registry.CoreRegistry; import org.terasology.rendering.nui.properties.Range; import org.terasology.utilities.procedural.BrownianNoise; import org.terasology.utilities.procedural.Noise; import org.terasology.utilities.procedural.PerlinNoise; import org.terasology.utilities.procedural.SimplexNoise; import org.terasology.utilities.procedural.SubSampledNoise; +import org.terasology.world.WorldProvider; import org.terasology.world.generation.Border3D; import org.terasology.world.generation.ConfigurableFacetProvider; import org.terasology.world.generation.Facet; @@ -47,6 +49,13 @@ public class TemperatureProvider implements ConfigurableFacetProvider { private TemperatureConfiguration configuration = new TemperatureConfiguration(); private Noise temperatureNoise; + private WorldProvider worldProvider; + + @Override + public void initialize() { + worldProvider = CoreRegistry.get(WorldProvider.class); + } + @Override public void setSeed(long seed) { temperatureNoise = new SubSampledNoise(new BrownianNoise(new PerlinNoise(seed + 2), 8), new Vector2f(0.001f, 0.001f), 1); @@ -70,7 +79,6 @@ public void setConfiguration(Component configuration) { @Override public void process(GeneratingRegion region) { SurfaceTemperatureFacet facet = region.getRegionFacet(SurfaceTemperatureFacet.class); - SurfaceHeightFacet heightFacet = region.getRegionFacet(SurfaceHeightFacet.class); SeaLevelFacet seaLevelFacet = region.getRegionFacet(SeaLevelFacet.class); float temperatureBase = configuration.temperatureBase; @@ -78,7 +86,6 @@ public void process(GeneratingRegion region) { for (BaseVector2i position : processRegion.contents()) { // modify initial noise so that it falls (almost always) in range and its average is approximately temperatureBase float noiseAdjusted = temperatureNoise.noise(position.x(), position.y()) / 5 + temperatureBase; - noiseAdjusted += -(heightFacet.getWorld(position) - seaLevelFacet.getSeaLevel()) * .00006f + .07f; // clamp to reasonable values, just in case noiseAdjusted = TeraMath.clamp(noiseAdjusted, -.6f, .5f); @@ -89,7 +96,7 @@ public void process(GeneratingRegion region) { private static class TemperatureConfiguration implements Component { @Range(min = -.4f, max = .4f, increment = .001f, precision = 1, description = "Temperature Base") - private float temperatureBase = .20f; + private float temperatureBase = .25f; } } diff --git a/src/main/java/org/terasology/core/world/generator/rasterizers/SolidRasterizer.java b/src/main/java/org/terasology/core/world/generator/rasterizers/SolidRasterizer.java index 90f9125..a95b670 100644 --- a/src/main/java/org/terasology/core/world/generator/rasterizers/SolidRasterizer.java +++ b/src/main/java/org/terasology/core/world/generator/rasterizers/SolidRasterizer.java @@ -56,8 +56,6 @@ public class SolidRasterizer implements WorldRasterizer { @Override public void initialize() { BlockManager blockManager = CoreRegistry.get(BlockManager.class); - worldProvider = CoreRegistry.get(WorldProvider.class); - biomeRegistry = CoreRegistry.get(BiomeRegistry.class); stone = blockManager.getBlock("CoreAssets:Stone"); water = blockManager.getBlock("CoreAssets:Water"); ice = blockManager.getBlock("CoreAssets:Ice"); @@ -65,6 +63,9 @@ public void initialize() { grass = blockManager.getBlock("CoreAssets:Grass"); snow = blockManager.getBlock("CoreAssets:Snow"); dirt = blockManager.getBlock("CoreAssets:Dirt"); + + worldProvider = CoreRegistry.get(WorldProvider.class); + biomeRegistry = CoreRegistry.get(BiomeRegistry.class); } @Override @@ -113,7 +114,7 @@ public void generateChunk(CoreChunk chunk, Region chunkRegion) { } // extra data has to be an int, so multiply by 1000, convert to int, and - // convert to float/divide by 1000 once using the block data + // then convert to float/divide by 1000 once using the block data worldProvider.setExtraData("coreWorlds.temperature", pos.x, pos.y, pos.z, (int) (surfaceTemperatureFacet.get(pos.x, pos.z) * 1000)); worldProvider.setExtraData("coreWorlds.humidity", pos.x, pos.y, pos.z, (int) (surfaceHumidityFacet.get(pos.x, pos.z) * 1000)); } diff --git a/src/main/java/org/terasology/core/world/generator/worldGenerators/FlatWorldGenerator.java b/src/main/java/org/terasology/core/world/generator/worldGenerators/FlatWorldGenerator.java index fb8c552..88d34ff 100644 --- a/src/main/java/org/terasology/core/world/generator/worldGenerators/FlatWorldGenerator.java +++ b/src/main/java/org/terasology/core/world/generator/worldGenerators/FlatWorldGenerator.java @@ -51,8 +51,6 @@ protected WorldBuilder createWorld() { .addProvider(new SeaLevelProvider(32)) // height of 40 so that it is far enough from sea level so that it doesnt just create beachfront .addProvider(new FlatSurfaceHeightProvider(40)) - .addProvider(new PerlinHumidityProvider()) - .addProvider(new PerlinSurfaceTemperatureProvider()) .addProvider(new TemperatureProvider()) .addProvider(new HumidityProvider()) .addProvider(new BiomeProvider()) diff --git a/src/main/java/org/terasology/core/world/generator/worldGenerators/HeightMapWorldGenerator.java b/src/main/java/org/terasology/core/world/generator/worldGenerators/HeightMapWorldGenerator.java index b546650..d7ee975 100644 --- a/src/main/java/org/terasology/core/world/generator/worldGenerators/HeightMapWorldGenerator.java +++ b/src/main/java/org/terasology/core/world/generator/worldGenerators/HeightMapWorldGenerator.java @@ -53,8 +53,6 @@ protected WorldBuilder createWorld() { .setSeaLevel(16) .addProvider(new SeaLevelProvider(16)) .addProvider(new HeightMapSurfaceHeightProvider()) - .addProvider(new PerlinHumidityProvider()) - .addProvider(new PerlinSurfaceTemperatureProvider()) .addProvider(new TemperatureProvider()) .addProvider(new HumidityProvider()) .addProvider(new BiomeProvider()) diff --git a/src/main/java/org/terasology/core/world/generator/worldGenerators/PerlinFacetedWorldGenerator.java b/src/main/java/org/terasology/core/world/generator/worldGenerators/PerlinFacetedWorldGenerator.java index c565698..095578e 100644 --- a/src/main/java/org/terasology/core/world/generator/worldGenerators/PerlinFacetedWorldGenerator.java +++ b/src/main/java/org/terasology/core/world/generator/worldGenerators/PerlinFacetedWorldGenerator.java @@ -70,8 +70,6 @@ protected WorldBuilder createWorld() { return new WorldBuilder(worldGeneratorPluginLibrary) .setSeaLevel(seaLevel) .addProvider(new SeaLevelProvider(seaLevel)) - .addProvider(new PerlinHumidityProvider()) - .addProvider(new PerlinSurfaceTemperatureProvider()) .addProvider(new PerlinBaseSurfaceProvider()) .addProvider(new PerlinRiverProvider()) .addProvider(new PerlinOceanProvider()) diff --git a/src/main/java/org/terasology/core/world/generator/worldGenerators/SimplexFacetedWorldGenerator.java b/src/main/java/org/terasology/core/world/generator/worldGenerators/SimplexFacetedWorldGenerator.java index a1346b3..ad8a422 100644 --- a/src/main/java/org/terasology/core/world/generator/worldGenerators/SimplexFacetedWorldGenerator.java +++ b/src/main/java/org/terasology/core/world/generator/worldGenerators/SimplexFacetedWorldGenerator.java @@ -76,8 +76,6 @@ protected WorldBuilder createWorld() { .addProvider(new SimplexRiverProvider()) .addProvider(new SimplexOceanProvider()) .addProvider(new SimplexHillsAndMountainsProvider()) - .addProvider(new TemperatureProvider()) - .addProvider(new HumidityProvider()) .addProvider(new BiomeProvider()) .addProvider(new SurfaceToDensityProvider()) .addProvider(new DefaultFloraProvider()) From e5765e59a8c7d274424fccd4833217674922e6a0 Mon Sep 17 00:00:00 2001 From: Louis Rosenberg Date: Sun, 16 Aug 2020 16:18:10 -0400 Subject: [PATCH 6/9] Undo changes related to BiomesAPI, more debugging --- .../org/terasology/core/world/CoreBiome.java | 30 ++---- .../facetProviders/HumidityProvider.java | 54 ---------- .../facetProviders/TemperatureProvider.java | 102 ------------------ .../rasterizers/SolidRasterizer.java | 16 +-- .../worldGenerators/FlatWorldGenerator.java | 10 +- .../HeightMapWorldGenerator.java | 10 +- .../PerlinFacetedWorldGenerator.java | 12 +-- 7 files changed, 30 insertions(+), 204 deletions(-) delete mode 100644 src/main/java/org/terasology/core/world/generator/facetProviders/HumidityProvider.java delete mode 100644 src/main/java/org/terasology/core/world/generator/facetProviders/TemperatureProvider.java diff --git a/src/main/java/org/terasology/core/world/CoreBiome.java b/src/main/java/org/terasology/core/world/CoreBiome.java index 85526d3..5872db4 100644 --- a/src/main/java/org/terasology/core/world/CoreBiome.java +++ b/src/main/java/org/terasology/core/world/CoreBiome.java @@ -19,24 +19,20 @@ import org.terasology.naming.Name; public enum CoreBiome implements Biome { - MOUNTAINS("Mountains", .3f, .09f), - SNOW("Snow", .85f, .05f), - DESERT("Desert", .15f, .26f), - FOREST("Forest", .65f, .22f), - OCEAN("Ocean", .9f, .13f), - BEACH("Beach", .8f, .28f), - PLAINS("Plains", .55f, .22f); + MOUNTAINS("Mountains"), + SNOW("Snow"), + DESERT("Desert"), + FOREST("Forest"), + OCEAN("Ocean"), + BEACH("Beach"), + PLAINS("Plains"); private final Name id; private final String displayName; - private final float humidity; - private final float temperature; - CoreBiome(String displayName, float humidity, float temperature) { + CoreBiome(String displayName) { this.id = new Name("CoreWorlds:" + name()); this.displayName = displayName; - this.humidity = humidity; - this.temperature = temperature; } @Override @@ -53,14 +49,4 @@ public String getDisplayName() { public String toString() { return this.displayName; } - - @Override - public float getHumidity() { - return this.humidity; - } - - @Override - public float getTemperature() { - return this.temperature; - } } diff --git a/src/main/java/org/terasology/core/world/generator/facetProviders/HumidityProvider.java b/src/main/java/org/terasology/core/world/generator/facetProviders/HumidityProvider.java deleted file mode 100644 index 5ca25ed..0000000 --- a/src/main/java/org/terasology/core/world/generator/facetProviders/HumidityProvider.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright 2020 MovingBlocks - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.terasology.core.world.generator.facetProviders; - -import org.terasology.math.TeraMath; -import org.terasology.math.geom.BaseVector2i; -import org.terasology.math.geom.Rect2i; -import org.terasology.registry.CoreRegistry; -import org.terasology.world.WorldProvider; -import org.terasology.world.generation.Facet; -import org.terasology.world.generation.FacetProvider; -import org.terasology.world.generation.GeneratingRegion; -import org.terasology.world.generation.Updates; -import org.terasology.world.generation.facets.SurfaceHumidityFacet; - -@Updates(@Facet(SurfaceHumidityFacet.class)) -public class HumidityProvider implements FacetProvider { - - private WorldProvider worldProvider; - - @Override - public void initialize() { - worldProvider = CoreRegistry.get(WorldProvider.class); - } - - @Override - public void setSeed(long seed) { - } - - @Override - public void process(GeneratingRegion region) { - SurfaceHumidityFacet facet = region.getRegionFacet(SurfaceHumidityFacet.class); - - Rect2i processRegion = facet.getWorldRegion(); - for (BaseVector2i position : processRegion.contents()) { - // modify initial noise so that it lies between 0 and 1 - facet.setWorld(position, TeraMath.clamp(facet.getWorld(position.x(), position.y()), 0, 1)); - } - } -} diff --git a/src/main/java/org/terasology/core/world/generator/facetProviders/TemperatureProvider.java b/src/main/java/org/terasology/core/world/generator/facetProviders/TemperatureProvider.java deleted file mode 100644 index ad8c995..0000000 --- a/src/main/java/org/terasology/core/world/generator/facetProviders/TemperatureProvider.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Copyright 2020 MovingBlocks - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.terasology.core.world.generator.facetProviders; - -import org.slf4j.LoggerFactory; -import org.terasology.core.world.generator.facets.TreeFacet; -import org.terasology.entitySystem.Component; -import org.terasology.math.TeraMath; -import org.terasology.math.geom.BaseVector2i; -import org.terasology.math.geom.Rect2i; -import org.terasology.math.geom.Vector2f; -import org.terasology.registry.CoreRegistry; -import org.terasology.rendering.nui.properties.Range; -import org.terasology.utilities.procedural.BrownianNoise; -import org.terasology.utilities.procedural.Noise; -import org.terasology.utilities.procedural.PerlinNoise; -import org.terasology.utilities.procedural.SimplexNoise; -import org.terasology.utilities.procedural.SubSampledNoise; -import org.terasology.world.WorldProvider; -import org.terasology.world.generation.Border3D; -import org.terasology.world.generation.ConfigurableFacetProvider; -import org.terasology.world.generation.Facet; -import org.terasology.world.generation.GeneratingRegion; -import org.terasology.world.generation.Requires; -import org.terasology.world.generation.Updates; -import org.terasology.world.generation.facets.SeaLevelFacet; -import org.terasology.world.generation.facets.SurfaceHeightFacet; -import org.terasology.world.generation.facets.SurfaceHumidityFacet; -import org.terasology.world.generation.facets.SurfaceTemperatureFacet; -import sun.rmi.runtime.Log; - -@Updates(@Facet(SurfaceTemperatureFacet.class)) - -public class TemperatureProvider implements ConfigurableFacetProvider { - private TemperatureConfiguration configuration = new TemperatureConfiguration(); - private Noise temperatureNoise; - - private WorldProvider worldProvider; - - @Override - public void initialize() { - worldProvider = CoreRegistry.get(WorldProvider.class); - } - - @Override - public void setSeed(long seed) { - temperatureNoise = new SubSampledNoise(new BrownianNoise(new PerlinNoise(seed + 2), 8), new Vector2f(0.001f, 0.001f), 1); - } - - @Override - public String getConfigurationName() { - return "Temperature"; - } - - @Override - public Component getConfiguration() { - return configuration; - } - - @Override - public void setConfiguration(Component configuration) { - this.configuration = (TemperatureConfiguration)configuration; - } - - @Override - public void process(GeneratingRegion region) { - SurfaceTemperatureFacet facet = region.getRegionFacet(SurfaceTemperatureFacet.class); - SeaLevelFacet seaLevelFacet = region.getRegionFacet(SeaLevelFacet.class); - float temperatureBase = configuration.temperatureBase; - - Rect2i processRegion = facet.getWorldRegion(); - for (BaseVector2i position : processRegion.contents()) { - // modify initial noise so that it falls (almost always) in range and its average is approximately temperatureBase - float noiseAdjusted = temperatureNoise.noise(position.x(), position.y()) / 5 + temperatureBase; - - // clamp to reasonable values, just in case - noiseAdjusted = TeraMath.clamp(noiseAdjusted, -.6f, .5f); - facet.setWorld(position, noiseAdjusted); - } - } - - private static class TemperatureConfiguration implements Component - { - @Range(min = -.4f, max = .4f, increment = .001f, precision = 1, description = "Temperature Base") - private float temperatureBase = .25f; - } - -} diff --git a/src/main/java/org/terasology/core/world/generator/rasterizers/SolidRasterizer.java b/src/main/java/org/terasology/core/world/generator/rasterizers/SolidRasterizer.java index a95b670..7fa2617 100644 --- a/src/main/java/org/terasology/core/world/generator/rasterizers/SolidRasterizer.java +++ b/src/main/java/org/terasology/core/world/generator/rasterizers/SolidRasterizer.java @@ -15,7 +15,6 @@ */ package org.terasology.core.world.generator.rasterizers; -import org.slf4j.LoggerFactory; import org.terasology.biomesAPI.Biome; import org.terasology.biomesAPI.BiomeRegistry; import org.terasology.core.world.CoreBiome; @@ -24,11 +23,11 @@ import org.terasology.math.geom.Vector2i; import org.terasology.math.geom.Vector3i; import org.terasology.registry.CoreRegistry; -import org.terasology.world.WorldProvider; import org.terasology.world.block.Block; import org.terasology.world.block.BlockManager; import org.terasology.world.chunks.ChunkConstants; import org.terasology.world.chunks.CoreChunk; +import org.terasology.world.chunks.blockdata.ExtraBlockDataManager; import org.terasology.world.chunks.blockdata.ExtraDataSystem; import org.terasology.world.chunks.blockdata.RegisterExtraData; import org.terasology.world.generation.Region; @@ -51,11 +50,12 @@ public class SolidRasterizer implements WorldRasterizer { private Block snow; private Block dirt; private BiomeRegistry biomeRegistry; - private WorldProvider worldProvider; + private ExtraBlockDataManager extraBlockDataManager; @Override public void initialize() { BlockManager blockManager = CoreRegistry.get(BlockManager.class); + biomeRegistry = CoreRegistry.get(BiomeRegistry.class); stone = blockManager.getBlock("CoreAssets:Stone"); water = blockManager.getBlock("CoreAssets:Water"); ice = blockManager.getBlock("CoreAssets:Ice"); @@ -64,12 +64,14 @@ public void initialize() { snow = blockManager.getBlock("CoreAssets:Snow"); dirt = blockManager.getBlock("CoreAssets:Dirt"); - worldProvider = CoreRegistry.get(WorldProvider.class); - biomeRegistry = CoreRegistry.get(BiomeRegistry.class); + extraBlockDataManager = CoreRegistry.get(ExtraBlockDataManager.class); } @Override public void generateChunk(CoreChunk chunk, Region chunkRegion) { + int temperatureSlot = extraBlockDataManager.getSlotNumber("coreWorlds.temperature"); + int humiditySlot = extraBlockDataManager.getSlotNumber("coreWorlds.humidity"); + DensityFacet solidityFacet = chunkRegion.getFacet(DensityFacet.class); SurfaceHeightFacet surfaceFacet = chunkRegion.getFacet(SurfaceHeightFacet.class); SurfaceDepthFacet surfaceDepthFacet = chunkRegion.getFacet(SurfaceDepthFacet.class); @@ -115,8 +117,8 @@ public void generateChunk(CoreChunk chunk, Region chunkRegion) { // extra data has to be an int, so multiply by 1000, convert to int, and // then convert to float/divide by 1000 once using the block data - worldProvider.setExtraData("coreWorlds.temperature", pos.x, pos.y, pos.z, (int) (surfaceTemperatureFacet.get(pos.x, pos.z) * 1000)); - worldProvider.setExtraData("coreWorlds.humidity", pos.x, pos.y, pos.z, (int) (surfaceHumidityFacet.get(pos.x, pos.z) * 1000)); + chunk.setExtraData(temperatureSlot, pos.x, pos.y, pos.z, (int) (surfaceTemperatureFacet.get(pos.x, pos.z) * 1000)); + chunk.setExtraData(humiditySlot, pos.x, pos.y, pos.z, (int) (surfaceHumidityFacet.get(pos.x, pos.z) * 1000)); } } diff --git a/src/main/java/org/terasology/core/world/generator/worldGenerators/FlatWorldGenerator.java b/src/main/java/org/terasology/core/world/generator/worldGenerators/FlatWorldGenerator.java index 88d34ff..490bbe3 100644 --- a/src/main/java/org/terasology/core/world/generator/worldGenerators/FlatWorldGenerator.java +++ b/src/main/java/org/terasology/core/world/generator/worldGenerators/FlatWorldGenerator.java @@ -19,12 +19,10 @@ import org.terasology.core.world.generator.facetProviders.DefaultFloraProvider; import org.terasology.core.world.generator.facetProviders.DefaultTreeProvider; import org.terasology.core.world.generator.facetProviders.FlatSurfaceHeightProvider; -import org.terasology.core.world.generator.facetProviders.HumidityProvider; -import org.terasology.core.world.generator.facetProviders.PerlinHumidityProvider; -import org.terasology.core.world.generator.facetProviders.PerlinSurfaceTemperatureProvider; import org.terasology.core.world.generator.facetProviders.SeaLevelProvider; +import org.terasology.core.world.generator.facetProviders.SimplexHumidityProvider; +import org.terasology.core.world.generator.facetProviders.SimplexSurfaceTemperatureProvider; import org.terasology.core.world.generator.facetProviders.SurfaceToDensityProvider; -import org.terasology.core.world.generator.facetProviders.TemperatureProvider; import org.terasology.core.world.generator.rasterizers.FloraRasterizer; import org.terasology.core.world.generator.rasterizers.SolidRasterizer; import org.terasology.core.world.generator.rasterizers.TreeRasterizer; @@ -51,8 +49,8 @@ protected WorldBuilder createWorld() { .addProvider(new SeaLevelProvider(32)) // height of 40 so that it is far enough from sea level so that it doesnt just create beachfront .addProvider(new FlatSurfaceHeightProvider(40)) - .addProvider(new TemperatureProvider()) - .addProvider(new HumidityProvider()) + .addProvider(new SimplexSurfaceTemperatureProvider()) + .addProvider(new SimplexHumidityProvider()) .addProvider(new BiomeProvider()) .addProvider(new SurfaceToDensityProvider()) .addProvider(new DefaultFloraProvider()) diff --git a/src/main/java/org/terasology/core/world/generator/worldGenerators/HeightMapWorldGenerator.java b/src/main/java/org/terasology/core/world/generator/worldGenerators/HeightMapWorldGenerator.java index d7ee975..ed3f466 100644 --- a/src/main/java/org/terasology/core/world/generator/worldGenerators/HeightMapWorldGenerator.java +++ b/src/main/java/org/terasology/core/world/generator/worldGenerators/HeightMapWorldGenerator.java @@ -19,12 +19,10 @@ import org.terasology.core.world.generator.facetProviders.DefaultFloraProvider; import org.terasology.core.world.generator.facetProviders.DefaultTreeProvider; import org.terasology.core.world.generator.facetProviders.HeightMapSurfaceHeightProvider; -import org.terasology.core.world.generator.facetProviders.HumidityProvider; -import org.terasology.core.world.generator.facetProviders.PerlinHumidityProvider; -import org.terasology.core.world.generator.facetProviders.PerlinSurfaceTemperatureProvider; import org.terasology.core.world.generator.facetProviders.SeaLevelProvider; +import org.terasology.core.world.generator.facetProviders.SimplexHumidityProvider; +import org.terasology.core.world.generator.facetProviders.SimplexSurfaceTemperatureProvider; import org.terasology.core.world.generator.facetProviders.SurfaceToDensityProvider; -import org.terasology.core.world.generator.facetProviders.TemperatureProvider; import org.terasology.core.world.generator.rasterizers.FloraRasterizer; import org.terasology.core.world.generator.rasterizers.SolidRasterizer; import org.terasology.core.world.generator.rasterizers.TreeRasterizer; @@ -53,8 +51,8 @@ protected WorldBuilder createWorld() { .setSeaLevel(16) .addProvider(new SeaLevelProvider(16)) .addProvider(new HeightMapSurfaceHeightProvider()) - .addProvider(new TemperatureProvider()) - .addProvider(new HumidityProvider()) + .addProvider(new SimplexSurfaceTemperatureProvider()) + .addProvider(new SimplexHumidityProvider()) .addProvider(new BiomeProvider()) .addProvider(new SurfaceToDensityProvider()) .addProvider(new DefaultFloraProvider()) diff --git a/src/main/java/org/terasology/core/world/generator/worldGenerators/PerlinFacetedWorldGenerator.java b/src/main/java/org/terasology/core/world/generator/worldGenerators/PerlinFacetedWorldGenerator.java index 095578e..b16eafd 100644 --- a/src/main/java/org/terasology/core/world/generator/worldGenerators/PerlinFacetedWorldGenerator.java +++ b/src/main/java/org/terasology/core/world/generator/worldGenerators/PerlinFacetedWorldGenerator.java @@ -18,17 +18,15 @@ import org.terasology.core.world.generator.facetProviders.BiomeProvider; import org.terasology.core.world.generator.facetProviders.DefaultFloraProvider; import org.terasology.core.world.generator.facetProviders.DefaultTreeProvider; -import org.terasology.core.world.generator.facetProviders.HumidityProvider; -import org.terasology.core.world.generator.facetProviders.PlateauProvider; import org.terasology.core.world.generator.facetProviders.PerlinBaseSurfaceProvider; import org.terasology.core.world.generator.facetProviders.PerlinHillsAndMountainsProvider; -import org.terasology.core.world.generator.facetProviders.PerlinHumidityProvider; import org.terasology.core.world.generator.facetProviders.PerlinOceanProvider; import org.terasology.core.world.generator.facetProviders.PerlinRiverProvider; -import org.terasology.core.world.generator.facetProviders.PerlinSurfaceTemperatureProvider; +import org.terasology.core.world.generator.facetProviders.PlateauProvider; import org.terasology.core.world.generator.facetProviders.SeaLevelProvider; +import org.terasology.core.world.generator.facetProviders.SimplexHumidityProvider; +import org.terasology.core.world.generator.facetProviders.SimplexSurfaceTemperatureProvider; import org.terasology.core.world.generator.facetProviders.SurfaceToDensityProvider; -import org.terasology.core.world.generator.facetProviders.TemperatureProvider; import org.terasology.core.world.generator.rasterizers.FloraRasterizer; import org.terasology.core.world.generator.rasterizers.SolidRasterizer; import org.terasology.core.world.generator.rasterizers.TreeRasterizer; @@ -74,8 +72,8 @@ protected WorldBuilder createWorld() { .addProvider(new PerlinRiverProvider()) .addProvider(new PerlinOceanProvider()) .addProvider(new PerlinHillsAndMountainsProvider()) - .addProvider(new TemperatureProvider()) - .addProvider(new HumidityProvider()) + .addProvider(new SimplexSurfaceTemperatureProvider()) + .addProvider(new SimplexHumidityProvider()) .addProvider(new BiomeProvider()) .addProvider(new SurfaceToDensityProvider()) .addProvider(new DefaultFloraProvider()) From 66cfed11f2831ec882f6ec5149db5b7c23c1d3c2 Mon Sep 17 00:00:00 2001 From: Louis Rosenberg Date: Sun, 30 Aug 2020 11:18:09 -0400 Subject: [PATCH 7/9] Adjustments to temperature and humidity generation; still being tested --- .../facetProviders/SimplexHumidityProvider.java | 17 +++++++---------- .../SimplexSurfaceTemperatureProvider.java | 17 ++++++----------- .../SimplexFacetedWorldGenerator.java | 4 +--- 3 files changed, 14 insertions(+), 24 deletions(-) diff --git a/src/main/java/org/terasology/core/world/generator/facetProviders/SimplexHumidityProvider.java b/src/main/java/org/terasology/core/world/generator/facetProviders/SimplexHumidityProvider.java index c677235..fbd49d5 100644 --- a/src/main/java/org/terasology/core/world/generator/facetProviders/SimplexHumidityProvider.java +++ b/src/main/java/org/terasology/core/world/generator/facetProviders/SimplexHumidityProvider.java @@ -15,6 +15,7 @@ */ package org.terasology.core.world.generator.facetProviders; +import org.slf4j.LoggerFactory; import org.terasology.entitySystem.Component; import org.terasology.math.TeraMath; import org.terasology.math.geom.BaseVector2i; @@ -71,17 +72,13 @@ public void process(GeneratingRegion region) { Border3D border = region.getBorderForFacet(SurfaceHumidityFacet.class); SurfaceHumidityFacet facet = new SurfaceHumidityFacet(region.getRegion(), border); - float[] noise = humidityNoise.noise(facet.getWorldRegion()); - for (int i = 0; i < noise.length; ++i) { - noise[i] = TeraMath.clamp((noise[i] * 2.11f + 1f) * 0.5f); - - Rect2i processRegion = facet.getWorldRegion(); - for (BaseVector2i position : processRegion.contents()) { - // clamp to reasonable values, just in case - float noiseAdjusted = TeraMath.clamp(noise[i], 0f,1f); - facet.setWorld(position, noiseAdjusted); - } + Rect2i processRegion = facet.getWorldRegion(); + for (BaseVector2i position : processRegion.contents()) { + // clamp to reasonable values, just in case + float noiseAdjusted = TeraMath.clamp(humidityNoise.noise(position.x(), position.y()) + .6f, 0f,1f); + facet.setWorld(position, noiseAdjusted); } + region.setRegionFacet(SurfaceHumidityFacet.class, facet); } diff --git a/src/main/java/org/terasology/core/world/generator/facetProviders/SimplexSurfaceTemperatureProvider.java b/src/main/java/org/terasology/core/world/generator/facetProviders/SimplexSurfaceTemperatureProvider.java index c49468f..856395e 100644 --- a/src/main/java/org/terasology/core/world/generator/facetProviders/SimplexSurfaceTemperatureProvider.java +++ b/src/main/java/org/terasology/core/world/generator/facetProviders/SimplexSurfaceTemperatureProvider.java @@ -47,20 +47,15 @@ public void setSeed(long seed) { @Override public void process(GeneratingRegion region) { SurfaceTemperatureFacet facet = new SurfaceTemperatureFacet(region.getRegion(), region.getBorderForFacet(SurfaceTemperatureFacet.class)); - SeaLevelFacet seaLevelFacet = region.getRegionFacet(SeaLevelFacet.class); - float[] noise = this.temperatureNoise.noise(facet.getWorldRegion()); Rect2i processRegion = facet.getWorldRegion(); - for (int i = 0; i < noise.length; ++i) { - noise[i] = TeraMath.clamp((noise[i] * 2.11f + 1f) * 0.5f); - for (BaseVector2i position : processRegion.contents()) { - // modify initial noise - float noiseAdjusted = noise[i] / 5 + TEMPERATURE_BASE; + for (BaseVector2i position : processRegion.contents()) { + // modify initial noise + float noiseAdjusted = this.temperatureNoise.noise(position.x(), position.y()) / 5 + TEMPERATURE_BASE; - // clamp to reasonable values, just in case - noiseAdjusted = TeraMath.clamp(noiseAdjusted, -.6f, .5f); - facet.setWorld(position, noiseAdjusted); - } + // clamp to more reasonable base values, just in case + noiseAdjusted = TeraMath.clamp(noiseAdjusted, -.1f, .45f); + facet.setWorld(position, noiseAdjusted); } region.setRegionFacet(SurfaceTemperatureFacet.class, facet); diff --git a/src/main/java/org/terasology/core/world/generator/worldGenerators/SimplexFacetedWorldGenerator.java b/src/main/java/org/terasology/core/world/generator/worldGenerators/SimplexFacetedWorldGenerator.java index ad8a422..ad25f97 100644 --- a/src/main/java/org/terasology/core/world/generator/worldGenerators/SimplexFacetedWorldGenerator.java +++ b/src/main/java/org/terasology/core/world/generator/worldGenerators/SimplexFacetedWorldGenerator.java @@ -18,17 +18,15 @@ import org.terasology.core.world.generator.facetProviders.BiomeProvider; import org.terasology.core.world.generator.facetProviders.DefaultFloraProvider; import org.terasology.core.world.generator.facetProviders.DefaultTreeProvider; -import org.terasology.core.world.generator.facetProviders.HumidityProvider; import org.terasology.core.world.generator.facetProviders.PlateauProvider; +import org.terasology.core.world.generator.facetProviders.SeaLevelProvider; import org.terasology.core.world.generator.facetProviders.SimplexBaseSurfaceProvider; import org.terasology.core.world.generator.facetProviders.SimplexHillsAndMountainsProvider; import org.terasology.core.world.generator.facetProviders.SimplexHumidityProvider; import org.terasology.core.world.generator.facetProviders.SimplexOceanProvider; import org.terasology.core.world.generator.facetProviders.SimplexRiverProvider; import org.terasology.core.world.generator.facetProviders.SimplexSurfaceTemperatureProvider; -import org.terasology.core.world.generator.facetProviders.SeaLevelProvider; import org.terasology.core.world.generator.facetProviders.SurfaceToDensityProvider; -import org.terasology.core.world.generator.facetProviders.TemperatureProvider; import org.terasology.core.world.generator.rasterizers.FloraRasterizer; import org.terasology.core.world.generator.rasterizers.SolidRasterizer; import org.terasology.core.world.generator.rasterizers.TreeRasterizer; From 24cf391690be49116581ed251f49b310d45eb8cf Mon Sep 17 00:00:00 2001 From: Louis Rosenberg Date: Sun, 30 Aug 2020 16:19:05 -0400 Subject: [PATCH 8/9] Simplify imports and adjust noise clamping --- .../core/world/generator/facetProviders/BiomeProvider.java | 4 ---- .../facetProviders/SimplexSurfaceTemperatureProvider.java | 2 +- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/src/main/java/org/terasology/core/world/generator/facetProviders/BiomeProvider.java b/src/main/java/org/terasology/core/world/generator/facetProviders/BiomeProvider.java index 323a660..04ef301 100644 --- a/src/main/java/org/terasology/core/world/generator/facetProviders/BiomeProvider.java +++ b/src/main/java/org/terasology/core/world/generator/facetProviders/BiomeProvider.java @@ -15,11 +15,9 @@ */ package org.terasology.core.world.generator.facetProviders; -import org.slf4j.LoggerFactory; import org.terasology.core.world.CoreBiome; import org.terasology.core.world.generator.facets.BiomeFacet; import org.terasology.math.geom.BaseVector2i; -import org.terasology.rendering.nui.properties.Range; import org.terasology.world.generation.Border3D; import org.terasology.world.generation.Facet; import org.terasology.world.generation.FacetProvider; @@ -31,8 +29,6 @@ import org.terasology.world.generation.facets.SurfaceHumidityFacet; import org.terasology.world.generation.facets.SurfaceTemperatureFacet; -import java.awt.Component; - /** * Determines the biome based on temperature and humidity */ diff --git a/src/main/java/org/terasology/core/world/generator/facetProviders/SimplexSurfaceTemperatureProvider.java b/src/main/java/org/terasology/core/world/generator/facetProviders/SimplexSurfaceTemperatureProvider.java index 856395e..82c30e6 100644 --- a/src/main/java/org/terasology/core/world/generator/facetProviders/SimplexSurfaceTemperatureProvider.java +++ b/src/main/java/org/terasology/core/world/generator/facetProviders/SimplexSurfaceTemperatureProvider.java @@ -54,7 +54,7 @@ public void process(GeneratingRegion region) { float noiseAdjusted = this.temperatureNoise.noise(position.x(), position.y()) / 5 + TEMPERATURE_BASE; // clamp to more reasonable base values, just in case - noiseAdjusted = TeraMath.clamp(noiseAdjusted, -.1f, .45f); + noiseAdjusted = TeraMath.clamp(noiseAdjusted, -.45f, .45f); facet.setWorld(position, noiseAdjusted); } From e2ee6169ba359a20fb18c38ea86eb8997a7b8f8b Mon Sep 17 00:00:00 2001 From: Louis Rosenberg Date: Sun, 13 Sep 2020 15:45:43 -0400 Subject: [PATCH 9/9] Make requested changes --- .../facetProviders/SimplexHumidityProvider.java | 11 ++--------- .../SimplexSurfaceTemperatureProvider.java | 7 ++----- .../world/generator/rasterizers/SolidRasterizer.java | 8 ++++---- 3 files changed, 8 insertions(+), 18 deletions(-) diff --git a/src/main/java/org/terasology/core/world/generator/facetProviders/SimplexHumidityProvider.java b/src/main/java/org/terasology/core/world/generator/facetProviders/SimplexHumidityProvider.java index fbd49d5..fde755a 100644 --- a/src/main/java/org/terasology/core/world/generator/facetProviders/SimplexHumidityProvider.java +++ b/src/main/java/org/terasology/core/world/generator/facetProviders/SimplexHumidityProvider.java @@ -15,7 +15,6 @@ */ package org.terasology.core.world.generator.facetProviders; -import org.slf4j.LoggerFactory; import org.terasology.entitySystem.Component; import org.terasology.math.TeraMath; import org.terasology.math.geom.BaseVector2i; @@ -25,22 +24,16 @@ import org.terasology.utilities.procedural.BrownianNoise; import org.terasology.utilities.procedural.SimplexNoise; import org.terasology.utilities.procedural.SubSampledNoise; -import org.terasology.world.WorldProvider; -import org.terasology.world.block.Block; -import org.terasology.world.chunks.blockdata.ExtraDataSystem; -import org.terasology.world.chunks.blockdata.RegisterExtraData; import org.terasology.world.generation.Border3D; import org.terasology.world.generation.ConfigurableFacetProvider; import org.terasology.world.generation.GeneratingRegion; import org.terasology.world.generation.Produces; -import org.terasology.world.generation.facets.SurfaceHeightFacet; import org.terasology.world.generation.facets.SurfaceHumidityFacet; /** * Defines surface humidity in the range [0..1] based on random noise. */ @Produces(SurfaceHumidityFacet.class) -@ExtraDataSystem public class SimplexHumidityProvider implements ConfigurableFacetProvider { private static final int SAMPLE_RATE = 4; @@ -74,8 +67,8 @@ public void process(GeneratingRegion region) { Rect2i processRegion = facet.getWorldRegion(); for (BaseVector2i position : processRegion.contents()) { - // clamp to reasonable values, just in case - float noiseAdjusted = TeraMath.clamp(humidityNoise.noise(position.x(), position.y()) + .6f, 0f,1f); + // clamp to reasonable values (between 0 and 1, since it's relative humidity), just in case + float noiseAdjusted = TeraMath.clamp(humidityNoise.noise(position.x(), position.y()) + .6f, 0f, 1f); facet.setWorld(position, noiseAdjusted); } diff --git a/src/main/java/org/terasology/core/world/generator/facetProviders/SimplexSurfaceTemperatureProvider.java b/src/main/java/org/terasology/core/world/generator/facetProviders/SimplexSurfaceTemperatureProvider.java index 82c30e6..9b7f347 100644 --- a/src/main/java/org/terasology/core/world/generator/facetProviders/SimplexSurfaceTemperatureProvider.java +++ b/src/main/java/org/terasology/core/world/generator/facetProviders/SimplexSurfaceTemperatureProvider.java @@ -15,7 +15,6 @@ */ package org.terasology.core.world.generator.facetProviders; -import org.slf4j.LoggerFactory; import org.terasology.math.TeraMath; import org.terasology.math.geom.BaseVector2i; import org.terasology.math.geom.Rect2i; @@ -26,8 +25,6 @@ import org.terasology.world.generation.FacetProvider; import org.terasology.world.generation.GeneratingRegion; import org.terasology.world.generation.Produces; -import org.terasology.world.generation.facets.SeaLevelFacet; -import org.terasology.world.generation.facets.SurfaceHeightFacet; import org.terasology.world.generation.facets.SurfaceTemperatureFacet; /** @@ -50,10 +47,10 @@ public void process(GeneratingRegion region) { Rect2i processRegion = facet.getWorldRegion(); for (BaseVector2i position : processRegion.contents()) { - // modify initial noise + // modify initial noise to make it closer to temperature base float noiseAdjusted = this.temperatureNoise.noise(position.x(), position.y()) / 5 + TEMPERATURE_BASE; - // clamp to more reasonable base values, just in case + // clamp to more reasonable base values, where each value is a Celsuis temperature / 100 noiseAdjusted = TeraMath.clamp(noiseAdjusted, -.45f, .45f); facet.setWorld(position, noiseAdjusted); } diff --git a/src/main/java/org/terasology/core/world/generator/rasterizers/SolidRasterizer.java b/src/main/java/org/terasology/core/world/generator/rasterizers/SolidRasterizer.java index 7fa2617..5c10ae1 100644 --- a/src/main/java/org/terasology/core/world/generator/rasterizers/SolidRasterizer.java +++ b/src/main/java/org/terasology/core/world/generator/rasterizers/SolidRasterizer.java @@ -69,8 +69,8 @@ public void initialize() { @Override public void generateChunk(CoreChunk chunk, Region chunkRegion) { - int temperatureSlot = extraBlockDataManager.getSlotNumber("coreWorlds.temperature"); - int humiditySlot = extraBlockDataManager.getSlotNumber("coreWorlds.humidity"); + int temperatureSlot = extraBlockDataManager.getSlotNumber("climateConditions.temperature"); + int humiditySlot = extraBlockDataManager.getSlotNumber("climateConditions.humidity"); DensityFacet solidityFacet = chunkRegion.getFacet(DensityFacet.class); SurfaceHeightFacet surfaceFacet = chunkRegion.getFacet(SurfaceHeightFacet.class); @@ -175,11 +175,11 @@ private Block getSurfaceBlock(int depth, int height, return dirt; } - @RegisterExtraData(name="coreWorlds.humidity", bitSize=16) + @RegisterExtraData(name="climateConditions.humidity", bitSize=16) public static boolean humidityByBlock(Block block) { return true; } - @RegisterExtraData(name="coreWorlds.temperature", bitSize=16) + @RegisterExtraData(name="climateConditions.temperature", bitSize=16) public static boolean temperatureByBlock(Block block) { return true; }