Revert panels.cpp to upstream version (remove unnecessary casts)

This commit is contained in:
ramenrrami 2025-09-26 07:10:52 +02:00
parent 6dce1f5844
commit 440ea68d1a

View file

@ -3,7 +3,6 @@
#include <math.h> #include <math.h>
#include "kvm/kvm.h" #include "kvm/kvm.h"
#include "common/passert.h" #include "common/passert.h"
#include <algorithm>
int8_t gui::panel::render_performance_panel(gui::panel::performance_panel_t* panel, performance_data_t* data, int8_t gui::panel::render_performance_panel(gui::panel::performance_panel_t* panel, performance_data_t* data,
std::chrono::steady_clock::time_point* last_render) std::chrono::steady_clock::time_point* last_render)
@ -25,11 +24,9 @@ int8_t gui::panel::render_performance_panel(gui::panel::performance_panel_t* pan
++data->frame_count; ++data->frame_count;
if (duration.count() >= 100) if (duration.count() >= 100)
{ {
//every 100ms // Every 100ms
const double ms = static_cast<double>(duration.count()); data->fps = (float)data->frame_count * 1000.0f / (float)duration.count();
data->fps = static_cast<float>(static_cast<double>(data->frame_count) * 1000.0 / ms); data->frame_time = (float)duration.count() / (float)data->frame_count;
data->frame_time = static_cast<float>(ms / static_cast<double>(data->frame_count));
panel->fps_history.push_back(data->fps); panel->fps_history.push_back(data->fps);
panel->frame_time_history.push_back(data->frame_time); panel->frame_time_history.push_back(data->frame_time);
@ -63,11 +60,8 @@ int8_t gui::panel::render_performance_panel(gui::panel::performance_panel_t* pan
(void)std::copy(panel->frame_time_history.begin(), panel->frame_time_history.end(), frame_time_array); (void)std::copy(panel->frame_time_history.begin(), panel->frame_time_history.end(), frame_time_array);
::ImGui::Text("Frame Time History (ms):"); ::ImGui::Text("Frame Time History (ms):");
::ImGui::PlotLines("##FrameTime", ::ImGui::PlotLines("##FrameTime", frame_time_array, (int)panel->frame_time_history.size(), 0, nullptr, 0.0f,
frame_time_array, 33.33f, ImVec2(0, 80));
static_cast<int>(panel->frame_time_history.size()),
0, nullptr, 0.0f, 33.33f, ImVec2(0, 80));
} }
::ImGui::Separator(); ::ImGui::Separator();