From c9d3e1fda0b238cbb62284e78267f18d5b4c7dcb Mon Sep 17 00:00:00 2001 From: HampusM Date: Thu, 13 Aug 2026 15:52:12 +0200 Subject: refactor(engine): replace mesh::cube mod with new Mesh::cube fn --- engine/src/mesh/vertex_buffer.rs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'engine/src/mesh/vertex_buffer.rs') diff --git a/engine/src/mesh/vertex_buffer.rs b/engine/src/mesh/vertex_buffer.rs index 4df3ffc..90e5752 100644 --- a/engine/src/mesh/vertex_buffer.rs +++ b/engine/src/mesh/vertex_buffer.rs @@ -73,6 +73,26 @@ pub struct VertexBuffer impl VertexBuffer { + pub unsafe fn from_raw( + vertex_attr_props: &[VertexAttrProperties], + buffer: Vec, + ) -> Self + { + let last_vertex_attr_props = vertex_attr_props + .iter() + .max_by_key(|props| props.byte_offset) + .expect("No vertex attribute properties are given"); + + let vertex_size = + last_vertex_attr_props.byte_offset + last_vertex_attr_props.layout.size(); + + Self { + buf: buffer, + vertex_size, + vertex_attr_props: vertex_attr_props.to_vec(), + } + } + pub fn with_capacity(vertex_attrs: &[VertexAttrInfo], capacity: usize) -> Self { let mut vertex_attr_props = vertex_attrs -- cgit v1.2.3-18-g5258