initial public release
This commit is contained in:
@@ -0,0 +1,262 @@
|
||||
/**
|
||||
* @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 "SGCoreImpl/SGSenseGloveHandProfileImpl.h"
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "Containers/StringConv.h"
|
||||
#include "Runtime/Launch/Resources/Version.h"
|
||||
|
||||
#include "SGBuildHacks/SGInclude_Core_HandInterpolator.h"
|
||||
#include "SGBuildHacks/SGInclude_Core_Quat.h"
|
||||
#include "SGBuildHacks/SGInclude_Core_Vect3D.h"
|
||||
#include "SGCoreImpl/SGCoreEnumCast.h"
|
||||
#include "SGCoreImpl/SGHandInterpolatorImpl.h"
|
||||
#include "SGCoreImpl/SGVect3DImpl.h"
|
||||
#include "SGUtils/SGArrayUtils.h"
|
||||
|
||||
struct FSGSenseGloveHandProfileImpl::FImpl
|
||||
{
|
||||
/************************
|
||||
* Member variables
|
||||
************************/
|
||||
|
||||
FSenseGloveHandProfileType SenseGloveHandProfile;
|
||||
|
||||
/************************
|
||||
* Owner object
|
||||
************************/
|
||||
|
||||
FSGSenseGloveHandProfileImpl* Owner;
|
||||
|
||||
/************************
|
||||
* Constructor / Destructor
|
||||
************************/
|
||||
|
||||
explicit FImpl(FSGSenseGloveHandProfileImpl* InOwner);
|
||||
~FImpl();
|
||||
|
||||
/************************
|
||||
* Default copy constructor & copy assignment operator
|
||||
************************/
|
||||
|
||||
FImpl(const FImpl& Rhs) = default;
|
||||
FImpl& operator=(const FImpl& Rhs) = default;
|
||||
};
|
||||
|
||||
FSGSenseGloveHandProfileImpl FSGSenseGloveHandProfileImpl::Default(const bool bRightHanded)
|
||||
{
|
||||
FSGSenseGloveHandProfileImpl SenseGloveHandProfileImpl(FSenseGloveHandProfileType::Default(bRightHanded));
|
||||
return SenseGloveHandProfileImpl;
|
||||
}
|
||||
|
||||
FSGSenseGloveHandProfileImpl FSGSenseGloveHandProfileImpl::Deserialize(const FString& SerializedString)
|
||||
{
|
||||
std::string Serialized(TCHAR_TO_UTF8(*SerializedString));
|
||||
const FSGSenseGloveHandProfileImpl HandProfile(FSenseGloveHandProfileType::Deserialize(MoveTemp(Serialized)));
|
||||
return HandProfile;
|
||||
}
|
||||
|
||||
const FVector& FSGSenseGloveHandProfileImpl::GetDefaultThimbleOffset()
|
||||
{
|
||||
static const FVector DefaultThimbleOffset(
|
||||
FSGVect3DImpl(FSenseGloveHandProfileType::GetDefaultThimbleOffset()).ToFVector());
|
||||
return DefaultThimbleOffset;
|
||||
}
|
||||
|
||||
FSGSenseGloveHandProfileImpl::FSGSenseGloveHandProfileImpl()
|
||||
:
|
||||
#if ENGINE_MAJOR_VERSION == 5 || ( ENGINE_MAJOR_VERSION == 4 && ENGINE_MINOR_VERSION > 22 )
|
||||
Pimpl(TUniquePtr<FImpl, FImplDeleter>(new FImpl{this}, PimplDeleter))
|
||||
#else
|
||||
Pimpl(TUniquePtr<FImpl, FImplDeleter>(new FImpl{this}))
|
||||
#endif /* ENGINE_MAJOR_VERSION == 5 || ( ENGINE_MAJOR_VERSION == 4 && ENGINE_MINOR_VERSION > 22 ) */
|
||||
{
|
||||
}
|
||||
|
||||
FSGSenseGloveHandProfileImpl::FSGSenseGloveHandProfileImpl(const bool bRightHanded,
|
||||
const FSGHandInterpolatorImpl& Interpolator,
|
||||
const ESGThumbSolver ThumbSolver,
|
||||
const ESGFingerSolver FingerSolver,
|
||||
const TArray<FVector>& FingerThimbleOffset)
|
||||
:
|
||||
#if ENGINE_MAJOR_VERSION == 5 || ( ENGINE_MAJOR_VERSION == 4 && ENGINE_MINOR_VERSION > 22 )
|
||||
Pimpl(TUniquePtr<FImpl, FImplDeleter>(new FImpl{this}, PimplDeleter))
|
||||
#else
|
||||
Pimpl(TUniquePtr<FImpl, FImplDeleter>(new FImpl{this}))
|
||||
#endif /* ENGINE_MAJOR_VERSION == 5 || ( ENGINE_MAJOR_VERSION == 4 && ENGINE_MINOR_VERSION > 22 ) */
|
||||
{
|
||||
std::vector<FSGVect3DImpl::FVect3DType> FingerThimbleOffsetVector{
|
||||
FSGArrayUtils::ToStdVector<FVector, FSGVect3DImpl::FVect3DType, FSGVect3DImpl, &FSGVect3DImpl::ToVect3D>(
|
||||
FingerThimbleOffset)
|
||||
};
|
||||
Pimpl->SenseGloveHandProfile = FSenseGloveHandProfileType(
|
||||
bRightHanded, Interpolator.ToHandInterpolator(),
|
||||
FSGCoreEnumCast::ToEThumbSolver(ThumbSolver),
|
||||
FSGCoreEnumCast::ToEFingerSolver(FingerSolver),
|
||||
MoveTemp(FingerThimbleOffsetVector));
|
||||
}
|
||||
|
||||
FSGSenseGloveHandProfileImpl::FSGSenseGloveHandProfileImpl(const FSenseGloveHandProfileType& SenseGloveHandProfile)
|
||||
:
|
||||
#if ENGINE_MAJOR_VERSION == 5 || ( ENGINE_MAJOR_VERSION == 4 && ENGINE_MINOR_VERSION > 22 )
|
||||
Pimpl(TUniquePtr<FImpl, FImplDeleter>(new FImpl{this}, PimplDeleter))
|
||||
#else
|
||||
Pimpl(TUniquePtr<FImpl, FImplDeleter>(new FImpl{this}))
|
||||
#endif /* ENGINE_MAJOR_VERSION == 5 || ( ENGINE_MAJOR_VERSION == 4 && ENGINE_MINOR_VERSION > 22 ) */
|
||||
{
|
||||
Pimpl->SenseGloveHandProfile = SenseGloveHandProfile;
|
||||
}
|
||||
|
||||
FSGSenseGloveHandProfileImpl::FSGSenseGloveHandProfileImpl(const FSGSenseGloveHandProfileImpl& Rhs)
|
||||
:
|
||||
#if ENGINE_MAJOR_VERSION == 5 || ( ENGINE_MAJOR_VERSION == 4 && ENGINE_MINOR_VERSION > 22 )
|
||||
Pimpl(TUniquePtr<FImpl, FImplDeleter>(new FImpl{*Rhs.Pimpl}, PimplDeleter))
|
||||
#else
|
||||
Pimpl(TUniquePtr<FImpl, FImplDeleter>(new FImpl{*Rhs.Pimpl}))
|
||||
#endif /* ENGINE_MAJOR_VERSION == 5 || ( ENGINE_MAJOR_VERSION == 4 && ENGINE_MINOR_VERSION > 22 ) */
|
||||
{
|
||||
Pimpl->Owner = this;
|
||||
}
|
||||
|
||||
FSGSenseGloveHandProfileImpl::FSGSenseGloveHandProfileImpl(FSGSenseGloveHandProfileImpl&& Rhs) noexcept = default;
|
||||
|
||||
FSGSenseGloveHandProfileImpl::~FSGSenseGloveHandProfileImpl() = default;
|
||||
|
||||
FSGSenseGloveHandProfileImpl& FSGSenseGloveHandProfileImpl::operator=(const FSGSenseGloveHandProfileImpl& Rhs)
|
||||
{
|
||||
*Pimpl = *Rhs.Pimpl;
|
||||
Pimpl->Owner = this;
|
||||
return *this;
|
||||
}
|
||||
|
||||
FSGSenseGloveHandProfileImpl& FSGSenseGloveHandProfileImpl::operator=(FSGSenseGloveHandProfileImpl&& Rhs) noexcept
|
||||
= default;
|
||||
|
||||
const FSGSenseGloveHandProfileImpl::FSenseGloveHandProfileType& FSGSenseGloveHandProfileImpl::ToSenseGloveHandProfile(
|
||||
) const
|
||||
{
|
||||
return Pimpl->SenseGloveHandProfile;
|
||||
}
|
||||
|
||||
bool FSGSenseGloveHandProfileImpl::IsRight() const
|
||||
{
|
||||
return Pimpl->SenseGloveHandProfile.IsRight();
|
||||
}
|
||||
|
||||
void FSGSenseGloveHandProfileImpl::SetIsRight(const bool bRightHanded)
|
||||
{
|
||||
Pimpl->SenseGloveHandProfile.SetIsRight(bRightHanded);
|
||||
}
|
||||
|
||||
FSGHandInterpolatorImpl FSGSenseGloveHandProfileImpl::GetInterpolationSet() const
|
||||
{
|
||||
const FSGHandInterpolatorImpl HandInterpolatorImpl(
|
||||
FSGHandInterpolatorImpl::FHandInterpolatorType(Pimpl->SenseGloveHandProfile.GetInterpolationSet()));
|
||||
return HandInterpolatorImpl;
|
||||
}
|
||||
|
||||
void FSGSenseGloveHandProfileImpl::SetInterpolationSet(const FSGHandInterpolatorImpl& InterpolationSet)
|
||||
{
|
||||
Pimpl->SenseGloveHandProfile.SetInterpolationSet(InterpolationSet.ToHandInterpolator());
|
||||
}
|
||||
|
||||
ESGThumbSolver FSGSenseGloveHandProfileImpl::GetThumbSolver() const
|
||||
{
|
||||
return FSGCoreEnumCast::ToESGThumbSolver(Pimpl->SenseGloveHandProfile.GetThumbSolver());
|
||||
}
|
||||
|
||||
void FSGSenseGloveHandProfileImpl::SetThumbSolver(const ESGThumbSolver ThumbSolver)
|
||||
{
|
||||
Pimpl->SenseGloveHandProfile.SetThumbSolver(FSGCoreEnumCast::ToEThumbSolver(ThumbSolver));
|
||||
}
|
||||
|
||||
ESGFingerSolver FSGSenseGloveHandProfileImpl::GetFingerSolver() const
|
||||
{
|
||||
return FSGCoreEnumCast::ToESGFingerSolver(Pimpl->SenseGloveHandProfile.GetFingerSolver());
|
||||
}
|
||||
|
||||
void FSGSenseGloveHandProfileImpl::SetFingerSolver(const ESGFingerSolver FingerSolver)
|
||||
{
|
||||
Pimpl->SenseGloveHandProfile.SetFingerSolver(FSGCoreEnumCast::ToEFingerSolver(FingerSolver));
|
||||
}
|
||||
|
||||
TArray<FVector> FSGSenseGloveHandProfileImpl::GetFingerThimbleOffset() const
|
||||
{
|
||||
const TArray<FVector> FingerThimbleOffset{
|
||||
FSGArrayUtils::FromStdVector<FSGVect3DImpl::FVect3DType, FVector, FSGVect3DImpl, &FSGVect3DImpl::ToFVector>(
|
||||
Pimpl->SenseGloveHandProfile.GetFingerThimbleOffset())
|
||||
};
|
||||
return FingerThimbleOffset;
|
||||
}
|
||||
|
||||
void FSGSenseGloveHandProfileImpl::SetFingerThimbleOffset(const TArray<FVector>& FingerThimbleOffset)
|
||||
{
|
||||
std::vector<FSGVect3DImpl::FVect3DType> FingerThimbleOffsetVector{
|
||||
FSGArrayUtils::ToStdVector<FVector, FSGVect3DImpl::FVect3DType, FSGVect3DImpl, &FSGVect3DImpl::ToVect3D>(
|
||||
FingerThimbleOffset)
|
||||
};
|
||||
Pimpl->SenseGloveHandProfile.SetFingerThimbleOffset(MoveTemp(FingerThimbleOffsetVector));
|
||||
}
|
||||
|
||||
bool FSGSenseGloveHandProfileImpl::Equals(const FSGSenseGloveHandProfileImpl& SenseGloveHandProfileImpl) const
|
||||
{
|
||||
return Pimpl->SenseGloveHandProfile.Equals(SenseGloveHandProfileImpl.ToSenseGloveHandProfile());
|
||||
}
|
||||
|
||||
void FSGSenseGloveHandProfileImpl::Reset()
|
||||
{
|
||||
Pimpl->SenseGloveHandProfile.Reset();
|
||||
}
|
||||
|
||||
FString FSGSenseGloveHandProfileImpl::Serialize() const
|
||||
{
|
||||
const FString Serialized(UTF8_TO_TCHAR(Pimpl->SenseGloveHandProfile.Serialize().c_str()));
|
||||
return Serialized;
|
||||
}
|
||||
|
||||
FSGSenseGloveHandProfileImpl::FImpl::FImpl(FSGSenseGloveHandProfileImpl* InOwner)
|
||||
: Owner(InOwner)
|
||||
{
|
||||
}
|
||||
|
||||
FSGSenseGloveHandProfileImpl::FImpl::~FImpl() = default;
|
||||
|
||||
void FSGSenseGloveHandProfileImpl::FImplDeleter::operator()(const FImpl* P) const
|
||||
{
|
||||
delete P;
|
||||
}
|
||||
Reference in New Issue
Block a user