feat: Introduce TimingManager for Accurate Frame Timing

- Added TimingManager class to provide precise timing for animations and frame pacing, addressing issues with ImGui::GetIO().DeltaTime.
- Updated event handling in the window management to use SDL_PollEvent for improved responsiveness.
- Integrated TimingManager into EditorManager, BackgroundRenderer, and WelcomeScreen for consistent delta time usage across the application.
- Enhanced animation updates to utilize accurate frame timing, improving visual performance and user experience.
This commit is contained in:
scawful
2025-10-06 09:53:03 -04:00
parent 8688f0c502
commit e58bc3f007
5 changed files with 152 additions and 24 deletions

View File

@@ -3,6 +3,7 @@
#include <algorithm>
#include <cmath>
#include "app/core/timing.h"
#include "app/gui/theme_manager.h"
#include "imgui/imgui.h"
@@ -23,7 +24,7 @@ void BackgroundRenderer::RenderDockingBackground(ImDrawList* draw_list, const Im
const ImVec2& window_size, const Color& theme_color) {
if (!draw_list) return;
UpdateAnimation(ImGui::GetIO().DeltaTime);
UpdateAnimation(core::TimingManager::Get().GetDeltaTime());
// Get current theme colors
auto& theme_manager = ThemeManager::Get();

View File

@@ -10,6 +10,7 @@
#include "absl/time/clock.h"
#include "absl/time/time.h"
#include "app/core/project.h"
#include "app/core/timing.h"
#include "app/gui/icons.h"
#include "app/gui/theme_manager.h"
#include "imgui/imgui.h"
@@ -244,7 +245,8 @@ bool WelcomeScreen::Show(bool* p_open) {
}
// Smooth interpolation to target position (faster response)
float lerp_speed = 8.0f * ImGui::GetIO().DeltaTime;
// Use TimingManager for accurate delta time
float lerp_speed = 8.0f * yaze::core::TimingManager::Get().GetDeltaTime();
triforce_positions_[i].x += (target_pos.x - triforce_positions_[i].x) * lerp_speed;
triforce_positions_[i].y += (target_pos.y - triforce_positions_[i].y) * lerp_speed;