consider millimeters/centimeters conversion, introduce units, and minor array utils refactoring
This commit is contained in:
@@ -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;
|
||||
};
|
||||
Reference in New Issue
Block a user