allow setting custom hardware offset through the plugin settings
This commit is contained in:
@@ -38,6 +38,7 @@
|
|||||||
#include "Engine/Engine.h"
|
#include "Engine/Engine.h"
|
||||||
|
|
||||||
#include "SGLog/SGLog.h"
|
#include "SGLog/SGLog.h"
|
||||||
|
#include "SGCore/SGTracking.h"
|
||||||
|
|
||||||
struct USGSettings::FImpl
|
struct USGSettings::FImpl
|
||||||
{
|
{
|
||||||
@@ -68,6 +69,8 @@ struct USGSettings::FImpl
|
|||||||
/************************
|
/************************
|
||||||
* Methods
|
* Methods
|
||||||
************************/
|
************************/
|
||||||
|
|
||||||
|
void ResetHardwareOffsetValuesToZero();
|
||||||
};
|
};
|
||||||
|
|
||||||
USGSettings* USGSettings::GetInstance()
|
USGSettings* USGSettings::GetInstance()
|
||||||
@@ -76,17 +79,12 @@ USGSettings* USGSettings::GetInstance()
|
|||||||
return Instance;
|
return Instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
void USGSettings::FImplDeleter::operator()(const FImpl* P) const
|
|
||||||
{
|
|
||||||
delete P;
|
|
||||||
}
|
|
||||||
|
|
||||||
USGSettings::USGSettings()
|
USGSettings::USGSettings()
|
||||||
: Pimpl(TUniquePtr<FImpl, FImplDeleter>(new FImpl{this}, PimplDeleter))
|
: Pimpl(TUniquePtr<FImpl, FImplDeleter>(new FImpl{this}, PimplDeleter))
|
||||||
{
|
{
|
||||||
HardwareOffset = ESGPositionalTrackingHardware::None;
|
HardwareOffset = ESGPositionalTrackingHardware::None;
|
||||||
HardwareLocationOffset = FVector::ZeroVector;
|
|
||||||
HardwareRotationOffset = FRotator::ZeroRotator;
|
Pimpl->ResetHardwareOffsetValuesToZero();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool USGSettings::ShouldCreateSubsystem(UObject* Outer) const
|
bool USGSettings::ShouldCreateSubsystem(UObject* Outer) const
|
||||||
@@ -116,9 +114,57 @@ void USGSettings::Deinitialize()
|
|||||||
SGLOG("The SenseGlove settings singleton has been successfully de-initialized!");
|
SGLOG("The SenseGlove settings singleton has been successfully de-initialized!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if WITH_EDITOR
|
||||||
|
bool USGSettings::CanEditChange(const FProperty* InProperty) const
|
||||||
|
{
|
||||||
|
bool bCanEditChange = Super::CanEditChange(InProperty);
|
||||||
|
|
||||||
|
/*const FName PropertyName{InProperty ? InProperty->GetFName() : NAME_None};
|
||||||
|
|
||||||
|
if (PropertyName == GET_MEMBER_NAME_CHECKED(USGSettings, HardwareOffset))
|
||||||
|
{
|
||||||
|
return HardwareOffset == ESGPositionalTrackingHardware::Custom;
|
||||||
|
}*/
|
||||||
|
|
||||||
|
return bCanEditChange;
|
||||||
|
}
|
||||||
|
#endif /* WITH_EDITOR */
|
||||||
|
|
||||||
|
#if WITH_EDITOR
|
||||||
|
void USGSettings::PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent)
|
||||||
|
{
|
||||||
|
Super::PostEditChangeProperty(PropertyChangedEvent);
|
||||||
|
|
||||||
|
const FName PropertyName{
|
||||||
|
PropertyChangedEvent.Property
|
||||||
|
? PropertyChangedEvent.Property->GetFName()
|
||||||
|
: NAME_None
|
||||||
|
};
|
||||||
|
|
||||||
|
if (PropertyName == GET_MEMBER_NAME_CHECKED(USGSettings, HardwareOffset))
|
||||||
|
{
|
||||||
|
Pimpl->ResetHardwareOffsetValuesToZero();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif /* WITH_EDITOR */
|
||||||
|
|
||||||
USGSettings::FImpl::FImpl(USGSettings* InOwner)
|
USGSettings::FImpl::FImpl(USGSettings* InOwner)
|
||||||
: Owner(InOwner)
|
: Owner(InOwner)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
USGSettings::FImpl::~FImpl() = default;
|
USGSettings::FImpl::~FImpl() = default;
|
||||||
|
|
||||||
|
void USGSettings::FImpl::ResetHardwareOffsetValuesToZero()
|
||||||
|
{
|
||||||
|
Owner->HardwareLocationOffsetLeftHand = FVector::ZeroVector;
|
||||||
|
Owner->HardwareLocationOffsetRightHand = FVector::ZeroVector;
|
||||||
|
Owner->HardwareRotationOffsetLeftHand = FRotator::ZeroRotator;
|
||||||
|
Owner->HardwareRotationOffsetRightHand = FRotator::ZeroRotator;
|
||||||
|
}
|
||||||
|
|
||||||
|
void USGSettings::FImplDeleter::operator()(const FImpl* P) const
|
||||||
|
{
|
||||||
|
delete P;
|
||||||
|
}
|
||||||
@@ -35,6 +35,8 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "Math/Rotator.h"
|
||||||
|
#include "Math/Vector.h"
|
||||||
#include "Subsystems/EngineSubsystem.h"
|
#include "Subsystems/EngineSubsystem.h"
|
||||||
#include "Templates/UniquePtr.h"
|
#include "Templates/UniquePtr.h"
|
||||||
#include "UObject/ObjectMacros.h"
|
#include "UObject/ObjectMacros.h"
|
||||||
@@ -66,6 +68,22 @@ private:
|
|||||||
UPROPERTY(Config, EditDefaultsOnly, Category = "Wrist Tracking")
|
UPROPERTY(Config, EditDefaultsOnly, Category = "Wrist Tracking")
|
||||||
ESGPositionalTrackingHardware HardwareOffset;
|
ESGPositionalTrackingHardware HardwareOffset;
|
||||||
|
|
||||||
|
UPROPERTY(Config, EditDefaultsOnly, Category = "Wrist Tracking",
|
||||||
|
meta=(EditCondition="HardwareOffset == ESGPositionalTrackingHardware::Custom", EditConditionHides))
|
||||||
|
FVector HardwareLocationOffsetLeftHand;
|
||||||
|
|
||||||
|
UPROPERTY(Config, EditDefaultsOnly, Category = "Wrist Tracking",
|
||||||
|
meta=(EditCondition="HardwareOffset == ESGPositionalTrackingHardware::Custom", EditConditionHides))
|
||||||
|
FVector HardwareLocationOffsetRightHand;
|
||||||
|
|
||||||
|
UPROPERTY(Config, EditDefaultsOnly, Category = "Wrist Tracking",
|
||||||
|
meta=(EditCondition="HardwareOffset == ESGPositionalTrackingHardware::Custom", EditConditionHides))
|
||||||
|
FRotator HardwareRotationOffsetLeftHand;
|
||||||
|
|
||||||
|
UPROPERTY(Config, EditDefaultsOnly, Category = "Wrist Tracking",
|
||||||
|
meta=(EditCondition="HardwareOffset == ESGPositionalTrackingHardware::Custom", EditConditionHides))
|
||||||
|
FRotator HardwareRotationOffsetRightHand;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
USGSettings();
|
USGSettings();
|
||||||
|
|
||||||
@@ -85,4 +103,10 @@ public:
|
|||||||
|
|
||||||
virtual void Initialize(FSubsystemCollectionBase& Collection) override;
|
virtual void Initialize(FSubsystemCollectionBase& Collection) override;
|
||||||
virtual void Deinitialize() override;
|
virtual void Deinitialize() override;
|
||||||
|
|
||||||
|
public:
|
||||||
|
#if WITH_EDITOR
|
||||||
|
virtual bool CanEditChange(const FProperty* InProperty) const override;
|
||||||
|
virtual void PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent) override;
|
||||||
|
#endif /* WITH_EDITOR */
|
||||||
};
|
};
|
||||||
@@ -55,6 +55,7 @@ public class SenseGloveSettings : ModuleRules
|
|||||||
"CoreUObject",
|
"CoreUObject",
|
||||||
"Engine",
|
"Engine",
|
||||||
"Settings",
|
"Settings",
|
||||||
|
"SenseGloveCore",
|
||||||
"SenseGloveLog",
|
"SenseGloveLog",
|
||||||
"SenseGloveTypes",
|
"SenseGloveTypes",
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user