208 lines
8.2 KiB
C++
208 lines
8.2 KiB
C++
/**
|
|
* @file
|
|
*
|
|
* @author Mamadou Babaei <mamadou@senseglove.com>
|
|
*
|
|
* @section LICENSE
|
|
*
|
|
* (The MIT License)
|
|
*
|
|
* Copyright (c) 2020 - 2023 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 "SGCore/SGNovaGloveHandProfile.h"
|
|
|
|
#include "Runtime/Launch/Resources/Version.h"
|
|
|
|
#include "SGCore/SGHandInterpolator.h"
|
|
#include "SGCoreImpl/SGExportedFunctions.h"
|
|
#include "SGCoreImpl/SGNovaGloveHandProfileImpl.h"
|
|
#include "SGInterop/SGIC_FSGHandInterpolatorImpl.h"
|
|
#include "SGInterop/SGIC_FSGNovaGloveHandProfileImpl.h"
|
|
#include "SGInterop/SGIC_FString.h"
|
|
|
|
struct USGNovaGloveHandProfile::FImpl
|
|
{
|
|
/************************
|
|
* Member variables
|
|
************************/
|
|
|
|
FSGNovaGloveHandProfileImpl NovaGloveHandProfileImpl;
|
|
|
|
/************************
|
|
* Owner object
|
|
************************/
|
|
|
|
USGNovaGloveHandProfile* Owner;
|
|
|
|
/************************
|
|
* Constructor / Destructor
|
|
************************/
|
|
|
|
explicit FImpl(USGNovaGloveHandProfile* InOwner);
|
|
~FImpl();
|
|
|
|
/************************
|
|
* Default copy constructor & copy assignment operator
|
|
************************/
|
|
|
|
FImpl(const FImpl& Rhs) = default;
|
|
FImpl& operator=(const FImpl& Rhs) = default;
|
|
};
|
|
|
|
USGNovaGloveHandProfile* USGNovaGloveHandProfile::NewNovaGloveHandProfile(
|
|
UObject* Outer, const FSGNovaGloveHandProfileImpl& NovaGloveHandProfileImpl)
|
|
{
|
|
USGNovaGloveHandProfile* Instance = NewObject<USGNovaGloveHandProfile>(Outer);
|
|
Instance->SetNovaGloveHandProfileImpl(NovaGloveHandProfileImpl);
|
|
return Instance;
|
|
}
|
|
|
|
USGNovaGloveHandProfile* USGNovaGloveHandProfile::NewNovaGloveHandProfile(UObject* Outer)
|
|
{
|
|
FSGIC_FSGNovaGloveHandProfileImpl OutNovaGloveHandProfileImplContainer;
|
|
SGCoreImpl_FSGNovaGloveHandProfileImpl_ctor(&OutNovaGloveHandProfileImplContainer);
|
|
|
|
return NewNovaGloveHandProfile(Outer, MoveTemp(OutNovaGloveHandProfileImplContainer.NovaGloveHandProfileImpl));
|
|
}
|
|
|
|
USGNovaGloveHandProfile* USGNovaGloveHandProfile::NewNovaGloveHandProfile(
|
|
UObject* Outer, const bool bRightHanded, const USGHandInterpolator* Interpolator)
|
|
{
|
|
FSGIC_FSGNovaGloveHandProfileImpl OutNovaGloveHandProfileImplContainer;
|
|
FSGIC_FSGHandInterpolatorImpl InterpolatorContainer{Interpolator->ToHandInterpolatorImpl()};
|
|
SGCoreImpl_FSGNovaGloveHandProfileImpl_ctor_bRightHanded_Interpolator(
|
|
&OutNovaGloveHandProfileImplContainer, bRightHanded, &InterpolatorContainer);
|
|
|
|
return NewNovaGloveHandProfile(Outer, MoveTemp(OutNovaGloveHandProfileImplContainer.NovaGloveHandProfileImpl));
|
|
}
|
|
|
|
USGNovaGloveHandProfile* USGNovaGloveHandProfile::Default(UObject* Outer, const bool bRightHanded)
|
|
{
|
|
FSGIC_FSGNovaGloveHandProfileImpl OutNovaGloveHandProfileImplContainer;
|
|
SGCoreImpl_FSGNovaGloveHandProfileImpl_Default(&OutNovaGloveHandProfileImplContainer, bRightHanded);
|
|
|
|
return NewNovaGloveHandProfile(Outer, MoveTemp(OutNovaGloveHandProfileImplContainer.NovaGloveHandProfileImpl));
|
|
}
|
|
|
|
USGNovaGloveHandProfile* USGNovaGloveHandProfile::Deserialize(UObject* Outer, const FString& SerializedString)
|
|
{
|
|
FSGIC_FSGNovaGloveHandProfileImpl OutNovaGloveHandProfileImplContainer;
|
|
FSGIC_FString SerializedStringContainer{SerializedString};
|
|
SGCoreImpl_FSGNovaGloveHandProfileImpl_Deserialize(&OutNovaGloveHandProfileImplContainer,
|
|
&SerializedStringContainer);
|
|
|
|
return NewNovaGloveHandProfile(Outer, MoveTemp(OutNovaGloveHandProfileImplContainer.NovaGloveHandProfileImpl));
|
|
}
|
|
|
|
USGNovaGloveHandProfile::USGNovaGloveHandProfile()
|
|
: Pimpl(TUniquePtr<FImpl, FImplDeleter>(new FImpl{this}, PimplDeleter))
|
|
{
|
|
FSGIC_FSGNovaGloveHandProfileImpl OutNovaGloveHandProfileImplContainer;
|
|
SGCoreImpl_FSGNovaGloveHandProfileImpl_ctor(&OutNovaGloveHandProfileImplContainer);
|
|
|
|
Pimpl->NovaGloveHandProfileImpl = MoveTemp(OutNovaGloveHandProfileImplContainer.NovaGloveHandProfileImpl);
|
|
}
|
|
|
|
USGNovaGloveHandProfile::USGNovaGloveHandProfile(const bool bRightHanded, const USGHandInterpolator* Interpolator)
|
|
: Pimpl(TUniquePtr<FImpl, FImplDeleter>(new FImpl{this}, PimplDeleter))
|
|
{
|
|
FSGIC_FSGNovaGloveHandProfileImpl OutNovaGloveHandProfileImplContainer;
|
|
FSGIC_FSGHandInterpolatorImpl InterpolatorContainer{Interpolator->ToHandInterpolatorImpl()};
|
|
SGCoreImpl_FSGNovaGloveHandProfileImpl_ctor_bRightHanded_Interpolator(
|
|
&OutNovaGloveHandProfileImplContainer, bRightHanded, &InterpolatorContainer);
|
|
|
|
Pimpl->NovaGloveHandProfileImpl = MoveTemp(OutNovaGloveHandProfileImplContainer.NovaGloveHandProfileImpl);
|
|
}
|
|
|
|
USGNovaGloveHandProfile::USGNovaGloveHandProfile(const FSGNovaGloveHandProfileImpl& NovaGloveHandProfileImpl)
|
|
: Pimpl(TUniquePtr<FImpl, FImplDeleter>(new FImpl{this}, PimplDeleter))
|
|
{
|
|
SetNovaGloveHandProfileImpl(NovaGloveHandProfileImpl);
|
|
}
|
|
|
|
USGNovaGloveHandProfile::~USGNovaGloveHandProfile() = default;
|
|
|
|
void USGNovaGloveHandProfile::SetNovaGloveHandProfileImpl(const FSGNovaGloveHandProfileImpl& NovaGloveHandProfileImpl)
|
|
{
|
|
FSGIC_FSGNovaGloveHandProfileImpl OutNovaGloveHandProfileContainer;
|
|
FSGIC_FSGNovaGloveHandProfileImpl RhsContainer{NovaGloveHandProfileImpl};
|
|
SGCoreImpl_FSGNovaGloveHandProfileImpl_ctor_copy(&OutNovaGloveHandProfileContainer, &RhsContainer);
|
|
Pimpl->NovaGloveHandProfileImpl = MoveTemp(OutNovaGloveHandProfileContainer.NovaGloveHandProfileImpl);
|
|
}
|
|
|
|
const FSGNovaGloveHandProfileImpl& USGNovaGloveHandProfile::ToNovaGloveHandProfileImpl() const
|
|
{
|
|
return Pimpl->NovaGloveHandProfileImpl;
|
|
}
|
|
|
|
bool USGNovaGloveHandProfile::IsRight() const
|
|
{
|
|
FSGIC_FSGNovaGloveHandProfileImpl InstanceContainer{ToNovaGloveHandProfileImpl()};
|
|
return SGCoreImpl_FSGNovaGloveHandProfileImpl_IsRight(&InstanceContainer);
|
|
}
|
|
|
|
USGHandInterpolator* USGNovaGloveHandProfile::GetInterpolationSet(UObject* Outer) const
|
|
{
|
|
FSGIC_FSGNovaGloveHandProfileImpl InstanceContainer{ToNovaGloveHandProfileImpl()};
|
|
FSGIC_FSGHandInterpolatorImpl OutSetContainer;
|
|
SGCoreImpl_FSGNovaGloveHandProfileImpl_GetInterpolationSet(&InstanceContainer, &OutSetContainer);
|
|
|
|
return USGHandInterpolator::NewHandInterpolator(Outer, MoveTemp(OutSetContainer.HandInterpolatorImpl));
|
|
}
|
|
|
|
bool USGNovaGloveHandProfile::Equals(const USGNovaGloveHandProfile* NovaGloveHandProfile) const
|
|
{
|
|
FSGIC_FSGNovaGloveHandProfileImpl InstanceContainer{ToNovaGloveHandProfileImpl()};
|
|
FSGIC_FSGNovaGloveHandProfileImpl NovaGloveHandProfileContainer{NovaGloveHandProfile->ToNovaGloveHandProfileImpl()};
|
|
return SGCoreImpl_FSGNovaGloveHandProfileImpl_Equals(&InstanceContainer, &NovaGloveHandProfileContainer);
|
|
}
|
|
|
|
void USGNovaGloveHandProfile::Reset()
|
|
{
|
|
FSGIC_FSGNovaGloveHandProfileImpl InstanceContainer{ToNovaGloveHandProfileImpl()};
|
|
SGCoreImpl_FSGNovaGloveHandProfileImpl_Reset(&InstanceContainer);
|
|
}
|
|
|
|
FString USGNovaGloveHandProfile::SGSerialize() const
|
|
{
|
|
FSGIC_FSGNovaGloveHandProfileImpl InstanceContainer{ToNovaGloveHandProfileImpl()};
|
|
FSGIC_FString OutStringContainer;
|
|
SGCoreImpl_FSGNovaGloveHandProfileImpl_Serialize(&InstanceContainer, &OutStringContainer);
|
|
return MoveTemp(OutStringContainer.String);
|
|
}
|
|
|
|
USGNovaGloveHandProfile::FImpl::FImpl(USGNovaGloveHandProfile* InOwner)
|
|
: Owner(InOwner)
|
|
{
|
|
}
|
|
|
|
USGNovaGloveHandProfile::FImpl::~FImpl() = default;
|
|
|
|
void USGNovaGloveHandProfile::FImplDeleter::operator()(const FImpl* P) const
|
|
{
|
|
delete P;
|
|
} |