From a89f37bb653eda393d835b9546ec86244d3932b6 Mon Sep 17 00:00:00 2001 From: kwolekr Date: Wed, 10 Dec 2014 01:31:21 -0500 Subject: [PATCH] Add support for lacunarity in legacy NoiseParams string format --- src/settings.cpp | 6 +++++- src/test.cpp | 8 ++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/settings.cpp b/src/settings.cpp index aec4b8f65..d1a257607 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -473,7 +473,11 @@ bool Settings::getNoiseParamsFromValue(const std::string &name, f.next(","); np.seed = stoi(f.next(",")); np.octaves = stoi(f.next(",")); - np.persist = stof(f.next("")); + np.persist = stof(f.next(",")); + + std::string optional_params = f.next(""); + if (optional_params != "") + np.lacunarity = stof(optional_params); return true; } diff --git a/src/test.cpp b/src/test.cpp index adae8ff57..e0e17bed4 100644 --- a/src/test.cpp +++ b/src/test.cpp @@ -440,7 +440,7 @@ struct TestPath: public TestBase "some multiline text\n" \ " with leading whitespace!\n" \ "\"\"\"\n" \ - "np_terrain = 5, 40, (250, 250, 250), 12345, 5, 0.7\n" \ + "np_terrain = 5, 40, (250, 250, 250), 12341, 5, 0.7, 2.4\n" \ "zoop = true" #define TEST_CONFIG_TEXT_AFTER \ @@ -467,12 +467,12 @@ struct TestPath: public TestBase "\"\"\"\n" \ "np_terrain = {\n" \ " flags = defaults\n" \ - " lacunarity = 2\n" \ + " lacunarity = 2.4\n" \ " octaves = 6\n" \ " offset = 3.5\n" \ " persistence = 0.7\n" \ " scale = 40\n" \ - " seed = 12345\n" \ + " seed = 12341\n" \ " spread = (250,250,250)\n" \ "}\n" \ "zoop = true\n" \ @@ -552,7 +552,7 @@ struct TestSettings: public TestBase UASSERT(fabs(np.spread.X - 250) < 0.001); UASSERT(fabs(np.spread.Y - 250) < 0.001); UASSERT(fabs(np.spread.Z - 250) < 0.001); - UASSERT(np.seed == 12345); + UASSERT(np.seed == 12341); UASSERT(np.octaves == 5); UASSERT(fabs(np.persist - 0.7) < 0.001);