Skip to content

Commit 51534c8

Browse files
committed
Turn Vertex into a tuple struct
1 parent 705e1be commit 51534c8

File tree

1 file changed

+4
-11
lines changed

1 file changed

+4
-11
lines changed

src/plugin.rs

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,10 @@ type IndexType = u32;
4444
/// Lyon's [`VertexBuffers`] generic data type defined for [`Vertex`].
4545
type VertexBuffers = tess::VertexBuffers<Vertex, IndexType>;
4646

47-
// TODO: Turn into a tuple struct.
4847
/// A vertex with all the necessary attributes to be inserted into a Bevy
4948
/// [`Mesh`](bevy::render::mesh::Mesh).
5049
#[derive(Debug, Clone, Copy, PartialEq)]
51-
struct Vertex {
52-
position: [f32; 3],
53-
}
50+
struct Vertex([f32; 3]);
5451

5552
/// Zero-sized type used to implement various vertex construction traits from
5653
/// Lyon.
@@ -59,18 +56,14 @@ struct VertexConstructor;
5956
/// Enables the construction of a [`Vertex`] when using a `FillTessellator`.
6057
impl FillVertexConstructor<Vertex> for VertexConstructor {
6158
fn new_vertex(&mut self, vertex: FillVertex) -> Vertex {
62-
Vertex {
63-
position: [vertex.position().x, vertex.position().y, 0.0],
64-
}
59+
Vertex([vertex.position().x, vertex.position().y, 0.0])
6560
}
6661
}
6762

6863
/// Enables the construction of a [`Vertex`] when using a `StrokeTessellator`.
6964
impl StrokeVertexConstructor<Vertex> for VertexConstructor {
7065
fn new_vertex(&mut self, vertex: StrokeVertex) -> Vertex {
71-
Vertex {
72-
position: [vertex.position().x, vertex.position().y, 0.0],
73-
}
66+
Vertex([vertex.position().x, vertex.position().y, 0.0])
7467
}
7568
}
7669

@@ -140,7 +133,7 @@ fn build_mesh(buffers: &VertexBuffers) -> Mesh {
140133
buffers
141134
.vertices
142135
.iter()
143-
.map(|v| v.position)
136+
.map(|v| v.0)
144137
.collect::<Vec<[f32; 3]>>(),
145138
);
146139

0 commit comments

Comments
 (0)