From 217292f6da87bf4fba3d6590b3a337ba152c2ff7 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 8 Dec 2023 03:49:00 +0100 Subject: w --- src/chunk-walls.cpp | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++-- src/quads.cpp | 2 +- src/wall-defs.hpp | 2 +- 3 files changed, 61 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/chunk-walls.cpp b/src/chunk-walls.cpp index 0e3c3d31..b71616f2 100644 --- a/src/chunk-walls.cpp +++ b/src/chunk-walls.cpp @@ -20,7 +20,6 @@ using Wall::Group_; namespace { constexpr Vector2 half_tile = TILE_SIZE2*.5f; -constexpr float hx = half_tile.x(), hy = half_tile.y(); constexpr float tile_height = TILE_SIZE.z(); } // namespace @@ -33,15 +32,73 @@ void chunk::ensure_alloc_walls() // ----------------------- +// overlay north +template<> std::array chunk::make_wall_vertex_data(Vector2 center, float depth) +{ + return wall_quad_N(Vector3(center, tile_height), TILE_SIZE); +} + +// overlay west +template<> std::array chunk::make_wall_vertex_data(Vector2 center, float depth) +{ + return wall_quad_W(Vector3(center, tile_height), TILE_SIZE); +} + +// corner left +template<> std::array chunk::make_wall_vertex_data(Vector2 center, float depth) +{ + constexpr float x = half_tile.x(), y = half_tile.y(), z = tile_height; + constexpr float x_offset = (float)(int)x; + return {{ + { x + center.x(), -y + center.y(), z + 0 }, + { x + center.x(), -y + center.y(), 0 }, + { x_offset + -x + center.x(), -y + center.y(), z + 0 }, + { x_offset + -x + center.x(), -y + center.y(), 0 }, + }}; +} + +// corner right +template<> std::array chunk::make_wall_vertex_data(Vector2 center, float depth) +{ + constexpr float x = half_tile.x(), y = half_tile.y(), z = tile_height; + return {{ + {-x + center.x(), y + center.y(), z + 0 }, + {-x + center.x(), y + center.y(), 0 }, + {-x + center.x(), -y + center.y(), z + 0 }, + {-x + center.x(), -y + center.y(), 0 }, + }}; +} + // wall north template<> std::array chunk::make_wall_vertex_data(Vector2 center, float depth) { - auto quad = wall_quad_N(Vector3(center, tile_height), TILE_SIZE); + return wall_quad_N(Vector3(center, tile_height), TILE_SIZE); } // wall west template<> std::array chunk::make_wall_vertex_data(Vector2 center, float depth) { + return wall_quad_W(Vector3(center, tile_height), TILE_SIZE); +} + +// side north +template<> std::array chunk::make_wall_vertex_data(Vector2 center, float depth) +{ + constexpr float x = half_tile.x(), y = half_tile.y(), z = tile_height; + auto left = Vector2{x + center.x(), -y + center.y() }, + right = Vector2{left.x(), left.y() - depth }; + return {{ + { right.x(), right.y(), z + 0 }, + { right.x(), right.y(), 0 }, + { left.x(), left.y(), z + 0 }, + { left.x(), left.y(), 0 }, + }}; +} + +// side west +template<> std::array chunk::make_wall_vertex_data(Vector2 center, float depth) +{ + constexpr float x = half_tile.x(), y = half_tile.y(), z = tile_height; } // ----------------------- diff --git a/src/quads.cpp b/src/quads.cpp index 7a4cef58..801c0448 100644 --- a/src/quads.cpp +++ b/src/quads.cpp @@ -2,7 +2,7 @@ namespace floormat::Quads { -indexes quad_indexes(size_t N) +std::array quad_indexes(size_t N) { using u16 = UnsignedShort; return { /* 3--1 1 */ diff --git a/src/wall-defs.hpp b/src/wall-defs.hpp index a9327d53..05af548c 100644 --- a/src/wall-defs.hpp +++ b/src/wall-defs.hpp @@ -3,7 +3,7 @@ namespace floormat::Wall { -enum class Group_ : uint8_t { wall, overlay, side, top, corner_L, corner_R, COUNT }; +enum class Group_ : uint8_t { overlay, corner_L, corner_R, wall, side, top, COUNT }; enum class Direction_ : uint8_t { N, E, S, W, COUNT }; -- cgit v1.2.3