From cd31407cb3f178a2906f8d1f800c0a8e200094e5 Mon Sep 17 00:00:00 2001 From: Yuri Sizov Date: Fri, 20 Oct 2023 17:54:39 +0200 Subject: [PATCH] Clean up some Editor, OpenXR, VideoStream code - EditorNode has excessive and pointless checks for Input singleton. - EditorNode initialization order is a bit awkward. - OpenXR binds a method that doesn't need that (for call deferred). - VideoStream has a formatting error. --- editor/editor_node.cpp | 56 +++++++++---------- .../openxr_interaction_profile_editor.cpp | 3 +- scene/resources/video_stream.h | 3 +- 3 files changed, 29 insertions(+), 33 deletions(-) diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index fa8810c539c1..30872f02889d 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -6728,30 +6728,38 @@ int EditorNode::execute_and_show_output(const String &p_title, const String &p_p } EditorNode::EditorNode() { - EditorPropertyNameProcessor *epnp = memnew(EditorPropertyNameProcessor); - add_child(epnp); + DEV_ASSERT(!singleton); + singleton = this; - PortableCompressedTexture2D::set_keep_all_compressed_buffers(true); - Input::get_singleton()->set_use_accumulated_input(true); Resource::_get_local_scene_func = _resource_get_edited_scene; - RenderingServer::get_singleton()->set_debug_generate_wireframes(true); + { + PortableCompressedTexture2D::set_keep_all_compressed_buffers(true); + RenderingServer::get_singleton()->set_debug_generate_wireframes(true); - AudioServer::get_singleton()->set_enable_tagging_used_audio_streams(true); + AudioServer::get_singleton()->set_enable_tagging_used_audio_streams(true); - // No navigation server by default if in editor. - if (NavigationServer3D::get_singleton()->get_debug_enabled()) { - NavigationServer3D::get_singleton()->set_active(true); - } else { - NavigationServer3D::get_singleton()->set_active(false); - } + // No navigation by default if in editor. + if (NavigationServer3D::get_singleton()->get_debug_enabled()) { + NavigationServer3D::get_singleton()->set_active(true); + } else { + NavigationServer3D::get_singleton()->set_active(false); + } - // No physics by default if in editor. - PhysicsServer3D::get_singleton()->set_active(false); - PhysicsServer2D::get_singleton()->set_active(false); + // No physics by default if in editor. + PhysicsServer3D::get_singleton()->set_active(false); + PhysicsServer2D::get_singleton()->set_active(false); - // No scripting by default if in editor. - ScriptServer::set_scripting_enabled(false); + // No scripting by default if in editor (except for tool). + ScriptServer::set_scripting_enabled(false); + + Input::get_singleton()->set_use_accumulated_input(true); + if (!DisplayServer::get_singleton()->is_touchscreen_available()) { + // Only if no touchscreen ui hint, disable emulation just in case. + Input::get_singleton()->set_emulate_touch_from_mouse(false); + } + DisplayServer::get_singleton()->cursor_set_custom_image(Ref()); + } EditorHelp::generate_doc(); SceneState::set_disable_placeholders(true); @@ -6759,18 +6767,8 @@ EditorNode::EditorNode() { ResourceLoader::clear_path_remaps(); ResourceLoader::set_create_missing_resources_if_class_unavailable(true); - Input *id = Input::get_singleton(); - - if (id) { - if (!DisplayServer::get_singleton()->is_touchscreen_available() && Input::get_singleton()) { - // Only if no touchscreen ui hint, disable emulation just in case. - id->set_emulate_touch_from_mouse(false); - } - DisplayServer::get_singleton()->cursor_set_custom_image(Ref()); - } - - DEV_ASSERT(!singleton); - singleton = this; + EditorPropertyNameProcessor *epnp = memnew(EditorPropertyNameProcessor); + add_child(epnp); EditorUndoRedoManager::get_singleton()->connect("version_changed", callable_mp(this, &EditorNode::_update_undo_redo_allowed)); EditorUndoRedoManager::get_singleton()->connect("history_changed", callable_mp(this, &EditorNode::_update_undo_redo_allowed)); diff --git a/modules/openxr/editor/openxr_interaction_profile_editor.cpp b/modules/openxr/editor/openxr_interaction_profile_editor.cpp index 7bccabf93664..da6a9eed7039 100644 --- a/modules/openxr/editor/openxr_interaction_profile_editor.cpp +++ b/modules/openxr/editor/openxr_interaction_profile_editor.cpp @@ -45,7 +45,6 @@ void OpenXRInteractionProfileEditorBase::_bind_methods() { ClassDB::bind_method(D_METHOD("_add_binding", "action", "path"), &OpenXRInteractionProfileEditorBase::_add_binding); ClassDB::bind_method(D_METHOD("_remove_binding", "action", "path"), &OpenXRInteractionProfileEditorBase::_remove_binding); - ClassDB::bind_method(D_METHOD("_update_interaction_profile"), &OpenXRInteractionProfileEditorBase::_update_interaction_profile); } void OpenXRInteractionProfileEditorBase::_notification(int p_what) { @@ -63,7 +62,7 @@ void OpenXRInteractionProfileEditorBase::_notification(int p_what) { void OpenXRInteractionProfileEditorBase::_do_update_interaction_profile() { if (!is_dirty) { is_dirty = true; - call_deferred("_update_interaction_profile"); + callable_mp(this, &OpenXRInteractionProfileEditorBase::_update_interaction_profile).call_deferred(); } } diff --git a/scene/resources/video_stream.h b/scene/resources/video_stream.h index b91a7acf350a..dc54f4b76969 100644 --- a/scene/resources/video_stream.h +++ b/scene/resources/video_stream.h @@ -94,8 +94,7 @@ class VideoStream : public Resource { OBJ_SAVE_TYPE(VideoStream); protected: - static void - _bind_methods(); + static void _bind_methods(); GDVIRTUAL0R(Ref, _instantiate_playback);