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.
|
||||
- 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.
|
||||
- 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.
|
||||
|
||||
@@ -42,9 +42,7 @@
|
||||
#include "Engine/EngineTypes.h"
|
||||
#include "Engine/SkeletalMesh.h"
|
||||
#include "InputCoreTypes.h"
|
||||
#include "IXRTrackingSystem.h"
|
||||
#include "Templates/UnrealTypeTraits.h"
|
||||
#include "TimerManager.h"
|
||||
#include "UObject/ConstructorHelpers.h"
|
||||
|
||||
#include "SenseGlove/Animation/SGVirtualHandAnimInstance.h"
|
||||
@@ -92,13 +90,6 @@ 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
|
||||
************************/
|
||||
@@ -109,15 +100,14 @@ struct USGVirtualHandComponent::FImpl
|
||||
ECollisionEnabled::Type CachedCollisionEnabled;
|
||||
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
|
||||
FXRMotionControllerState MotionControllerState;
|
||||
FXRHandTrackingState HandTrackingState;
|
||||
#endif /* ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 5 */
|
||||
|
||||
FTimerHandle XRDataRetrievalTimer;
|
||||
|
||||
/************************
|
||||
* Owner object
|
||||
************************/
|
||||
@@ -160,6 +150,8 @@ struct USGVirtualHandComponent::FImpl
|
||||
void DisableCollisionResponse();
|
||||
void RestoreCollisionResponse() const;
|
||||
|
||||
void UpdateXRData();
|
||||
|
||||
void SetVisibility(const bool bInVisible);
|
||||
void UpdateVisibility();
|
||||
|
||||
@@ -174,8 +166,6 @@ struct USGVirtualHandComponent::FImpl
|
||||
void DrawDebugVirtualHand() const;
|
||||
|
||||
void TriggerHandVisibilityChangedEvent(bool bNewVisibility) const;
|
||||
|
||||
void StartXRDataRetrievalTimer();
|
||||
};
|
||||
|
||||
FName USGVirtualHandComponent::FImpl::ParseVirtualHandSettingsOverridesPropertyName(const FName& PropertyName)
|
||||
@@ -387,7 +377,7 @@ void USGVirtualHandComponent::InitializeComponent()
|
||||
Pimpl->SetDefaultMesh();
|
||||
}
|
||||
|
||||
Pimpl->StartXRDataRetrievalTimer();
|
||||
Pimpl->UpdateXRData();
|
||||
}
|
||||
|
||||
void USGVirtualHandComponent::UninitializeComponent()
|
||||
@@ -406,6 +396,8 @@ void USGVirtualHandComponent::UninitializeComponent()
|
||||
void USGVirtualHandComponent::BeginPlay()
|
||||
{
|
||||
Super::BeginPlay();
|
||||
|
||||
Pimpl->UpdateXRData();
|
||||
}
|
||||
|
||||
void USGVirtualHandComponent::EndPlay(const EEndPlayReason::Type EndPlayReason)
|
||||
@@ -434,6 +426,8 @@ void USGVirtualHandComponent::TickComponent(
|
||||
|
||||
Super::TickComponent(DeltaTime, TickType, ThisTickFunction);
|
||||
|
||||
Pimpl->UpdateXRData();
|
||||
|
||||
if (Pimpl->ShouldDrawDebugVirtualHand())
|
||||
{
|
||||
Pimpl->DrawDebugVirtualHand();
|
||||
@@ -455,6 +449,8 @@ void USGVirtualHandComponent::SetSkeletalMesh(USkeletalMesh* NewMesh, const bool
|
||||
void USGVirtualHandComponent::EditorTick(
|
||||
const float DeltaTime, const ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction)
|
||||
{
|
||||
Pimpl->UpdateXRData();
|
||||
|
||||
if (Pimpl->ShouldDrawDebugVirtualHand())
|
||||
{
|
||||
Pimpl->DrawDebugVirtualHand();
|
||||
@@ -754,6 +750,42 @@ void USGVirtualHandComponent::FImpl::RestoreCollisionResponse() const
|
||||
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)
|
||||
{
|
||||
Owner->SetHiddenInGame(!bInVisible, false);
|
||||
@@ -863,71 +895,6 @@ 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;
|
||||
|
||||
@@ -36,8 +36,6 @@
|
||||
#include "SenseGlove/Components/SGWristTrackerComponent.h"
|
||||
|
||||
#include "IXRTrackingSystem.h"
|
||||
#include "MotionDelayBuffer.h"
|
||||
#include "TimerManager.h"
|
||||
|
||||
#include "SGBuildHacks/SGPlatform.h"
|
||||
#include "SGDebug/SGDebugGizmo.h"
|
||||
@@ -53,28 +51,20 @@ 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;
|
||||
|
||||
#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
|
||||
FXRMotionControllerState MotionControllerState;
|
||||
FXRHandTrackingState HandTrackingState;
|
||||
#endif /* ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 5 */
|
||||
|
||||
FTimerHandle XRDataRetrievalTimer;
|
||||
|
||||
/************************
|
||||
* Owner object
|
||||
************************/
|
||||
@@ -104,10 +94,10 @@ struct USGWristTrackerComponent::FImpl
|
||||
void OverridePluginSettingsPropertyChanged();
|
||||
|
||||
void UpdateMotionSource() const;
|
||||
void UpdateXRData();
|
||||
void UpdateWristTrackingData() const;
|
||||
void DrawDebugWristTracker() const;
|
||||
|
||||
void StartXRDataRetrievalTimer();
|
||||
void DrawDebugWristTracker() const;
|
||||
};
|
||||
|
||||
USGWristTrackerComponent::USGWristTrackerComponent(const FObjectInitializer& ObjectInitializer)
|
||||
@@ -222,9 +212,9 @@ void USGWristTrackerComponent::InitializeComponent()
|
||||
{
|
||||
Super::InitializeComponent();
|
||||
|
||||
Pimpl->StartXRDataRetrievalTimer();
|
||||
|
||||
Pimpl->UpdateMotionSource();
|
||||
Pimpl->UpdateXRData();
|
||||
Pimpl->UpdateWristTrackingData();
|
||||
}
|
||||
|
||||
void USGWristTrackerComponent::BeginPlay()
|
||||
@@ -232,6 +222,8 @@ void USGWristTrackerComponent::BeginPlay()
|
||||
Super::BeginPlay();
|
||||
|
||||
Pimpl->UpdateMotionSource();
|
||||
Pimpl->UpdateXRData();
|
||||
Pimpl->UpdateWristTrackingData();
|
||||
}
|
||||
|
||||
void USGWristTrackerComponent::TickComponent(
|
||||
@@ -247,6 +239,9 @@ void USGWristTrackerComponent::TickComponent(
|
||||
|
||||
Super::TickComponent(DeltaTime, TickType, ThisTickFunction);
|
||||
|
||||
Pimpl->UpdateXRData();
|
||||
Pimpl->UpdateWristTrackingData();
|
||||
|
||||
if (GetWristTrackingSettings().DebuggingSettings.bDrawDebugWristTracker)
|
||||
{
|
||||
Pimpl->DrawDebugWristTracker();
|
||||
@@ -256,12 +251,16 @@ void USGWristTrackerComponent::TickComponent(
|
||||
void USGWristTrackerComponent::EditorTick(
|
||||
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
|
||||
const FXRHandTrackingState& USGWristTrackerComponent::GetHandTrackingState() const
|
||||
@@ -328,6 +327,41 @@ void USGWristTrackerComponent::FImpl::UpdateMotionSource() const
|
||||
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
|
||||
{
|
||||
FVector NewWristLocation{Owner->GetComponentLocation()};
|
||||
@@ -370,71 +404,6 @@ 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;
|
||||
|
||||
Reference in New Issue
Block a user