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/SGTouchComponent.h"
|
||||||
#include "SenseGlove/Components/SGVirtualHandComponent.h"
|
#include "SenseGlove/Components/SGVirtualHandComponent.h"
|
||||||
#include "SenseGlove/Components/SGWristTrackerComponent.h"
|
#include "SenseGlove/Components/SGWristTrackerComponent.h"
|
||||||
|
#include "SGSettings/SGSettings.h"
|
||||||
#include "SGLog/SGLog.h"
|
#include "SGLog/SGLog.h"
|
||||||
|
|
||||||
static constexpr float SG_HAND_MESH_YAW_CORRECTION_OFFSET = -90.0f;
|
|
||||||
|
|
||||||
struct ASGPawn::FImpl
|
struct ASGPawn::FImpl
|
||||||
{
|
{
|
||||||
/************************
|
/************************
|
||||||
@@ -80,6 +79,13 @@ struct ASGPawn::FImpl
|
|||||||
* Methods
|
* 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 BindRealHandsOverlapEvents();
|
||||||
void UnbindRealHandsOverlapEvents();
|
void UnbindRealHandsOverlapEvents();
|
||||||
|
|
||||||
@@ -200,7 +206,7 @@ ASGPawn::ASGPawn(const FObjectInitializer& ObjectInitializer)
|
|||||||
HandLeft->SetCollisionResponseToChannel(ECC_Destructible, ECR_Block);
|
HandLeft->SetCollisionResponseToChannel(ECC_Destructible, ECR_Block);
|
||||||
HandLeft->SetRight(false);
|
HandLeft->SetRight(false);
|
||||||
HandLeft->SetVisibleWhenHandDataUnavailable(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);
|
false, nullptr, ETeleportType::None);
|
||||||
HandLeft->SetRelativeLocation(FVector{30.0f, -20.0f, -10.0f},
|
HandLeft->SetRelativeLocation(FVector{30.0f, -20.0f, -10.0f},
|
||||||
false, nullptr, ETeleportType::None);
|
false, nullptr, ETeleportType::None);
|
||||||
@@ -224,7 +230,7 @@ ASGPawn::ASGPawn(const FObjectInitializer& ObjectInitializer)
|
|||||||
RealHandLeft->SetRight(false);
|
RealHandLeft->SetRight(false);
|
||||||
Pimpl->SetVisibility(RealHandLeft, false);
|
Pimpl->SetVisibility(RealHandLeft, false);
|
||||||
RealHandLeft->SetVisibleWhenHandDataUnavailable(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);
|
false, nullptr, ETeleportType::None);
|
||||||
RealHandLeft->SetRelativeLocation(FVector{30.0f, -20.0f, -10.0f},
|
RealHandLeft->SetRelativeLocation(FVector{30.0f, -20.0f, -10.0f},
|
||||||
false, nullptr, ETeleportType::None);
|
false, nullptr, ETeleportType::None);
|
||||||
@@ -359,7 +365,7 @@ ASGPawn::ASGPawn(const FObjectInitializer& ObjectInitializer)
|
|||||||
HandRight->SetCollisionResponseToChannel(ECC_Destructible, ECR_Block);
|
HandRight->SetCollisionResponseToChannel(ECC_Destructible, ECR_Block);
|
||||||
HandRight->SetRight(true);
|
HandRight->SetRight(true);
|
||||||
HandRight->SetVisibleWhenHandDataUnavailable(false);
|
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);
|
false, nullptr, ETeleportType::None);
|
||||||
HandRight->SetRelativeLocation(FVector{30.0f, 20.0f, -10.0f},
|
HandRight->SetRelativeLocation(FVector{30.0f, 20.0f, -10.0f},
|
||||||
false, nullptr, ETeleportType::None);
|
false, nullptr, ETeleportType::None);
|
||||||
@@ -383,7 +389,7 @@ ASGPawn::ASGPawn(const FObjectInitializer& ObjectInitializer)
|
|||||||
RealHandRight->SetRight(true);
|
RealHandRight->SetRight(true);
|
||||||
Pimpl->SetVisibility(RealHandRight, false);
|
Pimpl->SetVisibility(RealHandRight, false);
|
||||||
RealHandRight->SetVisibleWhenHandDataUnavailable(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);
|
false, nullptr, ETeleportType::None);
|
||||||
RealHandRight->SetRelativeLocation(FVector{30.0f, 20.0f, -10.0f},
|
RealHandRight->SetRelativeLocation(FVector{30.0f, 20.0f, -10.0f},
|
||||||
false, nullptr, ETeleportType::None);
|
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)
|
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{
|
||||||
const FQuat NewRotation{Rotation.Quaternion() * Offset};
|
Rotation.Quaternion() * GetVirtualHandTrackingSettings().RootBoneRotationCorrection.Quaternion()
|
||||||
|
};
|
||||||
if (bUpdateVirtualHand)
|
if (bUpdateVirtualHand)
|
||||||
{
|
{
|
||||||
Owner->HandLeft->SetWorldRotation(NewRotation);
|
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)
|
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{
|
||||||
const FQuat NewRotation{Rotation.Quaternion() * Offset};
|
Rotation.Quaternion() * GetVirtualHandTrackingSettings().RootBoneRotationCorrection.Quaternion()
|
||||||
|
};
|
||||||
if (bUpdateVirtualHand)
|
if (bUpdateVirtualHand)
|
||||||
{
|
{
|
||||||
Owner->HandRight->SetWorldRotation(NewRotation);
|
Owner->HandRight->SetWorldRotation(NewRotation);
|
||||||
|
|||||||
@@ -65,9 +65,15 @@ struct USGSettings::FImpl
|
|||||||
|
|
||||||
USGSettings* USGSettings::GetInstance()
|
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>()};
|
USGSettings* Instance{GEngine->GetEngineSubsystem<USGSettings>()};
|
||||||
|
|||||||
@@ -51,6 +51,7 @@ public class SenseGloveSettings : ModuleRules
|
|||||||
"InputCore",
|
"InputCore",
|
||||||
"SenseGloveCore",
|
"SenseGloveCore",
|
||||||
"SenseGloveLog",
|
"SenseGloveLog",
|
||||||
|
"SenseGloveSettings",
|
||||||
"SenseGloveTypes",
|
"SenseGloveTypes",
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user