diff options
Diffstat (limited to 'mm/2s2h/BenPort.cpp')
| -rw-r--r-- | mm/2s2h/BenPort.cpp | 33 |
1 files changed, 16 insertions, 17 deletions
diff --git a/mm/2s2h/BenPort.cpp b/mm/2s2h/BenPort.cpp index faaaa1006..4e611479d 100644 --- a/mm/2s2h/BenPort.cpp +++ b/mm/2s2h/BenPort.cpp @@ -734,11 +734,6 @@ extern "C" uint32_t Ship_GetInterpolationFPS() { return OTRGlobals::Instance->GetInterpolationFPS(); } -// Number of interpolated frames -extern "C" uint32_t Ship_GetInterpolationFrameCount() { - return ceil((float)Ship_GetInterpolationFPS() / 20.0f); -} - struct ExtensionEntry { std::string path; std::string ext; @@ -1160,7 +1155,8 @@ extern "C" void Graph_StartFrame() { #endif } -void RunCommands(Gfx* Commands, const std::vector<std::unordered_map<Mtx*, MtxF>>& mtx_replacements) { +// Interpolated frames of a tick are evenly spaced numerators time+step, time+2*step, ... over denom. +void RunCommands(Gfx* Commands, int time, int step, int denom, int count) { auto wnd = std::dynamic_pointer_cast<Fast::Fast3dWindow>(OTRGlobals::Instance->context->GetWindow()); if (wnd == nullptr) { @@ -1176,8 +1172,12 @@ void RunCommands(Gfx* Commands, const std::vector<std::unordered_map<Mtx*, MtxF> UIWidgets::Colors themeColor = static_cast<UIWidgets::Colors>(CVarGetInteger("gSettings.Menu.Theme", UIWidgets::Colors::LightBlue)); ImGui::PushStyleColor(ImGuiCol_TitleBgActive, UIWidgets::ColorValues.at(themeColor)); - for (const auto& m : mtx_replacements) { - wnd->DrawAndRunGraphicsCommands(Commands, m); + for (int i = 0; i < count; i++) { + time += step; + std::unordered_map<Mtx*, MtxF> mtx_replacements = + (time == denom) ? std::unordered_map<Mtx*, MtxF>() : FrameInterpolation_Interpolate((float)time / denom); + intp->mInterpolationT = (float)time / denom; + wnd->DrawAndRunGraphicsCommands(Commands, mtx_replacements); intp->mInterpolationIndex++; } ImGui::PopStyleColor(); @@ -1191,7 +1191,6 @@ extern "C" void Graph_ProcessGfxCommands(Gfx* commands) { } audio.cv_to_thread.notify_one(); - std::vector<std::unordered_map<Mtx*, MtxF>> mtx_replacements; int target_fps = OTRGlobals::Instance->GetInterpolationFPS(); static int last_fps; static int last_update_rate; @@ -1211,13 +1210,11 @@ extern "C" void Graph_ProcessGfxCommands(Gfx* commands) { // time_base = fps * original_fps (one second) int next_original_frame = fps; + int start_time = time; + int count = 0; while (time + original_fps <= next_original_frame) { time += original_fps; - if (time != next_original_frame) { - mtx_replacements.push_back(FrameInterpolation_Interpolate((float)time / next_original_frame)); - } else { - mtx_replacements.emplace_back(); - } + count++; } time -= fps; @@ -1226,13 +1223,15 @@ extern "C" void Graph_ProcessGfxCommands(Gfx* commands) { wnd->SetTargetFps(fps); } + int step = original_fps; // When the gfx debugger is active, only run with the final mtx if (GfxDebuggerIsDebugging()) { - mtx_replacements.clear(); - mtx_replacements.emplace_back(); + start_time = next_original_frame; + step = 0; + count = 1; } - RunCommands(commands, mtx_replacements); + RunCommands(commands, start_time, step, next_original_frame, count); last_fps = fps; last_update_rate = R_UPDATE_RATE; |
