refactor the sgxrtracker internals to use transforms as pimpl methods args instead of a combination of fvectors/fquats
This commit is contained in:
@@ -465,64 +465,48 @@ struct FSGXRTracker::FImpl
|
||||
|
||||
bool UpdateXRHandTrackingData(FSGXRHandState& OutHandState, const XrHandJointsLocateInfoEXT& LocateInfo) const;
|
||||
|
||||
bool GetOpenXRHandTrackingWristLocationAndRotation(EControllerHand DeviceHand,
|
||||
FVector& OutWristLocation, FQuat& OutWristRotation) const;
|
||||
bool GetOpenXRWristLocationAndRotation(const EControllerHand DeviceHand,
|
||||
const IMotionController* MotionController, const FName& MotionSource,
|
||||
FVector& OutWristLocation, FQuat& OutWristRotation) const;
|
||||
bool GetWristLocationAndRotation(EControllerHand DeviceHand,
|
||||
FVector& OutWristLocation, FQuat& OutWristRotation,
|
||||
bool& bOutMotionSourceHandTracking) const;
|
||||
bool GetOpenXRHandTrackingWristTransform(EControllerHand DeviceHand, FTransform& OutTransform) const;
|
||||
bool GetOpenXRWristTransform(const EControllerHand DeviceHand,
|
||||
const IMotionController* MotionController, const FName& MotionSource,
|
||||
FTransform& OutTransform) const;
|
||||
bool GetWristTransform(EControllerHand DeviceHand,
|
||||
FTransform& OutTransform, bool& bOutMotionSourceHandTracking) const;
|
||||
|
||||
bool UpdateSGJointData(FSGXRHandState& OutHandState, const EHandKeypoint Joint,
|
||||
const FVector& JointLocation, const FQuat& JointRotation,
|
||||
const FVector& WristLocation, const FQuat& WristRotation,
|
||||
const FTransform& JointTransform, const FTransform& WristTransform,
|
||||
bool bMotionSourceHandTracking) const;
|
||||
|
||||
bool UpdateSGWristJointData(FSGXRHandState& OutHandState,
|
||||
const FVector& WristLocation, const FQuat& WristRotation,
|
||||
bool bMotionSourceHandTracking) const;
|
||||
const FTransform& WristTransform, bool bMotionSourceHandTracking) const;
|
||||
|
||||
bool UpdateSGPalmJointData(
|
||||
FSGXRHandState& OutHandState,
|
||||
EControllerHand DeviceHand,
|
||||
const FVector& WristLocation, const FQuat& WristRotation,
|
||||
bool bMotionSourceHandTracking) const;
|
||||
FSGXRHandState& OutHandState, EControllerHand DeviceHand,
|
||||
const FTransform& WristTransform, 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;
|
||||
const FTransform& WristTransform, bool bMotionSourceHandTracking) const;
|
||||
|
||||
bool UpdateSGIndexJointData(
|
||||
FSGXRHandState& OutHandState,
|
||||
EControllerHand DeviceHand,
|
||||
FSGXRHandState& OutHandState, EControllerHand DeviceHand,
|
||||
const TArray<TArray<FVector>>& JointLocations, const TArray<TArray<FQuat>>& JointRotations,
|
||||
const FVector& WristLocation, const FQuat& WristRotation,
|
||||
bool bMotionSourceHandTracking) const;
|
||||
const FTransform& WristTransform, bool bMotionSourceHandTracking) const;
|
||||
|
||||
bool UpdateSGMiddleJointData(
|
||||
FSGXRHandState& OutHandState,
|
||||
EControllerHand DeviceHand,
|
||||
FSGXRHandState& OutHandState, EControllerHand DeviceHand,
|
||||
const TArray<TArray<FVector>>& JointLocations, const TArray<TArray<FQuat>>& JointRotations,
|
||||
const FVector& WristLocation, const FQuat& WristRotation,
|
||||
bool bMotionSourceHandTracking) const;
|
||||
const FTransform& WristTransform, bool bMotionSourceHandTracking) const;
|
||||
|
||||
bool UpdateSGRingJointData(
|
||||
FSGXRHandState& OutHandState,
|
||||
EControllerHand DeviceHand,
|
||||
FSGXRHandState& OutHandState, EControllerHand DeviceHand,
|
||||
const TArray<TArray<FVector>>& JointLocations, const TArray<TArray<FQuat>>& JointRotations,
|
||||
const FVector& WristLocation, const FQuat& WristRotation,
|
||||
bool bMotionSourceHandTracking) const;
|
||||
const FTransform& WristTransform, bool bMotionSourceHandTracking) const;
|
||||
|
||||
bool UpdateSGLittleJointData(
|
||||
FSGXRHandState& OutHandState,
|
||||
EControllerHand DeviceHand,
|
||||
FSGXRHandState& OutHandState, EControllerHand DeviceHand,
|
||||
const TArray<TArray<FVector>>& JointLocations, const TArray<TArray<FQuat>>& JointRotations,
|
||||
const FVector& WristLocation, const FQuat& WristRotation,
|
||||
bool bMotionSourceHandTracking) const;
|
||||
const FTransform& WristTransform, bool bMotionSourceHandTracking) const;
|
||||
|
||||
bool UpdateSGHandState(const EControllerHand DeviceHand, FSGXRHandState& OutHandState) const;
|
||||
};
|
||||
@@ -1533,8 +1517,8 @@ bool FSGXRTracker::FImpl::UpdateXRHandTrackingData(
|
||||
return false;
|
||||
}
|
||||
|
||||
bool FSGXRTracker::FImpl::GetOpenXRHandTrackingWristLocationAndRotation(
|
||||
const EControllerHand DeviceHand, FVector& OutWristLocation, FQuat& OutWristRotation) const
|
||||
bool FSGXRTracker::FImpl::GetOpenXRHandTrackingWristTransform(
|
||||
const EControllerHand DeviceHand, FTransform& OutTransform) const
|
||||
{
|
||||
if (!ensureAlwaysMsgf(XRTrackingSystem, TEXT("Invalid XR tracking system!")))
|
||||
{
|
||||
@@ -1548,18 +1532,20 @@ bool FSGXRTracker::FImpl::GetOpenXRHandTrackingWristLocationAndRotation(
|
||||
if (MotionControllerData.bValid)
|
||||
{
|
||||
static constexpr int32_t WristJointIndex = static_cast<int32>(EHandKeypoint::Wrist);
|
||||
OutWristLocation = MotionControllerData.HandKeyPositions[WristJointIndex];
|
||||
OutWristRotation = MotionControllerData.HandKeyRotations[WristJointIndex];
|
||||
OutTransform = FTransform{
|
||||
MotionControllerData.HandKeyRotations[WristJointIndex],
|
||||
MotionControllerData.HandKeyPositions[WristJointIndex]
|
||||
};
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool FSGXRTracker::FImpl::GetOpenXRWristLocationAndRotation(
|
||||
bool FSGXRTracker::FImpl::GetOpenXRWristTransform(
|
||||
const EControllerHand DeviceHand,
|
||||
const IMotionController* MotionController, const FName& MotionSource,
|
||||
FVector& OutWristLocation, FQuat& OutWristRotation) const
|
||||
FTransform& OutTransform) const
|
||||
{
|
||||
static constexpr int32 CurrentPlayerControllerIndex = 0;
|
||||
|
||||
@@ -1593,7 +1579,7 @@ bool FSGXRTracker::FImpl::GetOpenXRWristLocationAndRotation(
|
||||
FVector WristLocation;
|
||||
FRotator WristRotation;
|
||||
|
||||
USGHapticGlove* Glove = GetGlove(bIsRight);
|
||||
const USGHapticGlove* Glove{GetGlove(bIsRight)};
|
||||
if (!IsValid(Glove))
|
||||
{
|
||||
return false;
|
||||
@@ -1602,8 +1588,7 @@ bool FSGXRTracker::FImpl::GetOpenXRWristLocationAndRotation(
|
||||
Glove->GetWristLocation(TrackerLocation, TrackerRotation, TrackingHardware,
|
||||
WristLocation, WristRotation);
|
||||
|
||||
OutWristLocation = MoveTemp(WristLocation);
|
||||
OutWristRotation = FQuat(MoveTemp(WristRotation));
|
||||
OutTransform = FTransform{MoveTemp(WristRotation), WristLocation};
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -1611,9 +1596,8 @@ bool FSGXRTracker::FImpl::GetOpenXRWristLocationAndRotation(
|
||||
return false;
|
||||
}
|
||||
|
||||
bool FSGXRTracker::FImpl::GetWristLocationAndRotation(
|
||||
const EControllerHand DeviceHand, FVector& OutWristLocation, FQuat& OutWristRotation,
|
||||
bool& bOutMotionSourceHandTracking) const
|
||||
bool FSGXRTracker::FImpl::GetWristTransform(
|
||||
const EControllerHand DeviceHand, FTransform& OutTransform, bool& bOutMotionSourceHandTracking) const
|
||||
{
|
||||
static const FName OpenXRName{TEXT("OpenXR")};
|
||||
static const FName OpenXRHandTrackingName{TEXT("OpenXRHandTracking")};
|
||||
@@ -1635,7 +1619,7 @@ bool FSGXRTracker::FImpl::GetWristLocationAndRotation(
|
||||
|
||||
static constexpr int32 CurrentPlayerControllerIndex = 0;
|
||||
|
||||
TArray<IMotionController*> MotionControllers{IModularFeatures::Get().GetModularFeatureImplementations<
|
||||
const TArray<IMotionController*> MotionControllers{IModularFeatures::Get().GetModularFeatureImplementations<
|
||||
IMotionController>(IMotionController::GetModularFeatureName())};
|
||||
|
||||
for (const IMotionController* MotionController: MotionControllers)
|
||||
@@ -1662,14 +1646,15 @@ bool FSGXRTracker::FImpl::GetWristLocationAndRotation(
|
||||
if (DeviceTypeName == OpenXRHandTrackingName)
|
||||
{
|
||||
bOutMotionSourceHandTracking = true;
|
||||
return GetOpenXRHandTrackingWristLocationAndRotation(DeviceHand, OutWristLocation, OutWristRotation);
|
||||
const bool bResult = GetOpenXRHandTrackingWristTransform(DeviceHand, OutTransform);
|
||||
return bResult;
|
||||
}
|
||||
|
||||
if (DeviceTypeName == OpenXRName)
|
||||
{
|
||||
bOutMotionSourceHandTracking = false;
|
||||
return GetOpenXRWristLocationAndRotation(DeviceHand, MotionController, MotionSource,
|
||||
OutWristLocation, OutWristRotation);
|
||||
const bool bResult = GetOpenXRWristTransform(DeviceHand, MotionController, MotionSource, OutTransform);
|
||||
return bResult;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1678,8 +1663,7 @@ bool FSGXRTracker::FImpl::GetWristLocationAndRotation(
|
||||
|
||||
bool FSGXRTracker::FImpl::UpdateSGJointData(
|
||||
FSGXRHandState& OutHandState, const EHandKeypoint Joint,
|
||||
const FVector& JointLocation, const FQuat& JointRotation,
|
||||
const FVector& WristLocation, const FQuat& WristRotation,
|
||||
const FTransform& JointTransform, const FTransform& WristTransform,
|
||||
const bool bMotionSourceHandTracking) const
|
||||
{
|
||||
if (!ensureAlwaysMsgf(XRTrackingSystem, TEXT("Invalid XR tracking system!")))
|
||||
@@ -1693,6 +1677,11 @@ bool FSGXRTracker::FImpl::UpdateSGJointData(
|
||||
|
||||
const int32_t JointIndex = static_cast<int32>(Joint);
|
||||
|
||||
const FQuat WristRotation{WristTransform.GetRotation()};
|
||||
const FVector WristLocation{WristTransform.GetLocation()};
|
||||
const FQuat JointRotation{JointTransform.GetRotation()};
|
||||
const FVector JointLocation{JointTransform.GetLocation()};
|
||||
|
||||
FTransform Transform;
|
||||
if (bMotionSourceHandTracking)
|
||||
{
|
||||
@@ -1704,8 +1693,8 @@ bool FSGXRTracker::FImpl::UpdateSGJointData(
|
||||
}
|
||||
else
|
||||
{
|
||||
Transform.SetLocation(WristLocation + (WristRotation * JointLocation));
|
||||
Transform.SetRotation(WristRotation * JointRotation);
|
||||
Transform.SetLocation(WristLocation + (WristRotation * JointLocation));
|
||||
}
|
||||
|
||||
OutHandState.KeypointTransforms[JointIndex] = MoveTemp(Transform);
|
||||
@@ -1715,8 +1704,8 @@ bool FSGXRTracker::FImpl::UpdateSGJointData(
|
||||
}
|
||||
|
||||
bool FSGXRTracker::FImpl::UpdateSGWristJointData(
|
||||
FSGXRHandState& OutHandState, const FVector& WristLocation, const FQuat& WristRotation,
|
||||
const bool bMotionSourceHandTracking) const
|
||||
FSGXRHandState& OutHandState,
|
||||
const FTransform& WristTransform, const bool bMotionSourceHandTracking) const
|
||||
{
|
||||
if (!ensureAlwaysMsgf(XRTrackingSystem, TEXT("Invalid XR tracking system!")))
|
||||
{
|
||||
@@ -1734,15 +1723,15 @@ bool FSGXRTracker::FImpl::UpdateSGWristJointData(
|
||||
if (bMotionSourceHandTracking)
|
||||
{
|
||||
XrPosef Pose;
|
||||
Pose.orientation = ToXrQuat(WristRotation);
|
||||
Pose.position = ToXrVector(WristLocation, WorldToMetersScale);
|
||||
Pose.orientation = ToXrQuat(WristTransform.GetRotation());
|
||||
Pose.position = ToXrVector(WristTransform.GetLocation(), WorldToMetersScale);
|
||||
Transform = ToFTransform(MoveTemp(Pose), WorldToMetersScale);
|
||||
Transform *= WorldToTrackingTransform;
|
||||
}
|
||||
else
|
||||
{
|
||||
Transform.SetLocation(WristLocation);
|
||||
Transform.SetRotation(WristRotation);
|
||||
Transform.SetRotation(WristTransform.GetRotation());
|
||||
Transform.SetLocation(WristTransform.GetLocation());
|
||||
}
|
||||
|
||||
OutHandState.KeypointTransforms[JointIndex] = MoveTemp(Transform);
|
||||
@@ -1752,22 +1741,18 @@ bool FSGXRTracker::FImpl::UpdateSGWristJointData(
|
||||
}
|
||||
|
||||
bool FSGXRTracker::FImpl::UpdateSGPalmJointData(
|
||||
FSGXRHandState& OutHandState,
|
||||
const EControllerHand DeviceHand,
|
||||
const FVector& WristLocation, const FQuat& WristRotation,
|
||||
const bool bMotionSourceHandTracking) const
|
||||
FSGXRHandState& OutHandState, const EControllerHand DeviceHand,
|
||||
const FTransform& WristTransform, const bool bMotionSourceHandTracking) const
|
||||
{
|
||||
if (!ensureAlwaysMsgf(XRTrackingSystem, TEXT("Invalid XR tracking system!")))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
const FTransform JointTransform{GetMeshWristChildBoneRefTransform(DeviceHand, EHandKeypoint::Palm)};
|
||||
FVector JointLocation{JointTransform.GetLocation()};
|
||||
FQuat JointRotation{JointTransform.GetRotation()};
|
||||
FTransform JointTransform{GetMeshWristChildBoneRefTransform(DeviceHand, EHandKeypoint::Palm)};
|
||||
|
||||
if (!UpdateSGJointData(OutHandState, EHandKeypoint::Palm,
|
||||
MoveTemp(JointLocation), MoveTemp(JointRotation), WristLocation, WristRotation,
|
||||
MoveTemp(JointTransform), WristTransform,
|
||||
bMotionSourceHandTracking))
|
||||
{
|
||||
return false;
|
||||
@@ -1778,10 +1763,8 @@ 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
|
||||
const FTransform& WristTransform, const bool bMotionSourceHandTracking) const
|
||||
{
|
||||
static constexpr int32 ThumbFingerIndex = 0;
|
||||
static constexpr int32 ThumbMetacarpalJointIndex = 0;
|
||||
@@ -1789,44 +1772,47 @@ bool FSGXRTracker::FImpl::UpdateSGThumbJointData(
|
||||
static constexpr int32 ThumbDistalJointIndex = 2;
|
||||
static constexpr int32 ThumbTipJointIndex = 3;
|
||||
|
||||
const FVector& ThumbMetacarpalLocation{JointLocations[ThumbFingerIndex][ThumbMetacarpalJointIndex]};
|
||||
const FVector& ThumbProximalLocation{JointLocations[ThumbFingerIndex][ThumbProximalJointIndex]};
|
||||
const FVector& ThumbDistalLocation{JointLocations[ThumbFingerIndex][ThumbDistalJointIndex]};
|
||||
const FVector& ThumbTipLocation{JointLocations[ThumbFingerIndex][ThumbTipJointIndex]};
|
||||
|
||||
const FQuat& ThumbMetacarpalRotation{JointRotations[ThumbFingerIndex][ThumbMetacarpalJointIndex]};
|
||||
const FQuat& ThumbProximalRotation{JointRotations[ThumbFingerIndex][ThumbProximalJointIndex]};
|
||||
const FQuat& ThumbDistalRotation{JointRotations[ThumbFingerIndex][ThumbDistalJointIndex]};
|
||||
const FQuat& ThumbTipRotation{JointRotations[ThumbFingerIndex][ThumbTipJointIndex]};
|
||||
FTransform ThumbMetacarpalTransform{
|
||||
JointRotations[ThumbFingerIndex][ThumbMetacarpalJointIndex],
|
||||
JointLocations[ThumbFingerIndex][ThumbMetacarpalJointIndex]
|
||||
};
|
||||
FTransform ThumbProximalTransform{
|
||||
JointRotations[ThumbFingerIndex][ThumbProximalJointIndex],
|
||||
JointLocations[ThumbFingerIndex][ThumbProximalJointIndex]
|
||||
};
|
||||
FTransform ThumbDistalTransform{
|
||||
JointRotations[ThumbFingerIndex][ThumbDistalJointIndex],
|
||||
JointLocations[ThumbFingerIndex][ThumbDistalJointIndex]
|
||||
};
|
||||
FTransform ThumbTipTransform{
|
||||
JointRotations[ThumbFingerIndex][ThumbTipJointIndex],
|
||||
JointLocations[ThumbFingerIndex][ThumbTipJointIndex]
|
||||
};
|
||||
|
||||
if (!UpdateSGJointData(
|
||||
OutHandState, EHandKeypoint::ThumbMetacarpal,
|
||||
ThumbMetacarpalLocation, ThumbMetacarpalRotation, WristLocation, WristRotation,
|
||||
bMotionSourceHandTracking))
|
||||
MoveTemp(ThumbMetacarpalTransform), WristTransform, bMotionSourceHandTracking))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!UpdateSGJointData(
|
||||
OutHandState, EHandKeypoint::ThumbProximal,
|
||||
ThumbProximalLocation, ThumbProximalRotation, WristLocation, WristRotation,
|
||||
bMotionSourceHandTracking))
|
||||
MoveTemp(ThumbProximalTransform), WristTransform, bMotionSourceHandTracking))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!UpdateSGJointData(
|
||||
OutHandState, EHandKeypoint::ThumbDistal,
|
||||
ThumbDistalLocation, ThumbDistalRotation, WristLocation, WristRotation,
|
||||
bMotionSourceHandTracking))
|
||||
MoveTemp(ThumbDistalTransform), WristTransform, bMotionSourceHandTracking))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!UpdateSGJointData(
|
||||
OutHandState, EHandKeypoint::ThumbTip,
|
||||
ThumbTipLocation, ThumbTipRotation, WristLocation, WristRotation,
|
||||
bMotionSourceHandTracking))
|
||||
MoveTemp(ThumbTipTransform), WristTransform, bMotionSourceHandTracking))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -1835,11 +1821,9 @@ bool FSGXRTracker::FImpl::UpdateSGThumbJointData(
|
||||
}
|
||||
|
||||
bool FSGXRTracker::FImpl::UpdateSGIndexJointData(
|
||||
FSGXRHandState& OutHandState,
|
||||
const EControllerHand DeviceHand,
|
||||
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
|
||||
const FTransform& WristTransform, const bool bMotionSourceHandTracking) const
|
||||
{
|
||||
static constexpr int32 IndexFingerIndex = 1;
|
||||
|
||||
@@ -1848,59 +1832,57 @@ bool FSGXRTracker::FImpl::UpdateSGIndexJointData(
|
||||
static constexpr int32 IndexDistalJointIndex = 2;
|
||||
static constexpr int32 IndexTipJointIndex = 3;
|
||||
|
||||
const FTransform& IndexMetacarpalTransform{
|
||||
FTransform IndexMetacarpalTransform{
|
||||
GetMeshWristChildBoneRefTransform(DeviceHand, EHandKeypoint::IndexMetacarpal)
|
||||
};
|
||||
FVector IndexMetacarpalLocation{IndexMetacarpalTransform.GetLocation()};
|
||||
FQuat IndexMetacarpalRotation{IndexMetacarpalTransform.GetRotation()};
|
||||
|
||||
const FVector& IndexProximalLocation{JointLocations[IndexFingerIndex][IndexProximalJointIndex]};
|
||||
const FVector& IndexIntermediateLocation{JointLocations[IndexFingerIndex][IndexIntermediateJointIndex]};
|
||||
const FVector& IndexDistalLocation{JointLocations[IndexFingerIndex][IndexDistalJointIndex]};
|
||||
const FVector& IndexTipLocation{JointLocations[IndexFingerIndex][IndexTipJointIndex]};
|
||||
|
||||
const FQuat& IndexProximalRotation{JointRotations[IndexFingerIndex][IndexProximalJointIndex]};
|
||||
const FQuat& IndexIntermediateRotation{JointRotations[IndexFingerIndex][IndexIntermediateJointIndex]};
|
||||
const FQuat& IndexDistalRotation{JointRotations[IndexFingerIndex][IndexDistalJointIndex]};
|
||||
const FQuat& IndexTipRotation{JointRotations[IndexFingerIndex][IndexTipJointIndex]};
|
||||
FTransform IndexProximalTransform{
|
||||
JointRotations[IndexFingerIndex][IndexProximalJointIndex],
|
||||
JointLocations[IndexFingerIndex][IndexProximalJointIndex]
|
||||
};
|
||||
FTransform IndexIntermediateTransform{
|
||||
JointRotations[IndexFingerIndex][IndexIntermediateJointIndex],
|
||||
JointLocations[IndexFingerIndex][IndexIntermediateJointIndex]
|
||||
};
|
||||
FTransform IndexDistalTransform{
|
||||
JointRotations[IndexFingerIndex][IndexDistalJointIndex],
|
||||
JointLocations[IndexFingerIndex][IndexDistalJointIndex]
|
||||
};
|
||||
FTransform IndexTipTransform{
|
||||
JointRotations[IndexFingerIndex][IndexTipJointIndex],
|
||||
JointLocations[IndexFingerIndex][IndexTipJointIndex]
|
||||
};
|
||||
|
||||
if (!UpdateSGJointData(
|
||||
OutHandState, EHandKeypoint::IndexMetacarpal,
|
||||
MoveTemp(IndexMetacarpalLocation), MoveTemp(IndexMetacarpalRotation),
|
||||
WristLocation, WristRotation,
|
||||
bMotionSourceHandTracking))
|
||||
MoveTemp(IndexMetacarpalTransform), WristTransform, bMotionSourceHandTracking))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!UpdateSGJointData(
|
||||
OutHandState, EHandKeypoint::IndexProximal,
|
||||
IndexProximalLocation, IndexProximalRotation, WristLocation, WristRotation,
|
||||
bMotionSourceHandTracking))
|
||||
MoveTemp(IndexProximalTransform), WristTransform, bMotionSourceHandTracking))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!UpdateSGJointData(
|
||||
OutHandState, EHandKeypoint::IndexIntermediate,
|
||||
IndexIntermediateLocation, IndexIntermediateRotation, WristLocation, WristRotation,
|
||||
bMotionSourceHandTracking))
|
||||
MoveTemp(IndexIntermediateTransform), WristTransform, bMotionSourceHandTracking))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!UpdateSGJointData(
|
||||
OutHandState, EHandKeypoint::IndexDistal,
|
||||
IndexDistalLocation, IndexDistalRotation, WristLocation, WristRotation,
|
||||
bMotionSourceHandTracking))
|
||||
MoveTemp(IndexDistalTransform), WristTransform, bMotionSourceHandTracking))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!UpdateSGJointData(
|
||||
OutHandState, EHandKeypoint::IndexTip,
|
||||
IndexTipLocation, IndexTipRotation, WristLocation, WristRotation,
|
||||
bMotionSourceHandTracking))
|
||||
MoveTemp(IndexTipTransform), WristTransform, bMotionSourceHandTracking))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -1909,11 +1891,9 @@ bool FSGXRTracker::FImpl::UpdateSGIndexJointData(
|
||||
}
|
||||
|
||||
bool FSGXRTracker::FImpl::UpdateSGMiddleJointData(
|
||||
FSGXRHandState& OutHandState,
|
||||
const EControllerHand DeviceHand,
|
||||
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
|
||||
const FTransform& WristTransform, const bool bMotionSourceHandTracking) const
|
||||
{
|
||||
static constexpr int32 MiddleFingerMiddle = 2;
|
||||
|
||||
@@ -1922,59 +1902,57 @@ bool FSGXRTracker::FImpl::UpdateSGMiddleJointData(
|
||||
static constexpr int32 MiddleDistalJointMiddle = 2;
|
||||
static constexpr int32 MiddleTipJointMiddle = 3;
|
||||
|
||||
const FTransform& MiddleMetacarpalTransform{
|
||||
FTransform MiddleMetacarpalTransform{
|
||||
GetMeshWristChildBoneRefTransform(DeviceHand, EHandKeypoint::MiddleMetacarpal)
|
||||
};
|
||||
FVector MiddleMetacarpalLocation{MiddleMetacarpalTransform.GetLocation()};
|
||||
FQuat MiddleMetacarpalRotation{MiddleMetacarpalTransform.GetRotation()};
|
||||
|
||||
const FVector& MiddleProximalLocation{JointLocations[MiddleFingerMiddle][MiddleProximalJointMiddle]};
|
||||
const FVector& MiddleIntermediateLocation{JointLocations[MiddleFingerMiddle][MiddleIntermediateJointMiddle]};
|
||||
const FVector& MiddleDistalLocation{JointLocations[MiddleFingerMiddle][MiddleDistalJointMiddle]};
|
||||
const FVector& MiddleTipLocation{JointLocations[MiddleFingerMiddle][MiddleTipJointMiddle]};
|
||||
|
||||
const FQuat& MiddleProximalRotation{JointRotations[MiddleFingerMiddle][MiddleProximalJointMiddle]};
|
||||
const FQuat& MiddleIntermediateRotation{JointRotations[MiddleFingerMiddle][MiddleIntermediateJointMiddle]};
|
||||
const FQuat& MiddleDistalRotation{JointRotations[MiddleFingerMiddle][MiddleDistalJointMiddle]};
|
||||
const FQuat& MiddleTipRotation{JointRotations[MiddleFingerMiddle][MiddleTipJointMiddle]};
|
||||
FTransform MiddleProximalTransform{
|
||||
JointRotations[MiddleFingerMiddle][MiddleProximalJointMiddle],
|
||||
JointLocations[MiddleFingerMiddle][MiddleProximalJointMiddle]
|
||||
};
|
||||
FTransform MiddleIntermediateTransform{
|
||||
JointRotations[MiddleFingerMiddle][MiddleIntermediateJointMiddle],
|
||||
JointLocations[MiddleFingerMiddle][MiddleIntermediateJointMiddle]
|
||||
};
|
||||
FTransform MiddleDistalTransform{
|
||||
JointRotations[MiddleFingerMiddle][MiddleDistalJointMiddle],
|
||||
JointLocations[MiddleFingerMiddle][MiddleDistalJointMiddle]
|
||||
};
|
||||
FTransform MiddleTipTransform{
|
||||
JointRotations[MiddleFingerMiddle][MiddleTipJointMiddle],
|
||||
JointLocations[MiddleFingerMiddle][MiddleTipJointMiddle]
|
||||
};
|
||||
|
||||
if (!UpdateSGJointData(
|
||||
OutHandState, EHandKeypoint::MiddleMetacarpal,
|
||||
MoveTemp(MiddleMetacarpalLocation), MoveTemp(MiddleMetacarpalRotation),
|
||||
WristLocation, WristRotation,
|
||||
bMotionSourceHandTracking))
|
||||
MoveTemp(MiddleMetacarpalTransform), WristTransform, bMotionSourceHandTracking))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!UpdateSGJointData(
|
||||
OutHandState, EHandKeypoint::MiddleProximal,
|
||||
MiddleProximalLocation, MiddleProximalRotation, WristLocation, WristRotation,
|
||||
bMotionSourceHandTracking))
|
||||
MoveTemp(MiddleProximalTransform), WristTransform, bMotionSourceHandTracking))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!UpdateSGJointData(
|
||||
OutHandState, EHandKeypoint::MiddleIntermediate,
|
||||
MiddleIntermediateLocation, MiddleIntermediateRotation, WristLocation, WristRotation,
|
||||
bMotionSourceHandTracking))
|
||||
MoveTemp(MiddleIntermediateTransform), WristTransform, bMotionSourceHandTracking))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!UpdateSGJointData(
|
||||
OutHandState, EHandKeypoint::MiddleDistal,
|
||||
MiddleDistalLocation, MiddleDistalRotation, WristLocation, WristRotation,
|
||||
bMotionSourceHandTracking))
|
||||
MoveTemp(MiddleDistalTransform), WristTransform, bMotionSourceHandTracking))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!UpdateSGJointData(
|
||||
OutHandState, EHandKeypoint::MiddleTip,
|
||||
MiddleTipLocation, MiddleTipRotation, WristLocation, WristRotation,
|
||||
bMotionSourceHandTracking))
|
||||
MoveTemp(MiddleTipTransform), WristTransform, bMotionSourceHandTracking))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -1983,11 +1961,9 @@ bool FSGXRTracker::FImpl::UpdateSGMiddleJointData(
|
||||
}
|
||||
|
||||
bool FSGXRTracker::FImpl::UpdateSGRingJointData(
|
||||
FSGXRHandState& OutHandState,
|
||||
const EControllerHand DeviceHand,
|
||||
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
|
||||
const FTransform& WristTransform, const bool bMotionSourceHandTracking) const
|
||||
{
|
||||
static constexpr int32 RingFingerRing = 3;
|
||||
|
||||
@@ -1996,59 +1972,57 @@ bool FSGXRTracker::FImpl::UpdateSGRingJointData(
|
||||
static constexpr int32 RingDistalJointRing = 2;
|
||||
static constexpr int32 RingTipJointRing = 3;
|
||||
|
||||
const FTransform& RingMetacarpalTransform{
|
||||
FTransform RingMetacarpalTransform{
|
||||
GetMeshWristChildBoneRefTransform(DeviceHand, EHandKeypoint::RingMetacarpal)
|
||||
};
|
||||
FVector RingMetacarpalLocation{RingMetacarpalTransform.GetLocation()};
|
||||
FQuat RingMetacarpalRotation{RingMetacarpalTransform.GetRotation()};
|
||||
|
||||
const FVector& RingProximalLocation{JointLocations[RingFingerRing][RingProximalJointRing]};
|
||||
const FVector& RingIntermediateLocation{JointLocations[RingFingerRing][RingIntermediateJointRing]};
|
||||
const FVector& RingDistalLocation{JointLocations[RingFingerRing][RingDistalJointRing]};
|
||||
const FVector& RingTipLocation{JointLocations[RingFingerRing][RingTipJointRing]};
|
||||
|
||||
const FQuat& RingProximalRotation{JointRotations[RingFingerRing][RingProximalJointRing]};
|
||||
const FQuat& RingIntermediateRotation{JointRotations[RingFingerRing][RingIntermediateJointRing]};
|
||||
const FQuat& RingDistalRotation{JointRotations[RingFingerRing][RingDistalJointRing]};
|
||||
const FQuat& RingTipRotation{JointRotations[RingFingerRing][RingTipJointRing]};
|
||||
FTransform RingProximalTransform{
|
||||
JointRotations[RingFingerRing][RingProximalJointRing],
|
||||
JointLocations[RingFingerRing][RingProximalJointRing]
|
||||
};
|
||||
FTransform RingIntermediateTransform{
|
||||
JointRotations[RingFingerRing][RingIntermediateJointRing],
|
||||
JointLocations[RingFingerRing][RingIntermediateJointRing]
|
||||
};
|
||||
FTransform RingDistalTransform{
|
||||
JointRotations[RingFingerRing][RingDistalJointRing],
|
||||
JointLocations[RingFingerRing][RingDistalJointRing]
|
||||
};
|
||||
FTransform RingTipTransform{
|
||||
JointRotations[RingFingerRing][RingTipJointRing],
|
||||
JointLocations[RingFingerRing][RingTipJointRing]
|
||||
};
|
||||
|
||||
if (!UpdateSGJointData(
|
||||
OutHandState, EHandKeypoint::RingMetacarpal,
|
||||
MoveTemp(RingMetacarpalLocation), MoveTemp(RingMetacarpalRotation),
|
||||
WristLocation, WristRotation,
|
||||
bMotionSourceHandTracking))
|
||||
MoveTemp(RingMetacarpalTransform), WristTransform, bMotionSourceHandTracking))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!UpdateSGJointData(
|
||||
OutHandState, EHandKeypoint::RingProximal,
|
||||
RingProximalLocation, RingProximalRotation, WristLocation, WristRotation,
|
||||
bMotionSourceHandTracking))
|
||||
MoveTemp(RingProximalTransform), WristTransform, bMotionSourceHandTracking))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!UpdateSGJointData(
|
||||
OutHandState, EHandKeypoint::RingIntermediate,
|
||||
RingIntermediateLocation, RingIntermediateRotation, WristLocation, WristRotation,
|
||||
bMotionSourceHandTracking))
|
||||
MoveTemp(RingIntermediateTransform), WristTransform, bMotionSourceHandTracking))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!UpdateSGJointData(
|
||||
OutHandState, EHandKeypoint::RingDistal,
|
||||
RingDistalLocation, RingDistalRotation, WristLocation, WristRotation,
|
||||
bMotionSourceHandTracking))
|
||||
MoveTemp(RingDistalTransform), WristTransform, bMotionSourceHandTracking))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!UpdateSGJointData(
|
||||
OutHandState, EHandKeypoint::RingTip,
|
||||
RingTipLocation, RingTipRotation, WristLocation, WristRotation,
|
||||
bMotionSourceHandTracking))
|
||||
MoveTemp(RingTipTransform), WristTransform, bMotionSourceHandTracking))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -2057,11 +2031,9 @@ bool FSGXRTracker::FImpl::UpdateSGRingJointData(
|
||||
}
|
||||
|
||||
bool FSGXRTracker::FImpl::UpdateSGLittleJointData(
|
||||
FSGXRHandState& OutHandState,
|
||||
const EControllerHand DeviceHand,
|
||||
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
|
||||
const FTransform& WristTransform, const bool bMotionSourceHandTracking) const
|
||||
{
|
||||
static constexpr int32 LittleFingerLittle = 4;
|
||||
|
||||
@@ -2070,59 +2042,57 @@ bool FSGXRTracker::FImpl::UpdateSGLittleJointData(
|
||||
static constexpr int32 LittleDistalJointLittle = 2;
|
||||
static constexpr int32 LittleTipJointLittle = 3;
|
||||
|
||||
const FTransform& LittleMetacarpalTransform{
|
||||
FTransform LittleMetacarpalTransform{
|
||||
GetMeshWristChildBoneRefTransform(DeviceHand, EHandKeypoint::LittleMetacarpal)
|
||||
};
|
||||
FVector LittleMetacarpalLocation{LittleMetacarpalTransform.GetLocation()};
|
||||
FQuat LittleMetacarpalRotation{LittleMetacarpalTransform.GetRotation()};
|
||||
|
||||
const FVector& LittleProximalLocation{JointLocations[LittleFingerLittle][LittleProximalJointLittle]};
|
||||
const FVector& LittleIntermediateLocation{JointLocations[LittleFingerLittle][LittleIntermediateJointLittle]};
|
||||
const FVector& LittleDistalLocation{JointLocations[LittleFingerLittle][LittleDistalJointLittle]};
|
||||
const FVector& LittleTipLocation{JointLocations[LittleFingerLittle][LittleTipJointLittle]};
|
||||
|
||||
const FQuat& LittleProximalRotation{JointRotations[LittleFingerLittle][LittleProximalJointLittle]};
|
||||
const FQuat& LittleIntermediateRotation{JointRotations[LittleFingerLittle][LittleIntermediateJointLittle]};
|
||||
const FQuat& LittleDistalRotation{JointRotations[LittleFingerLittle][LittleDistalJointLittle]};
|
||||
const FQuat& LittleTipRotation{JointRotations[LittleFingerLittle][LittleTipJointLittle]};
|
||||
FTransform LittleProximalTransform{
|
||||
JointRotations[LittleFingerLittle][LittleProximalJointLittle],
|
||||
JointLocations[LittleFingerLittle][LittleProximalJointLittle]
|
||||
};
|
||||
FTransform LittleIntermediateTransform{
|
||||
JointRotations[LittleFingerLittle][LittleIntermediateJointLittle],
|
||||
JointLocations[LittleFingerLittle][LittleIntermediateJointLittle]
|
||||
};
|
||||
FTransform LittleDistalTransform{
|
||||
JointRotations[LittleFingerLittle][LittleDistalJointLittle],
|
||||
JointLocations[LittleFingerLittle][LittleDistalJointLittle]
|
||||
};
|
||||
FTransform LittleTipTransform{
|
||||
JointRotations[LittleFingerLittle][LittleTipJointLittle],
|
||||
JointLocations[LittleFingerLittle][LittleTipJointLittle]
|
||||
};
|
||||
|
||||
if (!UpdateSGJointData(
|
||||
OutHandState, EHandKeypoint::LittleMetacarpal,
|
||||
MoveTemp(LittleMetacarpalLocation), MoveTemp(LittleMetacarpalRotation),
|
||||
WristLocation, WristRotation,
|
||||
bMotionSourceHandTracking))
|
||||
MoveTemp(LittleMetacarpalTransform), WristTransform, bMotionSourceHandTracking))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!UpdateSGJointData(
|
||||
OutHandState, EHandKeypoint::LittleProximal,
|
||||
LittleProximalLocation, LittleProximalRotation, WristLocation, WristRotation,
|
||||
bMotionSourceHandTracking))
|
||||
MoveTemp(LittleProximalTransform), WristTransform, bMotionSourceHandTracking))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!UpdateSGJointData(
|
||||
OutHandState, EHandKeypoint::LittleIntermediate,
|
||||
LittleIntermediateLocation, LittleIntermediateRotation, WristLocation, WristRotation,
|
||||
bMotionSourceHandTracking))
|
||||
MoveTemp(LittleIntermediateTransform), WristTransform, bMotionSourceHandTracking))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!UpdateSGJointData(
|
||||
OutHandState, EHandKeypoint::LittleDistal,
|
||||
LittleDistalLocation, LittleDistalRotation, WristLocation, WristRotation,
|
||||
bMotionSourceHandTracking))
|
||||
MoveTemp(LittleDistalTransform), WristTransform, bMotionSourceHandTracking))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!UpdateSGJointData(
|
||||
OutHandState, EHandKeypoint::LittleTip,
|
||||
LittleTipLocation, LittleTipRotation, WristLocation, WristRotation,
|
||||
bMotionSourceHandTracking))
|
||||
MoveTemp(LittleTipTransform), WristTransform, bMotionSourceHandTracking))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -2132,7 +2102,7 @@ bool FSGXRTracker::FImpl::UpdateSGLittleJointData(
|
||||
|
||||
bool FSGXRTracker::FImpl::UpdateSGHandState(const EControllerHand DeviceHand, FSGXRHandState& OutHandState) const
|
||||
{
|
||||
USGHandPose* HandPose{FImpl::GetHandPose(DeviceHand)};
|
||||
const USGHandPose* HandPose{FImpl::GetHandPose(DeviceHand)};
|
||||
if (!IsValid(HandPose))
|
||||
{
|
||||
return false;
|
||||
@@ -2143,55 +2113,54 @@ bool FSGXRTracker::FImpl::UpdateSGHandState(const EControllerHand DeviceHand, FS
|
||||
const TArray<TArray<FVector>> JointLocations{HandPose->GetJointPositions()};
|
||||
const TArray<TArray<FQuat>> JointRotations{HandPose->GetJointRotationsQ()};
|
||||
|
||||
FVector WristLocation;
|
||||
FQuat WristRotation;
|
||||
FTransform WristTransform;
|
||||
bool bMotionSourceHandTracking = false;
|
||||
if (!GetWristLocationAndRotation(DeviceHand, WristLocation, WristRotation, bMotionSourceHandTracking))
|
||||
if (!GetWristTransform(DeviceHand, WristTransform, bMotionSourceHandTracking))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!UpdateSGWristJointData(OutHandState, WristLocation, WristRotation, bMotionSourceHandTracking))
|
||||
if (!UpdateSGWristJointData(OutHandState, WristTransform, bMotionSourceHandTracking))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!UpdateSGPalmJointData(OutHandState, DeviceHand, WristLocation, WristRotation, bMotionSourceHandTracking))
|
||||
if (!UpdateSGPalmJointData(OutHandState, DeviceHand, WristTransform, bMotionSourceHandTracking))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!UpdateSGThumbJointData(OutHandState, DeviceHand,
|
||||
JointLocations, JointRotations, WristLocation, WristRotation,
|
||||
bMotionSourceHandTracking))
|
||||
if (!UpdateSGThumbJointData(OutHandState,
|
||||
JointLocations, JointRotations,
|
||||
WristTransform, bMotionSourceHandTracking))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!UpdateSGIndexJointData(OutHandState, DeviceHand,
|
||||
JointLocations, JointRotations, WristLocation, WristRotation,
|
||||
bMotionSourceHandTracking))
|
||||
JointLocations, JointRotations,
|
||||
WristTransform, bMotionSourceHandTracking))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!UpdateSGMiddleJointData(OutHandState, DeviceHand,
|
||||
JointLocations, JointRotations, WristLocation, WristRotation,
|
||||
bMotionSourceHandTracking))
|
||||
JointLocations, JointRotations,
|
||||
WristTransform, bMotionSourceHandTracking))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!UpdateSGRingJointData(OutHandState, DeviceHand,
|
||||
JointLocations, JointRotations, WristLocation, WristRotation,
|
||||
bMotionSourceHandTracking))
|
||||
JointLocations, JointRotations,
|
||||
WristTransform, bMotionSourceHandTracking))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!UpdateSGLittleJointData(OutHandState, DeviceHand,
|
||||
JointLocations, JointRotations, WristLocation, WristRotation,
|
||||
bMotionSourceHandTracking))
|
||||
JointLocations, JointRotations,
|
||||
WristTransform, bMotionSourceHandTracking))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user