Skip to content

Commit

Permalink
Fix for CollisionSystem depending on object order
Browse files Browse the repository at this point in the history
  • Loading branch information
mrkubax10 committed Oct 29, 2023
1 parent d355d87 commit 9f88337
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/collision/collision_system.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,12 +160,6 @@ collision::Constraints check_collisions(const Vector& obj_movement, const Rectf&

if (!shiftout)
{
if (other_object != nullptr && moving_object != nullptr) {
const HitResponse response = other_object->collision(*moving_object, dummy);
if (response == ABORT_MOVE)
return constraints;
}

if (other_object && other_object->is_unisolid())
{
// Constrain only on fall on top of the unisolid object.
Expand Down Expand Up @@ -198,6 +192,16 @@ collision::Constraints check_collisions(const Vector& obj_movement, const Rectf&
constraints.hit.left = true;
}
}
if (other_object && moving_object)
{
CollisionHit hit = constraints.hit;
moving_object->collision(*other_object, hit);
std::swap(hit.left, hit.right);
std::swap(hit.top, hit.bottom);
const HitResponse response = other_object->collision(*moving_object, hit);
if(response==ABORT_MOVE)
return collision::Constraints();
}
}

return constraints;
Expand Down

0 comments on commit 9f88337

Please sign in to comment.