summaryrefslogtreecommitdiffhomepage
path: root/src/chunk-walls.cpp
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 /src/chunk-walls.cpp
parent108e9e17dbee028eeb8530f99b1167b7c30c01ae (diff)
w
Diffstat (limited to 'src/chunk-walls.cpp')
-rw-r--r--src/chunk-walls.cpp61
1 files changed, 59 insertions, 2 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;
}
// -----------------------