Prepare to consolidate operation addition APIs

This commit is contained in:
Hanno Braun 2024-12-16 20:14:54 +01:00
parent 3dc94c24ad
commit c5ceab8ef9
2 changed files with 9 additions and 0 deletions

View File

@ -13,6 +13,13 @@ pub struct Shape {
}
impl Shape {
pub fn extend(&mut self) -> OperationResult<()> {
OperationResult {
operations: self,
results: (),
}
}
pub fn vertex(
&mut self,
vertex: impl Into<Vertex>,

View File

@ -2,6 +2,7 @@ use crate::geometry::Shape;
pub fn model(shape: &mut Shape) {
let (a, b, c, d, e, f, g, h) = shape
.extend()
.vertex([-0.5, -0.5, -0.5])
.vertex([0.5, -0.5, -0.5])
.vertex([-0.5, 0.5, -0.5])
@ -13,6 +14,7 @@ pub fn model(shape: &mut Shape) {
.results();
shape
.extend()
.triangle([&a, &e, &g]) // left
.triangle([&a, &g, &c])
.triangle([&b, &d, &h]) // right