summaryrefslogtreecommitdiff
path: root/src/cube.rs
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2024-04-14 12:36:31 +0200
committerHampusM <hampus@hampusmat.com>2024-04-14 12:36:31 +0200
commitc2419bfee851810a27672b40c77c829e4b4c2829 (patch)
treeafd63e7a2ce546a4f3302a49c25638dc4383b288 /src/cube.rs
parent101b455e51f9b702da5517cabe2c3b1086fcb2e7 (diff)
chore: use new engine architecture
Diffstat (limited to 'src/cube.rs')
-rw-r--r--src/cube.rs19
1 files changed, 13 insertions, 6 deletions
diff --git a/src/cube.rs b/src/cube.rs
index d81eb76..9877b98 100644
--- a/src/cube.rs
+++ b/src/cube.rs
@@ -1,5 +1,5 @@
use engine::math::calc_triangle_surface_normal;
-use engine::object::Builder as ObjectBuilder;
+use engine::mesh::Mesh;
use engine::vector::Vec3;
use engine::vertex::{Builder as VertexBuilder, Vertex};
@@ -21,9 +21,9 @@ pub enum Corner
BottomLeft,
}
-pub fn create_cube(
+pub fn create_cube_mesh(
vertex_builder_cb: impl Fn(VertexBuilder, Side, Corner) -> VertexBuilder,
-) -> ObjectBuilder
+) -> Mesh
{
let mut vertices: [Option<Vertex>; VertexIndex::VARIANT_CNT] =
[(); VertexIndex::VARIANT_CNT].map(|()| None);
@@ -456,9 +456,16 @@ pub fn create_cube(
let indices = [front, back, right, left, top, bottom];
- ObjectBuilder::new()
- .vertices(vertices.map(Option::unwrap))
- .indices(indices.into_iter().flatten().map(|index| index as u32))
+ Mesh::new(
+ vertices.map(Option::unwrap).to_vec(),
+ Some(
+ indices
+ .into_iter()
+ .flatten()
+ .map(|index| index as u32)
+ .collect(),
+ ),
+ )
}
macro_rules! one {