summaryrefslogtreecommitdiff
path: root/engine
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2026-06-05 21:47:17 +0200
committerHampusM <hampus@hampusmat.com>2026-06-05 21:47:17 +0200
commit87015a4abcd45d6c69b289467c9e37426e1f0930 (patch)
treee175f8c7e59178050a248916745a24407860d9e1 /engine
parente69aa8a01bdb6f547fa78a146a6398a093576445 (diff)
feat(engine): add fns for changing mesh data
Diffstat (limited to 'engine')
-rw-r--r--engine/src/mesh.rs14
-rw-r--r--engine/src/mesh/vertex_buffer.rs5
2 files changed, 19 insertions, 0 deletions
diff --git a/engine/src/mesh.rs b/engine/src/mesh.rs
index a223f60..9aa1f80 100644
--- a/engine/src/mesh.rs
+++ b/engine/src/mesh.rs
@@ -26,6 +26,11 @@ impl Mesh
&self.vertex_buf
}
+ pub fn vertex_buf_mut(&mut self) -> &mut vertex_buffer::VertexBuffer
+ {
+ &mut self.vertex_buf
+ }
+
#[must_use]
pub fn indices(&self) -> Option<&[u32]>
{
@@ -38,6 +43,15 @@ impl Mesh
self.indices.as_deref_mut()
}
+ pub fn set_indices(&mut self, indices: impl IntoIterator<Item = u32>)
+ {
+ let curr_indices = self.indices.get_or_insert_with(|| Vec::new());
+
+ curr_indices.clear();
+
+ curr_indices.extend(indices.into_iter());
+ }
+
/// Finds the vertex positions that are furthest in every 3D direction. Keep in mind
/// that this can be quite time-expensive if the mesh has many vertices.
pub fn find_furthest_vertex_positions(&self) -> DirectionPositions
diff --git a/engine/src/mesh/vertex_buffer.rs b/engine/src/mesh/vertex_buffer.rs
index 3e3c467..9d77270 100644
--- a/engine/src/mesh/vertex_buffer.rs
+++ b/engine/src/mesh/vertex_buffer.rs
@@ -163,6 +163,11 @@ impl VertexBuffer
&self.buf
}
+ pub fn clear(&mut self)
+ {
+ self.buf.clear();
+ }
+
pub fn iter<VertexAttr: VertexAttrValue>(
&self,
vertex_attr_name: &str,