Skip to content

Commit

Permalink
Add support for removing attributes from meshes. (bevyengine#5254)
Browse files Browse the repository at this point in the history
# Objective

Support removing attributes from meshes. For an example use case, meshes created using the bevy::predule::shape types or loaded from external files may have attributes that are not needed for the materials they will be rendered with.

This was extracted from PR bevyengine#5222.

## Solution

Implement Mesh::remove_attribute().
  • Loading branch information
komadori authored and inodentry committed Aug 8, 2022
1 parent 7836552 commit 845658c
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions crates/bevy_render/src/mesh/mesh/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,16 @@ impl Mesh {
);
}

/// Removes the data for a vertex attribute
pub fn remove_attribute(
&mut self,
attribute: impl Into<MeshVertexAttributeId>,
) -> Option<VertexAttributeValues> {
self.attributes
.remove(&attribute.into())
.map(|data| data.values)
}

#[inline]
pub fn contains_attribute(&self, id: impl Into<MeshVertexAttributeId>) -> bool {
self.attributes.contains_key(&id.into())
Expand Down

0 comments on commit 845658c

Please sign in to comment.