Веб-сайт самохостера Lotigara

summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKae <80987908+Novaenia@users.noreply.github.com>2023-08-31 04:55:36 +1000
committerKae <80987908+Novaenia@users.noreply.github.com>2023-08-31 04:55:36 +1000
commit51d6e63dfe5bce9812886e0ece5fa62975f38d77 (patch)
tree58ad00e05e9d0f8e2f08cd725636d4fa8a81b7a7
parent182d3052c5da17701b6407164a6505b8aeafa867 (diff)
Only do spatial logging when spatial log is observed
-rw-r--r--source/core/StarLogging.cpp20
-rw-r--r--source/core/StarLogging.hpp4
-rw-r--r--source/frontend/StarMainInterface.cpp2
3 files changed, 26 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;
}
diff --git a/source/core/StarLogging.hpp b/source/core/StarLogging.hpp
index 1ab21a9..6e909fb 100644
--- a/source/core/StarLogging.hpp
+++ b/source/core/StarLogging.hpp
@@ -147,11 +147,15 @@ public:
static void clear();
+ static bool observed();
+ static void setObserved(bool observed);
+
private:
static Mutex s_mutex;
static StringMap<Deque<Line>> s_lines;
static StringMap<Deque<Point>> s_points;
static StringMap<Deque<LogText>> s_logText;
+ static bool s_observed;
};
template <typename... Args>
diff --git a/source/frontend/StarMainInterface.cpp b/source/frontend/StarMainInterface.cpp
index 4d8a22e..37d0a99 100644
--- a/source/frontend/StarMainInterface.cpp
+++ b/source/frontend/StarMainInterface.cpp
@@ -1329,8 +1329,10 @@ void MainInterface::renderDebug() {
SpatialLogger::clear();
m_debugTextRect = RectF::null();
LogMap::clear();
+ SpatialLogger::setObserved(false);
return;
}
+ SpatialLogger::setObserved(true);
if (m_clientCommandProcessor->debugHudEnabled()) {
auto assets = Root::singleton().assets();