Add Mesh::vertices

This commit is contained in:
Hanno Braun 2024-10-31 21:26:22 +01:00
parent 924e9a03d4
commit 7146ce45a6
3 changed files with 6 additions and 2 deletions

View File

@ -4,7 +4,7 @@ use crate::mesh::Mesh;
pub fn export(mesh: &Mesh) -> anyhow::Result<()> {
let vertices = mesh
.vertices
.vertices()
.iter()
.copied()
.map(|vertex| vertex.map(Into::into))

View File

@ -5,6 +5,10 @@ pub struct Mesh {
}
impl Mesh {
pub fn vertices(&self) -> &[[f32; 3]] {
&self.vertices
}
pub fn push_vertex(&mut self, vertex: [f32; 3]) {
self.vertices.push(vertex);
}

View File

@ -169,7 +169,7 @@ impl Renderer {
self.device
.create_buffer_init(&wgpu::util::BufferInitDescriptor {
label: None,
contents: bytemuck::cast_slice(&mesh.vertices),
contents: bytemuck::cast_slice(&mesh.vertices()),
usage: wgpu::BufferUsages::VERTEX,
});