summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2023-12-08 03:49:00 +0100
committerStanislaw Halik <sthalik@misaki.pl>2023-12-09 05:12:02 +0100
commit217292f6da87bf4fba3d6590b3a337ba152c2ff7 (patch)
tree1deec13f00008fca8a169b1e7b092af3fd5e2631
parent108e9e17dbee028eeb8530f99b1167b7c30c01ae (diff)
w
-rw-r--r--src/chunk-walls.cpp61
-rw-r--r--src/quads.cpp2
-rw-r--r--src/wall-defs.hpp2
3 files changed, 61 insertions, 4 deletions
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<Vector3, 4> chunk::make_wall_vertex_data<Group_::overlay, false>(Vector2 center, float depth)
+{
+ return wall_quad_N(Vector3(center, tile_height), TILE_SIZE);
+}
+
+// overlay west
+template<> std::array<Vector3, 4> chunk::make_wall_vertex_data<Group_::overlay, true>(Vector2 center, float depth)
+{
+ return wall_quad_W(Vector3(center, tile_height), TILE_SIZE);
+}
+
+// corner left
+template<> std::array<Vector3, 4> chunk::make_wall_vertex_data<Group_::corner_L, false>(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<Vector3, 4> chunk::make_wall_vertex_data<Group_::corner_R, true>(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<Vector3, 4> chunk::make_wall_vertex_data<Group_::wall, false>(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<Vector3, 4> chunk::make_wall_vertex_data<Group_::wall, true>(Vector2 center, float depth)
{
+ return wall_quad_W(Vector3(center, tile_height), TILE_SIZE);
+}
+
+// side north
+template<> std::array<Vector3, 4> chunk::make_wall_vertex_data<Group_::side, false>(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<Vector3, 4> chunk::make_wall_vertex_data<Group_::side, true>(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<UnsignedShort, 6> 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 };