Prepare to refer to Vertex by Handle

This commit is contained in:
Hanno Braun 2024-12-13 20:42:38 +01:00
parent f66603375b
commit 4780753fb6
2 changed files with 17 additions and 15 deletions

View File

@ -44,9 +44,11 @@ pub struct Triangle {
pub vertices: [Vertex; 3],
}
impl From<[Vertex; 3]> for Triangle {
fn from(vertices: [Vertex; 3]) -> Self {
Self { vertices }
impl From<[&Vertex; 3]> for Triangle {
fn from(vertices: [&Vertex; 3]) -> Self {
Self {
vertices: vertices.map(|vertex| *vertex),
}
}
}

View File

@ -16,16 +16,16 @@ pub fn model(shape: &mut Shape) {
[a, b, c, d, e, f, g, h].map(|vertex| vertex.get());
shape
.triangle([a, e, g]) // left
.triangle([a, g, c])
.triangle([b, d, h]) // right
.triangle([b, h, f])
.triangle([a, b, f]) // front
.triangle([a, f, e])
.triangle([c, h, d]) // back
.triangle([c, g, h])
.triangle([a, c, b]) // bottom
.triangle([b, c, d])
.triangle([e, f, h]) // top
.triangle([e, h, g]);
.triangle([&a, &e, &g]) // left
.triangle([&a, &g, &c])
.triangle([&b, &d, &h]) // right
.triangle([&b, &h, &f])
.triangle([&a, &b, &f]) // front
.triangle([&a, &f, &e])
.triangle([&c, &h, &d]) // back
.triangle([&c, &g, &h])
.triangle([&a, &c, &b]) // bottom
.triangle([&b, &c, &d])
.triangle([&e, &f, &h]) // top
.triangle([&e, &h, &g]);
}