diff options
-rw-r--r-- | editor/tests/region-test.cpp | 2 | ||||
-rw-r--r-- | src/chunk-region.cpp | 24 | ||||
-rw-r--r-- | src/chunk.hpp | 4 |
3 files changed, 24 insertions, 6 deletions
diff --git a/editor/tests/region-test.cpp b/editor/tests/region-test.cpp index 47272593..9b027636 100644 --- a/editor/tests/region-test.cpp +++ b/editor/tests/region-test.cpp @@ -153,7 +153,7 @@ void region_test::do_region_extraction(world& w, chunk_coords_ coord) if (auto* c = w.at(coord)) { result = { - .is_passable = c->make_pass_region().bits, + .is_passable = c->make_pass_region(true).bits, .c = coord, .exists = true, }; diff --git a/src/chunk-region.cpp b/src/chunk-region.cpp index c0afe9f0..fb85223b 100644 --- a/src/chunk-region.cpp +++ b/src/chunk-region.cpp @@ -8,6 +8,7 @@ #include <array> #include <Corrade/Containers/GrowableArray.h> #include <Magnum/Math/Functions.h> +#include <Magnum/Timeline.h> namespace floormat { @@ -128,13 +129,17 @@ auto default_region_predicate(chunk& c) noexcept } // namespace -auto chunk::make_pass_region() -> pass_region +auto chunk::make_pass_region(bool debug) -> pass_region { - return make_pass_region(default_region_predicate(*this)); + return make_pass_region(default_region_predicate(*this), debug); } -auto chunk::make_pass_region(const pred& f) -> pass_region +auto chunk::make_pass_region(const pred& f, bool debug) -> pass_region { + Timeline timeline; + if (debug) [[unlikely]] + timeline.start(); + pass_region ret; auto& tmp = get_tmp(); const auto nbs = _world->neighbors(_coord); @@ -175,6 +180,19 @@ auto chunk::make_pass_region(const pred& f) -> pass_region } } + if (debug) [[unlikely]] + { + const auto time = timeline.currentFrameTime(); + char buf[32]; + std::snprintf(buf, sizeof buf, "%.3f", 1e3*(double)time); + auto c = Vector3i(_coord); + auto dbg = DBG_nospace; + dbg << "region: generating for chunk{" << c.x() << "," << c.y(); + if (c.z() != 0) + dbg << "," << c.z(); + dbg << "} took " << buf << " ms"; + } + return ret; } diff --git a/src/chunk.hpp b/src/chunk.hpp index e2b812fb..266d01e5 100644 --- a/src/chunk.hpp +++ b/src/chunk.hpp @@ -117,8 +117,8 @@ public: static constexpr size_t max_wall_quad_count = TILE_COUNT*Wall::Direction_COUNT*(Wall::Group_COUNT+4); - pass_region make_pass_region(); - pass_region make_pass_region(const Search::pred& f); + pass_region make_pass_region(bool debug = false); + pass_region make_pass_region(const Search::pred& f, bool debug = false); private: struct ground_stuff |