diff options
author | Kae <80987908+Novaenia@users.noreply.github.com> | 2023-08-31 04:55:36 +1000 |
---|---|---|
committer | Kae <80987908+Novaenia@users.noreply.github.com> | 2023-08-31 04:55:36 +1000 |
commit | 51d6e63dfe5bce9812886e0ece5fa62975f38d77 (patch) | |
tree | 58ad00e05e9d0f8e2f08cd725636d4fa8a81b7a7 /source/core/StarLogging.cpp | |
parent | 182d3052c5da17701b6407164a6505b8aeafa867 (diff) |
Only do spatial logging when spatial log is observed
Diffstat (limited to 'source/core/StarLogging.cpp')
-rw-r--r-- | source/core/StarLogging.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/source/core/StarLogging.cpp b/source/core/StarLogging.cpp index 03414d6..19094f8 100644 --- a/source/core/StarLogging.cpp +++ b/source/core/StarLogging.cpp @@ -120,6 +120,8 @@ size_t const SpatialLogger::MaximumPoints; size_t const SpatialLogger::MaximumText; void SpatialLogger::logPoly(char const* space, PolyF const& poly, Vec4B const& color) { + if (!observed()) return; + MutexLocker locker(s_mutex); auto& lines = s_lines[space]; @@ -133,6 +135,8 @@ void SpatialLogger::logPoly(char const* space, PolyF const& poly, Vec4B const& c } void SpatialLogger::logLine(char const* space, Line2F const& line, Vec4B const& color) { + if (!observed()) return; + MutexLocker locker(s_mutex); auto& lines = s_lines[space]; @@ -143,6 +147,8 @@ void SpatialLogger::logLine(char const* space, Line2F const& line, Vec4B const& } void SpatialLogger::logLine(char const* space, Vec2F const& begin, Vec2F const& end, Vec4B const& color) { + if (!observed()) return; + MutexLocker locker(s_mutex); auto& lines = s_lines[space]; @@ -153,6 +159,8 @@ void SpatialLogger::logLine(char const* space, Vec2F const& begin, Vec2F const& } void SpatialLogger::logPoint(char const* space, Vec2F const& position, Vec4B const& color) { + if (!observed()) return; + MutexLocker locker(s_mutex); auto& points = s_points[space]; @@ -163,6 +171,8 @@ void SpatialLogger::logPoint(char const* space, Vec2F const& position, Vec4B con } void SpatialLogger::logText(char const* space, String text, Vec2F const& position, Vec4B const& color) { + if (!observed()) return; + MutexLocker locker(s_mutex); auto& texts = s_logText[space]; @@ -208,8 +218,18 @@ void SpatialLogger::clear() { } // Move while locked to deallocate contents while unlocked. } +bool SpatialLogger::observed() { + return s_observed; +} + +void SpatialLogger::setObserved(bool observed) { + s_observed = observed; +} + + Mutex SpatialLogger::s_mutex; StringMap<Deque<SpatialLogger::Line>> SpatialLogger::s_lines; StringMap<Deque<SpatialLogger::Point>> SpatialLogger::s_points; StringMap<Deque<SpatialLogger::LogText>> SpatialLogger::s_logText; +bool SpatialLogger::s_observed = false; } |