diff options
author | kwolekr <kwolekr@minetest.net> | 2014-12-10 01:31:21 -0500 |
---|---|---|
committer | kwolekr <kwolekr@minetest.net> | 2014-12-10 01:31:43 -0500 |
commit | a89f37bb653eda393d835b9546ec86244d3932b6 (patch) | |
tree | a4cf06fdea9dc4d5ed6ada2fa772ebbb93090e57 | |
parent | daefd0ab367605eabe1a293dd7f6a50964bb3801 (diff) | |
download | minetest-a89f37bb653eda393d835b9546ec86244d3932b6.tar.gz minetest-a89f37bb653eda393d835b9546ec86244d3932b6.tar.bz2 minetest-a89f37bb653eda393d835b9546ec86244d3932b6.zip |
Add support for lacunarity in legacy NoiseParams string format
-rw-r--r-- | src/settings.cpp | 6 | ||||
-rw-r--r-- | 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); |