MCPcopy Create free account
hub / github.com/OpenStarbound/OpenStarbound / forEachMovingCollision

Method forEachMovingCollision

source/game/StarMovementController.cpp:714–735  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

712}
713
714void 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
737void MovementController::updateForceRegions(float) {
738 auto geometry = world()->geometry();

Callers 1

movingCollisionMethod · 0.80

Calls 12

entityIdMethod · 0.80
geometryMethod · 0.45
containsMethod · 0.45
movingCollisionCountMethod · 0.45
movingCollisionMethod · 0.45
checkMethod · 0.45
valueMethod · 0.45
translateMethod · 0.45
nearestToMethod · 0.45
minMethod · 0.45
boundBoxMethod · 0.45
intersectsMethod · 0.45

Tested by

no test coverage detected