Add support for removing attributes from meshes. (#5254)
# 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 #5222. ## Solution Implement Mesh::remove_attribute().
This commit is contained in:
parent
3c51ad2764
commit
e6faf993b0
@ -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]
|
#[inline]
|
||||||
pub fn contains_attribute(&self, id: impl Into<MeshVertexAttributeId>) -> bool {
|
pub fn contains_attribute(&self, id: impl Into<MeshVertexAttributeId>) -> bool {
|
||||||
self.attributes.contains_key(&id.into())
|
self.attributes.contains_key(&id.into())
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user