-
Notifications
You must be signed in to change notification settings - Fork 173
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add vis data to tie/tfrag and better framelimiting/lag (#1100)
* add vis data to tie/tfrag and better fps stuff * better default
- Loading branch information
Showing
21 changed files
with
285 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#pragma once | ||
|
||
#include "common/util/Timer.h" | ||
|
||
class FrameLimiter { | ||
public: | ||
void run(double target_fps, bool experimental_accurate_lag, double engine_time) { | ||
double target_seconds; | ||
if (experimental_accurate_lag) { | ||
target_seconds = round_to_nearest_60fps(engine_time); | ||
} else { | ||
target_seconds = 1.f / target_fps; | ||
} | ||
double remaining_time = target_seconds - m_timer.getSeconds(); | ||
while (remaining_time > 0) { | ||
if (remaining_time > 0.003) { | ||
std::this_thread::sleep_for(std::chrono::microseconds(int(remaining_time * 1e6 * 0.5))); | ||
} | ||
remaining_time = target_seconds - m_timer.getSeconds(); | ||
} | ||
|
||
m_timer.start(); | ||
} | ||
|
||
private: | ||
double round_to_nearest_60fps(double current) { | ||
double one_frame = 1.f / 60.f; | ||
int frames_missed = (current / one_frame); // rounds down | ||
if (frames_missed > 4) { | ||
frames_missed = 4; | ||
} | ||
return (frames_missed + 1) * one_frame; | ||
} | ||
|
||
Timer m_timer; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.