From 3a144c8c1fc83150fc06d792082db5cc4bce3cc5 Mon Sep 17 00:00:00 2001 From: Julian T Date: Tue, 9 Feb 2021 20:00:52 +0100 Subject: Add tiling for rendering --- src/core/bound.rs | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'src/core/bound.rs') diff --git a/src/core/bound.rs b/src/core/bound.rs index a1c1070..404424e 100644 --- a/src/core/bound.rs +++ b/src/core/bound.rs @@ -45,6 +45,15 @@ impl Bound2 { ) } + /// Finds the intersected area between two bounds + pub fn intersect(&self, b: &Bound2) -> Bound2 { + Bound2::new( + &Vector2::new_xy(max(self.min.x, b.min.x), max(self.min.y, b.min.y)), + &Vector2::new_xy(min(self.max.x, b.max.x), min(self.max.y, b.max.y)), + ) + } + + /// Calculates the diagonal vector /// /// Can be used to calculate the size of the bound @@ -96,14 +105,6 @@ impl From<&Bound2f> for Bound2i { } } -/// Finds the intersected area between two bounds -pub fn intersect(a: &Bound2, b: &Bound2) -> Bound2 { - Bound2::new( - &Vector2::new_xy(max(a.min.x, b.min.x), max(a.min.y, b.min.y)), - &Vector2::new_xy(min(a.max.x, b.max.x), min(a.max.y, b.max.y)), - ) -} - #[cfg(test)] mod tests { use super::*; -- cgit v1.2.3