consider millimeters/centimeters conversion, introduce units, and minor array utils refactoring

This commit is contained in:
Mamadou Babaei
2022-11-17 02:29:10 +01:00
parent 5983ac830c
commit 6293c8f285
23 changed files with 400 additions and 185 deletions
@@ -118,7 +118,7 @@ USGBasicHandModel* USGBasicHandModel::NewBasicHandModel(UObject* Outer, const bo
{
FSGIC_FSGBasicHandModelImpl OutBasicHandModelImplContainer;
FSGIC_TArray_TArray_float LengthsContainer{
FSGArrayUtils::FromBPNestedArray<float, FSGFloatArray, &FSGFloatArray::FloatArray>(Lengths)
FSGArrayUtils::FromNestedBPArray<float, FSGFloatArray, &FSGFloatArray::FloatArray>(Lengths)
};
FSGIC_TArray_FVector StartPositionsContainer{StartPositions};
SGCoreImpl_FSGBasicHandModelImpl_ctor_bRightHanded_Lengths_StartPosition(
@@ -166,7 +166,7 @@ USGBasicHandModel* USGBasicHandModel::NewBasicHandModel(UObject* Outer, const bo
{
FSGIC_FSGBasicHandModelImpl OutBasicHandModelImplContainer;
FSGIC_TArray_TArray_float LengthsContainer{
FSGArrayUtils::FromBPNestedArray<float, FSGFloatArray, &FSGFloatArray::FloatArray>(Lengths)
FSGArrayUtils::FromNestedBPArray<float, FSGFloatArray, &FSGFloatArray::FloatArray>(Lengths)
};
FSGIC_TArray_FVector StartPositionsContainer{StartPositions};
FSGIC_TArray_FQuat StartRotationsContainer{StartRotations};
@@ -184,7 +184,7 @@ USGBasicHandModel* USGBasicHandModel::NewBasicHandModel(UObject* Outer, const bo
{
FSGIC_FSGBasicHandModelImpl OutBasicHandModelImplContainer;
FSGIC_TArray_TArray_float LengthsContainer{
FSGArrayUtils::FromBPNestedArray<float, FSGFloatArray, &FSGFloatArray::FloatArray>(Lengths)
FSGArrayUtils::FromNestedBPArray<float, FSGFloatArray, &FSGFloatArray::FloatArray>(Lengths)
};
FSGIC_TArray_FVector StartPositionsContainer{StartPositions};
FSGIC_TArray_FQuat StartRotationsContainer{FSGArrayUtils::RotatorsToQuats(StartRotations)};
@@ -276,7 +276,7 @@ USGBasicHandModel::USGBasicHandModel(bool bRightHanded, const TArray<FSGFloatArr
{
FSGIC_FSGBasicHandModelImpl OutBasicHandModelImplContainer;
FSGIC_TArray_TArray_float LengthsContainer{
FSGArrayUtils::FromBPNestedArray<float, FSGFloatArray, &FSGFloatArray::FloatArray>(Lengths)
FSGArrayUtils::FromNestedBPArray<float, FSGFloatArray, &FSGFloatArray::FloatArray>(Lengths)
};
FSGIC_TArray_FVector StartPositionsContainer{StartPositions};
SGCoreImpl_FSGBasicHandModelImpl_ctor_bRightHanded_Lengths_StartPosition(
@@ -339,7 +339,7 @@ USGBasicHandModel::USGBasicHandModel(const bool bRightHanded, const TArray<FSGFl
{
FSGIC_FSGBasicHandModelImpl OutBasicHandModelImplContainer;
FSGIC_TArray_TArray_float LengthsContainer{
FSGArrayUtils::FromBPNestedArray<float, FSGFloatArray, &FSGFloatArray::FloatArray>(Lengths)
FSGArrayUtils::FromNestedBPArray<float, FSGFloatArray, &FSGFloatArray::FloatArray>(Lengths)
};
FSGIC_TArray_FVector StartPositionsContainer{StartPositions};
FSGIC_TArray_FQuat StartRotationsContainer{StartRotations};
@@ -362,7 +362,7 @@ USGBasicHandModel::USGBasicHandModel(const bool bRightHanded, const TArray<FSGFl
{
FSGIC_FSGBasicHandModelImpl OutBasicHandModelImplContainer;
FSGIC_TArray_TArray_float LengthsContainer{
FSGArrayUtils::FromBPNestedArray<float, FSGFloatArray, &FSGFloatArray::FloatArray>(Lengths)
FSGArrayUtils::FromNestedBPArray<float, FSGFloatArray, &FSGFloatArray::FloatArray>(Lengths)
};
FSGIC_TArray_FVector StartPositionsContainer{StartPositions};
FSGIC_TArray_FQuat StartRotationsContainer{FSGArrayUtils::RotatorsToQuats(StartRotations)};
@@ -139,13 +139,13 @@ USGHandPose* USGHandPose::NewHandPose(
{
FSGIC_FSGHandPoseImpl OutHandPoseImplContainer;
FSGIC_TArray_TArray_FVector JointPositionsContainer{
FSGArrayUtils::FromBPNestedArray<FVector, FSGVectorArray, &FSGVectorArray::VectorArray>(JointPositions)
FSGArrayUtils::FromNestedBPArray<FVector, FSGVectorArray, &FSGVectorArray::VectorArray>(JointPositions)
};
FSGIC_TArray_TArray_FQuat JointRotationsContainer{
FSGArrayUtils::FromBPNestedArray<FQuat, FSGQuatArray, &FSGQuatArray::QuatArray>(JointRotations)
FSGArrayUtils::FromNestedBPArray<FQuat, FSGQuatArray, &FSGQuatArray::QuatArray>(JointRotations)
};
FSGIC_TArray_TArray_FVector HandAnglesContainer{
FSGArrayUtils::FromBPNestedArray<FVector, FSGVectorArray, &FSGVectorArray::VectorArray>(HandAngles)
FSGArrayUtils::FromNestedBPArray<FVector, FSGVectorArray, &FSGVectorArray::VectorArray>(HandAngles)
};
SGCoreImpl_FSGHandPoseImpl_ctor_bRightHanded_JointPositions_JointRotations_HandAngles(
&OutHandPoseImplContainer, bRightHanded, &JointPositionsContainer,
@@ -162,13 +162,13 @@ USGHandPose* USGHandPose::NewHandPose(
{
FSGIC_FSGHandPoseImpl OutHandPoseImplContainer;
FSGIC_TArray_TArray_FVector JointPositionsContainer{
FSGArrayUtils::FromBPNestedArray<FVector, FSGVectorArray, &FSGVectorArray::VectorArray>(JointPositions)
FSGArrayUtils::FromNestedBPArray<FVector, FSGVectorArray, &FSGVectorArray::VectorArray>(JointPositions)
};
FSGIC_TArray_TArray_FQuat JointRotationsContainer{
FSGArrayUtils::RotatorsToQuats<FSGRotatorArray, &FSGRotatorArray::RotatorArray>(JointRotations)
};
FSGIC_TArray_TArray_FVector HandAnglesContainer{
FSGArrayUtils::FromBPNestedArray<FVector, FSGVectorArray, &FSGVectorArray::VectorArray>(HandAngles)
FSGArrayUtils::FromNestedBPArray<FVector, FSGVectorArray, &FSGVectorArray::VectorArray>(HandAngles)
};
SGCoreImpl_FSGHandPoseImpl_ctor_bRightHanded_JointPositions_JointRotations_HandAngles(
&OutHandPoseImplContainer, bRightHanded, &JointPositionsContainer,
@@ -353,13 +353,13 @@ USGHandPose::USGHandPose(const bool bRightHanded, const
{
FSGIC_FSGHandPoseImpl OutHandPoseImplContainer;
FSGIC_TArray_TArray_FVector JointPositionsContainer{
FSGArrayUtils::FromBPNestedArray<FVector, FSGVectorArray, &FSGVectorArray::VectorArray>(JointPositions)
FSGArrayUtils::FromNestedBPArray<FVector, FSGVectorArray, &FSGVectorArray::VectorArray>(JointPositions)
};
FSGIC_TArray_TArray_FQuat JointRotationsContainer{
FSGArrayUtils::FromBPNestedArray<FQuat, FSGQuatArray, &FSGQuatArray::QuatArray>(JointRotations)
FSGArrayUtils::FromNestedBPArray<FQuat, FSGQuatArray, &FSGQuatArray::QuatArray>(JointRotations)
};
FSGIC_TArray_TArray_FVector HandAnglesContainer{
FSGArrayUtils::FromBPNestedArray<FVector, FSGVectorArray, &FSGVectorArray::VectorArray>(HandAngles)
FSGArrayUtils::FromNestedBPArray<FVector, FSGVectorArray, &FSGVectorArray::VectorArray>(HandAngles)
};
SGCoreImpl_FSGHandPoseImpl_ctor_bRightHanded_JointPositions_JointRotations_HandAngles(
&OutHandPoseImplContainer, bRightHanded, &JointPositionsContainer,
@@ -381,13 +381,13 @@ USGHandPose::USGHandPose(const bool bRightHanded,
{
FSGIC_FSGHandPoseImpl OutHandPoseImplContainer;
FSGIC_TArray_TArray_FVector JointPositionsContainer{
FSGArrayUtils::FromBPNestedArray<FVector, FSGVectorArray, &FSGVectorArray::VectorArray>(JointPositions)
FSGArrayUtils::FromNestedBPArray<FVector, FSGVectorArray, &FSGVectorArray::VectorArray>(JointPositions)
};
FSGIC_TArray_TArray_FQuat JointRotationsContainer{
FSGArrayUtils::RotatorsToQuats<FSGRotatorArray, &FSGRotatorArray::RotatorArray>(JointRotations)
};
FSGIC_TArray_TArray_FVector HandAnglesContainer{
FSGArrayUtils::FromBPNestedArray<FVector, FSGVectorArray, &FSGVectorArray::VectorArray>(HandAngles)
FSGArrayUtils::FromNestedBPArray<FVector, FSGVectorArray, &FSGVectorArray::VectorArray>(HandAngles)
};
SGCoreImpl_FSGHandPoseImpl_ctor_bRightHanded_JointPositions_JointRotations_HandAngles(
&OutHandPoseImplContainer, bRightHanded, &JointPositionsContainer,
@@ -170,7 +170,7 @@ USGSenseGloveInfo* USGSenseGloveInfo::NewSenseGloveInfo(UObject* Outer, const FS
FSGIC_TArray_FVector StartPositionsContainer{StartPositions};
FSGIC_TArray_FQuat StartRotationsContainer{StartRotations};
FSGIC_TArray_TArray_FVector GloveLengthsContainer{
FSGArrayUtils::FromBPNestedArray<FVector, FSGVectorArray, &FSGVectorArray::VectorArray>(GloveLengths)
FSGArrayUtils::FromNestedBPArray<FVector, FSGVectorArray, &FSGVectorArray::VectorArray>(GloveLengths)
};
FSGIC_TArray_bool FunctionsContainer{Functions};
SGCoreImpl_FSGSenseGloveInfoImpl_ctor_DeviceId_HardwareVersion_FirmwareVersion_SubFirmwareVersion_bRightHanded_NumberOfSensors_ImuCorrection_StartPositions_StartRotations_GloveLengths_Functions(
@@ -199,7 +199,7 @@ USGSenseGloveInfo* USGSenseGloveInfo::NewSenseGloveInfo(UObject* Outer, const FS
FSGIC_TArray_FVector StartPositionsContainer{StartPositions};
FSGIC_TArray_FQuat StartRotationsContainer{FSGArrayUtils::RotatorsToQuats(StartRotations)};
FSGIC_TArray_TArray_FVector GloveLengthsContainer{
FSGArrayUtils::FromBPNestedArray<FVector, FSGVectorArray, &FSGVectorArray::VectorArray>(GloveLengths)
FSGArrayUtils::FromNestedBPArray<FVector, FSGVectorArray, &FSGVectorArray::VectorArray>(GloveLengths)
};
FSGIC_TArray_bool FunctionsContainer{Functions};
SGCoreImpl_FSGSenseGloveInfoImpl_ctor_DeviceId_HardwareVersion_FirmwareVersion_SubFirmwareVersion_bRightHanded_NumberOfSensors_ImuCorrection_StartPositions_StartRotations_GloveLengths_Functions(
@@ -330,7 +330,7 @@ USGSenseGloveInfo::USGSenseGloveInfo(
FSGIC_TArray_FVector StartPositionsContainer{StartPositions};
FSGIC_TArray_FQuat StartRotationsContainer{StartRotations};
FSGIC_TArray_TArray_FVector GloveLengthsContainer{
FSGArrayUtils::FromBPNestedArray<FVector, FSGVectorArray, &FSGVectorArray::VectorArray>(GloveLengths)
FSGArrayUtils::FromNestedBPArray<FVector, FSGVectorArray, &FSGVectorArray::VectorArray>(GloveLengths)
};
FSGIC_TArray_bool FunctionsContainer{Functions};
SGCoreImpl_FSGSenseGloveInfoImpl_ctor_DeviceId_HardwareVersion_FirmwareVersion_SubFirmwareVersion_bRightHanded_NumberOfSensors_ImuCorrection_StartPositions_StartRotations_GloveLengths_Functions(
@@ -358,7 +358,7 @@ USGSenseGloveInfo::USGSenseGloveInfo(
FSGIC_TArray_FVector StartPositionsContainer{StartPositions};
FSGIC_TArray_FQuat StartRotationsContainer{FSGArrayUtils::RotatorsToQuats(StartRotations)};
FSGIC_TArray_TArray_FVector GloveLengthsContainer{
FSGArrayUtils::FromBPNestedArray<FVector, FSGVectorArray, &FSGVectorArray::VectorArray>(GloveLengths)
FSGArrayUtils::FromNestedBPArray<FVector, FSGVectorArray, &FSGVectorArray::VectorArray>(GloveLengths)
};
FSGIC_TArray_bool FunctionsContainer{Functions};
SGCoreImpl_FSGSenseGloveInfoImpl_ctor_DeviceId_HardwareVersion_FirmwareVersion_SubFirmwareVersion_bRightHanded_NumberOfSensors_ImuCorrection_StartPositions_StartRotations_GloveLengths_Functions(
@@ -138,13 +138,13 @@ USGSenseGlovePose* USGSenseGlovePose::NewSenseGlovePose(UObject* Outer, const bo
{
FSGIC_FSGSenseGlovePoseImpl OutSenseGlovePoseImplContainer;
FSGIC_TArray_TArray_FVector JointPositionsContainer{
FSGArrayUtils::FromBPNestedArray<FVector, FSGVectorArray, &FSGVectorArray::VectorArray>(JointPositions)
FSGArrayUtils::FromNestedBPArray<FVector, FSGVectorArray, &FSGVectorArray::VectorArray>(JointPositions)
};
FSGIC_TArray_TArray_FQuat JointRotationsContainer{
FSGArrayUtils::FromBPNestedArray<FQuat, FSGQuatArray, &FSGQuatArray::QuatArray>(JointRotations)
FSGArrayUtils::FromNestedBPArray<FQuat, FSGQuatArray, &FSGQuatArray::QuatArray>(JointRotations)
};
FSGIC_TArray_TArray_FVector GloveAnglesContainer{
FSGArrayUtils::FromBPNestedArray<FVector, FSGVectorArray, &FSGVectorArray::VectorArray>(GloveAngles)
FSGArrayUtils::FromNestedBPArray<FVector, FSGVectorArray, &FSGVectorArray::VectorArray>(GloveAngles)
};
SGCoreImpl_FSGSenseGlovePoseImpl_ctor_bRightHanded_JointPositions_JointRotations_GloveAngles(
&OutSenseGlovePoseImplContainer, bRightHanded, &JointPositionsContainer,
@@ -160,13 +160,13 @@ USGSenseGlovePose* USGSenseGlovePose::NewSenseGlovePose(UObject* Outer, const bo
{
FSGIC_FSGSenseGlovePoseImpl OutSenseGlovePoseImplContainer;
FSGIC_TArray_TArray_FVector JointPositionsContainer{
FSGArrayUtils::FromBPNestedArray<FVector, FSGVectorArray, &FSGVectorArray::VectorArray>(JointPositions)
FSGArrayUtils::FromNestedBPArray<FVector, FSGVectorArray, &FSGVectorArray::VectorArray>(JointPositions)
};
FSGIC_TArray_TArray_FQuat JointRotationsContainer{
FSGArrayUtils::RotatorsToQuats<FSGRotatorArray, &FSGRotatorArray::RotatorArray>(JointRotations)
};
FSGIC_TArray_TArray_FVector GloveAnglesContainer{
FSGArrayUtils::FromBPNestedArray<FVector, FSGVectorArray, &FSGVectorArray::VectorArray>(GloveAngles)
FSGArrayUtils::FromNestedBPArray<FVector, FSGVectorArray, &FSGVectorArray::VectorArray>(GloveAngles)
};
SGCoreImpl_FSGSenseGlovePoseImpl_ctor_bRightHanded_JointPositions_JointRotations_GloveAngles(
&OutSenseGlovePoseImplContainer, bRightHanded, &JointPositionsContainer,
@@ -261,13 +261,13 @@ USGSenseGlovePose::USGSenseGlovePose(const bool bRightHanded,
{
FSGIC_FSGSenseGlovePoseImpl OutSenseGlovePoseImplContainer;
FSGIC_TArray_TArray_FVector JointPositionsContainer{
FSGArrayUtils::FromBPNestedArray<FVector, FSGVectorArray, &FSGVectorArray::VectorArray>(JointPositions)
FSGArrayUtils::FromNestedBPArray<FVector, FSGVectorArray, &FSGVectorArray::VectorArray>(JointPositions)
};
FSGIC_TArray_TArray_FQuat JointRotationsContainer{
FSGArrayUtils::FromBPNestedArray<FQuat, FSGQuatArray, &FSGQuatArray::QuatArray>(JointRotations)
FSGArrayUtils::FromNestedBPArray<FQuat, FSGQuatArray, &FSGQuatArray::QuatArray>(JointRotations)
};
FSGIC_TArray_TArray_FVector GloveAnglesContainer{
FSGArrayUtils::FromBPNestedArray<FVector, FSGVectorArray, &FSGVectorArray::VectorArray>(GloveAngles)
FSGArrayUtils::FromNestedBPArray<FVector, FSGVectorArray, &FSGVectorArray::VectorArray>(GloveAngles)
};
SGCoreImpl_FSGSenseGlovePoseImpl_ctor_bRightHanded_JointPositions_JointRotations_GloveAngles(
&OutSenseGlovePoseImplContainer, bRightHanded, &JointPositionsContainer,
@@ -284,13 +284,13 @@ USGSenseGlovePose::USGSenseGlovePose(const bool bRightHanded,
{
FSGIC_FSGSenseGlovePoseImpl OutSenseGlovePoseImplContainer;
FSGIC_TArray_TArray_FVector JointPositionsContainer{
FSGArrayUtils::FromBPNestedArray<FVector, FSGVectorArray, &FSGVectorArray::VectorArray>(JointPositions)
FSGArrayUtils::FromNestedBPArray<FVector, FSGVectorArray, &FSGVectorArray::VectorArray>(JointPositions)
};
FSGIC_TArray_TArray_FQuat JointRotationsContainer{
FSGArrayUtils::RotatorsToQuats<FSGRotatorArray, &FSGRotatorArray::RotatorArray>(JointRotations)
};
FSGIC_TArray_TArray_FVector GloveAnglesContainer{
FSGArrayUtils::FromBPNestedArray<FVector, FSGVectorArray, &FSGVectorArray::VectorArray>(GloveAngles)
FSGArrayUtils::FromNestedBPArray<FVector, FSGVectorArray, &FSGVectorArray::VectorArray>(GloveAngles)
};
SGCoreImpl_FSGSenseGlovePoseImpl_ctor_bRightHanded_JointPositions_JointRotations_GloveAngles(
&OutSenseGlovePoseImplContainer, bRightHanded, &JointPositionsContainer,
@@ -131,7 +131,7 @@ USGSenseGloveSensorData* USGSenseGloveSensorData::NewSenseGloveSensorData(
{
FSGIC_FSGSenseGloveSensorDataImpl OutSenseGloveSensorDataImplContainer;
FSGIC_TArray_TArray_float SensorAnglesContainer{
FSGArrayUtils::FromBPNestedArray<float, FSGFloatArray, &FSGFloatArray::FloatArray>(SensorAngles)
FSGArrayUtils::FromNestedBPArray<float, FSGFloatArray, &FSGFloatArray::FloatArray>(SensorAngles)
};
FSGIC_FQuat ImuRotationContainer{ImuRotation};
SGCoreImpl_FSGSenseGloveSensorDataImpl_ctor_SensorAngles_ImuRotation_ParsedValues_bImuParsed(
@@ -146,7 +146,7 @@ USGSenseGloveSensorData* USGSenseGloveSensorData::NewSenseGloveSensorData(
{
FSGIC_FSGSenseGloveSensorDataImpl OutSenseGloveSensorDataImplContainer;
FSGIC_TArray_TArray_float SensorAnglesContainer{
FSGArrayUtils::FromBPNestedArray<float, FSGFloatArray, &FSGFloatArray::FloatArray>(SensorAngles)
FSGArrayUtils::FromNestedBPArray<float, FSGFloatArray, &FSGFloatArray::FloatArray>(SensorAngles)
};
FSGIC_FQuat ImuRotationContainer{ImuRotation.Quaternion()};
SGCoreImpl_FSGSenseGloveSensorDataImpl_ctor_SensorAngles_ImuRotation_ParsedValues_bImuParsed(
@@ -243,7 +243,7 @@ USGSenseGloveSensorData::USGSenseGloveSensorData(const TArray<FSGFloatArray>& Se
{
FSGIC_FSGSenseGloveSensorDataImpl OutSenseGloveSensorDataImplContainer;
FSGIC_TArray_TArray_float SensorAnglesContainer{
FSGArrayUtils::FromBPNestedArray<float, FSGFloatArray, &FSGFloatArray::FloatArray>(SensorAngles)
FSGArrayUtils::FromNestedBPArray<float, FSGFloatArray, &FSGFloatArray::FloatArray>(SensorAngles)
};
FSGIC_FQuat ImuRotationContainer{ImuRotation};
SGCoreImpl_FSGSenseGloveSensorDataImpl_ctor_SensorAngles_ImuRotation_ParsedValues_bImuParsed(
@@ -258,7 +258,7 @@ USGSenseGloveSensorData::USGSenseGloveSensorData(const TArray<FSGFloatArray>& Se
{
FSGIC_FSGSenseGloveSensorDataImpl OutSenseGloveSensorDataImplContainer;
FSGIC_TArray_TArray_float SensorAnglesContainer{
FSGArrayUtils::FromBPNestedArray<float, FSGFloatArray, &FSGFloatArray::FloatArray>(SensorAngles)
FSGArrayUtils::FromNestedBPArray<float, FSGFloatArray, &FSGFloatArray::FloatArray>(SensorAngles)
};
FSGIC_FQuat ImuRotationContainer{ImuRotation.Quaternion()};
SGCoreImpl_FSGSenseGloveSensorDataImpl_ctor_SensorAngles_ImuRotation_ParsedValues_bImuParsed(
@@ -99,7 +99,7 @@ TArray<TArray<FVector>> FSGSenseGloveVars::GetGloveLengths(const FString& Hardwa
/*
TArray<FSGVectorArray> FSGSenseGloveVars::GetGloveLengths_BP(const FString& HardwareVersion)
{
return FSGArrayUtils::ToBPNestedArray<FVector, FSGVectorArray>(GetGloveLengths(HardwareVersion));
return FSGArrayUtils::ToNestedBPArray<FVector, FSGVectorArray>(GetGloveLengths(HardwareVersion));
}
*/
int32 FSGSenseGloveVars::GetSensors(const FString& HardwareVersion)
@@ -47,6 +47,7 @@
#include "SGCoreImpl/SGQuatImpl.h"
#include "SGCoreImpl/SGVect3DImpl.h"
#include "SGUtils/SGArrayUtils.h"
#include "SGUtils/SGUnits.h"
struct FSGBasicHandModelImpl::FImpl
{
@@ -223,7 +224,7 @@ void FSGBasicHandModelImpl::SetIsRight(const bool bRightHanded)
TArray<TArray<float>> FSGBasicHandModelImpl::GetFingerLengths() const
{
TArray<TArray<float>> FingerLengths{
FSGArrayUtils::FromStdVector<float>(Pimpl->BasicHandModel.GetFingerLengths())
FSGArrayUtils::FromMillimeters(Pimpl->BasicHandModel.GetFingerLengths())
};
return MoveTemp(FingerLengths);
}
@@ -231,28 +232,32 @@ TArray<TArray<float>> FSGBasicHandModelImpl::GetFingerLengths() const
void FSGBasicHandModelImpl::SetFingerLengths(const TArray<TArray<float>>& FingerLengths)
{
std::vector<std::vector<float>> FingerLengthsVector{
FSGArrayUtils::ToStdVector<float>(FingerLengths)
FSGArrayUtils::ToMillimeters(FingerLengths)
};
Pimpl->BasicHandModel.SetFingerLengths(MoveTemp(FingerLengthsVector));
}
TArray<float> FSGBasicHandModelImpl::GetFingerLengths(ESGFinger Finger) const
TArray<float> FSGBasicHandModelImpl::GetFingerLengths(const ESGFinger Finger) const
{
TArray<float> FingerLengths{FSGArrayUtils::FromStdVector<float>(
Pimpl->BasicHandModel.GetFingerLengths(FSGCoreEnumCast::ToEFinger(Finger)))
TArray<float> FingerLengths{
FSGArrayUtils::FromMillimeters(Pimpl->BasicHandModel.GetFingerLengths(FSGCoreEnumCast::ToEFinger(Finger)))
};
return MoveTemp(FingerLengths);
}
void FSGBasicHandModelImpl::SetFingerLengths(ESGFinger Finger, const TArray<float>& Lengths)
void FSGBasicHandModelImpl::SetFingerLengths(const ESGFinger Finger, const TArray<float>& Lengths)
{
std::vector<float> LengthsVector{FSGArrayUtils::ToStdVector<float>(Lengths)};
std::vector<float> LengthsVector{
FSGArrayUtils::ToMillimeters(Lengths)
};
Pimpl->BasicHandModel.SetFingerLengths(FSGCoreEnumCast::ToEFinger(Finger), MoveTemp(LengthsVector));
}
void FSGBasicHandModelImpl::SetFingerLengths(uint8 Finger, const TArray<float>& Lengths)
void FSGBasicHandModelImpl::SetFingerLengths(const uint8 Finger, const TArray<float>& Lengths)
{
std::vector<float> LengthsVector{FSGArrayUtils::ToStdVector<float>(Lengths)};
std::vector<float> LengthsVector{
FSGArrayUtils::ToMillimeters(Lengths)
};
Pimpl->BasicHandModel.SetFingerLengths(Finger, MoveTemp(LengthsVector));
}
@@ -264,7 +269,7 @@ TArray<TArray<float>> FSGBasicHandModelImpl::GetFingerRatios() const
return MoveTemp(FingerRatios);
}
TArray<float> FSGBasicHandModelImpl::GetFingerRatios(ESGFinger Finger) const
TArray<float> FSGBasicHandModelImpl::GetFingerRatios(const ESGFinger Finger) const
{
TArray<float> FingerRatios{
FSGArrayUtils::FromStdVector<float>(Pimpl->BasicHandModel.GetFingerRatios(FSGCoreEnumCast::ToEFinger(Finger)))
@@ -345,21 +350,23 @@ void FSGBasicHandModelImpl::SetJointRotation(const FQuat& NewRotation, const ESG
TArray<float> FSGBasicHandModelImpl::GetTotalLengths() const
{
const TArray<float> TotalLengths{
FSGArrayUtils::FromStdVector<float>(Pimpl->BasicHandModel.GetTotalLengths())
FSGArrayUtils::FromMillimeters(Pimpl->BasicHandModel.GetTotalLengths())
};
return TotalLengths;
}
float FSGBasicHandModelImpl::GetTotalLength(const ESGFinger Finger) const
{
return Pimpl->BasicHandModel.GetTotalLength(FSGCoreEnumCast::ToEFinger(Finger));
return FSGUnits::MillimetersToCentimeters(
Pimpl->BasicHandModel.GetTotalLength(FSGCoreEnumCast::ToEFinger(Finger)));
}
TArray<FVector> FSGBasicHandModelImpl::Get3DLengths(const ESGFinger Finger) const
{
const TArray<FVector> Lengths(FSGArrayUtils::FromStdVector<
FSGVect3DImpl::FVect3DType, FVector, FSGVect3DImpl, &FSGVect3DImpl::ToFVector>(
Pimpl->BasicHandModel.Get3DLengths(FSGCoreEnumCast::ToEFinger(Finger))));
const TArray<FVector> Lengths{
FSGArrayUtils::FromStdVector<FSGVect3DImpl::FVect3DType, FVector, FSGVect3DImpl, &FSGVect3DImpl::ToFVector>(
Pimpl->BasicHandModel.Get3DLengths(FSGCoreEnumCast::ToEFinger(Finger)))
};
return Lengths;
}
@@ -39,6 +39,7 @@
#include "Runtime/Launch/Resources/Version.h"
#include "SGBuildHacks/SGInclude_Core_Vect3D.h"
#include "SGUtils/SGUnits.h"
struct FSGVect3DImpl::FImpl
{
@@ -101,7 +102,12 @@ FSGVect3DImpl::FSGVect3DImpl(const float X, const float Y, const float Z)
Pimpl(TUniquePtr<FImpl, FImplDeleter>(new FImpl{this}))
#endif /* ENGINE_MAJOR_VERSION == 5 || ( ENGINE_MAJOR_VERSION == 4 && ENGINE_MINOR_VERSION > 22 ) */
{
Pimpl->Vect3D = FVect3DType(X, Y, Z);
/// NOTE
/// Unreal Engine uses the Metric System and centimeters as its default unit for measuring distance/length;
/// while SenseGlove uses millimeters.
Pimpl->Vect3D = FVect3DType(FSGUnits::CentimetersToMillimeters(X),
FSGUnits::CentimetersToMillimeters(Y),
FSGUnits::CentimetersToMillimeters(Z));
}
FSGVect3DImpl::FSGVect3DImpl(const FVect3DType& Vect3D)
@@ -132,12 +138,14 @@ FSGVect3DImpl::FSGVect3DImpl(const FVector& Vector)
/// Forward X
/// Right Y
/// Up Z
FVect3DType Vect3D(Vector.X, -Vector.Y, Vector.Z);
/// NOTE
/// Unreal Engine uses the Metric System and centimeters as its default unit for measuring distance/length;
/// while SenseGlove uses millimeters.
Vect3D.Scale(10.0f);
FVect3DType Vect3D(FSGUnits::CentimetersToMillimeters(Vector.X),
FSGUnits::CentimetersToMillimeters(-Vector.Y),
FSGUnits::CentimetersToMillimeters(Vector.Z));
Pimpl->Vect3D = MoveTemp(Vect3D);
}
@@ -182,12 +190,14 @@ FVector FSGVect3DImpl::ToFVector() const
/// Forward X
/// Right Y
/// Up Z
FVector Vector(Pimpl->Vect3D.GetX(), -Pimpl->Vect3D.GetY(), Pimpl->Vect3D.GetZ());
/// NOTE
/// Unreal Engine uses the Metric System and centimeters as its default unit for measuring distance/length;
/// while SenseGlove uses millimeters.
Vector *= 0.1f;
FVector Vector(FSGUnits::MillimetersToCentimeters(Pimpl->Vect3D.GetX()),
FSGUnits::MillimetersToCentimeters(-Pimpl->Vect3D.GetY()),
FSGUnits::MillimetersToCentimeters(Pimpl->Vect3D.GetZ()));
return MoveTemp(Vector);
}
@@ -209,37 +219,58 @@ FSGVect3DImpl FSGVect3DImpl::operator*(const float& ScaleFactor) const
float FSGVect3DImpl::GetX() const
{
return Pimpl->Vect3D.GetX();
/// NOTE
/// Unreal Engine uses the Metric System and centimeters as its default unit for measuring distance/length;
/// while SenseGlove uses millimeters.
return FSGUnits::MillimetersToCentimeters(Pimpl->Vect3D.GetX());
}
void FSGVect3DImpl::SetX(const float X)
{
Pimpl->Vect3D.SetX(X);
/// NOTE
/// Unreal Engine uses the Metric System and centimeters as its default unit for measuring distance/length;
/// while SenseGlove uses millimeters.
Pimpl->Vect3D.SetX(FSGUnits::CentimetersToMillimeters(X));
}
float FSGVect3DImpl::GetY() const
{
return Pimpl->Vect3D.GetY();
/// NOTE
/// Unreal Engine uses the Metric System and centimeters as its default unit for measuring distance/length;
/// while SenseGlove uses millimeters.
return FSGUnits::MillimetersToCentimeters(Pimpl->Vect3D.GetY());
}
void FSGVect3DImpl::SetY(const float Y)
{
Pimpl->Vect3D.SetY(Y);
/// NOTE
/// Unreal Engine uses the Metric System and centimeters as its default unit for measuring distance/length;
/// while SenseGlove uses millimeters.
Pimpl->Vect3D.SetY(FSGUnits::CentimetersToMillimeters(Y));
}
float FSGVect3DImpl::GetZ() const
{
return Pimpl->Vect3D.GetZ();
/// NOTE
/// Unreal Engine uses the Metric System and centimeters as its default unit for measuring distance/length;
/// while SenseGlove uses millimeters.
return FSGUnits::MillimetersToCentimeters(Pimpl->Vect3D.GetZ());
}
void FSGVect3DImpl::SetZ(const float Z)
{
Pimpl->Vect3D.SetZ(Z);
/// NOTE
/// Unreal Engine uses the Metric System and centimeters as its default unit for measuring distance/length;
/// while SenseGlove uses millimeters.
Pimpl->Vect3D.SetZ(FSGUnits::CentimetersToMillimeters(Z));
}
float FSGVect3DImpl::Magnitude() const
{
return Pimpl->Vect3D.Magnitude();
/// NOTE
/// Unreal Engine uses the Metric System and centimeters as its default unit for measuring distance/length;
/// while SenseGlove uses millimeters.
return FSGUnits::MillimetersToCentimeters(Pimpl->Vect3D.Magnitude());
}
void FSGVect3DImpl::Normalize()
@@ -254,7 +285,10 @@ void FSGVect3DImpl::Scale(const float Factor)
float FSGVect3DImpl::DistTo(const FSGVect3DImpl& Vect3DImpl) const
{
return Pimpl->Vect3D.DistTo(Vect3DImpl.ToVect3D());
/// NOTE
/// Unreal Engine uses the Metric System and centimeters as its default unit for measuring distance/length;
/// while SenseGlove uses millimeters.
return FSGUnits::MillimetersToCentimeters(Pimpl->Vect3D.DistTo(Vect3DImpl.ToVect3D()));
}
bool FSGVect3DImpl::Equals(const FSGVect3DImpl& Vect3DImpl) const
@@ -153,38 +153,38 @@ public:
public:
/**
* Get the x-component of the 3D vector.
* Get the x-component of the 3D vector in cm.
*/
float GetX() const;
/**
* Set the x-component of the 3D vector.
* Set the x-component of the 3D vector in cm.
*/
void SetX(float X);
/**
* Get the y-component of the 3D vector.
* Get the y-component of the 3D vector in cm.
*/
float GetY() const;
/**
* Set the y-component of the 3D vector.
* Set the y-component of the 3D vector in cm.
*/
void SetY(float Y);
/**
* Get the z-component of the 3D vector.
* Get the z-component of the 3D vector in cm.
*/
float GetZ() const;
/**
* Set the z-component of the 3D vector.
* Set the z-component of the 3D vector in cm.
*/
void SetZ(float Z);
public:
/**
* Calculate the magnitude or 'length' of this Vector.
* Calculate the magnitude or 'length' of this Vector in cm.
*/
float Magnitude() const;
@@ -199,7 +199,7 @@ public:
void Scale(float Factor);
/**
* Calculate the distance between this Vector and another one.
* Calculate the distance between this Vector and another one in cm.
*/
float DistTo(const FSGVect3DImpl& Vect3DImpl) const;
@@ -82,20 +82,20 @@ float USGAnatomyKismetLibrary::NormalizeThumbFlex(const float FlexionInRadians)
TArray<FSGVectorArray> USGAnatomyKismetLibrary::GetDefaultHandAngles(const bool bRightHanded)
{
return FSGArrayUtils::ToBPNestedArray<FVector, FSGVectorArray>(FSGAnatomy::GetDefaultHandAngles(bRightHanded));
return FSGArrayUtils::ToNestedBPArray<FVector, FSGVectorArray>(FSGAnatomy::GetDefaultHandAngles(bRightHanded));
}
TArray<FSGVectorArray> USGAnatomyKismetLibrary::GetFlatHandAngles(const bool bRightHanded)
{
return FSGArrayUtils::ToBPNestedArray<FVector, FSGVectorArray>(FSGAnatomy::GetFlatHandAngles(bRightHanded));
return FSGArrayUtils::ToNestedBPArray<FVector, FSGVectorArray>(FSGAnatomy::GetFlatHandAngles(bRightHanded));
}
TArray<FSGVectorArray> USGAnatomyKismetLibrary::GetThumbsUpHandAngles(const bool bRightHanded)
{
return FSGArrayUtils::ToBPNestedArray<FVector, FSGVectorArray>(FSGAnatomy::GetThumbsUpHandAngles(bRightHanded));
return FSGArrayUtils::ToNestedBPArray<FVector, FSGVectorArray>(FSGAnatomy::GetThumbsUpHandAngles(bRightHanded));
}
TArray<FSGVectorArray> USGAnatomyKismetLibrary::GetFistHandAngles(const bool bRightHanded)
{
return FSGArrayUtils::ToBPNestedArray<FVector, FSGVectorArray>(FSGAnatomy::GetFistHandAngles(bRightHanded));
return FSGArrayUtils::ToNestedBPArray<FVector, FSGVectorArray>(FSGAnatomy::GetFistHandAngles(bRightHanded));
}
@@ -81,7 +81,7 @@ USGBasicHandModel* USGBasicHandModelKismetLibrary::Deserialize(UObject* WorldCon
TArray<FSGFloatArray> USGBasicHandModelKismetLibrary::GetBaseFingerLengths()
{
return FSGArrayUtils::ToBPNestedArray<float, FSGFloatArray>(USGBasicHandModel::GetBaseFingerLengths());
return FSGArrayUtils::ToNestedBPArray<float, FSGFloatArray>(USGBasicHandModel::GetBaseFingerLengths());
}
TArray<FVector> USGBasicHandModelKismetLibrary::GetBaseJointPositions()
@@ -101,7 +101,7 @@ bool USGBasicHandModelKismetLibrary::IsRight(const USGBasicHandModel* BasicHandM
TArray<FSGFloatArray> USGBasicHandModelKismetLibrary::GetFingerLengths(const USGBasicHandModel* BasicHandModel)
{
return FSGArrayUtils::ToBPNestedArray<float, FSGFloatArray>(BasicHandModel->GetFingerLengths());
return FSGArrayUtils::ToNestedBPArray<float, FSGFloatArray>(BasicHandModel->GetFingerLengths());
}
TArray<float> USGBasicHandModelKismetLibrary::GetFingerLengths_F(const USGBasicHandModel* BasicHandModel,
@@ -125,7 +125,7 @@ void USGBasicHandModelKismetLibrary::SetFingerLengths_uint8_F_L(USGBasicHandMode
TArray<FSGFloatArray> USGBasicHandModelKismetLibrary::GetFingerRatios(const USGBasicHandModel* BasicHandModel) const
{
return FSGArrayUtils::ToBPNestedArray<float, FSGFloatArray>(BasicHandModel->GetFingerRatios());
return FSGArrayUtils::ToNestedBPArray<float, FSGFloatArray>(BasicHandModel->GetFingerRatios());
}
TArray<float> USGBasicHandModelKismetLibrary::GetFingerRatios_F(const USGBasicHandModel* BasicHandModel,
@@ -89,14 +89,14 @@ TArray<FVector> USGHandInterpolatorKismetLibrary::InterpolateThumbAngles(
TArray<FSGVectorArray> USGHandInterpolatorKismetLibrary::InterpolateHandAngles(
const USGHandInterpolator* Interpolator, const TArray<FVector>& TotalAngles)
{
return FSGArrayUtils::ToBPNestedArray<FVector, FSGVectorArray>(
return FSGArrayUtils::ToNestedBPArray<FVector, FSGVectorArray>(
USGHandInterpolator::InterpolateHandAngles(Interpolator, TotalAngles));
}
TArray<FSGInterpolationSetArray> USGHandInterpolatorKismetLibrary::GetJointInterpolations(
UObject* WorldContextObject, const USGHandInterpolator* HandInterpolator) const
{
return FSGArrayUtils::ToBPNestedArray<USGInterpolationSet, FSGInterpolationSetArray>(
return FSGArrayUtils::ToNestedBPArray<USGInterpolationSet, FSGInterpolationSetArray>(
HandInterpolator->GetJointInterpolations(WorldContextObject));
}
@@ -71,7 +71,7 @@ USGHandPose* USGHandPoseKismetLibrary::FromHandAngles_HA_bRH_HD(
const TArray<FSGVectorArray>& HandAngles, const bool bRightHanded, const USGBasicHandModel* HandDimensions)
{
TArray<TArray<FVector>> HandAnglesNestedArray{
FSGArrayUtils::FromBPNestedArray<FVector, FSGVectorArray, &FSGVectorArray::VectorArray>(HandAngles)
FSGArrayUtils::FromNestedBPArray<FVector, FSGVectorArray, &FSGVectorArray::VectorArray>(HandAngles)
};
return USGHandPose::FromHandAngles(WorldContextObject, MoveTemp(HandAnglesNestedArray), bRightHanded,
HandDimensions);
@@ -81,7 +81,7 @@ USGHandPose* USGHandPoseKismetLibrary::FromHandAngles_HA_bRH(
UObject* WorldContextObject, const TArray<FSGVectorArray>& HandAngles, const bool bRightHanded)
{
TArray<TArray<FVector>> HandAnglesNestedArray{
FSGArrayUtils::FromBPNestedArray<FVector, FSGVectorArray, &FSGVectorArray::VectorArray>(HandAngles)
FSGArrayUtils::FromNestedBPArray<FVector, FSGVectorArray, &FSGVectorArray::VectorArray>(HandAngles)
};
return USGHandPose::FromHandAngles(WorldContextObject, MoveTemp(HandAnglesNestedArray), bRightHanded);
}
@@ -137,22 +137,22 @@ bool USGHandPoseKismetLibrary::IsRight(const USGHandPose* HandPose)
TArray<FSGVectorArray> USGHandPoseKismetLibrary::GetJointPositions(const USGHandPose* HandPose)
{
return FSGArrayUtils::ToBPNestedArray<FVector, FSGVectorArray>(HandPose->GetJointPositions());
return FSGArrayUtils::ToNestedBPArray<FVector, FSGVectorArray>(HandPose->GetJointPositions());
}
TArray<FSGQuatArray> USGHandPoseKismetLibrary::GetJointRotationsQ(const USGHandPose* HandPose)
{
return FSGArrayUtils::ToBPNestedArray<FQuat, FSGQuatArray>(HandPose->GetJointRotationsQ());
return FSGArrayUtils::ToNestedBPArray<FQuat, FSGQuatArray>(HandPose->GetJointRotationsQ());
}
TArray<FSGRotatorArray> USGHandPoseKismetLibrary::GetJointRotations(const USGHandPose* HandPose)
{
return FSGArrayUtils::ToBPNestedArray<FRotator, FSGRotatorArray>(HandPose->GetJointRotations());
return FSGArrayUtils::ToNestedBPArray<FRotator, FSGRotatorArray>(HandPose->GetJointRotations());
}
TArray<FSGVectorArray> USGHandPoseKismetLibrary::GetHandAngles(const USGHandPose* HandPose)
{
return FSGArrayUtils::ToBPNestedArray<FVector, FSGVectorArray>(HandPose->GetHandAngles());
return FSGArrayUtils::ToNestedBPArray<FVector, FSGVectorArray>(HandPose->GetHandAngles());
}
bool USGHandPoseKismetLibrary::Equals(const USGHandPose* A, const USGHandPose* B)
@@ -54,9 +54,9 @@ void USGNovaGloveCalibrationKismetLibrary::ApplyInterpolationValues(const TArray
{
FSGNovaGloveCalibration::ApplyInterpolationValues(
RetractedValues, ExtendedValues,
FSGArrayUtils::FromBPNestedArray<
FSGArrayUtils::FromNestedBPArray<
FVector, FSGVectorArray, &FSGVectorArray::VectorArray>(RetractedAngles),
FSGArrayUtils::FromBPNestedArray<
FSGArrayUtils::FromNestedBPArray<
FVector, FSGVectorArray, &FSGVectorArray::VectorArray>(ExtendedAngles),
Profile);
}
@@ -144,7 +144,7 @@ TArray<FRotator> USGSenseGloveInfoKismetLibrary::GetStartRotations_TArrayFRotato
TArray<FSGVectorArray> USGSenseGloveInfoKismetLibrary::GetGloveLengths(const USGSenseGloveInfo* SenseGloveInfo)
{
return FSGArrayUtils::ToBPNestedArray<FVector, FSGVectorArray>(SenseGloveInfo->GetGloveLengths());
return FSGArrayUtils::ToNestedBPArray<FVector, FSGVectorArray>(SenseGloveInfo->GetGloveLengths());
}
TArray<bool> USGSenseGloveInfoKismetLibrary::GetFunctions(const USGSenseGloveInfo* SenseGloveInfo)
@@ -180,11 +180,11 @@ TArray<FSGVectorArray> USGSenseGloveInfoKismetLibrary::ToGloveAngles(const USGSe
const TArray<FSGFloatArray>& SensorAngles)
{
TArray<TArray<float>> SensorAnglesNestedArray{
FSGArrayUtils::FromBPNestedArray<
FSGArrayUtils::FromNestedBPArray<
float, FSGFloatArray, &FSGFloatArray::FloatArray>(SensorAngles)
};
TArray<FSGVectorArray> GloveAngles{
FSGArrayUtils::ToBPNestedArray<FVector, FSGVectorArray>(
FSGArrayUtils::ToNestedBPArray<FVector, FSGVectorArray>(
SenseGloveInfo->ToGloveAngles(MoveTemp(SensorAnglesNestedArray)))
};
return MoveTemp(GloveAngles);
@@ -62,7 +62,7 @@ USGSenseGlovePose* USGSenseGloveKismetLibrary::CalculateGlovePose_GA_GM(
const TArray<FSGVectorArray>& GloveAngles, const USGSenseGloveInfo* GloveModel)
{
TArray<TArray<FVector>> GloveAnglesNestedArray{
FSGArrayUtils::FromBPNestedArray<FVector, FSGVectorArray, &FSGVectorArray::VectorArray>(GloveAngles)
FSGArrayUtils::FromNestedBPArray<FVector, FSGVectorArray, &FSGVectorArray::VectorArray>(GloveAngles)
};
return USGSenseGlove::CalculateGlovePose(WorldContextObject, MoveTemp(GloveAnglesNestedArray), GloveModel);
}
@@ -80,24 +80,24 @@ bool USGSenseGlovePoseKismetLibrary::IsRight(const USGSenseGlovePose* SenseGlove
TArray<FSGVectorArray> USGSenseGlovePoseKismetLibrary::GetJointPositions(const USGSenseGlovePose* SenseGlovePose)
{
return FSGArrayUtils::ToBPNestedArray<FVector, FSGVectorArray>(SenseGlovePose->GetJointPositions());
return FSGArrayUtils::ToNestedBPArray<FVector, FSGVectorArray>(SenseGlovePose->GetJointPositions());
}
TArray<FSGQuatArray> USGSenseGlovePoseKismetLibrary::GetJointRotations_TArrayFSGQuatArray(
const USGSenseGlovePose* SenseGlovePose)
{
return FSGArrayUtils::ToBPNestedArray<FQuat, FSGQuatArray>(SenseGlovePose->GetJointRotationsQ());
return FSGArrayUtils::ToNestedBPArray<FQuat, FSGQuatArray>(SenseGlovePose->GetJointRotationsQ());
}
TArray<FSGRotatorArray> USGSenseGlovePoseKismetLibrary::GetJointRotations_TArrayFSGRotatorArray(
const USGSenseGlovePose* SenseGlovePose)
{
return FSGArrayUtils::ToBPNestedArray<FRotator, FSGRotatorArray>(SenseGlovePose->GetJointRotations());
return FSGArrayUtils::ToNestedBPArray<FRotator, FSGRotatorArray>(SenseGlovePose->GetJointRotations());
}
TArray<FSGVectorArray> USGSenseGlovePoseKismetLibrary::GetGloveAngles(const USGSenseGlovePose* SenseGlovePose)
{
return FSGArrayUtils::ToBPNestedArray<FVector, FSGVectorArray>(SenseGlovePose->GetGloveAngles());
return FSGArrayUtils::ToNestedBPArray<FVector, FSGVectorArray>(SenseGlovePose->GetGloveAngles());
}
TArray<FVector> USGSenseGlovePoseKismetLibrary::GetThimblePositions(const USGSenseGlovePose* SenseGlovePose)
@@ -81,7 +81,7 @@ USGSenseGloveSensorData* USGSenseGloveSensorDataKismetLibrary::Deserialize(UObje
TArray<FSGFloatArray> USGSenseGloveSensorDataKismetLibrary::GetSensorAngles(
const USGSenseGloveSensorData* SenseGloveSensorData)
{
return FSGArrayUtils::ToBPNestedArray<float, FSGFloatArray>(SenseGloveSensorData->GetSensorAngles());
return FSGArrayUtils::ToNestedBPArray<float, FSGFloatArray>(SenseGloveSensorData->GetSensorAngles());
}
FQuat USGSenseGloveSensorDataKismetLibrary::GetImuRotation_FQuat(const USGSenseGloveSensorData* SenseGloveSensorData)
@@ -70,7 +70,7 @@ TArray<FRotator> USGSenseGloveVarsKismetLibrary::GetStartRotations_TArrayFRotato
TArray<FSGVectorArray> USGSenseGloveVarsKismetLibrary::GetGloveLengths(const FString& HardwareVersion)
{
return FSGArrayUtils::ToBPNestedArray<FVector, FSGVectorArray>(FSGSenseGloveVars::GetGloveLengths(HardwareVersion));
return FSGArrayUtils::ToNestedBPArray<FVector, FSGVectorArray>(FSGSenseGloveVars::GetGloveLengths(HardwareVersion));
}
int32 USGSenseGloveVarsKismetLibrary::GetSensors(const FString& HardwareVersion)
@@ -35,6 +35,8 @@
#include "SGUtils/SGArrayUtils.h"
#include "SGUtils/SGUnits.h"
TArray<FRotator> FSGArrayUtils::QuatsToRotators(const TArray<FQuat>& QuatsArray)
{
TArray<FRotator> RotatorsArray;
@@ -85,4 +87,54 @@ TArray<TArray<FQuat>> FSGArrayUtils::RotatorsToQuats(const TArray<TArray<FRotato
}
return MoveTemp(QuatsNestedArray);
}
TArray<float> FSGArrayUtils::FromMillimeters(const std::vector<float>& Vector)
{
TArray<float> Array;
for (const float Value: Vector)
{
Array.Add(FSGUnits::MillimetersToCentimeters(Value));
}
return MoveTemp(Array);
}
TArray<TArray<float>> FSGArrayUtils::FromMillimeters(const std::vector<std::vector<float>>& NestedVector)
{
TArray<TArray<float>> NestedArray;
for (const std::vector<float>& InnerVector: NestedVector)
{
TArray<float> InnerArray{FromMillimeters(InnerVector)};
NestedArray.Add(MoveTemp(InnerArray));
}
return MoveTemp(NestedArray);
}
std::vector<float> FSGArrayUtils::ToMillimeters(const TArray<float>& Array)
{
std::vector<float> Vector;
for (const float Value: Array)
{
Vector.emplace_back(FSGUnits::CentimetersToMillimeters(Value));
}
return MoveTemp(Vector);
}
std::vector<std::vector<float>> FSGArrayUtils::ToMillimeters(const TArray<TArray<float>>& NestedArray)
{
std::vector<std::vector<float>> NestedVector;
for (const TArray<float>& InnerArray: NestedArray)
{
std::vector<float> InnerVector{ToMillimeters(InnerArray)};
NestedVector.emplace_back(MoveTemp(InnerVector));
}
return MoveTemp(NestedVector);
}
@@ -0,0 +1,36 @@
/**
* @file
*
* @author Mamadou Babaei <mamadou@senseglove.com>
*
* @section LICENSE
*
* (The MIT License)
*
* Copyright (c) 2020 - 2022 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 "SGUtils/SGUnits.h"
@@ -67,17 +67,17 @@ public:
}
template<typename T>
static FORCEINLINE TArray<TArray<T>> FromStdVector(const std::vector<std::vector<T>>& Vector)
static TArray<TArray<T>> FromStdVector(const std::vector<std::vector<T>>& NestedVector)
{
TArray<TArray<T>> Array;
TArray<TArray<T>> NestedArray;
for (const std::vector<T>& InnerVector: Vector)
for (const std::vector<T>& InnerVector: NestedVector)
{
TArray<T> InnerArray{FromStdVector<T>(InnerVector)};
Array.Add(MoveTemp(InnerArray));
NestedArray.Add(MoveTemp(InnerArray));
}
return MoveTemp(Array);
return MoveTemp(NestedArray);
}
template<typename T1, typename T2>
@@ -95,17 +95,17 @@ public:
}
template<typename T1, typename T2>
static TArray<TArray<T2>> FromStdVector(const std::vector<std::vector<T1>>& Vector)
static TArray<TArray<T2>> FromStdVector(const std::vector<std::vector<T1>>& NestedVector)
{
TArray<TArray<T2>> Array;
TArray<TArray<T2>> NestedArray;
for (const std::vector<T1>& InnerVector: Vector)
for (const std::vector<T1>& InnerVector: NestedVector)
{
TArray<T2> InnerArray{FromStdVector<T1, T2>(InnerVector)};
Array.Add(MoveTemp(InnerArray));
NestedArray.Add(MoveTemp(InnerArray));
}
return MoveTemp(Array);
return MoveTemp(NestedArray);
}
template<typename T1, typename T2, typename IntermediateImpl, T2(IntermediateImpl::*ToT2TypeMethod)() const>
@@ -124,17 +124,17 @@ public:
}
template<typename T1, typename T2, typename IntermediateImpl, T2(IntermediateImpl::*ToT2TypeMethod)() const>
static TArray<TArray<T2>> FromStdVector(const std::vector<std::vector<T1>>& Vector)
static TArray<TArray<T2>> FromStdVector(const std::vector<std::vector<T1>>& NestedVector)
{
TArray<TArray<T2>> Array;
TArray<TArray<T2>> NestedArray;
for (const std::vector<T1>& InnerVector: Vector)
for (const std::vector<T1>& InnerVector: NestedVector)
{
TArray<T2> InnerArray{FromStdVector<T1, T2, IntermediateImpl, ToT2TypeMethod>(InnerVector)};
Array.Add(MoveTemp(InnerArray));
NestedArray.Add(MoveTemp(InnerArray));
}
return MoveTemp(Array);
return MoveTemp(NestedArray);
}
template<typename T>
@@ -145,17 +145,17 @@ public:
}
template<typename T>
static FORCEINLINE std::vector<std::vector<T>> ToStdVector(const TArray<TArray<T>>& Array)
static std::vector<std::vector<T>> ToStdVector(const TArray<TArray<T>>& NestedArray)
{
std::vector<std::vector<T>> Vector;
std::vector<std::vector<T>> NestedVector;
for (const TArray<T>& InnerArray: Array)
for (const TArray<T>& InnerArray: NestedArray)
{
std::vector<T> InnerVector{ToStdVector<T>(InnerArray)};
Vector.emplace_back(MoveTemp(InnerVector));
NestedVector.emplace_back(MoveTemp(InnerVector));
}
return MoveTemp(Vector);
return MoveTemp(NestedVector);
}
template<typename T1, typename T2, const T2&(T1::*ToUnderlyingTypeMethod)() const>
@@ -173,17 +173,17 @@ public:
}
template<typename T1, typename T2, const T2&(T1::*ToUnderlyingTypeMethod)() const>
static std::vector<std::vector<T2>> ToStdVector(const TArray<TArray<T1>>& Array)
static std::vector<std::vector<T2>> ToStdVector(const TArray<TArray<T1>>& NestedArray)
{
std::vector<std::vector<T2>> Vector;
std::vector<std::vector<T2>> NestedVector;
for (const TArray<T1>& InnerArray: Array)
for (const TArray<T1>& InnerArray: NestedArray)
{
std::vector<T2> InnerVector{ToStdVector<T1, T2, ToUnderlyingTypeMethod>(InnerArray)};
Vector.emplace_back(MoveTemp(InnerVector));
NestedVector.emplace_back(MoveTemp(InnerVector));
}
return MoveTemp(Vector);
return MoveTemp(NestedVector);
}
template<typename T1, typename T2, typename IntermediateImpl,
@@ -204,17 +204,17 @@ public:
template<typename T1, typename T2, typename IntermediateImpl,
const T2&(IntermediateImpl::*ToUnderlyingTypeMethod)() const>
static std::vector<std::vector<T2>> ToStdVector(const TArray<TArray<T1>>& Array)
static std::vector<std::vector<T2>> ToStdVector(const TArray<TArray<T1>>& NestedArray)
{
std::vector<std::vector<T2>> Vector;
std::vector<std::vector<T2>> NestedVector;
for (const TArray<T1>& InnerArray: Array)
for (const TArray<T1>& InnerArray: NestedArray)
{
std::vector<T2> InnerVector{ToStdVector<T1, T2, IntermediateImpl, ToUnderlyingTypeMethod>(InnerArray)};
Vector.emplace_back(MoveTemp(InnerVector));
NestedVector.emplace_back(MoveTemp(InnerVector));
}
return MoveTemp(Vector);
return MoveTemp(NestedVector);
}
template<typename T1, typename T2>
@@ -246,46 +246,46 @@ public:
}
template<typename T1, typename T2>
static TArray<TArray<T2>> FromImplType(const TArray<TArray<T1>>& ImplArray)
static TArray<TArray<T2>> FromImplType(const TArray<TArray<T1>>& NestedImplArray)
{
TArray<TArray<T2>> Array;
TArray<TArray<T2>> NestedArray;
for (const TArray<T1>& InnerImplArray: ImplArray)
for (const TArray<T1>& InnerImplArray: NestedImplArray)
{
TArray<T2> InnerArray{FromImplType<T1, T2>(InnerImplArray)};
Array.Add(MoveTemp(InnerArray));
NestedArray.Add(MoveTemp(InnerArray));
}
return MoveTemp(Array);
return MoveTemp(NestedArray);
}
template<typename T1, typename T2, T2*(*NewObjectMethod)(UObject*, const T1&)>
static TArray<TArray<T2*>> FromImplType(UObject* Outer, const TArray<TArray<T1>>& ImplArray)
static TArray<TArray<T2*>> FromImplType(UObject* Outer, const TArray<TArray<T1>>& NestedImplArray)
{
TArray<TArray<T2*>> Array;
TArray<TArray<T2*>> NestedArray;
for (const TArray<T1>& InnerImplArray: ImplArray)
for (const TArray<T1>& InnerImplArray: NestedImplArray)
{
TArray<T2*> InnerArray{FromImplType<T1, T2, NewObjectMethod>(Outer, InnerImplArray)};
Array.Add(MoveTemp(InnerArray));
NestedArray.Add(MoveTemp(InnerArray));
}
return MoveTemp(Array);
return MoveTemp(NestedArray);
}
template<typename T1, typename T2, typename S>
static TArray<S> FromImplType(const TArray<TArray<T1>>& ImplArray)
static TArray<S> FromImplType(const TArray<TArray<T1>>& NestedImplArray)
{
TArray<S> Array;
TArray<S> NestedBPArray;
for (const TArray<T1>& InnerImplArray: ImplArray)
for (const TArray<T1>& InnerImplArray: NestedImplArray)
{
TArray<T2> InnerArray{FromImplType<T1, T2>(InnerImplArray)};
S InnerArrayContainer{MoveTemp(InnerArray)};
Array.Add(MoveTemp(InnerArrayContainer));
NestedBPArray.Add(MoveTemp(InnerArrayContainer));
}
return MoveTemp(Array);
return MoveTemp(NestedBPArray);
}
template<typename T1, typename T2, typename S, T2*(*NewObjectMethod)(UObject*, const T1&)>
@@ -405,132 +405,152 @@ public:
}
template<typename T, typename S, TArray<T> S::*InnerArray>
static TArray<TArray<T>> FromBPNestedArray(const TArray<S>& BPNestedArray)
static TArray<TArray<T>> FromNestedBPArray(const TArray<S>& NestedBPArray)
{
TArray<TArray<T>> NestedArray;
for (const S& BPInnerArrayContainer: BPNestedArray)
for (const S& InnerBPArrayContainer: NestedBPArray)
{
NestedArray.Add(BPInnerArrayContainer.*InnerArray);
NestedArray.Add(InnerBPArrayContainer.*InnerArray);
}
return MoveTemp(NestedArray);
}
template<typename T, typename S>
static TArray<S> ToBPNestedArray(const TArray<TArray<T>>& NestedArray)
static TArray<S> ToNestedBPArray(const TArray<TArray<T>>& Array)
{
TArray<S> BPNestedArray;
TArray<S> NestedBPArray;
for (const TArray<T>& InnerArray: NestedArray)
for (const TArray<T>& InnerArray: Array)
{
S BPInnerArrayContainer{InnerArray};
BPNestedArray.Add(MoveTemp(BPInnerArrayContainer));
S InnerBPArrayContainer{InnerArray};
NestedBPArray.Add(MoveTemp(InnerBPArrayContainer));
}
return MoveTemp(BPNestedArray);
return MoveTemp(NestedBPArray);
}
template<typename T, typename S>
static TArray<S> ToBPNestedArray(const TArray<TArray<T*>>& NestedArray)
static TArray<S> ToNestedBPArray(const TArray<TArray<T*>>& NestedArray)
{
TArray<S> BPNestedArray;
TArray<S> NestedBPArray;
for (const TArray<T*>& InnerArray: NestedArray)
{
S BPInnerArrayContainer{InnerArray};
BPNestedArray.Add(MoveTemp(BPInnerArrayContainer));
S InnerBPArrayContainer{InnerArray};
NestedBPArray.Add(MoveTemp(InnerBPArrayContainer));
}
return MoveTemp(BPNestedArray);
return MoveTemp(NestedBPArray);
}
static TArray<FRotator> QuatsToRotators(const TArray<FQuat>& QuatsArray);
static TArray<TArray<FRotator>> QuatsToRotators(const TArray<TArray<FQuat>>& QuatsNestedArray);
static TArray<TArray<FRotator>> QuatsToRotators(const TArray<TArray<FQuat>>& QuatsArray);
template<typename S, TArray<FQuat> S::*InnerArray>
static TArray<TArray<FRotator>> QuatsToRotators(const TArray<S>& QuatsNestedArray)
{
TArray<TArray<FRotator>> RotatorsNestedArray;
TArray<TArray<FRotator>> RotatorsArray;
for (const S& BPQuatsInnerArrayContainer: QuatsNestedArray)
for (const S& QuatsInnerBPArrayContainer: QuatsNestedArray)
{
RotatorsNestedArray.Add(QuatsToRotators(BPQuatsInnerArrayContainer.*InnerArray));
RotatorsArray.Add(QuatsToRotators(QuatsInnerBPArrayContainer.*InnerArray));
}
return MoveTemp(RotatorsNestedArray);
return MoveTemp(RotatorsArray);
}
template<typename S>
static TArray<S> QuatsToRotators(const TArray<TArray<FQuat>>& QuatsNestedArray)
static TArray<S> QuatsToRotators(const TArray<TArray<FQuat>>& QuatsArray)
{
TArray<S> BPRotatorsNestedArray;
TArray<S> RotatorsNestedBPArray;
for (const TArray<FQuat>& QuatsInnerArray: QuatsNestedArray)
for (const TArray<FQuat>& QuatsInnerArray: QuatsArray)
{
S BPRotatorsInnerArrayContainer{QuatsToRotators(QuatsInnerArray)};
BPRotatorsNestedArray.Add(MoveTemp(BPRotatorsInnerArrayContainer));
S RotatorsInnerBPArrayContainer{QuatsToRotators(QuatsInnerArray)};
RotatorsNestedBPArray.Add(MoveTemp(RotatorsInnerBPArrayContainer));
}
return MoveTemp(BPRotatorsNestedArray);
return MoveTemp(RotatorsNestedBPArray);
}
template<typename Q, typename R, TArray<FQuat> Q::*InnerArray>
static TArray<R> QuatsToRotators(const TArray<Q>& QuatsNestedArray)
{
TArray<R> BPRotatorsNestedArray;
TArray<R> RotatorsNestedBPArray;
for (const Q& QuatsInnerArrayContainer: QuatsNestedArray)
{
R BPRotatorsInnerArrayContainer{QuatsToRotators(QuatsInnerArrayContainer.*InnerArray)};
BPRotatorsNestedArray.Add(MoveTemp(BPRotatorsInnerArrayContainer));
R RotatorsInnerBPArrayContainer{QuatsToRotators(QuatsInnerArrayContainer.*InnerArray)};
RotatorsNestedBPArray.Add(MoveTemp(RotatorsInnerBPArrayContainer));
}
return MoveTemp(BPRotatorsNestedArray);
return MoveTemp(RotatorsNestedBPArray);
}
static TArray<FQuat> RotatorsToQuats(const TArray<FRotator>& RotatorsArray);
static TArray<FQuat> RotatorsToQuats(const TArray<FRotator>& RotatorsNestedArray);
static TArray<TArray<FQuat>> RotatorsToQuats(const TArray<TArray<FRotator>>& RotatorsNestedArray);
template<typename S, TArray<FRotator> S::*InnerArray>
static TArray<TArray<FQuat>> RotatorsToQuats(const TArray<S>& RotatorsNestedArray)
{
TArray<TArray<FQuat>> QuatsNestedArray;
TArray<TArray<FQuat>> QuatsArray;
for (const S& BPRotatorsInnerArrayContainer: RotatorsNestedArray)
for (const S& RotatorsInnerBPArrayContainer: RotatorsNestedArray)
{
QuatsNestedArray.Add(RotatorsToQuats(BPRotatorsInnerArrayContainer.*InnerArray));
QuatsArray.Add(RotatorsToQuats(RotatorsInnerBPArrayContainer.*InnerArray));
}
return MoveTemp(QuatsNestedArray);
return MoveTemp(QuatsArray);
}
template<typename S>
static TArray<S> RotatorsToQuats(const TArray<TArray<FRotator>>& RotatorsNestedArray)
{
TArray<S> BPQuatsNestedArray;
TArray<S> QuatsNestedBPArray;
for (const TArray<FRotator>& RotatorsInnerArray: RotatorsNestedArray)
{
S BPQuatsInnerArrayContainer{RotatorsToQuats(RotatorsInnerArray)};
BPQuatsNestedArray.Add(MoveTemp(BPQuatsInnerArrayContainer));
S QuatsInnerBPArrayContainer{RotatorsToQuats(RotatorsInnerArray)};
QuatsNestedBPArray.Add(MoveTemp(QuatsInnerBPArrayContainer));
}
return MoveTemp(BPQuatsNestedArray);
return MoveTemp(QuatsNestedBPArray);
}
template<typename Q, typename R, TArray<FRotator> Q::*InnerArray>
static TArray<R> RotatorsToQuats(const TArray<Q>& RotatorsNestedArray)
{
TArray<R> BPQuatsNestedArray;
TArray<R> QuatsNestedBPArray;
for (const Q& RotatorsInnerArrayContainer: RotatorsNestedArray)
{
R BPQuatsInnerArrayContainer{RotatorsToQuats(RotatorsInnerArrayContainer.*InnerArray)};
BPQuatsNestedArray.Add(MoveTemp(BPQuatsInnerArrayContainer));
R QuatsInnerBPArrayContainer{RotatorsToQuats(RotatorsInnerArrayContainer.*InnerArray)};
QuatsNestedBPArray.Add(MoveTemp(QuatsInnerBPArrayContainer));
}
return MoveTemp(BPQuatsNestedArray);
return MoveTemp(QuatsNestedBPArray);
}
static TArray<float> FromMillimeters(const std::vector<float>& Vector);
static TArray<TArray<float>> FromMillimeters(const std::vector<std::vector<float>>& NestedVector);
static std::vector<float> ToMillimeters(const TArray<float>& Array);
static std::vector<std::vector<float>> ToMillimeters(const TArray<TArray<float>>& NestedArray);
template<typename S, TArray<float> S::*InnerArray>
static std::vector<std::vector<float>> ToMillimeters(const TArray<S>& NestedBPArray)
{
std::vector<std::vector<float>> NestedVector;
for (const S& InnerBPArrayContainer: NestedBPArray)
{
std::vector<float> InnerVector{ToMillimeters(InnerBPArrayContainer.*InnerArray)};
NestedVector.emplace_back(MoveTemp(InnerVector));
}
return MoveTemp(NestedVector);
}
public:
@@ -0,0 +1,66 @@
/**
* @file
*
* @author Mamadou Babaei <mamadou@senseglove.com>
*
* @section LICENSE
*
* (The MIT License)
*
* Copyright (c) 2020 - 2022 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 "Math/Vector.h"
class SENSEGLOVEUTILS_API FSGUnits final
{
public:
static FORCEINLINE constexpr float CentimetersToMillimetersMultiplier()
{
return 10.0f;
}
static FORCEINLINE constexpr float MillimetersToCentimetersMultiplier()
{
return 0.1f;
}
static FORCEINLINE float CentimetersToMillimeters(const float Value)
{
return Value * CentimetersToMillimetersMultiplier();
}
static FORCEINLINE float MillimetersToCentimeters(const float Value)
{
return Value * MillimetersToCentimetersMultiplier();
}
public:
FSGUnits() = delete;
virtual ~FSGUnits() = delete;
};