diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2024-02-25 19:20:29 +0100 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2024-02-25 19:20:29 +0100 |
commit | 8d0c254f45f3754142996d45434a67ec7ebc5dd9 (patch) | |
tree | 5ed904577967440cb7f9c37e9321d8f311f2f4d2 /src/chunk-region.cpp | |
parent | bd2aa935bfc2b377481ca5900d0d89168a507eae (diff) |
remove cached pass_region from chunk
This wasn't well thought out because the regiojn gets dirtied after
every critter movement, even though it ignores critters by default.
Diffstat (limited to 'src/chunk-region.cpp')
-rw-r--r-- | src/chunk-region.cpp | 40 |
1 files changed, 6 insertions, 34 deletions
diff --git a/src/chunk-region.cpp b/src/chunk-region.cpp index c976fd28..c0afe9f0 100644 --- a/src/chunk-region.cpp +++ b/src/chunk-region.cpp @@ -128,44 +128,14 @@ auto default_region_predicate(chunk& c) noexcept } // namespace -void chunk::delete_pass_region(pass_region*& ptr) +auto chunk::make_pass_region() -> pass_region { - if (ptr) - { - delete ptr; - ptr = nullptr; - } + return make_pass_region(default_region_predicate(*this)); } -auto chunk::get_pass_region() -> const pass_region* +auto chunk::make_pass_region(const pred& f) -> pass_region { - if (!_region_modified) - { - fm_debug_assert(_region != nullptr); - return _region; - } - _region_modified = false; - - if (!_region) - _region = new pass_region; - else - _region->bits = {}; - - make_pass_region(*_region); - return _region; -} - -bool chunk::is_region_modified() const noexcept { return _region_modified; } -void chunk::mark_region_modified() noexcept { _region_modified = true; } - -void chunk::make_pass_region(pass_region& ret) -{ - return make_pass_region(ret, default_region_predicate(*this)); -} - -void chunk::make_pass_region(pass_region& ret, const pred& f) -{ - ret = {}; + pass_region ret; auto& tmp = get_tmp(); const auto nbs = _world->neighbors(_coord); @@ -204,6 +174,8 @@ void chunk::make_pass_region(pass_region& ret, const pred& f) tmp.append(ret.bits, pos); } } + + return ret; } } // namespace floormat |