+bool Settings::getNoiseParams(const std::string &name, NoiseParams &np) const
+{
+ return getNoiseParamsFromGroup(name, np) || getNoiseParamsFromValue(name, np);
+}
+
+
+bool Settings::getNoiseParamsFromValue(const std::string &name,
+ NoiseParams &np) const
+{
+ std::string value;
+
+ if (!getNoEx(name, value))
+ return false;
+
+ Strfnd f(value);
+
+ np.offset = stof(f.next(","));
+ np.scale = stof(f.next(","));
+ f.next("(");
+ np.spread.X = stof(f.next(","));
+ np.spread.Y = stof(f.next(","));
+ np.spread.Z = stof(f.next(")"));
+ f.next(",");
+ np.seed = stoi(f.next(","));
+ np.octaves = stoi(f.next(","));
+ np.persist = stof(f.next(","));
+
+ std::string optional_params = f.next("");
+ if (optional_params != "")
+ np.lacunarity = stof(optional_params);
+
+ return true;
+}
+
+
+bool Settings::getNoiseParamsFromGroup(const std::string &name,
+ NoiseParams &np) const
+{
+ Settings *group = NULL;
+
+ if (!getGroupNoEx(name, group))
+ return false;
+
+ group->getFloatNoEx("offset", np.offset);
+ group->getFloatNoEx("scale", np.scale);
+ group->getV3FNoEx("spread", np.spread);
+ group->getS32NoEx("seed", np.seed);
+ group->getU16NoEx("octaves", np.octaves);
+ group->getFloatNoEx("persistence", np.persist);
+ group->getFloatNoEx("lacunarity", np.lacunarity);
+
+ np.flags = 0;
+ if (!group->getFlagStrNoEx("flags", np.flags, flagdesc_noiseparams))
+ np.flags = NOISE_FLAG_DEFAULTS;
+
+ return true;
+}
+
+