>> Build for Lathe {
- fn build(self) -> Mesh {
+impl>> Build> for Lathe {
+ fn build(self) -> Mesh> {
self.build_with(&mut |p, n, _| vertex(p.to(), n))
}
}
@@ -228,10 +228,10 @@ impl>> Build for Lathe {
self.build_with(&mut |p, _, tc| vertex(p.to(), tc))
}
}
-impl>> Build<(Normal3, TexCoord)>
+impl>> Build<(Normal3, TexCoord)>
for Lathe
{
- fn build(self) -> Mesh<(Normal3, TexCoord)> {
+ fn build(self) -> Mesh<(Normal3, TexCoord)> {
self.build_with(&mut |p, n, tc| vertex(p.to(), (n, tc)))
}
}
@@ -248,9 +248,9 @@ impl Sphere {
}
}
-impl Build for Sphere {
+impl Build> for Sphere {
/// Builds a spherical mesh with normals.
- fn build(self) -> Mesh {
+ fn build(self) -> Mesh> {
self.lathe().build()
}
}
@@ -271,9 +271,9 @@ impl Torus {
Lathe::new(pts, self.major_sectors, self.minor_sectors)
}
}
-impl Build for Torus {
+impl Build> for Torus {
/// Builds the toroidal mesh.
- fn build(self) -> Mesh {
+ fn build(self) -> Mesh> {
self.lathe().build()
}
}
@@ -284,9 +284,9 @@ impl Build for Torus {
}
}
-impl Build for Cylinder {
+impl Build> for Cylinder {
/// Builds the cylindrical mesh.
- fn build(self) -> Mesh {
+ fn build(self) -> Mesh> {
#[rustfmt::skip]
let Self { sectors, segments, capped, radius } = self;
Cone {
@@ -330,9 +330,9 @@ impl Cone {
Lathe::new(pts, self.sectors, self.segments).capped(self.capped)
}
}
-impl Build for Cone {
+impl Build> for Cone {
/// Builds the conical mesh.
- fn build(self) -> Mesh {
+ fn build(self) -> Mesh> {
self.lathe().build()
}
}
@@ -381,9 +381,9 @@ impl Capsule {
}
}
-impl Build for Capsule {
+impl Build> for Capsule {
/// Builds the capsule mesh.
- fn build(self) -> Mesh {
+ fn build(self) -> Mesh> {
self.lathe().build()
}
}
@@ -398,7 +398,7 @@ impl Build for Capsule {
mod tests {
use super::*;
- type Mesh = super::Mesh;
+ type Mesh = super::Mesh>;
#[test]
fn sphere_verts_faces() {
diff --git a/geom/src/solids/platonic.rs b/geom/src/solids/platonic.rs
index dda3279e..48648238 100644
--- a/geom/src/solids/platonic.rs
+++ b/geom/src/solids/platonic.rs
@@ -115,13 +115,13 @@ impl Tetrahedron {
];
/// Builds the tetrahedral mesh.
- pub fn build(self) -> Mesh {
+ pub fn build(self) -> Mesh> {
let mut b = Mesh::builder();
for (vs, i) in zip(Self::FACES, 0..) {
b.push_face(i * 3, i * 3 + 1, i * 3 + 2);
let n = -Self::NORMS[i]; // already unit length
for v in vs {
- b.push_vert(Self::COORDS[v].to_pt(), n);
+ b.push_vert(Self::COORDS[v].to_pt(), n.to());
}
}
b.build()
@@ -141,7 +141,7 @@ impl Box {
vec3(1.0, 1.0, 0.0), // 0b110
vec3(1.0, 1.0, 1.0), // 0b111
];
- const NORMS: [Normal3; 6] = [
+ const NORMS: [Normal3; 6] = [
vec3(-1.0, 0.0, 0.0),
vec3(1.0, 0.0, 0.0),
vec3(0.0, -1.0, 0.0),
@@ -190,7 +190,7 @@ impl Box {
/// Builds the cuboid mesh.
pub fn build_with(
self,
- mut f: impl FnMut(Point3, Normal3, TexCoord) -> Vertex3,
+ mut f: impl FnMut(Point3, Normal3, TexCoord) -> Vertex3,
) -> Mesh {
let mut b = Mesh::builder();
b.push_faces(Self::FACES);
@@ -209,8 +209,8 @@ impl Box {
}
}
-impl Build for Box {
- fn build(self) -> Mesh {
+impl Build> for Box {
+ fn build(self) -> Mesh> {
self.build_with(|p, n, _| vertex(p, n))
}
}
@@ -219,8 +219,8 @@ impl Build for Box {
self.build_with(|p, _, uv| vertex(p, uv))
}
}
-impl Build<(Normal3, TexCoord)> for Box {
- fn build(self) -> Mesh<(Normal3, TexCoord)> {
+impl Build<(Normal3, TexCoord)> for Box {
+ fn build(self) -> Mesh<(Normal3, TexCoord)> {
self.build_with(|p, n, uv| vertex(p, (n, uv)))
}
}
@@ -251,7 +251,7 @@ impl Octahedron {
pt3(0.0, 0.0, 1.0),
pt3(1.0, 0.0, 0.0),
];
- const NORMS: [Normal3; 8] = [
+ const NORMS: [Normal3<()>; 8] = [
vec3(-1.0, -1.0, -1.0),
vec3(-1.0, 1.0, -1.0),
vec3(-1.0, 1.0, 1.0),
@@ -284,16 +284,16 @@ impl Octahedron {
];
}
-impl Build for Octahedron {
+impl Build> for Octahedron {
/// Builds the octahedral mesh.
- fn build(self) -> Mesh {
+ fn build(self) -> Mesh> {
let mut b = Mesh::builder();
for (vs, i) in zip(&Self::FACES, 0..) {
b.push_face(i * 3, i * 3 + 1, i * 3 + 2);
for &vi in vs {
let pos = Self::COORDS[Self::VERTS[vi].0];
let n = Self::NORMS[i].normalize();
- b.push_vert(pos, n);
+ b.push_vert(pos, n.to());
}
}
b.build()
@@ -346,9 +346,9 @@ impl Dodecahedron {
const NORMALS: [Vec3; 12] = Icosahedron::COORDS;
}
-impl Build for Dodecahedron {
+impl Build> for Dodecahedron {
/// Builds the dodecahedral mesh.
- fn build(self) -> Mesh {
+ fn build(self) -> Mesh> {
let mut b = Mesh::builder();
for (face, i) in zip(&Self::FACES, 0..) {
@@ -360,7 +360,7 @@ impl Build for Dodecahedron {
b.push_face(i5, i5 + 3, i5 + 4);
for &j in face {
let pos = Self::COORDS[j].normalize().to_pt();
- b.push_vert(pos, n);
+ b.push_vert(pos, n.to());
}
}
b.build()
@@ -399,16 +399,16 @@ impl Icosahedron {
const NORMALS: [Vec3; 20] = Dodecahedron::COORDS;
}
-impl Build for Icosahedron {
+impl Build> for Icosahedron {
/// Builds the icosahedral mesh.
- fn build(self) -> Mesh {
+ fn build(self) -> Mesh> {
let mut b = Mesh::builder();
for (vs, i) in zip(&Self::FACES, 0..) {
let n = Self::NORMALS[i].normalize();
b.push_face(i * 3, i * 3 + 1, i * 3 + 2);
for &vi in vs {
let pos = Self::COORDS[vi].normalize().to_pt();
- b.push_vert(pos, n);
+ b.push_vert(pos, n.to());
}
}
b.build()