add the USGVirtualHandComponent::OnHandVisibilityChanged() event
This commit is contained in:
@@ -99,9 +99,9 @@ struct USGVirtualHandComponent::FImpl
|
||||
* Member variables
|
||||
************************/
|
||||
|
||||
FCollisionResponseContainer CachedCollisionResponse;
|
||||
ECollisionEnabled::Type CachedCollisionEnabled;
|
||||
bool bCachedGenerateOverlapEvents;
|
||||
ECollisionEnabled::Type CachedCollisionEnabled;
|
||||
FCollisionResponseContainer CachedCollisionResponse;
|
||||
|
||||
/************************
|
||||
* Owner object
|
||||
@@ -146,6 +146,8 @@ struct USGVirtualHandComponent::FImpl
|
||||
void UpdateVisibility();
|
||||
|
||||
void DrawDebugVirtualHand() const;
|
||||
|
||||
void TriggerHandVisibilityChangedEvent(bool bNewVisibility) const;
|
||||
};
|
||||
|
||||
const TArray<FName>& USGVirtualHandComponent::GetLeftHandBoneNames()
|
||||
@@ -240,6 +242,10 @@ USGVirtualHandComponent::USGVirtualHandComponent(const FObjectInitializer& Objec
|
||||
WristTracker = nullptr;
|
||||
}
|
||||
|
||||
void USGVirtualHandComponent::OnHandVisibilityChanged_Implementation(bool bNewVisibility)
|
||||
{
|
||||
}
|
||||
|
||||
void USGVirtualHandComponent::SetRight(const bool bInRight)
|
||||
{
|
||||
bRight = bInRight;
|
||||
@@ -470,8 +476,8 @@ FRotator USGVirtualHandComponent::GetHandBoneRefRotation(const int32 Joint) cons
|
||||
}
|
||||
|
||||
USGVirtualHandComponent::FImpl::FImpl(USGVirtualHandComponent* InOwner)
|
||||
: CachedCollisionEnabled(InOwner->GetCollisionEnabled()),
|
||||
bCachedGenerateOverlapEvents(InOwner->GetGenerateOverlapEvents()),
|
||||
: bCachedGenerateOverlapEvents(InOwner->GetGenerateOverlapEvents()),
|
||||
CachedCollisionEnabled(InOwner->GetCollisionEnabled()),
|
||||
Owner(InOwner)
|
||||
|
||||
{
|
||||
@@ -595,19 +601,19 @@ const FReferenceSkeleton& USGVirtualHandComponent::FImpl::GetRefSkeleton() const
|
||||
|
||||
void USGVirtualHandComponent::FImpl::DisableCollisionResponse()
|
||||
{
|
||||
bCachedGenerateOverlapEvents = Owner->GetGenerateOverlapEvents();
|
||||
CachedCollisionEnabled = Owner->GetCollisionEnabled();
|
||||
CachedCollisionResponse = Owner->GetCollisionResponseToChannels();
|
||||
bCachedGenerateOverlapEvents = Owner->GetGenerateOverlapEvents();
|
||||
Owner->SetCollisionResponseToAllChannels(ECR_Ignore);
|
||||
Owner->SetCollisionEnabled(ECollisionEnabled::NoCollision);
|
||||
Owner->SetGenerateOverlapEvents(false);
|
||||
Owner->SetCollisionEnabled(ECollisionEnabled::NoCollision);
|
||||
Owner->SetCollisionResponseToAllChannels(ECR_Ignore);
|
||||
}
|
||||
|
||||
void USGVirtualHandComponent::FImpl::RestoreCollisionResponse() const
|
||||
{
|
||||
Owner->SetCollisionResponseToChannels(CachedCollisionResponse);
|
||||
Owner->SetCollisionEnabled(CachedCollisionEnabled);
|
||||
Owner->SetGenerateOverlapEvents(bCachedGenerateOverlapEvents);
|
||||
Owner->SetCollisionEnabled(CachedCollisionEnabled);
|
||||
Owner->SetCollisionResponseToChannels(CachedCollisionResponse);
|
||||
}
|
||||
|
||||
void USGVirtualHandComponent::FImpl::SetVisibility(const bool bInVisible)
|
||||
@@ -622,6 +628,8 @@ void USGVirtualHandComponent::FImpl::SetVisibility(const bool bInVisible)
|
||||
{
|
||||
DisableCollisionResponse();
|
||||
}
|
||||
|
||||
TriggerHandVisibilityChangedEvent(bInVisible);
|
||||
}
|
||||
|
||||
void USGVirtualHandComponent::FImpl::UpdateVisibility()
|
||||
@@ -664,6 +672,12 @@ void USGVirtualHandComponent::FImpl::DrawDebugVirtualHand() const
|
||||
FSGDebugVirtualHand::Draw(World, MotionControllerData, Owner->DebugVirtualHandSettings);
|
||||
}
|
||||
|
||||
void USGVirtualHandComponent::FImpl::TriggerHandVisibilityChangedEvent(const bool bNewVisibility) const
|
||||
{
|
||||
Owner->HandVisibilityChangedEvent.Broadcast(bNewVisibility);
|
||||
Owner->OnHandVisibilityChanged(bNewVisibility);
|
||||
}
|
||||
|
||||
void USGVirtualHandComponent::FImplDeleter::operator()(const FImpl* P) const
|
||||
{
|
||||
delete P;
|
||||
|
||||
@@ -62,6 +62,17 @@ class SENSEGLOVE_API USGVirtualHandComponent : public USkeletalMeshComponent
|
||||
{
|
||||
GENERATED_UCLASS_BODY()
|
||||
|
||||
public:
|
||||
DECLARE_EVENT_OneParam(USGVirtualHandComponent, FHandVisibilityChangedEvent, bool bNewVisibiliy);
|
||||
|
||||
FHandVisibilityChangedEvent& OnHandVisibilityChanged()
|
||||
{
|
||||
return HandVisibilityChangedEvent;
|
||||
};
|
||||
|
||||
private:
|
||||
FHandVisibilityChangedEvent HandVisibilityChangedEvent;
|
||||
|
||||
public:
|
||||
static const TArray<FName>& GetLeftHandBoneNames();
|
||||
static const TArray<FName>& GetRightHandBoneNames();
|
||||
@@ -136,6 +147,10 @@ private:
|
||||
UPROPERTY(Transient)
|
||||
USGWristTrackerComponent* WristTracker;
|
||||
|
||||
protected:
|
||||
UFUNCTION(BlueprintNativeEvent, Category="SenseGlove | Components | Virtual Hand Component")
|
||||
void OnHandVisibilityChanged(bool bNewVisibility);
|
||||
|
||||
public:
|
||||
FORCEINLINE bool IsLeft() const
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user