summaryrefslogtreecommitdiffstats
path: root/graphics
diff options
context:
space:
mode:
Diffstat (limited to 'graphics')
-rw-r--r--graphics/src/damage.rs7
1 files changed, 4 insertions, 3 deletions
diff --git a/graphics/src/damage.rs b/graphics/src/damage.rs
index ff8edaf5..17d60451 100644
--- a/graphics/src/damage.rs
+++ b/graphics/src/damage.rs
@@ -1,5 +1,5 @@
//! Compute the damage between frames.
-use crate::core::Rectangle;
+use crate::core::{Point, Rectangle};
/// Diffs the damage regions given some previous and current primitives.
pub fn diff<T>(
@@ -50,9 +50,10 @@ pub fn group(mut damage: Vec<Rectangle>, bounds: Rectangle) -> Vec<Rectangle> {
const AREA_THRESHOLD: f32 = 20_000.0;
damage.sort_by(|a, b| {
- a.x.partial_cmp(&b.x)
+ a.center()
+ .distance(Point::ORIGIN)
+ .partial_cmp(&b.center().distance(Point::ORIGIN))
.unwrap_or(Ordering::Equal)
- .then_with(|| a.y.partial_cmp(&b.y).unwrap_or(Ordering::Equal))
});
let mut output = Vec::new();