diff options
-rw-r--r-- | editor/app.cpp | 1 | ||||
-rw-r--r-- | editor/app.hpp | 3 | ||||
-rw-r--r-- | editor/update.cpp | 24 |
3 files changed, 21 insertions, 7 deletions
diff --git a/editor/app.cpp b/editor/app.cpp index ca4dd853..1727b780 100644 --- a/editor/app.cpp +++ b/editor/app.cpp @@ -94,6 +94,7 @@ void app::reset_world(class world&& w_) _character_id = 0; _render_vobjs = true; _render_all_z_levels = true; + _timestamp = 0; auto& w = M->reset_world(move(w_)); w.collect(true); diff --git a/editor/app.hpp b/editor/app.hpp index 32193fe6..b3645a7d 100644 --- a/editor/app.hpp +++ b/editor/app.hpp @@ -157,7 +157,7 @@ private: void do_key(key k); void do_set_mode(editor_mode mode); void do_rotate(bool backward); - static void do_emit_timestamp(); + void do_emit_timestamp(); void apply_commands(const key_set& k); int get_key_modifiers(); void clear_keys(key min_inclusive, key max_exclusive); @@ -183,6 +183,7 @@ private: void erase_inspector(size_t index, ptrdiff_t count = 1); void kill_inspectors(); + uint64_t _timestamp = 0; floormat_main* M; safe_ptr<ImGuiIntegration::Context> _imgui; safe_ptr<floormat::wireframe::meshes> _wireframe; diff --git a/editor/update.cpp b/editor/update.cpp index dffc1fdd..8c3349e5 100644 --- a/editor/update.cpp +++ b/editor/update.cpp @@ -124,13 +124,25 @@ void app::do_rotate(bool backward) void app::do_emit_timestamp() { - static struct - { - Time time = Time::now(); - unsigned ctr = 0; - } s; + constexpr const char* prefix = " -- MARK -- "; + + static unsigned counter; + const auto now = Time::now(); + const auto time = (double)Time::to_milliseconds(now - Time{_timestamp}); char buf[fm_DATETIME_BUF_SIZE]; - fm_debug("%s -- MARK -- 0x%08X", format_datetime_to_string(buf), ++s.ctr & 0xffff'ffffU); + format_datetime_to_string(buf); + + if (time >= 1e5f) + fm_debug("%s%s0x%08x %.2f" " s", buf, prefix, counter++, time*1e-3); + else if (time >= 1e4f) + fm_debug("%s%s0x%08x %.2f" " s", buf, prefix, counter++, time*1e-3); + else if (time >= 1e3f) + fm_debug("%s%s0x%08x %.2f" " ms", buf, prefix, counter++, time); + else if (time > 0) + fm_debug("%s%s0x%08x %.4f" " ms", buf, prefix, counter++, time); + else + fm_debug("%s%s0x%08x 0" " ms", buf, prefix, counter++); + _timestamp = now.stamp; } void app::do_set_mode(editor_mode mode) |