Add a V-Sync editor setting

The editor setting makes it possible to tweak V-Sync status
independently of the project setting.

Use cases:

- Decrease input lag and increase editor responsiveness when editing
  a project that has V-Sync enabled.
- Avoid tearing when editing a project that has V-Sync disabled.
This commit is contained in:
Hugo Locurcio
2021-05-02 01:18:56 +02:00
parent d3352813ea
commit 6f9586443a
5 changed files with 18 additions and 1 deletions

View File

@@ -345,6 +345,11 @@ void EditorNode::shortcut_input(const Ref<InputEvent> &p_event) {
}
}
void EditorNode::_update_vsync_mode() {
const DisplayServer::VSyncMode window_vsync_mode = DisplayServer::VSyncMode(int(EDITOR_GET("interface/editor/vsync_mode")));
DisplayServer::get_singleton()->window_set_vsync_mode(window_vsync_mode);
}
void EditorNode::_update_from_settings() {
_update_title();
@@ -758,6 +763,7 @@ void EditorNode::_notification(int p_what) {
} break;
case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: {
_update_vsync_mode();
FileDialog::set_default_show_hidden_files(EDITOR_GET("filesystem/file_dialog/show_hidden_files"));
EditorFileDialog::set_default_show_hidden_files(EDITOR_GET("filesystem/file_dialog/show_hidden_files"));
EditorFileDialog::set_default_display_mode((EditorFileDialog::DisplayMode)EDITOR_GET("filesystem/file_dialog/display_mode").operator int());
@@ -6268,6 +6274,8 @@ EditorNode::EditorNode() {
FileAccess::set_backup_save(EDITOR_GET("filesystem/on_save/safe_save_on_backup_then_rename"));
_update_vsync_mode();
// Warm up the surface upgrade tool as early as possible.
surface_upgrade_tool = memnew(SurfaceUpgradeTool);
run_surface_upgrade_tool = EditorSettings::get_singleton()->get_project_metadata("surface_upgrade_tool", "run_on_restart", false);