fix the motion source options crashes
This commit is contained in:
@@ -84,6 +84,7 @@ struct USGWristTrackerComponent::FImpl
|
||||
bool UninitializeBackend() const;
|
||||
bool CheckGlove() const;
|
||||
|
||||
void UpdateMotionSource() const;
|
||||
void UpdateWristTrackingData() const;
|
||||
void DrawDebugGizmo();
|
||||
};
|
||||
@@ -125,12 +126,18 @@ USGWristTrackerComponent::USGWristTrackerComponent(const FObjectInitializer& Obj
|
||||
)
|
||||
);
|
||||
|
||||
bRight = true;
|
||||
|
||||
bBackendInitialized = false;
|
||||
Glove = nullptr;
|
||||
WristLocation = FVector::ZeroVector;
|
||||
WristRotation = FRotator::ZeroRotator;
|
||||
}
|
||||
|
||||
SetRight(true);
|
||||
void USGWristTrackerComponent::SetRight(const bool bInRight)
|
||||
{
|
||||
bRight = bInRight;
|
||||
Pimpl->UpdateMotionSource();
|
||||
}
|
||||
|
||||
const FSGWristTrackingSettings& USGWristTrackerComponent::GetWristTrackingSettings() const
|
||||
@@ -158,13 +165,6 @@ void USGWristTrackerComponent::SetWristTrackingSettings(const FSGWristTrackingSe
|
||||
WristTrackingSettings = InWristTrackingSettings;
|
||||
}
|
||||
|
||||
void USGWristTrackerComponent::SetRight(const bool bRight)
|
||||
{
|
||||
SetTrackingSource(bRight
|
||||
? GetWristTrackingSettings().LeftHandMotionSource
|
||||
: GetWristTrackingSettings().RightHandMotionSource);
|
||||
}
|
||||
|
||||
#if WITH_EDITOR
|
||||
void USGWristTrackerComponent::PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent)
|
||||
{
|
||||
@@ -188,6 +188,8 @@ void USGWristTrackerComponent::InitializeComponent()
|
||||
{
|
||||
(void) Pimpl->CheckGlove();
|
||||
}
|
||||
|
||||
Pimpl->UpdateMotionSource();
|
||||
}
|
||||
|
||||
void USGWristTrackerComponent::UninitializeComponent()
|
||||
@@ -205,6 +207,8 @@ void USGWristTrackerComponent::BeginPlay()
|
||||
{
|
||||
(void) Pimpl->CheckGlove();
|
||||
}
|
||||
|
||||
Pimpl->UpdateMotionSource();
|
||||
}
|
||||
|
||||
void USGWristTrackerComponent::EndPlay(const EEndPlayReason::Type EndPlayReason)
|
||||
@@ -378,6 +382,16 @@ bool USGWristTrackerComponent::FImpl::CheckGlove() const
|
||||
return bFoundGlove;
|
||||
}
|
||||
|
||||
void USGWristTrackerComponent::FImpl::UpdateMotionSource() const
|
||||
{
|
||||
if (GEngine)
|
||||
{
|
||||
Owner->SetTrackingSource(Owner->IsRight()
|
||||
? Owner->GetWristTrackingSettings().LeftHandMotionSource
|
||||
: Owner->GetWristTrackingSettings().RightHandMotionSource);
|
||||
}
|
||||
}
|
||||
|
||||
void USGWristTrackerComponent::FImpl::UpdateWristTrackingData() const
|
||||
{
|
||||
ensureAlwaysMsgf(Owner->Glove, TEXT("Invalid Glove!"));
|
||||
|
||||
@@ -94,17 +94,20 @@ private:
|
||||
FImplDeleter PimplDeleter;
|
||||
|
||||
private:
|
||||
UPROPERTY(EditAnywhere, Category="SenseGlove", meta=(AllowPrivateAccess="false"))
|
||||
uint8 bRight : 1;
|
||||
|
||||
/**
|
||||
* Determines whether to override the plugin's wrist tracking settings or not.
|
||||
*/
|
||||
UPROPERTY(Config, EditAnywhere, Category = "SenseGlove")
|
||||
UPROPERTY(EditAnywhere, Category = "SenseGlove", meta=(AllowPrivateAccess="false"))
|
||||
uint8 bOverridePluginWristTrackingSettings : 1;
|
||||
|
||||
/**
|
||||
* Overrides the plugin's wrist tracking settings.
|
||||
*/
|
||||
UPROPERTY(Config, EditAnywhere, Category = "SenseGlove",
|
||||
meta=(EditCondition="bOverridePluginWristTrackingSettings", EditConditionHides))
|
||||
UPROPERTY(EditAnywhere, Category = "SenseGlove",
|
||||
meta=(AllowPrivateAccess="false", EditCondition="bOverridePluginWristTrackingSettings", EditConditionHides))
|
||||
FSGWristTrackingSettings WristTrackingSettings;
|
||||
|
||||
private:
|
||||
@@ -121,6 +124,18 @@ private:
|
||||
FRotator WristRotation;
|
||||
|
||||
public:
|
||||
FORCEINLINE bool IsLeft() const
|
||||
{
|
||||
return !IsRight();
|
||||
}
|
||||
|
||||
FORCEINLINE bool IsRight() const
|
||||
{
|
||||
return !!bRight;
|
||||
}
|
||||
|
||||
void SetRight(const bool bInRight);
|
||||
|
||||
FORCEINLINE bool OverridesPluginWristTrackingSettings() const
|
||||
{
|
||||
return !!bOverridePluginWristTrackingSettings;
|
||||
@@ -134,18 +149,6 @@ public:
|
||||
const FSGWristTrackingSettings& GetWristTrackingSettings() const;
|
||||
void SetWristTrackingSettings(const FSGWristTrackingSettings& InWristTrackingSettings);
|
||||
|
||||
FORCEINLINE bool IsLeft() const
|
||||
{
|
||||
return GetTrackingSource() == GetWristTrackingSettings().LeftHandMotionSource;
|
||||
}
|
||||
|
||||
FORCEINLINE bool IsRight() const
|
||||
{
|
||||
return GetTrackingSource() == GetWristTrackingSettings().RightHandMotionSource;
|
||||
}
|
||||
|
||||
void SetRight(const bool bRight);
|
||||
|
||||
FORCEINLINE const FVector& GetWristLocation() const
|
||||
{
|
||||
return WristLocation;
|
||||
|
||||
Reference in New Issue
Block a user