Optimize the values for EMPTY rect. (#13470)

I am unsure if this needs changing, so let me know if I need to change
anything else.

# Objective

Fixes #13461.

## Solution

I applied the changes as suggested in the issue, and updated the doc
comments accordingly

## Testing

I don't think this needs too much testing, but there are no `cargo test`
failures.
This commit is contained in:
Olle Lukowski 2024-05-22 15:34:23 +02:00 committed by GitHub
parent 5dbd827728
commit 1ec5cdf3f2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 16 additions and 7 deletions

View file

@ -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.

View file

@ -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.
///

View file

@ -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.