| 183 | } |
| 184 | |
| 185 | std::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; |
nothing calls this directly
no test coverage detected