diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2024-02-11 02:15:08 +0100 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2024-02-11 08:49:52 +0100 |
commit | 7abfbd9961072bb4e358c675d417cc8e8bb16d70 (patch) | |
tree | 0d6adff5305e35561429d9267383b88200bbd13c /loader | |
parent | c6abddc2349685a9476b6838a59893a17e443d2f (diff) |
wip atlas
Diffstat (limited to 'loader')
-rw-r--r-- | loader/anim-traits.cpp | 15 | ||||
-rw-r--r-- | loader/atlas-loader.inl | 15 | ||||
-rw-r--r-- | loader/ground-traits.cpp | 4 | ||||
-rw-r--r-- | loader/wall-traits.cpp | 5 |
4 files changed, 20 insertions, 19 deletions
diff --git a/loader/anim-traits.cpp b/loader/anim-traits.cpp index 9ff7e6b5..a2c932cc 100644 --- a/loader/anim-traits.cpp +++ b/loader/anim-traits.cpp @@ -8,6 +8,7 @@ #include <cr/StringView.h> #include <cr/Pointer.h> #include <cr/Optional.h> +#include <cr/Move.h> #include <mg/ImageData.h> #include <mg/ImageView.h> @@ -23,7 +24,7 @@ String& anim_traits::name_of(Cell& x) { return x.name; } void anim_traits::ensure_atlases_loaded(Storage& s) { - fm_assert(s.name_map.empty()); + fm_debug_assert(s.name_map.empty()); s.cell_array = {}; s.cell_array.reserve(16); s.name_map[loader.INVALID] = -1uz; @@ -32,10 +33,12 @@ void anim_traits::ensure_atlases_loaded(Storage& s) auto anim_traits::make_invalid_atlas(Storage& s) -> Pointer<Cell> { fm_debug_assert(!s.invalid_atlas); - constexpr auto size = Vector2ui{16}; + + constexpr auto size = Vector2ui{tile_size_xy*3/4}; + constexpr auto ground = Vector2i(size/2); auto frame = anim_frame { - .ground = Vector2i(size/2), + .ground = ground, .offset = {}, .size = size, }; @@ -57,15 +60,15 @@ auto anim_traits::make_invalid_atlas(Storage& s) -> Pointer<Cell> .name = loader.INVALID, .atlas = atlas, }; - return Pointer<anim_cell>{ InPlace, std::move(info) }; + return Pointer<anim_cell>{ InPlace, Utility::move(info) }; } -auto anim_traits::make_atlas(StringView name, const Cell&) -> std::shared_ptr<Atlas> +auto anim_traits::make_atlas(StringView name, const Cell& c) -> std::shared_ptr<Atlas> { return {}; // todo } -auto anim_traits::make_cell(StringView) -> Optional<Cell> +auto anim_traits::make_cell(StringView name) -> Optional<Cell> { return {}; } diff --git a/loader/atlas-loader.inl b/loader/atlas-loader.inl index c1093f82..6c341ba0 100644 --- a/loader/atlas-loader.inl +++ b/loader/atlas-loader.inl @@ -64,7 +64,6 @@ const std::shared_ptr<ATLAS>& atlas_loader<ATLAS, TRAITS>::get_atlas(StringView { ensure_atlas_list(); const std::shared_ptr<Atlas>& invalid_atlas = t.atlas_of(get_invalid_atlas()); - fm_debug_assert(invalid_atlas); switch (p) { @@ -122,15 +121,17 @@ const std::shared_ptr<ATLAS>& atlas_loader<ATLAS, TRAITS>::get_atlas(StringView } } } - else if (Optional<Cell> c_{t.make_cell(name)}) // todo! + else if (Optional<Cell> c_{t.make_cell(name)}) { - size_t index = s.cell_array.size(); + fm_debug_assert(t.name_of(*c_)); + fm_debug_assert(!t.atlas_of(*c_)); + const size_t index{s.cell_array.size()}; + if (t.name_of(c_).isSmall()) + t.name_of(c_) = { AllocatedInit, t.name_of(c_) }; s.cell_array.emplace_back(Utility::move(*c_)); - Cell& c = s.cell_array.back(); - fm_debug_assert(!t.name_of(c)); fm_debug_assert(!t.atlas_of(c)); + Cell& c{s.cell_array.back()}; t.atlas_of(c) = make_atlas(name, c); - t.name_of(c) = String{AllocatedInit, name}; - fm_debug_assert(t.name_of(c)); fm_debug_assert(t.atlas_of(c)); + fm_debug_assert(t.atlas_of(c)); s.name_map[t.name_of(c)] = index; return t.atlas_of(c); } diff --git a/loader/ground-traits.cpp b/loader/ground-traits.cpp index f1795f4e..ae6e17bc 100644 --- a/loader/ground-traits.cpp +++ b/loader/ground-traits.cpp @@ -24,8 +24,7 @@ String& ground_traits::name_of(Cell& x) { return x.name; } void ground_traits::ensure_atlases_loaded(Storage& s) { - fm_assert(s.name_map.empty()); - + fm_debug_assert(s.name_map.empty()); s.cell_array = ground_cell::load_atlases_from_json().vec; s.name_map[loader.INVALID] = -1uz; } @@ -33,7 +32,6 @@ void ground_traits::ensure_atlases_loaded(Storage& s) auto ground_traits::make_invalid_atlas(Storage& s) -> Pointer<Cell> { fm_debug_assert(!s.invalid_atlas); - fm_assert(!s.invalid_atlas); auto atlas = std::make_shared<Atlas>( ground_def{loader.INVALID, Vector2ub{1,1}, pass_mode::pass}, loader.make_error_texture(Vector2ui(tile_size_xy))); diff --git a/loader/wall-traits.cpp b/loader/wall-traits.cpp index 70d729c0..182d30b2 100644 --- a/loader/wall-traits.cpp +++ b/loader/wall-traits.cpp @@ -24,15 +24,14 @@ String& wall_traits::name_of(Cell& x) { return x.name; } void wall_traits::ensure_atlases_loaded(Storage& s) { - fm_assert(s.name_map.empty()); - + fm_debug_assert(s.name_map.empty()); s.cell_array = wall_cell::load_atlases_from_json().vec; s.name_map[loader.INVALID] = -1uz; } auto wall_traits::make_invalid_atlas(Storage& s) -> Pointer<Cell> { - fm_assert(!s.invalid_atlas); + fm_debug_assert(!s.invalid_atlas); constexpr auto name = loader_::INVALID; constexpr auto frame_size = Vector2ui{tile_size_xy, tile_size_z}; |