diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2024-02-11 02:29:26 +0100 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2024-02-11 08:49:52 +0100 |
commit | c40f3dc1505439acd34b5fff12ea0a570920f98d (patch) | |
tree | 8e73438f8f03295dd3285ba1fbc044693bafe230 | |
parent | 7abfbd9961072bb4e358c675d417cc8e8bb16d70 (diff) |
wip atlas
-rw-r--r-- | loader/anim-atlas.cpp | 4 | ||||
-rw-r--r-- | loader/anim-cell.hpp | 2 | ||||
-rw-r--r-- | loader/anim-traits.cpp | 7 | ||||
-rw-r--r-- | loader/atlas-loader.inl | 17 |
4 files changed, 16 insertions, 14 deletions
diff --git a/loader/anim-atlas.cpp b/loader/anim-atlas.cpp index 6fca5a49..9f8de563 100644 --- a/loader/anim-atlas.cpp +++ b/loader/anim-atlas.cpp @@ -116,9 +116,9 @@ const anim_cell& loader_impl::make_invalid_anim_atlas() .nframes = 1, }; auto atlas = std::make_shared<class anim_atlas>(INVALID, make_error_texture(size), std::move(def)); - auto info = anim_cell{ - .name = INVALID, + auto info = anim_cell { .atlas = atlas, + .name = INVALID, }; invalid_anim_atlas = Pointer<anim_cell>{ InPlace, std::move(info) }; return *invalid_anim_atlas; diff --git a/loader/anim-cell.hpp b/loader/anim-cell.hpp index a9c92a23..37bbb7d8 100644 --- a/loader/anim-cell.hpp +++ b/loader/anim-cell.hpp @@ -8,8 +8,8 @@ class anim_atlas; struct anim_cell { - String name; std::shared_ptr<anim_atlas> atlas; + String name; }; } // namespace floormat diff --git a/loader/anim-traits.cpp b/loader/anim-traits.cpp index a2c932cc..925fcfad 100644 --- a/loader/anim-traits.cpp +++ b/loader/anim-traits.cpp @@ -26,7 +26,6 @@ void anim_traits::ensure_atlases_loaded(Storage& s) { fm_debug_assert(s.name_map.empty()); s.cell_array = {}; - s.cell_array.reserve(16); s.name_map[loader.INVALID] = -1uz; } @@ -56,9 +55,9 @@ auto anim_traits::make_invalid_atlas(Storage& s) -> Pointer<Cell> .nframes = 1, }; auto atlas = std::make_shared<class anim_atlas>(loader.INVALID, loader.make_error_texture(size), std::move(def)); - auto info = anim_cell{ - .name = loader.INVALID, + auto info = anim_cell { .atlas = atlas, + .name = loader.INVALID, }; return Pointer<anim_cell>{ InPlace, Utility::move(info) }; } @@ -70,7 +69,7 @@ auto anim_traits::make_atlas(StringView name, const Cell& c) -> std::shared_ptr< auto anim_traits::make_cell(StringView name) -> Optional<Cell> { - return {}; + return { InPlace, Cell{ .atlas = {}, .name = name, } }; } } // namespace floormat::loader_detail diff --git a/loader/atlas-loader.inl b/loader/atlas-loader.inl index 6c341ba0..c2a7cb88 100644 --- a/loader/atlas-loader.inl +++ b/loader/atlas-loader.inl @@ -107,27 +107,30 @@ const std::shared_ptr<ATLAS>& atlas_loader<ATLAS, TRAITS>::get_atlas(StringView { Cell& c = s.cell_array[it->second]; fm_assert(t.name_of(c)); - std::shared_ptr<ATLAS>& atlas = t.atlas_of(c); + std::shared_ptr<ATLAS>& atlas{t.atlas_of(c)}; if (!atlas) [[unlikely]] { atlas = make_atlas(name, c); - fm_debug_assert(atlas); + fm_assert(atlas); + fm_assert(t.atlas_of(c) == atlas); + fm_assert(t.name_of(*atlas) == name); return atlas; } else { - fm_assert(t.name_of(c) == name); + fm_debug_assert(t.name_of(c) == name); return atlas; } } } else if (Optional<Cell> c_{t.make_cell(name)}) { - fm_debug_assert(t.name_of(*c_)); - fm_debug_assert(!t.atlas_of(*c_)); + fm_assert(t.name_of(*c_)); + fm_assert(!t.atlas_of(*c_)); + fm_assert(t.name_of(*c_) == name); const size_t index{s.cell_array.size()}; - if (t.name_of(c_).isSmall()) - t.name_of(c_) = { AllocatedInit, t.name_of(c_) }; + if (t.name_of(*c_).isSmall()) + t.name_of(*c_) = String{ AllocatedInit, t.name_of(*c_) }; s.cell_array.emplace_back(Utility::move(*c_)); Cell& c{s.cell_array.back()}; t.atlas_of(c) = make_atlas(name, c); |