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:
@@ -11,6 +11,7 @@
|
||||
#include "absl/strings/match.h"
|
||||
#include "absl/strings/str_cat.h"
|
||||
#include "app/core/features.h"
|
||||
#include "app/core/timing.h"
|
||||
#include "util/file_util.h"
|
||||
#include "app/core/project.h"
|
||||
#include "app/editor/code/assembly_editor.h"
|
||||
@@ -636,6 +637,10 @@ void EditorManager::Initialize(const std::string& filename) {
|
||||
}
|
||||
|
||||
absl::Status EditorManager::Update() {
|
||||
// Update timing manager for accurate delta time across the application
|
||||
// This fixes animation timing issues that occur when mouse isn't moving
|
||||
core::TimingManager::Get().Update();
|
||||
|
||||
popup_manager_->DrawPopups();
|
||||
ExecuteShortcuts(context_.shortcut_manager);
|
||||
toast_manager_.Draw();
|
||||
@@ -1475,7 +1480,7 @@ void EditorManager::DrawMenuBar() {
|
||||
|
||||
if (show_emulator_) {
|
||||
Begin("Emulator", &show_emulator_, ImGuiWindowFlags_MenuBar);
|
||||
emulator_.Run();
|
||||
emulator_.Run(current_rom_);
|
||||
End();
|
||||
}
|
||||
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user