diff --git a/Source/SenseGlove/Private/SenseGlove/GameFramework/SGPawn.cpp b/Source/SenseGlove/Private/SenseGlove/GameFramework/SGPawn.cpp index 46bfd594..1ebb27a0 100644 --- a/Source/SenseGlove/Private/SenseGlove/GameFramework/SGPawn.cpp +++ b/Source/SenseGlove/Private/SenseGlove/GameFramework/SGPawn.cpp @@ -38,6 +38,8 @@ #include "Camera/CameraComponent.h" #include "Components/SphereComponent.h" +#include "SenseGlove/Components/SGGrabComponent.h" +#include "SenseGlove/Components/SGTouchComponent.h" #include "SenseGlove/Components/SGVirtualHandComponent.h" #include "SenseGlove/Components/SGWristTrackerComponent.h" @@ -424,6 +426,26 @@ ASGPawn::ASGPawn(const FObjectInitializer& ObjectInitializer) RightPinkyFingertipTouchCollider->SetCollisionResponseToChannel(ECC_PhysicsBody, ECR_Overlap); RightPinkyFingertipTouchCollider->SetCollisionResponseToChannel(ECC_Vehicle, ECR_Overlap); RightPinkyFingertipTouchCollider->SetCollisionResponseToChannel(ECC_Destructible, ECR_Overlap); + + ActorLeftThumbCanGrab = nullptr; + ActorLeftIndexCanGrab = nullptr; + ActorLeftMiddleCanGrab = nullptr; + + ActorLeftThumbTouching = nullptr; + ActorLeftIndexTouching = nullptr; + ActorLeftMiddleTouching = nullptr; + ActorLeftRingTouching = nullptr; + ActorLeftPinkyTouching = nullptr; + + ActorRightThumbCanGrab = nullptr; + ActorRightIndexCanGrab = nullptr; + ActorRightMiddleCanGrab = nullptr; + + ActorRightThumbTouching = nullptr; + ActorRightIndexTouching = nullptr; + ActorRightMiddleTouching = nullptr; + ActorRightRingTouching = nullptr; + ActorRightPinkyTouching = nullptr; } void ASGPawn::BeginPlay() @@ -485,6 +507,16 @@ void ASGPawn::OnLeftThumbFingertipGrabColliderOverlapBegins( const bool bFromSweep, const FHitResult& SweepResult) { + (void)OverlappedComponent; + (void)OtherComp; + (void)OtherBodyIndex; + (void)bFromSweep; + (void)SweepResult; + + if (USGGrabComponent::IsGrabbable(OtherActor)) + { + ActorLeftThumbCanGrab = OtherActor; + } } void ASGPawn::OnLeftThumbFingertipGrabColliderOverlapEnds( @@ -493,6 +525,14 @@ void ASGPawn::OnLeftThumbFingertipGrabColliderOverlapEnds( UPrimitiveComponent* OtherComp, const int32 OtherBodyIndex) { + (void)OverlappedComponent; + (void)OtherComp; + (void)OtherBodyIndex; + + if (ActorLeftThumbCanGrab == OtherActor) + { + ActorLeftThumbCanGrab = nullptr; + } } void ASGPawn::OnLeftIndexFingertipGrabColliderOverlapBegins( @@ -503,6 +543,16 @@ void ASGPawn::OnLeftIndexFingertipGrabColliderOverlapBegins( const bool bFromSweep, const FHitResult& SweepResult) { + (void)OverlappedComponent; + (void)OtherComp; + (void)OtherBodyIndex; + (void)bFromSweep; + (void)SweepResult; + + if (USGGrabComponent::IsGrabbable(OtherActor)) + { + ActorLeftIndexCanGrab = OtherActor; + } } void ASGPawn::OnLeftIndexFingertipGrabColliderOverlapEnds( @@ -511,6 +561,14 @@ void ASGPawn::OnLeftIndexFingertipGrabColliderOverlapEnds( UPrimitiveComponent* OtherComp, const int32 OtherBodyIndex) { + (void)OverlappedComponent; + (void)OtherComp; + (void)OtherBodyIndex; + + if (ActorLeftIndexCanGrab == OtherActor) + { + ActorLeftIndexCanGrab = nullptr; + } } void ASGPawn::OnLeftMiddleFingertipGrabColliderOverlapBegins( @@ -521,6 +579,16 @@ void ASGPawn::OnLeftMiddleFingertipGrabColliderOverlapBegins( const bool bFromSweep, const FHitResult& SweepResult) { + (void)OverlappedComponent; + (void)OtherComp; + (void)OtherBodyIndex; + (void)bFromSweep; + (void)SweepResult; + + if (USGGrabComponent::IsGrabbable(OtherActor)) + { + ActorLeftMiddleCanGrab = OtherActor; + } } void ASGPawn::OnLeftMiddleFingertipGrabColliderOverlapEnds( @@ -529,6 +597,14 @@ void ASGPawn::OnLeftMiddleFingertipGrabColliderOverlapEnds( UPrimitiveComponent* OtherComp, const int32 OtherBodyIndex) { + (void)OverlappedComponent; + (void)OtherComp; + (void)OtherBodyIndex; + + if (ActorLeftMiddleCanGrab == OtherActor) + { + ActorLeftMiddleCanGrab = nullptr; + } } void ASGPawn::OnLeftThumbFingertipTouchColliderOverlapBegins( @@ -539,6 +615,16 @@ void ASGPawn::OnLeftThumbFingertipTouchColliderOverlapBegins( const bool bFromSweep, const FHitResult& SweepResult) { + (void)OverlappedComponent; + (void)OtherComp; + (void)OtherBodyIndex; + (void)bFromSweep; + (void)SweepResult; + + if (USGTouchComponent::IsTouchable(OtherActor)) + { + ActorLeftThumbTouching = OtherActor; + } } void ASGPawn::OnLeftThumbFingertipTouchColliderOverlapEnds( @@ -547,6 +633,14 @@ void ASGPawn::OnLeftThumbFingertipTouchColliderOverlapEnds( UPrimitiveComponent* OtherComp, const int32 OtherBodyIndex) { + (void)OverlappedComponent; + (void)OtherComp; + (void)OtherBodyIndex; + + if (ActorLeftThumbTouching == OtherActor) + { + ActorLeftThumbTouching = nullptr; + } } void ASGPawn::OnLeftIndexFingertipTouchColliderOverlapBegins( @@ -557,6 +651,16 @@ void ASGPawn::OnLeftIndexFingertipTouchColliderOverlapBegins( const bool bFromSweep, const FHitResult& SweepResult) { + (void)OverlappedComponent; + (void)OtherComp; + (void)OtherBodyIndex; + (void)bFromSweep; + (void)SweepResult; + + if (USGTouchComponent::IsTouchable(OtherActor)) + { + ActorLeftIndexTouching = OtherActor; + } } void ASGPawn::OnLeftIndexFingertipTouchColliderOverlapEnds( @@ -565,6 +669,14 @@ void ASGPawn::OnLeftIndexFingertipTouchColliderOverlapEnds( UPrimitiveComponent* OtherComp, const int32 OtherBodyIndex) { + (void)OverlappedComponent; + (void)OtherComp; + (void)OtherBodyIndex; + + if (ActorLeftIndexTouching == OtherActor) + { + ActorLeftIndexTouching = nullptr; + } } void ASGPawn::OnLeftMiddleFingertipTouchColliderOverlapBegins( @@ -575,6 +687,16 @@ void ASGPawn::OnLeftMiddleFingertipTouchColliderOverlapBegins( const bool bFromSweep, const FHitResult& SweepResult) { + (void)OverlappedComponent; + (void)OtherComp; + (void)OtherBodyIndex; + (void)bFromSweep; + (void)SweepResult; + + if (USGTouchComponent::IsTouchable(OtherActor)) + { + ActorLeftMiddleTouching = OtherActor; + } } void ASGPawn::OnLeftMiddleFingertipTouchColliderOverlapEnds( @@ -583,6 +705,14 @@ void ASGPawn::OnLeftMiddleFingertipTouchColliderOverlapEnds( UPrimitiveComponent* OtherComp, const int32 OtherBodyIndex) { + (void)OverlappedComponent; + (void)OtherComp; + (void)OtherBodyIndex; + + if (ActorLeftMiddleTouching == OtherActor) + { + ActorLeftMiddleTouching = nullptr; + } } void ASGPawn::OnLeftRingFingertipTouchColliderOverlapBegins( @@ -593,6 +723,16 @@ void ASGPawn::OnLeftRingFingertipTouchColliderOverlapBegins( const bool bFromSweep, const FHitResult& SweepResult) { + (void)OverlappedComponent; + (void)OtherComp; + (void)OtherBodyIndex; + (void)bFromSweep; + (void)SweepResult; + + if (USGTouchComponent::IsTouchable(OtherActor)) + { + ActorLeftRingTouching = OtherActor; + } } void ASGPawn::OnLeftRingFingertipTouchColliderOverlapEnds( @@ -601,6 +741,14 @@ void ASGPawn::OnLeftRingFingertipTouchColliderOverlapEnds( UPrimitiveComponent* OtherComp, const int32 OtherBodyIndex) { + (void)OverlappedComponent; + (void)OtherComp; + (void)OtherBodyIndex; + + if (ActorLeftRingTouching == OtherActor) + { + ActorLeftRingTouching = nullptr; + } } void ASGPawn::OnLeftPinkyFingertipTouchColliderOverlapBegins( @@ -611,6 +759,16 @@ void ASGPawn::OnLeftPinkyFingertipTouchColliderOverlapBegins( const bool bFromSweep, const FHitResult& SweepResult) { + (void)OverlappedComponent; + (void)OtherComp; + (void)OtherBodyIndex; + (void)bFromSweep; + (void)SweepResult; + + if (USGTouchComponent::IsTouchable(OtherActor)) + { + ActorLeftPinkyTouching = OtherActor; + } } void ASGPawn::OnLeftPinkyFingertipTouchColliderOverlapEnds( @@ -619,6 +777,14 @@ void ASGPawn::OnLeftPinkyFingertipTouchColliderOverlapEnds( UPrimitiveComponent* OtherComp, const int32 OtherBodyIndex) { + (void)OverlappedComponent; + (void)OtherComp; + (void)OtherBodyIndex; + + if (ActorLeftPinkyTouching == OtherActor) + { + ActorLeftPinkyTouching = nullptr; + } } void ASGPawn::OnRightThumbFingertipGrabColliderOverlapBegins( @@ -629,6 +795,16 @@ void ASGPawn::OnRightThumbFingertipGrabColliderOverlapBegins( const bool bFromSweep, const FHitResult& SweepResult) { + (void)OverlappedComponent; + (void)OtherComp; + (void)OtherBodyIndex; + (void)bFromSweep; + (void)SweepResult; + + if (USGGrabComponent::IsGrabbable(OtherActor)) + { + ActorRightThumbCanGrab = OtherActor; + } } void ASGPawn::OnRightThumbFingertipGrabColliderOverlapEnds( @@ -637,6 +813,14 @@ void ASGPawn::OnRightThumbFingertipGrabColliderOverlapEnds( UPrimitiveComponent* OtherComp, const int32 OtherBodyIndex) { + (void)OverlappedComponent; + (void)OtherComp; + (void)OtherBodyIndex; + + if (ActorRightThumbCanGrab == OtherActor) + { + ActorRightThumbCanGrab = nullptr; + } } void ASGPawn::OnRightIndexFingertipGrabColliderOverlapBegins( @@ -647,6 +831,16 @@ void ASGPawn::OnRightIndexFingertipGrabColliderOverlapBegins( const bool bFromSweep, const FHitResult& SweepResult) { + (void)OverlappedComponent; + (void)OtherComp; + (void)OtherBodyIndex; + (void)bFromSweep; + (void)SweepResult; + + if (USGGrabComponent::IsGrabbable(OtherActor)) + { + ActorRightIndexCanGrab = OtherActor; + } } void ASGPawn::OnRightIndexFingertipGrabColliderOverlapEnds( @@ -655,6 +849,14 @@ void ASGPawn::OnRightIndexFingertipGrabColliderOverlapEnds( UPrimitiveComponent* OtherComp, const int32 OtherBodyIndex) { + (void)OverlappedComponent; + (void)OtherComp; + (void)OtherBodyIndex; + + if (ActorRightThumbCanGrab == OtherActor) + { + ActorRightIndexCanGrab = nullptr; + } } void ASGPawn::OnRightMiddleFingertipGrabColliderOverlapBegins( @@ -665,6 +867,16 @@ void ASGPawn::OnRightMiddleFingertipGrabColliderOverlapBegins( const bool bFromSweep, const FHitResult& SweepResult) { + (void)OverlappedComponent; + (void)OtherComp; + (void)OtherBodyIndex; + (void)bFromSweep; + (void)SweepResult; + + if (USGGrabComponent::IsGrabbable(OtherActor)) + { + ActorRightMiddleCanGrab = OtherActor; + } } void ASGPawn::OnRightMiddleFingertipGrabColliderOverlapEnds( @@ -673,6 +885,14 @@ void ASGPawn::OnRightMiddleFingertipGrabColliderOverlapEnds( UPrimitiveComponent* OtherComp, const int32 OtherBodyIndex) { + (void)OverlappedComponent; + (void)OtherComp; + (void)OtherBodyIndex; + + if (ActorRightMiddleCanGrab == OtherActor) + { + ActorRightMiddleCanGrab = nullptr; + } } void ASGPawn::OnRightThumbFingertipTouchColliderOverlapBegins( @@ -683,6 +903,16 @@ void ASGPawn::OnRightThumbFingertipTouchColliderOverlapBegins( const bool bFromSweep, const FHitResult& SweepResult) { + (void)OverlappedComponent; + (void)OtherComp; + (void)OtherBodyIndex; + (void)bFromSweep; + (void)SweepResult; + + if (USGTouchComponent::IsTouchable(OtherActor)) + { + ActorRightThumbTouching = OtherActor; + } } void ASGPawn::OnRightThumbFingertipTouchColliderOverlapEnds( @@ -691,6 +921,14 @@ void ASGPawn::OnRightThumbFingertipTouchColliderOverlapEnds( UPrimitiveComponent* OtherComp, const int32 OtherBodyIndex) { + (void)OverlappedComponent; + (void)OtherComp; + (void)OtherBodyIndex; + + if (ActorRightThumbTouching == OtherActor) + { + ActorRightThumbTouching = nullptr; + } } void ASGPawn::OnRightIndexFingertipTouchColliderOverlapBegins( @@ -701,6 +939,16 @@ void ASGPawn::OnRightIndexFingertipTouchColliderOverlapBegins( const bool bFromSweep, const FHitResult& SweepResult) { + (void)OverlappedComponent; + (void)OtherComp; + (void)OtherBodyIndex; + (void)bFromSweep; + (void)SweepResult; + + if (USGTouchComponent::IsTouchable(OtherActor)) + { + ActorRightIndexTouching = OtherActor; + } } void ASGPawn::OnRightIndexFingertipTouchColliderOverlapEnds( @@ -709,6 +957,14 @@ void ASGPawn::OnRightIndexFingertipTouchColliderOverlapEnds( UPrimitiveComponent* OtherComp, const int32 OtherBodyIndex) { + (void)OverlappedComponent; + (void)OtherComp; + (void)OtherBodyIndex; + + if (ActorRightIndexTouching == OtherActor) + { + ActorRightIndexTouching = nullptr; + } } void ASGPawn::OnRightMiddleFingertipTouchColliderOverlapBegins( @@ -719,6 +975,16 @@ void ASGPawn::OnRightMiddleFingertipTouchColliderOverlapBegins( const bool bFromSweep, const FHitResult& SweepResult) { + (void)OverlappedComponent; + (void)OtherComp; + (void)OtherBodyIndex; + (void)bFromSweep; + (void)SweepResult; + + if (USGTouchComponent::IsTouchable(OtherActor)) + { + ActorRightMiddleTouching = OtherActor; + } } void ASGPawn::OnRightMiddleFingertipTouchColliderOverlapEnds( @@ -727,6 +993,14 @@ void ASGPawn::OnRightMiddleFingertipTouchColliderOverlapEnds( UPrimitiveComponent* OtherComp, const int32 OtherBodyIndex) { + (void)OverlappedComponent; + (void)OtherComp; + (void)OtherBodyIndex; + + if (ActorRightMiddleTouching == OtherActor) + { + ActorRightMiddleTouching = nullptr; + } } void ASGPawn::OnRightRingFingertipTouchColliderOverlapBegins( @@ -737,6 +1011,16 @@ void ASGPawn::OnRightRingFingertipTouchColliderOverlapBegins( const bool bFromSweep, const FHitResult& SweepResult) { + (void)OverlappedComponent; + (void)OtherComp; + (void)OtherBodyIndex; + (void)bFromSweep; + (void)SweepResult; + + if (USGTouchComponent::IsTouchable(OtherActor)) + { + ActorRightRingTouching = OtherActor; + } } void ASGPawn::OnRightRingFingertipTouchColliderOverlapEnds( @@ -745,6 +1029,14 @@ void ASGPawn::OnRightRingFingertipTouchColliderOverlapEnds( UPrimitiveComponent* OtherComp, const int32 OtherBodyIndex) { + (void)OverlappedComponent; + (void)OtherComp; + (void)OtherBodyIndex; + + if (ActorRightRingTouching == OtherActor) + { + ActorRightRingTouching = nullptr; + } } void ASGPawn::OnRightPinkyFingertipTouchColliderOverlapBegins( @@ -755,6 +1047,16 @@ void ASGPawn::OnRightPinkyFingertipTouchColliderOverlapBegins( const bool bFromSweep, const FHitResult& SweepResult) { + (void)OverlappedComponent; + (void)OtherComp; + (void)OtherBodyIndex; + (void)bFromSweep; + (void)SweepResult; + + if (USGTouchComponent::IsTouchable(OtherActor)) + { + ActorRightPinkyTouching = OtherActor; + } } void ASGPawn::OnRightPinkyFingertipTouchColliderOverlapEnds( @@ -763,6 +1065,14 @@ void ASGPawn::OnRightPinkyFingertipTouchColliderOverlapEnds( UPrimitiveComponent* OtherComp, const int32 OtherBodyIndex) { + (void)OverlappedComponent; + (void)OtherComp; + (void)OtherBodyIndex; + + if (ActorRightPinkyTouching == OtherActor) + { + ActorRightPinkyTouching = nullptr; + } } ASGPawn::FImpl::FImpl(ASGPawn* InOwner) diff --git a/Source/SenseGlove/Private/SenseGlove/GameFramework/SGVirtualHandActor.cpp b/Source/SenseGlove/Private/SenseGlove/GameFramework/SGVirtualHandActor.cpp index 9644aa6f..b3192113 100644 --- a/Source/SenseGlove/Private/SenseGlove/GameFramework/SGVirtualHandActor.cpp +++ b/Source/SenseGlove/Private/SenseGlove/GameFramework/SGVirtualHandActor.cpp @@ -37,6 +37,8 @@ #include "Components/SphereComponent.h" +#include "SenseGlove/Components/SGGrabComponent.h" +#include "SenseGlove/Components/SGTouchComponent.h" #include "SenseGlove/Components/SGVirtualHandComponent.h" #include "SenseGlove/Components/SGWristTrackerComponent.h" @@ -71,6 +73,9 @@ struct ASGVirtualHandActor::FImpl void BindFingerTouchOverlapEvents(); void UnbindFingerTouchOverlapEvents(); + + bool IsFingerGrabbing(AActor* Actor) const; + bool IsFingerTouching(AActor* Actor) const; }; ASGVirtualHandActor::ASGVirtualHandActor(const FObjectInitializer& ObjectInitializer) @@ -243,6 +248,16 @@ ASGVirtualHandActor::ASGVirtualHandActor(const FObjectInitializer& ObjectInitial WristTracker->SetupAttachment(RootComponent); WristTracker->SetRight(VirtualHand->IsRight()); + + ActorThumbCanGrab = nullptr; + ActorIndexCanGrab = nullptr; + ActorMiddleCanGrab = nullptr; + + ActorThumbTouching = nullptr; + ActorIndexTouching = nullptr; + ActorMiddleTouching = nullptr; + ActorRingTouching = nullptr; + ActorPinkyTouching = nullptr; } void ASGVirtualHandActor::BeginPlay() @@ -283,6 +298,282 @@ void ASGVirtualHandActor::PreInitializeComponents() WristTracker->SetRight(VirtualHand->IsRight()); } +void ASGVirtualHandActor::OnThumbFingertipGrabColliderOverlapBegins( + UPrimitiveComponent* OverlappedComponent, + AActor* OtherActor, + UPrimitiveComponent* OtherComp, + const int32 OtherBodyIndex, + const bool bFromSweep, + const FHitResult& SweepResult) +{ + (void)OverlappedComponent; + (void)OtherComp; + (void)OtherBodyIndex; + (void)bFromSweep; + (void)SweepResult; + + if (USGGrabComponent::IsGrabbable(OtherActor)) + { + ActorThumbCanGrab = OtherActor; + } +} + +void ASGVirtualHandActor::OnThumbFingertipGrabColliderOverlapEnds( + UPrimitiveComponent* OverlappedComponent, + AActor* OtherActor, + UPrimitiveComponent* OtherComp, + const int32 OtherBodyIndex) +{ + (void)OverlappedComponent; + (void)OtherComp; + (void)OtherBodyIndex; + + if (ActorThumbCanGrab == OtherActor) + { + ActorThumbCanGrab = nullptr; + } +} + +void ASGVirtualHandActor::OnIndexFingertipGrabColliderOverlapBegins( + UPrimitiveComponent* OverlappedComponent, + AActor* OtherActor, + UPrimitiveComponent* OtherComp, + const int32 OtherBodyIndex, + const bool bFromSweep, + const FHitResult& SweepResult) +{ + (void)OverlappedComponent; + (void)OtherComp; + (void)OtherBodyIndex; + (void)bFromSweep; + (void)SweepResult; + + if (USGGrabComponent::IsGrabbable(OtherActor)) + { + ActorIndexCanGrab = OtherActor; + } +} + +void ASGVirtualHandActor::OnIndexFingertipGrabColliderOverlapEnds( + UPrimitiveComponent* OverlappedComponent, + AActor* OtherActor, + UPrimitiveComponent* OtherComp, + const int32 OtherBodyIndex) +{ + (void)OverlappedComponent; + (void)OtherComp; + (void)OtherBodyIndex; + + if (ActorIndexCanGrab == OtherActor) + { + ActorIndexCanGrab = nullptr; + } +} + +void ASGVirtualHandActor::OnMiddleFingertipGrabColliderOverlapBegins( + UPrimitiveComponent* OverlappedComponent, + AActor* OtherActor, + UPrimitiveComponent* OtherComp, + const int32 OtherBodyIndex, + const bool bFromSweep, + const FHitResult& SweepResult) +{ + (void)OverlappedComponent; + (void)OtherComp; + (void)OtherBodyIndex; + (void)bFromSweep; + (void)SweepResult; + + if (USGGrabComponent::IsGrabbable(OtherActor)) + { + ActorMiddleCanGrab = OtherActor; + } +} + +void ASGVirtualHandActor::OnMiddleFingertipGrabColliderOverlapEnds( + UPrimitiveComponent* OverlappedComponent, + AActor* OtherActor, + UPrimitiveComponent* OtherComp, + const int32 OtherBodyIndex) +{ + (void)OverlappedComponent; + (void)OtherComp; + (void)OtherBodyIndex; + + if (ActorMiddleCanGrab == OtherActor) + { + ActorMiddleCanGrab = nullptr; + } +} + +void ASGVirtualHandActor::OnThumbFingertipTouchColliderOverlapBegins( + UPrimitiveComponent* OverlappedComponent, + AActor* OtherActor, + UPrimitiveComponent* OtherComp, + const int32 OtherBodyIndex, + const bool bFromSweep, + const FHitResult& SweepResult) +{ + (void)OverlappedComponent; + (void)OtherComp; + (void)OtherBodyIndex; + (void)bFromSweep; + (void)SweepResult; + + if (USGTouchComponent::IsTouchable(OtherActor)) + { + ActorThumbTouching = OtherActor; + } +} + +void ASGVirtualHandActor::OnThumbFingertipTouchColliderOverlapEnds( + UPrimitiveComponent* OverlappedComponent, + AActor* OtherActor, + UPrimitiveComponent* OtherComp, + const int32 OtherBodyIndex) +{ + (void)OverlappedComponent; + (void)OtherComp; + (void)OtherBodyIndex; + + if (ActorThumbTouching == OtherActor) + { + ActorThumbTouching = nullptr; + } +} + +void ASGVirtualHandActor::OnIndexFingertipTouchColliderOverlapBegins( + UPrimitiveComponent* OverlappedComponent, + AActor* OtherActor, + UPrimitiveComponent* OtherComp, + const int32 OtherBodyIndex, + const bool bFromSweep, + const FHitResult& SweepResult) +{ + (void)OverlappedComponent; + (void)OtherComp; + (void)OtherBodyIndex; + (void)bFromSweep; + (void)SweepResult; + + if (USGTouchComponent::IsTouchable(OtherActor)) + { + ActorIndexTouching = OtherActor; + } +} + +void ASGVirtualHandActor::OnIndexFingertipTouchColliderOverlapEnds( + UPrimitiveComponent* OverlappedComponent, + AActor* OtherActor, + UPrimitiveComponent* OtherComp, + const int32 OtherBodyIndex) +{ + (void)OverlappedComponent; + (void)OtherComp; + (void)OtherBodyIndex; + + if (ActorIndexTouching == OtherActor) + { + ActorIndexTouching = nullptr; + } +} + +void ASGVirtualHandActor::OnMiddleFingertipTouchColliderOverlapBegins( + UPrimitiveComponent* OverlappedComponent, + AActor* OtherActor, + UPrimitiveComponent* OtherComp, + const int32 OtherBodyIndex, + const bool bFromSweep, + const FHitResult& SweepResult) +{ + (void)OverlappedComponent; + (void)OtherComp; + (void)OtherBodyIndex; + (void)bFromSweep; + (void)SweepResult; + + if (USGTouchComponent::IsTouchable(OtherActor)) + { + ActorMiddleTouching = OtherActor; + } +} + +void ASGVirtualHandActor::OnMiddleFingertipTouchColliderOverlapEnds( + UPrimitiveComponent* OverlappedComponent, + AActor* OtherActor, + UPrimitiveComponent* OtherComp, + const int32 OtherBodyIndex) +{ + (void)OverlappedComponent; + (void)OtherComp; + (void)OtherBodyIndex; + + if (ActorMiddleTouching == OtherActor) + { + ActorMiddleTouching = nullptr; + } +} + +void ASGVirtualHandActor::OnRingFingertipTouchColliderOverlapBegins( + UPrimitiveComponent* OverlappedComponent, + AActor* OtherActor, + UPrimitiveComponent* OtherComp, + const int32 OtherBodyIndex, + const bool bFromSweep, + const FHitResult& SweepResult) +{ + if (USGTouchComponent::IsTouchable(OtherActor)) + { + ActorRingTouching = OtherActor; + } +} + +void ASGVirtualHandActor::OnRingFingertipTouchColliderOverlapEnds( + UPrimitiveComponent* OverlappedComponent, + AActor* OtherActor, + UPrimitiveComponent* OtherComp, + const int32 OtherBodyIndex) +{ + (void)OverlappedComponent; + (void)OtherComp; + (void)OtherBodyIndex; + + if (ActorRingTouching == OtherActor) + { + ActorRingTouching = nullptr; + } +} + +void ASGVirtualHandActor::OnPinkyFingertipTouchColliderOverlapBegins( + UPrimitiveComponent* OverlappedComponent, + AActor* OtherActor, + UPrimitiveComponent* OtherComp, + const int32 OtherBodyIndex, + const bool bFromSweep, + const FHitResult& SweepResult) +{ + if (USGTouchComponent::IsTouchable(OtherActor)) + { + ActorPinkyTouching = OtherActor; + } +} + +void ASGVirtualHandActor::OnPinkyFingertipTouchColliderOverlapEnds( + UPrimitiveComponent* OverlappedComponent, + AActor* OtherActor, + UPrimitiveComponent* OtherComp, + const int32 OtherBodyIndex) +{ + (void)OverlappedComponent; + (void)OtherComp; + (void)OtherBodyIndex; + + if (ActorPinkyTouching == OtherActor) + { + ActorPinkyTouching = nullptr; + } +} + bool ASGVirtualHandActor::IsLeft() const { return WristTracker->IsLeft() && VirtualHand->IsLeft(); @@ -304,150 +595,6 @@ bool ASGVirtualHandActor::IsGloveConnected() const return VirtualHand->IsGloveConnected(); } -void ASGVirtualHandActor::OnThumbFingertipGrabColliderOverlapBegins( - UPrimitiveComponent* OverlappedComponent, - AActor* OtherActor, - UPrimitiveComponent* OtherComp, - const int32 OtherBodyIndex, - const bool bFromSweep, - const FHitResult& SweepResult) -{ -} - -void ASGVirtualHandActor::OnThumbFingertipGrabColliderOverlapEnds( - UPrimitiveComponent* OverlappedComponent, - AActor* OtherActor, - UPrimitiveComponent* OtherComp, - const int32 OtherBodyIndex) -{ -} - -void ASGVirtualHandActor::OnIndexFingertipGrabColliderOverlapBegins( - UPrimitiveComponent* OverlappedComponent, - AActor* OtherActor, - UPrimitiveComponent* OtherComp, - const int32 OtherBodyIndex, - const bool bFromSweep, - const FHitResult& SweepResult) -{ -} - -void ASGVirtualHandActor::OnIndexFingertipGrabColliderOverlapEnds( - UPrimitiveComponent* OverlappedComponent, - AActor* OtherActor, - UPrimitiveComponent* OtherComp, - const int32 OtherBodyIndex) -{ -} - -void ASGVirtualHandActor::OnMiddleFingertipGrabColliderOverlapBegins( - UPrimitiveComponent* OverlappedComponent, - AActor* OtherActor, - UPrimitiveComponent* OtherComp, - const int32 OtherBodyIndex, - const bool bFromSweep, - const FHitResult& SweepResult) -{ -} - -void ASGVirtualHandActor::OnMiddleFingertipGrabColliderOverlapEnds( - UPrimitiveComponent* OverlappedComponent, - AActor* OtherActor, - UPrimitiveComponent* OtherComp, - const int32 OtherBodyIndex) -{ -} - -void ASGVirtualHandActor::OnThumbFingertipTouchColliderOverlapBegins( - UPrimitiveComponent* OverlappedComponent, - AActor* OtherActor, - UPrimitiveComponent* OtherComp, - const int32 OtherBodyIndex, - const bool bFromSweep, - const FHitResult& SweepResult) -{ -} - -void ASGVirtualHandActor::OnThumbFingertipTouchColliderOverlapEnds( - UPrimitiveComponent* OverlappedComponent, - AActor* OtherActor, - UPrimitiveComponent* OtherComp, - const int32 OtherBodyIndex) -{ -} - -void ASGVirtualHandActor::OnIndexFingertipTouchColliderOverlapBegins( - UPrimitiveComponent* OverlappedComponent, - AActor* OtherActor, - UPrimitiveComponent* OtherComp, - const int32 OtherBodyIndex, - const bool bFromSweep, - const FHitResult& SweepResult) -{ -} - -void ASGVirtualHandActor::OnIndexFingertipTouchColliderOverlapEnds( - UPrimitiveComponent* OverlappedComponent, - AActor* OtherActor, - UPrimitiveComponent* OtherComp, - const int32 OtherBodyIndex) -{ -} - -void ASGVirtualHandActor::OnMiddleFingertipTouchColliderOverlapBegins( - UPrimitiveComponent* OverlappedComponent, - AActor* OtherActor, - UPrimitiveComponent* OtherComp, - const int32 OtherBodyIndex, - const bool bFromSweep, - const FHitResult& SweepResult) -{ -} - -void ASGVirtualHandActor::OnMiddleFingertipTouchColliderOverlapEnds( - UPrimitiveComponent* OverlappedComponent, - AActor* OtherActor, - UPrimitiveComponent* OtherComp, - const int32 OtherBodyIndex) -{ -} - -void ASGVirtualHandActor::OnRingFingertipTouchColliderOverlapBegins( - UPrimitiveComponent* OverlappedComponent, - AActor* OtherActor, - UPrimitiveComponent* OtherComp, - const int32 OtherBodyIndex, - const bool bFromSweep, - const FHitResult& SweepResult) -{ -} - -void ASGVirtualHandActor::OnRingFingertipTouchColliderOverlapEnds( - UPrimitiveComponent* OverlappedComponent, - AActor* OtherActor, - UPrimitiveComponent* OtherComp, - const int32 OtherBodyIndex) -{ -} - -void ASGVirtualHandActor::OnPinkyFingertipTouchColliderOverlapBegins( - UPrimitiveComponent* OverlappedComponent, - AActor* OtherActor, - UPrimitiveComponent* OtherComp, - const int32 OtherBodyIndex, - const bool bFromSweep, - const FHitResult& SweepResult) -{ -} - -void ASGVirtualHandActor::OnPinkyFingertipTouchColliderOverlapEnds( - UPrimitiveComponent* OverlappedComponent, - AActor* OtherActor, - UPrimitiveComponent* OtherComp, - const int32 OtherBodyIndex) -{ -} - ASGVirtualHandActor::FImpl::FImpl(ASGVirtualHandActor* InOwner) : Owner(InOwner) { diff --git a/Source/SenseGlove/Public/SenseGlove/GameFramework/SGPawn.h b/Source/SenseGlove/Public/SenseGlove/GameFramework/SGPawn.h index ff92e5cb..f275d8cf 100644 --- a/Source/SenseGlove/Public/SenseGlove/GameFramework/SGPawn.h +++ b/Source/SenseGlove/Public/SenseGlove/GameFramework/SGPawn.h @@ -129,6 +129,55 @@ private: UPROPERTY(EditAnywhere, Category="SenseGlove", meta=(AllowPrivateAccess="false")) USphereComponent* RightPinkyFingertipTouchCollider; +private: + UPROPERTY(Transient) + AActor* ActorLeftThumbCanGrab; + + UPROPERTY(Transient) + AActor* ActorLeftIndexCanGrab; + + UPROPERTY(Transient) + AActor* ActorLeftMiddleCanGrab; + + 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* ActorRightThumbTouching; + + UPROPERTY(Transient) + AActor* ActorRightIndexTouching; + + UPROPERTY(Transient) + AActor* ActorRightMiddleTouching; + + UPROPERTY(Transient) + AActor* ActorRightRingTouching; + + UPROPERTY(Transient) + AActor* ActorRightPinkyTouching; + public: FORCEINLINE UCameraComponent* GetCamera() const { @@ -496,4 +545,17 @@ protected: AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex); + +public: + FORCEINLINE bool CanLeftHandGrab(const AActor* Actor) const + { + return ((IsValid(Actor) && Actor == ActorLeftThumbCanGrab) + && (Actor == ActorLeftIndexCanGrab || Actor == ActorLeftMiddleCanGrab)); + } + + FORCEINLINE bool CanRightHandGrab(const AActor* Actor) const + { + return ((IsValid(Actor) && Actor == ActorRightThumbCanGrab) + && (Actor == ActorRightIndexCanGrab || Actor == ActorRightMiddleCanGrab)); + } }; \ No newline at end of file diff --git a/Source/SenseGlove/Public/SenseGlove/GameFramework/SGVirtualHandActor.h b/Source/SenseGlove/Public/SenseGlove/GameFramework/SGVirtualHandActor.h index ec98e320..6a98ef7e 100644 --- a/Source/SenseGlove/Public/SenseGlove/GameFramework/SGVirtualHandActor.h +++ b/Source/SenseGlove/Public/SenseGlove/GameFramework/SGVirtualHandActor.h @@ -102,6 +102,31 @@ private: UPROPERTY(EditAnywhere, Category="SenseGlove", meta=(AllowPrivateAccess="false")) USphereComponent* PinkyFingertipTouchCollider; +private: + UPROPERTY(Transient) + AActor* ActorThumbCanGrab; + + 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; + public: FORCEINLINE USGWristTrackerComponent* GetWristTracker() const { @@ -164,13 +189,6 @@ public: virtual void EndPlay(const EEndPlayReason::Type EndPlayReason) override; virtual void PreInitializeComponents() override; -public: - bool IsLeft() const; - bool IsRight() const; - void SetRight(bool bRight); - - bool IsGloveConnected() const; - protected: UFUNCTION() virtual void OnThumbFingertipGrabColliderOverlapBegins( @@ -299,4 +317,17 @@ protected: AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex); + +public: + bool IsLeft() const; + bool IsRight() const; + void SetRight(bool bRight); + + bool IsGloveConnected() const; + + FORCEINLINE bool CanGrab(const AActor* Actor) const + { + return ((IsValid(Actor) && Actor == ActorThumbCanGrab) + && (Actor == ActorIndexCanGrab || Actor == ActorMiddleCanGrab)); + } }; \ No newline at end of file