diff options
-rw-r--r-- | engine/src/mesh/cube.rs | 157 |
1 files changed, 82 insertions, 75 deletions
diff --git a/engine/src/mesh/cube.rs b/engine/src/mesh/cube.rs index ca946bb..7cdf885 100644 --- a/engine/src/mesh/cube.rs +++ b/engine/src/mesh/cube.rs @@ -62,84 +62,10 @@ pub fn create( create_top(&creation_spec, &mut vertices, &vertex_builder_cb); create_bottom(&creation_spec, &mut vertices, &vertex_builder_cb); - let front = [ - // 🮝 - VertexIndex::FrontTopRight, - VertexIndex::FrontBottomRight, - VertexIndex::FrontTopLeft, - // - // 🮟 - VertexIndex::FrontBottomRight, - VertexIndex::FrontBottomLeft, - VertexIndex::FrontTopLeft, - ]; - - let back = [ - // 🮝 - VertexIndex::BackTopRight, - VertexIndex::BackBottomRight, - VertexIndex::BackTopLeft, - // - // 🮟 - VertexIndex::BackBottomRight, - VertexIndex::BackBottomLeft, - VertexIndex::BackTopLeft, - ]; - - let right = [ - // 🮝 - VertexIndex::RightBackTop, - VertexIndex::RightBackBottom, - VertexIndex::RightFrontTop, - // - // 🮟 - VertexIndex::RightBackBottom, - VertexIndex::RightFrontBottom, - VertexIndex::RightFrontTop, - ]; - - let left = [ - // 🮝 - VertexIndex::LeftBackTop, - VertexIndex::LeftBackBottom, - VertexIndex::LeftFrontTop, - // - // 🮟 - VertexIndex::LeftBackBottom, - VertexIndex::LeftFrontBottom, - VertexIndex::LeftFrontTop, - ]; - - let top = [ - // 🮝 - VertexIndex::TopBackRight, - VertexIndex::TopBackLeft, - VertexIndex::TopFrontRight, - // - // 🮟 - VertexIndex::TopBackLeft, - VertexIndex::TopFrontLeft, - VertexIndex::TopFrontRight, - ]; - - let bottom = [ - // 🮝 - VertexIndex::BottomBackRight, - VertexIndex::BottomBackLeft, - VertexIndex::BottomFrontRight, - // - // 🮟 - VertexIndex::BottomBackLeft, - VertexIndex::BottomFrontLeft, - VertexIndex::BottomFrontRight, - ]; - - let indices = [front, back, right, left, top, bottom]; - Mesh::new( vertices.map(Option::unwrap).to_vec(), Some( - indices + VERTEX_INDICES .into_iter() .flatten() .map(|index| index as u32) @@ -693,3 +619,84 @@ fn create_bottom( .build(), ); } + +const VERTEX_INDICES_FRONT: [VertexIndex; 6] = [ + // 🮝 + VertexIndex::FrontTopRight, + VertexIndex::FrontBottomRight, + VertexIndex::FrontTopLeft, + // + // 🮟 + VertexIndex::FrontBottomRight, + VertexIndex::FrontBottomLeft, + VertexIndex::FrontTopLeft, +]; + +const VERTEX_INDICES_BACK: [VertexIndex; 6] = [ + // 🮝 + VertexIndex::BackTopRight, + VertexIndex::BackBottomRight, + VertexIndex::BackTopLeft, + // + // 🮟 + VertexIndex::BackBottomRight, + VertexIndex::BackBottomLeft, + VertexIndex::BackTopLeft, +]; + +const VERTEX_INDICES_RIGHT: [VertexIndex; 6] = [ + // 🮝 + VertexIndex::RightBackTop, + VertexIndex::RightBackBottom, + VertexIndex::RightFrontTop, + // + // 🮟 + VertexIndex::RightBackBottom, + VertexIndex::RightFrontBottom, + VertexIndex::RightFrontTop, +]; + +const VERTEX_INDICES_LEFT: [VertexIndex; 6] = [ + // 🮝 + VertexIndex::LeftBackTop, + VertexIndex::LeftBackBottom, + VertexIndex::LeftFrontTop, + // + // 🮟 + VertexIndex::LeftBackBottom, + VertexIndex::LeftFrontBottom, + VertexIndex::LeftFrontTop, +]; + +const VERTEX_INDICES_TOP: [VertexIndex; 6] = [ + // 🮝 + VertexIndex::TopBackRight, + VertexIndex::TopBackLeft, + VertexIndex::TopFrontRight, + // + // 🮟 + VertexIndex::TopBackLeft, + VertexIndex::TopFrontLeft, + VertexIndex::TopFrontRight, +]; + +const VERTEX_INDICES_BOTTOM: [VertexIndex; 6] = [ + // 🮝 + VertexIndex::BottomBackRight, + VertexIndex::BottomBackLeft, + VertexIndex::BottomFrontRight, + // + // 🮟 + VertexIndex::BottomBackLeft, + VertexIndex::BottomFrontLeft, + VertexIndex::BottomFrontRight, +]; + +const VERTEX_INDICES: [[VertexIndex; 6]; 6] = [ + VERTEX_INDICES_FRONT, + VERTEX_INDICES_BACK, + VERTEX_INDICES_RIGHT, + VERTEX_INDICES_LEFT, + VERTEX_INDICES_TOP, + VERTEX_INDICES_BOTTOM, +]; |