revert offloading senseglove glove data retrieval api calls to timers and restore calls from tickcomponent functions
This commit is contained in:
@@ -46,7 +46,6 @@ This minor release focuses on delivering performance improvements, made possible
|
|||||||
- As a result of SenseGlove libraries >= `v2.300.0` changing it's directory structure, the `ThirdParty` folder's directory structure has been revamped.
|
- As a result of SenseGlove libraries >= `v2.300.0` changing it's directory structure, the `ThirdParty` folder's directory structure has been revamped.
|
||||||
- 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.
|
- 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.
|
- `FSGGloveTrackingSettings::GloveConnectivityCheckInterval` settings have been renamed to `FSGGloveTrackingSettings::DataRetrievalRefreshRate` for adoption other than glove connectivity use cases.
|
||||||
- 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::GetMotionControllerData()` signature has changed.
|
||||||
- `USGVirtualHandComponent::GetHandTrackingState()` signature has changed.
|
- `USGVirtualHandComponent::GetHandTrackingState()` signature has changed.
|
||||||
- `USGWristTrackerComponent::GetMotionControllerData()` signature has changed.
|
- `USGWristTrackerComponent::GetMotionControllerData()` signature has changed.
|
||||||
|
|||||||
@@ -42,9 +42,7 @@
|
|||||||
#include "Engine/EngineTypes.h"
|
#include "Engine/EngineTypes.h"
|
||||||
#include "Engine/SkeletalMesh.h"
|
#include "Engine/SkeletalMesh.h"
|
||||||
#include "InputCoreTypes.h"
|
#include "InputCoreTypes.h"
|
||||||
#include "IXRTrackingSystem.h"
|
|
||||||
#include "Templates/UnrealTypeTraits.h"
|
#include "Templates/UnrealTypeTraits.h"
|
||||||
#include "TimerManager.h"
|
|
||||||
#include "UObject/ConstructorHelpers.h"
|
#include "UObject/ConstructorHelpers.h"
|
||||||
|
|
||||||
#include "SenseGlove/Animation/SGVirtualHandAnimInstance.h"
|
#include "SenseGlove/Animation/SGVirtualHandAnimInstance.h"
|
||||||
@@ -92,13 +90,6 @@ struct USGVirtualHandComponent::FImpl
|
|||||||
return GetPluginVirtualHandSettings().MeshSettings.DefaultRightHandMeshPathOnly;
|
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
|
* Member variables
|
||||||
************************/
|
************************/
|
||||||
@@ -109,13 +100,14 @@ struct USGVirtualHandComponent::FImpl
|
|||||||
ECollisionEnabled::Type CachedCollisionEnabled;
|
ECollisionEnabled::Type CachedCollisionEnabled;
|
||||||
FCollisionResponseContainer CachedCollisionResponse;
|
FCollisionResponseContainer CachedCollisionResponse;
|
||||||
|
|
||||||
|
#if ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION < 7
|
||||||
|
FXRMotionControllerData MotionControllerData;
|
||||||
|
#endif /* ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION < 7 */
|
||||||
|
|
||||||
#if ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 5
|
#if ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 5
|
||||||
FXRMotionControllerState MotionControllerState;
|
|
||||||
FXRHandTrackingState HandTrackingState;
|
FXRHandTrackingState HandTrackingState;
|
||||||
#endif /* ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 5 */
|
#endif /* ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 5 */
|
||||||
|
|
||||||
FTimerHandle XRDataRetrievalTimer;
|
|
||||||
|
|
||||||
/************************
|
/************************
|
||||||
* Owner object
|
* Owner object
|
||||||
************************/
|
************************/
|
||||||
@@ -158,6 +150,8 @@ struct USGVirtualHandComponent::FImpl
|
|||||||
void DisableCollisionResponse();
|
void DisableCollisionResponse();
|
||||||
void RestoreCollisionResponse() const;
|
void RestoreCollisionResponse() const;
|
||||||
|
|
||||||
|
void UpdateXRData();
|
||||||
|
|
||||||
void SetVisibility(const bool bInVisible);
|
void SetVisibility(const bool bInVisible);
|
||||||
void UpdateVisibility();
|
void UpdateVisibility();
|
||||||
|
|
||||||
@@ -172,8 +166,6 @@ struct USGVirtualHandComponent::FImpl
|
|||||||
void DrawDebugVirtualHand() const;
|
void DrawDebugVirtualHand() const;
|
||||||
|
|
||||||
void TriggerHandVisibilityChangedEvent(bool bNewVisibility) const;
|
void TriggerHandVisibilityChangedEvent(bool bNewVisibility) const;
|
||||||
|
|
||||||
void StartXRDataRetrievalTimer();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
FName USGVirtualHandComponent::FImpl::ParseVirtualHandSettingsOverridesPropertyName(const FName& PropertyName)
|
FName USGVirtualHandComponent::FImpl::ParseVirtualHandSettingsOverridesPropertyName(const FName& PropertyName)
|
||||||
@@ -385,7 +377,7 @@ void USGVirtualHandComponent::InitializeComponent()
|
|||||||
Pimpl->SetDefaultMesh();
|
Pimpl->SetDefaultMesh();
|
||||||
}
|
}
|
||||||
|
|
||||||
Pimpl->StartXRDataRetrievalTimer();
|
Pimpl->UpdateXRData();
|
||||||
}
|
}
|
||||||
|
|
||||||
void USGVirtualHandComponent::UninitializeComponent()
|
void USGVirtualHandComponent::UninitializeComponent()
|
||||||
@@ -404,6 +396,8 @@ void USGVirtualHandComponent::UninitializeComponent()
|
|||||||
void USGVirtualHandComponent::BeginPlay()
|
void USGVirtualHandComponent::BeginPlay()
|
||||||
{
|
{
|
||||||
Super::BeginPlay();
|
Super::BeginPlay();
|
||||||
|
|
||||||
|
Pimpl->UpdateXRData();
|
||||||
}
|
}
|
||||||
|
|
||||||
void USGVirtualHandComponent::EndPlay(const EEndPlayReason::Type EndPlayReason)
|
void USGVirtualHandComponent::EndPlay(const EEndPlayReason::Type EndPlayReason)
|
||||||
@@ -432,6 +426,8 @@ void USGVirtualHandComponent::TickComponent(
|
|||||||
|
|
||||||
Super::TickComponent(DeltaTime, TickType, ThisTickFunction);
|
Super::TickComponent(DeltaTime, TickType, ThisTickFunction);
|
||||||
|
|
||||||
|
Pimpl->UpdateXRData();
|
||||||
|
|
||||||
if (Pimpl->ShouldDrawDebugVirtualHand())
|
if (Pimpl->ShouldDrawDebugVirtualHand())
|
||||||
{
|
{
|
||||||
Pimpl->DrawDebugVirtualHand();
|
Pimpl->DrawDebugVirtualHand();
|
||||||
@@ -453,6 +449,8 @@ void USGVirtualHandComponent::SetSkeletalMesh(USkeletalMesh* NewMesh, const bool
|
|||||||
void USGVirtualHandComponent::EditorTick(
|
void USGVirtualHandComponent::EditorTick(
|
||||||
const float DeltaTime, const ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction)
|
const float DeltaTime, const ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction)
|
||||||
{
|
{
|
||||||
|
Pimpl->UpdateXRData();
|
||||||
|
|
||||||
if (Pimpl->ShouldDrawDebugVirtualHand())
|
if (Pimpl->ShouldDrawDebugVirtualHand())
|
||||||
{
|
{
|
||||||
Pimpl->DrawDebugVirtualHand();
|
Pimpl->DrawDebugVirtualHand();
|
||||||
@@ -747,6 +745,42 @@ void USGVirtualHandComponent::FImpl::RestoreCollisionResponse() const
|
|||||||
Owner->SetCollisionResponseToChannels(CachedCollisionResponse);
|
Owner->SetCollisionResponseToChannels(CachedCollisionResponse);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void USGVirtualHandComponent::FImpl::UpdateXRData()
|
||||||
|
{
|
||||||
|
const EControllerHand Hand = Owner->IsRight() ? EControllerHand::Right : EControllerHand::Left;
|
||||||
|
|
||||||
|
#if ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION < 7
|
||||||
|
{
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
#endif /* ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION < 7 */
|
||||||
|
|
||||||
|
#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 */
|
||||||
|
}
|
||||||
|
|
||||||
void USGVirtualHandComponent::FImpl::SetVisibility(const bool bInVisible)
|
void USGVirtualHandComponent::FImpl::SetVisibility(const bool bInVisible)
|
||||||
{
|
{
|
||||||
Owner->SetHiddenInGame(!bInVisible, false);
|
Owner->SetHiddenInGame(!bInVisible, false);
|
||||||
@@ -856,74 +890,6 @@ void USGVirtualHandComponent::FImpl::TriggerHandVisibilityChangedEvent(const boo
|
|||||||
Owner->OnHandVisibilityChanged(bNewVisibility);
|
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;
|
|
||||||
|
|
||||||
|
|
||||||
#if ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION < 7
|
|
||||||
{
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
#endif /* ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION < 7 */
|
|
||||||
|
|
||||||
#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
|
void USGVirtualHandComponent::FImplDeleter::operator()(const FImpl* P) const
|
||||||
{
|
{
|
||||||
delete P;
|
delete P;
|
||||||
|
|||||||
@@ -36,8 +36,6 @@
|
|||||||
#include "SenseGlove/Components/SGWristTrackerComponent.h"
|
#include "SenseGlove/Components/SGWristTrackerComponent.h"
|
||||||
|
|
||||||
#include "IXRTrackingSystem.h"
|
#include "IXRTrackingSystem.h"
|
||||||
#include "MotionDelayBuffer.h"
|
|
||||||
#include "TimerManager.h"
|
|
||||||
|
|
||||||
#include "SGBuildHacks/SGPlatform.h"
|
#include "SGBuildHacks/SGPlatform.h"
|
||||||
#include "SGDebug/SGDebugGizmo.h"
|
#include "SGDebug/SGDebugGizmo.h"
|
||||||
@@ -53,26 +51,20 @@ struct USGWristTrackerComponent::FImpl
|
|||||||
|
|
||||||
static FName ParseWristTrackingSettingsOverridesPropertyName(const FName& PropertyName);
|
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
|
* Member variables
|
||||||
************************/
|
************************/
|
||||||
|
|
||||||
bool bOverridePluginSettingsPropertyAlreadyModified;
|
bool bOverridePluginSettingsPropertyAlreadyModified;
|
||||||
|
|
||||||
|
#if ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION < 7
|
||||||
|
FXRMotionControllerData MotionControllerData;
|
||||||
|
#endif /* ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION < 7 */
|
||||||
|
|
||||||
#if ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 5
|
#if ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 5
|
||||||
FXRMotionControllerState MotionControllerState;
|
|
||||||
FXRHandTrackingState HandTrackingState;
|
FXRHandTrackingState HandTrackingState;
|
||||||
#endif /* ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 5 */
|
#endif /* ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 5 */
|
||||||
|
|
||||||
FTimerHandle XRDataRetrievalTimer;
|
|
||||||
|
|
||||||
/************************
|
/************************
|
||||||
* Owner object
|
* Owner object
|
||||||
************************/
|
************************/
|
||||||
@@ -102,10 +94,10 @@ struct USGWristTrackerComponent::FImpl
|
|||||||
void OverridePluginSettingsPropertyChanged();
|
void OverridePluginSettingsPropertyChanged();
|
||||||
|
|
||||||
void UpdateMotionSource() const;
|
void UpdateMotionSource() const;
|
||||||
|
void UpdateXRData();
|
||||||
void UpdateWristTrackingData() const;
|
void UpdateWristTrackingData() const;
|
||||||
void DrawDebugWristTracker() const;
|
|
||||||
|
|
||||||
void StartXRDataRetrievalTimer();
|
void DrawDebugWristTracker() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
USGWristTrackerComponent::USGWristTrackerComponent(const FObjectInitializer& ObjectInitializer)
|
USGWristTrackerComponent::USGWristTrackerComponent(const FObjectInitializer& ObjectInitializer)
|
||||||
@@ -220,9 +212,9 @@ void USGWristTrackerComponent::InitializeComponent()
|
|||||||
{
|
{
|
||||||
Super::InitializeComponent();
|
Super::InitializeComponent();
|
||||||
|
|
||||||
Pimpl->StartXRDataRetrievalTimer();
|
|
||||||
|
|
||||||
Pimpl->UpdateMotionSource();
|
Pimpl->UpdateMotionSource();
|
||||||
|
Pimpl->UpdateXRData();
|
||||||
|
Pimpl->UpdateWristTrackingData();
|
||||||
}
|
}
|
||||||
|
|
||||||
void USGWristTrackerComponent::BeginPlay()
|
void USGWristTrackerComponent::BeginPlay()
|
||||||
@@ -230,6 +222,8 @@ void USGWristTrackerComponent::BeginPlay()
|
|||||||
Super::BeginPlay();
|
Super::BeginPlay();
|
||||||
|
|
||||||
Pimpl->UpdateMotionSource();
|
Pimpl->UpdateMotionSource();
|
||||||
|
Pimpl->UpdateXRData();
|
||||||
|
Pimpl->UpdateWristTrackingData();
|
||||||
}
|
}
|
||||||
|
|
||||||
void USGWristTrackerComponent::TickComponent(
|
void USGWristTrackerComponent::TickComponent(
|
||||||
@@ -245,6 +239,9 @@ void USGWristTrackerComponent::TickComponent(
|
|||||||
|
|
||||||
Super::TickComponent(DeltaTime, TickType, ThisTickFunction);
|
Super::TickComponent(DeltaTime, TickType, ThisTickFunction);
|
||||||
|
|
||||||
|
Pimpl->UpdateXRData();
|
||||||
|
Pimpl->UpdateWristTrackingData();
|
||||||
|
|
||||||
if (GetWristTrackingSettings().DebuggingSettings.bDrawDebugWristTracker)
|
if (GetWristTrackingSettings().DebuggingSettings.bDrawDebugWristTracker)
|
||||||
{
|
{
|
||||||
Pimpl->DrawDebugWristTracker();
|
Pimpl->DrawDebugWristTracker();
|
||||||
@@ -254,8 +251,17 @@ void USGWristTrackerComponent::TickComponent(
|
|||||||
void USGWristTrackerComponent::EditorTick(
|
void USGWristTrackerComponent::EditorTick(
|
||||||
const float DeltaTime, const ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction)
|
const float DeltaTime, const ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction)
|
||||||
{
|
{
|
||||||
|
Pimpl->UpdateXRData();
|
||||||
|
Pimpl->UpdateWristTrackingData();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION < 7
|
||||||
|
const FXRMotionControllerData& USGWristTrackerComponent::GetMotionControllerData() const
|
||||||
|
{
|
||||||
|
return Pimpl->MotionControllerData;
|
||||||
|
}
|
||||||
|
#endif /* ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION < 7 */
|
||||||
|
|
||||||
#if ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 5
|
#if ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 5
|
||||||
const FXRHandTrackingState& USGWristTrackerComponent::GetHandTrackingState() const
|
const FXRHandTrackingState& USGWristTrackerComponent::GetHandTrackingState() const
|
||||||
{
|
{
|
||||||
@@ -321,6 +327,41 @@ void USGWristTrackerComponent::FImpl::UpdateMotionSource() const
|
|||||||
Owner->SetTrackingMotionSource(TrackingMotionSource);
|
Owner->SetTrackingMotionSource(TrackingMotionSource);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void USGWristTrackerComponent::FImpl::UpdateXRData()
|
||||||
|
{
|
||||||
|
const EControllerHand Hand = Owner->IsRight() ? EControllerHand::Right : EControllerHand::Left;
|
||||||
|
|
||||||
|
#if ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION < 7
|
||||||
|
{
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
#endif /* ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION < 7 */
|
||||||
|
|
||||||
|
#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 */
|
||||||
|
}
|
||||||
|
|
||||||
void USGWristTrackerComponent::FImpl::UpdateWristTrackingData() const
|
void USGWristTrackerComponent::FImpl::UpdateWristTrackingData() const
|
||||||
{
|
{
|
||||||
FVector NewWristLocation{Owner->GetComponentLocation()};
|
FVector NewWristLocation{Owner->GetComponentLocation()};
|
||||||
@@ -363,58 +404,6 @@ void USGWristTrackerComponent::FImpl::DrawDebugWristTracker() const
|
|||||||
FSGDebugGizmo::Draw(World, Owner->WristLocation, Owner->WristRotation, DebuggingSettings.DebugWristTrackerSettings);
|
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;
|
|
||||||
|
|
||||||
#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
|
void USGWristTrackerComponent::FImplDeleter::operator()(const FImpl* P) const
|
||||||
{
|
{
|
||||||
delete P;
|
delete P;
|
||||||
|
|||||||
Reference in New Issue
Block a user