Skip to content

Commit

Permalink
Simplify
Browse files Browse the repository at this point in the history
  • Loading branch information
hannobraun committed Nov 5, 2024
1 parent 9039c81 commit 8e134a4
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
1 change: 1 addition & 0 deletions experiments/2024-10-30/src/export.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ pub fn export(mesh: &Mesh) -> anyhow::Result<()> {

let triangles = mesh
.triangles()
.into_iter()
.map(|triangle| {
triangle.map(|index| {
index.try_into().expect(
Expand Down
10 changes: 5 additions & 5 deletions experiments/2024-10-30/src/geometry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ impl Operation for Mesh {
self.vertices.clone()
}

fn triangles(&self) -> impl Iterator<Item = Triangle> {
self.triangles.iter().copied()
fn triangles(&self) -> Vec<Triangle> {
self.triangles.clone()
}
}

Expand All @@ -36,8 +36,8 @@ impl Operation for Vertex {
vec![*self]
}

fn triangles(&self) -> impl Iterator<Item = Triangle> {
[].into_iter()
fn triangles(&self) -> Vec<Triangle> {
vec![]
}
}

Expand All @@ -46,5 +46,5 @@ pub type Triangle = [Index; 3];

pub trait Operation {
fn vertices(&self) -> Vec<Vertex>;
fn triangles(&self) -> impl Iterator<Item = Triangle>;
fn triangles(&self) -> Vec<Triangle>;
}
2 changes: 1 addition & 1 deletion experiments/2024-10-30/src/render.rs
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ impl Renderer {
render_pass.set_pipeline(&self.pipeline);
render_pass.set_bind_group(0, &self.bind_group, &[]);
render_pass.draw_indexed(
0..mesh.triangles().count() as u32 * 3,
0..mesh.triangles().len() as u32 * 3,
0,
0..1,
);
Expand Down

0 comments on commit 8e134a4

Please sign in to comment.