From 95b72631aa78fe5da45a911b59cab2d6f2b76c49 Mon Sep 17 00:00:00 2001 From: Bastiaan Olij Date: Wed, 10 Jul 2024 14:41:37 +1000 Subject: [PATCH] Couple of small fixes on the action map: now saves when CTRL-S is pressed/project is run, no longer looses content if OpenXR is not enabled, and a small documentation fix. --- doc/classes/XRInterface.xml | 4 ++++ doc/classes/XRNode3D.xml | 4 ++++ .../openxr/action_map/openxr_interaction_profile.cpp | 9 ++++++--- modules/openxr/editor/openxr_action_map_editor.cpp | 12 +++++++++--- 4 files changed, 23 insertions(+), 6 deletions(-) diff --git a/doc/classes/XRInterface.xml b/doc/classes/XRInterface.xml index 175caca598a..68d055ad8db 100644 --- a/doc/classes/XRInterface.xml +++ b/doc/classes/XRInterface.xml @@ -176,6 +176,10 @@ Triggers a haptic pulse on a device associated with this interface. [param action_name] is the name of the action for this pulse. [param tracker_name] is optional and can be used to direct the pulse to a specific device provided that device is bound to this haptic. + [param frequency] is the frequency of the pulse, set to [code]0.0[/code] to have the system use a default frequency. + [param amplitude] is the amplitude of the pulse between [code]0.0[/code] and [code]1.0[/code]. + [param duration_sec] is the duration of the pulse in seconds. + [param delay_sec] is a delay in seconds before the pulse is given. diff --git a/doc/classes/XRNode3D.xml b/doc/classes/XRNode3D.xml index dfe5600fcc9..82f4fa4ab94 100644 --- a/doc/classes/XRNode3D.xml +++ b/doc/classes/XRNode3D.xml @@ -38,6 +38,10 @@ Triggers a haptic pulse on a device associated with this interface. [param action_name] is the name of the action for this pulse. + [param frequency] is the frequency of the pulse, set to [code]0.0[/code] to have the system use a default frequency. + [param amplitude] is the amplitude of the pulse between [code]0.0[/code] and [code]1.0[/code]. + [param duration_sec] is the duration of the pulse in seconds. + [param delay_sec] is a delay in seconds before the pulse is given. diff --git a/modules/openxr/action_map/openxr_interaction_profile.cpp b/modules/openxr/action_map/openxr_interaction_profile.cpp index 2579697d054..12664571137 100644 --- a/modules/openxr/action_map/openxr_interaction_profile.cpp +++ b/modules/openxr/action_map/openxr_interaction_profile.cpp @@ -127,9 +127,12 @@ Ref OpenXRInteractionProfile::new_profile(const char * void OpenXRInteractionProfile::set_interaction_profile_path(const String p_input_profile_path) { OpenXRInteractionProfileMetadata *pmd = OpenXRInteractionProfileMetadata::get_singleton(); - ERR_FAIL_NULL(pmd); - - interaction_profile_path = pmd->check_profile_name(p_input_profile_path); + if (pmd) { + interaction_profile_path = pmd->check_profile_name(p_input_profile_path); + } else { + // OpenXR module not enabled, ignore checks. + interaction_profile_path = p_input_profile_path; + } emit_changed(); } diff --git a/modules/openxr/editor/openxr_action_map_editor.cpp b/modules/openxr/editor/openxr_action_map_editor.cpp index 937973f3887..51e6c3e2773 100644 --- a/modules/openxr/editor/openxr_action_map_editor.cpp +++ b/modules/openxr/editor/openxr_action_map_editor.cpp @@ -248,7 +248,7 @@ void OpenXRActionMapEditor::_on_interaction_profile_selected(const String p_path void OpenXRActionMapEditor::_load_action_map(const String p_path, bool p_create_new_if_missing) { Error err = OK; - action_map = ResourceLoader::load(p_path, "", ResourceFormatLoader::CACHE_MODE_IGNORE, &err); + action_map = ResourceLoader::load(p_path, "", ResourceFormatLoader::CACHE_MODE_REUSE, &err); if (err != OK) { if ((err == ERR_FILE_NOT_FOUND || err == ERR_CANT_OPEN) && p_create_new_if_missing) { action_map.instantiate(); @@ -257,10 +257,16 @@ void OpenXRActionMapEditor::_load_action_map(const String p_path, bool p_create_ // Save it immediately err = ResourceSaver::save(action_map, p_path); if (err != OK) { - // show warning but continue + // Show warning but continue. EditorNode::get_singleton()->show_warning(vformat(TTR("Error saving file %s: %s"), edited_path, error_names[err])); + } else { + // Reload so it's cached. + action_map = ResourceLoader::load(p_path, "", ResourceFormatLoader::CACHE_MODE_REUSE, &err); + if (err != OK) { + // Show warning but continue. + EditorNode::get_singleton()->show_warning(vformat(TTR("Error reloading file %s: %s"), edited_path, error_names[err])); + } } - } else { EditorNode::get_singleton()->show_warning(vformat(TTR("Error loading %s: %s."), edited_path, error_names[err]));