diff --git a/modules/openxr/doc_classes/OpenXRAPIExtension.xml b/modules/openxr/doc_classes/OpenXRAPIExtension.xml index 2f1f472a7ef..f737f3b6422 100644 --- a/modules/openxr/doc_classes/OpenXRAPIExtension.xml +++ b/modules/openxr/doc_classes/OpenXRAPIExtension.xml @@ -30,6 +30,13 @@ Returns an error string for the given [url=https://registry.khronos.org/OpenXR/specs/1.0/man/html/XrResult.html]XrResult[/url]. + + + + + Returns the corresponding [code]XRHandTrackerEXT[/code] handle for the given hand index value. + + diff --git a/modules/openxr/openxr_api.cpp b/modules/openxr/openxr_api.cpp index 36c3faaf750..ccf97662e29 100644 --- a/modules/openxr/openxr_api.cpp +++ b/modules/openxr/openxr_api.cpp @@ -57,6 +57,7 @@ #include "extensions/openxr_fb_display_refresh_rate_extension.h" #include "extensions/openxr_fb_foveation_extension.h" #include "extensions/openxr_fb_update_swapchain_extension.h" +#include "extensions/openxr_hand_tracking_extension.h" #ifdef ANDROID_ENABLED #define OPENXR_LOADER_NAME "libopenxr_loader.so" @@ -1536,6 +1537,12 @@ void OpenXRAPI::cleanup_extension_wrappers() { registered_extension_wrappers.clear(); } +XrHandTrackerEXT OpenXRAPI::get_hand_tracker(int p_hand_index) { + ERR_FAIL_INDEX_V(p_hand_index, OpenXRHandTrackingExtension::HandTrackedHands::OPENXR_MAX_TRACKED_HANDS, XR_NULL_HANDLE); + OpenXRHandTrackingExtension::HandTrackedHands hand = static_cast(p_hand_index); + return OpenXRHandTrackingExtension::get_singleton()->get_hand_tracker(hand)->hand_tracker; +} + Size2 OpenXRAPI::get_recommended_target_size() { ERR_FAIL_NULL_V(view_configuration_views, Size2()); diff --git a/modules/openxr/openxr_api.h b/modules/openxr/openxr_api.h index d39e6e0b2ee..d3e6eb01cee 100644 --- a/modules/openxr/openxr_api.h +++ b/modules/openxr/openxr_api.h @@ -359,6 +359,8 @@ public: XrTime get_next_frame_time() { return frame_state.predictedDisplayTime + frame_state.predictedDisplayPeriod; } bool can_render() { return instance != XR_NULL_HANDLE && session != XR_NULL_HANDLE && running && view_pose_valid && frame_state.shouldRender; } + XrHandTrackerEXT get_hand_tracker(int p_hand_index); + Size2 get_recommended_target_size(); XRPose::TrackingConfidence get_head_center(Transform3D &r_transform, Vector3 &r_linear_velocity, Vector3 &r_angular_velocity); bool get_view_transform(uint32_t p_view, Transform3D &r_transform); diff --git a/modules/openxr/openxr_api_extension.cpp b/modules/openxr/openxr_api_extension.cpp index d9e282e218c..fae0fc13d35 100644 --- a/modules/openxr/openxr_api_extension.cpp +++ b/modules/openxr/openxr_api_extension.cpp @@ -51,6 +51,8 @@ void OpenXRAPIExtension::_bind_methods() { ClassDB::bind_method(D_METHOD("get_next_frame_time"), &OpenXRAPIExtension::get_next_frame_time); ClassDB::bind_method(D_METHOD("can_render"), &OpenXRAPIExtension::can_render); + ClassDB::bind_method(D_METHOD("get_hand_tracker", "hand_index"), &OpenXRAPIExtension::get_hand_tracker); + ClassDB::bind_method(D_METHOD("register_composition_layer_provider", "extension"), &OpenXRAPIExtension::register_composition_layer_provider); ClassDB::bind_method(D_METHOD("unregister_composition_layer_provider", "extension"), &OpenXRAPIExtension::unregister_composition_layer_provider); @@ -138,6 +140,11 @@ bool OpenXRAPIExtension::can_render() { return OpenXRAPI::get_singleton()->can_render(); } +uint64_t OpenXRAPIExtension::get_hand_tracker(int p_hand_index) { + ERR_FAIL_NULL_V(OpenXRAPI::get_singleton(), 0); + return (uint64_t)OpenXRAPI::get_singleton()->get_hand_tracker(p_hand_index); +} + void OpenXRAPIExtension::register_composition_layer_provider(OpenXRExtensionWrapperExtension *p_extension) { ERR_FAIL_NULL(OpenXRAPI::get_singleton()); OpenXRAPI::get_singleton()->register_composition_layer_provider(p_extension); diff --git a/modules/openxr/openxr_api_extension.h b/modules/openxr/openxr_api_extension.h index 82344c1d060..576e497798f 100644 --- a/modules/openxr/openxr_api_extension.h +++ b/modules/openxr/openxr_api_extension.h @@ -72,6 +72,8 @@ public: int64_t get_next_frame_time(); bool can_render(); + uint64_t get_hand_tracker(int p_hand_index); + void register_composition_layer_provider(OpenXRExtensionWrapperExtension *p_extension); void unregister_composition_layer_provider(OpenXRExtensionWrapperExtension *p_extension);