diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2023-05-18 16:26:01 +0200 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2023-05-18 16:26:01 +0200 |
commit | ec7be88fbb4062af20b77198007d815c321c2850 (patch) | |
tree | 85fbe24dc79d2e8072990939f1e7e8de97a84e84 /src | |
parent | 44c8e45d71e5320aedaa5b4b839e636a0d973f7f (diff) |
wip vobj
Diffstat (limited to 'src')
-rw-r--r-- | src/anim-atlas.cpp | 3 | ||||
-rw-r--r-- | src/chunk-collision.cpp | 46 | ||||
-rw-r--r-- | src/light.cpp | 9 |
3 files changed, 34 insertions, 24 deletions
diff --git a/src/anim-atlas.cpp b/src/anim-atlas.cpp index cdffea28..4dbb7104 100644 --- a/src/anim-atlas.cpp +++ b/src/anim-atlas.cpp @@ -176,6 +176,9 @@ void anim_atlas::make_bitmask_(const ImageView2D& tex, BitArray& array) BitArray anim_atlas::make_bitmask(const ImageView2D& tex) { + if (tex.pixelSize() == 3) + return {}; + const auto size = tex.pixels().size(); auto array = BitArray{NoInit, size[0]*size[1]}; make_bitmask_(tex, array); diff --git a/src/chunk-collision.cpp b/src/chunk-collision.cpp index 2c612576..e6d0fe93 100644 --- a/src/chunk-collision.cpp +++ b/src/chunk-collision.cpp @@ -74,30 +74,27 @@ void chunk::ensure_passability() noexcept for (auto i = 0uz; i < TILE_COUNT; i++) { if (const auto* atlas = ground_atlas_at(i)) - if (auto p = atlas->pass_mode(pass_mode::pass); p != pass_mode::pass) - { - auto [min, max] = whole_tile(i); - auto id = make_id(collision_type::geometry, p, i); - _rtree.Insert(min.data(), max.data(), id); - } + { + auto [min, max] = whole_tile(i); + auto id = make_id(collision_type::geometry, atlas->pass_mode(pass_mode::pass), i); + _rtree.Insert(min.data(), max.data(), id); + } } for (auto i = 0uz; i < TILE_COUNT; i++) { auto tile = operator[](i); if (const auto* atlas = tile.wall_north_atlas().get()) - if (auto p = atlas->pass_mode(pass_mode::blocked); p != pass_mode::pass) - { - auto [min, max] = wall_north(i); - auto id = make_id(collision_type::geometry, p, i); - _rtree.Insert(min.data(), max.data(), id); - } + { + auto [min, max] = wall_north(i); + auto id = make_id(collision_type::geometry, atlas->pass_mode(pass_mode::blocked), i); + _rtree.Insert(min.data(), max.data(), id); + } if (const auto* atlas = tile.wall_west_atlas().get()) - if (auto p = atlas->pass_mode(pass_mode::blocked); p != pass_mode::pass) - { - auto [min, max] = wall_west(i); - auto id = make_id(collision_type::geometry, p, i); - _rtree.Insert(min.data(), max.data(), id); - } + { + auto [min, max] = wall_west(i); + auto id = make_id(collision_type::geometry, atlas->pass_mode(pass_mode::blocked), i); + _rtree.Insert(min.data(), max.data(), id); + } } } @@ -106,7 +103,7 @@ bool chunk::_bbox_for_scenery(const entity& s, local_coords local, Vector2b offs auto [start, end] = scenery_tile(local, offset, bbox_offset, bbox_size); auto id = make_id(collision_type::scenery, s.pass, s.id); value = { .id = id, .start = start, .end = end }; - return s.atlas && s.pass != pass_mode::pass; + return s.atlas && !Vector2ui(s.bbox_size).isZero(); } bool chunk::_bbox_for_scenery(const entity& s, bbox& value) noexcept @@ -132,7 +129,7 @@ void chunk::_replace_bbox(const bbox& x0, const bbox& x1, bool b0, bool b1) return; unsigned i = (unsigned)b1 << 1 | (unsigned)(b0 ? 1 : 0) << 0; - CORRADE_ASSUME(i < 4u); + CORRADE_ASSUME(i < 4u); (void)0; switch (i) // NOLINT(hicpp-multiway-paths-covered) { @@ -150,7 +147,7 @@ void chunk::_replace_bbox(const bbox& x0, const bbox& x1, bool b0, bool b1) case 0 << 1 | 0 << 0: return; } - CORRADE_ASSUME(false); + CORRADE_ASSUME(false); (void)0; } bool chunk::can_place_entity(const entity_proto& proto, local_coords pos) @@ -160,7 +157,12 @@ bool chunk::can_place_entity(const entity_proto& proto, local_coords pos) const auto center = Vector2(pos)*TILE_SIZE2 + Vector2(proto.offset) + Vector2(proto.bbox_offset), min = center - Vector2(proto.bbox_size/2), max = min + Vector2(proto.bbox_size); bool ret = true; - _rtree.Search(min.data(), max.data(), [&](auto, const auto&) { return ret = false; }); + _rtree.Search(min.data(), max.data(), [&](uint64_t data, const auto&) { + [[maybe_unused]] auto x = std::bit_cast<collision_data>(data); + if (x.pass == (uint64_t)pass_mode::pass) + return true; + return ret = false; + }); return ret; } diff --git a/src/light.cpp b/src/light.cpp index 64da857b..e1dd00b9 100644 --- a/src/light.cpp +++ b/src/light.cpp @@ -4,7 +4,12 @@ namespace floormat { -light_proto::light_proto() = default; +light_proto::light_proto() +{ + pass = pass_mode::pass; + type = entity_type::light; +} + light_proto::light_proto(const light_proto&) = default; light_proto& light_proto::operator=(const light_proto&) = default; light_proto::~light_proto() noexcept = default; @@ -20,7 +25,7 @@ light::light(object_id id, struct chunk& c, const light_proto& proto) : float light::depth_offset() const { - constexpr auto ret = 4.f / tile_shader::depth_tile_size; + constexpr auto ret = 4 / tile_shader::depth_tile_size; return ret; } |