mirror of
https://github.com/godotengine/godot.git
synced 2026-01-03 18:11:19 +03:00
Add frame delta smoothing option (4.x)
Frame deltas are currently measured by querying the OS timer each frame. This is subject to random error. Frame delta smoothing instead filters the delta read from the OS by replacing it with the refresh rate delta wherever possible. This PR also contains code to estimate the refresh rate based on the input deltas, without reading the refresh rate from the host OS. The delta_smooth_enabled setting can also be modified at runtime through OS::, and there is also now a command line setting to override the project setting.
This commit is contained in:
@@ -224,6 +224,14 @@ int OS::get_low_processor_usage_mode_sleep_usec() const {
|
||||
return ::OS::get_singleton()->get_low_processor_usage_mode_sleep_usec();
|
||||
}
|
||||
|
||||
void OS::set_delta_smoothing(bool p_enabled) {
|
||||
::OS::get_singleton()->set_delta_smoothing(p_enabled);
|
||||
}
|
||||
|
||||
bool OS::is_delta_smoothing_enabled() const {
|
||||
return ::OS::get_singleton()->is_delta_smoothing_enabled();
|
||||
}
|
||||
|
||||
void OS::alert(const String &p_alert, const String &p_title) {
|
||||
::OS::get_singleton()->alert(p_alert, p_title);
|
||||
}
|
||||
@@ -556,6 +564,9 @@ void OS::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("set_low_processor_usage_mode_sleep_usec", "usec"), &OS::set_low_processor_usage_mode_sleep_usec);
|
||||
ClassDB::bind_method(D_METHOD("get_low_processor_usage_mode_sleep_usec"), &OS::get_low_processor_usage_mode_sleep_usec);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_delta_smoothing", "delta_smoothing_enabled"), &OS::set_delta_smoothing);
|
||||
ClassDB::bind_method(D_METHOD("is_delta_smoothing_enabled"), &OS::is_delta_smoothing_enabled);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_processor_count"), &OS::get_processor_count);
|
||||
ClassDB::bind_method(D_METHOD("get_processor_name"), &OS::get_processor_name);
|
||||
|
||||
@@ -631,6 +642,7 @@ void OS::_bind_methods() {
|
||||
|
||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "low_processor_usage_mode"), "set_low_processor_usage_mode", "is_in_low_processor_usage_mode");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "low_processor_usage_mode_sleep_usec"), "set_low_processor_usage_mode_sleep_usec", "get_low_processor_usage_mode_sleep_usec");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "delta_smoothing"), "set_delta_smoothing", "is_delta_smoothing_enabled");
|
||||
|
||||
// Those default values need to be specified for the docs generator,
|
||||
// to avoid using values from the documentation writer's own OS instance.
|
||||
|
||||
Reference in New Issue
Block a user