MCPcopy Create free account
hub / github.com/ElectroZybr/LatticeLab / parseRandomFillOptions

Method parseRandomFillOptions

Lattice/Scripting/ScriptAPI.cpp:212–239  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

210}
211
212::Generators::RandomFillOptions ScriptAPI::parseRandomFillOptions(const sol::object& object) const {
213 ::Generators::RandomFillOptions options;
214 if (!object.is<sol::table>()) {
215 return options;
216 }
217
218 const sol::table table = object.as<sol::table>();
219 options.density = table.get_or("density", options.density);
220 options.temperature = table.get_or("temperature", options.temperature);
221 options.margin = table.get_or("margin", options.margin);
222 options.maxAttemptsPerSpawn = table.get_or("attempts", options.maxAttemptsPerSpawn);
223 options.randomRotation = table.get_or("random_rotation", options.randomRotation);
224 options.fixed = table.get_or("fixed", options.fixed);
225 options.seed = table.get_or("seed", options.seed);
226
227 const std::string mode = table.get_or("mode", std::string{});
228 if (mode == "reset") {
229 options.mode = ::Generators::SpawnMode::Reset;
230 } else if (mode == "add") {
231 options.mode = ::Generators::SpawnMode::Add;
232 } else if (mode == "replace" || mode.empty()) {
233 options.mode = ::Generators::SpawnMode::Replace;
234 } else {
235 throw std::runtime_error("unsupported random_fill mode: " + mode);
236 }
237
238 return options;
239}
240
241::Generators::LatticeFillOptions ScriptAPI::parseLatticeFillOptions(const sol::object& object) const {
242 ::Generators::LatticeFillOptions options;

Callers

nothing calls this directly

Calls 1

emptyMethod · 0.45

Tested by

no test coverage detected