From 4c49b6ba6aa454f3e79cd67e1914f68fe155c694 Mon Sep 17 00:00:00 2001 From: Dan Date: Thu, 7 Jul 2011 22:59:52 +0100 Subject: [PATCH] replaces TERRAIN_HILLS_DUNES with something less messed up and altogether nicer. --- Changelog.txt | 1 + src/GeoSphereStyle.cpp | 29 ++++++++++++++++++----------- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/Changelog.txt b/Changelog.txt index 0b2c12dbc1a..78df52dfcf8 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -52,6 +52,7 @@ Alpha 12 * Occasional crash in system cache pruning (#230, #237) * Crash due to buffer overrun in sound player (#253) * Fixed HDR lighting on Radeon (#87, #263) + * Replace broken hill/dune terrain with something that works * Internal changes * All model timing now based of game time (#175, #178) diff --git a/src/GeoSphereStyle.cpp b/src/GeoSphereStyle.cpp index 1a48eb60dc9..4116b7d2731 100644 --- a/src/GeoSphereStyle.cpp +++ b/src/GeoSphereStyle.cpp @@ -351,7 +351,7 @@ GeoSphereStyle::GeoSphereStyle(const SBody *body) TERRAIN_RUGGED_LAVA, TERRAIN_RUGGED_DESERT, }; - //m_terrainType = TERRAIN_MOUNTAINS_RIVERS; + //m_terrainType = TERRAIN_HILLS_DUNES; m_terrainType = choices[rand.Int32(11)]; m_colorType = COLOR_TFPOOR; } else if (body->m_volatileGas > fixed(1,10)) { @@ -508,10 +508,10 @@ void GeoSphereStyle::InitFractalType(MTRand &rand) case TERRAIN_HILLS_DUNES: { SetFracDef(&m_fracdef[0], m_maxHeightInMeters, rand.Double(1e6, 1e7), rand, 10000); - SetFracDef(&m_fracdef[1], m_maxHeightInMeters*0.00000000001, 100.0, rand, 10000); - SetFracDef(&m_fracdef[2], m_maxHeightInMeters*0.0000001, rand.Double(500, 2e3), rand, 1000); - SetFracDef(&m_fracdef[3], m_maxHeightInMeters*0.00002, rand.Double(1500, 1e4), rand, 100); - SetFracDef(&m_fracdef[4], m_maxHeightInMeters*0.08, 1e4, rand, 50); + SetFracDef(&m_fracdef[1], m_maxHeightInMeters*0.00001, 1e5, rand, 1000); + SetFracDef(&m_fracdef[2], m_maxHeightInMeters*0.000001, rand.Double(1e5, 1e6), rand, 100); + SetFracDef(&m_fracdef[3], m_maxHeightInMeters*0.0000002, rand.Double(500, 2e4), rand, 50); + SetFracDef(&m_fracdef[4], m_maxHeightInMeters*0.000000008, rand.Double(5, 70), rand, 10); break; } case TERRAIN_HILLS_RIDGED: @@ -852,14 +852,21 @@ double GeoSphereStyle::GetHeight(const vector3d &p) double continents = ridged_octavenoise(m_fracdef[0], 0.585, p) - m_sealevel; if (continents < 0) return 0; double n = continents; - double distrib = dunes_octavenoise(m_fracdef[2], 0.5, p); - double m = m_fracdef[3].amplitude * dunes_octavenoise(m_fracdef[4], 0.5*distrib, p); - m += ridged_octavenoise(m_fracdef[2], 0.5*distrib, p); + double distrib = dunes_octavenoise(m_fracdef[1], 0.5*m_fracdef[2].amplitude, p); + double m = 0.1 * m_fracdef[1].amplitude * dunes_octavenoise(m_fracdef[2], 0.5*distrib, p); + double mountains = ridged_octavenoise(m_fracdef[2], 0.5*distrib, p) * octavenoise(m_fracdef[2], 0.5, p) * + octavenoise(m_fracdef[1], 0.5*distrib, p) * distrib; + m += mountains; + //detail for mountains, stops them looking smooth, m_fracdef[4] is a very small scale fractal for close-up + //for this terrain m_fracdef[0-4] gradually decrease in size with 0 being large. + m += mountains*mountains*0.02*octavenoise(m_fracdef[4], 0.6*mountains*mountains*distrib, p); + m *= m*m*m*10.0; // cliffs at shore - if (continents < 0.001) n += m * continents * 1000.0f; + if (continents < 0.01) n += m * continents * 100.0f; else n += m; - n += continents*continents*continents*dunes_octavenoise(m_fracdef[1], 0.4*distrib, p); - return m_maxHeight * n; + n += continents*Clamp(0.5-m, 0.0, 0.5)*0.2*dunes_octavenoise(m_fracdef[3], 0.6*distrib, p); + n += continents*Clamp(0.05-n, 0.0, 0.01)*0.2*dunes_octavenoise(m_fracdef[4], Clamp(0.5-n, 0.0, 0.5), p); + return n*m_maxHeight; } case TERRAIN_HILLS_RIDGED: {