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

Method parseRegion

Lattice/Scripting/ScriptAPI.cpp:185–210  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

183}
184
185std::unique_ptr<Generators::Region> ScriptAPI::parseRegion(const sol::object& object) const {
186 if (!object.is<sol::table>()) {
187 throw std::runtime_error("region must be a table");
188 }
189
190 const sol::table table = object.as<sol::table>();
191 const std::string kind = requireStringField(table, "kind", "region");
192
193 if (kind == "box") {
194 auto region = std::make_unique<Generators::Rectangle>();
195 const glm::vec3 min = readVec3Object(table["min"]);
196 const glm::vec3 size = readVec3Object(table["size"]);
197 region->boxSize = size;
198 region->center = min + size * 0.5f;
199 return region;
200 }
201
202 if (kind == "sphere") {
203 auto region = std::make_unique<Generators::Sphere>();
204 region->center = readVec3Object(table["center"]);
205 region->sphereRadius = table.get_or("radius", 0.0f);
206 return region;
207 }
208
209 throw std::runtime_error("unsupported region kind: " + kind);
210}
211
212::Generators::RandomFillOptions ScriptAPI::parseRandomFillOptions(const sol::object& object) const {
213 ::Generators::RandomFillOptions options;

Callers

nothing calls this directly

Calls 2

requireStringFieldFunction · 0.85
readVec3ObjectFunction · 0.85

Tested by

no test coverage detected