Skip to content

Commit

Permalink
Fix swimming on slopes
Browse files Browse the repository at this point in the history
  • Loading branch information
MatusGuy committed Apr 2, 2024
1 parent 47a37d6 commit c7704bb
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/collision/collision_system.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -675,22 +675,24 @@ CollisionSystem::is_free_of_tiles(const Rectf& rect, const bool ignoreUnisolid,
for (int y = test_tiles.top; y < test_tiles.bottom; ++y) {
const Tile& tile = solids->get_tile(x, y);

if (tile.get_attributes() & tiletype)
return false;
if (tile.is_unisolid() && !ignoreUnisolid)
return false;
if (!(tile.get_attributes() & tiletype))
continue;
if (tile.is_unisolid () && ignoreUnisolid)
continue;
if (tile.is_slope ()) {
AATriangle triangle;
const Rectf tbbox = solids->get_tile_bbox(x, y);
triangle = AATriangle(tbbox, tile.get_data());
Constraints constraints;
if (collision::rectangle_aatriangle(&constraints, rect, triangle))
return false;
if (!collision::rectangle_aatriangle(&constraints, rect, triangle))
continue;
}
// We have a solid tile that overlaps the given rectangle.
return false;
}
}
}

return true;
}

Expand Down

0 comments on commit c7704bb

Please sign in to comment.