summary refs log tree commit diff
path: root/src/World/Generation/ChunkMeshing.cpp
diff options
context:
space:
mode:
authorMel <einebeere@gmail.com>2023-07-11 04:13:18 +0200
committerMel <einebeere@gmail.com>2023-07-11 04:13:18 +0200
commite6812d2df6bd8a0a71375096abe46f8039d8c570 (patch)
tree8fd1bb578f5a6e2edfc1b1dfffea32f9285c17c9 /src/World/Generation/ChunkMeshing.cpp
parent2c3ac8db3f539459166c801e61c5efdacf9150c3 (diff)
downloadmeowcraft-e6812d2df6bd8a0a71375096abe46f8039d8c570.tar.zst
meowcraft-e6812d2df6bd8a0a71375096abe46f8039d8c570.zip
Create MeshBuilder utility for comfy mesh building
Diffstat (limited to 'src/World/Generation/ChunkMeshing.cpp')
-rw-r--r--src/World/Generation/ChunkMeshing.cpp14
1 files changed, 7 insertions, 7 deletions
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<Vector<3, F32>, 4> DefaultMeshDecisions::face_positions(BlockSide side, U32 x, U32 y, U32 z) {
+Face<Vertex> 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<Vector<3, F32>, 4> face{};
+    Face<Vertex> 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<Vector<3, F32>, 4> DefaultMeshDecisions::face_positions(BlockSide sid
     return face;
 }
 
-std::array<Vector<2, F32>, 4> DefaultMeshDecisions::face_tex_coords(BlockType type, BlockSide side) {
+Face<TexCoord> 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<Vector<2, F32>, 4> {
+    auto block_coords = [=](U8 x, U8 y) -> Face<TexCoord> {
         auto t = y * height_step;
         auto l = x * width_step;
         auto b = t + height_step;
@@ -119,12 +119,12 @@ std::array<Vector<2, F32>, 4> DefaultMeshDecisions::face_tex_coords(BlockType ty
     }
 }
 
-std::array<Vector<3, F32>, 4> DefaultMeshDecisions::face_normals(BlockSide side) {
+Face<Normal> DefaultMeshDecisions::face_normals(BlockSide side) {
     Vector<3, F32> normal{get_face_normal(side)};
     return {normal, normal, normal, normal};
 }
 
-std::array<F32, 4> DefaultMeshDecisions::face_ao_values(Chunk& chunk, const ChunkNeighbors& neighbors, U32 x, U32 y, U32 z, BlockSide side) {
+Face<AO> DefaultMeshDecisions::face_ao_values(Chunk& chunk, const ChunkNeighbors& neighbors, U32 x, U32 y, U32 z, BlockSide side) {
     std::array<Vector<3, I32>, 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<F32, 4> DefaultMeshDecisions::face_ao_values(Chunk& chunk, const Chun
         break;
     }
 
-    std::array<F32, 4> vertex_ao{};
+    Face<AO> vertex_ao{};
 
     UInt offset_index = 0;
     for (UInt vertex = 0; vertex < 4; vertex++) {