diff --git a/crates/bevy_math/src/rects/irect.rs b/crates/bevy_math/src/rects/irect.rs index d99a4ae080..786f39cdd4 100644 --- a/crates/bevy_math/src/rects/irect.rs +++ b/crates/bevy_math/src/rects/irect.rs @@ -20,9 +20,12 @@ pub struct IRect { impl IRect { /// An empty `IRect`, represented by maximum and minimum corner points - /// with all `i32::MAX` values. + /// with `max == IVec2::MIN` and `min == IVec2::MAX`, so the + /// rect has an extremely large negative size. + /// This is useful, because when taking a union B of a non-empty `IRect` A and + /// this empty `IRect`, B will simply equal A. pub const EMPTY: Self = Self { - max: IVec2::MAX, + max: IVec2::MIN, min: IVec2::MAX, }; /// Create a new rectangle from two corner points. diff --git a/crates/bevy_math/src/rects/rect.rs b/crates/bevy_math/src/rects/rect.rs index 786c57588f..82aa9d8574 100644 --- a/crates/bevy_math/src/rects/rect.rs +++ b/crates/bevy_math/src/rects/rect.rs @@ -20,10 +20,13 @@ pub struct Rect { impl Rect { /// An empty `Rect`, represented by maximum and minimum corner points - /// with all `f32::MAX` values. + /// at `Vec2::NEG_INFINITY` and `Vec2::INFINITY`, respectively. + /// This is so the `Rect` has a infinitely negative size. + /// This is useful, because when taking a union B of a non-empty `Rect` A and + /// this empty `Rect`, B will simply equal A. pub const EMPTY: Self = Self { - max: Vec2::MAX, - min: Vec2::MAX, + max: Vec2::NEG_INFINITY, + min: Vec2::INFINITY, }; /// Create a new rectangle from two corner points. /// diff --git a/crates/bevy_math/src/rects/urect.rs b/crates/bevy_math/src/rects/urect.rs index 2903dc163d..80fdbe7760 100644 --- a/crates/bevy_math/src/rects/urect.rs +++ b/crates/bevy_math/src/rects/urect.rs @@ -20,9 +20,12 @@ pub struct URect { impl URect { /// An empty `URect`, represented by maximum and minimum corner points - /// with all `u32::MAX` values. + /// with `max == UVec2::MIN` and `min == UVec2::MAX`, so the + /// rect has an extremely large negative size. + /// This is useful, because when taking a union B of a non-empty `URect` A and + /// this empty `URect`, B will simply equal A. pub const EMPTY: Self = Self { - max: UVec2::MAX, + max: UVec2::MIN, min: UVec2::MAX, }; /// Create a new rectangle from two corner points.