Skip to content

Commit

Permalink
Merge pull request #2651 from rhogenson/total-cmp
Browse files Browse the repository at this point in the history
Use float total_cmp instead of partial_cmp to get a total order.
  • Loading branch information
hecrj authored Oct 28, 2024
2 parents d660fad + f3733a8 commit 50340b4
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions graphics/src/damage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,12 @@ pub fn list<T>(
/// Groups the given damage regions that are close together inside the given
/// bounds.
pub fn group(mut damage: Vec<Rectangle>, bounds: Rectangle) -> Vec<Rectangle> {
use std::cmp::Ordering;

const AREA_THRESHOLD: f32 = 20_000.0;

damage.sort_by(|a, b| {
a.center()
.distance(Point::ORIGIN)
.partial_cmp(&b.center().distance(Point::ORIGIN))
.unwrap_or(Ordering::Equal)
.total_cmp(&b.center().distance(Point::ORIGIN))
});

let mut output = Vec::new();
Expand Down

0 comments on commit 50340b4

Please sign in to comment.