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

Deprecate shapes in bevy_render::mesh::shape #11773

Merged
merged 5 commits into from
Feb 8, 2024

Conversation

Jondolf
Copy link
Contributor

@Jondolf Jondolf commented Feb 7, 2024

Objective

#11431 and #11688 implemented meshing support for Bevy's new geometric primitives. The next step is to deprecate the shapes in bevy_render::mesh::shape and to later remove them completely for 0.14.

Solution

Deprecate the shapes and reduce code duplication by utilizing the primitive meshing API for the old shapes where possible.

Note that some shapes have behavior that can't be exactly reproduced with the new primitives yet:

  • Box is more of an AABB with min/max extents
  • Plane supports a subdivision count
  • Quad has a flipped property

These types have not been changed to utilize the new primitives yet.


Changelog

  • Deprecated all shapes in bevy_render::mesh::shape
  • Changed all examples to use new primitives for meshing

Migration Guide

Bevy has previously used rendering-specific types like UVSphere and Quad for primitive mesh shapes. These have now been deprecated to use the geometric primitives newly introduced in version 0.13.

Some examples:

let before = meshes.add(shape::Box::new(5.0, 0.15, 5.0));
let after = meshes.add(Cuboid::new(5.0, 0.15, 5.0));

let before = meshes.add(shape::Quad::default());
let after = meshes.add(Rectangle::default());

let before = meshes.add(shape::Plane::from_size(5.0));
// The surface normal can now also be specified when using `new`
let after = meshes.add(Plane3d::default().mesh().size(5.0, 5.0));

let before = meshes.add(
    Mesh::try_from(shape::Icosphere {
        radius: 0.5,
        subdivisions: 5,
    })
    .unwrap(),
);
let after = meshes.add(Sphere::new(0.5).mesh().ico(5).unwrap());

@Jondolf Jondolf added this to the 0.13 milestone Feb 7, 2024
@Jondolf Jondolf added A-Rendering Drawing game state to the screen C-Code-Quality A section of code that is hard to understand or change labels Feb 7, 2024
@Jondolf Jondolf changed the title Deprecate shapes in bevy_render::mesh::shapes Deprecate shapes in bevy_render::mesh::shape Feb 7, 2024
Comment on lines 36 to 42
#[deprecated(
since = "0.13.0",
note = "please use the `Cuboid` primitive for meshing or `Aabb2d` for a bounding volume"
)]
#[derive(Debug, Copy, Clone)]
pub struct Box {
pub min_x: f32,
Copy link
Contributor

Choose a reason for hiding this comment

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

Hooray!

Copy link
Member

@alice-i-cecile alice-i-cecile left a comment

Choose a reason for hiding this comment

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

Nice deprecation notices :)

Copy link
Contributor

@NthTensor NthTensor left a comment

Choose a reason for hiding this comment

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

Looks great. This must have been pretty tedious. Really appreceate how quickly you got this in.

}

#[test]
fn test_regular_polygon() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Document the purpose of this test please. I'm not sure I could fix this if I broke it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's not my test, it was added by #11017. Personally, I find it to be a bit redundant and would remove it, but it was on the old RegularPolygon type so I kept it for now.

Copy link
Contributor

Choose a reason for hiding this comment

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

"Document RegularPolygon by writing a test" and then proceeds to write no documentation for the test.

Fair enough.

errors/B0004.md Show resolved Hide resolved
@alice-i-cecile alice-i-cecile added this pull request to the merge queue Feb 8, 2024
@alice-i-cecile alice-i-cecile added the S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it label Feb 8, 2024
Merged via the queue into bevyengine:main with commit 0166db3 Feb 8, 2024
24 checks passed
@Jondolf Jondolf deleted the deprecate-old-shapes branch February 8, 2024 19:07
@eerii eerii mentioned this pull request Feb 14, 2024
@rparrett rparrett mentioned this pull request Mar 1, 2024
46 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Rendering Drawing game state to the screen C-Code-Quality A section of code that is hard to understand or change S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants