From 1efaa0681d5e13eb46928f5ccc52119f436140b5 Mon Sep 17 00:00:00 2001 From: Mamadou Babaei Date: Thu, 19 Feb 2026 18:28:39 +0100 Subject: [PATCH] add a new FSGHandLayer::GetWristLocation() overload which allows passing FRotator instead of FQuat as input or output parameters --- Handbook/src/appendix/changelog.md | 1 + .../Private/SGCore/SGHandLayer.cpp | 19 +++++++++++++++++++ .../Public/SGCore/SGHandLayer.h | 17 +++++++++++++++++ .../SGCoreKismet/SGHandLayerKismetLibrary.cpp | 19 +++++++++++++++---- .../SGCoreKismet/SGHandLayerKismetLibrary.h | 14 ++++++++++++-- 5 files changed, 64 insertions(+), 6 deletions(-) diff --git a/Handbook/src/appendix/changelog.md b/Handbook/src/appendix/changelog.md index 15e07362..7be5c166 100644 --- a/Handbook/src/appendix/changelog.md +++ b/Handbook/src/appendix/changelog.md @@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Added a `USGHapticsComponent` to allow sending a variety of haptic feedbacks (force-feedback, vibrotactile, custom waveforms, and wrist-squeeze) to the gloves without touching SenseGlove's low-level API. - Added a `USGHandTrackerComponent` to allow retrieval or visualization of `FXRHandTrackingState` without relying on low-level SenseGlove API or UE's generic `GetHandTrackingState()` functionality. This is useful when developing a custom hand-interaction system using SenseGlove/UE OpenXR API or interfacing with third-party OpenXR-compatible plugins such as [VR Expansion Plugin (VRE)](https://vreue4.com/). Using this component removes the need to calculate the wrist offsets manually, or an extra call to `USGHapticGlove::GetWristLocation()`, in comparison to when the `FXRHandTrackingState` is retrieved via UE's `GetHandTrackingState()`. - A new `FSGDebugVirtualHand::Draw()` overload has been added to allow visualizing `FSGDebugGizmoSettings` directly. This is used internally by the new `USGHandTrackerComponent` to visualize its `FXRHandTrackingState` if `bVisualize` is enabled. +- Added a new `FSGHandLayer::GetWristLocation()` overload to allow passing `FRotator`s instead of `FQuat`s as input or output parameters. ### Fixed diff --git a/Source/SenseGloveCore/Private/SGCore/SGHandLayer.cpp b/Source/SenseGloveCore/Private/SGCore/SGHandLayer.cpp index b95ddb62..77324b19 100644 --- a/Source/SenseGloveCore/Private/SGCore/SGHandLayer.cpp +++ b/Source/SenseGloveCore/Private/SGCore/SGHandLayer.cpp @@ -132,6 +132,25 @@ void FSGHandLayer::GetWristLocation( OutWristRotation = MoveTemp(OutWristRotationContainer.Quat); } +void FSGHandLayer::GetWristLocation( + const bool bRightHanded, const FVector& ReferencePosition, const FRotator& ReferenceRotation, + ESGPositionalTrackingHardware TrackingHardware, FVector& OutWristPosition, FRotator& OutWristRotation) +{ + FSGIC_FVector ReferencePositionContainer{ReferencePosition}; + FSGIC_FQuat ReferenceRotationContainer{ReferenceRotation.Quaternion()}; + FSGIC_ESGPositionalTrackingHardware TrackingHardwareContainer{TrackingHardware}; + FSGIC_FVector OutWristPositionContainer; + FSGIC_FQuat OutWristRotationContainer; + + SGCoreImpl_FSGHandLayerImpl_GetWristLocation( + bRightHanded, &ReferencePositionContainer, &ReferenceRotationContainer, + &TrackingHardwareContainer, + &OutWristPositionContainer, &OutWristRotationContainer); + + OutWristPosition = MoveTemp(OutWristPositionContainer.Vector); + OutWristRotation = OutWristRotationContainer.Quat.Rotator(); +} + void FSGHandLayer::StopAllHaptics(const bool bRightHanded) { SGCoreImpl_FSGHandLayerImpl_StopAllHaptics(bRightHanded); diff --git a/Source/SenseGloveCore/Public/SGCore/SGHandLayer.h b/Source/SenseGloveCore/Public/SGCore/SGHandLayer.h index 6ab7f168..a5348710 100644 --- a/Source/SenseGloveCore/Public/SGCore/SGHandLayer.h +++ b/Source/SenseGloveCore/Public/SGCore/SGHandLayer.h @@ -42,6 +42,7 @@ #include "Containers/UnrealString.h" #include "HAL/Platform.h" #include "Math/Quat.h" +#include "Math/Rotator.h" #include "Math/Vector.h" #include "UObject/ObjectMacros.h" @@ -148,6 +149,22 @@ public: ESGPositionalTrackingHardware TrackingHardware, FVector& OutWristPosition, FQuat& OutWristRotation); + /** + * Calculate the Wrist Location of the chosen hand, based on a reference location and tracking hardware. + * + * @param bRightHanded + * @param ReferencePosition + * @param ReferenceRotation + * @param TrackingHardware + * @param OutWristPosition + * @param OutWristRotation + */ + static void GetWristLocation( + bool bRightHanded, + const FVector& ReferencePosition, const FRotator& ReferenceRotation, + ESGPositionalTrackingHardware TrackingHardware, + FVector& OutWristPosition, FRotator& OutWristRotation); + /** * Stop all haptics on the chosen hand. * diff --git a/Source/SenseGloveCoreKismet/Private/SGCoreKismet/SGHandLayerKismetLibrary.cpp b/Source/SenseGloveCoreKismet/Private/SGCoreKismet/SGHandLayerKismetLibrary.cpp index a06b05bc..9a54e13b 100644 --- a/Source/SenseGloveCoreKismet/Private/SGCoreKismet/SGHandLayerKismetLibrary.cpp +++ b/Source/SenseGloveCoreKismet/Private/SGCoreKismet/SGHandLayerKismetLibrary.cpp @@ -91,10 +91,21 @@ bool USGHandLayerKismetLibrary::GetHandPose(UObject* WorldContextObject, return FSGHandLayer::GetHandPose(WorldContextObject, bRightHanded, OutHandPose); } -void USGHandLayerKismetLibrary::GetWristLocation(const bool bRightHanded, - const FVector& ReferencePosition, const FQuat& ReferenceRotation, - const ESGPositionalTrackingHardware TrackingHardware, - FVector& OutWristPosition, FQuat& OutWristRotation) +void USGHandLayerKismetLibrary::GetWristLocation_bRH_FQuat_RR_TH_OutWP_OutWR( + const bool bRightHanded, + const FVector& ReferencePosition, const FQuat& ReferenceRotation, + ESGPositionalTrackingHardware TrackingHardware, + FVector& OutWristPosition, FQuat& OutWristRotation) +{ + FSGHandLayer::GetWristLocation(bRightHanded, ReferencePosition, ReferenceRotation, TrackingHardware, + OutWristPosition, OutWristRotation); +} + +void USGHandLayerKismetLibrary::GetWristLocation_bRH_RP_FRotator_RR_TH_OutWP_OutWR( + const bool bRightHanded, + const FVector& ReferencePosition, const FRotator& ReferenceRotation, + ESGPositionalTrackingHardware TrackingHardware, + FVector& OutWristPosition, FRotator& OutWristRotation) { FSGHandLayer::GetWristLocation(bRightHanded, ReferencePosition, ReferenceRotation, TrackingHardware, OutWristPosition, OutWristRotation); diff --git a/Source/SenseGloveCoreKismet/Public/SGCoreKismet/SGHandLayerKismetLibrary.h b/Source/SenseGloveCoreKismet/Public/SGCoreKismet/SGHandLayerKismetLibrary.h index 9401d5a3..69b10b2d 100644 --- a/Source/SenseGloveCoreKismet/Public/SGCoreKismet/SGHandLayerKismetLibrary.h +++ b/Source/SenseGloveCoreKismet/Public/SGCoreKismet/SGHandLayerKismetLibrary.h @@ -122,13 +122,23 @@ public: /** * Calculate the Wrist Location of the chosen hand, based on a reference location and tracking hardware. */ - UFUNCTION(BlueprintCallable, Category="SenseGlove | Core | Hand Layer") - static void GetWristLocation( + UFUNCTION(BlueprintCallable, DisplayName="Get Wrist Location", Category="SenseGlove | Core | Hand Layer") + static void GetWristLocation_bRH_FQuat_RR_TH_OutWP_OutWR( bool bRightHanded, const FVector& ReferencePosition, const FQuat& ReferenceRotation, ESGPositionalTrackingHardware TrackingHardware, FVector& OutWristPosition, FQuat& OutWristRotation); + /** + * Calculate the Wrist Location of the chosen hand, based on a reference location and tracking hardware. + */ + UFUNCTION(BlueprintCallable, DisplayName="Get Wrist Location", Category="SenseGlove | Core | Hand Layer") + static void GetWristLocation_bRH_RP_FRotator_RR_TH_OutWP_OutWR( + bool bRightHanded, + const FVector& ReferencePosition, const FRotator& ReferenceRotation, + ESGPositionalTrackingHardware TrackingHardware, + FVector& OutWristPosition, FRotator& OutWristRotation); + /** * Stop all haptics on the chosen hand. */