| 338 | } |
| 339 | |
| 340 | void PolygonalCollider::load(vili::node& data) |
| 341 | { |
| 342 | auto addTagHelper = [this](ColliderTagType type, vili::node& tag) { |
| 343 | if (!tag.is_null()) |
| 344 | { |
| 345 | if (tag.is<vili::string>()) |
| 346 | { |
| 347 | this->addTag(type, tag); |
| 348 | } |
| 349 | else if (tag.is<vili::array>()) |
| 350 | { |
| 351 | for (vili::node& item : tag) |
| 352 | this->addTag(Collision::ColliderTagType::Rejected, item); |
| 353 | } |
| 354 | else |
| 355 | { |
| 356 | // TODO: Raise exception |
| 357 | } |
| 358 | } |
| 359 | }; |
| 360 | const std::string pointsUnit = data.at("unit"); |
| 361 | bool completePoint = true; |
| 362 | double pointBuffer = 0; |
| 363 | const Transform::Units pBaseUnit = Transform::stringToUnits(pointsUnit); |
| 364 | for (vili::node& colliderPoint : data["points"]) |
| 365 | { |
| 366 | const Transform::UnitVector pVector2 = Transform::UnitVector( |
| 367 | colliderPoint["x"], colliderPoint["y"], pBaseUnit); |
| 368 | this->addPoint(pVector2); |
| 369 | } |
| 370 | this->setWorkingUnit(pBaseUnit); |
| 371 | |
| 372 | addTagHelper(ColliderTagType::Tag, data["tag"]); |
| 373 | addTagHelper(ColliderTagType::Accepted, data["accept"]); |
| 374 | addTagHelper(ColliderTagType::Rejected, data["reject"]); |
| 375 | } |
| 376 | |
| 377 | bool PolygonalCollider::checkTags(const PolygonalCollider& collider) const |
| 378 | { |
nothing calls this directly
no test coverage detected