Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new constructors for Circle and Sphere #11526

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions crates/bevy_math/src/primitives/dim2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,12 @@ pub struct Circle {
impl Primitive2d for Circle {}

impl Circle {
/// Create a new [`Circle`] from a `radius`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// Create a new [`Circle`] from a `radius`
/// Create a new [`Circle`] from a `radius`.

Copy link
Contributor Author

@Jondolf Jondolf Jan 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most constructors (Plane2d::new, Segment2d::new, Polyline2d::new, Triangle2d::new, Rectangle::new...) in these files currently don't end the doc comment with a period unless the comment spans multiple lines. The doc comments for Circle and its radius also don't end with a period. I'd like to change them all to end with a period and be more consistent though.

#[inline(always)]
pub const fn new(radius: f32) -> Self {
Self { radius }
}

/// Finds the point on the circle that is closest to the given `point`.
///
/// If the point is outside the circle, the returned point will be on the perimeter of the circle.
Expand Down
6 changes: 6 additions & 0 deletions crates/bevy_math/src/primitives/dim3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,12 @@ pub struct Sphere {
impl Primitive3d for Sphere {}

impl Sphere {
/// Create a new [`Sphere`] from a `radius`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// Create a new [`Sphere`] from a `radius`
/// Create a new [`Sphere`] from a `radius`.

#[inline(always)]
pub const fn new(radius: f32) -> Self {
Self { radius }
}

/// Finds the point on the sphere that is closest to the given `point`.
///
/// If the point is outside the sphere, the returned point will be on the surface of the sphere.
Expand Down