Add Index

This commit is contained in:
Hanno Braun 2024-11-05 17:54:36 +01:00
parent 596a02d82a
commit 34aa368907

View File

@ -1,7 +1,7 @@
#[derive(Default)] #[derive(Default)]
pub struct Mesh { pub struct Mesh {
vertices: Vec<Vertex>, vertices: Vec<Vertex>,
triangles: Vec<[u32; 3]>, triangles: Vec<[Index; 3]>,
} }
impl Mesh { impl Mesh {
@ -9,7 +9,7 @@ impl Mesh {
&self.vertices &self.vertices
} }
pub fn triangles(&self) -> &[[u32; 3]] { pub fn triangles(&self) -> &[[Index; 3]] {
&self.triangles &self.triangles
} }
@ -17,9 +17,10 @@ impl Mesh {
self.vertices.push(vertex); self.vertices.push(vertex);
} }
pub fn push_triangle(&mut self, triangle: [u32; 3]) { pub fn push_triangle(&mut self, triangle: [Index; 3]) {
self.triangles.push(triangle); self.triangles.push(triangle);
} }
} }
pub type Vertex = [f32; 3]; pub type Vertex = [f32; 3];
pub type Index = u32;