| 712 | } |
| 713 | |
| 714 | void MovementController::forEachMovingCollision(RectF const& region, function<bool(MovingCollisionId id, PhysicsMovingCollision, PolyF, RectF)> callback) { |
| 715 | auto geometry = world()->geometry(); |
| 716 | for (auto& physicsEntity : world()->query<PhysicsEntity>(region)) { |
| 717 | if (m_ignorePhysicsEntities.contains(physicsEntity->entityId())) |
| 718 | continue; |
| 719 | for (size_t i = 0; i < physicsEntity->movingCollisionCount(); ++i) { |
| 720 | if (auto mc = physicsEntity->movingCollision(i)) { |
| 721 | if (mc->categoryFilter.check(m_parameters.physicsEffectCategories.value())) { |
| 722 | PolyF poly = std::move(mc->collision); |
| 723 | poly.translate(geometry.nearestTo(region.min(), mc->position)); |
| 724 | RectF polyBounds = poly.boundBox(); |
| 725 | |
| 726 | if (region.intersects(polyBounds)) { |
| 727 | // early exit if the callback returns false |
| 728 | if(callback({physicsEntity->entityId(), i}, *mc, poly, polyBounds) == false) |
| 729 | return; |
| 730 | } |
| 731 | } |
| 732 | } |
| 733 | } |
| 734 | } |
| 735 | } |
| 736 | |
| 737 | void MovementController::updateForceRegions(float) { |
| 738 | auto geometry = world()->geometry(); |
no test coverage detected