Skip to content

Commit

Permalink
Potential 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 c686f42 commit 6d09519
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 @@ -152,12 +152,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;
}

const float vert_penetration = std::min(itop, ibottom);
const float horiz_penetration = std::min(ileft, iright);

Expand All @@ -178,6 +172,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 6d09519

Please sign in to comment.