summaryrefslogtreecommitdiffstats
path: root/modules/openxr/register_types.cpp
diff options
context:
space:
mode:
authorBastiaan Olij <mux213@gmail.com>2022-11-12 01:59:22 +1100
committerBastiaan Olij <mux213@gmail.com>2022-11-25 20:26:30 +1100
commit96bbdf72490971d886f6ce57476f11bb14523f15 (patch)
tree61519b914686c23f0d996bb10c2af00cb8e3c30a /modules/openxr/register_types.cpp
parent7580565c28e7e10db7f551287e1f91cfd614b195 (diff)
downloadredot-engine-96bbdf72490971d886f6ce57476f11bb14523f15.tar.gz
Various fixes for OpenXR action map meta data and editing
Diffstat (limited to 'modules/openxr/register_types.cpp')
-rw-r--r--modules/openxr/register_types.cpp22
1 files changed, 19 insertions, 3 deletions
diff --git a/modules/openxr/register_types.cpp b/modules/openxr/register_types.cpp
index 5694fffe39..0835bbd642 100644
--- a/modules/openxr/register_types.cpp
+++ b/modules/openxr/register_types.cpp
@@ -37,9 +37,14 @@
#include "action_map/openxr_action_map.h"
#include "action_map/openxr_action_set.h"
#include "action_map/openxr_interaction_profile.h"
+#include "action_map/openxr_interaction_profile_meta_data.h"
#include "scene/openxr_hand.h"
+static OpenXRAPI *openxr_api = nullptr;
+static OpenXRInteractionProfileMetaData *openxr_interaction_profile_meta_data = nullptr;
+static Ref<OpenXRInterface> openxr_interface;
+
#ifdef TOOLS_ENABLED
#include "editor/editor_node.h"
@@ -49,6 +54,12 @@ static void _editor_init() {
if (OpenXRAPI::openxr_is_enabled(false)) {
// Only add our OpenXR action map editor if OpenXR is enabled for our project
+ if (openxr_interaction_profile_meta_data == nullptr) {
+ // If we didn't initialize our actionmap meta data at startup, we initialise it now.
+ openxr_interaction_profile_meta_data = memnew(OpenXRInteractionProfileMetaData);
+ ERR_FAIL_NULL(openxr_interaction_profile_meta_data);
+ }
+
OpenXREditorPlugin *openxr_plugin = memnew(OpenXREditorPlugin());
EditorNode::get_singleton()->add_editor_plugin(openxr_plugin);
}
@@ -56,14 +67,13 @@ static void _editor_init() {
#endif
-static OpenXRAPI *openxr_api = nullptr;
-static Ref<OpenXRInterface> openxr_interface;
-
void initialize_openxr_module(ModuleInitializationLevel p_level) {
if (p_level == MODULE_INITIALIZATION_LEVEL_SERVERS) {
// For now we create our openxr device here. If we merge it with openxr_interface we'll create that here soon.
if (OpenXRAPI::openxr_is_enabled()) {
+ openxr_interaction_profile_meta_data = memnew(OpenXRInteractionProfileMetaData);
+ ERR_FAIL_NULL(openxr_interaction_profile_meta_data);
openxr_api = memnew(OpenXRAPI);
ERR_FAIL_NULL(openxr_api);
@@ -81,6 +91,7 @@ void initialize_openxr_module(ModuleInitializationLevel p_level) {
GDREGISTER_CLASS(OpenXRAction);
GDREGISTER_CLASS(OpenXRActionSet);
GDREGISTER_CLASS(OpenXRActionMap);
+ GDREGISTER_CLASS(OpenXRInteractionProfileMetaData);
GDREGISTER_CLASS(OpenXRIPBinding);
GDREGISTER_CLASS(OpenXRInteractionProfile);
@@ -131,4 +142,9 @@ void uninitialize_openxr_module(ModuleInitializationLevel p_level) {
memdelete(openxr_api);
openxr_api = nullptr;
}
+
+ if (openxr_interaction_profile_meta_data) {
+ memdelete(openxr_interaction_profile_meta_data);
+ openxr_interaction_profile_meta_data = nullptr;
+ }
}