Mutable mesh accessors: indices_mut and attribute_mut (#1164)

mutable mesh accessors: indices_mut and attribute_mut
This commit is contained in:
MsK` 2020-12-30 22:17:44 +01:00 committed by GitHub
parent 871b47f1c3
commit 2754a9dde8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -219,6 +219,13 @@ impl Mesh {
self.attributes.get(&name.into()) self.attributes.get(&name.into())
} }
pub fn attribute_mut(
&mut self,
name: impl Into<Cow<'static, str>>,
) -> Option<&mut VertexAttributeValues> {
self.attributes.get_mut(&name.into())
}
pub fn set_indices(&mut self, indices: Option<Indices>) { pub fn set_indices(&mut self, indices: Option<Indices>) {
self.indices = indices; self.indices = indices;
} }
@ -227,6 +234,10 @@ impl Mesh {
self.indices.as_ref() self.indices.as_ref()
} }
pub fn indices_mut(&mut self) -> Option<&mut Indices> {
self.indices.as_mut()
}
pub fn get_index_buffer_bytes(&self) -> Option<Vec<u8>> { pub fn get_index_buffer_bytes(&self) -> Option<Vec<u8>> {
self.indices.as_ref().map(|indices| match &indices { self.indices.as_ref().map(|indices| match &indices {
Indices::U16(indices) => indices.as_slice().as_bytes().to_vec(), Indices::U16(indices) => indices.as_slice().as_bytes().to_vec(),