Merge pull request #2651 from rhogenson/total-cmp

Use float total_cmp instead of partial_cmp to get a total order.
This commit is contained in:
Héctor 2024-10-28 17:38:54 +01:00 committed by GitHub
commit 50340b4b43
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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();