Skip to content

Commit

Permalink
Allow shapes to be constructed with zero values (#13365)
Browse files Browse the repository at this point in the history
# Objective

Fixes #13332.

## Solution

The assertion `circumradius >= 0.0` to allow zero.

Are there any other shapes that need to be allowed to be constructed
with zero?

---------

Co-authored-by: François Mockers <francois.mockers@vleue.com>
  • Loading branch information
juliohq and mockersf authored May 16, 2024
1 parent d17fb16 commit f61c55f
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions crates/bevy_math/src/primitives/dim2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -723,10 +723,13 @@ impl RegularPolygon {
///
/// # Panics
///
/// Panics if `circumradius` is non-positive
/// Panics if `circumradius` is negative
#[inline(always)]
pub fn new(circumradius: f32, sides: usize) -> Self {
assert!(circumradius > 0.0, "polygon has a non-positive radius");
assert!(
circumradius.is_sign_positive(),
"polygon has a negative radius"
);
assert!(sides > 2, "polygon has less than 3 sides");

Self {
Expand Down

0 comments on commit f61c55f

Please sign in to comment.