From 2d6f82259c65c4969a99e27a5db025c401afacc7 Mon Sep 17 00:00:00 2001 From: Robin KAY Date: Fri, 8 Jul 2022 21:31:24 +0100 Subject: [PATCH 1/2] Add Mesh::remove_attribute(). --- crates/bevy_render/src/mesh/mesh/mod.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/crates/bevy_render/src/mesh/mesh/mod.rs b/crates/bevy_render/src/mesh/mesh/mod.rs index b4fecc066ddb6..467c655832e18 100644 --- a/crates/bevy_render/src/mesh/mesh/mod.rs +++ b/crates/bevy_render/src/mesh/mesh/mod.rs @@ -116,6 +116,16 @@ impl Mesh { ); } + /// Removes the data for a vertex attribute + pub fn remove_attribute( + &mut self, + attribute: MeshVertexAttribute, + ) -> Option { + self.attributes + .remove(&attribute.id) + .map(|data| data.values) + } + #[inline] pub fn contains_attribute(&self, id: impl Into) -> bool { self.attributes.contains_key(&id.into()) From 6886a57586a902922488e9c6a49322b44ce86ea7 Mon Sep 17 00:00:00 2001 From: Robin KAY Date: Fri, 8 Jul 2022 22:03:49 +0100 Subject: [PATCH 2/2] Change remove_attribute to use Into. --- crates/bevy_render/src/mesh/mesh/mod.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/bevy_render/src/mesh/mesh/mod.rs b/crates/bevy_render/src/mesh/mesh/mod.rs index 467c655832e18..fde82287d1f56 100644 --- a/crates/bevy_render/src/mesh/mesh/mod.rs +++ b/crates/bevy_render/src/mesh/mesh/mod.rs @@ -119,10 +119,10 @@ impl Mesh { /// Removes the data for a vertex attribute pub fn remove_attribute( &mut self, - attribute: MeshVertexAttribute, + attribute: impl Into, ) -> Option { self.attributes - .remove(&attribute.id) + .remove(&attribute.into()) .map(|data| data.values) }