add a temporary workaround for the android crashes and the hidden if glove not found functionality
This commit is contained in:
@@ -41,8 +41,11 @@
|
|||||||
#include "UObject/ConstructorHelpers.h"
|
#include "UObject/ConstructorHelpers.h"
|
||||||
|
|
||||||
#include "SenseGlove/Animation/SGVirtualHandAnimInstance.h"
|
#include "SenseGlove/Animation/SGVirtualHandAnimInstance.h"
|
||||||
|
#include "SGConnect/SGConnect.h"
|
||||||
|
#include "SGCore/SGDeviceList.h"
|
||||||
#include "SGCore/SGHandPose.h"
|
#include "SGCore/SGHandPose.h"
|
||||||
#include "SGCore/SGHapticGlove.h"
|
#include "SGCore/SGHapticGlove.h"
|
||||||
|
#include "SGCore/SGHapticGloveHandProfiles.h"
|
||||||
#include "SGLog/SGLog.h"
|
#include "SGLog/SGLog.h"
|
||||||
|
|
||||||
struct USGVirtualHandComponent::FImpl
|
struct USGVirtualHandComponent::FImpl
|
||||||
@@ -115,6 +118,8 @@ struct USGVirtualHandComponent::FImpl
|
|||||||
const FReferenceSkeleton& GetRefSkeleton() const;
|
const FReferenceSkeleton& GetRefSkeleton() const;
|
||||||
|
|
||||||
bool CheckGlove() const;
|
bool CheckGlove() const;
|
||||||
|
|
||||||
|
void SetVisibility(bool bVisible) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
const TArray<TArray<FName>>& USGVirtualHandComponent::GetLeftHandFingerBoneNames()
|
const TArray<TArray<FName>>& USGVirtualHandComponent::GetLeftHandFingerBoneNames()
|
||||||
@@ -203,6 +208,7 @@ USGVirtualHandComponent::USGVirtualHandComponent(const FObjectInitializer& Objec
|
|||||||
TEXT("Failed to load the skeletal mesh: '%s'"), *SkeletalMeshPath);
|
TEXT("Failed to load the skeletal mesh: '%s'"), *SkeletalMeshPath);
|
||||||
Super::SetSkeletalMesh(SkeletalMesh.Object, true);
|
Super::SetSkeletalMesh(SkeletalMesh.Object, true);
|
||||||
|
|
||||||
|
bSGConnectInitialized = false;
|
||||||
Glove = nullptr;
|
Glove = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -252,6 +258,8 @@ void USGVirtualHandComponent::InitializeComponent()
|
|||||||
{
|
{
|
||||||
Pimpl->SetDefaultMesh();
|
Pimpl->SetDefaultMesh();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
(void) Pimpl->CheckGlove();
|
||||||
}
|
}
|
||||||
|
|
||||||
void USGVirtualHandComponent::TickComponent(
|
void USGVirtualHandComponent::TickComponent(
|
||||||
@@ -270,6 +278,13 @@ void USGVirtualHandComponent::TickComponent(
|
|||||||
(void) Pimpl->CheckGlove();
|
(void) Pimpl->CheckGlove();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void USGVirtualHandComponent::BeginPlay()
|
||||||
|
{
|
||||||
|
Super::BeginPlay();
|
||||||
|
|
||||||
|
(void) Pimpl->CheckGlove();
|
||||||
|
}
|
||||||
|
|
||||||
void USGVirtualHandComponent::SetSkeletalMesh(USkeletalMesh* NewMesh, const bool bReinitPose)
|
void USGVirtualHandComponent::SetSkeletalMesh(USkeletalMesh* NewMesh, const bool bReinitPose)
|
||||||
{
|
{
|
||||||
if (IsValid(NewMesh))
|
if (IsValid(NewMesh))
|
||||||
@@ -481,6 +496,24 @@ const FReferenceSkeleton& USGVirtualHandComponent::FImpl::GetRefSkeleton() const
|
|||||||
|
|
||||||
bool USGVirtualHandComponent::FImpl::CheckGlove() const
|
bool USGVirtualHandComponent::FImpl::CheckGlove() const
|
||||||
{
|
{
|
||||||
|
if (!Owner->bSGConnectInitialized)
|
||||||
|
{
|
||||||
|
// Ensure the device list is empty before doing anything.
|
||||||
|
FSGDeviceList::Dispose();
|
||||||
|
FSGDeviceList::Reinitialize();
|
||||||
|
|
||||||
|
// Load the latest hand profiles.
|
||||||
|
FSGHapticGloveHandProfiles::TryLoadingFromDisk();
|
||||||
|
|
||||||
|
const int32_t Result = FSGConnect::Init();
|
||||||
|
if (Result != 1)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
Owner->bSGConnectInitialized = true;
|
||||||
|
}
|
||||||
|
|
||||||
const bool bGloveWasPresent = IsValid(Owner->Glove);
|
const bool bGloveWasPresent = IsValid(Owner->Glove);
|
||||||
const bool bFoundGlove = USGHapticGlove::GetGlove(Owner, Owner->IsRight(), Owner->Glove);
|
const bool bFoundGlove = USGHapticGlove::GetGlove(Owner, Owner->IsRight(), Owner->Glove);
|
||||||
|
|
||||||
@@ -490,9 +523,20 @@ bool USGVirtualHandComponent::FImpl::CheckGlove() const
|
|||||||
(Owner->bRight ? TEXT("right-handed") : TEXT("left-handed"))));
|
(Owner->bRight ? TEXT("right-handed") : TEXT("left-handed"))));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!IsEditor() && Owner->IsVisible() != bFoundGlove)
|
||||||
|
{
|
||||||
|
SetVisibility(bFoundGlove);
|
||||||
|
}
|
||||||
|
|
||||||
return bFoundGlove;
|
return bFoundGlove;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void USGVirtualHandComponent::FImpl::SetVisibility(const bool bVisible) const
|
||||||
|
{
|
||||||
|
Owner->SetVisibility(bVisible, true);
|
||||||
|
Owner->SetHiddenInGame(!bVisible, false);
|
||||||
|
}
|
||||||
|
|
||||||
void USGVirtualHandComponent::FImplDeleter::operator()(const FImpl* P) const
|
void USGVirtualHandComponent::FImplDeleter::operator()(const FImpl* P) const
|
||||||
{
|
{
|
||||||
delete P;
|
delete P;
|
||||||
|
|||||||
@@ -86,6 +86,9 @@ private:
|
|||||||
uint8 bHiddenInGameIfNoGloveDetected : 1;
|
uint8 bHiddenInGameIfNoGloveDetected : 1;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
UPROPERTY(Transient)
|
||||||
|
uint8 bSGConnectInitialized : 1;
|
||||||
|
|
||||||
UPROPERTY(Transient)
|
UPROPERTY(Transient)
|
||||||
USGHapticGlove* Glove;
|
USGHapticGlove* Glove;
|
||||||
|
|
||||||
@@ -125,6 +128,8 @@ public:
|
|||||||
enum ELevelTick TickType,
|
enum ELevelTick TickType,
|
||||||
FActorComponentTickFunction* ThisTickFunction) override;
|
FActorComponentTickFunction* ThisTickFunction) override;
|
||||||
|
|
||||||
|
virtual void BeginPlay() override;
|
||||||
|
|
||||||
virtual void SetSkeletalMesh(USkeletalMesh* NewMesh, bool bReinitPose = true) override;
|
virtual void SetSkeletalMesh(USkeletalMesh* NewMesh, bool bReinitPose = true) override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|||||||
Reference in New Issue
Block a user