From 248a87a949a2d2dad21985416af67ad09e111794 Mon Sep 17 00:00:00 2001 From: Mamadou Babaei Date: Mon, 14 Aug 2023 16:02:23 +0200 Subject: [PATCH] initial working implementation of the separated virtual/real hand rendering --- CHANGELOG.md | 4 +- .../SenseGlove/GameFramework/SGPawn.cpp | 397 +++++++++++++++--- .../Components/SGVirtualHandComponent.h | 15 + .../Public/SenseGlove/GameFramework/SGPawn.h | 22 +- .../Private/SGKismet/SGPawnKismetLibrary.cpp | 10 + .../SGVirtualHandComponentKismetLibrary.cpp | 52 ++- .../Public/SGKismet/SGPawnKismetLibrary.h | 6 + .../SGVirtualHandComponentKismetLibrary.h | 8 + 8 files changed, 428 insertions(+), 86 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a7ebf61a..fa6c80e3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,8 +9,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added -- Add support for the upcoming Unreal Engine 5.3. +- Added support for the upcoming Unreal Engine 5.3. - Now, the hand's velocity is applied to grabbed actors after being released from the hand. +- Added separation of the virtual and real hand rendering. ### Fixed @@ -20,7 +21,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - SenseGlove libraries have been updated to v2.11.0-b775a05. - ## [1.5.3] - 2023-07-19 This is a hotfix release mostly addressing Android Bluetooth performance issues. diff --git a/Source/SenseGlove/Private/SenseGlove/GameFramework/SGPawn.cpp b/Source/SenseGlove/Private/SenseGlove/GameFramework/SGPawn.cpp index 6c72335e..db270d03 100644 --- a/Source/SenseGlove/Private/SenseGlove/GameFramework/SGPawn.cpp +++ b/Source/SenseGlove/Private/SenseGlove/GameFramework/SGPawn.cpp @@ -53,6 +53,13 @@ struct ASGPawn::FImpl * Static methods ************************/ + /************************ + * Member variables + ************************/ + + bool bUpdateLeftHandLocationAndRotation; + bool bUpdateRightHandLocationAndRotation; + /************************ * Owner object ************************/ @@ -86,6 +93,23 @@ struct ASGPawn::FImpl void BindFingerTouchOverlapEvents(); void UnbindFingerTouchOverlapEvents(); + void SetVisibility(USceneComponent* SceneComponent, const bool bVisibility) const; + + void UpdateHandLocation(const bool bRight, const FVector& Location, const bool bUpdateVirtualHand); + void UpdateLeftHandLocation(const FVector& Location, const bool bUpdateVirtualHand); + void UpdateRightHandLocation(const FVector& Location, const bool bUpdateVirtualHand); + + void UpdateHandRotation(const bool bRight, const FRotator& Rotation, const bool bUpdateVirtualHand); + void UpdateLeftHandRotation(const FRotator& Rotation, const bool bUpdateVirtualHand); + void UpdateRightHandRotation(const FRotator& Rotation, const bool bUpdateVirtualHand); + + void UpdateHandLocationAndRotation( + const bool bRight, const FVector& Location, const FRotator& Rotation, const bool bUpdateVirtualHand); + void UpdateLeftHandLocationAndRotation( + const FVector& Location, const FRotator& Rotation, const bool bUpdateVirtualHand); + void UpdateRightHandLocationAndRotation( + const FVector& Location, const FRotator& Rotation, const bool bUpdateVirtualHand); + void DisableActorPhysics(const AActor* Actor) const; void EnableActorPhysics(const AActor* Actor) const; @@ -120,6 +144,19 @@ ASGPawn::ASGPawn(const FObjectInitializer& ObjectInitializer) HandLeft = ObjectInitializer.CreateDefaultSubobject(this, TEXT("HandLeft")); HandLeft->SetupAttachment(GetRootComponent()); + HandLeft->SetCanEverAffectNavigation(false); + HandLeft->SetGenerateOverlapEvents(true); + HandLeft->CanCharacterStepUpOn = ECanBeCharacterBase::ECB_Owner; + HandLeft->SetCollisionObjectType(ECC_Pawn); + HandLeft->SetCollisionEnabled(ECollisionEnabled::QueryAndPhysics); + HandLeft->SetCollisionResponseToAllChannels(ECR_Block); + HandLeft->SetCollisionResponseToChannel(ECC_WorldStatic, ECR_Block); + HandLeft->SetCollisionResponseToChannel(ECC_WorldDynamic, ECR_Block); + HandLeft->SetCollisionResponseToChannel(ECC_Pawn, ECR_Block); + HandLeft->SetCollisionResponseToChannel(ECC_Visibility, ECR_Block); + HandLeft->SetCollisionResponseToChannel(ECC_PhysicsBody, ECR_Block); + HandLeft->SetCollisionResponseToChannel(ECC_Vehicle, ECR_Block); + HandLeft->SetCollisionResponseToChannel(ECC_Destructible, ECR_Block); HandLeft->SetRight(false); HandLeft->SetHiddenIfNoGloveDetected(true); HandLeft->SetRelativeRotation(FRotator{0.0f, -90.0f, 0.0f}, @@ -128,6 +165,36 @@ ASGPawn::ASGPawn(const FObjectInitializer& ObjectInitializer) false, nullptr, ETeleportType::None); HandLeft->SetWristTracker(WristTrackerLeft); + RealHandLeft = ObjectInitializer.CreateDefaultSubobject(this, TEXT("RealHandLeft")); + RealHandLeft->SetupAttachment(GetRootComponent()); + RealHandLeft->SetCanEverAffectNavigation(false); + RealHandLeft->SetGenerateOverlapEvents(true); + RealHandLeft->CanCharacterStepUpOn = ECanBeCharacterBase::ECB_Owner; + RealHandLeft->SetCollisionObjectType(ECC_Pawn); + RealHandLeft->SetCollisionEnabled(ECollisionEnabled::QueryOnly); + RealHandLeft->SetCollisionResponseToAllChannels(ECR_Overlap); + RealHandLeft->SetCollisionResponseToChannel(ECC_WorldStatic, ECR_Overlap); + RealHandLeft->SetCollisionResponseToChannel(ECC_WorldDynamic, ECR_Overlap); + RealHandLeft->SetCollisionResponseToChannel(ECC_Pawn, ECR_Overlap); + RealHandLeft->SetCollisionResponseToChannel(ECC_Visibility, ECR_Overlap); + RealHandLeft->SetCollisionResponseToChannel(ECC_PhysicsBody, ECR_Overlap); + RealHandLeft->SetCollisionResponseToChannel(ECC_Vehicle, ECR_Overlap); + RealHandLeft->SetCollisionResponseToChannel(ECC_Destructible, ECR_Overlap); + RealHandLeft->SetRight(false); + Pimpl->SetVisibility(RealHandLeft, false); + RealHandLeft->SetHiddenIfNoGloveDetected(true); + RealHandLeft->SetRelativeRotation(FRotator{0.0f, -90.0f, 0.0f}, + false, nullptr, ETeleportType::None); + RealHandLeft->SetRelativeLocation(FVector{30.0f, -20.0f, -10.0f}, + false, nullptr, ETeleportType::None); + RealHandLeft->SetWristTracker(WristTrackerLeft); + + FSGDebugVirtualHandSettings RealHandLeftDebugSettings; + RealHandLeftDebugSettings.bDrawDebugVirtualHand = true; + RealHandLeftDebugSettings.DrawingMode = ESGDebugVirtualHandDrawingMode::GizmoJoints; + RealHandLeftDebugSettings.GizmoThickness = 0.5f; + RealHandLeft->SetDebugVirtualHandSettings(MoveTemp(RealHandLeftDebugSettings)); + LeftThumbFingertipGrabCollider = ObjectInitializer.CreateDefaultSubobject( this, TEXT("LeftThumbFingertipGrabCollider")); LeftThumbFingertipGrabCollider->SetRelativeScale3D(HandLeft->GetDefaultFingertipsGrabColliderSize()); @@ -136,7 +203,8 @@ ASGPawn::ASGPawn(const FObjectInitializer& ObjectInitializer) LeftThumbFingertipGrabCollider->bCastDynamicShadow = false; LeftThumbFingertipGrabCollider->SetReceivesDecals(true); LeftThumbFingertipGrabCollider->SetCanEverAffectNavigation(false); - LeftThumbFingertipGrabCollider->SetCollisionObjectType(ECC_WorldDynamic); + LeftThumbFingertipGrabCollider->CanCharacterStepUpOn = ECanBeCharacterBase::ECB_Owner; + LeftThumbFingertipGrabCollider->SetCollisionObjectType(ECC_Pawn); LeftThumbFingertipGrabCollider->SetCollisionEnabled(ECollisionEnabled::QueryOnly); LeftThumbFingertipGrabCollider->SetCollisionResponseToAllChannels(ECR_Overlap); LeftThumbFingertipGrabCollider->SetCollisionResponseToChannel(ECC_WorldStatic, ECR_Overlap); @@ -155,7 +223,8 @@ ASGPawn::ASGPawn(const FObjectInitializer& ObjectInitializer) LeftIndexFingertipGrabCollider->bCastDynamicShadow = false; LeftIndexFingertipGrabCollider->SetReceivesDecals(true); LeftIndexFingertipGrabCollider->SetCanEverAffectNavigation(false); - LeftIndexFingertipGrabCollider->SetCollisionObjectType(ECC_WorldDynamic); + LeftIndexFingertipGrabCollider->CanCharacterStepUpOn = ECanBeCharacterBase::ECB_Owner; + LeftIndexFingertipGrabCollider->SetCollisionObjectType(ECC_Pawn); LeftIndexFingertipGrabCollider->SetCollisionEnabled(ECollisionEnabled::QueryOnly); LeftIndexFingertipGrabCollider->SetCollisionResponseToAllChannels(ECR_Overlap); LeftIndexFingertipGrabCollider->SetCollisionResponseToChannel(ECC_WorldStatic, ECR_Overlap); @@ -174,7 +243,8 @@ ASGPawn::ASGPawn(const FObjectInitializer& ObjectInitializer) LeftMiddleFingertipGrabCollider->bCastDynamicShadow = false; LeftMiddleFingertipGrabCollider->SetReceivesDecals(true); LeftMiddleFingertipGrabCollider->SetCanEverAffectNavigation(false); - LeftMiddleFingertipGrabCollider->SetCollisionObjectType(ECC_WorldDynamic); + LeftMiddleFingertipGrabCollider->CanCharacterStepUpOn = ECanBeCharacterBase::ECB_Owner; + LeftMiddleFingertipGrabCollider->SetCollisionObjectType(ECC_Pawn); LeftMiddleFingertipGrabCollider->SetCollisionEnabled(ECollisionEnabled::QueryOnly); LeftMiddleFingertipGrabCollider->SetCollisionResponseToAllChannels(ECR_Overlap); LeftMiddleFingertipGrabCollider->SetCollisionResponseToChannel(ECC_WorldStatic, ECR_Overlap); @@ -193,7 +263,8 @@ ASGPawn::ASGPawn(const FObjectInitializer& ObjectInitializer) LeftThumbFingertipTouchCollider->bCastDynamicShadow = false; LeftThumbFingertipTouchCollider->SetReceivesDecals(true); LeftThumbFingertipTouchCollider->SetCanEverAffectNavigation(false); - LeftThumbFingertipTouchCollider->SetCollisionObjectType(ECC_WorldDynamic); + LeftThumbFingertipTouchCollider->CanCharacterStepUpOn = ECanBeCharacterBase::ECB_Owner; + LeftThumbFingertipTouchCollider->SetCollisionObjectType(ECC_Pawn); LeftThumbFingertipTouchCollider->SetCollisionEnabled(ECollisionEnabled::QueryOnly); LeftThumbFingertipTouchCollider->SetCollisionResponseToAllChannels(ECR_Overlap); LeftThumbFingertipTouchCollider->SetCollisionResponseToChannel(ECC_WorldStatic, ECR_Overlap); @@ -212,7 +283,8 @@ ASGPawn::ASGPawn(const FObjectInitializer& ObjectInitializer) LeftIndexFingertipTouchCollider->bCastDynamicShadow = false; LeftIndexFingertipTouchCollider->SetReceivesDecals(true); LeftIndexFingertipTouchCollider->SetCanEverAffectNavigation(false); - LeftIndexFingertipTouchCollider->SetCollisionObjectType(ECC_WorldDynamic); + LeftIndexFingertipTouchCollider->CanCharacterStepUpOn = ECanBeCharacterBase::ECB_Owner; + LeftIndexFingertipTouchCollider->SetCollisionObjectType(ECC_Pawn); LeftIndexFingertipTouchCollider->SetCollisionEnabled(ECollisionEnabled::QueryOnly); LeftIndexFingertipTouchCollider->SetCollisionResponseToAllChannels(ECR_Overlap); LeftIndexFingertipTouchCollider->SetCollisionResponseToChannel(ECC_WorldStatic, ECR_Overlap); @@ -231,7 +303,8 @@ ASGPawn::ASGPawn(const FObjectInitializer& ObjectInitializer) LeftMiddleFingertipTouchCollider->bCastDynamicShadow = false; LeftMiddleFingertipTouchCollider->SetReceivesDecals(true); LeftMiddleFingertipTouchCollider->SetCanEverAffectNavigation(false); - LeftMiddleFingertipTouchCollider->SetCollisionObjectType(ECC_WorldDynamic); + LeftMiddleFingertipTouchCollider->CanCharacterStepUpOn = ECanBeCharacterBase::ECB_Owner; + LeftMiddleFingertipTouchCollider->SetCollisionObjectType(ECC_Pawn); LeftMiddleFingertipTouchCollider->SetCollisionEnabled(ECollisionEnabled::QueryOnly); LeftMiddleFingertipTouchCollider->SetCollisionResponseToAllChannels(ECR_Overlap); LeftMiddleFingertipTouchCollider->SetCollisionResponseToChannel(ECC_WorldStatic, ECR_Overlap); @@ -250,7 +323,8 @@ ASGPawn::ASGPawn(const FObjectInitializer& ObjectInitializer) LeftRingFingertipTouchCollider->bCastDynamicShadow = false; LeftRingFingertipTouchCollider->SetReceivesDecals(true); LeftRingFingertipTouchCollider->SetCanEverAffectNavigation(false); - LeftRingFingertipTouchCollider->SetCollisionObjectType(ECC_WorldDynamic); + LeftRingFingertipTouchCollider->CanCharacterStepUpOn = ECanBeCharacterBase::ECB_Owner; + LeftRingFingertipTouchCollider->SetCollisionObjectType(ECC_Pawn); LeftRingFingertipTouchCollider->SetCollisionEnabled(ECollisionEnabled::QueryOnly); LeftRingFingertipTouchCollider->SetCollisionResponseToAllChannels(ECR_Overlap); LeftRingFingertipTouchCollider->SetCollisionResponseToChannel(ECC_WorldStatic, ECR_Overlap); @@ -269,7 +343,8 @@ ASGPawn::ASGPawn(const FObjectInitializer& ObjectInitializer) LeftPinkyFingertipTouchCollider->bCastDynamicShadow = false; LeftPinkyFingertipTouchCollider->SetReceivesDecals(true); LeftPinkyFingertipTouchCollider->SetCanEverAffectNavigation(false); - LeftPinkyFingertipTouchCollider->SetCollisionObjectType(ECC_WorldDynamic); + LeftPinkyFingertipTouchCollider->CanCharacterStepUpOn = ECanBeCharacterBase::ECB_Owner; + LeftPinkyFingertipTouchCollider->SetCollisionObjectType(ECC_Pawn); LeftPinkyFingertipTouchCollider->SetCollisionEnabled(ECollisionEnabled::QueryOnly); LeftPinkyFingertipTouchCollider->SetCollisionResponseToAllChannels(ECR_Overlap); LeftPinkyFingertipTouchCollider->SetCollisionResponseToChannel(ECC_WorldStatic, ECR_Overlap); @@ -287,7 +362,21 @@ ASGPawn::ASGPawn(const FObjectInitializer& ObjectInitializer) HandRight = ObjectInitializer.CreateDefaultSubobject(this, TEXT("HandRight")); HandRight->SetupAttachment(GetRootComponent()); + HandRight->SetCanEverAffectNavigation(false); + HandRight->SetGenerateOverlapEvents(true); + HandRight->CanCharacterStepUpOn = ECanBeCharacterBase::ECB_Owner; + HandRight->SetCollisionObjectType(ECC_Pawn); + HandRight->SetCollisionEnabled(ECollisionEnabled::QueryAndPhysics); + HandRight->SetCollisionResponseToAllChannels(ECR_Block); + HandRight->SetCollisionResponseToChannel(ECC_WorldStatic, ECR_Block); + HandRight->SetCollisionResponseToChannel(ECC_WorldDynamic, ECR_Block); + HandRight->SetCollisionResponseToChannel(ECC_Pawn, ECR_Block); + HandRight->SetCollisionResponseToChannel(ECC_Visibility, ECR_Block); + HandRight->SetCollisionResponseToChannel(ECC_PhysicsBody, ECR_Block); + HandRight->SetCollisionResponseToChannel(ECC_Vehicle, ECR_Block); + HandRight->SetCollisionResponseToChannel(ECC_Destructible, ECR_Block); HandRight->SetRight(true); + HandRight->SetHiddenInGame(true); HandRight->SetHiddenIfNoGloveDetected(true); HandRight->SetRelativeRotation(FRotator{0.0f, -90.0f, 0.0f}, false, nullptr, ETeleportType::None); @@ -295,6 +384,36 @@ ASGPawn::ASGPawn(const FObjectInitializer& ObjectInitializer) false, nullptr, ETeleportType::None); HandRight->SetWristTracker(WristTrackerRight); + RealHandRight = ObjectInitializer.CreateDefaultSubobject(this, TEXT("RealHandRight")); + RealHandRight->SetupAttachment(GetRootComponent()); + RealHandRight->SetCanEverAffectNavigation(false); + RealHandRight->SetGenerateOverlapEvents(true); + RealHandRight->CanCharacterStepUpOn = ECanBeCharacterBase::ECB_Owner; + RealHandRight->SetCollisionObjectType(ECC_Pawn); + RealHandRight->SetCollisionEnabled(ECollisionEnabled::QueryOnly); + RealHandRight->SetCollisionResponseToAllChannels(ECR_Overlap); + RealHandRight->SetCollisionResponseToChannel(ECC_WorldStatic, ECR_Overlap); + RealHandRight->SetCollisionResponseToChannel(ECC_WorldDynamic, ECR_Overlap); + RealHandRight->SetCollisionResponseToChannel(ECC_Pawn, ECR_Overlap); + RealHandRight->SetCollisionResponseToChannel(ECC_Visibility, ECR_Overlap); + RealHandRight->SetCollisionResponseToChannel(ECC_PhysicsBody, ECR_Overlap); + RealHandRight->SetCollisionResponseToChannel(ECC_Vehicle, ECR_Overlap); + RealHandRight->SetCollisionResponseToChannel(ECC_Destructible, ECR_Overlap); + RealHandRight->SetRight(true); + Pimpl->SetVisibility(RealHandRight, false); + RealHandRight->SetHiddenIfNoGloveDetected(true); + RealHandRight->SetRelativeRotation(FRotator{0.0f, -90.0f, 0.0f}, + false, nullptr, ETeleportType::None); + RealHandRight->SetRelativeLocation(FVector{30.0f, 20.0f, -10.0f}, + false, nullptr, ETeleportType::None); + RealHandRight->SetWristTracker(WristTrackerRight); + + FSGDebugVirtualHandSettings RealHandRightDebugSettings; + RealHandRightDebugSettings.bDrawDebugVirtualHand = true; + RealHandRightDebugSettings.DrawingMode = ESGDebugVirtualHandDrawingMode::GizmoJoints; + RealHandRightDebugSettings.GizmoThickness = 0.5f; + RealHandRight->SetDebugVirtualHandSettings(MoveTemp(RealHandRightDebugSettings)); + RightThumbFingertipGrabCollider = ObjectInitializer.CreateDefaultSubobject( this, TEXT("RightThumbFingertipGrabCollider")); RightThumbFingertipGrabCollider->SetRelativeScale3D(HandLeft->GetDefaultFingertipsGrabColliderSize()); @@ -303,7 +422,8 @@ ASGPawn::ASGPawn(const FObjectInitializer& ObjectInitializer) RightThumbFingertipGrabCollider->bCastDynamicShadow = false; RightThumbFingertipGrabCollider->SetReceivesDecals(true); RightThumbFingertipGrabCollider->SetCanEverAffectNavigation(false); - RightThumbFingertipGrabCollider->SetCollisionObjectType(ECC_WorldDynamic); + RightThumbFingertipGrabCollider->CanCharacterStepUpOn = ECanBeCharacterBase::ECB_Owner; + RightThumbFingertipGrabCollider->SetCollisionObjectType(ECC_Pawn); RightThumbFingertipGrabCollider->SetCollisionEnabled(ECollisionEnabled::QueryOnly); RightThumbFingertipGrabCollider->SetCollisionResponseToAllChannels(ECR_Overlap); RightThumbFingertipGrabCollider->SetCollisionResponseToChannel(ECC_WorldStatic, ECR_Overlap); @@ -322,7 +442,8 @@ ASGPawn::ASGPawn(const FObjectInitializer& ObjectInitializer) RightIndexFingertipGrabCollider->bCastDynamicShadow = false; RightIndexFingertipGrabCollider->SetReceivesDecals(true); RightIndexFingertipGrabCollider->SetCanEverAffectNavigation(false); - RightIndexFingertipGrabCollider->SetCollisionObjectType(ECC_WorldDynamic); + RightIndexFingertipGrabCollider->CanCharacterStepUpOn = ECanBeCharacterBase::ECB_Owner; + RightIndexFingertipGrabCollider->SetCollisionObjectType(ECC_Pawn); RightIndexFingertipGrabCollider->SetCollisionEnabled(ECollisionEnabled::QueryOnly); RightIndexFingertipGrabCollider->SetCollisionResponseToAllChannels(ECR_Overlap); RightIndexFingertipGrabCollider->SetCollisionResponseToChannel(ECC_WorldStatic, ECR_Overlap); @@ -341,7 +462,8 @@ ASGPawn::ASGPawn(const FObjectInitializer& ObjectInitializer) RightMiddleFingertipGrabCollider->bCastDynamicShadow = false; RightMiddleFingertipGrabCollider->SetReceivesDecals(true); RightMiddleFingertipGrabCollider->SetCanEverAffectNavigation(false); - RightMiddleFingertipGrabCollider->SetCollisionObjectType(ECC_WorldDynamic); + RightMiddleFingertipGrabCollider->CanCharacterStepUpOn = ECanBeCharacterBase::ECB_Owner; + RightMiddleFingertipGrabCollider->SetCollisionObjectType(ECC_Pawn); RightMiddleFingertipGrabCollider->SetCollisionEnabled(ECollisionEnabled::QueryOnly); RightMiddleFingertipGrabCollider->SetCollisionResponseToAllChannels(ECR_Overlap); RightMiddleFingertipGrabCollider->SetCollisionResponseToChannel(ECC_WorldStatic, ECR_Overlap); @@ -360,7 +482,8 @@ ASGPawn::ASGPawn(const FObjectInitializer& ObjectInitializer) RightThumbFingertipTouchCollider->bCastDynamicShadow = false; RightThumbFingertipTouchCollider->SetReceivesDecals(true); RightThumbFingertipTouchCollider->SetCanEverAffectNavigation(false); - RightThumbFingertipTouchCollider->SetCollisionObjectType(ECC_WorldDynamic); + RightThumbFingertipTouchCollider->CanCharacterStepUpOn = ECanBeCharacterBase::ECB_Owner; + RightThumbFingertipTouchCollider->SetCollisionObjectType(ECC_Pawn); RightThumbFingertipTouchCollider->SetCollisionEnabled(ECollisionEnabled::QueryOnly); RightThumbFingertipTouchCollider->SetCollisionResponseToAllChannels(ECR_Overlap); RightThumbFingertipTouchCollider->SetCollisionResponseToChannel(ECC_WorldStatic, ECR_Overlap); @@ -379,7 +502,8 @@ ASGPawn::ASGPawn(const FObjectInitializer& ObjectInitializer) RightIndexFingertipTouchCollider->bCastDynamicShadow = false; RightIndexFingertipTouchCollider->SetReceivesDecals(true); RightIndexFingertipTouchCollider->SetCanEverAffectNavigation(false); - RightIndexFingertipTouchCollider->SetCollisionObjectType(ECC_WorldDynamic); + RightIndexFingertipTouchCollider->CanCharacterStepUpOn = ECanBeCharacterBase::ECB_Owner; + RightIndexFingertipTouchCollider->SetCollisionObjectType(ECC_Pawn); RightIndexFingertipTouchCollider->SetCollisionEnabled(ECollisionEnabled::QueryOnly); RightIndexFingertipTouchCollider->SetCollisionResponseToAllChannels(ECR_Overlap); RightIndexFingertipTouchCollider->SetCollisionResponseToChannel(ECC_WorldStatic, ECR_Overlap); @@ -398,7 +522,8 @@ ASGPawn::ASGPawn(const FObjectInitializer& ObjectInitializer) RightMiddleFingertipTouchCollider->bCastDynamicShadow = false; RightMiddleFingertipTouchCollider->SetReceivesDecals(true); RightMiddleFingertipTouchCollider->SetCanEverAffectNavigation(false); - RightMiddleFingertipTouchCollider->SetCollisionObjectType(ECC_WorldDynamic); + RightMiddleFingertipTouchCollider->CanCharacterStepUpOn = ECanBeCharacterBase::ECB_Owner; + RightMiddleFingertipTouchCollider->SetCollisionObjectType(ECC_Pawn); RightMiddleFingertipTouchCollider->SetCollisionEnabled(ECollisionEnabled::QueryOnly); RightMiddleFingertipTouchCollider->SetCollisionResponseToAllChannels(ECR_Overlap); RightMiddleFingertipTouchCollider->SetCollisionResponseToChannel(ECC_WorldStatic, ECR_Overlap); @@ -417,7 +542,8 @@ ASGPawn::ASGPawn(const FObjectInitializer& ObjectInitializer) RightRingFingertipTouchCollider->bCastDynamicShadow = false; RightRingFingertipTouchCollider->SetReceivesDecals(true); RightRingFingertipTouchCollider->SetCanEverAffectNavigation(false); - RightRingFingertipTouchCollider->SetCollisionObjectType(ECC_WorldDynamic); + RightRingFingertipTouchCollider->CanCharacterStepUpOn = ECanBeCharacterBase::ECB_Owner; + RightRingFingertipTouchCollider->SetCollisionObjectType(ECC_Pawn); RightRingFingertipTouchCollider->SetCollisionEnabled(ECollisionEnabled::QueryOnly); RightRingFingertipTouchCollider->SetCollisionResponseToAllChannels(ECR_Overlap); RightRingFingertipTouchCollider->SetCollisionResponseToChannel(ECC_WorldStatic, ECR_Overlap); @@ -436,7 +562,8 @@ ASGPawn::ASGPawn(const FObjectInitializer& ObjectInitializer) RightPinkyFingertipTouchCollider->bCastDynamicShadow = false; RightPinkyFingertipTouchCollider->SetReceivesDecals(true); RightPinkyFingertipTouchCollider->SetCanEverAffectNavigation(false); - RightPinkyFingertipTouchCollider->SetCollisionObjectType(ECC_WorldDynamic); + RightPinkyFingertipTouchCollider->CanCharacterStepUpOn = ECanBeCharacterBase::ECB_Owner; + RightPinkyFingertipTouchCollider->SetCollisionObjectType(ECC_Pawn); RightPinkyFingertipTouchCollider->SetCollisionEnabled(ECollisionEnabled::QueryOnly); RightPinkyFingertipTouchCollider->SetCollisionResponseToAllChannels(ECR_Overlap); RightPinkyFingertipTouchCollider->SetCollisionResponseToChannel(ECC_WorldStatic, ECR_Overlap); @@ -469,26 +596,22 @@ void ASGPawn::BeginPlay() WristTrackerLeft->OnWristLocationChanged().AddWeakLambda(this, [&](const FVector& Location)-> void { - HandLeft->SetWorldLocation(Location); - RealHandLeft->SetWorldLocation(Location); + Pimpl->UpdateLeftHandLocation(Location, Pimpl->bUpdateLeftHandLocationAndRotation); }); WristTrackerLeft->OnWristRotationChanged().AddWeakLambda(this, [&](const FRotator& Rotation)-> void { - HandLeft->SetWorldRotation(Rotation); - RealHandLeft->SetWorldRotation(Rotation); + Pimpl->UpdateLeftHandRotation(Rotation, Pimpl->bUpdateLeftHandLocationAndRotation); }); WristTrackerRight->OnWristLocationChanged().AddWeakLambda(this, [&](const FVector& Location)-> void { - HandRight->SetWorldLocation(Location); - RealHandRight->SetWorldLocation(Location); + Pimpl->UpdateRightHandLocation(Location, Pimpl->bUpdateRightHandLocationAndRotation); }); WristTrackerRight->OnWristRotationChanged().AddWeakLambda(this, [&](const FRotator& Rotation)-> void { - HandRight->SetWorldRotation(Rotation); - RealHandRight->SetWorldRotation(Rotation); + Pimpl->UpdateRightHandRotation(Rotation, Pimpl->bUpdateRightHandLocationAndRotation); }); Pimpl->BindRealHandsOverlapEvents(); @@ -526,40 +649,6 @@ void ASGPawn::PreInitializeComponents() void ASGPawn::PostInitializeComponents() { Super::PostInitializeComponents(); - - RealHandLeft = DuplicateObject(HandLeft, this, FName(TEXT("RealHandLeft"))); - if (ensureAlwaysMsgf(IsValid(RealHandLeft), TEXT("failed to duplicate the left hand!"))) - { - RealHandLeft->SetupAttachment(GetRootComponent()); - RealHandLeft->SetCanEverAffectNavigation(false); - RealHandLeft->SetCollisionObjectType(ECC_WorldDynamic); - RealHandLeft->SetCollisionEnabled(ECollisionEnabled::QueryOnly); - RealHandLeft->SetCollisionResponseToAllChannels(ECR_Overlap); - RealHandLeft->SetCollisionResponseToChannel(ECC_WorldStatic, ECR_Overlap); - RealHandLeft->SetCollisionResponseToChannel(ECC_WorldDynamic, ECR_Overlap); - RealHandLeft->SetCollisionResponseToChannel(ECC_Pawn, ECR_Overlap); - RealHandLeft->SetCollisionResponseToChannel(ECC_Visibility, ECR_Overlap); - RealHandLeft->SetCollisionResponseToChannel(ECC_PhysicsBody, ECR_Overlap); - RealHandLeft->SetCollisionResponseToChannel(ECC_Vehicle, ECR_Overlap); - RealHandLeft->SetCollisionResponseToChannel(ECC_Destructible, ECR_Overlap); - } - - RealHandRight = DuplicateObject(HandRight, this, FName(TEXT("RealHandRight"))); - if (ensureAlwaysMsgf(IsValid(RealHandRight), TEXT("failed to duplicate the right hand!"))) - { - RealHandRight->SetupAttachment(GetRootComponent()); - RealHandRight->SetCanEverAffectNavigation(false); - RealHandRight->SetCollisionObjectType(ECC_WorldDynamic); - RealHandRight->SetCollisionEnabled(ECollisionEnabled::QueryOnly); - RealHandRight->SetCollisionResponseToAllChannels(ECR_Overlap); - RealHandRight->SetCollisionResponseToChannel(ECC_WorldStatic, ECR_Overlap); - RealHandRight->SetCollisionResponseToChannel(ECC_WorldDynamic, ECR_Overlap); - RealHandRight->SetCollisionResponseToChannel(ECC_Pawn, ECR_Overlap); - RealHandRight->SetCollisionResponseToChannel(ECC_Visibility, ECR_Overlap); - RealHandRight->SetCollisionResponseToChannel(ECC_PhysicsBody, ECR_Overlap); - RealHandRight->SetCollisionResponseToChannel(ECC_Vehicle, ECR_Overlap); - RealHandRight->SetCollisionResponseToChannel(ECC_Destructible, ECR_Overlap); - } } void ASGPawn::OnRealLeftHandOverlapBegins( @@ -571,9 +660,26 @@ void ASGPawn::OnRealLeftHandOverlapBegins( const FHitResult& SweepResult) { (void) OverlappedComponent; + (void) OtherComp; (void) OtherBodyIndex; (void) bFromSweep; (void) SweepResult; + + if (OtherActor == this) + { + return; + } + + if (!Pimpl->bUpdateLeftHandLocationAndRotation) + { + return; + } + + Pimpl->bUpdateLeftHandLocationAndRotation = false; + + /*FVector WristLocation{WristTrackerLeft->GetWristLocation()}; + FRotator WristRotation{WristTrackerLeft->GetWristRotation()}; + Pimpl->UpdateLeftHandLocationAndRotation(MoveTemp(WristLocation), MoveTemp(WristRotation), true);*/ } void ASGPawn::OnRealLeftHandOverlapEnds( @@ -583,7 +689,24 @@ void ASGPawn::OnRealLeftHandOverlapEnds( const int32 OtherBodyIndex) { (void) OverlappedComponent; + (void) OtherComp; (void) OtherBodyIndex; + + if (OtherActor == this) + { + return; + } + + if (Pimpl->bUpdateLeftHandLocationAndRotation) + { + return; + } + + Pimpl->bUpdateLeftHandLocationAndRotation = true; + + /*FVector WristLocation{WristTrackerLeft->GetWristLocation()}; + FRotator WristRotation{WristTrackerLeft->GetWristRotation()}; + Pimpl->UpdateLeftHandLocationAndRotation(MoveTemp(WristLocation), MoveTemp(WristRotation), true);*/ } void ASGPawn::OnRealRightHandOverlapBegins( @@ -595,9 +718,26 @@ void ASGPawn::OnRealRightHandOverlapBegins( const FHitResult& SweepResult) { (void) OverlappedComponent; + (void) OtherComp; (void) OtherBodyIndex; (void) bFromSweep; (void) SweepResult; + + if (OtherActor == this) + { + return; + } + + if (!Pimpl->bUpdateRightHandLocationAndRotation) + { + return; + } + + Pimpl->bUpdateRightHandLocationAndRotation = false; + + /*FVector WristLocation{WristTrackerRight->GetWristLocation()}; + FRotator WristRotation{WristTrackerRight->GetWristRotation()}; + Pimpl->UpdateRightHandLocationAndRotation(MoveTemp(WristLocation), MoveTemp(WristRotation), true);*/ } void ASGPawn::OnRealRightHandOverlapEnds( @@ -607,7 +747,24 @@ void ASGPawn::OnRealRightHandOverlapEnds( const int32 OtherBodyIndex) { (void) OverlappedComponent; + (void) OtherComp; (void) OtherBodyIndex; + + if (OtherActor == this) + { + return; + } + + if (Pimpl->bUpdateRightHandLocationAndRotation) + { + return; + } + + Pimpl->bUpdateRightHandLocationAndRotation = true; + + /*FVector WristLocation{WristTrackerRight->GetWristLocation()}; + FRotator WristRotation{WristTrackerRight->GetWristRotation()}; + Pimpl->UpdateRightHandLocationAndRotation(MoveTemp(WristLocation), MoveTemp(WristRotation), true);*/ } void ASGPawn::OnLeftThumbFingertipGrabColliderOverlapBegins( @@ -619,6 +776,7 @@ void ASGPawn::OnLeftThumbFingertipGrabColliderOverlapBegins( const FHitResult& SweepResult) { (void) OverlappedComponent; + (void) OtherComp; (void) OtherBodyIndex; (void) bFromSweep; (void) SweepResult; @@ -637,6 +795,7 @@ void ASGPawn::OnLeftThumbFingertipGrabColliderOverlapEnds( const int32 OtherBodyIndex) { (void) OverlappedComponent; + (void) OtherComp; (void) OtherBodyIndex; if (LeftHandGrabState.ActorThumbCanGrab == OtherActor) @@ -655,6 +814,7 @@ void ASGPawn::OnLeftIndexFingertipGrabColliderOverlapBegins( const FHitResult& SweepResult) { (void) OverlappedComponent; + (void) OtherComp; (void) OtherBodyIndex; (void) bFromSweep; (void) SweepResult; @@ -673,6 +833,7 @@ void ASGPawn::OnLeftIndexFingertipGrabColliderOverlapEnds( const int32 OtherBodyIndex) { (void) OverlappedComponent; + (void) OtherComp; (void) OtherBodyIndex; if (LeftHandGrabState.ActorIndexCanGrab == OtherActor) @@ -691,6 +852,7 @@ void ASGPawn::OnLeftMiddleFingertipGrabColliderOverlapBegins( const FHitResult& SweepResult) { (void) OverlappedComponent; + (void) OtherComp; (void) OtherBodyIndex; (void) bFromSweep; (void) SweepResult; @@ -709,6 +871,7 @@ void ASGPawn::OnLeftMiddleFingertipGrabColliderOverlapEnds( const int32 OtherBodyIndex) { (void) OverlappedComponent; + (void) OtherComp; (void) OtherBodyIndex; if (LeftHandGrabState.ActorMiddleCanGrab == OtherActor) @@ -917,6 +1080,7 @@ void ASGPawn::OnRightThumbFingertipGrabColliderOverlapBegins( const FHitResult& SweepResult) { (void) OverlappedComponent; + (void) OtherComp; (void) OtherBodyIndex; (void) bFromSweep; (void) SweepResult; @@ -935,6 +1099,7 @@ void ASGPawn::OnRightThumbFingertipGrabColliderOverlapEnds( const int32 OtherBodyIndex) { (void) OverlappedComponent; + (void) OtherComp; (void) OtherBodyIndex; if (RightHandGrabState.ActorThumbCanGrab == OtherActor) @@ -953,6 +1118,7 @@ void ASGPawn::OnRightIndexFingertipGrabColliderOverlapBegins( const FHitResult& SweepResult) { (void) OverlappedComponent; + (void) OtherComp; (void) OtherBodyIndex; (void) bFromSweep; (void) SweepResult; @@ -971,6 +1137,7 @@ void ASGPawn::OnRightIndexFingertipGrabColliderOverlapEnds( const int32 OtherBodyIndex) { (void) OverlappedComponent; + (void) OtherComp; (void) OtherBodyIndex; if (RightHandGrabState.ActorThumbCanGrab == OtherActor) @@ -989,6 +1156,7 @@ void ASGPawn::OnRightMiddleFingertipGrabColliderOverlapBegins( const FHitResult& SweepResult) { (void) OverlappedComponent; + (void) OtherComp; (void) OtherBodyIndex; (void) bFromSweep; (void) SweepResult; @@ -1007,6 +1175,7 @@ void ASGPawn::OnRightMiddleFingertipGrabColliderOverlapEnds( const int32 OtherBodyIndex) { (void) OverlappedComponent; + (void) OtherComp; (void) OtherBodyIndex; if (RightHandGrabState.ActorMiddleCanGrab == OtherActor) @@ -1309,7 +1478,9 @@ void ASGPawn::ReleaseRight() } ASGPawn::FImpl::FImpl(ASGPawn* InOwner) - : Owner(InOwner) + : bUpdateLeftHandLocationAndRotation(true), + bUpdateRightHandLocationAndRotation(true), + Owner(InOwner) { } @@ -1317,14 +1488,24 @@ void ASGPawn::FImpl::BindRealHandsOverlapEvents() { Owner->RealHandLeft->OnComponentBeginOverlap.AddDynamic( Owner, &ASGPawn::OnRealLeftHandOverlapBegins); + Owner->RealHandLeft->OnComponentEndOverlap.AddDynamic( + Owner, &ASGPawn::OnRealLeftHandOverlapEnds); + Owner->RealHandRight->OnComponentBeginOverlap.AddDynamic( Owner, &ASGPawn::OnRealRightHandOverlapBegins); + Owner->RealHandRight->OnComponentEndOverlap.AddDynamic( + Owner, &ASGPawn::OnRealRightHandOverlapEnds); } void ASGPawn::FImpl::UnbindRealHandsOverlapEvents() { + Owner->RealHandLeft->OnComponentBeginOverlap.RemoveDynamic( + Owner, &ASGPawn::OnRealLeftHandOverlapBegins); Owner->RealHandLeft->OnComponentEndOverlap.RemoveDynamic( Owner, &ASGPawn::OnRealLeftHandOverlapEnds); + + Owner->RealHandRight->OnComponentBeginOverlap.RemoveDynamic( + Owner, &ASGPawn::OnRealRightHandOverlapBegins); Owner->RealHandRight->OnComponentEndOverlap.RemoveDynamic( Owner, &ASGPawn::OnRealRightHandOverlapEnds); } @@ -1516,6 +1697,104 @@ void ASGPawn::FImpl::UnbindFingerTouchOverlapEvents() Owner, &ASGPawn::OnRightPinkyFingertipTouchColliderOverlapEnds); } +void ASGPawn::FImpl::SetVisibility(USceneComponent* SceneComponent, const bool bVisibility) const +{ + if (!ensureAlwaysMsgf(IsValid(SceneComponent), TEXT("Invalid SceneComponent!"))) + { + return; + } + + SceneComponent->SetHiddenInGame(!bVisibility); + SceneComponent->SetVisibility(bVisibility); +} + +void ASGPawn::FImpl::UpdateHandLocation(const bool bRight, const FVector& Location, const bool bUpdateVirtualHand) +{ + if (bRight) + { + UpdateRightHandLocation(Location, bUpdateVirtualHand); + } + else + { + UpdateLeftHandLocation(Location, bUpdateVirtualHand); + } +} + +void ASGPawn::FImpl::UpdateLeftHandLocation(const FVector& Location, const bool bUpdateVirtualHand) +{ + if (bUpdateVirtualHand) + { + Owner->HandLeft->SetWorldLocation(Location); + } + Owner->RealHandLeft->SetWorldLocation(Location); +} + +void ASGPawn::FImpl::UpdateRightHandLocation(const FVector& Location, const bool bUpdateVirtualHand) +{ + if (bUpdateVirtualHand) + { + Owner->HandRight->SetWorldLocation(Location); + } + Owner->RealHandRight->SetWorldLocation(Location); +} + +void ASGPawn::FImpl::UpdateHandRotation(const bool bRight, const FRotator& Rotation, const bool bUpdateVirtualHand) +{ + if (bRight) + { + UpdateRightHandRotation(Rotation, bUpdateVirtualHand); + } + else + { + UpdateLeftHandRotation(Rotation, bUpdateVirtualHand); + } +} + +void ASGPawn::FImpl::UpdateLeftHandRotation(const FRotator& Rotation, const bool bUpdateVirtualHand) +{ + if (bUpdateVirtualHand) + { + Owner->HandLeft->SetWorldRotation(Rotation); + } + Owner->RealHandLeft->SetWorldRotation(Rotation); +} + +void ASGPawn::FImpl::UpdateRightHandRotation(const FRotator& Rotation, const bool bUpdateVirtualHand) +{ + if (bUpdateVirtualHand) + { + Owner->HandRight->SetWorldRotation(Rotation); + } + Owner->RealHandRight->SetWorldRotation(Rotation); +} + +void ASGPawn::FImpl::UpdateHandLocationAndRotation( + const bool bRight, const FVector& Location, const FRotator& Rotation, const bool bUpdateVirtualHand) +{ + if (bRight) + { + UpdateRightHandLocationAndRotation(Location, Rotation, bUpdateVirtualHand); + } + else + { + UpdateLeftHandLocationAndRotation(Location, Rotation, bUpdateVirtualHand); + } +} + +void ASGPawn::FImpl::UpdateLeftHandLocationAndRotation( + const FVector& Location, const FRotator& Rotation, const bool bUpdateVirtualHand) +{ + UpdateLeftHandLocation(Location, bUpdateVirtualHand); + UpdateLeftHandRotation(Rotation, bUpdateVirtualHand); +} + +void ASGPawn::FImpl::UpdateRightHandLocationAndRotation( + const FVector& Location, const FRotator& Rotation, const bool bUpdateVirtualHand) +{ + UpdateRightHandLocation(Location, bUpdateVirtualHand); + UpdateRightHandRotation(Rotation, bUpdateVirtualHand); +} + void ASGPawn::FImpl::DisableActorPhysics(const AActor* Actor) const { UPrimitiveComponent* ActorRootComponent{Cast(Actor->GetRootComponent())}; diff --git a/Source/SenseGlove/Public/SenseGlove/Components/SGVirtualHandComponent.h b/Source/SenseGlove/Public/SenseGlove/Components/SGVirtualHandComponent.h index e6bbca10..e705dc22 100644 --- a/Source/SenseGlove/Public/SenseGlove/Components/SGVirtualHandComponent.h +++ b/Source/SenseGlove/Public/SenseGlove/Components/SGVirtualHandComponent.h @@ -254,6 +254,21 @@ public: PinkyFingertipTouchSocketName = SocketName; } + FORCEINLINE const FSGDebugVirtualHandSettings& GetDebugVirtualHandSettings() const + { + return DebugVirtualHandSettings; + } + + FORCEINLINE FSGDebugVirtualHandSettings& GetDebugVirtualHandSettings() + { + return DebugVirtualHandSettings; + } + + FORCEINLINE void SetDebugVirtualHandSettings(const FSGDebugVirtualHandSettings& InDebugVirtualHandSettings) + { + DebugVirtualHandSettings = InDebugVirtualHandSettings; + } + FORCEINLINE bool IsHiddenInGameIfNoGloveDetected() const { return !!bHiddenInGameIfNoGloveDetected; diff --git a/Source/SenseGlove/Public/SenseGlove/GameFramework/SGPawn.h b/Source/SenseGlove/Public/SenseGlove/GameFramework/SGPawn.h index 4e790303..3a5352ec 100644 --- a/Source/SenseGlove/Public/SenseGlove/GameFramework/SGPawn.h +++ b/Source/SenseGlove/Public/SenseGlove/GameFramework/SGPawn.h @@ -99,6 +99,9 @@ private: UPROPERTY(VisibleAnywhere, Category="SenseGlove", meta=(AllowPrivateAccess="false")) USGVirtualHandComponent* HandLeft; + UPROPERTY(VisibleAnywhere, Category="SenseGlove", meta=(AllowPrivateAccess="false")) + USGVirtualHandComponent* RealHandLeft; + UPROPERTY(EditAnywhere, Category="SenseGlove", meta=(AllowPrivateAccess="false")) USphereComponent* LeftThumbFingertipGrabCollider; @@ -129,6 +132,9 @@ private: UPROPERTY(VisibleAnywhere, Category="SenseGlove", meta=(AllowPrivateAccess="false")) USGVirtualHandComponent* HandRight; + UPROPERTY(VisibleAnywhere, Category="SenseGlove", meta=(AllowPrivateAccess="false")) + USGVirtualHandComponent* RealHandRight; + UPROPERTY(EditAnywhere, Category="SenseGlove", meta=(AllowPrivateAccess="false")) USphereComponent* RightThumbFingertipGrabCollider; @@ -157,12 +163,6 @@ private: int32 MaxNumberOfHandVelocitySamples; private: - UPROPERTY(Transient) - USGVirtualHandComponent* RealHandLeft; - - UPROPERTY(Transient) - USGVirtualHandComponent* RealHandRight; - UPROPERTY(Transient) FSGGrabState LeftHandGrabState; @@ -191,6 +191,11 @@ public: return HandLeft; } + FORCEINLINE USGVirtualHandComponent* GetRealHandLeft() const + { + return RealHandLeft; + } + FORCEINLINE USphereComponent* GetLeftThumbFingertipGrabCollider() const { return LeftThumbFingertipGrabCollider; @@ -241,6 +246,11 @@ public: return HandRight; } + FORCEINLINE USGVirtualHandComponent* GetRealHandRight() const + { + return RealHandRight; + } + FORCEINLINE USphereComponent* GetRightThumbFingertipGrabCollider() const { return RightThumbFingertipGrabCollider; diff --git a/Source/SenseGloveKismet/Private/SGKismet/SGPawnKismetLibrary.cpp b/Source/SenseGloveKismet/Private/SGKismet/SGPawnKismetLibrary.cpp index 7f9e22b8..87131995 100644 --- a/Source/SenseGloveKismet/Private/SGKismet/SGPawnKismetLibrary.cpp +++ b/Source/SenseGloveKismet/Private/SGKismet/SGPawnKismetLibrary.cpp @@ -57,6 +57,11 @@ USGVirtualHandComponent* UPawnKismetLibrary::GetHandLeft(const ASGPawn* Pawn) return Pawn->GetHandLeft(); } +USGVirtualHandComponent* UPawnKismetLibrary::GetRealHandLeft(const ASGPawn* Pawn) +{ + return Pawn->GetHandLeft(); +} + USphereComponent* UPawnKismetLibrary::GetLeftThumbFingertipGrabCollider(const ASGPawn* Pawn) { return Pawn->GetLeftThumbFingertipGrabCollider(); @@ -107,6 +112,11 @@ USGVirtualHandComponent* UPawnKismetLibrary::GetHandRight(const ASGPawn* Pawn) return Pawn->GetHandRight(); } +USGVirtualHandComponent* UPawnKismetLibrary::GetRealHandRight(const ASGPawn* Pawn) +{ + return Pawn->GetRealHandRight(); +} + USphereComponent* UPawnKismetLibrary::GetRightThumbFingertipGrabCollider(const ASGPawn* Pawn) { return Pawn->GetRightThumbFingertipGrabCollider(); diff --git a/Source/SenseGloveKismet/Private/SGKismet/SGVirtualHandComponentKismetLibrary.cpp b/Source/SenseGloveKismet/Private/SGKismet/SGVirtualHandComponentKismetLibrary.cpp index 3617d7ef..6f5943cf 100644 --- a/Source/SenseGloveKismet/Private/SGKismet/SGVirtualHandComponentKismetLibrary.cpp +++ b/Source/SenseGloveKismet/Private/SGKismet/SGVirtualHandComponentKismetLibrary.cpp @@ -72,8 +72,8 @@ bool UVirtualHandComponentKismetLibrary::IsRight(const USGVirtualHandComponent* return VirtualHandComponent->IsRight(); } -void UVirtualHandComponentKismetLibrary::SetRight(USGVirtualHandComponent* VirtualHandComponent, - const bool bInRight) +void UVirtualHandComponentKismetLibrary::SetRight( + USGVirtualHandComponent* VirtualHandComponent, const bool bInRight) { VirtualHandComponent->SetRight(bInRight); } @@ -96,8 +96,8 @@ bool UVirtualHandComponentKismetLibrary::AutoStopsAllHapticsOnEndPlay( return VirtualHandComponent->AutoStopsAllHapticsOnEndPlay(); } -void UVirtualHandComponentKismetLibrary::SetAutoStopAllHapticsOnEndPlay(USGVirtualHandComponent* VirtualHandComponent, - const bool bInAutoStopAllHapticsOnEndPlay) +void UVirtualHandComponentKismetLibrary::SetAutoStopAllHapticsOnEndPlay( + USGVirtualHandComponent* VirtualHandComponent, const bool bInAutoStopAllHapticsOnEndPlay) { VirtualHandComponent->SetAutoStopAllHapticsOnEndPlay(bInAutoStopAllHapticsOnEndPlay); } @@ -119,8 +119,8 @@ const FName& UVirtualHandComponentKismetLibrary::GetThumbFingertipGrabSocketName return VirtualHandComponent->GetThumbFingertipGrabSocketName(); } -void UVirtualHandComponentKismetLibrary::SetThumbFingertipGrabSocketName(USGVirtualHandComponent* VirtualHandComponent, - const FName& SocketName) +void UVirtualHandComponentKismetLibrary::SetThumbFingertipGrabSocketName( + USGVirtualHandComponent* VirtualHandComponent, const FName& SocketName) { VirtualHandComponent->SetThumbFingertipGrabSocketName(SocketName); } @@ -131,8 +131,8 @@ const FName& UVirtualHandComponentKismetLibrary::GetIndexFingertipGrabSocketName return VirtualHandComponent->GetIndexFingertipGrabSocketName(); } -void UVirtualHandComponentKismetLibrary::SetIndexFingertipGrabSocketName(USGVirtualHandComponent* VirtualHandComponent, - const FName& SocketName) +void UVirtualHandComponentKismetLibrary::SetIndexFingertipGrabSocketName( + USGVirtualHandComponent* VirtualHandComponent, const FName& SocketName) { VirtualHandComponent->SetIndexFingertipGrabSocketName(SocketName); } @@ -143,8 +143,8 @@ const FName& UVirtualHandComponentKismetLibrary::GetMiddleFingertipGrabSocketNam return VirtualHandComponent->GetMiddleFingertipGrabSocketName(); } -void UVirtualHandComponentKismetLibrary::SetMiddleFingertipGrabSocketName(USGVirtualHandComponent* VirtualHandComponent, - const FName& SocketName) +void UVirtualHandComponentKismetLibrary::SetMiddleFingertipGrabSocketName( + USGVirtualHandComponent* VirtualHandComponent, const FName& SocketName) { VirtualHandComponent->SetMiddleFingertipGrabSocketName(SocketName); } @@ -161,8 +161,8 @@ const FName& UVirtualHandComponentKismetLibrary::GetThumbFingertipTouchSocketNam return VirtualHandComponent->GetThumbFingertipTouchSocketName(); } -void UVirtualHandComponentKismetLibrary::SetThumbFingertipTouchSocketName(USGVirtualHandComponent* VirtualHandComponent, - const FName& SocketName) +void UVirtualHandComponentKismetLibrary::SetThumbFingertipTouchSocketName( + USGVirtualHandComponent* VirtualHandComponent, const FName& SocketName) { VirtualHandComponent->SetThumbFingertipTouchSocketName(SocketName); } @@ -173,8 +173,8 @@ const FName& UVirtualHandComponentKismetLibrary::GetIndexFingertipTouchSocketNam return VirtualHandComponent->GetIndexFingertipTouchSocketName(); } -void UVirtualHandComponentKismetLibrary::SetIndexFingertipTouchSocketName(USGVirtualHandComponent* VirtualHandComponent, - const FName& SocketName) +void UVirtualHandComponentKismetLibrary::SetIndexFingertipTouchSocketName( + USGVirtualHandComponent* VirtualHandComponent, const FName& SocketName) { VirtualHandComponent->SetIndexFingertipTouchSocketName(SocketName); } @@ -198,8 +198,8 @@ const FName& UVirtualHandComponentKismetLibrary::GetRingFingertipTouchSocketName return VirtualHandComponent->GetRingFingertipTouchSocketName(); } -void UVirtualHandComponentKismetLibrary::SetRingFingertipTouchSocketName(USGVirtualHandComponent* VirtualHandComponent, - const FName& SocketName) +void UVirtualHandComponentKismetLibrary::SetRingFingertipTouchSocketName( + USGVirtualHandComponent* VirtualHandComponent, const FName& SocketName) { VirtualHandComponent->SetRingFingertipTouchSocketName(SocketName); } @@ -210,18 +210,32 @@ const FName& UVirtualHandComponentKismetLibrary::GetPinkyFingertipTouchSocketNam return VirtualHandComponent->GetPinkyFingertipTouchSocketName(); } -void UVirtualHandComponentKismetLibrary::SetPinkyFingertipTouchSocketName(USGVirtualHandComponent* VirtualHandComponent, - const FName& SocketName) +void UVirtualHandComponentKismetLibrary::SetPinkyFingertipTouchSocketName( + USGVirtualHandComponent* VirtualHandComponent, const FName& SocketName) { VirtualHandComponent->SetPinkyFingertipTouchSocketName(SocketName); } +const FSGDebugVirtualHandSettings& UVirtualHandComponentKismetLibrary::GetDebugVirtualHandSettings( + const USGVirtualHandComponent* VirtualHandComponent) +{ + return VirtualHandComponent->GetDebugVirtualHandSettings(); +} + +void UVirtualHandComponentKismetLibrary::SetDebugVirtualHandSettings( + USGVirtualHandComponent* VirtualHandComponent, + const FSGDebugVirtualHandSettings& InDebugVirtualHandSettings) +{ + VirtualHandComponent->SetDebugVirtualHandSettings(InDebugVirtualHandSettings); +} + bool UVirtualHandComponentKismetLibrary::IsGloveConnected(const USGVirtualHandComponent* VirtualHandComponent) { return VirtualHandComponent->IsGloveConnected(); } -USGHapticGlove* UVirtualHandComponentKismetLibrary::GetConnectedGlove(const USGVirtualHandComponent* VirtualHandComponent) +USGHapticGlove* UVirtualHandComponentKismetLibrary::GetConnectedGlove( + const USGVirtualHandComponent* VirtualHandComponent) { return VirtualHandComponent->GetConnectedGlove(); } diff --git a/Source/SenseGloveKismet/Public/SGKismet/SGPawnKismetLibrary.h b/Source/SenseGloveKismet/Public/SGKismet/SGPawnKismetLibrary.h index 4ca49372..32d0cfd7 100644 --- a/Source/SenseGloveKismet/Public/SGKismet/SGPawnKismetLibrary.h +++ b/Source/SenseGloveKismet/Public/SGKismet/SGPawnKismetLibrary.h @@ -71,6 +71,9 @@ public: UFUNCTION(BlueprintPure, Category="SenseGlove | Game Framework | Pawn") static USGVirtualHandComponent* GetHandLeft(const ASGPawn* Pawn); + UFUNCTION(BlueprintPure, Category="SenseGlove | Game Framework | Pawn") + static USGVirtualHandComponent* GetRealHandLeft(const ASGPawn* Pawn); + UFUNCTION(BlueprintPure, Category="SenseGlove | Game Framework | Pawn") static USphereComponent* GetLeftThumbFingertipGrabCollider(const ASGPawn* Pawn); @@ -101,6 +104,9 @@ public: UFUNCTION(BlueprintPure, Category="SenseGlove | Game Framework | Pawn") static USGVirtualHandComponent* GetHandRight(const ASGPawn* Pawn); + UFUNCTION(BlueprintPure, Category="SenseGlove | Game Framework | Pawn") + static USGVirtualHandComponent* GetRealHandRight(const ASGPawn* Pawn); + UFUNCTION(BlueprintPure, Category="SenseGlove | Game Framework | Pawn") static USphereComponent* GetRightThumbFingertipGrabCollider(const ASGPawn* Pawn); diff --git a/Source/SenseGloveKismet/Public/SGKismet/SGVirtualHandComponentKismetLibrary.h b/Source/SenseGloveKismet/Public/SGKismet/SGVirtualHandComponentKismetLibrary.h index 0b7baafc..1d9ef1fa 100644 --- a/Source/SenseGloveKismet/Public/SGKismet/SGVirtualHandComponentKismetLibrary.h +++ b/Source/SenseGloveKismet/Public/SGKismet/SGVirtualHandComponentKismetLibrary.h @@ -160,6 +160,14 @@ public: static void SetPinkyFingertipTouchSocketName(UPARAM(ref) USGVirtualHandComponent* VirtualHandComponent, const FName& SocketName); + UFUNCTION(BlueprintPure, Category="SenseGlove | Components | Virtual Hand Component") + static const FSGDebugVirtualHandSettings& GetDebugVirtualHandSettings( + const USGVirtualHandComponent* VirtualHandComponent); + + UFUNCTION(BlueprintPure, Category="SenseGlove | Components | Virtual Hand Component") + static void SetDebugVirtualHandSettings(UPARAM(ref) USGVirtualHandComponent* VirtualHandComponent, + const FSGDebugVirtualHandSettings& InDebugVirtualHandSettings); + UFUNCTION(BlueprintPure, Category="SenseGlove | Components | Virtual Hand Component") static bool IsGloveConnected(const USGVirtualHandComponent* VirtualHandComponent);