refactor the grab/touch logic and data structure and also cache the component ready to be grabbed in order to affect its physics state

This commit is contained in:
Mamadou Babaei
2023-05-19 18:15:39 +02:00
parent 70fc1df7da
commit 01ae2b5920
13 changed files with 648 additions and 452 deletions
@@ -110,6 +110,8 @@ USGGrabComponent::USGGrabComponent(const FObjectInitializer& ObjectInitializer)
DetachmentRotationRule = EDetachmentRule::KeepWorld;
DetachmentScaleRule = EDetachmentRule::KeepWorld;
bDetachmentCallModify = false;
bAffectPhysicsState = true;
}
USGGrabComponent::FImpl::FImpl(USGGrabComponent* InOwner)
@@ -36,6 +36,7 @@
#include "SenseGlove/GameFramework/SGPawn.h"
#include "Camera/CameraComponent.h"
#include "Components/PrimitiveComponent.h"
#include "Components/SphereComponent.h"
#include "SenseGlove/Components/SGGrabComponent.h"
@@ -428,27 +429,11 @@ ASGPawn::ASGPawn(const FObjectInitializer& ObjectInitializer)
RightPinkyFingertipTouchCollider->SetCollisionResponseToChannel(ECC_Vehicle, ECR_Overlap);
RightPinkyFingertipTouchCollider->SetCollisionResponseToChannel(ECC_Destructible, ECR_Overlap);
ActorLeftThumbCanGrab = nullptr;
ActorLeftIndexCanGrab = nullptr;
ActorLeftMiddleCanGrab = nullptr;
ActorLeftHandGrabbing = nullptr;
LeftHandGrabState = FSGGrabState(HandLeft, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr);
LeftHandTouchState = FSGTouchState(HandLeft, nullptr, nullptr, nullptr, nullptr, nullptr);
ActorLeftThumbTouching = nullptr;
ActorLeftIndexTouching = nullptr;
ActorLeftMiddleTouching = nullptr;
ActorLeftRingTouching = nullptr;
ActorLeftPinkyTouching = nullptr;
ActorRightThumbCanGrab = nullptr;
ActorRightIndexCanGrab = nullptr;
ActorRightMiddleCanGrab = nullptr;
ActorRightHandGrabbing = nullptr;
ActorRightThumbTouching = nullptr;
ActorRightIndexTouching = nullptr;
ActorRightMiddleTouching = nullptr;
ActorRightRingTouching = nullptr;
ActorRightPinkyTouching = nullptr;
RightHandGrabState = FSGGrabState(HandLeft, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr);
RightHandTouchState = FSGTouchState(HandRight, nullptr, nullptr, nullptr, nullptr, nullptr);
}
void ASGPawn::BeginPlay()
@@ -511,16 +496,15 @@ void ASGPawn::OnLeftThumbFingertipGrabColliderOverlapBegins(
const FHitResult& SweepResult)
{
(void) OverlappedComponent;
(void) OtherComp;
(void) OtherBodyIndex;
(void) bFromSweep;
(void) SweepResult;
if (USGGrabComponent::IsGrabbable(OtherActor))
{
ActorLeftThumbCanGrab = OtherActor;
GrabStateUpdatedEvent.Broadcast(HandLeft, ActorLeftThumbCanGrab, ActorLeftIndexCanGrab, ActorLeftMiddleCanGrab);
LeftHandGrabState.ActorThumbCanGrab = OtherActor;
LeftHandGrabState.ComponentThumbCanGrab = OtherComp;
GrabStateUpdatedEvent.Broadcast(LeftHandGrabState);
}
}
@@ -531,14 +515,13 @@ void ASGPawn::OnLeftThumbFingertipGrabColliderOverlapEnds(
const int32 OtherBodyIndex)
{
(void) OverlappedComponent;
(void) OtherComp;
(void) OtherBodyIndex;
if (ActorLeftThumbCanGrab == OtherActor)
if (LeftHandGrabState.ActorThumbCanGrab == OtherActor)
{
ActorLeftThumbCanGrab = nullptr;
GrabStateUpdatedEvent.Broadcast(HandLeft, ActorLeftThumbCanGrab, ActorLeftIndexCanGrab, ActorLeftMiddleCanGrab);
LeftHandGrabState.ActorThumbCanGrab = nullptr;
LeftHandGrabState.ComponentThumbCanGrab = nullptr;
GrabStateUpdatedEvent.Broadcast(LeftHandGrabState);
}
}
@@ -551,16 +534,15 @@ void ASGPawn::OnLeftIndexFingertipGrabColliderOverlapBegins(
const FHitResult& SweepResult)
{
(void) OverlappedComponent;
(void) OtherComp;
(void) OtherBodyIndex;
(void) bFromSweep;
(void) SweepResult;
if (USGGrabComponent::IsGrabbable(OtherActor))
{
ActorLeftIndexCanGrab = OtherActor;
GrabStateUpdatedEvent.Broadcast(HandLeft, ActorLeftThumbCanGrab, ActorLeftIndexCanGrab, ActorLeftMiddleCanGrab);
LeftHandGrabState.ActorIndexCanGrab = OtherActor;
LeftHandGrabState.ComponentIndexCanGrab = OtherComp;
GrabStateUpdatedEvent.Broadcast(LeftHandGrabState);
}
}
@@ -571,14 +553,13 @@ void ASGPawn::OnLeftIndexFingertipGrabColliderOverlapEnds(
const int32 OtherBodyIndex)
{
(void) OverlappedComponent;
(void) OtherComp;
(void) OtherBodyIndex;
if (ActorLeftIndexCanGrab == OtherActor)
if (LeftHandGrabState.ActorIndexCanGrab == OtherActor)
{
ActorLeftIndexCanGrab = nullptr;
GrabStateUpdatedEvent.Broadcast(HandLeft, ActorLeftThumbCanGrab, ActorLeftIndexCanGrab, ActorLeftMiddleCanGrab);
LeftHandGrabState.ActorIndexCanGrab = nullptr;
LeftHandGrabState.ComponentIndexCanGrab = nullptr;
GrabStateUpdatedEvent.Broadcast(LeftHandGrabState);
}
}
@@ -591,16 +572,15 @@ void ASGPawn::OnLeftMiddleFingertipGrabColliderOverlapBegins(
const FHitResult& SweepResult)
{
(void) OverlappedComponent;
(void) OtherComp;
(void) OtherBodyIndex;
(void) bFromSweep;
(void) SweepResult;
if (USGGrabComponent::IsGrabbable(OtherActor))
{
ActorLeftMiddleCanGrab = OtherActor;
GrabStateUpdatedEvent.Broadcast(HandLeft, ActorLeftThumbCanGrab, ActorLeftIndexCanGrab, ActorLeftMiddleCanGrab);
LeftHandGrabState.ActorMiddleCanGrab = OtherActor;
LeftHandGrabState.ComponentMiddleCanGrab = OtherComp;
GrabStateUpdatedEvent.Broadcast(LeftHandGrabState);
}
}
@@ -611,14 +591,13 @@ void ASGPawn::OnLeftMiddleFingertipGrabColliderOverlapEnds(
const int32 OtherBodyIndex)
{
(void) OverlappedComponent;
(void) OtherComp;
(void) OtherBodyIndex;
if (ActorLeftMiddleCanGrab == OtherActor)
if (LeftHandGrabState.ActorMiddleCanGrab == OtherActor)
{
ActorLeftMiddleCanGrab = nullptr;
GrabStateUpdatedEvent.Broadcast(HandLeft, ActorLeftThumbCanGrab, ActorLeftIndexCanGrab, ActorLeftMiddleCanGrab);
LeftHandGrabState.ActorMiddleCanGrab = nullptr;
LeftHandGrabState.ComponentMiddleCanGrab = nullptr;
GrabStateUpdatedEvent.Broadcast(LeftHandGrabState);
}
}
@@ -638,11 +617,8 @@ void ASGPawn::OnLeftThumbFingertipTouchColliderOverlapBegins(
if (USGTouchComponent::IsTouchable(OtherActor))
{
ActorLeftThumbTouching = OtherActor;
TouchStateUpdatedEvent.Broadcast(
HandLeft, ActorLeftThumbTouching, ActorLeftIndexTouching, ActorLeftMiddleTouching,
ActorLeftRingTouching, ActorLeftPinkyTouching);
LeftHandTouchState.ActorThumbTouching = OtherActor;
TouchStateUpdatedEvent.Broadcast(LeftHandTouchState);
}
}
@@ -656,13 +632,10 @@ void ASGPawn::OnLeftThumbFingertipTouchColliderOverlapEnds(
(void) OtherComp;
(void) OtherBodyIndex;
if (ActorLeftThumbTouching == OtherActor)
if (LeftHandTouchState.ActorThumbTouching == OtherActor)
{
ActorLeftThumbTouching = nullptr;
TouchStateUpdatedEvent.Broadcast(
HandLeft, ActorLeftThumbTouching, ActorLeftIndexTouching, ActorLeftMiddleTouching,
ActorLeftRingTouching, ActorLeftPinkyTouching);
LeftHandTouchState.ActorThumbTouching = nullptr;
TouchStateUpdatedEvent.Broadcast(LeftHandTouchState);
}
}
@@ -682,11 +655,8 @@ void ASGPawn::OnLeftIndexFingertipTouchColliderOverlapBegins(
if (USGTouchComponent::IsTouchable(OtherActor))
{
ActorLeftIndexTouching = OtherActor;
TouchStateUpdatedEvent.Broadcast(
HandLeft, ActorLeftThumbTouching, ActorLeftIndexTouching, ActorLeftMiddleTouching,
ActorLeftRingTouching, ActorLeftPinkyTouching);
LeftHandTouchState.ActorIndexTouching = OtherActor;
TouchStateUpdatedEvent.Broadcast(LeftHandTouchState);
}
}
@@ -700,13 +670,10 @@ void ASGPawn::OnLeftIndexFingertipTouchColliderOverlapEnds(
(void) OtherComp;
(void) OtherBodyIndex;
if (ActorLeftIndexTouching == OtherActor)
if (LeftHandTouchState.ActorIndexTouching == OtherActor)
{
ActorLeftIndexTouching = nullptr;
TouchStateUpdatedEvent.Broadcast(
HandLeft, ActorLeftThumbTouching, ActorLeftIndexTouching, ActorLeftMiddleTouching,
ActorLeftRingTouching, ActorLeftPinkyTouching);
LeftHandTouchState.ActorIndexTouching = nullptr;
TouchStateUpdatedEvent.Broadcast(LeftHandTouchState);
}
}
@@ -726,11 +693,8 @@ void ASGPawn::OnLeftMiddleFingertipTouchColliderOverlapBegins(
if (USGTouchComponent::IsTouchable(OtherActor))
{
ActorLeftMiddleTouching = OtherActor;
TouchStateUpdatedEvent.Broadcast(
HandLeft, ActorLeftThumbTouching, ActorLeftIndexTouching, ActorLeftMiddleTouching,
ActorLeftRingTouching, ActorLeftPinkyTouching);
LeftHandTouchState.ActorMiddleTouching = OtherActor;
TouchStateUpdatedEvent.Broadcast(LeftHandTouchState);
}
}
@@ -744,13 +708,10 @@ void ASGPawn::OnLeftMiddleFingertipTouchColliderOverlapEnds(
(void) OtherComp;
(void) OtherBodyIndex;
if (ActorLeftMiddleTouching == OtherActor)
if (LeftHandTouchState.ActorMiddleTouching == OtherActor)
{
ActorLeftMiddleTouching = nullptr;
TouchStateUpdatedEvent.Broadcast(
HandLeft, ActorLeftThumbTouching, ActorLeftIndexTouching, ActorLeftMiddleTouching,
ActorLeftRingTouching, ActorLeftPinkyTouching);
LeftHandTouchState.ActorMiddleTouching = nullptr;
TouchStateUpdatedEvent.Broadcast(LeftHandTouchState);
}
}
@@ -770,11 +731,8 @@ void ASGPawn::OnLeftRingFingertipTouchColliderOverlapBegins(
if (USGTouchComponent::IsTouchable(OtherActor))
{
ActorLeftRingTouching = OtherActor;
TouchStateUpdatedEvent.Broadcast(
HandLeft, ActorLeftThumbTouching, ActorLeftIndexTouching, ActorLeftMiddleTouching,
ActorLeftRingTouching, ActorLeftPinkyTouching);
LeftHandTouchState.ActorRingTouching = OtherActor;
TouchStateUpdatedEvent.Broadcast(LeftHandTouchState);
}
}
@@ -788,13 +746,10 @@ void ASGPawn::OnLeftRingFingertipTouchColliderOverlapEnds(
(void) OtherComp;
(void) OtherBodyIndex;
if (ActorLeftRingTouching == OtherActor)
if (LeftHandTouchState.ActorRingTouching == OtherActor)
{
ActorLeftRingTouching = nullptr;
TouchStateUpdatedEvent.Broadcast(
HandLeft, ActorLeftThumbTouching, ActorLeftIndexTouching, ActorLeftMiddleTouching,
ActorLeftRingTouching, ActorLeftPinkyTouching);
LeftHandTouchState.ActorRingTouching = nullptr;
TouchStateUpdatedEvent.Broadcast(LeftHandTouchState);
}
}
@@ -814,11 +769,8 @@ void ASGPawn::OnLeftPinkyFingertipTouchColliderOverlapBegins(
if (USGTouchComponent::IsTouchable(OtherActor))
{
ActorLeftPinkyTouching = OtherActor;
TouchStateUpdatedEvent.Broadcast(
HandLeft, ActorLeftThumbTouching, ActorLeftIndexTouching, ActorLeftMiddleTouching,
ActorLeftRingTouching, ActorLeftPinkyTouching);
LeftHandTouchState.ActorPinkyTouching = OtherActor;
TouchStateUpdatedEvent.Broadcast(LeftHandTouchState);
}
}
@@ -832,13 +784,10 @@ void ASGPawn::OnLeftPinkyFingertipTouchColliderOverlapEnds(
(void) OtherComp;
(void) OtherBodyIndex;
if (ActorLeftPinkyTouching == OtherActor)
if (LeftHandTouchState.ActorPinkyTouching == OtherActor)
{
ActorLeftPinkyTouching = nullptr;
TouchStateUpdatedEvent.Broadcast(
HandLeft, ActorLeftThumbTouching, ActorLeftIndexTouching, ActorLeftMiddleTouching,
ActorLeftRingTouching, ActorLeftPinkyTouching);
LeftHandTouchState.ActorPinkyTouching = nullptr;
TouchStateUpdatedEvent.Broadcast(LeftHandTouchState);
}
}
@@ -851,17 +800,15 @@ void ASGPawn::OnRightThumbFingertipGrabColliderOverlapBegins(
const FHitResult& SweepResult)
{
(void) OverlappedComponent;
(void) OtherComp;
(void) OtherBodyIndex;
(void) bFromSweep;
(void) SweepResult;
if (USGGrabComponent::IsGrabbable(OtherActor))
{
ActorRightThumbCanGrab = OtherActor;
GrabStateUpdatedEvent.Broadcast(
HandRight, ActorRightThumbCanGrab, ActorRightIndexCanGrab, ActorRightMiddleCanGrab);
RightHandGrabState.ActorThumbCanGrab = OtherActor;
RightHandGrabState.ComponentThumbCanGrab = OtherComp;
TouchStateUpdatedEvent.Broadcast(LeftHandTouchState);
}
}
@@ -872,15 +819,13 @@ void ASGPawn::OnRightThumbFingertipGrabColliderOverlapEnds(
const int32 OtherBodyIndex)
{
(void) OverlappedComponent;
(void) OtherComp;
(void) OtherBodyIndex;
if (ActorRightThumbCanGrab == OtherActor)
if (RightHandGrabState.ActorThumbCanGrab == OtherActor)
{
ActorRightThumbCanGrab = nullptr;
GrabStateUpdatedEvent.Broadcast(
HandRight, ActorRightThumbCanGrab, ActorRightIndexCanGrab, ActorRightMiddleCanGrab);
RightHandGrabState.ActorThumbCanGrab = nullptr;
RightHandGrabState.ComponentThumbCanGrab = nullptr;
GrabStateUpdatedEvent.Broadcast(RightHandGrabState);
}
}
@@ -893,17 +838,15 @@ void ASGPawn::OnRightIndexFingertipGrabColliderOverlapBegins(
const FHitResult& SweepResult)
{
(void) OverlappedComponent;
(void) OtherComp;
(void) OtherBodyIndex;
(void) bFromSweep;
(void) SweepResult;
if (USGGrabComponent::IsGrabbable(OtherActor))
{
ActorRightIndexCanGrab = OtherActor;
GrabStateUpdatedEvent.Broadcast(
HandRight, ActorRightThumbCanGrab, ActorRightIndexCanGrab, ActorRightMiddleCanGrab);
RightHandGrabState.ActorIndexCanGrab = OtherActor;
RightHandGrabState.ComponentIndexCanGrab = OtherComp;
GrabStateUpdatedEvent.Broadcast(RightHandGrabState);
}
}
@@ -914,15 +857,13 @@ void ASGPawn::OnRightIndexFingertipGrabColliderOverlapEnds(
const int32 OtherBodyIndex)
{
(void) OverlappedComponent;
(void) OtherComp;
(void) OtherBodyIndex;
if (ActorRightThumbCanGrab == OtherActor)
if (RightHandGrabState.ActorThumbCanGrab == OtherActor)
{
ActorRightIndexCanGrab = nullptr;
GrabStateUpdatedEvent.Broadcast(
HandRight, ActorRightThumbCanGrab, ActorRightIndexCanGrab, ActorRightMiddleCanGrab);
RightHandGrabState.ActorIndexCanGrab = nullptr;
RightHandGrabState.ComponentIndexCanGrab = nullptr;
GrabStateUpdatedEvent.Broadcast(RightHandGrabState);
}
}
@@ -935,17 +876,15 @@ void ASGPawn::OnRightMiddleFingertipGrabColliderOverlapBegins(
const FHitResult& SweepResult)
{
(void) OverlappedComponent;
(void) OtherComp;
(void) OtherBodyIndex;
(void) bFromSweep;
(void) SweepResult;
if (USGGrabComponent::IsGrabbable(OtherActor))
{
ActorRightMiddleCanGrab = OtherActor;
GrabStateUpdatedEvent.Broadcast(
HandRight, ActorRightThumbCanGrab, ActorRightIndexCanGrab, ActorRightMiddleCanGrab);
RightHandGrabState.ActorMiddleCanGrab = OtherActor;
RightHandGrabState.ComponentMiddleCanGrab = OtherComp;
GrabStateUpdatedEvent.Broadcast(RightHandGrabState);
}
}
@@ -956,15 +895,13 @@ void ASGPawn::OnRightMiddleFingertipGrabColliderOverlapEnds(
const int32 OtherBodyIndex)
{
(void) OverlappedComponent;
(void) OtherComp;
(void) OtherBodyIndex;
if (ActorRightMiddleCanGrab == OtherActor)
if (RightHandGrabState.ActorMiddleCanGrab == OtherActor)
{
ActorRightMiddleCanGrab = nullptr;
GrabStateUpdatedEvent.Broadcast(
HandRight, ActorRightThumbCanGrab, ActorRightIndexCanGrab, ActorRightMiddleCanGrab);
RightHandGrabState.ActorMiddleCanGrab = nullptr;
RightHandGrabState.ComponentMiddleCanGrab = nullptr;
GrabStateUpdatedEvent.Broadcast(RightHandGrabState);
}
}
@@ -984,11 +921,8 @@ void ASGPawn::OnRightThumbFingertipTouchColliderOverlapBegins(
if (USGTouchComponent::IsTouchable(OtherActor))
{
ActorRightThumbTouching = OtherActor;
TouchStateUpdatedEvent.Broadcast(
HandRight, ActorRightThumbTouching, ActorRightIndexTouching, ActorRightMiddleTouching,
ActorRightRingTouching, ActorRightPinkyTouching);
RightHandTouchState.ActorThumbTouching = OtherActor;
TouchStateUpdatedEvent.Broadcast(RightHandTouchState);
}
}
@@ -1002,13 +936,10 @@ void ASGPawn::OnRightThumbFingertipTouchColliderOverlapEnds(
(void) OtherComp;
(void) OtherBodyIndex;
if (ActorRightThumbTouching == OtherActor)
if (RightHandTouchState.ActorThumbTouching == OtherActor)
{
ActorRightThumbTouching = nullptr;
TouchStateUpdatedEvent.Broadcast(
HandRight, ActorRightThumbTouching, ActorRightIndexTouching, ActorRightMiddleTouching,
ActorRightRingTouching, ActorRightPinkyTouching);
RightHandTouchState.ActorThumbTouching = nullptr;
TouchStateUpdatedEvent.Broadcast(RightHandTouchState);
}
}
@@ -1028,11 +959,8 @@ void ASGPawn::OnRightIndexFingertipTouchColliderOverlapBegins(
if (USGTouchComponent::IsTouchable(OtherActor))
{
ActorRightIndexTouching = OtherActor;
TouchStateUpdatedEvent.Broadcast(
HandRight, ActorRightThumbTouching, ActorRightIndexTouching, ActorRightMiddleTouching,
ActorRightRingTouching, ActorRightPinkyTouching);
RightHandTouchState.ActorIndexTouching = OtherActor;
TouchStateUpdatedEvent.Broadcast(RightHandTouchState);
}
}
@@ -1046,13 +974,10 @@ void ASGPawn::OnRightIndexFingertipTouchColliderOverlapEnds(
(void) OtherComp;
(void) OtherBodyIndex;
if (ActorRightIndexTouching == OtherActor)
if (RightHandTouchState.ActorIndexTouching == OtherActor)
{
ActorRightIndexTouching = nullptr;
TouchStateUpdatedEvent.Broadcast(
HandRight, ActorRightThumbTouching, ActorRightIndexTouching, ActorRightMiddleTouching,
ActorRightRingTouching, ActorRightPinkyTouching);
RightHandTouchState.ActorIndexTouching = nullptr;
TouchStateUpdatedEvent.Broadcast(RightHandTouchState);
}
}
@@ -1072,11 +997,8 @@ void ASGPawn::OnRightMiddleFingertipTouchColliderOverlapBegins(
if (USGTouchComponent::IsTouchable(OtherActor))
{
ActorRightMiddleTouching = OtherActor;
TouchStateUpdatedEvent.Broadcast(
HandRight, ActorRightThumbTouching, ActorRightIndexTouching, ActorRightMiddleTouching,
ActorRightRingTouching, ActorRightPinkyTouching);
RightHandTouchState.ActorMiddleTouching = OtherActor;
TouchStateUpdatedEvent.Broadcast(RightHandTouchState);
}
}
@@ -1090,13 +1012,10 @@ void ASGPawn::OnRightMiddleFingertipTouchColliderOverlapEnds(
(void) OtherComp;
(void) OtherBodyIndex;
if (ActorRightMiddleTouching == OtherActor)
if (RightHandTouchState.ActorMiddleTouching == OtherActor)
{
ActorRightMiddleTouching = nullptr;
TouchStateUpdatedEvent.Broadcast(
HandRight, ActorRightThumbTouching, ActorRightIndexTouching, ActorRightMiddleTouching,
ActorRightRingTouching, ActorRightPinkyTouching);
RightHandTouchState.ActorMiddleTouching = nullptr;
TouchStateUpdatedEvent.Broadcast(RightHandTouchState);
}
}
@@ -1116,11 +1035,8 @@ void ASGPawn::OnRightRingFingertipTouchColliderOverlapBegins(
if (USGTouchComponent::IsTouchable(OtherActor))
{
ActorRightRingTouching = OtherActor;
TouchStateUpdatedEvent.Broadcast(
HandRight, ActorRightThumbTouching, ActorRightIndexTouching, ActorRightMiddleTouching,
ActorRightRingTouching, ActorRightPinkyTouching);
RightHandTouchState.ActorRingTouching = OtherActor;
TouchStateUpdatedEvent.Broadcast(RightHandTouchState);
}
}
@@ -1134,13 +1050,10 @@ void ASGPawn::OnRightRingFingertipTouchColliderOverlapEnds(
(void) OtherComp;
(void) OtherBodyIndex;
if (ActorRightRingTouching == OtherActor)
if (RightHandTouchState.ActorRingTouching == OtherActor)
{
ActorRightRingTouching = nullptr;
TouchStateUpdatedEvent.Broadcast(
HandRight, ActorRightThumbTouching, ActorRightIndexTouching, ActorRightMiddleTouching,
ActorRightRingTouching, ActorRightPinkyTouching);
RightHandTouchState.ActorRingTouching = nullptr;
TouchStateUpdatedEvent.Broadcast(RightHandTouchState);
}
}
@@ -1160,11 +1073,8 @@ void ASGPawn::OnRightPinkyFingertipTouchColliderOverlapBegins(
if (USGTouchComponent::IsTouchable(OtherActor))
{
ActorRightPinkyTouching = OtherActor;
TouchStateUpdatedEvent.Broadcast(
HandRight, ActorRightThumbTouching, ActorRightIndexTouching, ActorRightMiddleTouching,
ActorRightRingTouching, ActorRightPinkyTouching);
RightHandTouchState.ActorPinkyTouching = OtherActor;
TouchStateUpdatedEvent.Broadcast(RightHandTouchState);
}
}
@@ -1178,21 +1088,18 @@ void ASGPawn::OnRightPinkyFingertipTouchColliderOverlapEnds(
(void) OtherComp;
(void) OtherBodyIndex;
if (ActorRightPinkyTouching == OtherActor)
if (RightHandTouchState.ActorPinkyTouching == OtherActor)
{
ActorRightPinkyTouching = nullptr;
TouchStateUpdatedEvent.Broadcast(
HandRight, ActorRightThumbTouching, ActorRightIndexTouching, ActorRightMiddleTouching,
ActorRightRingTouching, ActorRightPinkyTouching);
RightHandTouchState.ActorPinkyTouching = nullptr;
TouchStateUpdatedEvent.Broadcast(RightHandTouchState);
}
}
bool ASGPawn::IsLeftHandGrabbing(AActor*& OutActor) const
{
if (IsValid(ActorLeftHandGrabbing))
if (IsValid(LeftHandGrabState.GrabbedActor))
{
OutActor = ActorLeftHandGrabbing;
OutActor = LeftHandGrabState.GrabbedActor;
return true;
}
@@ -1201,9 +1108,9 @@ bool ASGPawn::IsLeftHandGrabbing(AActor*& OutActor) const
bool ASGPawn::IsRightHandGrabbing(AActor*& OutActor) const
{
if (IsValid(ActorRightHandGrabbing))
if (IsValid(RightHandGrabState.GrabbedActor))
{
OutActor = ActorRightHandGrabbing;
OutActor = RightHandGrabState.GrabbedActor;
return true;
}
@@ -1215,7 +1122,7 @@ bool ASGPawn::IsGrabbing(const USGVirtualHandComponent* Hand, AActor*& OutActor)
return Hand == HandLeft ? IsLeftHandGrabbing(OutActor) : IsRightHandGrabbing(OutActor);
}
void ASGPawn::Grab(USGVirtualHandComponent* Hand, AActor* Actor)
void ASGPawn::Grab(USGVirtualHandComponent* Hand, AActor* Actor, UPrimitiveComponent* Component)
{
if (!ensureAlwaysMsgf(IsValid(Actor), TEXT("%s"), TEXT("ERROR: invalid actor!")))
{
@@ -1238,26 +1145,34 @@ void ASGPawn::Grab(USGVirtualHandComponent* Hand, AActor* Actor)
const FName SocketName{GrabComponent->GetAttachmentSocketName()};
ensureAlwaysMsgf(SocketName != NAME_None, TEXT("invalid attachment socket name!"));
const USceneComponent* ActorRootComponent{Cast<USceneComponent>(Actor->GetRootComponent())};
if (!ensureAlwaysMsgf(IsValid(ActorRootComponent), TEXT("%s"), TEXT("ERROR: invalid actor's root component!")))
if (GrabComponent->GetAffectPhysicsState())
{
return;
}
TArray<USceneComponent*> ActorChildrenComponents;
ActorRootComponent->GetChildrenComponents(true, ActorChildrenComponents);
for (USceneComponent* SceneComponent : ActorChildrenComponents)
{
UPrimitiveComponent* PrimitiveComponent{Cast<UPrimitiveComponent>(SceneComponent)};
if (IsValid(PrimitiveComponent))
const USceneComponent* ActorRootComponent{Cast<USceneComponent>(Actor->GetRootComponent())};
if (!ensureAlwaysMsgf(IsValid(ActorRootComponent), TEXT("%s"), TEXT("ERROR: invalid actor's root component!")))
{
PrimitiveComponent->SetSimulatePhysics(false);
return;
}
TArray<USceneComponent*> ActorChildrenComponents;
ActorRootComponent->GetChildrenComponents(true, ActorChildrenComponents);
for (USceneComponent* SceneComponent: ActorChildrenComponents)
{
UPrimitiveComponent* PrimitiveComponent{Cast<UPrimitiveComponent>(SceneComponent)};
if (IsValid(PrimitiveComponent))
{
PrimitiveComponent->SetSimulatePhysics(false);
}
}
if (IsValid(Component))
{
Component->SetSimulatePhysics(false);
}
}
const bool bAttached = Actor->AttachToComponent(Hand, MoveTemp(AttachmentRules), SocketName);
if (bAttached)
{
ActorLeftHandGrabbing = Actor;
LeftHandGrabState.GrabbedActor = Actor;
}
else
{
@@ -1267,82 +1182,100 @@ void ASGPawn::Grab(USGVirtualHandComponent* Hand, AActor* Actor)
void ASGPawn::ReleaseLeft()
{
if (!IsValid(ActorLeftHandGrabbing))
if (!IsValid(LeftHandGrabState.GrabbedActor))
{
return;
}
const USGGrabComponent* GrabComponent{USGGrabComponent::GetGrabComponent(ActorLeftHandGrabbing)};
const USGGrabComponent* GrabComponent{USGGrabComponent::GetGrabComponent(LeftHandGrabState.GrabbedActor)};
if (!IsValid(GrabComponent))
{
return;
}
ActorLeftHandGrabbing->DetachFromActor(
LeftHandGrabState.GrabbedActor->DetachFromActor(
FDetachmentTransformRules(GrabComponent->GetDetachmentLocationRule(),
GrabComponent->GetDetachmentRotationRule(),
GrabComponent->GetDetachmentScaleRule(),
GrabComponent->GetDetachmentInCallModify())
);
const UPrimitiveComponent* ActorRootComponent{
Cast<UPrimitiveComponent>(ActorLeftHandGrabbing->GetRootComponent())
};
if (ensureAlwaysMsgf(IsValid(ActorRootComponent), TEXT("%s"), TEXT("ERROR: invalid actor's root component!")))
if (GrabComponent->GetAffectPhysicsState())
{
TArray<USceneComponent*> ActorChildrenComponents;
ActorRootComponent->GetChildrenComponents(true, ActorChildrenComponents);
for (USceneComponent* SceneComponent : ActorChildrenComponents)
const UPrimitiveComponent* ActorRootComponent{
Cast<UPrimitiveComponent>(LeftHandGrabState.GrabbedActor->GetRootComponent())
};
if (ensureAlwaysMsgf(IsValid(ActorRootComponent), TEXT("%s"), TEXT("ERROR: invalid actor's root component!")))
{
UPrimitiveComponent* PrimitiveComponent{Cast<UPrimitiveComponent>(SceneComponent)};
if (IsValid(PrimitiveComponent))
TArray<USceneComponent*> ActorChildrenComponents;
ActorRootComponent->GetChildrenComponents(true, ActorChildrenComponents);
for (USceneComponent* SceneComponent: ActorChildrenComponents)
{
PrimitiveComponent->SetSimulatePhysics(true);
UPrimitiveComponent* PrimitiveComponent{Cast<UPrimitiveComponent>(SceneComponent)};
if (IsValid(PrimitiveComponent))
{
PrimitiveComponent->SetSimulatePhysics(true);
}
}
}
if (IsValid(LeftHandGrabState.GrabbedComponent))
{
LeftHandGrabState.GrabbedComponent->SetSimulatePhysics(true);
}
}
ActorLeftHandGrabbing = nullptr;
LeftHandGrabState.GrabbedActor = nullptr;
LeftHandGrabState.GrabbedComponent = nullptr;
}
void ASGPawn::ReleaseRight()
{
if (!IsValid(ActorRightHandGrabbing))
if (!IsValid(RightHandGrabState.GrabbedActor))
{
return;
}
const USGGrabComponent* GrabComponent{USGGrabComponent::GetGrabComponent(ActorRightHandGrabbing)};
const USGGrabComponent* GrabComponent{USGGrabComponent::GetGrabComponent(RightHandGrabState.GrabbedActor)};
if (!IsValid(GrabComponent))
{
return;
}
ActorRightHandGrabbing->DetachFromActor(
RightHandGrabState.GrabbedActor->DetachFromActor(
FDetachmentTransformRules(GrabComponent->GetDetachmentLocationRule(),
GrabComponent->GetDetachmentRotationRule(),
GrabComponent->GetDetachmentScaleRule(),
GrabComponent->GetDetachmentInCallModify())
);
const UPrimitiveComponent* ActorRootComponent{
Cast<UPrimitiveComponent>(ActorLeftHandGrabbing->GetRootComponent())
};
if (ensureAlwaysMsgf(IsValid(ActorRootComponent), TEXT("%s"), TEXT("ERROR: invalid actor's root component!")))
if (GrabComponent->GetAffectPhysicsState())
{
TArray<USceneComponent*> ActorChildrenComponents;
ActorRootComponent->GetChildrenComponents(true, ActorChildrenComponents);
for (USceneComponent* SceneComponent : ActorChildrenComponents)
const UPrimitiveComponent* ActorRootComponent{
Cast<UPrimitiveComponent>(LeftHandGrabState.GrabbedActor->GetRootComponent())
};
if (ensureAlwaysMsgf(IsValid(ActorRootComponent), TEXT("%s"), TEXT("ERROR: invalid actor's root component!")))
{
UPrimitiveComponent* PrimitiveComponent{Cast<UPrimitiveComponent>(SceneComponent)};
if (IsValid(PrimitiveComponent))
TArray<USceneComponent*> ActorChildrenComponents;
ActorRootComponent->GetChildrenComponents(true, ActorChildrenComponents);
for (USceneComponent* SceneComponent: ActorChildrenComponents)
{
PrimitiveComponent->SetSimulatePhysics(true);
UPrimitiveComponent* PrimitiveComponent{Cast<UPrimitiveComponent>(SceneComponent)};
if (IsValid(PrimitiveComponent))
{
PrimitiveComponent->SetSimulatePhysics(true);
}
}
}
if (IsValid(RightHandGrabState.GrabbedComponent))
{
RightHandGrabState.GrabbedComponent->SetSimulatePhysics(true);
}
}
ActorRightHandGrabbing = nullptr;
RightHandGrabState.GrabbedActor = nullptr;
RightHandGrabState.GrabbedComponent = nullptr;
}
ASGPawn::FImpl::FImpl(ASGPawn* InOwner)
@@ -46,6 +46,8 @@
#include "SenseGlove/Components/SGGrabComponent.h"
#include "SenseGlove/Components/SGTouchComponent.h"
#include "SenseGlove/GameFramework/SGPawn.h"
#include "SenseGlove/Haptics/SGGrabState.h"
#include "SenseGlove/Haptics/SGTouchState.h"
#include "SGCore/SGBuzzCommand.h"
#include "SGCore/SGForceFeedbackCommand.h"
#include "SGCore/SGHapticGlove.h"
@@ -102,10 +104,7 @@ struct ASGPlayerController::FImpl
const AActor* ActorMiddleTouching, const AActor* ActorRingTouching,
const AActor* ActorPinkyTouching) const;
void UpdateHapticsFeedback(
const USGVirtualHandComponent* Hand,
const AActor* ActorThumbTouching, const AActor* ActorIndexTouching, const AActor* ActorMiddleTouching,
const AActor* ActorRingTouching, const AActor* ActorPinkyTouching);
void UpdateHapticsFeedback(const FSGTouchState& TouchState);
};
int32 ASGPlayerController::FImpl::GetBuzzLevel(const AActor* Actor)
@@ -205,47 +204,40 @@ void ASGPlayerController::BeginPlay()
}
SGPawn->OnGrabStateUpdated().AddWeakLambda(
this, [=](
USGVirtualHandComponent* Hand,
AActor* ActorThumbCanGrab, const AActor* ActorIndexCanGrab,
const AActor* ActorMiddleCanGrab) -> void
this, [=](const FSGGrabState& GrabState) -> void
{
if (!IsValid(SGPawn))
{
return;
}
if (!IsValid(Hand))
if (!IsValid(GrabState.Hand))
{
return;
}
if (SGPawn->IsGrabbing(Hand))
if (SGPawn->IsGrabbing(GrabState.Hand))
{
if (!IsValid(ActorThumbCanGrab) ||
(ActorIndexCanGrab != ActorThumbCanGrab && ActorMiddleCanGrab != ActorThumbCanGrab))
if (!IsValid(GrabState.ActorThumbCanGrab) ||
(GrabState.ActorIndexCanGrab != GrabState.ActorThumbCanGrab
&& GrabState.ActorMiddleCanGrab != GrabState.ActorThumbCanGrab))
{
SGPawn->Release(Hand);
SGPawn->Release(GrabState.Hand);
}
}
else
{
if (SGPawn->CanGrab(Hand, ActorThumbCanGrab))
if (SGPawn->CanGrab(GrabState.Hand, GrabState.ActorThumbCanGrab))
{
SGPawn->Grab(Hand, ActorThumbCanGrab);
SGPawn->Grab(GrabState.Hand, GrabState.ActorThumbCanGrab, GrabState.ComponentThumbCanGrab);
}
}
});
SGPawn->OnTouchStateUpdated().AddWeakLambda(
this, [=](
const USGVirtualHandComponent* Hand,
const AActor* ActorThumbTouching, const AActor* ActorIndexTouching, const AActor* ActorMiddleTouching,
const AActor* ActorRingTouching, const AActor* ActorPinkyTouching) -> void
this, [=](const FSGTouchState& TouchState) -> void
{
Pimpl->UpdateHapticsFeedback(
Hand,
ActorThumbTouching, ActorIndexTouching, ActorMiddleTouching, ActorRingTouching, ActorPinkyTouching);
Pimpl->UpdateHapticsFeedback(TouchState);
});
}
@@ -317,17 +309,14 @@ USGForceFeedbackCommand* ASGPlayerController::FImpl::GetForceFeedbackCommand(
return ForceFeedbackCommand;
}
void ASGPlayerController::FImpl::UpdateHapticsFeedback(
const USGVirtualHandComponent* Hand,
const AActor* ActorThumbTouching, const AActor* ActorIndexTouching, const AActor* ActorMiddleTouching,
const AActor* ActorRingTouching, const AActor* ActorPinkyTouching)
void ASGPlayerController::FImpl::UpdateHapticsFeedback(const FSGTouchState& TouchState)
{
if (!IsValid(Hand))
if (!IsValid(TouchState.Hand))
{
return;
}
USGHapticGlove* Glove = Hand->GetConnectedGlove();
USGHapticGlove* Glove = TouchState.Hand->GetConnectedGlove();
if (!IsValid(Glove))
{
return;
@@ -335,14 +324,16 @@ void ASGPlayerController::FImpl::UpdateHapticsFeedback(
const USGBuzzCommand* BuzzCommand{
GetBuzzCommand(
ActorThumbTouching, ActorIndexTouching, ActorMiddleTouching, ActorRingTouching, ActorPinkyTouching)
TouchState.ActorThumbTouching, TouchState.ActorIndexTouching, TouchState.ActorMiddleTouching,
TouchState.ActorRingTouching,TouchState.ActorPinkyTouching)
};
if (IsValid(BuzzCommand))
{
Glove->SendHaptics(BuzzCommand);
const float Duration = FImpl::GetBuzzDuration(
ActorThumbTouching, ActorIndexTouching, ActorMiddleTouching, ActorRingTouching, ActorPinkyTouching);
TouchState.ActorThumbTouching, TouchState.ActorIndexTouching, TouchState.ActorMiddleTouching,
TouchState. ActorRingTouching, TouchState.ActorPinkyTouching);
Owner->GetWorldTimerManager().ClearTimer(TouchBuzzStopTimer);
@@ -362,7 +353,8 @@ void ASGPlayerController::FImpl::UpdateHapticsFeedback(
const USGForceFeedbackCommand* ForceFeedbackCommand{
GetForceFeedbackCommand(
ActorThumbTouching, ActorIndexTouching, ActorMiddleTouching, ActorRingTouching, ActorPinkyTouching)
TouchState.ActorThumbTouching, TouchState.ActorIndexTouching, TouchState.ActorMiddleTouching,
TouchState. ActorRingTouching, TouchState.ActorPinkyTouching)
};
if (IsValid(ForceFeedbackCommand))
{
@@ -249,15 +249,8 @@ ASGVirtualHandActor::ASGVirtualHandActor(const FObjectInitializer& ObjectInitial
WristTracker->SetRight(VirtualHand->IsRight());
ActorThumbCanGrab = nullptr;
ActorIndexCanGrab = nullptr;
ActorMiddleCanGrab = nullptr;
ActorThumbTouching = nullptr;
ActorIndexTouching = nullptr;
ActorMiddleTouching = nullptr;
ActorRingTouching = nullptr;
ActorPinkyTouching = nullptr;
GrabState = FSGGrabState(VirtualHand, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr);
TouchState = FSGTouchState(VirtualHand, nullptr, nullptr, nullptr, nullptr, nullptr);
}
void ASGVirtualHandActor::BeginPlay()
@@ -307,16 +300,15 @@ void ASGVirtualHandActor::OnThumbFingertipGrabColliderOverlapBegins(
const FHitResult& SweepResult)
{
(void) OverlappedComponent;
(void) OtherComp;
(void) OtherBodyIndex;
(void) bFromSweep;
(void) SweepResult;
if (USGGrabComponent::IsGrabbable(OtherActor))
{
ActorThumbCanGrab = OtherActor;
GrabStateUpdatedEvent.Broadcast(VirtualHand, ActorThumbCanGrab, ActorIndexCanGrab, ActorMiddleCanGrab);
GrabState.ActorThumbCanGrab = OtherActor;
GrabState.ComponentThumbCanGrab = OtherComp;
GrabStateUpdatedEvent.Broadcast(GrabState);
}
}
@@ -327,14 +319,13 @@ void ASGVirtualHandActor::OnThumbFingertipGrabColliderOverlapEnds(
const int32 OtherBodyIndex)
{
(void) OverlappedComponent;
(void) OtherComp;
(void) OtherBodyIndex;
if (ActorThumbCanGrab == OtherActor)
if (GrabState.ActorThumbCanGrab == OtherActor)
{
ActorThumbCanGrab = nullptr;
GrabStateUpdatedEvent.Broadcast(VirtualHand, ActorThumbCanGrab, ActorIndexCanGrab, ActorMiddleCanGrab);
GrabState.ActorThumbCanGrab = nullptr;
GrabState.ComponentThumbCanGrab = nullptr;
GrabStateUpdatedEvent.Broadcast(GrabState);
}
}
@@ -347,16 +338,15 @@ void ASGVirtualHandActor::OnIndexFingertipGrabColliderOverlapBegins(
const FHitResult& SweepResult)
{
(void) OverlappedComponent;
(void) OtherComp;
(void) OtherBodyIndex;
(void) bFromSweep;
(void) SweepResult;
if (USGGrabComponent::IsGrabbable(OtherActor))
{
ActorIndexCanGrab = OtherActor;
GrabStateUpdatedEvent.Broadcast(VirtualHand, ActorThumbCanGrab, ActorIndexCanGrab, ActorMiddleCanGrab);
GrabState.ActorIndexCanGrab = OtherActor;
GrabState.ComponentIndexCanGrab = OtherComp;
GrabStateUpdatedEvent.Broadcast(GrabState);
}
}
@@ -367,14 +357,13 @@ void ASGVirtualHandActor::OnIndexFingertipGrabColliderOverlapEnds(
const int32 OtherBodyIndex)
{
(void) OverlappedComponent;
(void) OtherComp;
(void) OtherBodyIndex;
if (ActorIndexCanGrab == OtherActor)
if (GrabState.ActorIndexCanGrab == OtherActor)
{
ActorIndexCanGrab = nullptr;
GrabStateUpdatedEvent.Broadcast(VirtualHand, ActorThumbCanGrab, ActorIndexCanGrab, ActorMiddleCanGrab);
GrabState.ActorIndexCanGrab = nullptr;
GrabState.ComponentIndexCanGrab = nullptr;
GrabStateUpdatedEvent.Broadcast(GrabState);
}
}
@@ -387,16 +376,15 @@ void ASGVirtualHandActor::OnMiddleFingertipGrabColliderOverlapBegins(
const FHitResult& SweepResult)
{
(void) OverlappedComponent;
(void) OtherComp;
(void) OtherBodyIndex;
(void) bFromSweep;
(void) SweepResult;
if (USGGrabComponent::IsGrabbable(OtherActor))
{
ActorMiddleCanGrab = OtherActor;
GrabStateUpdatedEvent.Broadcast(VirtualHand, ActorThumbCanGrab, ActorIndexCanGrab, ActorMiddleCanGrab);
GrabState.ActorMiddleCanGrab = OtherActor;
GrabState.ComponentMiddleCanGrab = OtherComp;
GrabStateUpdatedEvent.Broadcast(GrabState);
}
}
@@ -407,14 +395,13 @@ void ASGVirtualHandActor::OnMiddleFingertipGrabColliderOverlapEnds(
const int32 OtherBodyIndex)
{
(void) OverlappedComponent;
(void) OtherComp;
(void) OtherBodyIndex;
if (ActorMiddleCanGrab == OtherActor)
if (GrabState.ActorMiddleCanGrab == OtherActor)
{
ActorMiddleCanGrab = nullptr;
GrabStateUpdatedEvent.Broadcast(VirtualHand, ActorThumbCanGrab, ActorIndexCanGrab, ActorMiddleCanGrab);
GrabState.ActorMiddleCanGrab = nullptr;
GrabState.ComponentMiddleCanGrab = nullptr;
GrabStateUpdatedEvent.Broadcast(GrabState);
}
}
@@ -434,11 +421,8 @@ void ASGVirtualHandActor::OnThumbFingertipTouchColliderOverlapBegins(
if (USGTouchComponent::IsTouchable(OtherActor))
{
ActorThumbTouching = OtherActor;
TouchStateUpdatedEvent.Broadcast(
VirtualHand, ActorThumbTouching, ActorIndexTouching, ActorMiddleTouching,
ActorRingTouching, ActorPinkyTouching);
TouchState.ActorThumbTouching = OtherActor;
TouchStateUpdatedEvent.Broadcast(TouchState);
}
}
@@ -452,13 +436,10 @@ void ASGVirtualHandActor::OnThumbFingertipTouchColliderOverlapEnds(
(void) OtherComp;
(void) OtherBodyIndex;
if (ActorThumbTouching == OtherActor)
if (TouchState.ActorThumbTouching == OtherActor)
{
ActorThumbTouching = nullptr;
TouchStateUpdatedEvent.Broadcast(
VirtualHand, ActorThumbTouching, ActorIndexTouching, ActorMiddleTouching,
ActorRingTouching, ActorPinkyTouching);
TouchState.ActorThumbTouching = nullptr;
TouchStateUpdatedEvent.Broadcast(TouchState);
}
}
@@ -478,11 +459,8 @@ void ASGVirtualHandActor::OnIndexFingertipTouchColliderOverlapBegins(
if (USGTouchComponent::IsTouchable(OtherActor))
{
ActorIndexTouching = OtherActor;
TouchStateUpdatedEvent.Broadcast(
VirtualHand, ActorThumbTouching, ActorIndexTouching, ActorMiddleTouching,
ActorRingTouching, ActorPinkyTouching);
TouchState.ActorIndexTouching = OtherActor;
TouchStateUpdatedEvent.Broadcast(TouchState);
}
}
@@ -496,13 +474,10 @@ void ASGVirtualHandActor::OnIndexFingertipTouchColliderOverlapEnds(
(void) OtherComp;
(void) OtherBodyIndex;
if (ActorIndexTouching == OtherActor)
if (TouchState.ActorIndexTouching == OtherActor)
{
ActorIndexTouching = nullptr;
TouchStateUpdatedEvent.Broadcast(
VirtualHand, ActorThumbTouching, ActorIndexTouching, ActorMiddleTouching,
ActorRingTouching, ActorPinkyTouching);
TouchState.ActorIndexTouching = nullptr;
TouchStateUpdatedEvent.Broadcast(TouchState);
}
}
@@ -522,11 +497,8 @@ void ASGVirtualHandActor::OnMiddleFingertipTouchColliderOverlapBegins(
if (USGTouchComponent::IsTouchable(OtherActor))
{
ActorMiddleTouching = OtherActor;
TouchStateUpdatedEvent.Broadcast(
VirtualHand, ActorThumbTouching, ActorIndexTouching, ActorMiddleTouching,
ActorRingTouching, ActorPinkyTouching);
TouchState.ActorMiddleTouching = OtherActor;
TouchStateUpdatedEvent.Broadcast(TouchState);
}
}
@@ -540,13 +512,10 @@ void ASGVirtualHandActor::OnMiddleFingertipTouchColliderOverlapEnds(
(void) OtherComp;
(void) OtherBodyIndex;
if (ActorMiddleTouching == OtherActor)
if (TouchState.ActorMiddleTouching == OtherActor)
{
ActorMiddleTouching = nullptr;
TouchStateUpdatedEvent.Broadcast(
VirtualHand, ActorThumbTouching, ActorIndexTouching, ActorMiddleTouching,
ActorRingTouching, ActorPinkyTouching);
TouchState.ActorMiddleTouching = nullptr;
TouchStateUpdatedEvent.Broadcast(TouchState);
}
}
@@ -560,11 +529,8 @@ void ASGVirtualHandActor::OnRingFingertipTouchColliderOverlapBegins(
{
if (USGTouchComponent::IsTouchable(OtherActor))
{
ActorRingTouching = OtherActor;
TouchStateUpdatedEvent.Broadcast(
VirtualHand, ActorThumbTouching, ActorIndexTouching, ActorMiddleTouching,
ActorRingTouching, ActorPinkyTouching);
TouchState.ActorRingTouching = OtherActor;
TouchStateUpdatedEvent.Broadcast(TouchState);
}
}
@@ -578,13 +544,10 @@ void ASGVirtualHandActor::OnRingFingertipTouchColliderOverlapEnds(
(void) OtherComp;
(void) OtherBodyIndex;
if (ActorRingTouching == OtherActor)
if (TouchState.ActorRingTouching == OtherActor)
{
ActorRingTouching = nullptr;
TouchStateUpdatedEvent.Broadcast(
VirtualHand, ActorThumbTouching, ActorIndexTouching, ActorMiddleTouching,
ActorRingTouching, ActorPinkyTouching);
TouchState.ActorRingTouching = nullptr;
TouchStateUpdatedEvent.Broadcast(TouchState);
}
}
@@ -598,11 +561,8 @@ void ASGVirtualHandActor::OnPinkyFingertipTouchColliderOverlapBegins(
{
if (USGTouchComponent::IsTouchable(OtherActor))
{
ActorPinkyTouching = OtherActor;
TouchStateUpdatedEvent.Broadcast(
VirtualHand, ActorThumbTouching, ActorIndexTouching, ActorMiddleTouching,
ActorRingTouching, ActorPinkyTouching);
TouchState.ActorPinkyTouching = OtherActor;
TouchStateUpdatedEvent.Broadcast(TouchState);
}
}
@@ -616,13 +576,10 @@ void ASGVirtualHandActor::OnPinkyFingertipTouchColliderOverlapEnds(
(void) OtherComp;
(void) OtherBodyIndex;
if (ActorPinkyTouching == OtherActor)
if (TouchState.ActorPinkyTouching == OtherActor)
{
ActorPinkyTouching = nullptr;
TouchStateUpdatedEvent.Broadcast(
VirtualHand, ActorThumbTouching, ActorIndexTouching, ActorMiddleTouching,
ActorRingTouching, ActorPinkyTouching);
TouchState.ActorPinkyTouching = nullptr;
TouchStateUpdatedEvent.Broadcast(TouchState);
}
}
@@ -0,0 +1,75 @@
/**
* @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 "SenseGlove/Haptics/SGGrabState.h"
#include "Components/SphereComponent.h"
#include "GameFramework/Actor.h"
#include "SenseGlove/Components/SGVirtualHandComponent.h"
FSGGrabState::FSGGrabState()
: Hand(nullptr),
ActorThumbCanGrab(nullptr),
ComponentThumbCanGrab(nullptr),
ActorIndexCanGrab(nullptr),
ComponentIndexCanGrab(nullptr),
ActorMiddleCanGrab(nullptr),
ComponentMiddleCanGrab(nullptr),
GrabbedActor(nullptr),
GrabbedComponent(nullptr)
{
}
FSGGrabState::FSGGrabState(USGVirtualHandComponent* InHand,
AActor* InActorThumbCanGrab,
UPrimitiveComponent* InComponentThumbCanGrab,
AActor* InActorIndexCanGrab,
UPrimitiveComponent* InComponentIndexCanGrab,
AActor* InActorMiddleCanGrab,
UPrimitiveComponent* InComponentMiddleCanGrab,
AActor* InGrabbedActor,
UPrimitiveComponent* InGrabbedComponent)
: Hand(InHand),
ActorThumbCanGrab(InActorThumbCanGrab),
ComponentThumbCanGrab(InComponentThumbCanGrab),
ActorIndexCanGrab(InActorIndexCanGrab),
ComponentIndexCanGrab(InComponentIndexCanGrab),
ActorMiddleCanGrab(InActorMiddleCanGrab),
ComponentMiddleCanGrab(InComponentMiddleCanGrab),
GrabbedActor(InGrabbedActor),
GrabbedComponent(InGrabbedComponent)
{
}
@@ -0,0 +1,65 @@
/**
* @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 "SenseGlove/Haptics/SGTouchState.h"
#include "GameFramework/Actor.h"
#include "SenseGlove/Components/SGVirtualHandComponent.h"
FSGTouchState::FSGTouchState()
: Hand(nullptr),
ActorThumbTouching(nullptr),
ActorIndexTouching(nullptr),
ActorMiddleTouching(nullptr),
ActorRingTouching(nullptr),
ActorPinkyTouching(nullptr)
{
}
FSGTouchState::FSGTouchState(USGVirtualHandComponent* InHand,
AActor* InActorThumbTouching,
AActor* InActorIndexTouching,
AActor* InActorMiddleTouching,
AActor* InActorRingTouching,
AActor* InActorPinkyTouching)
: Hand(InHand),
ActorThumbTouching(InActorThumbTouching),
ActorIndexTouching(InActorIndexTouching),
ActorMiddleTouching(InActorMiddleTouching),
ActorRingTouching(InActorRingTouching),
ActorPinkyTouching(InActorPinkyTouching)
{
}
@@ -82,6 +82,9 @@ private:
UPROPERTY(EditAnywhere, Category="SenseGlove", meta=(AllowPrivateAccess="false"))
uint8 bDetachmentCallModify : 1;
UPROPERTY(EditAnywhere, Category="SenseGlove", meta=(AllowPrivateAccess="false"))
uint8 bAffectPhysicsState : 1;
private:
struct FImpl;
@@ -183,4 +186,14 @@ public:
{
bDetachmentCallModify = bInDetachmentCallModify;
}
FORCEINLINE bool GetAffectPhysicsState() const
{
return !!bAffectPhysicsState;
}
FORCEINLINE void SetAffectPhysicsState(const bool bInAffectPhysicsState)
{
bAffectPhysicsState = bInAffectPhysicsState;
}
};
@@ -39,9 +39,13 @@
#include "SenseGlove/Components/SGVirtualHandComponent.h"
#include "Templates/UniquePtr.h"
#include "SenseGlove/Haptics/SGGrabState.h"
#include "SenseGlove/Haptics/SGTouchState.h"
#include "SGPawn.generated.h"
class UCameraComponent;
class UPrimitiveComponent;
class USphereComponent;
class USGVirtualHandComponent;
@@ -53,18 +57,14 @@ class SENSEGLOVE_API ASGPawn : public APawn
GENERATED_UCLASS_BODY()
public:
DECLARE_EVENT_FourParams(
ASGPawn, FGrabStateUpdatedEvent,
USGVirtualHandComponent*, AActor*, const AActor*, const AActor*);
DECLARE_EVENT_OneParam(ASGVirtualHandActor, FGrabStateUpdatedEvent, const FSGGrabState& GrabState);
FGrabStateUpdatedEvent& OnGrabStateUpdated()
{
return GrabStateUpdatedEvent;
};
DECLARE_EVENT_SixParams(
ASGPawn, FTouchStateUpdatedEvent,
const USGVirtualHandComponent*, const AActor*, const AActor*, const AActor*, const AActor*, const AActor*);
DECLARE_EVENT_OneParam(ASGVirtualHandActor, FTouchStateUpdatedEvent, const FSGTouchState& TouchState)
FTouchStateUpdatedEvent& OnTouchStateUpdated()
{
@@ -155,58 +155,16 @@ private:
private:
UPROPERTY(Transient)
AActor* ActorLeftThumbCanGrab;
FSGGrabState LeftHandGrabState;
UPROPERTY(Transient)
AActor* ActorLeftIndexCanGrab;
FSGTouchState LeftHandTouchState;
UPROPERTY(Transient)
AActor* ActorLeftMiddleCanGrab;
FSGGrabState RightHandGrabState;
UPROPERTY(Transient)
AActor* ActorLeftHandGrabbing;
UPROPERTY(Transient)
AActor* ActorLeftThumbTouching;
UPROPERTY(Transient)
AActor* ActorLeftIndexTouching;
UPROPERTY(Transient)
AActor* ActorLeftMiddleTouching;
UPROPERTY(Transient)
AActor* ActorLeftRingTouching;
UPROPERTY(Transient)
AActor* ActorLeftPinkyTouching;
UPROPERTY(Transient)
AActor* ActorRightThumbCanGrab;
UPROPERTY(Transient)
AActor* ActorRightIndexCanGrab;
UPROPERTY(Transient)
AActor* ActorRightMiddleCanGrab;
UPROPERTY(Transient)
AActor* ActorRightHandGrabbing;
UPROPERTY(Transient)
AActor* ActorRightThumbTouching;
UPROPERTY(Transient)
AActor* ActorRightIndexTouching;
UPROPERTY(Transient)
AActor* ActorRightMiddleTouching;
UPROPERTY(Transient)
AActor* ActorRightRingTouching;
UPROPERTY(Transient)
AActor* ActorRightPinkyTouching;
FSGTouchState RightHandTouchState;
public:
FORCEINLINE UCameraComponent* GetCamera() const
@@ -579,36 +537,36 @@ protected:
public:
FORCEINLINE bool CanLeftHandGrab(const AActor* Actor) const
{
return !IsLeftHandGrabbing() && ((IsValid(Actor) && Actor == ActorLeftThumbCanGrab)
&& (Actor == ActorLeftIndexCanGrab || Actor == ActorLeftMiddleCanGrab));
return !IsLeftHandGrabbing() && ((IsValid(Actor) && Actor == LeftHandGrabState.ActorThumbCanGrab)
&& (Actor == LeftHandGrabState.ActorIndexCanGrab || Actor == LeftHandGrabState.ActorMiddleCanGrab));
}
FORCEINLINE bool IsLeftHandGrabbing(const AActor* Actor) const
{
return IsValid(Actor) && ActorLeftHandGrabbing == Actor;
return IsValid(Actor) && LeftHandGrabState.GrabbedActor == Actor;
}
bool IsLeftHandGrabbing(AActor*& OutActor) const;
FORCEINLINE bool IsLeftHandGrabbing() const
{
return IsValid(ActorLeftHandGrabbing);
return IsValid(LeftHandGrabState.GrabbedActor);
}
FORCEINLINE bool CanRightHandGrab(const AActor* Actor) const
{
return !IsRightHandGrabbing() && ((IsValid(Actor) && Actor == ActorRightThumbCanGrab)
&& (Actor == ActorRightIndexCanGrab || Actor == ActorRightMiddleCanGrab));
return !IsRightHandGrabbing() && ((IsValid(Actor) && Actor == RightHandGrabState.ActorThumbCanGrab)
&& (Actor == RightHandGrabState.ActorIndexCanGrab || Actor == RightHandGrabState.ActorMiddleCanGrab));
}
FORCEINLINE bool IsRightHandGrabbing(const AActor* Actor) const
{
return IsValid(Actor) && ActorRightHandGrabbing == Actor;
return IsValid(Actor) && RightHandGrabState.GrabbedActor == Actor;
}
FORCEINLINE bool IsRightHandGrabbing() const
{
return IsValid(ActorRightHandGrabbing);
return IsValid(RightHandGrabState.GrabbedActor);
}
bool IsRightHandGrabbing(AActor*& OutActor) const;
@@ -631,17 +589,17 @@ public:
}
public:
FORCEINLINE void GrabLeft(AActor* Actor)
FORCEINLINE void GrabLeft(AActor* Actor, UPrimitiveComponent* Component)
{
Grab(HandLeft, Actor);
Grab(HandLeft, Actor, Component);
}
FORCEINLINE void GrabRight(AActor* Actor)
FORCEINLINE void GrabRight(AActor* Actor, UPrimitiveComponent* Component)
{
Grab(HandRight, Actor);
Grab(HandRight, Actor, Component);
}
void Grab(USGVirtualHandComponent* Hand, AActor* Actor);
void Grab(USGVirtualHandComponent* Hand, AActor* Actor, UPrimitiveComponent* Component);
void ReleaseLeft();
@@ -41,6 +41,9 @@
#include "Templates/UniquePtr.h"
#include "UObject/NameTypes.h"
#include "SenseGlove/Haptics/SGGrabState.h"
#include "SenseGlove/Haptics/SGTouchState.h"
#include "SGVirtualHandActor.generated.h"
class USceneComponent;
@@ -58,19 +61,14 @@ class SENSEGLOVE_API ASGVirtualHandActor : public AActor
GENERATED_UCLASS_BODY()
public:
DECLARE_EVENT_FourParams(
ASGVirtualHandActor, FGrabStateUpdatedEvent, const USGVirtualHandComponent*,
const AActor* ActorThumbCanGrab, const AActor* ActorIndexCanGrab, const AActor* ActorMiddleCanGrab);
DECLARE_EVENT_OneParam(ASGVirtualHandActor, FGrabStateUpdatedEvent, const FSGGrabState& GrabState);
FGrabStateUpdatedEvent& OnGrabStateUpdated()
{
return GrabStateUpdatedEvent;
};
DECLARE_EVENT_SixParams(
ASGVirtualHandActor, FTouchStateUpdatedEvent, const USGVirtualHandComponent*,
const AActor* ActorThumbTouching, const AActor* ActorIndexTouching, const AActor* ActorMiddleTouching,
const AActor* ActorRingTouching, const AActor* ActorPinkyTouching);
DECLARE_EVENT_OneParam(ASGVirtualHandActor, FTouchStateUpdatedEvent, const FSGTouchState& TouchState)
FTouchStateUpdatedEvent& OnTouchStateUpdated()
{
@@ -128,28 +126,10 @@ private:
private:
UPROPERTY(Transient)
AActor* ActorThumbCanGrab;
FSGGrabState GrabState;
UPROPERTY(Transient)
AActor* ActorIndexCanGrab;
UPROPERTY(Transient)
AActor* ActorMiddleCanGrab;
UPROPERTY(Transient)
AActor* ActorThumbTouching;
UPROPERTY(Transient)
AActor* ActorIndexTouching;
UPROPERTY(Transient)
AActor* ActorMiddleTouching;
UPROPERTY(Transient)
AActor* ActorRingTouching;
UPROPERTY(Transient)
AActor* ActorPinkyTouching;
FSGTouchState TouchState;
public:
FORCEINLINE USGWristTrackerComponent* GetWristTracker() const
@@ -351,7 +331,7 @@ public:
FORCEINLINE bool CanGrab(const AActor* Actor) const
{
return ((IsValid(Actor) && Actor == ActorThumbCanGrab)
&& (Actor == ActorIndexCanGrab || Actor == ActorMiddleCanGrab));
return ((IsValid(Actor) && Actor == GrabState.ActorThumbCanGrab)
&& (Actor == GrabState.ActorIndexCanGrab || Actor == GrabState.ActorMiddleCanGrab));
}
};
@@ -0,0 +1,92 @@
/**
* @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
*
*
*/
#pragma once
#include "UObject/ObjectMacros.h"
#include "SGGrabState.generated.h"
class AActor;
class UPrimitiveComponent;
class USGVirtualHandComponent;
USTRUCT(BlueprintType)
struct SENSEGLOVE_API FSGGrabState
{
GENERATED_USTRUCT_BODY()
public:
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "SenseGlove")
USGVirtualHandComponent* Hand;
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "SenseGlove")
AActor* ActorThumbCanGrab;
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "SenseGlove")
UPrimitiveComponent* ComponentThumbCanGrab;
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "SenseGlove")
AActor* ActorIndexCanGrab;
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "SenseGlove")
UPrimitiveComponent* ComponentIndexCanGrab;
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "SenseGlove")
AActor* ActorMiddleCanGrab;
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "SenseGlove")
UPrimitiveComponent* ComponentMiddleCanGrab;
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "SenseGlove")
AActor* GrabbedActor;
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "SenseGlove")
UPrimitiveComponent* GrabbedComponent;
public:
FSGGrabState();
explicit FSGGrabState(USGVirtualHandComponent* InHand,
AActor* InActorThumbCanGrab,
UPrimitiveComponent* InComponentThumbCanGrab,
AActor* InActorIndexCanGrab,
UPrimitiveComponent* InComponentIndexCanGrab,
AActor* InActorMiddleCanGrab,
UPrimitiveComponent* InComponentMiddleCanGrab,
AActor* InGrabbedActor,
UPrimitiveComponent* InGrabbedComponent);
};
@@ -0,0 +1,79 @@
/**
* @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
*
*
*/
#pragma once
#include "UObject/ObjectMacros.h"
#include "SGTouchState.generated.h"
class AActor;
class USGVirtualHandComponent;
USTRUCT(BlueprintType)
struct SENSEGLOVE_API FSGTouchState
{
GENERATED_USTRUCT_BODY()
public:
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "SenseGlove")
USGVirtualHandComponent* Hand;
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "SenseGlove")
AActor* ActorThumbTouching;
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "SenseGlove")
AActor* ActorIndexTouching;
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "SenseGlove")
AActor* ActorMiddleTouching;
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "SenseGlove")
AActor* ActorRingTouching;
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "SenseGlove")
AActor* ActorPinkyTouching;
public:
FSGTouchState();
explicit FSGTouchState(USGVirtualHandComponent* InHand,
AActor* InActorThumbTouching,
AActor* InActorIndexTouching,
AActor* InActorMiddleTouching,
AActor* InActorRingTouching,
AActor* InActorPinkyTouching);
};
@@ -197,7 +197,8 @@ bool UPawnKismetLibrary::IsGrabbing_Actor(const ASGPawn* Pawn, const USGVirtualH
return Pawn->IsGrabbing(Hand, Actor);
}
bool UPawnKismetLibrary::IsGrabbing_OutActor(const ASGPawn* Pawn, const USGVirtualHandComponent* Hand, AActor*& OutActor)
bool UPawnKismetLibrary::IsGrabbing_OutActor(const ASGPawn* Pawn, const USGVirtualHandComponent* Hand,
AActor*& OutActor)
{
return Pawn->IsGrabbing(Hand, OutActor);
}
@@ -205,4 +206,35 @@ bool UPawnKismetLibrary::IsGrabbing_OutActor(const ASGPawn* Pawn, const USGVirtu
bool UPawnKismetLibrary::IsGrabbing(const ASGPawn* Pawn, const USGVirtualHandComponent* Hand)
{
return Pawn->IsGrabbing(Hand);
}
void UPawnKismetLibrary::GrabLeft(ASGPawn* Pawn, AActor* Actor, UPrimitiveComponent* Component)
{
Pawn->GrabLeft(Actor, Component);
}
void UPawnKismetLibrary::GrabRight(ASGPawn* Pawn, AActor* Actor, UPrimitiveComponent* Component)
{
Pawn->GrabRight(Actor, Component);
}
void UPawnKismetLibrary::Grab(
ASGPawn* Pawn, USGVirtualHandComponent* Hand, AActor* Actor, UPrimitiveComponent* Component)
{
Pawn->Grab(Hand, Actor, Component);
}
void UPawnKismetLibrary::ReleaseLeft(ASGPawn* Pawn)
{
Pawn->ReleaseLeft();
}
void UPawnKismetLibrary::ReleaseRight(ASGPawn* Pawn)
{
Pawn->ReleaseRight();
}
void UPawnKismetLibrary::Release(ASGPawn* Pawn, const USGVirtualHandComponent* Hand)
{
Pawn->Release(Hand);
}
@@ -160,4 +160,22 @@ public:
UFUNCTION(BlueprintPure, Category="SenseGlove | Game Framework | Pawn")
static bool IsGrabbing(const ASGPawn* Pawn, const USGVirtualHandComponent* Hand);
UFUNCTION(BlueprintCallable, Category="SenseGlove | Game Framework | Pawn")
static void GrabLeft(UPARAM(ref) ASGPawn* Pawn, AActor* Actor, UPrimitiveComponent* Component);
UFUNCTION(BlueprintCallable, Category="SenseGlove | Game Framework | Pawn")
static void GrabRight(UPARAM(ref) ASGPawn* Pawn, AActor* Actor, UPrimitiveComponent* Component);
UFUNCTION(BlueprintCallable, Category="SenseGlove | Game Framework | Pawn")
void Grab(UPARAM(ref) ASGPawn* Pawn, USGVirtualHandComponent* Hand, AActor* Actor, UPrimitiveComponent* Component);
UFUNCTION(BlueprintCallable, Category="SenseGlove | Game Framework | Pawn")
void ReleaseLeft(UPARAM(ref) ASGPawn* Pawn);
UFUNCTION(BlueprintCallable, Category="SenseGlove | Game Framework | Pawn")
void ReleaseRight(UPARAM(ref) ASGPawn* Pawn);
UFUNCTION(BlueprintCallable, Category="SenseGlove | Game Framework | Pawn")
static void Release(UPARAM(ref) ASGPawn* Pawn, const USGVirtualHandComponent* Hand);
};