Skip to content

Commit f990050

Browse files
committed
Expose OpenXRInteractionProfileMetadata singleton
1 parent 456bdea commit f990050

32 files changed

Lines changed: 569 additions & 586 deletions
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
GH-117399
2+
--------------
3+
4+
Validate extension JSON: JSON file: Field was added in a way that breaks compatibility 'classes/OpenXRExtensionWrapper/methods/_on_register_metadata': arguments
5+
6+
Added OpenXRInteractionProfileMetadata parameter to function.

modules/openxr/action_map/openxr_interaction_profile_metadata.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ OpenXRInteractionProfileMetadata::OpenXRInteractionProfileMetadata() {
4040
singleton = this;
4141

4242
_register_core_metadata();
43-
OpenXRAPI::register_extension_metadata();
43+
OpenXRAPI::register_extension_metadata(this);
4444
}
4545

4646
OpenXRInteractionProfileMetadata::~OpenXRInteractionProfileMetadata() {

modules/openxr/doc_classes/OpenXRExtensionWrapper.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@
136136
</method>
137137
<method name="_on_register_metadata" qualifiers="virtual">
138138
<return type="void" />
139+
<param index="0" name="interaction_profile_metadata" type="OpenXRInteractionProfileMetadata" />
139140
<description>
140141
Allows extensions to register additional controller metadata. This function is called even when the OpenXR API is not constructed as the metadata needs to be available to the editor.
141142
Extensions should also provide metadata regardless of whether they are supported on the host system. The controller data is used to setup action maps for users who may have access to the relevant hardware.

modules/openxr/extensions/openxr_extension_wrapper.cpp

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ void OpenXRExtensionWrapper::_bind_methods() {
5555
GDVIRTUAL_BIND(_get_composition_layer, "index");
5656
GDVIRTUAL_BIND(_get_composition_layer_order, "index");
5757
GDVIRTUAL_BIND(_get_suggested_tracker_names);
58-
GDVIRTUAL_BIND(_on_register_metadata);
58+
GDVIRTUAL_BIND(_on_register_metadata, "interaction_profile_metadata");
5959
GDVIRTUAL_BIND(_on_before_instance_created);
6060
GDVIRTUAL_BIND(_on_instance_created, "instance");
6161
GDVIRTUAL_BIND(_on_instance_destroyed);
@@ -85,6 +85,7 @@ void OpenXRExtensionWrapper::_bind_methods() {
8585
#ifndef DISABLE_DEPRECATED
8686
GDVIRTUAL_BIND_COMPAT(_get_requested_extensions_bind_compat_109302);
8787
GDVIRTUAL_BIND_COMPAT(_set_instance_create_info_and_get_next_pointer_bind_compat_109302, "next_pointer");
88+
GDVIRTUAL_BIND_COMPAT(_on_register_metadata_bind_compat_117399);
8889
#endif
8990

9091
ClassDB::bind_method(D_METHOD("get_openxr_api"), &OpenXRExtensionWrapper::_gdextension_get_openxr_api);
@@ -283,8 +284,14 @@ int OpenXRExtensionWrapper::get_composition_layer_order(int p_index) {
283284
return order;
284285
}
285286

286-
void OpenXRExtensionWrapper::on_register_metadata() {
287-
GDVIRTUAL_CALL(_on_register_metadata);
287+
void OpenXRExtensionWrapper::on_register_metadata(OpenXRInteractionProfileMetadata *p_interaction_profile_metadata) {
288+
if (GDVIRTUAL_CALL(_on_register_metadata, p_interaction_profile_metadata)) {
289+
return;
290+
}
291+
292+
#ifndef DISABLE_DEPRECATED
293+
GDVIRTUAL_CALL(_on_register_metadata_bind_compat_117399);
294+
#endif
288295
}
289296

290297
void OpenXRExtensionWrapper::on_before_instance_created() {

modules/openxr/extensions/openxr_extension_wrapper.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@
3030

3131
#pragma once
3232

33+
#include "../action_map/openxr_interaction_profile_metadata.h"
34+
3335
#include "core/error/error_macros.h"
3436
#include "core/math/projection.h"
3537
#include "core/object/gdvirtual.gen.h"
@@ -116,6 +118,7 @@ class OpenXRExtensionWrapper : public Object {
116118
#ifndef DISABLE_DEPRECATED
117119
GDVIRTUAL0R_COMPAT(_get_requested_extensions_bind_compat_109302, Dictionary, _get_requested_extensions);
118120
GDVIRTUAL1R_COMPAT(_set_instance_create_info_and_get_next_pointer_bind_compat_109302, uint64_t, _set_instance_create_info_and_get_next_pointer, GDExtensionPtr<void>);
121+
GDVIRTUAL0_COMPAT(_on_register_metadata_bind_compat_117399, _on_register_metadata);
119122
#endif
120123

121124
virtual PackedStringArray get_suggested_tracker_names();
@@ -128,7 +131,7 @@ class OpenXRExtensionWrapper : public Object {
128131
// Also extensions should provide metadata regardless of whether they are supported
129132
// on the host system as the controller data is used to setup action maps for users
130133
// who may have access to the relevant hardware.
131-
virtual void on_register_metadata();
134+
virtual void on_register_metadata(OpenXRInteractionProfileMetadata *p_interaction_profile_metadata);
132135

133136
virtual void on_before_instance_created(); // `on_before_instance_created` is called before we create our OpenXR instance.
134137
virtual void on_instance_created(const XrInstance p_instance); // `on_instance_created` is called right after we've successfully created our OpenXR instance.
@@ -146,7 +149,7 @@ class OpenXRExtensionWrapper : public Object {
146149
virtual void on_pre_draw_viewport(RID p_render_target); // `on_pre_draw_viewport` is called right before we start rendering this viewport
147150
virtual void on_post_draw_viewport(RID p_render_target); // `on_port_draw_viewport` is called right after we start rendering this viewport (note that on Vulkan draw commands may only be queued)
148151

149-
GDVIRTUAL0(_on_register_metadata);
152+
GDVIRTUAL1(_on_register_metadata, OpenXRInteractionProfileMetadata *);
150153
GDVIRTUAL0(_on_before_instance_created);
151154
GDVIRTUAL1(_on_instance_created, uint64_t);
152155
GDVIRTUAL0(_on_instance_destroyed);

modules/openxr/extensions/openxr_eye_gaze_interaction.cpp

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -96,16 +96,13 @@ bool OpenXREyeGazeInteractionExtension::supports_eye_gaze_interaction() {
9696
return false;
9797
}
9898

99-
void OpenXREyeGazeInteractionExtension::on_register_metadata() {
100-
OpenXRInteractionProfileMetadata *openxr_metadata = OpenXRInteractionProfileMetadata::get_singleton();
101-
ERR_FAIL_NULL(openxr_metadata);
102-
99+
void OpenXREyeGazeInteractionExtension::on_register_metadata(OpenXRInteractionProfileMetadata *p_interaction_profile_metadata) {
103100
// Eyes top path
104-
openxr_metadata->register_top_level_path("Eye gaze tracker", "/user/eyes_ext", XR_EXT_EYE_GAZE_INTERACTION_EXTENSION_NAME);
101+
p_interaction_profile_metadata->register_top_level_path("Eye gaze tracker", "/user/eyes_ext", XR_EXT_EYE_GAZE_INTERACTION_EXTENSION_NAME);
105102

106103
// Eye gaze interaction
107-
openxr_metadata->register_interaction_profile("Eye gaze", "/interaction_profiles/ext/eye_gaze_interaction", XR_EXT_EYE_GAZE_INTERACTION_EXTENSION_NAME);
108-
openxr_metadata->register_io_path("/interaction_profiles/ext/eye_gaze_interaction", "Gaze pose", "/user/eyes_ext", "/user/eyes_ext/input/gaze_ext/pose", "", OpenXRAction::OPENXR_ACTION_POSE);
104+
p_interaction_profile_metadata->register_interaction_profile("Eye gaze", "/interaction_profiles/ext/eye_gaze_interaction", XR_EXT_EYE_GAZE_INTERACTION_EXTENSION_NAME);
105+
p_interaction_profile_metadata->register_io_path("/interaction_profiles/ext/eye_gaze_interaction", "Gaze pose", "/user/eyes_ext", "/user/eyes_ext/input/gaze_ext/pose", "", OpenXRAction::OPENXR_ACTION_POSE);
109106
}
110107

111108
bool OpenXREyeGazeInteractionExtension::get_eye_gaze_pose(double p_dist, Vector3 &r_eye_pose) {

modules/openxr/extensions/openxr_eye_gaze_interaction.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class OpenXREyeGazeInteractionExtension : public OpenXRExtensionWrapper {
5252
bool is_available();
5353
bool supports_eye_gaze_interaction();
5454

55-
virtual void on_register_metadata() override;
55+
virtual void on_register_metadata(OpenXRInteractionProfileMetadata *p_interaction_profile_metadata) override;
5656

5757
bool get_eye_gaze_pose(double p_dist, Vector3 &r_eye_pose);
5858

modules/openxr/extensions/openxr_hand_interaction_extension.cpp

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -68,34 +68,31 @@ bool OpenXRHandInteractionExtension::is_available() {
6868
return available;
6969
}
7070

71-
void OpenXRHandInteractionExtension::on_register_metadata() {
72-
OpenXRInteractionProfileMetadata *openxr_metadata = OpenXRInteractionProfileMetadata::get_singleton();
73-
ERR_FAIL_NULL(openxr_metadata);
74-
71+
void OpenXRHandInteractionExtension::on_register_metadata(OpenXRInteractionProfileMetadata *p_interaction_profile_metadata) {
7572
// Hand interaction profile.
7673
const String profile_path = "/interaction_profiles/ext/hand_interaction_ext";
77-
openxr_metadata->register_interaction_profile("Hand interaction", profile_path, XR_EXT_HAND_INTERACTION_EXTENSION_NAME);
74+
p_interaction_profile_metadata->register_interaction_profile("Hand interaction", profile_path, XR_EXT_HAND_INTERACTION_EXTENSION_NAME);
7875
for (const String user_path : { "/user/hand/left", "/user/hand/right" }) {
79-
openxr_metadata->register_io_path(profile_path, "Grip pose", user_path, user_path + "/input/grip/pose", "", OpenXRAction::OPENXR_ACTION_POSE);
80-
openxr_metadata->register_io_path(profile_path, "Aim pose", user_path, user_path + "/input/aim/pose", "", OpenXRAction::OPENXR_ACTION_POSE);
81-
openxr_metadata->register_io_path(profile_path, "Pinch pose", user_path, user_path + "/input/pinch_ext/pose", "", OpenXRAction::OPENXR_ACTION_POSE);
82-
openxr_metadata->register_io_path(profile_path, "Poke pose", user_path, user_path + "/input/poke_ext/pose", "", OpenXRAction::OPENXR_ACTION_POSE);
83-
openxr_metadata->register_io_path(profile_path, "Grip surface pose", user_path, user_path + "/input/grip_surface/pose", XR_EXT_PALM_POSE_EXTENSION_NAME "," XR_KHR_MAINTENANCE1_EXTENSION_NAME "," XR_OPENXR_1_1_NAME, OpenXRAction::OPENXR_ACTION_POSE);
76+
p_interaction_profile_metadata->register_io_path(profile_path, "Grip pose", user_path, user_path + "/input/grip/pose", "", OpenXRAction::OPENXR_ACTION_POSE);
77+
p_interaction_profile_metadata->register_io_path(profile_path, "Aim pose", user_path, user_path + "/input/aim/pose", "", OpenXRAction::OPENXR_ACTION_POSE);
78+
p_interaction_profile_metadata->register_io_path(profile_path, "Pinch pose", user_path, user_path + "/input/pinch_ext/pose", "", OpenXRAction::OPENXR_ACTION_POSE);
79+
p_interaction_profile_metadata->register_io_path(profile_path, "Poke pose", user_path, user_path + "/input/poke_ext/pose", "", OpenXRAction::OPENXR_ACTION_POSE);
80+
p_interaction_profile_metadata->register_io_path(profile_path, "Grip surface pose", user_path, user_path + "/input/grip_surface/pose", XR_EXT_PALM_POSE_EXTENSION_NAME "," XR_KHR_MAINTENANCE1_EXTENSION_NAME "," XR_OPENXR_1_1_NAME, OpenXRAction::OPENXR_ACTION_POSE);
8481

85-
openxr_metadata->register_io_path(profile_path, "Pinch", user_path, user_path + "/input/pinch_ext/value", "", OpenXRAction::OPENXR_ACTION_FLOAT);
86-
openxr_metadata->register_io_path(profile_path, "Pinch ready", user_path, user_path + "/input/pinch_ext/ready_ext", "", OpenXRAction::OPENXR_ACTION_BOOL);
82+
p_interaction_profile_metadata->register_io_path(profile_path, "Pinch", user_path, user_path + "/input/pinch_ext/value", "", OpenXRAction::OPENXR_ACTION_FLOAT);
83+
p_interaction_profile_metadata->register_io_path(profile_path, "Pinch ready", user_path, user_path + "/input/pinch_ext/ready_ext", "", OpenXRAction::OPENXR_ACTION_BOOL);
8784

88-
openxr_metadata->register_io_path(profile_path, "Aim activate", user_path, user_path + "/input/aim_activate_ext/value", "", OpenXRAction::OPENXR_ACTION_FLOAT);
89-
openxr_metadata->register_io_path(profile_path, "Aim activate ready", user_path, user_path + "/input/aim_activate_ext/ready_ext", "", OpenXRAction::OPENXR_ACTION_BOOL);
85+
p_interaction_profile_metadata->register_io_path(profile_path, "Aim activate", user_path, user_path + "/input/aim_activate_ext/value", "", OpenXRAction::OPENXR_ACTION_FLOAT);
86+
p_interaction_profile_metadata->register_io_path(profile_path, "Aim activate ready", user_path, user_path + "/input/aim_activate_ext/ready_ext", "", OpenXRAction::OPENXR_ACTION_BOOL);
9087

91-
openxr_metadata->register_io_path(profile_path, "Grasp", user_path, user_path + "/input/grasp_ext/value", "", OpenXRAction::OPENXR_ACTION_FLOAT);
92-
openxr_metadata->register_io_path(profile_path, "Grasp ready", user_path, user_path + "/input/grasp_ext/ready_ext", "", OpenXRAction::OPENXR_ACTION_BOOL);
88+
p_interaction_profile_metadata->register_io_path(profile_path, "Grasp", user_path, user_path + "/input/grasp_ext/value", "", OpenXRAction::OPENXR_ACTION_FLOAT);
89+
p_interaction_profile_metadata->register_io_path(profile_path, "Grasp ready", user_path, user_path + "/input/grasp_ext/ready_ext", "", OpenXRAction::OPENXR_ACTION_BOOL);
9390

9491
// Hand tracking microgestures.
95-
openxr_metadata->register_io_path(profile_path, "Swipe left", user_path, user_path + "/input/swipe_left_meta/click", "XR_META_hand_tracking_microgestures", OpenXRAction::OPENXR_ACTION_BOOL);
96-
openxr_metadata->register_io_path(profile_path, "Swipe right", user_path, user_path + "/input/swipe_right_meta/click", "XR_META_hand_tracking_microgestures", OpenXRAction::OPENXR_ACTION_BOOL);
97-
openxr_metadata->register_io_path(profile_path, "Swipe forward", user_path, user_path + "/input/swipe_forward_meta/click", "XR_META_hand_tracking_microgestures", OpenXRAction::OPENXR_ACTION_BOOL);
98-
openxr_metadata->register_io_path(profile_path, "Swipe backward", user_path, user_path + "/input/swipe_backward_meta/click", "XR_META_hand_tracking_microgestures", OpenXRAction::OPENXR_ACTION_BOOL);
99-
openxr_metadata->register_io_path(profile_path, "Tap thumb", user_path, user_path + "/input/tap_thumb_meta/click", "XR_META_hand_tracking_microgestures", OpenXRAction::OPENXR_ACTION_BOOL);
92+
p_interaction_profile_metadata->register_io_path(profile_path, "Swipe left", user_path, user_path + "/input/swipe_left_meta/click", "XR_META_hand_tracking_microgestures", OpenXRAction::OPENXR_ACTION_BOOL);
93+
p_interaction_profile_metadata->register_io_path(profile_path, "Swipe right", user_path, user_path + "/input/swipe_right_meta/click", "XR_META_hand_tracking_microgestures", OpenXRAction::OPENXR_ACTION_BOOL);
94+
p_interaction_profile_metadata->register_io_path(profile_path, "Swipe forward", user_path, user_path + "/input/swipe_forward_meta/click", "XR_META_hand_tracking_microgestures", OpenXRAction::OPENXR_ACTION_BOOL);
95+
p_interaction_profile_metadata->register_io_path(profile_path, "Swipe backward", user_path, user_path + "/input/swipe_backward_meta/click", "XR_META_hand_tracking_microgestures", OpenXRAction::OPENXR_ACTION_BOOL);
96+
p_interaction_profile_metadata->register_io_path(profile_path, "Tap thumb", user_path, user_path + "/input/tap_thumb_meta/click", "XR_META_hand_tracking_microgestures", OpenXRAction::OPENXR_ACTION_BOOL);
10097
}
10198
}

modules/openxr/extensions/openxr_hand_interaction_extension.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@
4949
// See: https://registry.khronos.org/OpenXR/specs/1.0/html/xrspec.html#XR_EXT_hand_interaction
5050
// for more information.
5151

52+
class OpenXRInteractionProfileMetadata;
53+
5254
class OpenXRHandInteractionExtension : public OpenXRExtensionWrapper {
5355
GDCLASS(OpenXRHandInteractionExtension, OpenXRExtensionWrapper);
5456

@@ -65,7 +67,7 @@ class OpenXRHandInteractionExtension : public OpenXRExtensionWrapper {
6567

6668
bool is_available();
6769

68-
virtual void on_register_metadata() override;
70+
virtual void on_register_metadata(OpenXRInteractionProfileMetadata *p_interaction_profile_metadata) override;
6971

7072
private:
7173
static OpenXRHandInteractionExtension *singleton;

0 commit comments

Comments
 (0)