cache all overlapped actors with the real/virtual hands
This commit is contained in:
@@ -53,13 +53,6 @@ struct ASGPawn::FImpl
|
|||||||
* Static methods
|
* Static methods
|
||||||
************************/
|
************************/
|
||||||
|
|
||||||
/************************
|
|
||||||
* Member variables
|
|
||||||
************************/
|
|
||||||
|
|
||||||
bool bUpdateLeftHandLocationAndRotation;
|
|
||||||
bool bUpdateRightHandLocationAndRotation;
|
|
||||||
|
|
||||||
/************************
|
/************************
|
||||||
* Owner object
|
* Owner object
|
||||||
************************/
|
************************/
|
||||||
@@ -110,6 +103,15 @@ struct ASGPawn::FImpl
|
|||||||
void UpdateRightHandLocationAndRotation(
|
void UpdateRightHandLocationAndRotation(
|
||||||
const FVector& Location, const FRotator& Rotation, const bool bUpdateVirtualHand);
|
const FVector& Location, const FRotator& Rotation, const bool bUpdateVirtualHand);
|
||||||
|
|
||||||
|
void RegisterLeftHandOverlappedActor(const AActor* Actor) const;
|
||||||
|
void UnregisterLeftHandOverlappedActor(const AActor* Actor) const;
|
||||||
|
|
||||||
|
void RegisterRightHandOverlappedActor(const AActor* Actor) const;
|
||||||
|
void UnregisterRightHandOverlappedActor(const AActor* Actor) const;
|
||||||
|
|
||||||
|
bool IsLeftHandOverlappingWithAnyActor() const;
|
||||||
|
bool IsRightHandOverlappingWithAnyActor() const;
|
||||||
|
|
||||||
void DisableActorPhysics(const AActor* Actor) const;
|
void DisableActorPhysics(const AActor* Actor) const;
|
||||||
void EnableActorPhysics(const AActor* Actor) const;
|
void EnableActorPhysics(const AActor* Actor) const;
|
||||||
|
|
||||||
@@ -596,22 +598,22 @@ void ASGPawn::BeginPlay()
|
|||||||
|
|
||||||
WristTrackerLeft->OnWristLocationChanged().AddWeakLambda(this, [&](const FVector& Location)-> void
|
WristTrackerLeft->OnWristLocationChanged().AddWeakLambda(this, [&](const FVector& Location)-> void
|
||||||
{
|
{
|
||||||
Pimpl->UpdateLeftHandLocation(Location, Pimpl->bUpdateLeftHandLocationAndRotation);
|
Pimpl->UpdateLeftHandLocation(Location, !Pimpl->IsLeftHandOverlappingWithAnyActor());
|
||||||
});
|
});
|
||||||
|
|
||||||
WristTrackerLeft->OnWristRotationChanged().AddWeakLambda(this, [&](const FRotator& Rotation)-> void
|
WristTrackerLeft->OnWristRotationChanged().AddWeakLambda(this, [&](const FRotator& Rotation)-> void
|
||||||
{
|
{
|
||||||
Pimpl->UpdateLeftHandRotation(Rotation, Pimpl->bUpdateLeftHandLocationAndRotation);
|
Pimpl->UpdateLeftHandRotation(Rotation, !Pimpl->IsLeftHandOverlappingWithAnyActor());
|
||||||
});
|
});
|
||||||
|
|
||||||
WristTrackerRight->OnWristLocationChanged().AddWeakLambda(this, [&](const FVector& Location)-> void
|
WristTrackerRight->OnWristLocationChanged().AddWeakLambda(this, [&](const FVector& Location)-> void
|
||||||
{
|
{
|
||||||
Pimpl->UpdateRightHandLocation(Location, Pimpl->bUpdateRightHandLocationAndRotation);
|
Pimpl->UpdateRightHandLocation(Location, !Pimpl->IsRightHandOverlappingWithAnyActor());
|
||||||
});
|
});
|
||||||
|
|
||||||
WristTrackerRight->OnWristRotationChanged().AddWeakLambda(this, [&](const FRotator& Rotation)-> void
|
WristTrackerRight->OnWristRotationChanged().AddWeakLambda(this, [&](const FRotator& Rotation)-> void
|
||||||
{
|
{
|
||||||
Pimpl->UpdateRightHandRotation(Rotation, Pimpl->bUpdateRightHandLocationAndRotation);
|
Pimpl->UpdateRightHandRotation(Rotation, !Pimpl->IsRightHandOverlappingWithAnyActor());
|
||||||
});
|
});
|
||||||
|
|
||||||
Pimpl->BindRealHandsOverlapEvents();
|
Pimpl->BindRealHandsOverlapEvents();
|
||||||
@@ -670,16 +672,7 @@ void ASGPawn::OnRealLeftHandOverlapBegins(
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Pimpl->bUpdateLeftHandLocationAndRotation)
|
Pimpl->RegisterLeftHandOverlappedActor(OtherActor);
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Pimpl->bUpdateLeftHandLocationAndRotation = false;
|
|
||||||
|
|
||||||
/*FVector WristLocation{WristTrackerLeft->GetWristLocation()};
|
|
||||||
FRotator WristRotation{WristTrackerLeft->GetWristRotation()};
|
|
||||||
Pimpl->UpdateLeftHandLocationAndRotation(MoveTemp(WristLocation), MoveTemp(WristRotation), true);*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ASGPawn::OnRealLeftHandOverlapEnds(
|
void ASGPawn::OnRealLeftHandOverlapEnds(
|
||||||
@@ -697,16 +690,7 @@ void ASGPawn::OnRealLeftHandOverlapEnds(
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Pimpl->bUpdateLeftHandLocationAndRotation)
|
Pimpl->UnregisterLeftHandOverlappedActor(OtherActor);
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Pimpl->bUpdateLeftHandLocationAndRotation = true;
|
|
||||||
|
|
||||||
/*FVector WristLocation{WristTrackerLeft->GetWristLocation()};
|
|
||||||
FRotator WristRotation{WristTrackerLeft->GetWristRotation()};
|
|
||||||
Pimpl->UpdateLeftHandLocationAndRotation(MoveTemp(WristLocation), MoveTemp(WristRotation), true);*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ASGPawn::OnRealRightHandOverlapBegins(
|
void ASGPawn::OnRealRightHandOverlapBegins(
|
||||||
@@ -728,16 +712,7 @@ void ASGPawn::OnRealRightHandOverlapBegins(
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Pimpl->bUpdateRightHandLocationAndRotation)
|
Pimpl->RegisterRightHandOverlappedActor(OtherActor);
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Pimpl->bUpdateRightHandLocationAndRotation = false;
|
|
||||||
|
|
||||||
/*FVector WristLocation{WristTrackerRight->GetWristLocation()};
|
|
||||||
FRotator WristRotation{WristTrackerRight->GetWristRotation()};
|
|
||||||
Pimpl->UpdateRightHandLocationAndRotation(MoveTemp(WristLocation), MoveTemp(WristRotation), true);*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ASGPawn::OnRealRightHandOverlapEnds(
|
void ASGPawn::OnRealRightHandOverlapEnds(
|
||||||
@@ -755,16 +730,7 @@ void ASGPawn::OnRealRightHandOverlapEnds(
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Pimpl->bUpdateRightHandLocationAndRotation)
|
Pimpl->UnregisterRightHandOverlappedActor(OtherActor);
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Pimpl->bUpdateRightHandLocationAndRotation = true;
|
|
||||||
|
|
||||||
/*FVector WristLocation{WristTrackerRight->GetWristLocation()};
|
|
||||||
FRotator WristRotation{WristTrackerRight->GetWristRotation()};
|
|
||||||
Pimpl->UpdateRightHandLocationAndRotation(MoveTemp(WristLocation), MoveTemp(WristRotation), true);*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ASGPawn::OnLeftThumbFingertipGrabColliderOverlapBegins(
|
void ASGPawn::OnLeftThumbFingertipGrabColliderOverlapBegins(
|
||||||
@@ -1478,9 +1444,7 @@ void ASGPawn::ReleaseRight()
|
|||||||
}
|
}
|
||||||
|
|
||||||
ASGPawn::FImpl::FImpl(ASGPawn* InOwner)
|
ASGPawn::FImpl::FImpl(ASGPawn* InOwner)
|
||||||
: bUpdateLeftHandLocationAndRotation(true),
|
: Owner(InOwner)
|
||||||
bUpdateRightHandLocationAndRotation(true),
|
|
||||||
Owner(InOwner)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1795,6 +1759,36 @@ void ASGPawn::FImpl::UpdateRightHandLocationAndRotation(
|
|||||||
UpdateRightHandRotation(Rotation, bUpdateVirtualHand);
|
UpdateRightHandRotation(Rotation, bUpdateVirtualHand);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ASGPawn::FImpl::RegisterLeftHandOverlappedActor(const AActor* Actor) const
|
||||||
|
{
|
||||||
|
Owner->LeftHandOverlappedActors.AddUnique(Actor);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ASGPawn::FImpl::UnregisterLeftHandOverlappedActor(const AActor* Actor) const
|
||||||
|
{
|
||||||
|
Owner->LeftHandOverlappedActors.Remove(Actor);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ASGPawn::FImpl::RegisterRightHandOverlappedActor(const AActor* Actor) const
|
||||||
|
{
|
||||||
|
Owner->RightHandOverlappedActors.AddUnique(Actor);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ASGPawn::FImpl::UnregisterRightHandOverlappedActor(const AActor* Actor) const
|
||||||
|
{
|
||||||
|
Owner->RightHandOverlappedActors.Remove(Actor);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ASGPawn::FImpl::IsLeftHandOverlappingWithAnyActor() const
|
||||||
|
{
|
||||||
|
return Owner->LeftHandOverlappedActors.Num() > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ASGPawn::FImpl::IsRightHandOverlappingWithAnyActor() const
|
||||||
|
{
|
||||||
|
return Owner->RightHandOverlappedActors.Num() > 0;
|
||||||
|
}
|
||||||
|
|
||||||
void ASGPawn::FImpl::DisableActorPhysics(const AActor* Actor) const
|
void ASGPawn::FImpl::DisableActorPhysics(const AActor* Actor) const
|
||||||
{
|
{
|
||||||
UPrimitiveComponent* ActorRootComponent{Cast<UPrimitiveComponent>(Actor->GetRootComponent())};
|
UPrimitiveComponent* ActorRootComponent{Cast<UPrimitiveComponent>(Actor->GetRootComponent())};
|
||||||
|
|||||||
@@ -35,6 +35,7 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "Containers/Array.h"
|
||||||
#include "GameFramework/Pawn.h"
|
#include "GameFramework/Pawn.h"
|
||||||
#include "SenseGlove/Components/SGVirtualHandComponent.h"
|
#include "SenseGlove/Components/SGVirtualHandComponent.h"
|
||||||
#include "Templates/UniquePtr.h"
|
#include "Templates/UniquePtr.h"
|
||||||
@@ -175,6 +176,12 @@ private:
|
|||||||
UPROPERTY(Transient)
|
UPROPERTY(Transient)
|
||||||
FSGTouchState RightHandTouchState;
|
FSGTouchState RightHandTouchState;
|
||||||
|
|
||||||
|
UPROPERTY(Transient)
|
||||||
|
TArray<const AActor*> LeftHandOverlappedActors;
|
||||||
|
|
||||||
|
UPROPERTY(Transient)
|
||||||
|
TArray<const AActor*> RightHandOverlappedActors;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
FORCEINLINE UCameraComponent* GetCamera() const
|
FORCEINLINE UCameraComponent* GetCamera() const
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user