diff options
-rw-r--r-- | src/chunk-region.cpp | 7 | ||||
-rw-r--r-- | src/global-coords.cpp | 27 | ||||
-rw-r--r-- | src/global-coords.hpp | 3 |
3 files changed, 31 insertions, 6 deletions
diff --git a/src/chunk-region.cpp b/src/chunk-region.cpp index fb85223b..0006285d 100644 --- a/src/chunk-region.cpp +++ b/src/chunk-region.cpp @@ -185,12 +185,7 @@ auto chunk::make_pass_region(const pred& f, bool debug) -> pass_region 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"; + DBG_nospace << "region: generating for " << _coord << " took " << buf << " ms"; } return ret; diff --git a/src/global-coords.cpp b/src/global-coords.cpp index f8d5daed..8775f9ba 100644 --- a/src/global-coords.cpp +++ b/src/global-coords.cpp @@ -5,6 +5,33 @@ namespace floormat { +Debug& operator<<(Debug& dbg, const chunk_coords& c) +{ + dbg << ""; + const auto flags = dbg.flags(); + + dbg.setFlags(flags | Debug::Flag::NoSpace); + dbg << "chunk{" << c.x << "," << c.y << "}"; + + dbg.setFlags(flags); + return dbg; +} + +Debug& operator<<(Debug& dbg, const chunk_coords_& c) +{ + dbg << ""; + const auto flags = dbg.flags(); + + dbg.setFlags(flags | Debug::Flag::NoSpace); + dbg << "chunk{" << c.x << "," << c.y; + if (c.z != 0) + dbg << "," << c.z; + dbg << "}"; + + dbg.setFlags(flags); + return dbg; +} + namespace { static_assert(sizeof(decltype(local_coords::x))*8 == 8); diff --git a/src/global-coords.hpp b/src/global-coords.hpp index 03dfc67e..ef571b18 100644 --- a/src/global-coords.hpp +++ b/src/global-coords.hpp @@ -11,6 +11,7 @@ struct chunk_coords final { int16_t x = 0, y = 0; constexpr bool operator==(const chunk_coords& other) const noexcept = default; + friend Debug& operator<<(Debug& dbg, const chunk_coords& pt); template<typename T> explicit constexpr operator Math::Vector2<T>() const noexcept @@ -36,7 +37,9 @@ struct chunk_coords_ final { constexpr chunk_coords_() noexcept = default; constexpr chunk_coords_(int16_t x, int16_t y, int8_t z) noexcept : x{x}, y{y}, z{z} {} constexpr chunk_coords_(chunk_coords c, int8_t z) noexcept : x{c.x}, y{c.y}, z{z} {} + constexpr bool operator==(const chunk_coords_&) const noexcept = default; + friend Debug& operator<<(Debug& dbg, const chunk_coords_& pt); template<typename T> requires std::is_integral_v<T> constexpr chunk_coords_ operator+(Math::Vector2<T> off) const noexcept { |