summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2024-10-06 12:08:27 +0200
committerStanislaw Halik <sthalik@misaki.pl>2024-10-06 12:08:27 +0200
commit1cf3b8d1adbe8b88d4c8b45bc976c6f9221fdce6 (patch)
tree2b1af2f202e740f212e40b9e78808a154e5acb31
parent10ccb5f431c25dc6945711f3547cc847480e7f04 (diff)
Revert "fix build for now (wip)"
This reverts commit 10ccb5f431c25dc6945711f3547cc847480e7f04.
-rw-r--r--src/chunk-walls.cpp63
1 files changed, 11 insertions, 52 deletions
diff --git a/src/chunk-walls.cpp b/src/chunk-walls.cpp
index bf862396..59e0e915 100644
--- a/src/chunk-walls.cpp
+++ b/src/chunk-walls.cpp
@@ -139,16 +139,18 @@ void cut_holes_in_wall(chunk& c, local_coords tile, Vector2i min, Vector2i max,
//constexpr auto eps = Vector2{.125f};
if (c.find_hole_in_bbox(hole, Vector2(min) /*- eps*/, Vector2(max) /*+ eps*/))
+ {
fun(min, max);
+ }
else
{
fm_assert(Vector2(Vector2i(hole.min)) == hole.min);
fm_assert(Vector2(Vector2i(hole.max)) == hole.max);
auto res = CutResult<Int>::cut(min, max, Vector2i(hole.min), Vector2i(hole.max));
if (!res.found())
+ {
fun(min, max);
- else if (res.size == 1)
- fun(Vector2(res.array[0].min), Vector2(res.array[0].max));
+ }
else
{
for (auto i = 0u; i < res.size; i++)
@@ -163,57 +165,14 @@ void cut_holes_in_wall(chunk& c, local_coords tile, Vector2i min, Vector2i max,
struct quad_tuple
{
Vector2ui tex_pos, tex_size;
- Vector2i pos_min, pos_max;
+ Vector2i min, max;
};
+template<bool IsWest>
quad_tuple get_wall_quad_stuff(const CutResult<Int>::rect& geom, const CutResult<Int>::rect& orig,
- const Vector2ui orig_tex_pos, const Vector2ui orig_tex_size)
-{
- fm_debug_assert(geom.max > geom.min);
- fm_debug_assert(orig.max > orig.max);
- fm_assert(geom.min >= orig.min);
- fm_assert(geom.max <= orig.max);
-
- auto off_min = Vector2ui(geom.min - orig.min), off_max = Vector2ui(orig.max - geom.max);
- fm_assert(orig_tex_size > off_min + off_max);
-
- return {
- .tex_pos = orig_tex_pos + off_min,
- .tex_size = orig_tex_size - off_min - off_max,
- .pos_min = geom.min,
- .pos_max = geom.max,
- };
-}
-
-Quads::texcoords texcoords_from_tuple(const wall_atlas& atlas, const quad_tuple& tuple, uint32_t top, uint32_t bottom)
+ Vector2ui orig_tex_pos, Vector2ui orig_tex_size)
{
- fm_assert(tuple.tex_size.y() > top + bottom);
-
- auto pos = tuple.tex_pos + Vector2ui{0, top};
- auto size = tuple.tex_size - Vector2ui{0, top + bottom};
-
- return Quads::texcoords_at(pos, size, atlas.image_size());
-}
-template<bool IsWest>
-Quads::quad get_quad_from_tuple(const quad_tuple& tuple, uint32_t top, uint32_t bottom)
-{
- constexpr float X = 0, Y = 0, Z = 0;
- fm_debug_assert(top > bottom && top <= tile_size_z);
- if constexpr(!IsWest)
- return {{
- { X, -Y, 0 },
- { X, -Y, Z },
- {-X, -Y, 0 },
- {-X, -Y, Z },
- }};
- else
- return {{
- {-X, -Y, 0 },
- {-X, -Y, Z },
- {-X, Y, 0 },
- {-X, Y, Z },
- }};
}
ArrayView<const Quads::indexes> make_indexes(uint32_t count)
@@ -335,7 +294,7 @@ void do_wall_part(const Group& group, wall_atlas& A, chunk& c, chunk::wall_stuff
fm_assert(frame.size.y() >= Depth);
auto start = frame.offset + Vector2ui{0, frame.size.y()} - Vector2ui{0, Depth};
const auto texcoords = Quads::texcoords_at(start, Vector2ui{Depth, Depth}, A.image_size());
- constexpr auto depth_offset = depth_offset_for_group<Group_::top, IsWest>();
+ const auto depth_offset = depth_offset_for_group<Group_::top, IsWest>();
const auto depth = tile_shader::depth_value(pos, depth_offset);
for (auto& v : quad)
v += center;
@@ -349,7 +308,7 @@ void do_wall_part(const Group& group, wall_atlas& A, chunk& c, chunk::wall_stuff
if (dir.corner.is_defined)
{
const auto frames = A.frames(dir.corner);
- constexpr auto depth_offset = depth_offset_for_group<Group_::corner, IsWest>();
+ const auto depth_offset = depth_offset_for_group<Group_::corner, IsWest>();
const auto pos_x = !IsWest ? (float)pos.x : (float)pos.x - 1;
const auto depth = tile_shader::depth_value(pos_x, pos.y, depth_offset);
const auto& frame = variant_from_frame(frames, coord, variant_2, IsWest);
@@ -364,7 +323,7 @@ void do_wall_part(const Group& group, wall_atlas& A, chunk& c, chunk::wall_stuff
else if (dir.wall.is_defined) [[likely]]
{
const auto frames = A.frames(dir.wall);
- constexpr auto depth_offset = depth_offset_for_group<Group_::corner, IsWest>();
+ const auto depth_offset = depth_offset_for_group<Group_::corner, IsWest>();
const auto depth = tile_shader::depth_value(!IsWest ? (float)pos.x : (float)pos.x - 1, (float)pos.y, depth_offset);
const auto frame = variant_from_frame(frames, coord, variant_2, IsWest);
fm_assert(frame.size.x() > Depth);
@@ -384,7 +343,7 @@ void do_wall_part(const Group& group, wall_atlas& A, chunk& c, chunk::wall_stuff
const auto frames = A.frames(group);
const auto frame = variant_from_frame(frames, coord, variant_2, IsWest);
const auto texcoords = Quads::texcoords_at(frame.offset, frame.size, A.image_size());
- constexpr auto depth_offset = depth_offset_for_group<G, IsWest>();
+ const auto depth_offset = depth_offset_for_group<G, IsWest>();
const auto depth = tile_shader::depth_value(pos, depth_offset);
auto quad = get_quad<G, IsWest>((float)Depth);
for (auto& v : quad)