openxr bugfixes and improvements + 1st attempt at calculating the fxrmotioncontrollerdata based off of the hand mesh

This commit is contained in:
Mamadou Babaei
2024-08-16 18:00:52 +02:00
parent f37c184d64
commit c78c28fab2
12 changed files with 708 additions and 136 deletions
@@ -50,6 +50,7 @@
#include "SGCore/SGHapticGlove.h"
#include "SGDebug/SGDebugVirtualHand.h"
#include "SGLog/SGLog.h"
#include "SGSettings/SGSettings.h"
#include "SGTracking/SGGloveTracker.h"
struct USGVirtualHandComponent::FImpl
@@ -86,6 +87,13 @@ struct USGVirtualHandComponent::FImpl
return Path;
}
static const FSGVirtualHandTrackingSettings& GetVirtualHandTrackingSettings()
{
const USGSettings* Settings{USGSettings::GetInstance()};
ensureAlwaysMsgf(Settings, TEXT("The settings subsystem has not been initialized!"));
return Settings->GetTrackingSettings().VirtualHandTrackingSettings;
}
/************************
* Owner object
************************/
@@ -134,68 +142,12 @@ struct USGVirtualHandComponent::FImpl
const TArray<FName>& USGVirtualHandComponent::GetLeftHandBoneNames()
{
static const TArray<FName> BoneNames{
FName{TEXT("palm_l")},// Palm
FName{TEXT("hand_l")},// Wrist
FName{TEXT("thumb_01_l")},// ThumbMetacarpal
FName{TEXT("thumb_02_l")},// ThumbProximal
FName{TEXT("thumb_03_l")},// ThumbDistal
NAME_None,// ThumbTip
FName{TEXT("index_metacarpal_l")},// IndexMetacarpal
FName{TEXT("index_01_l")},// IndexProximal
FName{TEXT("index_02_l")},// IndexIntermediate
FName{TEXT("index_03_l")},// IndexDistal
NAME_None,// IndexTip
FName{TEXT("middle_metacarpal_l")},// MiddleMetacarpal
FName{TEXT("middle_01_l")},// MiddleProximal
FName{TEXT("middle_02_l")},// MiddleIntermediate
FName{TEXT("middle_03_l")},// MiddleDistal
NAME_None,// MiddleTip
FName{TEXT("ring_metacarpal_l")},// RingMetacarpal
FName{TEXT("ring_01_l")},// RingProximal
FName{TEXT("ring_02_l")},// RingIntermediate
FName{TEXT("ring_03_l")},// RingDistal
NAME_None,// RingTip
FName{TEXT("pinky_metacarpal_l")},// LittleMetacarpal
FName{TEXT("pinky_01_l")},// LittleProximal
FName{TEXT("pinky_02_l")},// LittleIntermediate
FName{TEXT("pinky_03_l")},// LittleDistal
NAME_None,// LittleTip
};
return BoneNames;
return FImpl::GetVirtualHandTrackingSettings().LeftHandBoneNames;
}
const TArray<FName>& USGVirtualHandComponent::GetRightHandBoneNames()
{
static const TArray<FName> BoneNames{
FName{TEXT("palm_r")},// Palm
FName{TEXT("hand_r")},// Wrist
FName{TEXT("thumb_01_r")},// ThumbMetacarpal
FName{TEXT("thumb_02_r")},// ThumbProximal
FName{TEXT("thumb_03_r")},// ThumbDistal
NAME_None,// ThumbTip
FName{TEXT("index_metacarpal_r")},// IndexMetacarpal
FName{TEXT("index_01_r")},// IndexProximal
FName{TEXT("index_02_r")},// IndexIntermediate
FName{TEXT("index_03_r")},// IndexDistal
NAME_None,// IndexTip
FName{TEXT("middle_metacarpal_r")},// MiddleMetacarpal
FName{TEXT("middle_01_r")},// MiddleProximal
FName{TEXT("middle_02_r")},// MiddleIntermediate
FName{TEXT("middle_03_r")},// MiddleDistal
NAME_None,// MiddleTip
FName{TEXT("ring_metacarpal_r")},// RingMetacarpal
FName{TEXT("ring_01_r")},// RingProximal
FName{TEXT("ring_02_r")},// RingIntermediate
FName{TEXT("ring_03_r")},// RingDistal
NAME_None,// RingTip
FName{TEXT("pinky_metacarpal_r")},// LittleMetacarpal
FName{TEXT("pinky_01_r")},// LittleProximal
FName{TEXT("pinky_02_r")},// LittleIntermediate
FName{TEXT("pinky_03_r")},// LittleDistal
NAME_None,// LittleTip
};
return BoneNames;
return FImpl::GetVirtualHandTrackingSettings().RightHandBoneNames;
}
const FName& USGVirtualHandComponent::GetLeftHandBoneName(const int32 Joint)
@@ -36,14 +36,15 @@
#include "SGSettings/SGDebugGizmoSettings.h"
FSGDebugGizmoSettings::FSGDebugGizmoSettings()
: Length(4.0f),
Thickness(0.4f),
XAxisColor(255, 0, 0, 255),
YAxisColor(0, 255, 0, 255),
ZAxisColor(0, 0, 255, 255),
bPersistentLines(false),
LifeTimeModifier(1.1),
DepthPriority(0.0f)
: FSGDebugGizmoSettings(
4.0f,
0.4f,
FColor(255, 0, 0, 255),
FColor(0, 255, 0, 255),
FColor(0, 0, 255, 255),
false,
1.1f,
0)
{
}
@@ -36,19 +36,20 @@
#include "SGSettings/SGDebugVirtualHandSettings.h"
FSGDebugVirtualHandSettings::FSGDebugVirtualHandSettings()
: bDrawDebugVirtualHand(false),
DrawingMode(ESGDebugVirtualHandDrawingMode::None),
CubeExtent(FVector(0.5f, 0.5f, 0.5f)),
CubeColor(255, 0, 0, 255),
CubeThickness(0.2f),
GizmoLength(1.0f),
GizmoThickness(0.25f),
GizmoXAxisColor(255, 0, 0, 255),
GizmoYAxisColor(0, 255, 0, 255),
GizmoZAxisColor(0, 0, 255, 255),
bPersistentLines(false),
LifeTimeModifier(1.1f),
DepthPriority(0)
: FSGDebugVirtualHandSettings(
false,
ESGDebugVirtualHandDrawingMode::None,
FVector(0.5f, 0.5f, 0.5f),
FColor(255, 0, 0, 255),
0.2f,
1.0f,
0.25f,
FColor(255, 0, 0, 255),
FColor(0, 255, 0, 255),
FColor(0, 0, 255, 255),
false,
1.1f,
0)
{
}
@@ -36,7 +36,8 @@
#include "SGSettings/SGGloveTrackingSettings.h"
FSGGloveTrackingSettings::FSGGloveTrackingSettings()
: GloveConnectivityCheckInterval(0.125f)
: FSGGloveTrackingSettings(
0.125f)
{
}
@@ -36,7 +36,8 @@
#include "SGSettings/SGHMDTrackingSettings.h"
FSGHMDTrackingSettings::FSGHMDTrackingSettings()
: ViveHMDDetectionPriority(ESGViveHMDDetectionPriority::HtcViveFocus3First)
: FSGHMDTrackingSettings(
ESGViveHMDDetectionPriority::HtcViveFocus3First)
{
}
@@ -36,15 +36,16 @@
#include "SGSettings/SGHandTrackingSettings.h"
FSGHandTrackingSettings::FSGHandTrackingSettings()
: bUseMoreSpecificMotionSourceNames(false),
bSupportLegacyControllerMotionSources(true)
: FSGHandTrackingSettings(
false,
true)
{
}
FSGHandTrackingSettings::FSGHandTrackingSettings(
const bool bInUseMoreSpecificMotionSourceNames,
const bool bInSupportLegacyControllerMotionSources)
: bUseMoreSpecificMotionSourceNames(bInUseMoreSpecificMotionSourceNames),
: bUseMoreSpecificMotionSourceNames(bInUseMoreSpecificMotionSourceNames),
bSupportLegacyControllerMotionSources(bInSupportLegacyControllerMotionSources)
{
}
@@ -36,7 +36,13 @@
#include "SGSettings/SGTrackingSettings.h"
FSGTrackingSettings::FSGTrackingSettings()
: bFallbackToHandTrackingIfNoGloveDetected(true)
: FSGTrackingSettings(
true,
FSGGloveTrackingSettings{},
FSGHandTrackingSettings{},
FSGHMDTrackingSettings{},
FSGVirtualHandTrackingSettings{},
FSGWristTrackingSettings{})
{
}
@@ -45,11 +51,13 @@ FSGTrackingSettings::FSGTrackingSettings(
const FSGGloveTrackingSettings& InGloveTrackingSettings,
const FSGHandTrackingSettings& InHandTrackingSettings,
const FSGHMDTrackingSettings& InHmdTrackingSettings,
const FSGVirtualHandTrackingSettings& InVirtualHandTrackingSettings,
const FSGWristTrackingSettings& InWristTrackingSettings)
: bFallbackToHandTrackingIfNoGloveDetected(bInFallbackToHandTrackingIfNoGloveDetected),\
: bFallbackToHandTrackingIfNoGloveDetected(bInFallbackToHandTrackingIfNoGloveDetected),
GloveTrackingSettings(InGloveTrackingSettings),
HandTrackingSettings(InHandTrackingSettings),
HMDTrackingSettings(InHmdTrackingSettings),
VirtualHandTrackingSettings(InVirtualHandTrackingSettings),
WristTrackingSettings(InWristTrackingSettings)
{
}
@@ -0,0 +1,128 @@
/**
* @file
*
* @author Mamadou Babaei <mamadou@senseglove.com>
*
* @section LICENSE
*
* (The MIT License)
*
* Copyright (c) 2020 - 2024 SenseGlove
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
* @section DESCRIPTION
*
*
*/
#include "SGSettings/SGVirtualHandTrackingSettings.h"
#include "Engine/SkeletalMesh.h"
FSGVirtualHandTrackingSettings::FSGVirtualHandTrackingSettings()
: FSGVirtualHandTrackingSettings(
nullptr,
nullptr,
FRotator{0.0f, -90.0f, 0.0f},
1.0f,
1.0f,
1.0f,
1.0f,
1.0f)
{
}
FSGVirtualHandTrackingSettings::FSGVirtualHandTrackingSettings(
const TSoftObjectPtr<USkeletalMesh>& InLeftHandReferenceMesh,
const TSoftObjectPtr<USkeletalMesh>& InRightHandReferenceMesh,
const FRotator& InHandRootBoneRotationCorrection,
const float InThumbDistalPhalanxLength,
const float InIndexDistalPhalanxLength,
const float InMiddleDistalPhalanxLength,
const float InRingDistalPhalanxLength,
const float InLittleDistalPhalanxLength)
: LeftHandReferenceMesh(InLeftHandReferenceMesh),
RightHandReferenceMesh(InRightHandReferenceMesh),
HandRootBoneRotationCorrection(InHandRootBoneRotationCorrection),
ThumbDistalPhalanxLength(InThumbDistalPhalanxLength),
IndexDistalPhalanxLength(InIndexDistalPhalanxLength),
MiddleDistalPhalanxLength(InMiddleDistalPhalanxLength),
RingDistalPhalanxLength(InRingDistalPhalanxLength),
LittleDistalPhalanxLength(InLittleDistalPhalanxLength),
LeftHandBoneNames{
FName{TEXT("palm_l")},// Palm
FName{TEXT("hand_l")},// Wrist
FName{TEXT("thumb_01_l")},// ThumbMetacarpal
FName{TEXT("thumb_02_l")},// ThumbProximal
FName{TEXT("thumb_03_l")},// ThumbDistal
NAME_None,// ThumbTip
FName{TEXT("index_metacarpal_l")},// IndexMetacarpal
FName{TEXT("index_01_l")},// IndexProximal
FName{TEXT("index_02_l")},// IndexIntermediate
FName{TEXT("index_03_l")},// IndexDistal
NAME_None,// IndexTip
FName{TEXT("middle_metacarpal_l")},// MiddleMetacarpal
FName{TEXT("middle_01_l")},// MiddleProximal
FName{TEXT("middle_02_l")},// MiddleIntermediate
FName{TEXT("middle_03_l")},// MiddleDistal
NAME_None,// MiddleTip
FName{TEXT("ring_metacarpal_l")},// RingMetacarpal
FName{TEXT("ring_01_l")},// RingProximal
FName{TEXT("ring_02_l")},// RingIntermediate
FName{TEXT("ring_03_l")},// RingDistal
NAME_None,// RingTip
FName{TEXT("pinky_metacarpal_l")},// LittleMetacarpal
FName{TEXT("pinky_01_l")},// LittleProximal
FName{TEXT("pinky_02_l")},// LittleIntermediate
FName{TEXT("pinky_03_l")},// LittleDistal
NAME_None,// LittleTip
},
RightHandBoneNames{
FName{TEXT("palm_r")},// Palm
FName{TEXT("hand_r")},// Wrist
FName{TEXT("thumb_01_r")},// ThumbMetacarpal
FName{TEXT("thumb_02_r")},// ThumbProximal
FName{TEXT("thumb_03_r")},// ThumbDistal
NAME_None,// ThumbTip
FName{TEXT("index_metacarpal_r")},// IndexMetacarpal
FName{TEXT("index_01_r")},// IndexProximal
FName{TEXT("index_02_r")},// IndexIntermediate
FName{TEXT("index_03_r")},// IndexDistal
NAME_None,// IndexTip
FName{TEXT("middle_metacarpal_r")},// MiddleMetacarpal
FName{TEXT("middle_01_r")},// MiddleProximal
FName{TEXT("middle_02_r")},// MiddleIntermediate
FName{TEXT("middle_03_r")},// MiddleDistal
NAME_None,// MiddleTip
FName{TEXT("ring_metacarpal_r")},// RingMetacarpal
FName{TEXT("ring_01_r")},// RingProximal
FName{TEXT("ring_02_r")},// RingIntermediate
FName{TEXT("ring_03_r")},// RingDistal
NAME_None,// RingTip
FName{TEXT("pinky_metacarpal_r")},// LittleMetacarpal
FName{TEXT("pinky_01_r")},// LittleProximal
FName{TEXT("pinky_02_r")},// LittleIntermediate
FName{TEXT("pinky_03_r")},// LittleDistal
NAME_None// LittleTip
}
{
}
@@ -36,15 +36,16 @@
#include "SGSettings/SGWristTrackingSettings.h"
FSGWristTrackingSettings::FSGWristTrackingSettings()
: TrackingHardware(ESGPositionalTrackingHardware::None),
TrackingHardwareLocationOffsetLeftHand(FVector::ZeroVector),
TrackingHardwareLocationOffsetRightHand(FVector::ZeroVector),
TrackingHardwareRotationOffsetLeftHand(FRotator::ZeroRotator),
TrackingHardwareRotationOffsetRightHand(FRotator::ZeroRotator),
LeftHandMotionSource(EControllerHand::Left),
RightHandMotionSource(EControllerHand::Right),
bDrawDebugGizmo(false),
DebugGizmoSettings(FSGDebugGizmoSettings{})
: FSGWristTrackingSettings(
ESGPositionalTrackingHardware::None,
FVector::ZeroVector,
FVector::ZeroVector,
FRotator::ZeroRotator,
FRotator::ZeroRotator,
EControllerHand::Left,
EControllerHand::Right,
false,
FSGDebugGizmoSettings{})
{
}
@@ -40,6 +40,7 @@
#include "SGSettings/SGGloveTrackingSettings.h"
#include "SGSettings/SGHandTrackingSettings.h"
#include "SGSettings/SGHMDTrackingSettings.h"
#include "SGSettings/SGVirtualHandTrackingSettings.h"
#include "SGSettings/SGWristTrackingSettings.h"
#include "SGTrackingSettings.generated.h"
@@ -70,6 +71,9 @@ public:
UPROPERTY(Config, EditDefaultsOnly, Category="Tracking")
FSGHMDTrackingSettings HMDTrackingSettings;
UPROPERTY(Config, EditDefaultsOnly, Category="Tracking")
FSGVirtualHandTrackingSettings VirtualHandTrackingSettings;
UPROPERTY(Config, EditDefaultsOnly, Category="Tracking")
FSGWristTrackingSettings WristTrackingSettings;
@@ -81,5 +85,6 @@ public:
const FSGGloveTrackingSettings& InGloveTrackingSettings,
const FSGHandTrackingSettings& InHandTrackingSettings,
const FSGHMDTrackingSettings& InHmdTrackingSettings,
const FSGVirtualHandTrackingSettings& InVirtualHandTrackingSettings,
const FSGWristTrackingSettings& InWristTrackingSettings);
};
@@ -0,0 +1,97 @@
/**
* @file
*
* @author Mamadou Babaei <mamadou@senseglove.com>
*
* @section LICENSE
*
* (The MIT License)
*
* Copyright (c) 2020 - 2024 SenseGlove
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
* @section DESCRIPTION
*
*
*/
#pragma once
#include "UObject/ObjectMacros.h"
#include "UObject/SoftObjectPtr.h"
#include "SGVirtualHandTrackingSettings.generated.h"
USkeletalMesh;
/**
* Implements the hand tracking settings for the SenseGlove Tracking module.
*/
USTRUCT(BlueprintType)
struct SENSEGLOVESETTINGS_API FSGVirtualHandTrackingSettings
{
GENERATED_USTRUCT_BODY()
public:
UPROPERTY(Config, EditDefaultsOnly, Category="Virtual Hand")
TSoftObjectPtr<USkeletalMesh> LeftHandReferenceMesh;
UPROPERTY(Config, EditDefaultsOnly, Category="Virtual Hand")
TSoftObjectPtr<USkeletalMesh> RightHandReferenceMesh;
UPROPERTY(Config, EditDefaultsOnly, Category="Virtual Hand")
FRotator HandRootBoneRotationCorrection;
UPROPERTY(Config, EditDefaultsOnly, Category="Virtual Hand")
float ThumbDistalPhalanxLength;
UPROPERTY(Config, EditDefaultsOnly, Category="Virtual Hand")
float IndexDistalPhalanxLength;
UPROPERTY(Config, EditDefaultsOnly, Category="Virtual Hand")
float MiddleDistalPhalanxLength;
UPROPERTY(Config, EditDefaultsOnly, Category="Virtual Hand")
float RingDistalPhalanxLength;
UPROPERTY(Config, EditDefaultsOnly, Category="Virtual Hand")
float LittleDistalPhalanxLength;
UPROPERTY(Config, VisibleDefaultsOnly, Category="Virtual Hand")
TArray<FName> LeftHandBoneNames;
UPROPERTY(Config, VisibleDefaultsOnly, Category="Virtual Hand")
TArray<FName> RightHandBoneNames;
public:
FSGVirtualHandTrackingSettings();
FSGVirtualHandTrackingSettings(
const TSoftObjectPtr<USkeletalMesh>& InLeftHandReferenceMesh,
const TSoftObjectPtr<USkeletalMesh>& InRightHandReferenceMesh,
const FRotator& InHandRootBoneRotationCorrection,
float InThumbDistalPhalanxLength,
float InIndexDistalPhalanxLength,
float InMiddleDistalPhalanxLength,
float InRingDistalPhalanxLength,
float InLittleDistalPhalanxLength);
};
@@ -41,6 +41,7 @@
#include "Editor.h"
#endif /* WITH_EDITOR */
#include "Engine/Engine.h"
#include "Engine/SkeletalMesh.h"
#include "Engine/World.h"
#include "GameFramework/WorldSettings.h"
#include "IOpenXRHMDModule.h"
@@ -124,7 +125,21 @@ struct FSGXRTracker::FImpl
return bSupportLegacyControllerMotionSources;
}
static const FSGWristTrackingSettings& GetWristTrackingSettings()
FORCEINLINE static const FSGHandTrackingSettings& GetHandTrackingSettings()
{
const USGSettings* Settings{USGSettings::GetInstance()};
ensureAlwaysMsgf(Settings, TEXT("The settings subsystem has not been initialized!"));
return Settings->GetTrackingSettings().HandTrackingSettings;
}
FORCEINLINE static const FSGVirtualHandTrackingSettings& GetVirtualHandTrackingSettings()
{
const USGSettings* Settings{USGSettings::GetInstance()};
ensureAlwaysMsgf(Settings, TEXT("The settings subsystem has not been initialized!"));
return Settings->GetTrackingSettings().VirtualHandTrackingSettings;
}
FORCEINLINE static const FSGWristTrackingSettings& GetWristTrackingSettings()
{
const USGSettings* Settings{USGSettings::GetInstance()};
ensureAlwaysMsgf(Settings, TEXT("The settings subsystem has not been initialized!"));
@@ -135,9 +150,9 @@ struct FSGXRTracker::FImpl
FORCEINLINE static USGHapticGlove* GetGlove(const EControllerHand Hand)
{
const bool bIsRightHand = Hand == EControllerHand::Right;
const bool bRight = Hand == EControllerHand::Right;
const USGGloveTracker* GloveTracker{USGGloveTracker::GetInstance()};
return IsValid(GloveTracker) ? GloveTracker->GetGlove(bIsRightHand) : nullptr;
return IsValid(GloveTracker) ? GloveTracker->GetGlove(bRight) : nullptr;
}
FORCEINLINE static USGHapticGlove* GetGlove(const bool bRight)
@@ -160,9 +175,9 @@ struct FSGXRTracker::FImpl
FORCEINLINE static bool IsGloveConnected(const EControllerHand Hand)
{
const bool bIsRightHand = Hand == EControllerHand::Right;
const bool bRight = Hand == EControllerHand::Right;
const USGGloveTracker* GloveTracker{USGGloveTracker::GetInstance()};
return IsValid(GloveTracker) ? GloveTracker->IsGloveConnected(bIsRightHand) : false;
return IsValid(GloveTracker) ? GloveTracker->IsGloveConnected(bRight) : false;
}
FORCEINLINE static bool IsGloveConnected(const bool bRight)
@@ -189,6 +204,230 @@ struct FSGXRTracker::FImpl
return IsValid(GloveTracker) ? GloveTracker->IsAnyGloveConnected() : false;
}
FORCEINLINE static const FName& GetLeftMeshBoneName(const int32 JointIndex)
{
const FName& Name{GetVirtualHandTrackingSettings().LeftHandBoneNames[JointIndex]};
return Name;
}
FORCEINLINE static const FName& GetLeftMeshBoneName(const EHandKeypoint HandKeypoint)
{
const int32 JointIndex = static_cast<int32>(HandKeypoint);
const FName& Name{GetLeftMeshBoneName(JointIndex)};
return Name;
}
FORCEINLINE static const FName& GetRightMeshBoneName(const int32 JointIndex)
{
const FName& Name{GetVirtualHandTrackingSettings().RightHandBoneNames[JointIndex]};
return Name;
}
FORCEINLINE static const FName& GetRightMeshBoneName(const EHandKeypoint HandKeypoint)
{
const int32 JointIndex = static_cast<int32>(HandKeypoint);
const FName& Name{GetRightMeshBoneName(JointIndex)};
return Name;
}
FORCEINLINE static const FName& GetMeshBoneName(const bool bRight, const int32 Joint)
{
const FName& Name{
bRight
? GetRightMeshBoneName(Joint)
: GetLeftMeshBoneName(Joint)
};
return Name;
}
FORCEINLINE static const FName& GetMeshBoneName(const bool bRight, const EHandKeypoint HandKeypoint)
{
const int32 JointIndex = static_cast<int32>(HandKeypoint);
const FName& Name{GetMeshBoneName(bRight, JointIndex)};
return Name;
}
FORCEINLINE static const FName& GetMeshBoneName(const EControllerHand Hand, const int32 JointIndex)
{
const bool bRight = Hand == EControllerHand::Right;
const FName& Name{GetMeshBoneName(bRight, JointIndex)};
return Name;
}
static const FTransform& GetMeshBoneRefTransform(bool bRight, const FName& BoneName);
FORCEINLINE static const FTransform& GetMeshBoneRefTransform(const bool bRight, const int32 JointIndex)
{
const FName& Name{GetMeshBoneName(bRight, JointIndex)};
const FTransform& Transform{GetMeshBoneRefTransform(bRight, Name)};
return Transform;
}
FORCEINLINE static const FTransform& GetMeshBoneRefTransform(const bool bRight, const EHandKeypoint Keypoint)
{
const FName& Name{GetMeshBoneName(bRight, Keypoint)};
const FTransform& Transform{GetMeshBoneRefTransform(bRight, Name)};
return Transform;
}
FORCEINLINE static const FTransform& GetMeshBoneRefTransform(const EControllerHand Hand, const FName& BoneName)
{
const bool bRight = Hand == EControllerHand::Right;
const FTransform& Transform{GetMeshBoneRefTransform(bRight, BoneName)};
return Transform;
}
FORCEINLINE static const FTransform& GetMeshBoneRefTransform(const EControllerHand Hand, const int32 JointIndex)
{
const bool bRight = Hand == EControllerHand::Right;
const FTransform& Transform{GetMeshBoneRefTransform(bRight, JointIndex)};
return Transform;
}
FORCEINLINE static const FTransform& GetMeshBoneRefTransform(
const EControllerHand Hand, const EHandKeypoint Keypoint)
{
const bool bRight = Hand == EControllerHand::Right;
const FTransform& Transform{GetMeshBoneRefTransform(bRight, Keypoint)};
return Transform;
}
FORCEINLINE static const FVector& GetMeshDefaultRootBoneLocation(const bool bRight)
{
static const FVector LocationLeft{0.0f, 0.0f, 0.0f};
static const FVector LocationRight{0.0f, 0.0f, 0.0f};
return bRight ? LocationRight : LocationLeft;
}
FORCEINLINE static const FQuat& GetMeshDefaultRootBoneRotation(const bool bRight)
{
static const FQuat RotationLeft{FRotator{0.0f, -180.0f, 90.0f}};
static const FQuat RotationRight{FRotator{0.0f, -180.0f, 90.0f}};
return bRight ? RotationRight : RotationLeft;
}
FORCEINLINE static const FVector& GetMeshDefaultPalmBoneLocation(const bool bRight)
{
static const FVector LocationLeft{0.0f, 0.0f, -6.615570f};
static const FVector LocationRight{0.000052f, -0.000629f, -6.615405f};
return bRight ? LocationRight : LocationLeft;
}
FORCEINLINE static const FQuat& GetMeshDefaultPalmBoneRotation(const bool bRight)
{
static const FQuat RotationLeft{FRotator{0.0f, 0.0f, 0.0f}};
static const FQuat RotationRight{FRotator{0.0f, 0.0f, 0.0f}};
return bRight ? RotationRight : RotationLeft;
}
FORCEINLINE static const FVector& GetMeshDefaultIndexMetacarpalBoneLocation(const bool bRight)
{
static const FVector LocationLeft{2.379324f, -0.384681f, -3.444506f};
static const FVector LocationRight{-2.379309f, -0.385167f, -3.444514f};
return bRight ? LocationRight : LocationLeft;
}
FORCEINLINE static const FQuat& GetMeshDefaultIndexMetacarpalBoneRotation(const bool bRight)
{
static const FQuat RotationLeft{FRotator{7.277920f, 3.392215f, 1.032481f}};
static const FQuat RotationRight{FRotator{-7.277920f, -3.392215f, 1.032481f}};
return bRight ? RotationRight : RotationLeft;
}
FORCEINLINE static const FVector& GetMeshDefaultMiddleMetacarpalBoneLocation(const bool bRight)
{
static const FVector LocationLeft{0.182864f, -0.753571f, -3.375834f};
static const FVector LocationRight{-0.182806f, -0.754004f, -3.37580f};
return bRight ? LocationRight : LocationLeft;
}
FORCEINLINE static const FQuat& GetMeshDefaultMiddleMetacarpalBoneRotation(const bool bRight)
{
static const FQuat RotationLeft{FRotator{0.042392f, -4.274287f, 2.321687f}};
static const FQuat RotationRight{FRotator{-0.042392f, 4.274287f, 2.321687f}};
return bRight ? RotationRight : RotationLeft;
}
FORCEINLINE static const FVector& GetMeshDefaultRingMetacarpalBoneLocation(const bool bRight)
{
static const FVector LocationLeft{-1.091757f, -0.542517f, -3.374304f};
static const FVector LocationRight{1.091782f, -0.542992f, -3.374208f};
return bRight ? LocationRight : LocationLeft;
}
FORCEINLINE static const FQuat& GetMeshDefaultRingMetacarpalBoneRotation(const bool bRight)
{
static const FQuat RotationLeft{FRotator{-11.109678f, -13.886395f, 4.333313f}};
static const FQuat RotationRight{FRotator{11.109678f, 13.886395f, 4.333313f}};
return bRight ? RotationRight : RotationLeft;
}
FORCEINLINE static const FVector& GetMeshDefaultLittleMetacarpalBoneLocation(const bool bRight)
{
static const FVector LocationLeft{-2.391111f, -0.305917f, -3.314378f};
static const FVector LocationRight{2.391287f, -0.305935f, -3.314677f};
return bRight ? LocationRight : LocationLeft;
}
FORCEINLINE static const FQuat& GetMeshDefaultLittleMetacarpalBoneRotation(const bool bRight)
{
static const FQuat RotationLeft{FRotator{-22.652560f, -25.358337f, -1.818999f}};
static const FQuat RotationRight{FRotator{22.652560f, 25.358337f, -1.818999f}};
return bRight ? RotationRight : RotationLeft;
}
static const FVector& GetMeshDefaultBoneLocation(bool bRight, const FName& BoneName);
static const FQuat& GetMeshDefaultBoneRotation(bool bRight, const FName& BoneName);
FORCEINLINE static FTransform GetMeshBoneDefaultRefTransform(const bool bRight, const FName& BoneName)
{
const FTransform Transform{
GetMeshDefaultBoneRotation(bRight, BoneName), GetMeshDefaultBoneLocation(bRight, BoneName)
};
return Transform;
}
static FTransform GetRootAppliedMeshBoneRefTransformOrDefault(bool bRight, const FName& BoneName);
FORCEINLINE static FTransform GetRootAppliedMeshBoneRefTransformOrDefault(const bool bRight, const int32 JointIndex)
{
const FName& Name{GetMeshBoneName(bRight, JointIndex)};
const FTransform Transform{GetRootAppliedMeshBoneRefTransformOrDefault(bRight, Name)};
return Transform;
}
FORCEINLINE static FTransform GetRootAppliedMeshBoneRefTransformOrDefault(
const bool bRight, const EHandKeypoint Keypoint)
{
const FName& Name{GetMeshBoneName(bRight, Keypoint)};
const FTransform Transform{GetRootAppliedMeshBoneRefTransformOrDefault(bRight, Name)};
return Transform;
}
FORCEINLINE static FTransform GetRootAppliedMeshBoneRefTransformOrDefault(
const EControllerHand Hand, const FName& BoneName)
{
const bool bRight = Hand == EControllerHand::Right;
const FTransform Transform{GetRootAppliedMeshBoneRefTransformOrDefault(bRight, BoneName)};
return Transform;
}
FORCEINLINE static FTransform GetRootAppliedMeshBoneRefTransformOrDefault(
const EControllerHand Hand, const int32 JointIndex)
{
const bool bRight = Hand == EControllerHand::Right;
const FTransform Transform{GetRootAppliedMeshBoneRefTransformOrDefault(bRight, JointIndex)};
return Transform;
}
FORCEINLINE static FTransform GetRootAppliedMeshBoneRefTransformOrDefault(
const EControllerHand Hand, const EHandKeypoint Keypoint)
{
const bool bRight = Hand == EControllerHand::Right;
const FTransform Transform{GetRootAppliedMeshBoneRefTransformOrDefault(bRight, Keypoint)};
return Transform;
}
/************************
* Member variables
************************/
@@ -269,36 +508,41 @@ struct FSGXRTracker::FImpl
bool UpdateSGPalmJointData(
FSGXRHandState& OutHandState,
const TArray<TArray<FVector>>& JointLocations, const TArray<TArray<FQuat>>& JointRotations,
EControllerHand DeviceHand,
const FVector& WristLocation, const FQuat& WristRotation,
bool bMotionSourceHandTracking) const;
bool UpdateSGThumbJointData(
FSGXRHandState& OutHandState,
EControllerHand DeviceHand,
const TArray<TArray<FVector>>& JointLocations, const TArray<TArray<FQuat>>& JointRotations,
const FVector& WristLocation, const FQuat& WristRotation,
bool bMotionSourceHandTracking) const;
bool UpdateSGIndexJointData(
FSGXRHandState& OutHandState,
EControllerHand DeviceHand,
const TArray<TArray<FVector>>& JointLocations, const TArray<TArray<FQuat>>& JointRotations,
const FVector& WristLocation, const FQuat& WristRotation,
bool bMotionSourceHandTracking) const;
bool UpdateSGMiddleJointData(
FSGXRHandState& OutHandState,
EControllerHand DeviceHand,
const TArray<TArray<FVector>>& JointLocations, const TArray<TArray<FQuat>>& JointRotations,
const FVector& WristLocation, const FQuat& WristRotation,
bool bMotionSourceHandTracking) const;
bool UpdateSGRingJointData(
FSGXRHandState& OutHandState,
EControllerHand DeviceHand,
const TArray<TArray<FVector>>& JointLocations, const TArray<TArray<FQuat>>& JointRotations,
const FVector& WristLocation, const FQuat& WristRotation,
bool bMotionSourceHandTracking) const;
bool UpdateSGLittleJointData(
FSGXRHandState& OutHandState,
EControllerHand DeviceHand,
const TArray<TArray<FVector>>& JointLocations, const TArray<TArray<FQuat>>& JointRotations,
const FVector& WristLocation, const FQuat& WristRotation,
bool bMotionSourceHandTracking) const;
@@ -413,6 +657,121 @@ ESGPositionalTrackingHardware FSGXRTracker::FImpl::GetPositionalTrackingHardware
return TrackerHardware;
}
const FTransform& FSGXRTracker::FImpl::GetMeshBoneRefTransform(const bool bRight, const FName& BoneName)
{
const FReferenceSkeleton& ReferenceSkeleton{
bRight
? GetVirtualHandTrackingSettings().LeftHandReferenceMesh->GetRefSkeleton()
: GetVirtualHandTrackingSettings().RightHandReferenceMesh->GetRefSkeleton()
};
const int32 BoneIndex = ReferenceSkeleton.FindBoneIndex(BoneName);
if (BoneIndex == INDEX_NONE)
{
SGLOG_WARNING(FString::Printf(TEXT("Could not find a bone index for the '%s' joint!"),
*BoneName.ToString()));
return FTransform::Identity;
}
const FTransform& BoneTransform{ReferenceSkeleton.GetRefBonePose()[BoneIndex]};
return BoneTransform;
}
const FVector& FSGXRTracker::FImpl::GetMeshDefaultBoneLocation(const bool bRight, const FName& BoneName)
{
static const FVector Dummy{FVector::ZeroVector};
if (BoneName == GetMeshBoneName(bRight, EHandKeypoint::Palm))
{
return GetMeshDefaultPalmBoneLocation(bRight);
}
if (BoneName == GetMeshBoneName(bRight, EHandKeypoint::IndexMetacarpal))
{
return GetMeshDefaultIndexMetacarpalBoneLocation(bRight);
}
if (BoneName == GetMeshBoneName(bRight, EHandKeypoint::MiddleMetacarpal))
{
return GetMeshDefaultMiddleMetacarpalBoneLocation(bRight);
}
if (BoneName == GetMeshBoneName(bRight, EHandKeypoint::RingMetacarpal))
{
return GetMeshDefaultRingMetacarpalBoneLocation(bRight);
}
if (BoneName == GetMeshBoneName(bRight, EHandKeypoint::LittleMetacarpal))
{
return GetMeshDefaultLittleMetacarpalBoneLocation(bRight);
}
ensureAlwaysMsgf(false, TEXT("FATAL: the code flow should never reach here!"));
return Dummy;
}
const FQuat& FSGXRTracker::FImpl::GetMeshDefaultBoneRotation(const bool bRight, const FName& BoneName)
{
static const FQuat Dummy{FQuat::Identity};
if (BoneName == GetMeshBoneName(bRight, EHandKeypoint::Palm))
{
return GetMeshDefaultPalmBoneRotation(bRight);
}
if (BoneName == GetMeshBoneName(bRight, EHandKeypoint::IndexMetacarpal))
{
return GetMeshDefaultIndexMetacarpalBoneRotation(bRight);
}
if (BoneName == GetMeshBoneName(bRight, EHandKeypoint::MiddleMetacarpal))
{
return GetMeshDefaultMiddleMetacarpalBoneRotation(bRight);
}
if (BoneName == GetMeshBoneName(bRight, EHandKeypoint::RingMetacarpal))
{
return GetMeshDefaultRingMetacarpalBoneRotation(bRight);
}
if (BoneName == GetMeshBoneName(bRight, EHandKeypoint::LittleMetacarpal))
{
return GetMeshDefaultLittleMetacarpalBoneRotation(bRight);
}
ensureAlwaysMsgf(false, TEXT("FATAL: the code flow should never reach here!"));
return Dummy;
}
FTransform FSGXRTracker::FImpl::GetRootAppliedMeshBoneRefTransformOrDefault(const bool bRight, const FName& BoneName)
{
FTransform Transform;
const FQuat RootRotationCorrection{GetVirtualHandTrackingSettings().HandRootBoneRotationCorrection.Quaternion()};
if ((bRight && GetVirtualHandTrackingSettings().RightHandReferenceMesh.IsValid())
|| (!bRight && GetVirtualHandTrackingSettings().LeftHandReferenceMesh.IsValid()))
{
FTransform RootBoneRefTransform{GetMeshBoneRefTransform(bRight, EHandKeypoint::Wrist)};
RootBoneRefTransform.SetRotation(RootRotationCorrection * RootBoneRefTransform.GetRotation());
Transform = GetMeshBoneRefTransform(bRight, BoneName) * RootBoneRefTransform;
}
else
{
FTransform RootBoneRefTransform{
GetMeshDefaultRootBoneRotation(bRight), GetMeshDefaultRootBoneLocation(bRight)
};
RootBoneRefTransform.SetRotation(RootRotationCorrection * RootBoneRefTransform.GetRotation());
Transform = FTransform{
GetMeshDefaultBoneRotation(bRight, BoneName), GetMeshDefaultBoneLocation(bRight, BoneName)
} * RootBoneRefTransform;
}
return Transform;
}
FName FSGXRTracker::ParseEOpenXRHandKeypointEnumName(const FName& EnumName)
{
static const int32 EnumNameLength = FString{TEXT("EHandKeypoint::")}.Len();
@@ -650,7 +1009,7 @@ bool FSGXRTracker::GetControllerOrientationAndPosition(const int32 ControllerInd
#if ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 3
ControllerTransform = GetLeftHandState().GetTransform(KeyPoint);
#else /* ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 3 */
ControllerTransform = GetLeftHandState().GetTransform(EHandKeypoint::Palm);
ControllerTransform = GetLeftHandState().GetTransform(EHandKeypoint::Wrist);
#endif /* ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 3 */
bTracked = !!GetLeftHandState().bReceivedJointPoses;
}
@@ -659,7 +1018,7 @@ bool FSGXRTracker::GetControllerOrientationAndPosition(const int32 ControllerInd
#if ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 3
ControllerTransform = GetRightHandState().GetTransform(KeyPoint);
#else /* ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 3 */
ControllerTransform = GetRightHandState().GetTransform(EHandKeypoint::Palm);
ControllerTransform = GetRightHandState().GetTransform(EHandKeypoint::Wrist);
#endif /* ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 3 */
bTracked = !!GetRightHandState().bReceivedJointPoses;
}
@@ -1028,8 +1387,8 @@ void FSGXRTracker::FImpl::BuildMotionSourceToKeypointMap()
if (bSupportLegacyControllerMotionSources)
{
MotionSourceToKeypointMap.Add(FName("Left"), FSGMotionSourceInfo(EHandKeypoint::Palm, true));
MotionSourceToKeypointMap.Add(FName("Right"), FSGMotionSourceInfo(EHandKeypoint::Palm, false));
MotionSourceToKeypointMap.Add(FName("Left"), FSGMotionSourceInfo(EHandKeypoint::Wrist, true));
MotionSourceToKeypointMap.Add(FName("Right"), FSGMotionSourceInfo(EHandKeypoint::Wrist, false));
}
}
@@ -1310,7 +1669,7 @@ bool FSGXRTracker::FImpl::UpdateSGWristJointData(
bool FSGXRTracker::FImpl::UpdateSGPalmJointData(
FSGXRHandState& OutHandState,
const TArray<TArray<FVector>>& JointLocations, const TArray<TArray<FQuat>>& JointRotations,
const EControllerHand DeviceHand,
const FVector& WristLocation, const FQuat& WristRotation,
const bool bMotionSourceHandTracking) const
{
@@ -1319,15 +1678,12 @@ bool FSGXRTracker::FImpl::UpdateSGPalmJointData(
return false;
}
static constexpr int32 MiddleFingerMiddle = 2;
static constexpr int32 MiddleProximalJointMiddle = 0;
const FVector& MiddleProximalLocation{JointLocations[MiddleFingerMiddle][MiddleProximalJointMiddle]};
static const FVector JointLocation{MiddleProximalLocation / 2.0f};
static const FQuat JointRotation{FQuat::Identity};
const FTransform JointTransform{GetRootAppliedMeshBoneRefTransformOrDefault(DeviceHand, EHandKeypoint::Palm)};
FVector JointLocation{JointTransform.GetLocation()};
FQuat JointRotation{JointTransform.GetRotation()};
if (!UpdateSGJointData(OutHandState, EHandKeypoint::Palm,
JointLocation, JointRotation, WristLocation, WristRotation,
MoveTemp(JointLocation), MoveTemp(JointRotation), WristLocation, WristRotation,
bMotionSourceHandTracking))
{
return false;
@@ -1338,6 +1694,7 @@ bool FSGXRTracker::FImpl::UpdateSGPalmJointData(
bool FSGXRTracker::FImpl::UpdateSGThumbJointData(
FSGXRHandState& OutHandState,
const EControllerHand DeviceHand,
const TArray<TArray<FVector>>& JointLocations, const TArray<TArray<FQuat>>& JointRotations,
const FVector& WristLocation, const FQuat& WristRotation,
const bool bMotionSourceHandTracking) const
@@ -1399,6 +1756,7 @@ bool FSGXRTracker::FImpl::UpdateSGThumbJointData(
bool FSGXRTracker::FImpl::UpdateSGIndexJointData(
FSGXRHandState& OutHandState,
const EControllerHand DeviceHand,
const TArray<TArray<FVector>>& JointLocations, const TArray<TArray<FQuat>>& JointRotations,
const FVector& WristLocation, const FQuat& WristRotation,
const bool bMotionSourceHandTracking) const
@@ -1410,14 +1768,17 @@ bool FSGXRTracker::FImpl::UpdateSGIndexJointData(
static constexpr int32 IndexDistalJointIndex = 2;
static constexpr int32 IndexTipJointIndex = 3;
const FTransform& IndexMetacarpalTransform{
GetRootAppliedMeshBoneRefTransformOrDefault(DeviceHand, EHandKeypoint::IndexMetacarpal)
};
FVector IndexMetacarpalLocation{IndexMetacarpalTransform.GetLocation()};
FQuat IndexMetacarpalRotation{IndexMetacarpalTransform.GetRotation()};
const FVector& IndexProximalLocation{JointLocations[IndexFingerIndex][IndexProximalJointIndex]};
const FVector IndexMetacarpalLocation{IndexProximalLocation.X / 3.75f,
IndexProximalLocation.Y, IndexProximalLocation.Z};
const FVector& IndexIntermediateLocation{JointLocations[IndexFingerIndex][IndexIntermediateJointIndex]};
const FVector& IndexDistalLocation{JointLocations[IndexFingerIndex][IndexDistalJointIndex]};
const FVector& IndexTipLocation{JointLocations[IndexFingerIndex][IndexTipJointIndex]};
const FQuat IndexMetacarpalRotation{FQuat::Identity};
const FQuat& IndexProximalRotation{JointRotations[IndexFingerIndex][IndexProximalJointIndex]};
const FQuat& IndexIntermediateRotation{JointRotations[IndexFingerIndex][IndexIntermediateJointIndex]};
const FQuat& IndexDistalRotation{JointRotations[IndexFingerIndex][IndexDistalJointIndex]};
@@ -1425,7 +1786,8 @@ bool FSGXRTracker::FImpl::UpdateSGIndexJointData(
if (!UpdateSGJointData(
OutHandState,
EHandKeypoint::IndexMetacarpal, IndexMetacarpalLocation, IndexMetacarpalRotation,
EHandKeypoint::IndexMetacarpal,
MoveTemp(IndexMetacarpalLocation), MoveTemp(IndexMetacarpalRotation),
WristLocation, WristRotation,
bMotionSourceHandTracking))
{
@@ -1473,6 +1835,7 @@ bool FSGXRTracker::FImpl::UpdateSGIndexJointData(
bool FSGXRTracker::FImpl::UpdateSGMiddleJointData(
FSGXRHandState& OutHandState,
const EControllerHand DeviceHand,
const TArray<TArray<FVector>>& JointLocations, const TArray<TArray<FQuat>>& JointRotations,
const FVector& WristLocation, const FQuat& WristRotation,
const bool bMotionSourceHandTracking) const
@@ -1484,14 +1847,17 @@ bool FSGXRTracker::FImpl::UpdateSGMiddleJointData(
static constexpr int32 MiddleDistalJointMiddle = 2;
static constexpr int32 MiddleTipJointMiddle = 3;
const FTransform& MiddleMetacarpalTransform{
GetRootAppliedMeshBoneRefTransformOrDefault(DeviceHand, EHandKeypoint::MiddleMetacarpal)
};
FVector MiddleMetacarpalLocation{MiddleMetacarpalTransform.GetLocation()};
FQuat MiddleMetacarpalRotation{MiddleMetacarpalTransform.GetRotation()};
const FVector& MiddleProximalLocation{JointLocations[MiddleFingerMiddle][MiddleProximalJointMiddle]};
const FVector MiddleMetacarpalLocation{MiddleProximalLocation.X / 3.75f,
MiddleProximalLocation.Y, MiddleProximalLocation.Z};
const FVector& MiddleIntermediateLocation{JointLocations[MiddleFingerMiddle][MiddleIntermediateJointMiddle]};
const FVector& MiddleDistalLocation{JointLocations[MiddleFingerMiddle][MiddleDistalJointMiddle]};
const FVector& MiddleTipLocation{JointLocations[MiddleFingerMiddle][MiddleTipJointMiddle]};
const FQuat MiddleMetacarpalRotation{FQuat::Identity};
const FQuat& MiddleProximalRotation{JointRotations[MiddleFingerMiddle][MiddleProximalJointMiddle]};
const FQuat& MiddleIntermediateRotation{JointRotations[MiddleFingerMiddle][MiddleIntermediateJointMiddle]};
const FQuat& MiddleDistalRotation{JointRotations[MiddleFingerMiddle][MiddleDistalJointMiddle]};
@@ -1499,7 +1865,8 @@ bool FSGXRTracker::FImpl::UpdateSGMiddleJointData(
if (!UpdateSGJointData(
OutHandState,
EHandKeypoint::MiddleMetacarpal, MiddleMetacarpalLocation, MiddleMetacarpalRotation,
EHandKeypoint::MiddleMetacarpal,
MoveTemp(MiddleMetacarpalLocation), MoveTemp(MiddleMetacarpalRotation),
WristLocation, WristRotation,
bMotionSourceHandTracking))
{
@@ -1547,6 +1914,7 @@ bool FSGXRTracker::FImpl::UpdateSGMiddleJointData(
bool FSGXRTracker::FImpl::UpdateSGRingJointData(
FSGXRHandState& OutHandState,
const EControllerHand DeviceHand,
const TArray<TArray<FVector>>& JointLocations, const TArray<TArray<FQuat>>& JointRotations,
const FVector& WristLocation, const FQuat& WristRotation,
const bool bMotionSourceHandTracking) const
@@ -1558,14 +1926,17 @@ bool FSGXRTracker::FImpl::UpdateSGRingJointData(
static constexpr int32 RingDistalJointRing = 2;
static constexpr int32 RingTipJointRing = 3;
const FTransform& RingMetacarpalTransform{
GetRootAppliedMeshBoneRefTransformOrDefault(DeviceHand, EHandKeypoint::RingMetacarpal)
};
FVector RingMetacarpalLocation{RingMetacarpalTransform.GetLocation()};
FQuat RingMetacarpalRotation{RingMetacarpalTransform.GetRotation()};
const FVector& RingProximalLocation{JointLocations[RingFingerRing][RingProximalJointRing]};
const FVector RingMetacarpalLocation{RingProximalLocation.X / 3.75f,
RingProximalLocation.Y, RingProximalLocation.Z};
const FVector& RingIntermediateLocation{JointLocations[RingFingerRing][RingIntermediateJointRing]};
const FVector& RingDistalLocation{JointLocations[RingFingerRing][RingDistalJointRing]};
const FVector& RingTipLocation{JointLocations[RingFingerRing][RingTipJointRing]};
const FQuat RingMetacarpalRotation{FQuat::Identity};
const FQuat& RingProximalRotation{JointRotations[RingFingerRing][RingProximalJointRing]};
const FQuat& RingIntermediateRotation{JointRotations[RingFingerRing][RingIntermediateJointRing]};
const FQuat& RingDistalRotation{JointRotations[RingFingerRing][RingDistalJointRing]};
@@ -1573,7 +1944,8 @@ bool FSGXRTracker::FImpl::UpdateSGRingJointData(
if (!UpdateSGJointData(
OutHandState,
EHandKeypoint::RingMetacarpal, RingMetacarpalLocation, RingMetacarpalRotation,
EHandKeypoint::RingMetacarpal,
MoveTemp(RingMetacarpalLocation), MoveTemp(RingMetacarpalRotation),
WristLocation, WristRotation,
bMotionSourceHandTracking))
{
@@ -1621,6 +1993,7 @@ bool FSGXRTracker::FImpl::UpdateSGRingJointData(
bool FSGXRTracker::FImpl::UpdateSGLittleJointData(
FSGXRHandState& OutHandState,
const EControllerHand DeviceHand,
const TArray<TArray<FVector>>& JointLocations, const TArray<TArray<FQuat>>& JointRotations,
const FVector& WristLocation, const FQuat& WristRotation,
const bool bMotionSourceHandTracking) const
@@ -1632,14 +2005,17 @@ bool FSGXRTracker::FImpl::UpdateSGLittleJointData(
static constexpr int32 LittleDistalJointLittle = 2;
static constexpr int32 LittleTipJointLittle = 3;
const FTransform& LittleMetacarpalTransform{
GetRootAppliedMeshBoneRefTransformOrDefault(DeviceHand, EHandKeypoint::LittleMetacarpal)
};
FVector LittleMetacarpalLocation{LittleMetacarpalTransform.GetLocation()};
FQuat LittleMetacarpalRotation{LittleMetacarpalTransform.GetRotation()};
const FVector& LittleProximalLocation{JointLocations[LittleFingerLittle][LittleProximalJointLittle]};
const FVector LittleMetacarpalLocation{LittleProximalLocation.X / 3.75f,
LittleProximalLocation.Y, LittleProximalLocation.Z};
const FVector& LittleIntermediateLocation{JointLocations[LittleFingerLittle][LittleIntermediateJointLittle]};
const FVector& LittleDistalLocation{JointLocations[LittleFingerLittle][LittleDistalJointLittle]};
const FVector& LittleTipLocation{JointLocations[LittleFingerLittle][LittleTipJointLittle]};
const FQuat LittleMetacarpalRotation{FQuat::Identity};
const FQuat& LittleProximalRotation{JointRotations[LittleFingerLittle][LittleProximalJointLittle]};
const FQuat& LittleIntermediateRotation{JointRotations[LittleFingerLittle][LittleIntermediateJointLittle]};
const FQuat& LittleDistalRotation{JointRotations[LittleFingerLittle][LittleDistalJointLittle]};
@@ -1647,7 +2023,8 @@ bool FSGXRTracker::FImpl::UpdateSGLittleJointData(
if (!UpdateSGJointData(
OutHandState,
EHandKeypoint::LittleMetacarpal, LittleMetacarpalLocation, LittleMetacarpalRotation,
EHandKeypoint::LittleMetacarpal,
MoveTemp(LittleMetacarpalLocation), MoveTemp(LittleMetacarpalRotation),
WristLocation, WristRotation,
bMotionSourceHandTracking))
{
@@ -1728,37 +2105,36 @@ bool FSGXRTracker::FImpl::UpdateSGHandState(const EControllerHand DeviceHand, FS
return false;
}
if (!UpdateSGPalmJointData(OutHandState, JointLocations, JointRotations, WristLocation, WristRotation,
bMotionSourceHandTracking))
if (!UpdateSGPalmJointData(OutHandState, DeviceHand, WristLocation, WristRotation, bMotionSourceHandTracking))
{
return false;
}
if (!UpdateSGThumbJointData(OutHandState, JointLocations, JointRotations, WristLocation, WristRotation,
if (!UpdateSGThumbJointData(OutHandState, DeviceHand, JointLocations, JointRotations, WristLocation, WristRotation,
bMotionSourceHandTracking))
{
return false;
}
if (!UpdateSGIndexJointData(OutHandState, JointLocations, JointRotations, WristLocation, WristRotation,
if (!UpdateSGIndexJointData(OutHandState, DeviceHand, JointLocations, JointRotations, WristLocation, WristRotation,
bMotionSourceHandTracking))
{
return false;
}
if (!UpdateSGMiddleJointData(OutHandState, JointLocations, JointRotations, WristLocation, WristRotation,
if (!UpdateSGMiddleJointData(OutHandState, DeviceHand, JointLocations, JointRotations, WristLocation, WristRotation,
bMotionSourceHandTracking))
{
return false;
}
if (!UpdateSGRingJointData(OutHandState, JointLocations, JointRotations, WristLocation, WristRotation,
if (!UpdateSGRingJointData(OutHandState, DeviceHand, JointLocations, JointRotations, WristLocation, WristRotation,
bMotionSourceHandTracking))
{
return false;
}
if (!UpdateSGLittleJointData(OutHandState, JointLocations, JointRotations, WristLocation, WristRotation,
if (!UpdateSGLittleJointData(OutHandState, DeviceHand, JointLocations, JointRotations, WristLocation, WristRotation,
bMotionSourceHandTracking))
{
return false;