diff --git a/experiments/2024-12-09/src/export.rs b/experiments/2024-12-09/src/export.rs index 40c74236d..4b483c0cd 100644 --- a/experiments/2024-12-09/src/export.rs +++ b/experiments/2024-12-09/src/export.rs @@ -13,6 +13,7 @@ pub fn export(shape: &Shape) -> anyhow::Result<()> { for triangle in shape_triangles { let triangle = triangle.vertices.map(|vertex| { + let vertex = vertex.get(); *indices_by_vertex.entry(vertex).or_insert_with(|| { let index = vertices.len(); vertices.push(vertex); diff --git a/experiments/2024-12-09/src/geometry/primitives.rs b/experiments/2024-12-09/src/geometry/primitives.rs index 6fc4dae66..a41f12a02 100644 --- a/experiments/2024-12-09/src/geometry/primitives.rs +++ b/experiments/2024-12-09/src/geometry/primitives.rs @@ -2,7 +2,10 @@ use std::fmt; use crate::math::Point; -use super::{operation::HandleAny, Operation}; +use super::{ + operation::{Handle, HandleAny}, + Operation, +}; #[derive(Clone, Copy, Debug, Eq, Ord, PartialEq, PartialOrd)] pub struct Vertex { @@ -41,13 +44,13 @@ impl Operation for Vertex { #[derive(Clone, Debug, Eq, Ord, PartialEq, PartialOrd)] pub struct Triangle { - pub vertices: [Vertex; 3], + pub vertices: [Handle; 3], } -impl From<[&Vertex; 3]> for Triangle { - fn from(vertices: [&Vertex; 3]) -> Self { +impl From<[&Handle; 3]> for Triangle { + fn from(vertices: [&Handle; 3]) -> Self { Self { - vertices: vertices.map(|vertex| *vertex), + vertices: vertices.map(|vertex| vertex.clone()), } } } @@ -66,9 +69,6 @@ impl Operation for Triangle { } fn children(&self) -> Vec { - self.vertices - .iter() - .map(|vertex| HandleAny::new(*vertex)) - .collect() + self.vertices.iter().map(|vertex| vertex.to_any()).collect() } } diff --git a/experiments/2024-12-09/src/model.rs b/experiments/2024-12-09/src/model.rs index aa0e06f0e..c3cc9b115 100644 --- a/experiments/2024-12-09/src/model.rs +++ b/experiments/2024-12-09/src/model.rs @@ -12,9 +12,6 @@ pub fn model(shape: &mut Shape) { .vertex([0.5, 0.5, 0.5]) .results(); - let [a, b, c, d, e, f, g, h] = - [a, b, c, d, e, f, g, h].map(|vertex| vertex.get()); - shape .triangle([&a, &e, &g]) // left .triangle([&a, &g, &c]) diff --git a/experiments/2024-12-09/src/render/geometry.rs b/experiments/2024-12-09/src/render/geometry.rs index 731dca734..7b837525c 100644 --- a/experiments/2024-12-09/src/render/geometry.rs +++ b/experiments/2024-12-09/src/render/geometry.rs @@ -59,9 +59,10 @@ impl Geometry { let mut vertices = Vec::new(); for triangle in &mesh_triangles { - let triangle = triangle.vertices.map(|vertex| { + let triangle = triangle.vertices.each_ref().map(|vertex| { Vec3::from( vertex + .as_ref() .point .coords .components