Skip to content

Add get_attributes_mut for Mesh#18976

Open
hukasu wants to merge 10 commits into
bevyengine:mainfrom
hukasu:issue2134
Open

Add get_attributes_mut for Mesh#18976
hukasu wants to merge 10 commits into
bevyengine:mainfrom
hukasu:issue2134

Conversation

@hukasu
Copy link
Copy Markdown
Contributor

@hukasu hukasu commented Apr 29, 2025

Objective

Closes #2134

Solution

Create a method in Mesh to retrieve multiple attributes mutably.

Testing

New test on bevy_mesh/mesh.rs

Alternatives

Leave to the users collect the desired attributes through the Mesh::attributes_mut method

Showcase

let [pos1, pos2, pos3, normal, color] = mesh.get_attributes_mut([
    &Mesh::ATTRIBUTE_POSITION.id,
    &Mesh::ATTRIBUTE_POSITION.id,
    &Mesh::ATTRIBUTE_POSITION.id,
    &Mesh::ATTRIBUTE_NORMAL.id,
    &Mesh::ATTRIBUTE_COLOR.id,
]);
assert_eq!(pos1.unwrap().0, &Mesh::ATTRIBUTE_POSITION);
assert!(pos2.is_none());
assert!(pos3.is_none());
assert_eq!(normal.unwrap().0, &Mesh::ATTRIBUTE_NORMAL);
assert_eq!(color.unwrap().0, &Mesh::ATTRIBUTE_COLOR);

@ickshonpe ickshonpe added A-Rendering Drawing game state to the screen C-Usability A targeted quality-of-life change that makes Bevy easier to use S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Apr 29, 2025
@hukasu hukasu added S-Waiting-on-Author The author needs to make changes or address concerns before this can be merged and removed S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Jul 7, 2025
@hukasu hukasu added the M-Release-Note Work that should be called out in the blog due to impact label Nov 13, 2025
@github-actions
Copy link
Copy Markdown
Contributor

It looks like your PR has been selected for a highlight in the next release blog post, but you didn't provide a release note.

Please review the instructions for writing release notes, then expand or revise the content in the release notes directory to showcase your changes.

@hukasu hukasu added S-Needs-Review Needs reviewer attention (from anyone!) to move forward and removed S-Waiting-on-Author The author needs to make changes or address concerns before this can be merged labels Nov 13, 2025
@cart cart closed this May 5, 2026
@cart cart reopened this May 5, 2026
Copy link
Copy Markdown
Contributor

@IceSentry IceSentry left a comment

Choose a reason for hiding this comment

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

I thinks this could be useful, can you fix the conflicts?

Comment thread crates/bevy_mesh/src/mesh.rs Outdated
if let Some(pos) = attrs_slice[1..].iter().position(Option::is_none) {
attrs_slice.swap(0, pos + 1);
} else {
unimplemented!(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is it possible to avoid this unimplemented branch? I'd prefer if it returned and error instead of panicking.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

that is actually supposed to be an unreachable

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-Usability A targeted quality-of-life change that makes Bevy easier to use M-Release-Note Work that should be called out in the blog due to impact S-Needs-Review Needs reviewer attention (from anyone!) to move forward

Projects

No open projects
Status: No status

Development

Successfully merging this pull request may close these issues.

Simultaneous mutable/immutable access to different mesh attributes

5 participants