From e6812d2df6bd8a0a71375096abe46f8039d8c570 Mon Sep 17 00:00:00 2001 From: Mel Date: Tue, 11 Jul 2023 04:13:18 +0200 Subject: Create MeshBuilder utility for comfy mesh building --- src/World/Generation/ChunkMeshing.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src/World/Generation/ChunkMeshing.cpp') diff --git a/src/World/Generation/ChunkMeshing.cpp b/src/World/Generation/ChunkMeshing.cpp index 7158734..2e9f191 100644 --- a/src/World/Generation/ChunkMeshing.cpp +++ b/src/World/Generation/ChunkMeshing.cpp @@ -13,10 +13,10 @@ ChunkMesh mesh_chunk(Chunk& chunk, const ChunkNeighbors& neighbors) { namespace Detail { -std::array, 4> DefaultMeshDecisions::face_positions(BlockSide side, U32 x, U32 y, U32 z) { +Face DefaultMeshDecisions::face_positions(BlockSide side, U32 x, U32 y, U32 z) { // Winding order: (0, 1, 2) (2, 3, 0) // Note: OpenGL Coordinate system has a flipped z axis. - std::array, 4> face{}; + Face face{}; switch (side) { case BlockSide::Front: face = {{{0, 1, 1}, {0, 0, 1}, {1, 0, 1}, {1, 1, 1}}}; @@ -44,14 +44,14 @@ std::array, 4> DefaultMeshDecisions::face_positions(BlockSide sid return face; } -std::array, 4> DefaultMeshDecisions::face_tex_coords(BlockType type, BlockSide side) { +Face DefaultMeshDecisions::face_tex_coords(BlockType type, BlockSide side) { U8 atlas_width = 4; U8 atlas_height = 4; Real width_step = 1.0f / atlas_width; Real height_step = 1.0f / atlas_height; - auto block_coords = [=](U8 x, U8 y) -> std::array, 4> { + auto block_coords = [=](U8 x, U8 y) -> Face { auto t = y * height_step; auto l = x * width_step; auto b = t + height_step; @@ -119,12 +119,12 @@ std::array, 4> DefaultMeshDecisions::face_tex_coords(BlockType ty } } -std::array, 4> DefaultMeshDecisions::face_normals(BlockSide side) { +Face DefaultMeshDecisions::face_normals(BlockSide side) { Vector<3, F32> normal{get_face_normal(side)}; return {normal, normal, normal, normal}; } -std::array DefaultMeshDecisions::face_ao_values(Chunk& chunk, const ChunkNeighbors& neighbors, U32 x, U32 y, U32 z, BlockSide side) { +Face DefaultMeshDecisions::face_ao_values(Chunk& chunk, const ChunkNeighbors& neighbors, U32 x, U32 y, U32 z, BlockSide side) { std::array, 8> offsets{}; // Given a block position, these offsets can be added to it to get the 8 blocks necessary to calculate AO. // There are 4 corners and 4 sides, corners are visually distinguished by the lack of spaces and @@ -151,7 +151,7 @@ std::array DefaultMeshDecisions::face_ao_values(Chunk& chunk, const Chun break; } - std::array vertex_ao{}; + Face vertex_ao{}; UInt offset_index = 0; for (UInt vertex = 0; vertex < 4; vertex++) { -- cgit 1.4.1