From 0f8197efebd1c06c239abce1789beb1e5cf48d71 Mon Sep 17 00:00:00 2001 From: Mamadou Babaei Date: Tue, 13 Jun 2023 19:57:04 +0200 Subject: [PATCH] fix a bug where SteamVR trackers such as HTC VIVE and HTC VIVE Focus 3's wrist orientation and location were not being tracked. --- CHANGELOG.md | 7 +++- .../Components/SGWristTrackerComponent.cpp | 5 ++- .../Components/SGWristTrackerComponent.h | 39 ++++++++++++++++++- Source/SenseGlove/SenseGlove.Build.cs | 1 + .../SGWristTrackerComponentKismetLibrary.cpp | 24 ++++++++++++ .../SGWristTrackerComponentKismetLibrary.h | 17 +++++++- .../SenseGloveKismet.Build.cs | 1 + 7 files changed, 89 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 00ad2ea9..e86de46e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,12 +13,17 @@ This release breaks ABI/API compatibility with the previous versions in some are - Added support for the Meta Quest Pro positional tracking hardware. - Added HTC VIVE Focus 3 positional tracking hardware enum, though it has not been implemented, yet. +- Added two options to the wrist tracker component in order to be able to specify a custom motion source for the left and right hands in order to enable SteamVR-based trackers such as HTC VIVE or HTC VIVE Focus 3 to work. + +### Fixed + +- Fix a bug where SteamVR trackers such as HTC VIVE and HTC VIVE Focus 3's wrist orientation and location were not being tracked. ### Changed - Fully refactored the top-level configurations in the settings system into USTRUCTs. - SenseGlove libraries have been updated to v2.9.0-21c54c5. -- Change HTC VIVE Tracker enum's display name in order to clarify it has not been implemented, yet. +- Change the HTC VIVE Tracker enum's display name in order to clarify it has not been implemented, yet. ### Removed diff --git a/Source/SenseGlove/Private/SenseGlove/Components/SGWristTrackerComponent.cpp b/Source/SenseGlove/Private/SenseGlove/Components/SGWristTrackerComponent.cpp index c870dad6..98f301af 100644 --- a/Source/SenseGlove/Private/SenseGlove/Components/SGWristTrackerComponent.cpp +++ b/Source/SenseGlove/Private/SenseGlove/Components/SGWristTrackerComponent.cpp @@ -106,6 +106,9 @@ USGWristTrackerComponent::USGWristTrackerComponent(const FObjectInitializer& Obj SetReceivesDecals(false); SetCanEverAffectNavigation(false); + LeftHandMotionSource = EControllerHand::Left; + RightHandMotionSource = EControllerHand::Right; + SetRight(true); bOverridePluginWristTrackingSettings = false; @@ -152,7 +155,7 @@ void USGWristTrackerComponent::SetWristTrackingSettings(const FSGWristTrackingSe void USGWristTrackerComponent::SetRight(const bool bRight) { - SetTrackingSource(bRight ? EControllerHand::Right : EControllerHand::Left); + SetTrackingSource(bRight ? GetRightHandMotionSource() : GetLeftHandMotionSource()); } #if WITH_EDITOR diff --git a/Source/SenseGlove/Public/SenseGlove/Components/SGWristTrackerComponent.h b/Source/SenseGlove/Public/SenseGlove/Components/SGWristTrackerComponent.h index 13e3ef6e..c2b18744 100644 --- a/Source/SenseGlove/Public/SenseGlove/Components/SGWristTrackerComponent.h +++ b/Source/SenseGlove/Public/SenseGlove/Components/SGWristTrackerComponent.h @@ -36,6 +36,7 @@ #pragma once #include "GameFramework/Actor.h" +#include "InputCoreTypes.h" #include "Math/Rotator.h" #include "Math/Vector.h" #include "MotionControllerComponent.h" @@ -94,6 +95,20 @@ private: FImplDeleter PimplDeleter; private: + /** + * Determines which motion source to use. + * For Oculus this is usually Left, and for VIVE usually LeftFoot. + */ + UPROPERTY(EditAnywhere, Category="SenseGlove", meta=(AllowPrivateAccess="false")) + EControllerHand LeftHandMotionSource; + + /** + * Determines which motion source to use. + * For Oculus this is usually Right, and for VIVE usually RightFoot. + */ + UPROPERTY(EditAnywhere, Category="SenseGlove", meta=(AllowPrivateAccess="false")) + EControllerHand RightHandMotionSource; + /** * Determines whether to override the plugin's wrist tracking settings or not. */ @@ -121,6 +136,26 @@ private: FRotator WristRotation; public: + FORCEINLINE EControllerHand GetLeftHandMotionSource() const + { + return LeftHandMotionSource; + } + + void SetLeftHandMotionSource(const EControllerHand InLeftHandMotionSource) + { + LeftHandMotionSource = InLeftHandMotionSource; + } + + FORCEINLINE EControllerHand GetRightHandMotionSource() const + { + return RightHandMotionSource; + } + + void SetRightHandMotionSource(const EControllerHand InRightHandMotionSource) + { + RightHandMotionSource = InRightHandMotionSource; + } + FORCEINLINE bool OverridesPluginWristTrackingSettings() const { return !!bOverridePluginWristTrackingSettings; @@ -136,12 +171,12 @@ public: FORCEINLINE bool IsLeft() const { - return GetTrackingSource() == EControllerHand::Left; + return GetTrackingSource() == GetLeftHandMotionSource(); } FORCEINLINE bool IsRight() const { - return GetTrackingSource() == EControllerHand::Right; + return GetTrackingSource() == GetRightHandMotionSource(); } void SetRight(const bool bRight); diff --git a/Source/SenseGlove/SenseGlove.Build.cs b/Source/SenseGlove/SenseGlove.Build.cs index b328ec42..b8856aec 100644 --- a/Source/SenseGlove/SenseGlove.Build.cs +++ b/Source/SenseGlove/SenseGlove.Build.cs @@ -56,6 +56,7 @@ public class SenseGlove : ModuleRules "CoreUObject", "Engine", "HeadMountedDisplay", + "InputCore", "SenseGloveConnect", "SenseGloveCore", "SenseGloveDebug", diff --git a/Source/SenseGloveKismet/Private/SGKismet/SGWristTrackerComponentKismetLibrary.cpp b/Source/SenseGloveKismet/Private/SGKismet/SGWristTrackerComponentKismetLibrary.cpp index 31d8b1f2..c0e5981b 100644 --- a/Source/SenseGloveKismet/Private/SGKismet/SGWristTrackerComponentKismetLibrary.cpp +++ b/Source/SenseGloveKismet/Private/SGKismet/SGWristTrackerComponentKismetLibrary.cpp @@ -37,6 +37,30 @@ #include "SenseGlove/Components/SGWristTrackerComponent.h" +EControllerHand UWristTrackerComponentKismetLibrary::GetLeftHandMotionSource( + const USGWristTrackerComponent* WristTrackerComponent) +{ + return WristTrackerComponent->GetLeftHandMotionSource(); +} + +void UWristTrackerComponentKismetLibrary::SetLeftHandMotionSource( + USGWristTrackerComponent* WristTrackerComponent, const EControllerHand InLeftHandMotionSource) +{ + WristTrackerComponent->SetLeftHandMotionSource(InLeftHandMotionSource); +} + +EControllerHand UWristTrackerComponentKismetLibrary::GetRightHandMotionSource( + const USGWristTrackerComponent* WristTrackerComponent) +{ + return WristTrackerComponent->GetRightHandMotionSource(); +} + +void UWristTrackerComponentKismetLibrary::SetRightHandMotionSource( + USGWristTrackerComponent* WristTrackerComponent, const EControllerHand InRightHandMotionSource) +{ + WristTrackerComponent->SetRightHandMotionSource(InRightHandMotionSource); +} + bool UWristTrackerComponentKismetLibrary::OverridesPluginWristTrackingSettings( const USGWristTrackerComponent* WristTrackerComponent) { diff --git a/Source/SenseGloveKismet/Public/SGKismet/SGWristTrackerComponentKismetLibrary.h b/Source/SenseGloveKismet/Public/SGKismet/SGWristTrackerComponentKismetLibrary.h index 3c913db6..cb4bd755 100644 --- a/Source/SenseGloveKismet/Public/SGKismet/SGWristTrackerComponentKismetLibrary.h +++ b/Source/SenseGloveKismet/Public/SGKismet/SGWristTrackerComponentKismetLibrary.h @@ -37,8 +37,9 @@ #pragma once -#include "SGKismet/SGBlueprintFunctionLibrary.h" +#include "InputCoreTypes.h" +#include "SGKismet/SGBlueprintFunctionLibrary.h" #include "SGSettings/SGWristTrackingSettings.h" #include "SGWristTrackerComponentKismetLibrary.generated.h" @@ -54,6 +55,20 @@ class SENSEGLOVEKISMET_API UWristTrackerComponentKismetLibrary final : public US GENERATED_BODY() public: + UFUNCTION(BlueprintPure, Category="SenseGlove | Components | Wrist Tracker Component") + static EControllerHand GetLeftHandMotionSource(const USGWristTrackerComponent* WristTrackerComponent); + + UFUNCTION(BlueprintCallable, Category="SenseGlove | Components | Wrist Tracker Component") + static void SetLeftHandMotionSource(UPARAM(ref) USGWristTrackerComponent* WristTrackerComponent, + EControllerHand InLeftHandMotionSource); + + UFUNCTION(BlueprintPure, Category="SenseGlove | Components | Wrist Tracker Component") + static EControllerHand GetRightHandMotionSource(const USGWristTrackerComponent* WristTrackerComponent); + + UFUNCTION(BlueprintCallable, Category="SenseGlove | Components | Wrist Tracker Component") + static void SetRightHandMotionSource(UPARAM(ref) USGWristTrackerComponent* WristTrackerComponent, + EControllerHand InRightHandMotionSource); + UFUNCTION(BlueprintPure, Category="SenseGlove | Components | Wrist Tracker Component") static bool OverridesPluginWristTrackingSettings(const USGWristTrackerComponent* WristTrackerComponent); diff --git a/Source/SenseGloveKismet/SenseGloveKismet.Build.cs b/Source/SenseGloveKismet/SenseGloveKismet.Build.cs index 440cdee7..3ebf5125 100644 --- a/Source/SenseGloveKismet/SenseGloveKismet.Build.cs +++ b/Source/SenseGloveKismet/SenseGloveKismet.Build.cs @@ -55,6 +55,7 @@ public class SenseGloveKismet : ModuleRules "CoreUObject", "Engine", "HeadMountedDisplay", + "InputCore", "SenseGlove", "SenseGloveCore", "SenseGloveLog",