From d6239766d8bb4dd94f2f261108e06b29695ed063 Mon Sep 17 00:00:00 2001 From: Mamadou Babaei Date: Tue, 9 Sep 2025 11:25:30 +0200 Subject: [PATCH] avoid calling senseglove glove data retrieval api from tickcomponent functions and instead offload those to background timers --- Handbook/src/appendix/changelog.md | 11 ++ .../SGVirtualHandAnimInstanceProxy.cpp | 5 +- .../Components/SGVirtualHandComponent.cpp | 173 ++++++++++-------- .../Components/SGWristTrackerComponent.cpp | 148 +++++++++------ .../Components/SGVirtualHandComponent.h | 9 +- .../Components/SGWristTrackerComponent.h | 9 +- .../SGVirtualHandComponentKismetLibrary.cpp | 6 +- .../SGWristTrackerComponentKismetLibrary.cpp | 8 +- .../SGVirtualHandComponentKismetLibrary.h | 4 +- .../SGWristTrackerComponentKismetLibrary.h | 4 +- 10 files changed, 216 insertions(+), 161 deletions(-) diff --git a/Handbook/src/appendix/changelog.md b/Handbook/src/appendix/changelog.md index 85bb682f..c881451e 100644 --- a/Handbook/src/appendix/changelog.md +++ b/Handbook/src/appendix/changelog.md @@ -35,6 +35,13 @@ This minor release focuses on delivering performance improvements, made possible - Renamed third-party module `SGSerialThirdPartyLibs` to `SGWjwwoodSerialThirdPartyLibs` since SenseGlove libraries >= `v2.300.0` ships a new static library named `sgserial`. Thus, to avoid confusion and naming conflicts the third-party `serial` static library is now provided by the `SGWjwwoodSerialThirdPartyLibs` module and `sgserial` is provided by the `SGSerialThirdPartyLibs` module. - `FSGGloveTrackingSettings::GloveConnectivityCheckInterval` settings have been renamed to `FSGGloveTrackingSettings::DataRetrievalRefreshRate` for adoption other than glove connectivity use cases. - The hand velocity sampler is now timer-based instead of being tick-based and the update interval is controlled via `SGPawn::HandVelocitySamplerFramerate`. +- Glove data retrieval and related calculations have been moved from `USGVirtualHandComponent::TickComponent()` and `USGWristTrackerComponent::TickComponent()` into background timers, reducing the performance overhead of any SenseGlove API calls. +- `USGVirtualHandComponent::GetMotionControllerData()` signature has changed. +- `USGVirtualHandComponent::GetHandTrackingState()` signature has changed. +- `USGWristTrackerComponent::GetMotionControllerData()` signature has changed. +- `USGWristTrackerComponent::GetHandTrackingState()` signature has changed. +- `USGVirtualHandComponentKismetLibrary::GetMotionControllerData()` signature has changed. +- `USGVirtualHandComponentKismetLibrary::GetHandTrackingState()` signature has changed. ### Removed @@ -44,6 +51,10 @@ This minor release focuses on delivering performance improvements, made possible - Cleaned up remnants of the long-removed Unreal Engine `5.2` from `SenseGlove.Build.cs`, `SenseGloveKismet.Build.cs`, `SenseGloveTracking.Build.cs`, files. - Cleaned up remnants of the long-removed Unreal Engine `5.2` from `SenseGloveTracking` module. - `SGPawn::Tick()` is no longer handled in order to improve performance and reliability. The hand velocity sampler is now timer-based instead of being tick-based and the update interval is controlled via `SGPawn::HandVelocitySamplerFramerate`. +- `USGVirtualHandComponent::GetMotionControllerState()` has been removed. +- `USGWristTrackerComponent::GetMotionControllerState()` has been removed. +- `USGVirtualHandComponentKismetLibrary::GetMotionControllerState()` has been removed. +- `USGWristTrackerComponentKismetLibrary::GetMotionControllerState()` has been removed. ### Documentation diff --git a/Source/SenseGlove/Private/SenseGlove/Animation/SGVirtualHandAnimInstanceProxy.cpp b/Source/SenseGlove/Private/SenseGlove/Animation/SGVirtualHandAnimInstanceProxy.cpp index 7d17242d..b8e74dc7 100644 --- a/Source/SenseGlove/Private/SenseGlove/Animation/SGVirtualHandAnimInstanceProxy.cpp +++ b/Source/SenseGlove/Private/SenseGlove/Animation/SGVirtualHandAnimInstanceProxy.cpp @@ -108,9 +108,8 @@ void FSGVirtualHandAnimInstanceProxy::PreEvaluateAnimation(UAnimInstance* InAnim } #if ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 5 - const bool bGotHandTrackingState = VirtualHand->GetHandTrackingState( - EXRSpaceType::UnrealWorldSpace, HandTrackingState); - if (!bGotHandTrackingState || !HandTrackingState.bValid) + HandTrackingState = VirtualHand->GetHandTrackingState(); + if (!HandTrackingState.bValid) { return; } diff --git a/Source/SenseGlove/Private/SenseGlove/Components/SGVirtualHandComponent.cpp b/Source/SenseGlove/Private/SenseGlove/Components/SGVirtualHandComponent.cpp index 8ef92e47..0a4f95fb 100644 --- a/Source/SenseGlove/Private/SenseGlove/Components/SGVirtualHandComponent.cpp +++ b/Source/SenseGlove/Private/SenseGlove/Components/SGVirtualHandComponent.cpp @@ -44,10 +44,12 @@ #include "InputCoreTypes.h" #include "IXRTrackingSystem.h" #include "Templates/UnrealTypeTraits.h" +#include "TimerManager.h" #include "UObject/ConstructorHelpers.h" #include "SenseGlove/Animation/SGVirtualHandAnimInstance.h" #include "SenseGlove/Components/SGWristTrackerComponent.h" +#include "SGBuildHacks/SGPlatform.h" #include "SGCore/SGHapticGlove.h" #include "SGDebug/SGDebugVirtualHand.h" #include "SGLog/SGLog.h" @@ -90,6 +92,13 @@ struct USGVirtualHandComponent::FImpl return GetPluginVirtualHandSettings().MeshSettings.DefaultRightHandMeshPathOnly; } + FORCEINLINE static float GetXRDataRetrievalInterval() + { + const USGSettings* Settings{USGSettings::GetInstance()}; + ensureAlwaysMsgf(Settings, TEXT("The settings subsystem has not been initialized!")); + return 1.0f / Settings->GetTrackingSettings().GloveTrackingSettings.DataRetrievalRefreshRate; + } + /************************ * Member variables ************************/ @@ -100,6 +109,15 @@ struct USGVirtualHandComponent::FImpl ECollisionEnabled::Type CachedCollisionEnabled; FCollisionResponseContainer CachedCollisionResponse; + FXRMotionControllerData MotionControllerData; + +#if ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 5 + FXRMotionControllerState MotionControllerState; + FXRHandTrackingState HandTrackingState; +#endif /* ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 5 */ + + FTimerHandle XRDataRetrievalTimer; + /************************ * Owner object ************************/ @@ -156,6 +174,8 @@ struct USGVirtualHandComponent::FImpl void DrawDebugVirtualHand() const; void TriggerHandVisibilityChangedEvent(bool bNewVisibility) const; + + void StartXRDataRetrievalTimer(); }; FName USGVirtualHandComponent::FImpl::ParseVirtualHandSettingsOverridesPropertyName(const FName& PropertyName) @@ -367,7 +387,7 @@ void USGVirtualHandComponent::InitializeComponent() Pimpl->SetDefaultMesh(); } - Pimpl->UpdateVisibility(); + Pimpl->StartXRDataRetrievalTimer(); } void USGVirtualHandComponent::UninitializeComponent() @@ -386,8 +406,6 @@ void USGVirtualHandComponent::UninitializeComponent() void USGVirtualHandComponent::BeginPlay() { Super::BeginPlay(); - - Pimpl->UpdateVisibility(); } void USGVirtualHandComponent::EndPlay(const EEndPlayReason::Type EndPlayReason) @@ -416,8 +434,6 @@ void USGVirtualHandComponent::TickComponent( Super::TickComponent(DeltaTime, TickType, ThisTickFunction); - Pimpl->UpdateVisibility(); - if (Pimpl->ShouldDrawDebugVirtualHand()) { Pimpl->DrawDebugVirtualHand(); @@ -439,8 +455,6 @@ void USGVirtualHandComponent::SetSkeletalMesh(USkeletalMesh* NewMesh, const bool void USGVirtualHandComponent::EditorTick( const float DeltaTime, const ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) { - Pimpl->UpdateVisibility(); - if (Pimpl->ShouldDrawDebugVirtualHand()) { Pimpl->DrawDebugVirtualHand(); @@ -461,61 +475,16 @@ USGHapticGlove* USGVirtualHandComponent::GetConnectedGlove() const return Glove; } -bool USGVirtualHandComponent::GetMotionControllerData(FXRMotionControllerData& OutMotionControllerData) +const FXRMotionControllerData& USGVirtualHandComponent::GetMotionControllerData() const { - OutMotionControllerData.bValid = false; - - const EControllerHand Hand = IsRight() ? EControllerHand::Right : EControllerHand::Left; - PRAGMA_DISABLE_DEPRECATION_WARNINGS - const bool bGotMotionControllerData = - FSGXRTracker::GetMotionControllerData(this, Hand, OutMotionControllerData); - PRAGMA_ENABLE_DEPRECATION_WARNINGS - if (!bGotMotionControllerData || !OutMotionControllerData.bValid) - { - return false; - } - - return OutMotionControllerData.bValid; + return Pimpl->MotionControllerData; } #if ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 5 - -bool USGVirtualHandComponent::GetMotionControllerState( - const EXRSpaceType XRSpaceType, const EXRControllerPoseType XRControllerPoseType, - FXRMotionControllerState& OutMotionControllerState) +const FXRHandTrackingState& USGVirtualHandComponent::GetHandTrackingState() const { - OutMotionControllerState.bValid = false; - - const EControllerHand Hand = IsRight() ? EControllerHand::Right : EControllerHand::Left; - const bool bGotMotionControllerState = - FSGXRTracker::GetMotionControllerState( - this, XRSpaceType, Hand, XRControllerPoseType, OutMotionControllerState); - if (!bGotMotionControllerState || !OutMotionControllerState.bValid) - { - return false; - } - - return OutMotionControllerState.bValid; + return Pimpl->HandTrackingState; } - -bool USGVirtualHandComponent::GetHandTrackingState( - const EXRSpaceType XRSpaceType, - FXRHandTrackingState& OutHandTrackingState) -{ - OutHandTrackingState.bValid = false; - - const EControllerHand Hand = IsRight() ? EControllerHand::Right : EControllerHand::Left; - const bool bGotHandTrackingState = - FSGXRTracker::GetHandTrackingState( - this, XRSpaceType, Hand, OutHandTrackingState); - if (!bGotHandTrackingState || !OutHandTrackingState.bValid) - { - return false; - } - - return OutHandTrackingState.bValid; -} - #endif /* ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 5 */ const TArray& USGVirtualHandComponent::GetHandBoneNames() const @@ -803,23 +772,12 @@ void USGVirtualHandComponent::FImpl::SetVisibility(const bool bInVisible) void USGVirtualHandComponent::FImpl::UpdateVisibility() { -#if ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 5 - FXRHandTrackingState HandTrackingState; - const bool bGotHandTrackingState = - Owner->GetHandTrackingState(EXRSpaceType::UnrealWorldSpace, HandTrackingState); -#else /* ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 5 */ - FXRMotionControllerData MotionControllerData; - const bool bGotMotionControllerData = Owner->GetMotionControllerData(MotionControllerData); -#endif /* ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 5 */ - const bool bHandDataAvailable = #if ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 5 - bGotHandTrackingState - && HandTrackingState.bValid + HandTrackingState.bValid #else /* ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 5 */ - bGotMotionControllerData - && MotionControllerData.bValid - && MotionControllerData.DeviceVisualType == EXRVisualType::Hand + MotionControllerData.bValid + && MotionControllerData.DeviceVisualType == EXRVisualType::Hand #endif /* ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 5 */ ; const bool bHandVisible = Owner->IsVisible(); @@ -881,18 +839,16 @@ void USGVirtualHandComponent::FImpl::DrawDebugVirtualHand() const } #if ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 5 - FXRHandTrackingState HandTrackingState; - const bool bGotHandTrackingState = Owner->GetHandTrackingState(EXRSpaceType::UnrealWorldSpace, HandTrackingState); - if (!bGotHandTrackingState || !HandTrackingState.bValid) + if (!HandTrackingState.bValid) { return; } FSGDebugVirtualHand::Draw(World, HandTrackingState, Owner->GetVirtualHandSettings().DebuggingSettings); #else /* ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 5 */ - FXRMotionControllerData MotionControllerData; - const bool bGotMotionControllerData = Owner->GetMotionControllerData(MotionControllerData); - if (!bGotMotionControllerData || !MotionControllerData.bValid) + + if (!MotionControllerData.bValid + || MotionControllerData.DeviceVisualType == EXRVisualType::Hand) { return; } @@ -907,6 +863,71 @@ void USGVirtualHandComponent::FImpl::TriggerHandVisibilityChangedEvent(const boo Owner->OnHandVisibilityChanged(bNewVisibility); } +void USGVirtualHandComponent::FImpl::StartXRDataRetrievalTimer() +{ + const UWorld* World{Owner->GetWorld()}; + if (!ensureAlwaysMsgf(World, TEXT("Invalid world!"))) + { + SGLOG_ERROR("The SGVirtualHandComponent's XRDataRetrievalTimer has failed to start!"); + return; + } + + SGLOG("Starting SGVirtualHandComponent's XRDataRetrievalTimer..."); + + FTimerDelegate Handler; + Handler.BindLambda([= SG_CAPTURE_THIS]()-> void + { + const EControllerHand Hand = Owner->IsRight() ? EControllerHand::Right : EControllerHand::Left; + + { + FXRMotionControllerData Data; + Data.bValid = false; + + PRAGMA_DISABLE_DEPRECATION_WARNINGS + const bool bGotMotionControllerData = + FSGXRTracker::GetMotionControllerData(Owner, Hand, Data); + PRAGMA_ENABLE_DEPRECATION_WARNINGS + + (void) bGotMotionControllerData; + MotionControllerData = MoveTemp(Data); + } + +#if ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 5 + { + FXRHandTrackingState State; + State.bValid = false; + const bool bGotHandTrackingState = + FSGXRTracker::GetHandTrackingState( + Owner, EXRSpaceType::UnrealWorldSpace, Hand, State); + + (void) bGotHandTrackingState; + HandTrackingState = MoveTemp(State); + } +#endif /* ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 5 */ + + // Perform all other updates for the next tick! + UpdateVisibility(); + }); + + const float Interval = GetXRDataRetrievalInterval(); + + FTimerManager& TimerManager = World->GetTimerManager(); + TimerManager.SetTimer( + XRDataRetrievalTimer, Handler, Interval, + true, -1.0f); + + if (ensureAlwaysMsgf(TimerManager.IsTimerActive(XRDataRetrievalTimer), + TEXT("XRDataRetrievalTimer is not active"))) + { + SGLOG("The SGVirtualHandComponent's XRDataRetrievalTimer has been started successfully!"); + SGLOG("The SGVirtualHandComponent's XRDataRetrievalTimer interval is: ", Interval); + } + else + { + SGLOG_ERROR("The SGVirtualHandComponent's XRDataRetrievalTimer has failed to start!"); + } +} + void USGVirtualHandComponent::FImplDeleter::operator()(const FImpl* P) const { delete P; diff --git a/Source/SenseGlove/Private/SenseGlove/Components/SGWristTrackerComponent.cpp b/Source/SenseGlove/Private/SenseGlove/Components/SGWristTrackerComponent.cpp index 89313f11..ca755fe4 100644 --- a/Source/SenseGlove/Private/SenseGlove/Components/SGWristTrackerComponent.cpp +++ b/Source/SenseGlove/Private/SenseGlove/Components/SGWristTrackerComponent.cpp @@ -37,8 +37,11 @@ #include "IXRTrackingSystem.h" #include "MotionDelayBuffer.h" +#include "TimerManager.h" +#include "SGBuildHacks/SGPlatform.h" #include "SGDebug/SGDebugGizmo.h" +#include "SGLog/SGLog.h" #include "SGSettings/SGSettings.h" #include "SGTracking/SGXRTracker.h" @@ -50,12 +53,28 @@ struct USGWristTrackerComponent::FImpl static FName ParseWristTrackingSettingsOverridesPropertyName(const FName& PropertyName); + FORCEINLINE static float GetXRDataRetrievalInterval() + { + const USGSettings* Settings{USGSettings::GetInstance()}; + ensureAlwaysMsgf(Settings, TEXT("The settings subsystem has not been initialized!")); + return 1.0f / Settings->GetTrackingSettings().GloveTrackingSettings.DataRetrievalRefreshRate; + } + /************************ * Member variables ************************/ bool bOverridePluginSettingsPropertyAlreadyModified; + FXRMotionControllerData MotionControllerData; + +#if ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 5 + FXRMotionControllerState MotionControllerState; + FXRHandTrackingState HandTrackingState; +#endif /* ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 5 */ + + FTimerHandle XRDataRetrievalTimer; + /************************ * Owner object ************************/ @@ -87,6 +106,8 @@ struct USGWristTrackerComponent::FImpl void UpdateMotionSource() const; void UpdateWristTrackingData() const; void DrawDebugWristTracker() const; + + void StartXRDataRetrievalTimer(); }; USGWristTrackerComponent::USGWristTrackerComponent(const FObjectInitializer& ObjectInitializer) @@ -201,7 +222,7 @@ void USGWristTrackerComponent::InitializeComponent() { Super::InitializeComponent(); - Pimpl->UpdateWristTrackingData(); + Pimpl->StartXRDataRetrievalTimer(); Pimpl->UpdateMotionSource(); } @@ -210,8 +231,6 @@ void USGWristTrackerComponent::BeginPlay() { Super::BeginPlay(); - Pimpl->UpdateWristTrackingData(); - Pimpl->UpdateMotionSource(); } @@ -232,73 +251,23 @@ void USGWristTrackerComponent::TickComponent( { Pimpl->DrawDebugWristTracker(); } - - Pimpl->UpdateWristTrackingData(); } - void USGWristTrackerComponent::EditorTick( const float DeltaTime, const ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) { - Pimpl->UpdateWristTrackingData(); } -bool USGWristTrackerComponent::GetMotionControllerData(FXRMotionControllerData& OutMotionControllerData) +const FXRMotionControllerData& USGWristTrackerComponent::GetMotionControllerData() const { - OutMotionControllerData.bValid = false; - - const EControllerHand Hand = IsRight() ? EControllerHand::Right : EControllerHand::Left; - PRAGMA_DISABLE_DEPRECATION_WARNINGS - const bool bGotMotionControllerData = - FSGXRTracker::GetMotionControllerData(this, Hand, OutMotionControllerData); - PRAGMA_ENABLE_DEPRECATION_WARNINGS - - if (!bGotMotionControllerData || !OutMotionControllerData.bValid) - { - return false; - } - - return OutMotionControllerData.bValid; + return Pimpl->MotionControllerData; } #if ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 5 - -bool USGWristTrackerComponent::GetMotionControllerState( - const EXRSpaceType XRSpaceType, const EXRControllerPoseType XRControllerPoseType, - FXRMotionControllerState& OutMotionControllerState) +const FXRHandTrackingState& USGWristTrackerComponent::GetHandTrackingState() const { - OutMotionControllerState.bValid = false; - - const EControllerHand Hand = IsRight() ? EControllerHand::Right : EControllerHand::Left; - const bool bGotMotionControllerState = - FSGXRTracker::GetMotionControllerState( - this, XRSpaceType, Hand, XRControllerPoseType, OutMotionControllerState); - if (!bGotMotionControllerState || !OutMotionControllerState.bValid) - { - return false; - } - - return OutMotionControllerState.bValid; + return Pimpl->HandTrackingState; } - -bool USGWristTrackerComponent::GetHandTrackingState( - const EXRSpaceType XRSpaceType, - FXRHandTrackingState& OutHandTrackingState) -{ - OutHandTrackingState.bValid = false; - - const EControllerHand Hand = IsRight() ? EControllerHand::Right : EControllerHand::Left; - const bool bGotHandTrackingState = - FSGXRTracker::GetHandTrackingState( - this, XRSpaceType, Hand, OutHandTrackingState); - if (!bGotHandTrackingState || !OutHandTrackingState.bValid) - { - return false; - } - - return OutHandTrackingState.bValid; -} - #endif /* ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 5 */ USGWristTrackerComponent::FImpl::FImpl(USGWristTrackerComponent* InOwner) @@ -401,6 +370,71 @@ void USGWristTrackerComponent::FImpl::DrawDebugWristTracker() const FSGDebugGizmo::Draw(World, Owner->WristLocation, Owner->WristRotation, DebuggingSettings.DebugWristTrackerSettings); } +void USGWristTrackerComponent::FImpl::StartXRDataRetrievalTimer() +{ + const UWorld* World{Owner->GetWorld()}; + if (!ensureAlwaysMsgf(World, TEXT("Invalid world!"))) + { + SGLOG_ERROR("The SGWristTrackerComponent's XRDataRetrievalTimer has failed to start!"); + return; + } + + SGLOG("Starting SGWristTrackerComponent's XRDataRetrievalTimer..."); + + FTimerDelegate Handler; + Handler.BindLambda([= SG_CAPTURE_THIS]()-> void + { + const EControllerHand Hand = Owner->IsRight() ? EControllerHand::Right : EControllerHand::Left; + + { + FXRMotionControllerData Data; + Data.bValid = false; + + PRAGMA_DISABLE_DEPRECATION_WARNINGS + const bool bGotMotionControllerData = + FSGXRTracker::GetMotionControllerData(Owner, Hand, Data); + PRAGMA_ENABLE_DEPRECATION_WARNINGS + + (void) bGotMotionControllerData; + MotionControllerData = MoveTemp(Data); + } + +#if ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 5 + { + FXRHandTrackingState State; + State.bValid = false; + const bool bGotHandTrackingState = + FSGXRTracker::GetHandTrackingState( + Owner, EXRSpaceType::UnrealWorldSpace, Hand, State); + + (void) bGotHandTrackingState; + HandTrackingState = MoveTemp(State); + } +#endif /* ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 5 */ + + // Perform all other updates for the next tick! + UpdateWristTrackingData(); + }); + + const float Interval = GetXRDataRetrievalInterval(); + + FTimerManager& TimerManager = World->GetTimerManager(); + TimerManager.SetTimer( + XRDataRetrievalTimer, Handler, Interval, + true, -1.0f); + + if (ensureAlwaysMsgf(TimerManager.IsTimerActive(XRDataRetrievalTimer), + TEXT("XRDataRetrievalTimer is not active"))) + { + SGLOG("The SGWristTrackerComponent's XRDataRetrievalTimer has been started successfully!"); + SGLOG("The SGWristTrackerComponent's XRDataRetrievalTimer interval is: ", Interval); + } + else + { + SGLOG_ERROR("The SGWristTrackerComponent's XRDataRetrievalTimer has failed to start!"); + } +} + void USGWristTrackerComponent::FImplDeleter::operator()(const FImpl* P) const { delete P; diff --git a/Source/SenseGlove/Public/SenseGlove/Components/SGVirtualHandComponent.h b/Source/SenseGlove/Public/SenseGlove/Components/SGVirtualHandComponent.h index b97213cb..81c08b90 100644 --- a/Source/SenseGlove/Public/SenseGlove/Components/SGVirtualHandComponent.h +++ b/Source/SenseGlove/Public/SenseGlove/Components/SGVirtualHandComponent.h @@ -181,15 +181,10 @@ public: bool IsGloveConnected() const; USGHapticGlove* GetConnectedGlove() const; - bool GetMotionControllerData(FXRMotionControllerData& OutMotionControllerData); + const FXRMotionControllerData& GetMotionControllerData() const; #if ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 5 - bool GetMotionControllerState( - EXRSpaceType XRSpaceType, EXRControllerPoseType XRControllerPoseType, - FXRMotionControllerState& OutMotionControllerState); - bool GetHandTrackingState( - EXRSpaceType XRSpaceType, - FXRHandTrackingState& OutHandTrackingState); + const FXRHandTrackingState& GetHandTrackingState() const; #endif /* ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 5 */ public: diff --git a/Source/SenseGlove/Public/SenseGlove/Components/SGWristTrackerComponent.h b/Source/SenseGlove/Public/SenseGlove/Components/SGWristTrackerComponent.h index 833d29c5..3ab7d8e4 100644 --- a/Source/SenseGlove/Public/SenseGlove/Components/SGWristTrackerComponent.h +++ b/Source/SenseGlove/Public/SenseGlove/Components/SGWristTrackerComponent.h @@ -165,14 +165,9 @@ protected: FActorComponentTickFunction* ThisTickFunction); public: - bool GetMotionControllerData(FXRMotionControllerData& OutMotionControllerData); + const FXRMotionControllerData& GetMotionControllerData() const; #if ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 5 - bool GetMotionControllerState( - EXRSpaceType XRSpaceType, EXRControllerPoseType XRControllerPoseType, - FXRMotionControllerState& OutMotionControllerState); - bool GetHandTrackingState( - EXRSpaceType XRSpaceType, - FXRHandTrackingState& OutHandTrackingState); + const FXRHandTrackingState& GetHandTrackingState() const; #endif /* ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 5 */ }; \ No newline at end of file diff --git a/Source/SenseGloveKismet/Private/SGKismet/SGVirtualHandComponentKismetLibrary.cpp b/Source/SenseGloveKismet/Private/SGKismet/SGVirtualHandComponentKismetLibrary.cpp index bdc4143d..0574fe2a 100644 --- a/Source/SenseGloveKismet/Private/SGKismet/SGVirtualHandComponentKismetLibrary.cpp +++ b/Source/SenseGloveKismet/Private/SGKismet/SGVirtualHandComponentKismetLibrary.cpp @@ -110,11 +110,11 @@ USGHapticGlove* UVirtualHandComponentKismetLibrary::GetConnectedGlove( return VirtualHandComponent->GetConnectedGlove(); } -bool UVirtualHandComponentKismetLibrary::GetMotionControllerData( - USGVirtualHandComponent* VirtualHandComponent, FXRMotionControllerData& OutMotionControllerData) +const FXRMotionControllerData& UVirtualHandComponentKismetLibrary::GetMotionControllerData( + USGVirtualHandComponent* VirtualHandComponent) { PRAGMA_DISABLE_DEPRECATION_WARNINGS - return VirtualHandComponent->GetMotionControllerData(OutMotionControllerData); + return VirtualHandComponent->GetMotionControllerData(); PRAGMA_ENABLE_DEPRECATION_WARNINGS } diff --git a/Source/SenseGloveKismet/Private/SGKismet/SGWristTrackerComponentKismetLibrary.cpp b/Source/SenseGloveKismet/Private/SGKismet/SGWristTrackerComponentKismetLibrary.cpp index 1a8b2958..7371e41e 100644 --- a/Source/SenseGloveKismet/Private/SGKismet/SGWristTrackerComponentKismetLibrary.cpp +++ b/Source/SenseGloveKismet/Private/SGKismet/SGWristTrackerComponentKismetLibrary.cpp @@ -90,10 +90,10 @@ const FRotator& UWristTrackerComponentKismetLibrary::GetWristRotation( return WristTrackerComponent->GetWristRotation(); } -bool UWristTrackerComponentKismetLibrary::GetMotionControllerData( - USGWristTrackerComponent* WristTrackerComponent, FXRMotionControllerData& OutMotionControllerData) +const FXRMotionControllerData& UWristTrackerComponentKismetLibrary::GetMotionControllerData( + USGWristTrackerComponent* WristTrackerComponent) { PRAGMA_DISABLE_DEPRECATION_WARNINGS - return WristTrackerComponent->GetMotionControllerData(OutMotionControllerData); + return WristTrackerComponent->GetMotionControllerData(); PRAGMA_ENABLE_DEPRECATION_WARNINGS -} \ No newline at end of file +} diff --git a/Source/SenseGloveKismet/Public/SGKismet/SGVirtualHandComponentKismetLibrary.h b/Source/SenseGloveKismet/Public/SGKismet/SGVirtualHandComponentKismetLibrary.h index 3ed6dd38..ea6aff9c 100644 --- a/Source/SenseGloveKismet/Public/SGKismet/SGVirtualHandComponentKismetLibrary.h +++ b/Source/SenseGloveKismet/Public/SGKismet/SGVirtualHandComponentKismetLibrary.h @@ -103,8 +103,8 @@ public: static USGHapticGlove* GetConnectedGlove(const USGVirtualHandComponent* VirtualHandComponent); UFUNCTION(BlueprintCallable, Category="SenseGlove | Components | Virtual Hand Component") - static bool GetMotionControllerData(UPARAM(ref) USGVirtualHandComponent* VirtualHandComponent, - FXRMotionControllerData& OutMotionControllerData); + static const FXRMotionControllerData& GetMotionControllerData( + UPARAM(ref) USGVirtualHandComponent* VirtualHandComponent); UFUNCTION(BlueprintPure, Category="SenseGlove | Components | Virtual Hand Component") static const TArray& GetHandBoneNames(const USGVirtualHandComponent* VirtualHandComponent); diff --git a/Source/SenseGloveKismet/Public/SGKismet/SGWristTrackerComponentKismetLibrary.h b/Source/SenseGloveKismet/Public/SGKismet/SGWristTrackerComponentKismetLibrary.h index 923b2781..719e21f3 100644 --- a/Source/SenseGloveKismet/Public/SGKismet/SGWristTrackerComponentKismetLibrary.h +++ b/Source/SenseGloveKismet/Public/SGKismet/SGWristTrackerComponentKismetLibrary.h @@ -84,6 +84,6 @@ public: static const FRotator& GetWristRotation(const USGWristTrackerComponent* WristTrackerComponent); UFUNCTION(BlueprintCallable, Category="SenseGlove | Components | Wrist Tracker Component") - static bool GetMotionControllerData(UPARAM(ref) USGWristTrackerComponent* WristTrackerComponent, - FXRMotionControllerData& OutMotionControllerData); + static const FXRMotionControllerData& GetMotionControllerData( + UPARAM(ref) USGWristTrackerComponent* WristTrackerComponent); }; \ No newline at end of file