remove the hardcoded SG_HAND_MESH_YAW_CORRECTION_OFFSET and rely on FVirtualHandTrackingSettings::RootBoneRotationCorrection
This commit is contained in:
@@ -46,10 +46,9 @@
|
||||
#include "SenseGlove/Components/SGTouchComponent.h"
|
||||
#include "SenseGlove/Components/SGVirtualHandComponent.h"
|
||||
#include "SenseGlove/Components/SGWristTrackerComponent.h"
|
||||
#include "SGSettings/SGSettings.h"
|
||||
#include "SGLog/SGLog.h"
|
||||
|
||||
static constexpr float SG_HAND_MESH_YAW_CORRECTION_OFFSET = -90.0f;
|
||||
|
||||
struct ASGPawn::FImpl
|
||||
{
|
||||
/************************
|
||||
@@ -80,6 +79,13 @@ struct ASGPawn::FImpl
|
||||
* Methods
|
||||
************************/
|
||||
|
||||
FORCEINLINE static const FSGVirtualHandTrackingSettings& GetVirtualHandTrackingSettings()
|
||||
{
|
||||
const USGSettings* Settings{USGSettings::GetInstance()};
|
||||
ensureAlwaysMsgf(Settings, TEXT("The settings subsystem has not been initialized!"));
|
||||
return Settings->GetTrackingSettings().VirtualHandTrackingSettings;
|
||||
}
|
||||
|
||||
void BindRealHandsOverlapEvents();
|
||||
void UnbindRealHandsOverlapEvents();
|
||||
|
||||
@@ -200,7 +206,7 @@ ASGPawn::ASGPawn(const FObjectInitializer& ObjectInitializer)
|
||||
HandLeft->SetCollisionResponseToChannel(ECC_Destructible, ECR_Block);
|
||||
HandLeft->SetRight(false);
|
||||
HandLeft->SetVisibleWhenHandDataUnavailable(false);
|
||||
HandLeft->SetRelativeRotation(FRotator{0.0f, SG_HAND_MESH_YAW_CORRECTION_OFFSET, 0.0f},
|
||||
HandLeft->SetRelativeRotation(FImpl::GetVirtualHandTrackingSettings().RootBoneRotationCorrection,
|
||||
false, nullptr, ETeleportType::None);
|
||||
HandLeft->SetRelativeLocation(FVector{30.0f, -20.0f, -10.0f},
|
||||
false, nullptr, ETeleportType::None);
|
||||
@@ -224,7 +230,7 @@ ASGPawn::ASGPawn(const FObjectInitializer& ObjectInitializer)
|
||||
RealHandLeft->SetRight(false);
|
||||
Pimpl->SetVisibility(RealHandLeft, false);
|
||||
RealHandLeft->SetVisibleWhenHandDataUnavailable(false);
|
||||
RealHandLeft->SetRelativeRotation(FRotator{0.0f, SG_HAND_MESH_YAW_CORRECTION_OFFSET, 0.0f},
|
||||
RealHandLeft->SetRelativeRotation(FImpl::GetVirtualHandTrackingSettings().RootBoneRotationCorrection,
|
||||
false, nullptr, ETeleportType::None);
|
||||
RealHandLeft->SetRelativeLocation(FVector{30.0f, -20.0f, -10.0f},
|
||||
false, nullptr, ETeleportType::None);
|
||||
@@ -359,7 +365,7 @@ ASGPawn::ASGPawn(const FObjectInitializer& ObjectInitializer)
|
||||
HandRight->SetCollisionResponseToChannel(ECC_Destructible, ECR_Block);
|
||||
HandRight->SetRight(true);
|
||||
HandRight->SetVisibleWhenHandDataUnavailable(false);
|
||||
HandRight->SetRelativeRotation(FRotator{0.0f, SG_HAND_MESH_YAW_CORRECTION_OFFSET, 0.0f},
|
||||
HandRight->SetRelativeRotation(FImpl::GetVirtualHandTrackingSettings().RootBoneRotationCorrection,
|
||||
false, nullptr, ETeleportType::None);
|
||||
HandRight->SetRelativeLocation(FVector{30.0f, 20.0f, -10.0f},
|
||||
false, nullptr, ETeleportType::None);
|
||||
@@ -383,7 +389,7 @@ ASGPawn::ASGPawn(const FObjectInitializer& ObjectInitializer)
|
||||
RealHandRight->SetRight(true);
|
||||
Pimpl->SetVisibility(RealHandRight, false);
|
||||
RealHandRight->SetVisibleWhenHandDataUnavailable(false);
|
||||
RealHandRight->SetRelativeRotation(FRotator{0.0f, SG_HAND_MESH_YAW_CORRECTION_OFFSET, 0.0f},
|
||||
RealHandRight->SetRelativeRotation(FImpl::GetVirtualHandTrackingSettings().RootBoneRotationCorrection,
|
||||
false, nullptr, ETeleportType::None);
|
||||
RealHandRight->SetRelativeLocation(FVector{30.0f, 20.0f, -10.0f},
|
||||
false, nullptr, ETeleportType::None);
|
||||
@@ -1695,8 +1701,9 @@ void ASGPawn::FImpl::UpdateHandRotation(const bool bRight, const FRotator& Rotat
|
||||
|
||||
void ASGPawn::FImpl::UpdateLeftHandRotation(const FRotator& Rotation, const bool bUpdateVirtualHand)
|
||||
{
|
||||
static const FQuat Offset{FQuat::MakeFromEuler(FVector{0.0f, 0.0f, SG_HAND_MESH_YAW_CORRECTION_OFFSET})};
|
||||
const FQuat NewRotation{Rotation.Quaternion() * Offset};
|
||||
const FQuat NewRotation{
|
||||
Rotation.Quaternion() * GetVirtualHandTrackingSettings().RootBoneRotationCorrection.Quaternion()
|
||||
};
|
||||
if (bUpdateVirtualHand)
|
||||
{
|
||||
Owner->HandLeft->SetWorldRotation(NewRotation);
|
||||
@@ -1706,8 +1713,9 @@ void ASGPawn::FImpl::UpdateLeftHandRotation(const FRotator& Rotation, const bool
|
||||
|
||||
void ASGPawn::FImpl::UpdateRightHandRotation(const FRotator& Rotation, const bool bUpdateVirtualHand)
|
||||
{
|
||||
static const FQuat Offset{FQuat::MakeFromEuler(FVector{0.0f, 0.0f, SG_HAND_MESH_YAW_CORRECTION_OFFSET})};
|
||||
const FQuat NewRotation{Rotation.Quaternion() * Offset};
|
||||
const FQuat NewRotation{
|
||||
Rotation.Quaternion() * GetVirtualHandTrackingSettings().RootBoneRotationCorrection.Quaternion()
|
||||
};
|
||||
if (bUpdateVirtualHand)
|
||||
{
|
||||
Owner->HandRight->SetWorldRotation(NewRotation);
|
||||
|
||||
@@ -65,9 +65,15 @@ struct USGSettings::FImpl
|
||||
|
||||
USGSettings* USGSettings::GetInstance()
|
||||
{
|
||||
if (!ensureAlwaysMsgf(GEngine, TEXT("The engine has not been initialized!")))
|
||||
/// HACK
|
||||
// Allow the game module to use the settings system in situations when GEngine is not initialized, yet!
|
||||
// e.g. from SGPawn's CDO.
|
||||
if (!GEngine)
|
||||
{
|
||||
return nullptr;
|
||||
USGSettings* StartupInstance{
|
||||
NewObject<USGSettings>(GetTransientPackage(), FName(TEXT("SGSettings")))
|
||||
};
|
||||
return StartupInstance;
|
||||
}
|
||||
|
||||
USGSettings* Instance{GEngine->GetEngineSubsystem<USGSettings>()};
|
||||
|
||||
@@ -51,6 +51,7 @@ public class SenseGloveSettings : ModuleRules
|
||||
"InputCore",
|
||||
"SenseGloveCore",
|
||||
"SenseGloveLog",
|
||||
"SenseGloveSettings",
|
||||
"SenseGloveTypes",
|
||||
}
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user