cache which finger can grab or touch objects

This commit is contained in:
Mamadou Babaei
2023-05-19 18:02:20 +02:00
parent b7ea384fd7
commit f3afbccb2b
4 changed files with 701 additions and 151 deletions
@@ -38,6 +38,8 @@
#include "Camera/CameraComponent.h" #include "Camera/CameraComponent.h"
#include "Components/SphereComponent.h" #include "Components/SphereComponent.h"
#include "SenseGlove/Components/SGGrabComponent.h"
#include "SenseGlove/Components/SGTouchComponent.h"
#include "SenseGlove/Components/SGVirtualHandComponent.h" #include "SenseGlove/Components/SGVirtualHandComponent.h"
#include "SenseGlove/Components/SGWristTrackerComponent.h" #include "SenseGlove/Components/SGWristTrackerComponent.h"
@@ -424,6 +426,26 @@ ASGPawn::ASGPawn(const FObjectInitializer& ObjectInitializer)
RightPinkyFingertipTouchCollider->SetCollisionResponseToChannel(ECC_PhysicsBody, ECR_Overlap); RightPinkyFingertipTouchCollider->SetCollisionResponseToChannel(ECC_PhysicsBody, ECR_Overlap);
RightPinkyFingertipTouchCollider->SetCollisionResponseToChannel(ECC_Vehicle, ECR_Overlap); RightPinkyFingertipTouchCollider->SetCollisionResponseToChannel(ECC_Vehicle, ECR_Overlap);
RightPinkyFingertipTouchCollider->SetCollisionResponseToChannel(ECC_Destructible, 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() void ASGPawn::BeginPlay()
@@ -485,6 +507,16 @@ void ASGPawn::OnLeftThumbFingertipGrabColliderOverlapBegins(
const bool bFromSweep, const bool bFromSweep,
const FHitResult& SweepResult) const FHitResult& SweepResult)
{ {
(void)OverlappedComponent;
(void)OtherComp;
(void)OtherBodyIndex;
(void)bFromSweep;
(void)SweepResult;
if (USGGrabComponent::IsGrabbable(OtherActor))
{
ActorLeftThumbCanGrab = OtherActor;
}
} }
void ASGPawn::OnLeftThumbFingertipGrabColliderOverlapEnds( void ASGPawn::OnLeftThumbFingertipGrabColliderOverlapEnds(
@@ -493,6 +525,14 @@ void ASGPawn::OnLeftThumbFingertipGrabColliderOverlapEnds(
UPrimitiveComponent* OtherComp, UPrimitiveComponent* OtherComp,
const int32 OtherBodyIndex) const int32 OtherBodyIndex)
{ {
(void)OverlappedComponent;
(void)OtherComp;
(void)OtherBodyIndex;
if (ActorLeftThumbCanGrab == OtherActor)
{
ActorLeftThumbCanGrab = nullptr;
}
} }
void ASGPawn::OnLeftIndexFingertipGrabColliderOverlapBegins( void ASGPawn::OnLeftIndexFingertipGrabColliderOverlapBegins(
@@ -503,6 +543,16 @@ void ASGPawn::OnLeftIndexFingertipGrabColliderOverlapBegins(
const bool bFromSweep, const bool bFromSweep,
const FHitResult& SweepResult) const FHitResult& SweepResult)
{ {
(void)OverlappedComponent;
(void)OtherComp;
(void)OtherBodyIndex;
(void)bFromSweep;
(void)SweepResult;
if (USGGrabComponent::IsGrabbable(OtherActor))
{
ActorLeftIndexCanGrab = OtherActor;
}
} }
void ASGPawn::OnLeftIndexFingertipGrabColliderOverlapEnds( void ASGPawn::OnLeftIndexFingertipGrabColliderOverlapEnds(
@@ -511,6 +561,14 @@ void ASGPawn::OnLeftIndexFingertipGrabColliderOverlapEnds(
UPrimitiveComponent* OtherComp, UPrimitiveComponent* OtherComp,
const int32 OtherBodyIndex) const int32 OtherBodyIndex)
{ {
(void)OverlappedComponent;
(void)OtherComp;
(void)OtherBodyIndex;
if (ActorLeftIndexCanGrab == OtherActor)
{
ActorLeftIndexCanGrab = nullptr;
}
} }
void ASGPawn::OnLeftMiddleFingertipGrabColliderOverlapBegins( void ASGPawn::OnLeftMiddleFingertipGrabColliderOverlapBegins(
@@ -521,6 +579,16 @@ void ASGPawn::OnLeftMiddleFingertipGrabColliderOverlapBegins(
const bool bFromSweep, const bool bFromSweep,
const FHitResult& SweepResult) const FHitResult& SweepResult)
{ {
(void)OverlappedComponent;
(void)OtherComp;
(void)OtherBodyIndex;
(void)bFromSweep;
(void)SweepResult;
if (USGGrabComponent::IsGrabbable(OtherActor))
{
ActorLeftMiddleCanGrab = OtherActor;
}
} }
void ASGPawn::OnLeftMiddleFingertipGrabColliderOverlapEnds( void ASGPawn::OnLeftMiddleFingertipGrabColliderOverlapEnds(
@@ -529,6 +597,14 @@ void ASGPawn::OnLeftMiddleFingertipGrabColliderOverlapEnds(
UPrimitiveComponent* OtherComp, UPrimitiveComponent* OtherComp,
const int32 OtherBodyIndex) const int32 OtherBodyIndex)
{ {
(void)OverlappedComponent;
(void)OtherComp;
(void)OtherBodyIndex;
if (ActorLeftMiddleCanGrab == OtherActor)
{
ActorLeftMiddleCanGrab = nullptr;
}
} }
void ASGPawn::OnLeftThumbFingertipTouchColliderOverlapBegins( void ASGPawn::OnLeftThumbFingertipTouchColliderOverlapBegins(
@@ -539,6 +615,16 @@ void ASGPawn::OnLeftThumbFingertipTouchColliderOverlapBegins(
const bool bFromSweep, const bool bFromSweep,
const FHitResult& SweepResult) const FHitResult& SweepResult)
{ {
(void)OverlappedComponent;
(void)OtherComp;
(void)OtherBodyIndex;
(void)bFromSweep;
(void)SweepResult;
if (USGTouchComponent::IsTouchable(OtherActor))
{
ActorLeftThumbTouching = OtherActor;
}
} }
void ASGPawn::OnLeftThumbFingertipTouchColliderOverlapEnds( void ASGPawn::OnLeftThumbFingertipTouchColliderOverlapEnds(
@@ -547,6 +633,14 @@ void ASGPawn::OnLeftThumbFingertipTouchColliderOverlapEnds(
UPrimitiveComponent* OtherComp, UPrimitiveComponent* OtherComp,
const int32 OtherBodyIndex) const int32 OtherBodyIndex)
{ {
(void)OverlappedComponent;
(void)OtherComp;
(void)OtherBodyIndex;
if (ActorLeftThumbTouching == OtherActor)
{
ActorLeftThumbTouching = nullptr;
}
} }
void ASGPawn::OnLeftIndexFingertipTouchColliderOverlapBegins( void ASGPawn::OnLeftIndexFingertipTouchColliderOverlapBegins(
@@ -557,6 +651,16 @@ void ASGPawn::OnLeftIndexFingertipTouchColliderOverlapBegins(
const bool bFromSweep, const bool bFromSweep,
const FHitResult& SweepResult) const FHitResult& SweepResult)
{ {
(void)OverlappedComponent;
(void)OtherComp;
(void)OtherBodyIndex;
(void)bFromSweep;
(void)SweepResult;
if (USGTouchComponent::IsTouchable(OtherActor))
{
ActorLeftIndexTouching = OtherActor;
}
} }
void ASGPawn::OnLeftIndexFingertipTouchColliderOverlapEnds( void ASGPawn::OnLeftIndexFingertipTouchColliderOverlapEnds(
@@ -565,6 +669,14 @@ void ASGPawn::OnLeftIndexFingertipTouchColliderOverlapEnds(
UPrimitiveComponent* OtherComp, UPrimitiveComponent* OtherComp,
const int32 OtherBodyIndex) const int32 OtherBodyIndex)
{ {
(void)OverlappedComponent;
(void)OtherComp;
(void)OtherBodyIndex;
if (ActorLeftIndexTouching == OtherActor)
{
ActorLeftIndexTouching = nullptr;
}
} }
void ASGPawn::OnLeftMiddleFingertipTouchColliderOverlapBegins( void ASGPawn::OnLeftMiddleFingertipTouchColliderOverlapBegins(
@@ -575,6 +687,16 @@ void ASGPawn::OnLeftMiddleFingertipTouchColliderOverlapBegins(
const bool bFromSweep, const bool bFromSweep,
const FHitResult& SweepResult) const FHitResult& SweepResult)
{ {
(void)OverlappedComponent;
(void)OtherComp;
(void)OtherBodyIndex;
(void)bFromSweep;
(void)SweepResult;
if (USGTouchComponent::IsTouchable(OtherActor))
{
ActorLeftMiddleTouching = OtherActor;
}
} }
void ASGPawn::OnLeftMiddleFingertipTouchColliderOverlapEnds( void ASGPawn::OnLeftMiddleFingertipTouchColliderOverlapEnds(
@@ -583,6 +705,14 @@ void ASGPawn::OnLeftMiddleFingertipTouchColliderOverlapEnds(
UPrimitiveComponent* OtherComp, UPrimitiveComponent* OtherComp,
const int32 OtherBodyIndex) const int32 OtherBodyIndex)
{ {
(void)OverlappedComponent;
(void)OtherComp;
(void)OtherBodyIndex;
if (ActorLeftMiddleTouching == OtherActor)
{
ActorLeftMiddleTouching = nullptr;
}
} }
void ASGPawn::OnLeftRingFingertipTouchColliderOverlapBegins( void ASGPawn::OnLeftRingFingertipTouchColliderOverlapBegins(
@@ -593,6 +723,16 @@ void ASGPawn::OnLeftRingFingertipTouchColliderOverlapBegins(
const bool bFromSweep, const bool bFromSweep,
const FHitResult& SweepResult) const FHitResult& SweepResult)
{ {
(void)OverlappedComponent;
(void)OtherComp;
(void)OtherBodyIndex;
(void)bFromSweep;
(void)SweepResult;
if (USGTouchComponent::IsTouchable(OtherActor))
{
ActorLeftRingTouching = OtherActor;
}
} }
void ASGPawn::OnLeftRingFingertipTouchColliderOverlapEnds( void ASGPawn::OnLeftRingFingertipTouchColliderOverlapEnds(
@@ -601,6 +741,14 @@ void ASGPawn::OnLeftRingFingertipTouchColliderOverlapEnds(
UPrimitiveComponent* OtherComp, UPrimitiveComponent* OtherComp,
const int32 OtherBodyIndex) const int32 OtherBodyIndex)
{ {
(void)OverlappedComponent;
(void)OtherComp;
(void)OtherBodyIndex;
if (ActorLeftRingTouching == OtherActor)
{
ActorLeftRingTouching = nullptr;
}
} }
void ASGPawn::OnLeftPinkyFingertipTouchColliderOverlapBegins( void ASGPawn::OnLeftPinkyFingertipTouchColliderOverlapBegins(
@@ -611,6 +759,16 @@ void ASGPawn::OnLeftPinkyFingertipTouchColliderOverlapBegins(
const bool bFromSweep, const bool bFromSweep,
const FHitResult& SweepResult) const FHitResult& SweepResult)
{ {
(void)OverlappedComponent;
(void)OtherComp;
(void)OtherBodyIndex;
(void)bFromSweep;
(void)SweepResult;
if (USGTouchComponent::IsTouchable(OtherActor))
{
ActorLeftPinkyTouching = OtherActor;
}
} }
void ASGPawn::OnLeftPinkyFingertipTouchColliderOverlapEnds( void ASGPawn::OnLeftPinkyFingertipTouchColliderOverlapEnds(
@@ -619,6 +777,14 @@ void ASGPawn::OnLeftPinkyFingertipTouchColliderOverlapEnds(
UPrimitiveComponent* OtherComp, UPrimitiveComponent* OtherComp,
const int32 OtherBodyIndex) const int32 OtherBodyIndex)
{ {
(void)OverlappedComponent;
(void)OtherComp;
(void)OtherBodyIndex;
if (ActorLeftPinkyTouching == OtherActor)
{
ActorLeftPinkyTouching = nullptr;
}
} }
void ASGPawn::OnRightThumbFingertipGrabColliderOverlapBegins( void ASGPawn::OnRightThumbFingertipGrabColliderOverlapBegins(
@@ -629,6 +795,16 @@ void ASGPawn::OnRightThumbFingertipGrabColliderOverlapBegins(
const bool bFromSweep, const bool bFromSweep,
const FHitResult& SweepResult) const FHitResult& SweepResult)
{ {
(void)OverlappedComponent;
(void)OtherComp;
(void)OtherBodyIndex;
(void)bFromSweep;
(void)SweepResult;
if (USGGrabComponent::IsGrabbable(OtherActor))
{
ActorRightThumbCanGrab = OtherActor;
}
} }
void ASGPawn::OnRightThumbFingertipGrabColliderOverlapEnds( void ASGPawn::OnRightThumbFingertipGrabColliderOverlapEnds(
@@ -637,6 +813,14 @@ void ASGPawn::OnRightThumbFingertipGrabColliderOverlapEnds(
UPrimitiveComponent* OtherComp, UPrimitiveComponent* OtherComp,
const int32 OtherBodyIndex) const int32 OtherBodyIndex)
{ {
(void)OverlappedComponent;
(void)OtherComp;
(void)OtherBodyIndex;
if (ActorRightThumbCanGrab == OtherActor)
{
ActorRightThumbCanGrab = nullptr;
}
} }
void ASGPawn::OnRightIndexFingertipGrabColliderOverlapBegins( void ASGPawn::OnRightIndexFingertipGrabColliderOverlapBegins(
@@ -647,6 +831,16 @@ void ASGPawn::OnRightIndexFingertipGrabColliderOverlapBegins(
const bool bFromSweep, const bool bFromSweep,
const FHitResult& SweepResult) const FHitResult& SweepResult)
{ {
(void)OverlappedComponent;
(void)OtherComp;
(void)OtherBodyIndex;
(void)bFromSweep;
(void)SweepResult;
if (USGGrabComponent::IsGrabbable(OtherActor))
{
ActorRightIndexCanGrab = OtherActor;
}
} }
void ASGPawn::OnRightIndexFingertipGrabColliderOverlapEnds( void ASGPawn::OnRightIndexFingertipGrabColliderOverlapEnds(
@@ -655,6 +849,14 @@ void ASGPawn::OnRightIndexFingertipGrabColliderOverlapEnds(
UPrimitiveComponent* OtherComp, UPrimitiveComponent* OtherComp,
const int32 OtherBodyIndex) const int32 OtherBodyIndex)
{ {
(void)OverlappedComponent;
(void)OtherComp;
(void)OtherBodyIndex;
if (ActorRightThumbCanGrab == OtherActor)
{
ActorRightIndexCanGrab = nullptr;
}
} }
void ASGPawn::OnRightMiddleFingertipGrabColliderOverlapBegins( void ASGPawn::OnRightMiddleFingertipGrabColliderOverlapBegins(
@@ -665,6 +867,16 @@ void ASGPawn::OnRightMiddleFingertipGrabColliderOverlapBegins(
const bool bFromSweep, const bool bFromSweep,
const FHitResult& SweepResult) const FHitResult& SweepResult)
{ {
(void)OverlappedComponent;
(void)OtherComp;
(void)OtherBodyIndex;
(void)bFromSweep;
(void)SweepResult;
if (USGGrabComponent::IsGrabbable(OtherActor))
{
ActorRightMiddleCanGrab = OtherActor;
}
} }
void ASGPawn::OnRightMiddleFingertipGrabColliderOverlapEnds( void ASGPawn::OnRightMiddleFingertipGrabColliderOverlapEnds(
@@ -673,6 +885,14 @@ void ASGPawn::OnRightMiddleFingertipGrabColliderOverlapEnds(
UPrimitiveComponent* OtherComp, UPrimitiveComponent* OtherComp,
const int32 OtherBodyIndex) const int32 OtherBodyIndex)
{ {
(void)OverlappedComponent;
(void)OtherComp;
(void)OtherBodyIndex;
if (ActorRightMiddleCanGrab == OtherActor)
{
ActorRightMiddleCanGrab = nullptr;
}
} }
void ASGPawn::OnRightThumbFingertipTouchColliderOverlapBegins( void ASGPawn::OnRightThumbFingertipTouchColliderOverlapBegins(
@@ -683,6 +903,16 @@ void ASGPawn::OnRightThumbFingertipTouchColliderOverlapBegins(
const bool bFromSweep, const bool bFromSweep,
const FHitResult& SweepResult) const FHitResult& SweepResult)
{ {
(void)OverlappedComponent;
(void)OtherComp;
(void)OtherBodyIndex;
(void)bFromSweep;
(void)SweepResult;
if (USGTouchComponent::IsTouchable(OtherActor))
{
ActorRightThumbTouching = OtherActor;
}
} }
void ASGPawn::OnRightThumbFingertipTouchColliderOverlapEnds( void ASGPawn::OnRightThumbFingertipTouchColliderOverlapEnds(
@@ -691,6 +921,14 @@ void ASGPawn::OnRightThumbFingertipTouchColliderOverlapEnds(
UPrimitiveComponent* OtherComp, UPrimitiveComponent* OtherComp,
const int32 OtherBodyIndex) const int32 OtherBodyIndex)
{ {
(void)OverlappedComponent;
(void)OtherComp;
(void)OtherBodyIndex;
if (ActorRightThumbTouching == OtherActor)
{
ActorRightThumbTouching = nullptr;
}
} }
void ASGPawn::OnRightIndexFingertipTouchColliderOverlapBegins( void ASGPawn::OnRightIndexFingertipTouchColliderOverlapBegins(
@@ -701,6 +939,16 @@ void ASGPawn::OnRightIndexFingertipTouchColliderOverlapBegins(
const bool bFromSweep, const bool bFromSweep,
const FHitResult& SweepResult) const FHitResult& SweepResult)
{ {
(void)OverlappedComponent;
(void)OtherComp;
(void)OtherBodyIndex;
(void)bFromSweep;
(void)SweepResult;
if (USGTouchComponent::IsTouchable(OtherActor))
{
ActorRightIndexTouching = OtherActor;
}
} }
void ASGPawn::OnRightIndexFingertipTouchColliderOverlapEnds( void ASGPawn::OnRightIndexFingertipTouchColliderOverlapEnds(
@@ -709,6 +957,14 @@ void ASGPawn::OnRightIndexFingertipTouchColliderOverlapEnds(
UPrimitiveComponent* OtherComp, UPrimitiveComponent* OtherComp,
const int32 OtherBodyIndex) const int32 OtherBodyIndex)
{ {
(void)OverlappedComponent;
(void)OtherComp;
(void)OtherBodyIndex;
if (ActorRightIndexTouching == OtherActor)
{
ActorRightIndexTouching = nullptr;
}
} }
void ASGPawn::OnRightMiddleFingertipTouchColliderOverlapBegins( void ASGPawn::OnRightMiddleFingertipTouchColliderOverlapBegins(
@@ -719,6 +975,16 @@ void ASGPawn::OnRightMiddleFingertipTouchColliderOverlapBegins(
const bool bFromSweep, const bool bFromSweep,
const FHitResult& SweepResult) const FHitResult& SweepResult)
{ {
(void)OverlappedComponent;
(void)OtherComp;
(void)OtherBodyIndex;
(void)bFromSweep;
(void)SweepResult;
if (USGTouchComponent::IsTouchable(OtherActor))
{
ActorRightMiddleTouching = OtherActor;
}
} }
void ASGPawn::OnRightMiddleFingertipTouchColliderOverlapEnds( void ASGPawn::OnRightMiddleFingertipTouchColliderOverlapEnds(
@@ -727,6 +993,14 @@ void ASGPawn::OnRightMiddleFingertipTouchColliderOverlapEnds(
UPrimitiveComponent* OtherComp, UPrimitiveComponent* OtherComp,
const int32 OtherBodyIndex) const int32 OtherBodyIndex)
{ {
(void)OverlappedComponent;
(void)OtherComp;
(void)OtherBodyIndex;
if (ActorRightMiddleTouching == OtherActor)
{
ActorRightMiddleTouching = nullptr;
}
} }
void ASGPawn::OnRightRingFingertipTouchColliderOverlapBegins( void ASGPawn::OnRightRingFingertipTouchColliderOverlapBegins(
@@ -737,6 +1011,16 @@ void ASGPawn::OnRightRingFingertipTouchColliderOverlapBegins(
const bool bFromSweep, const bool bFromSweep,
const FHitResult& SweepResult) const FHitResult& SweepResult)
{ {
(void)OverlappedComponent;
(void)OtherComp;
(void)OtherBodyIndex;
(void)bFromSweep;
(void)SweepResult;
if (USGTouchComponent::IsTouchable(OtherActor))
{
ActorRightRingTouching = OtherActor;
}
} }
void ASGPawn::OnRightRingFingertipTouchColliderOverlapEnds( void ASGPawn::OnRightRingFingertipTouchColliderOverlapEnds(
@@ -745,6 +1029,14 @@ void ASGPawn::OnRightRingFingertipTouchColliderOverlapEnds(
UPrimitiveComponent* OtherComp, UPrimitiveComponent* OtherComp,
const int32 OtherBodyIndex) const int32 OtherBodyIndex)
{ {
(void)OverlappedComponent;
(void)OtherComp;
(void)OtherBodyIndex;
if (ActorRightRingTouching == OtherActor)
{
ActorRightRingTouching = nullptr;
}
} }
void ASGPawn::OnRightPinkyFingertipTouchColliderOverlapBegins( void ASGPawn::OnRightPinkyFingertipTouchColliderOverlapBegins(
@@ -755,6 +1047,16 @@ void ASGPawn::OnRightPinkyFingertipTouchColliderOverlapBegins(
const bool bFromSweep, const bool bFromSweep,
const FHitResult& SweepResult) const FHitResult& SweepResult)
{ {
(void)OverlappedComponent;
(void)OtherComp;
(void)OtherBodyIndex;
(void)bFromSweep;
(void)SweepResult;
if (USGTouchComponent::IsTouchable(OtherActor))
{
ActorRightPinkyTouching = OtherActor;
}
} }
void ASGPawn::OnRightPinkyFingertipTouchColliderOverlapEnds( void ASGPawn::OnRightPinkyFingertipTouchColliderOverlapEnds(
@@ -763,6 +1065,14 @@ void ASGPawn::OnRightPinkyFingertipTouchColliderOverlapEnds(
UPrimitiveComponent* OtherComp, UPrimitiveComponent* OtherComp,
const int32 OtherBodyIndex) const int32 OtherBodyIndex)
{ {
(void)OverlappedComponent;
(void)OtherComp;
(void)OtherBodyIndex;
if (ActorRightPinkyTouching == OtherActor)
{
ActorRightPinkyTouching = nullptr;
}
} }
ASGPawn::FImpl::FImpl(ASGPawn* InOwner) ASGPawn::FImpl::FImpl(ASGPawn* InOwner)
@@ -37,6 +37,8 @@
#include "Components/SphereComponent.h" #include "Components/SphereComponent.h"
#include "SenseGlove/Components/SGGrabComponent.h"
#include "SenseGlove/Components/SGTouchComponent.h"
#include "SenseGlove/Components/SGVirtualHandComponent.h" #include "SenseGlove/Components/SGVirtualHandComponent.h"
#include "SenseGlove/Components/SGWristTrackerComponent.h" #include "SenseGlove/Components/SGWristTrackerComponent.h"
@@ -71,6 +73,9 @@ struct ASGVirtualHandActor::FImpl
void BindFingerTouchOverlapEvents(); void BindFingerTouchOverlapEvents();
void UnbindFingerTouchOverlapEvents(); void UnbindFingerTouchOverlapEvents();
bool IsFingerGrabbing(AActor* Actor) const;
bool IsFingerTouching(AActor* Actor) const;
}; };
ASGVirtualHandActor::ASGVirtualHandActor(const FObjectInitializer& ObjectInitializer) ASGVirtualHandActor::ASGVirtualHandActor(const FObjectInitializer& ObjectInitializer)
@@ -243,6 +248,16 @@ ASGVirtualHandActor::ASGVirtualHandActor(const FObjectInitializer& ObjectInitial
WristTracker->SetupAttachment(RootComponent); WristTracker->SetupAttachment(RootComponent);
WristTracker->SetRight(VirtualHand->IsRight()); WristTracker->SetRight(VirtualHand->IsRight());
ActorThumbCanGrab = nullptr;
ActorIndexCanGrab = nullptr;
ActorMiddleCanGrab = nullptr;
ActorThumbTouching = nullptr;
ActorIndexTouching = nullptr;
ActorMiddleTouching = nullptr;
ActorRingTouching = nullptr;
ActorPinkyTouching = nullptr;
} }
void ASGVirtualHandActor::BeginPlay() void ASGVirtualHandActor::BeginPlay()
@@ -283,6 +298,282 @@ void ASGVirtualHandActor::PreInitializeComponents()
WristTracker->SetRight(VirtualHand->IsRight()); 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 bool ASGVirtualHandActor::IsLeft() const
{ {
return WristTracker->IsLeft() && VirtualHand->IsLeft(); return WristTracker->IsLeft() && VirtualHand->IsLeft();
@@ -304,150 +595,6 @@ bool ASGVirtualHandActor::IsGloveConnected() const
return VirtualHand->IsGloveConnected(); 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) ASGVirtualHandActor::FImpl::FImpl(ASGVirtualHandActor* InOwner)
: Owner(InOwner) : Owner(InOwner)
{ {
@@ -129,6 +129,55 @@ private:
UPROPERTY(EditAnywhere, Category="SenseGlove", meta=(AllowPrivateAccess="false")) UPROPERTY(EditAnywhere, Category="SenseGlove", meta=(AllowPrivateAccess="false"))
USphereComponent* RightPinkyFingertipTouchCollider; 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: public:
FORCEINLINE UCameraComponent* GetCamera() const FORCEINLINE UCameraComponent* GetCamera() const
{ {
@@ -496,4 +545,17 @@ protected:
AActor* OtherActor, AActor* OtherActor,
UPrimitiveComponent* OtherComp, UPrimitiveComponent* OtherComp,
int32 OtherBodyIndex); 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));
}
}; };
@@ -102,6 +102,31 @@ private:
UPROPERTY(EditAnywhere, Category="SenseGlove", meta=(AllowPrivateAccess="false")) UPROPERTY(EditAnywhere, Category="SenseGlove", meta=(AllowPrivateAccess="false"))
USphereComponent* PinkyFingertipTouchCollider; 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: public:
FORCEINLINE USGWristTrackerComponent* GetWristTracker() const FORCEINLINE USGWristTrackerComponent* GetWristTracker() const
{ {
@@ -164,13 +189,6 @@ public:
virtual void EndPlay(const EEndPlayReason::Type EndPlayReason) override; virtual void EndPlay(const EEndPlayReason::Type EndPlayReason) override;
virtual void PreInitializeComponents() override; virtual void PreInitializeComponents() override;
public:
bool IsLeft() const;
bool IsRight() const;
void SetRight(bool bRight);
bool IsGloveConnected() const;
protected: protected:
UFUNCTION() UFUNCTION()
virtual void OnThumbFingertipGrabColliderOverlapBegins( virtual void OnThumbFingertipGrabColliderOverlapBegins(
@@ -299,4 +317,17 @@ protected:
AActor* OtherActor, AActor* OtherActor,
UPrimitiveComponent* OtherComp, UPrimitiveComponent* OtherComp,
int32 OtherBodyIndex); 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));
}
}; };