only instantiate the connected glove once instead of recreating and destroying it every frame
This commit is contained in:
@@ -598,13 +598,18 @@ bool USGVirtualHandComponent::FImpl::CheckGlove() const
|
||||
}
|
||||
}
|
||||
|
||||
const bool bGloveWasPresent = IsValid(Owner->Glove);
|
||||
const bool bFoundGlove = USGHapticGlove::GetGlove(Owner, Owner->IsRight(), Owner->Glove);
|
||||
|
||||
if (!bFoundGlove && bGloveWasPresent)
|
||||
bool bGloveConnected;
|
||||
if (!IsValid(Owner->Glove) || !Owner->Glove->IsConnected())
|
||||
{
|
||||
SGLOG_ERROR(FString::Printf(TEXT("Could not find a %s glove!"),
|
||||
(Owner->IsRight() ? TEXT("right-handed") : TEXT("left-handed"))));
|
||||
bGloveConnected = USGHapticGlove::GetGlove(Owner, Owner->IsRight(), Owner->Glove);
|
||||
if (!bGloveConnected)
|
||||
{
|
||||
Owner->Glove = nullptr;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
bGloveConnected = true;
|
||||
}
|
||||
|
||||
const bool bIsEditor = IsEditor();
|
||||
@@ -613,7 +618,7 @@ bool USGVirtualHandComponent::FImpl::CheckGlove() const
|
||||
const bool bIsVisible = Owner->IsVisible();
|
||||
if (Owner->bHiddenInGameIfNoGloveDetected)
|
||||
{
|
||||
if (bFoundGlove)
|
||||
if (bGloveConnected)
|
||||
{
|
||||
if (!bIsVisible)
|
||||
{
|
||||
@@ -637,7 +642,7 @@ bool USGVirtualHandComponent::FImpl::CheckGlove() const
|
||||
}
|
||||
}
|
||||
|
||||
return bFoundGlove;
|
||||
return bGloveConnected;
|
||||
}
|
||||
|
||||
void USGVirtualHandComponent::FImpl::DrawDebugVirtualHand() const
|
||||
|
||||
@@ -250,21 +250,22 @@ bool USGWristTrackerComponent::FImpl::CheckGlove() const
|
||||
}
|
||||
}
|
||||
|
||||
const bool bGloveWasPresent = IsValid(Owner->Glove);
|
||||
const bool bFoundGlove = USGHapticGlove::GetGlove(Owner, Owner->IsRight(), Owner->Glove);
|
||||
|
||||
if (!bFoundGlove && bGloveWasPresent)
|
||||
bool bGloveConnected;
|
||||
if (!IsValid(Owner->Glove) || !Owner->Glove->IsConnected())
|
||||
{
|
||||
SGLOG_ERROR(FString::Printf(TEXT("Could not find a %s glove!"),
|
||||
(Owner->IsRight() ? TEXT("right-handed") : TEXT("left-handed"))));
|
||||
bGloveConnected = USGHapticGlove::GetGlove(Owner, Owner->IsRight(), Owner->Glove);
|
||||
if (!bGloveConnected)
|
||||
{
|
||||
Owner->Glove = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
if (bFoundGlove)
|
||||
else
|
||||
{
|
||||
bGloveConnected = true;
|
||||
UpdateWristTrackingData();
|
||||
}
|
||||
|
||||
return bFoundGlove;
|
||||
return bGloveConnected;
|
||||
}
|
||||
|
||||
void USGWristTrackerComponent::FImpl::UpdateMotionSource() const
|
||||
|
||||
Reference in New Issue
Block a user