2025 lines
84 KiB
C++
2025 lines
84 KiB
C++
/**
|
|
* @file
|
|
*
|
|
* @author Mamadou Babaei <mamadou@senseglove.com>
|
|
*
|
|
* @section LICENSE
|
|
*
|
|
* (The MIT License)
|
|
*
|
|
* Copyright (c) 2020 - 2023 SenseGlove
|
|
*
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
* of this software and associated documentation files (the "Software"), to deal
|
|
* in the Software without restriction, including without limitation the rights
|
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
* copies of the Software, and to permit persons to whom the Software is
|
|
* furnished to do so, subject to the following conditions:
|
|
*
|
|
* The above copyright notice and this permission notice shall be included in all
|
|
* copies or substantial portions of the Software.
|
|
*
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
* SOFTWARE.
|
|
*
|
|
* @section DESCRIPTION
|
|
*
|
|
*
|
|
*/
|
|
|
|
|
|
#include "SenseGlove/GameFramework/SGPawn.h"
|
|
|
|
#include "Camera/CameraComponent.h"
|
|
#include "Components/PrimitiveComponent.h"
|
|
#include "Components/SphereComponent.h"
|
|
#include "Kismet/KismetMathLibrary.h"
|
|
#include "UObject/UObjectGlobals.h"
|
|
|
|
#include "SenseGlove/Components/SGGrabComponent.h"
|
|
#include "SenseGlove/Components/SGTouchComponent.h"
|
|
#include "SenseGlove/Components/SGVirtualHandComponent.h"
|
|
#include "SenseGlove/Components/SGWristTrackerComponent.h"
|
|
#include "SGLog/SGLog.h"
|
|
|
|
struct ASGPawn::FImpl
|
|
{
|
|
/************************
|
|
* Static methods
|
|
************************/
|
|
|
|
/************************
|
|
* Owner object
|
|
************************/
|
|
|
|
ASGPawn* Owner;
|
|
|
|
/************************
|
|
* Constructor / Destructor
|
|
************************/
|
|
|
|
explicit FImpl(ASGPawn* InOwner);
|
|
~FImpl();
|
|
|
|
/************************
|
|
* Default copy constructor & copy assignment operator
|
|
************************/
|
|
|
|
FImpl(const FImpl& Rhs) = default;
|
|
FImpl& operator=(const FImpl& Rhs) = default;
|
|
|
|
/************************
|
|
* Methods
|
|
************************/
|
|
|
|
void BindRealHandsOverlapEvents();
|
|
void UnbindRealHandsOverlapEvents();
|
|
|
|
void BindFingerGrabOverlapEvents();
|
|
void UnbindFingerGrabOverlapEvents();
|
|
|
|
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);
|
|
|
|
FORCEINLINE void RegisterLeftHandOverlappedActor(const AActor* Actor) const
|
|
{
|
|
Owner->LeftHandOverlappedActors.AddUnique(Actor);
|
|
}
|
|
|
|
FORCEINLINE void UnregisterLeftHandOverlappedActor(const AActor* Actor) const
|
|
{
|
|
Owner->LeftHandOverlappedActors.Remove(Actor);
|
|
}
|
|
|
|
FORCEINLINE void RegisterRightHandOverlappedActor(const AActor* Actor) const
|
|
{
|
|
Owner->RightHandOverlappedActors.AddUnique(Actor);
|
|
}
|
|
|
|
FORCEINLINE void UnregisterRightHandOverlappedActor(const AActor* Actor) const
|
|
{
|
|
Owner->RightHandOverlappedActors.Remove(Actor);
|
|
}
|
|
|
|
FORCEINLINE bool IsLeftHandOverlappingWithAnyActor() const
|
|
{
|
|
return Owner->LeftHandOverlappedActors.Num() > 0;
|
|
}
|
|
|
|
FORCEINLINE bool IsRightHandOverlappingWithAnyActor() const
|
|
{
|
|
return Owner->RightHandOverlappedActors.Num() > 0;
|
|
}
|
|
|
|
void DisableActorPhysics(const AActor* Actor) const;
|
|
void EnableActorPhysics(const AActor* Actor) const;
|
|
|
|
void ApplyHandVelocityToGrabbedActor(const FSGGrabState& GrabState) const;
|
|
|
|
void SetGrabbedActor(FSGGrabState& GrabState, AActor* Actor) const;
|
|
void SetLeftHandGrabbedActor(AActor* Actor) const;
|
|
void SetRightHandGrabbedActor(AActor* Actor) const;
|
|
|
|
void RecordHandVelocity(FSGGrabState& GrabState, const float DeltaSeconds) const;
|
|
|
|
void Release(FSGGrabState& GrabState) const;
|
|
|
|
void TriggerGrabStateUpdatedEvent(const FSGGrabState& GrabState) const;
|
|
void TriggerTouchStateUpdatedEvent(const FSGTouchState& TouchState) const;
|
|
void TriggerActorGrabbedEvent(const USGVirtualHandComponent* Hand, const AActor* Actor) const;
|
|
void TriggerActorReleasedEvent(const USGVirtualHandComponent* Hand, const AActor* Actor) const;
|
|
void TriggerBeginTouch(const USGVirtualHandComponent* Hand, const AActor* Actor) const;
|
|
void TriggerEndTouch(const USGVirtualHandComponent* Hand, const AActor* Actor) const;
|
|
};
|
|
|
|
ASGPawn::ASGPawn(const FObjectInitializer& ObjectInitializer)
|
|
: Super(ObjectInitializer),
|
|
Pimpl(TUniquePtr<FImpl, FImplDeleter>(new FImpl{this}, PimplDeleter))
|
|
{
|
|
PrimaryActorTick.bCanEverTick = true;
|
|
|
|
SceneRoot = ObjectInitializer.CreateDefaultSubobject<USceneComponent>(this, TEXT("SceneRoot"));
|
|
SetRootComponent(SceneRoot);
|
|
|
|
Camera = ObjectInitializer.CreateDefaultSubobject<UCameraComponent>(this, TEXT("Camera"));
|
|
Camera->SetupAttachment(GetRootComponent());
|
|
Camera->SetCanEverAffectNavigation(false);
|
|
|
|
WristTrackerLeft = ObjectInitializer.CreateDefaultSubobject<USGWristTrackerComponent>(
|
|
this, TEXT("WristTrackerLeft"));
|
|
WristTrackerLeft->SetupAttachment(GetRootComponent());
|
|
WristTrackerLeft->SetRight(false);
|
|
|
|
HandLeft = ObjectInitializer.CreateDefaultSubobject<USGVirtualHandComponent>(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},
|
|
false, nullptr, ETeleportType::None);
|
|
HandLeft->SetRelativeLocation(FVector{30.0f, -20.0f, -10.0f},
|
|
false, nullptr, ETeleportType::None);
|
|
HandLeft->SetWristTracker(WristTrackerLeft);
|
|
|
|
RealHandLeft = ObjectInitializer.CreateDefaultSubobject<USGVirtualHandComponent>(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<USphereComponent>(
|
|
this, TEXT("LeftThumbFingertipGrabCollider"));
|
|
LeftThumbFingertipGrabCollider->SetRelativeScale3D(HandLeft->GetDefaultFingertipsGrabColliderSize());
|
|
LeftThumbFingertipGrabCollider->SetupAttachment(HandLeft, HandLeft->GetThumbFingertipGrabSocketName());
|
|
LeftThumbFingertipGrabCollider->SetCastShadow(false);
|
|
LeftThumbFingertipGrabCollider->bCastDynamicShadow = false;
|
|
LeftThumbFingertipGrabCollider->SetReceivesDecals(true);
|
|
LeftThumbFingertipGrabCollider->SetCanEverAffectNavigation(false);
|
|
LeftThumbFingertipGrabCollider->CanCharacterStepUpOn = ECanBeCharacterBase::ECB_Owner;
|
|
LeftThumbFingertipGrabCollider->SetCollisionObjectType(ECC_Pawn);
|
|
LeftThumbFingertipGrabCollider->SetCollisionEnabled(ECollisionEnabled::QueryOnly);
|
|
LeftThumbFingertipGrabCollider->SetCollisionResponseToAllChannels(ECR_Overlap);
|
|
LeftThumbFingertipGrabCollider->SetCollisionResponseToChannel(ECC_WorldStatic, ECR_Overlap);
|
|
LeftThumbFingertipGrabCollider->SetCollisionResponseToChannel(ECC_WorldDynamic, ECR_Overlap);
|
|
LeftThumbFingertipGrabCollider->SetCollisionResponseToChannel(ECC_Pawn, ECR_Overlap);
|
|
LeftThumbFingertipGrabCollider->SetCollisionResponseToChannel(ECC_Visibility, ECR_Overlap);
|
|
LeftThumbFingertipGrabCollider->SetCollisionResponseToChannel(ECC_PhysicsBody, ECR_Overlap);
|
|
LeftThumbFingertipGrabCollider->SetCollisionResponseToChannel(ECC_Vehicle, ECR_Overlap);
|
|
LeftThumbFingertipGrabCollider->SetCollisionResponseToChannel(ECC_Destructible, ECR_Overlap);
|
|
|
|
LeftIndexFingertipGrabCollider = ObjectInitializer.CreateDefaultSubobject<USphereComponent>(
|
|
this, TEXT("LeftIndexFingertipGrabCollider"));
|
|
LeftIndexFingertipGrabCollider->SetRelativeScale3D(HandLeft->GetDefaultFingertipsGrabColliderSize());
|
|
LeftIndexFingertipGrabCollider->SetupAttachment(HandLeft, HandLeft->GetIndexFingertipGrabSocketName());
|
|
LeftIndexFingertipGrabCollider->SetCastShadow(false);
|
|
LeftIndexFingertipGrabCollider->bCastDynamicShadow = false;
|
|
LeftIndexFingertipGrabCollider->SetReceivesDecals(true);
|
|
LeftIndexFingertipGrabCollider->SetCanEverAffectNavigation(false);
|
|
LeftIndexFingertipGrabCollider->CanCharacterStepUpOn = ECanBeCharacterBase::ECB_Owner;
|
|
LeftIndexFingertipGrabCollider->SetCollisionObjectType(ECC_Pawn);
|
|
LeftIndexFingertipGrabCollider->SetCollisionEnabled(ECollisionEnabled::QueryOnly);
|
|
LeftIndexFingertipGrabCollider->SetCollisionResponseToAllChannels(ECR_Overlap);
|
|
LeftIndexFingertipGrabCollider->SetCollisionResponseToChannel(ECC_WorldStatic, ECR_Overlap);
|
|
LeftIndexFingertipGrabCollider->SetCollisionResponseToChannel(ECC_WorldDynamic, ECR_Overlap);
|
|
LeftIndexFingertipGrabCollider->SetCollisionResponseToChannel(ECC_Pawn, ECR_Overlap);
|
|
LeftIndexFingertipGrabCollider->SetCollisionResponseToChannel(ECC_Visibility, ECR_Overlap);
|
|
LeftIndexFingertipGrabCollider->SetCollisionResponseToChannel(ECC_PhysicsBody, ECR_Overlap);
|
|
LeftIndexFingertipGrabCollider->SetCollisionResponseToChannel(ECC_Vehicle, ECR_Overlap);
|
|
LeftIndexFingertipGrabCollider->SetCollisionResponseToChannel(ECC_Destructible, ECR_Overlap);
|
|
|
|
LeftMiddleFingertipGrabCollider = ObjectInitializer.CreateDefaultSubobject<USphereComponent>(
|
|
this, TEXT("LeftMiddleFingertipGrabCollider"));
|
|
LeftMiddleFingertipGrabCollider->SetRelativeScale3D(HandLeft->GetDefaultFingertipsGrabColliderSize());
|
|
LeftMiddleFingertipGrabCollider->SetupAttachment(HandLeft, HandLeft->GetMiddleFingertipGrabSocketName());
|
|
LeftMiddleFingertipGrabCollider->SetCastShadow(false);
|
|
LeftMiddleFingertipGrabCollider->bCastDynamicShadow = false;
|
|
LeftMiddleFingertipGrabCollider->SetReceivesDecals(true);
|
|
LeftMiddleFingertipGrabCollider->SetCanEverAffectNavigation(false);
|
|
LeftMiddleFingertipGrabCollider->CanCharacterStepUpOn = ECanBeCharacterBase::ECB_Owner;
|
|
LeftMiddleFingertipGrabCollider->SetCollisionObjectType(ECC_Pawn);
|
|
LeftMiddleFingertipGrabCollider->SetCollisionEnabled(ECollisionEnabled::QueryOnly);
|
|
LeftMiddleFingertipGrabCollider->SetCollisionResponseToAllChannels(ECR_Overlap);
|
|
LeftMiddleFingertipGrabCollider->SetCollisionResponseToChannel(ECC_WorldStatic, ECR_Overlap);
|
|
LeftMiddleFingertipGrabCollider->SetCollisionResponseToChannel(ECC_WorldDynamic, ECR_Overlap);
|
|
LeftMiddleFingertipGrabCollider->SetCollisionResponseToChannel(ECC_Pawn, ECR_Overlap);
|
|
LeftMiddleFingertipGrabCollider->SetCollisionResponseToChannel(ECC_Visibility, ECR_Overlap);
|
|
LeftMiddleFingertipGrabCollider->SetCollisionResponseToChannel(ECC_PhysicsBody, ECR_Overlap);
|
|
LeftMiddleFingertipGrabCollider->SetCollisionResponseToChannel(ECC_Vehicle, ECR_Overlap);
|
|
LeftMiddleFingertipGrabCollider->SetCollisionResponseToChannel(ECC_Destructible, ECR_Overlap);
|
|
|
|
LeftThumbFingertipTouchCollider = ObjectInitializer.CreateDefaultSubobject<USphereComponent>(
|
|
this, TEXT("LeftThumbFingertipTouchCollider"));
|
|
LeftThumbFingertipTouchCollider->SetRelativeScale3D(HandLeft->GetDefaultFingertipsTouchColliderSize());
|
|
LeftThumbFingertipTouchCollider->SetupAttachment(HandLeft, HandLeft->GetThumbFingertipTouchSocketName());
|
|
LeftThumbFingertipTouchCollider->SetCastShadow(false);
|
|
LeftThumbFingertipTouchCollider->bCastDynamicShadow = false;
|
|
LeftThumbFingertipTouchCollider->SetReceivesDecals(true);
|
|
LeftThumbFingertipTouchCollider->SetCanEverAffectNavigation(false);
|
|
LeftThumbFingertipTouchCollider->CanCharacterStepUpOn = ECanBeCharacterBase::ECB_Owner;
|
|
LeftThumbFingertipTouchCollider->SetCollisionObjectType(ECC_Pawn);
|
|
LeftThumbFingertipTouchCollider->SetCollisionEnabled(ECollisionEnabled::QueryOnly);
|
|
LeftThumbFingertipTouchCollider->SetCollisionResponseToAllChannels(ECR_Overlap);
|
|
LeftThumbFingertipTouchCollider->SetCollisionResponseToChannel(ECC_WorldStatic, ECR_Overlap);
|
|
LeftThumbFingertipTouchCollider->SetCollisionResponseToChannel(ECC_WorldDynamic, ECR_Overlap);
|
|
LeftThumbFingertipTouchCollider->SetCollisionResponseToChannel(ECC_Pawn, ECR_Overlap);
|
|
LeftThumbFingertipTouchCollider->SetCollisionResponseToChannel(ECC_Visibility, ECR_Overlap);
|
|
LeftThumbFingertipTouchCollider->SetCollisionResponseToChannel(ECC_PhysicsBody, ECR_Overlap);
|
|
LeftThumbFingertipTouchCollider->SetCollisionResponseToChannel(ECC_Vehicle, ECR_Overlap);
|
|
LeftThumbFingertipTouchCollider->SetCollisionResponseToChannel(ECC_Destructible, ECR_Overlap);
|
|
|
|
LeftIndexFingertipTouchCollider = ObjectInitializer.CreateDefaultSubobject<USphereComponent>(
|
|
this, TEXT("LeftIndexFingertipTouchCollider"));
|
|
LeftIndexFingertipTouchCollider->SetRelativeScale3D(HandLeft->GetDefaultFingertipsTouchColliderSize());
|
|
LeftIndexFingertipTouchCollider->SetupAttachment(HandLeft, HandLeft->GetIndexFingertipTouchSocketName());
|
|
LeftIndexFingertipTouchCollider->SetCastShadow(false);
|
|
LeftIndexFingertipTouchCollider->bCastDynamicShadow = false;
|
|
LeftIndexFingertipTouchCollider->SetReceivesDecals(true);
|
|
LeftIndexFingertipTouchCollider->SetCanEverAffectNavigation(false);
|
|
LeftIndexFingertipTouchCollider->CanCharacterStepUpOn = ECanBeCharacterBase::ECB_Owner;
|
|
LeftIndexFingertipTouchCollider->SetCollisionObjectType(ECC_Pawn);
|
|
LeftIndexFingertipTouchCollider->SetCollisionEnabled(ECollisionEnabled::QueryOnly);
|
|
LeftIndexFingertipTouchCollider->SetCollisionResponseToAllChannels(ECR_Overlap);
|
|
LeftIndexFingertipTouchCollider->SetCollisionResponseToChannel(ECC_WorldStatic, ECR_Overlap);
|
|
LeftIndexFingertipTouchCollider->SetCollisionResponseToChannel(ECC_WorldDynamic, ECR_Overlap);
|
|
LeftIndexFingertipTouchCollider->SetCollisionResponseToChannel(ECC_Pawn, ECR_Overlap);
|
|
LeftIndexFingertipTouchCollider->SetCollisionResponseToChannel(ECC_Visibility, ECR_Overlap);
|
|
LeftIndexFingertipTouchCollider->SetCollisionResponseToChannel(ECC_PhysicsBody, ECR_Overlap);
|
|
LeftIndexFingertipTouchCollider->SetCollisionResponseToChannel(ECC_Vehicle, ECR_Overlap);
|
|
LeftIndexFingertipTouchCollider->SetCollisionResponseToChannel(ECC_Destructible, ECR_Overlap);
|
|
|
|
LeftMiddleFingertipTouchCollider = ObjectInitializer.CreateDefaultSubobject<USphereComponent>(
|
|
this, TEXT("LeftMiddleFingertipTouchCollider"));
|
|
LeftMiddleFingertipTouchCollider->SetRelativeScale3D(HandLeft->GetDefaultFingertipsTouchColliderSize());
|
|
LeftMiddleFingertipTouchCollider->SetupAttachment(HandLeft, HandLeft->GetMiddleFingertipTouchSocketName());
|
|
LeftMiddleFingertipTouchCollider->SetCastShadow(false);
|
|
LeftMiddleFingertipTouchCollider->bCastDynamicShadow = false;
|
|
LeftMiddleFingertipTouchCollider->SetReceivesDecals(true);
|
|
LeftMiddleFingertipTouchCollider->SetCanEverAffectNavigation(false);
|
|
LeftMiddleFingertipTouchCollider->CanCharacterStepUpOn = ECanBeCharacterBase::ECB_Owner;
|
|
LeftMiddleFingertipTouchCollider->SetCollisionObjectType(ECC_Pawn);
|
|
LeftMiddleFingertipTouchCollider->SetCollisionEnabled(ECollisionEnabled::QueryOnly);
|
|
LeftMiddleFingertipTouchCollider->SetCollisionResponseToAllChannels(ECR_Overlap);
|
|
LeftMiddleFingertipTouchCollider->SetCollisionResponseToChannel(ECC_WorldStatic, ECR_Overlap);
|
|
LeftMiddleFingertipTouchCollider->SetCollisionResponseToChannel(ECC_WorldDynamic, ECR_Overlap);
|
|
LeftMiddleFingertipTouchCollider->SetCollisionResponseToChannel(ECC_Pawn, ECR_Overlap);
|
|
LeftMiddleFingertipTouchCollider->SetCollisionResponseToChannel(ECC_Visibility, ECR_Overlap);
|
|
LeftMiddleFingertipTouchCollider->SetCollisionResponseToChannel(ECC_PhysicsBody, ECR_Overlap);
|
|
LeftMiddleFingertipTouchCollider->SetCollisionResponseToChannel(ECC_Vehicle, ECR_Overlap);
|
|
LeftMiddleFingertipTouchCollider->SetCollisionResponseToChannel(ECC_Destructible, ECR_Overlap);
|
|
|
|
LeftRingFingertipTouchCollider = ObjectInitializer.CreateDefaultSubobject<USphereComponent>(
|
|
this, TEXT("LeftRingFingertipTouchCollider"));
|
|
LeftRingFingertipTouchCollider->SetRelativeScale3D(HandLeft->GetDefaultFingertipsTouchColliderSize());
|
|
LeftRingFingertipTouchCollider->SetupAttachment(HandLeft, HandLeft->GetRingFingertipTouchSocketName());
|
|
LeftRingFingertipTouchCollider->SetCastShadow(false);
|
|
LeftRingFingertipTouchCollider->bCastDynamicShadow = false;
|
|
LeftRingFingertipTouchCollider->SetReceivesDecals(true);
|
|
LeftRingFingertipTouchCollider->SetCanEverAffectNavigation(false);
|
|
LeftRingFingertipTouchCollider->CanCharacterStepUpOn = ECanBeCharacterBase::ECB_Owner;
|
|
LeftRingFingertipTouchCollider->SetCollisionObjectType(ECC_Pawn);
|
|
LeftRingFingertipTouchCollider->SetCollisionEnabled(ECollisionEnabled::QueryOnly);
|
|
LeftRingFingertipTouchCollider->SetCollisionResponseToAllChannels(ECR_Overlap);
|
|
LeftRingFingertipTouchCollider->SetCollisionResponseToChannel(ECC_WorldStatic, ECR_Overlap);
|
|
LeftRingFingertipTouchCollider->SetCollisionResponseToChannel(ECC_WorldDynamic, ECR_Overlap);
|
|
LeftRingFingertipTouchCollider->SetCollisionResponseToChannel(ECC_Pawn, ECR_Overlap);
|
|
LeftRingFingertipTouchCollider->SetCollisionResponseToChannel(ECC_Visibility, ECR_Overlap);
|
|
LeftRingFingertipTouchCollider->SetCollisionResponseToChannel(ECC_PhysicsBody, ECR_Overlap);
|
|
LeftRingFingertipTouchCollider->SetCollisionResponseToChannel(ECC_Vehicle, ECR_Overlap);
|
|
LeftRingFingertipTouchCollider->SetCollisionResponseToChannel(ECC_Destructible, ECR_Overlap);
|
|
|
|
LeftPinkyFingertipTouchCollider = ObjectInitializer.CreateDefaultSubobject<USphereComponent>(
|
|
this, TEXT("LeftPinkyFingertipTouchCollider"));
|
|
LeftPinkyFingertipTouchCollider->SetRelativeScale3D(HandLeft->GetDefaultFingertipsTouchColliderSize());
|
|
LeftPinkyFingertipTouchCollider->SetupAttachment(HandLeft, HandLeft->GetPinkyFingertipTouchSocketName());
|
|
LeftPinkyFingertipTouchCollider->SetCastShadow(false);
|
|
LeftPinkyFingertipTouchCollider->bCastDynamicShadow = false;
|
|
LeftPinkyFingertipTouchCollider->SetReceivesDecals(true);
|
|
LeftPinkyFingertipTouchCollider->SetCanEverAffectNavigation(false);
|
|
LeftPinkyFingertipTouchCollider->CanCharacterStepUpOn = ECanBeCharacterBase::ECB_Owner;
|
|
LeftPinkyFingertipTouchCollider->SetCollisionObjectType(ECC_Pawn);
|
|
LeftPinkyFingertipTouchCollider->SetCollisionEnabled(ECollisionEnabled::QueryOnly);
|
|
LeftPinkyFingertipTouchCollider->SetCollisionResponseToAllChannels(ECR_Overlap);
|
|
LeftPinkyFingertipTouchCollider->SetCollisionResponseToChannel(ECC_WorldStatic, ECR_Overlap);
|
|
LeftPinkyFingertipTouchCollider->SetCollisionResponseToChannel(ECC_WorldDynamic, ECR_Overlap);
|
|
LeftPinkyFingertipTouchCollider->SetCollisionResponseToChannel(ECC_Pawn, ECR_Overlap);
|
|
LeftPinkyFingertipTouchCollider->SetCollisionResponseToChannel(ECC_Visibility, ECR_Overlap);
|
|
LeftPinkyFingertipTouchCollider->SetCollisionResponseToChannel(ECC_PhysicsBody, ECR_Overlap);
|
|
LeftPinkyFingertipTouchCollider->SetCollisionResponseToChannel(ECC_Vehicle, ECR_Overlap);
|
|
LeftPinkyFingertipTouchCollider->SetCollisionResponseToChannel(ECC_Destructible, ECR_Overlap);
|
|
|
|
WristTrackerRight = ObjectInitializer.CreateDefaultSubobject<USGWristTrackerComponent>(
|
|
this, TEXT("WristTrackerRight"));
|
|
WristTrackerRight->SetupAttachment(GetRootComponent());
|
|
WristTrackerRight->SetRight(true);
|
|
|
|
HandRight = ObjectInitializer.CreateDefaultSubobject<USGVirtualHandComponent>(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);
|
|
HandRight->SetRelativeLocation(FVector{30.0f, 20.0f, -10.0f},
|
|
false, nullptr, ETeleportType::None);
|
|
HandRight->SetWristTracker(WristTrackerRight);
|
|
|
|
RealHandRight = ObjectInitializer.CreateDefaultSubobject<USGVirtualHandComponent>(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<USphereComponent>(
|
|
this, TEXT("RightThumbFingertipGrabCollider"));
|
|
RightThumbFingertipGrabCollider->SetRelativeScale3D(HandLeft->GetDefaultFingertipsGrabColliderSize());
|
|
RightThumbFingertipGrabCollider->SetupAttachment(HandRight, HandRight->GetThumbFingertipGrabSocketName());
|
|
RightThumbFingertipGrabCollider->SetCastShadow(false);
|
|
RightThumbFingertipGrabCollider->bCastDynamicShadow = false;
|
|
RightThumbFingertipGrabCollider->SetReceivesDecals(true);
|
|
RightThumbFingertipGrabCollider->SetCanEverAffectNavigation(false);
|
|
RightThumbFingertipGrabCollider->CanCharacterStepUpOn = ECanBeCharacterBase::ECB_Owner;
|
|
RightThumbFingertipGrabCollider->SetCollisionObjectType(ECC_Pawn);
|
|
RightThumbFingertipGrabCollider->SetCollisionEnabled(ECollisionEnabled::QueryOnly);
|
|
RightThumbFingertipGrabCollider->SetCollisionResponseToAllChannels(ECR_Overlap);
|
|
RightThumbFingertipGrabCollider->SetCollisionResponseToChannel(ECC_WorldStatic, ECR_Overlap);
|
|
RightThumbFingertipGrabCollider->SetCollisionResponseToChannel(ECC_WorldDynamic, ECR_Overlap);
|
|
RightThumbFingertipGrabCollider->SetCollisionResponseToChannel(ECC_Pawn, ECR_Overlap);
|
|
RightThumbFingertipGrabCollider->SetCollisionResponseToChannel(ECC_Visibility, ECR_Overlap);
|
|
RightThumbFingertipGrabCollider->SetCollisionResponseToChannel(ECC_PhysicsBody, ECR_Overlap);
|
|
RightThumbFingertipGrabCollider->SetCollisionResponseToChannel(ECC_Vehicle, ECR_Overlap);
|
|
RightThumbFingertipGrabCollider->SetCollisionResponseToChannel(ECC_Destructible, ECR_Overlap);
|
|
|
|
RightIndexFingertipGrabCollider = ObjectInitializer.CreateDefaultSubobject<USphereComponent>(
|
|
this, TEXT("RightIndexFingertipGrabCollider"));
|
|
RightIndexFingertipGrabCollider->SetRelativeScale3D(HandLeft->GetDefaultFingertipsGrabColliderSize());
|
|
RightIndexFingertipGrabCollider->SetupAttachment(HandRight, HandRight->GetIndexFingertipGrabSocketName());
|
|
RightIndexFingertipGrabCollider->SetCastShadow(false);
|
|
RightIndexFingertipGrabCollider->bCastDynamicShadow = false;
|
|
RightIndexFingertipGrabCollider->SetReceivesDecals(true);
|
|
RightIndexFingertipGrabCollider->SetCanEverAffectNavigation(false);
|
|
RightIndexFingertipGrabCollider->CanCharacterStepUpOn = ECanBeCharacterBase::ECB_Owner;
|
|
RightIndexFingertipGrabCollider->SetCollisionObjectType(ECC_Pawn);
|
|
RightIndexFingertipGrabCollider->SetCollisionEnabled(ECollisionEnabled::QueryOnly);
|
|
RightIndexFingertipGrabCollider->SetCollisionResponseToAllChannels(ECR_Overlap);
|
|
RightIndexFingertipGrabCollider->SetCollisionResponseToChannel(ECC_WorldStatic, ECR_Overlap);
|
|
RightIndexFingertipGrabCollider->SetCollisionResponseToChannel(ECC_WorldDynamic, ECR_Overlap);
|
|
RightIndexFingertipGrabCollider->SetCollisionResponseToChannel(ECC_Pawn, ECR_Overlap);
|
|
RightIndexFingertipGrabCollider->SetCollisionResponseToChannel(ECC_Visibility, ECR_Overlap);
|
|
RightIndexFingertipGrabCollider->SetCollisionResponseToChannel(ECC_PhysicsBody, ECR_Overlap);
|
|
RightIndexFingertipGrabCollider->SetCollisionResponseToChannel(ECC_Vehicle, ECR_Overlap);
|
|
RightIndexFingertipGrabCollider->SetCollisionResponseToChannel(ECC_Destructible, ECR_Overlap);
|
|
|
|
RightMiddleFingertipGrabCollider = ObjectInitializer.CreateDefaultSubobject<USphereComponent>(
|
|
this, TEXT("RightMiddleFingertipGrabCollider"));
|
|
RightMiddleFingertipGrabCollider->SetRelativeScale3D(HandLeft->GetDefaultFingertipsGrabColliderSize());
|
|
RightMiddleFingertipGrabCollider->SetupAttachment(HandRight, HandRight->GetMiddleFingertipGrabSocketName());
|
|
RightMiddleFingertipGrabCollider->SetCastShadow(false);
|
|
RightMiddleFingertipGrabCollider->bCastDynamicShadow = false;
|
|
RightMiddleFingertipGrabCollider->SetReceivesDecals(true);
|
|
RightMiddleFingertipGrabCollider->SetCanEverAffectNavigation(false);
|
|
RightMiddleFingertipGrabCollider->CanCharacterStepUpOn = ECanBeCharacterBase::ECB_Owner;
|
|
RightMiddleFingertipGrabCollider->SetCollisionObjectType(ECC_Pawn);
|
|
RightMiddleFingertipGrabCollider->SetCollisionEnabled(ECollisionEnabled::QueryOnly);
|
|
RightMiddleFingertipGrabCollider->SetCollisionResponseToAllChannels(ECR_Overlap);
|
|
RightMiddleFingertipGrabCollider->SetCollisionResponseToChannel(ECC_WorldStatic, ECR_Overlap);
|
|
RightMiddleFingertipGrabCollider->SetCollisionResponseToChannel(ECC_WorldDynamic, ECR_Overlap);
|
|
RightMiddleFingertipGrabCollider->SetCollisionResponseToChannel(ECC_Pawn, ECR_Overlap);
|
|
RightMiddleFingertipGrabCollider->SetCollisionResponseToChannel(ECC_Visibility, ECR_Overlap);
|
|
RightMiddleFingertipGrabCollider->SetCollisionResponseToChannel(ECC_PhysicsBody, ECR_Overlap);
|
|
RightMiddleFingertipGrabCollider->SetCollisionResponseToChannel(ECC_Vehicle, ECR_Overlap);
|
|
RightMiddleFingertipGrabCollider->SetCollisionResponseToChannel(ECC_Destructible, ECR_Overlap);
|
|
|
|
RightThumbFingertipTouchCollider = ObjectInitializer.CreateDefaultSubobject<USphereComponent>(
|
|
this, TEXT("RightThumbFingertipTouchCollider"));
|
|
RightThumbFingertipTouchCollider->SetRelativeScale3D(HandRight->GetDefaultFingertipsTouchColliderSize());
|
|
RightThumbFingertipTouchCollider->SetupAttachment(HandRight, HandRight->GetThumbFingertipTouchSocketName());
|
|
RightThumbFingertipTouchCollider->SetCastShadow(false);
|
|
RightThumbFingertipTouchCollider->bCastDynamicShadow = false;
|
|
RightThumbFingertipTouchCollider->SetReceivesDecals(true);
|
|
RightThumbFingertipTouchCollider->SetCanEverAffectNavigation(false);
|
|
RightThumbFingertipTouchCollider->CanCharacterStepUpOn = ECanBeCharacterBase::ECB_Owner;
|
|
RightThumbFingertipTouchCollider->SetCollisionObjectType(ECC_Pawn);
|
|
RightThumbFingertipTouchCollider->SetCollisionEnabled(ECollisionEnabled::QueryOnly);
|
|
RightThumbFingertipTouchCollider->SetCollisionResponseToAllChannels(ECR_Overlap);
|
|
RightThumbFingertipTouchCollider->SetCollisionResponseToChannel(ECC_WorldStatic, ECR_Overlap);
|
|
RightThumbFingertipTouchCollider->SetCollisionResponseToChannel(ECC_WorldDynamic, ECR_Overlap);
|
|
RightThumbFingertipTouchCollider->SetCollisionResponseToChannel(ECC_Pawn, ECR_Overlap);
|
|
RightThumbFingertipTouchCollider->SetCollisionResponseToChannel(ECC_Visibility, ECR_Overlap);
|
|
RightThumbFingertipTouchCollider->SetCollisionResponseToChannel(ECC_PhysicsBody, ECR_Overlap);
|
|
RightThumbFingertipTouchCollider->SetCollisionResponseToChannel(ECC_Vehicle, ECR_Overlap);
|
|
RightThumbFingertipTouchCollider->SetCollisionResponseToChannel(ECC_Destructible, ECR_Overlap);
|
|
|
|
RightIndexFingertipTouchCollider = ObjectInitializer.CreateDefaultSubobject<USphereComponent>(
|
|
this, TEXT("RightIndexFingertipTouchCollider"));
|
|
RightIndexFingertipTouchCollider->SetRelativeScale3D(HandRight->GetDefaultFingertipsTouchColliderSize());
|
|
RightIndexFingertipTouchCollider->SetupAttachment(HandRight, HandRight->GetIndexFingertipTouchSocketName());
|
|
RightIndexFingertipTouchCollider->SetCastShadow(false);
|
|
RightIndexFingertipTouchCollider->bCastDynamicShadow = false;
|
|
RightIndexFingertipTouchCollider->SetReceivesDecals(true);
|
|
RightIndexFingertipTouchCollider->SetCanEverAffectNavigation(false);
|
|
RightIndexFingertipTouchCollider->CanCharacterStepUpOn = ECanBeCharacterBase::ECB_Owner;
|
|
RightIndexFingertipTouchCollider->SetCollisionObjectType(ECC_Pawn);
|
|
RightIndexFingertipTouchCollider->SetCollisionEnabled(ECollisionEnabled::QueryOnly);
|
|
RightIndexFingertipTouchCollider->SetCollisionResponseToAllChannels(ECR_Overlap);
|
|
RightIndexFingertipTouchCollider->SetCollisionResponseToChannel(ECC_WorldStatic, ECR_Overlap);
|
|
RightIndexFingertipTouchCollider->SetCollisionResponseToChannel(ECC_WorldDynamic, ECR_Overlap);
|
|
RightIndexFingertipTouchCollider->SetCollisionResponseToChannel(ECC_Pawn, ECR_Overlap);
|
|
RightIndexFingertipTouchCollider->SetCollisionResponseToChannel(ECC_Visibility, ECR_Overlap);
|
|
RightIndexFingertipTouchCollider->SetCollisionResponseToChannel(ECC_PhysicsBody, ECR_Overlap);
|
|
RightIndexFingertipTouchCollider->SetCollisionResponseToChannel(ECC_Vehicle, ECR_Overlap);
|
|
RightIndexFingertipTouchCollider->SetCollisionResponseToChannel(ECC_Destructible, ECR_Overlap);
|
|
|
|
RightMiddleFingertipTouchCollider = ObjectInitializer.CreateDefaultSubobject<USphereComponent>(
|
|
this, TEXT("RightMiddleFingertipTouchCollider"));
|
|
RightMiddleFingertipTouchCollider->SetRelativeScale3D(HandRight->GetDefaultFingertipsTouchColliderSize());
|
|
RightMiddleFingertipTouchCollider->SetupAttachment(HandRight, HandRight->GetMiddleFingertipTouchSocketName());
|
|
RightMiddleFingertipTouchCollider->SetCastShadow(false);
|
|
RightMiddleFingertipTouchCollider->bCastDynamicShadow = false;
|
|
RightMiddleFingertipTouchCollider->SetReceivesDecals(true);
|
|
RightMiddleFingertipTouchCollider->SetCanEverAffectNavigation(false);
|
|
RightMiddleFingertipTouchCollider->CanCharacterStepUpOn = ECanBeCharacterBase::ECB_Owner;
|
|
RightMiddleFingertipTouchCollider->SetCollisionObjectType(ECC_Pawn);
|
|
RightMiddleFingertipTouchCollider->SetCollisionEnabled(ECollisionEnabled::QueryOnly);
|
|
RightMiddleFingertipTouchCollider->SetCollisionResponseToAllChannels(ECR_Overlap);
|
|
RightMiddleFingertipTouchCollider->SetCollisionResponseToChannel(ECC_WorldStatic, ECR_Overlap);
|
|
RightMiddleFingertipTouchCollider->SetCollisionResponseToChannel(ECC_WorldDynamic, ECR_Overlap);
|
|
RightMiddleFingertipTouchCollider->SetCollisionResponseToChannel(ECC_Pawn, ECR_Overlap);
|
|
RightMiddleFingertipTouchCollider->SetCollisionResponseToChannel(ECC_Visibility, ECR_Overlap);
|
|
RightMiddleFingertipTouchCollider->SetCollisionResponseToChannel(ECC_PhysicsBody, ECR_Overlap);
|
|
RightMiddleFingertipTouchCollider->SetCollisionResponseToChannel(ECC_Vehicle, ECR_Overlap);
|
|
RightMiddleFingertipTouchCollider->SetCollisionResponseToChannel(ECC_Destructible, ECR_Overlap);
|
|
|
|
RightRingFingertipTouchCollider = ObjectInitializer.CreateDefaultSubobject<USphereComponent>(
|
|
this, TEXT("RightRingFingertipTouchCollider"));
|
|
RightRingFingertipTouchCollider->SetRelativeScale3D(HandRight->GetDefaultFingertipsTouchColliderSize());
|
|
RightRingFingertipTouchCollider->SetupAttachment(HandRight, HandRight->GetRingFingertipTouchSocketName());
|
|
RightRingFingertipTouchCollider->SetCastShadow(false);
|
|
RightRingFingertipTouchCollider->bCastDynamicShadow = false;
|
|
RightRingFingertipTouchCollider->SetReceivesDecals(true);
|
|
RightRingFingertipTouchCollider->SetCanEverAffectNavigation(false);
|
|
RightRingFingertipTouchCollider->CanCharacterStepUpOn = ECanBeCharacterBase::ECB_Owner;
|
|
RightRingFingertipTouchCollider->SetCollisionObjectType(ECC_Pawn);
|
|
RightRingFingertipTouchCollider->SetCollisionEnabled(ECollisionEnabled::QueryOnly);
|
|
RightRingFingertipTouchCollider->SetCollisionResponseToAllChannels(ECR_Overlap);
|
|
RightRingFingertipTouchCollider->SetCollisionResponseToChannel(ECC_WorldStatic, ECR_Overlap);
|
|
RightRingFingertipTouchCollider->SetCollisionResponseToChannel(ECC_WorldDynamic, ECR_Overlap);
|
|
RightRingFingertipTouchCollider->SetCollisionResponseToChannel(ECC_Pawn, ECR_Overlap);
|
|
RightRingFingertipTouchCollider->SetCollisionResponseToChannel(ECC_Visibility, ECR_Overlap);
|
|
RightRingFingertipTouchCollider->SetCollisionResponseToChannel(ECC_PhysicsBody, ECR_Overlap);
|
|
RightRingFingertipTouchCollider->SetCollisionResponseToChannel(ECC_Vehicle, ECR_Overlap);
|
|
RightRingFingertipTouchCollider->SetCollisionResponseToChannel(ECC_Destructible, ECR_Overlap);
|
|
|
|
RightPinkyFingertipTouchCollider = ObjectInitializer.CreateDefaultSubobject<USphereComponent>(
|
|
this, TEXT("RightPinkyFingertipTouchCollider"));
|
|
RightPinkyFingertipTouchCollider->SetRelativeScale3D(HandRight->GetDefaultFingertipsTouchColliderSize());
|
|
RightPinkyFingertipTouchCollider->SetupAttachment(HandRight, HandRight->GetPinkyFingertipTouchSocketName());
|
|
RightPinkyFingertipTouchCollider->SetCastShadow(false);
|
|
RightPinkyFingertipTouchCollider->bCastDynamicShadow = false;
|
|
RightPinkyFingertipTouchCollider->SetReceivesDecals(true);
|
|
RightPinkyFingertipTouchCollider->SetCanEverAffectNavigation(false);
|
|
RightPinkyFingertipTouchCollider->CanCharacterStepUpOn = ECanBeCharacterBase::ECB_Owner;
|
|
RightPinkyFingertipTouchCollider->SetCollisionObjectType(ECC_Pawn);
|
|
RightPinkyFingertipTouchCollider->SetCollisionEnabled(ECollisionEnabled::QueryOnly);
|
|
RightPinkyFingertipTouchCollider->SetCollisionResponseToAllChannels(ECR_Overlap);
|
|
RightPinkyFingertipTouchCollider->SetCollisionResponseToChannel(ECC_WorldStatic, ECR_Overlap);
|
|
RightPinkyFingertipTouchCollider->SetCollisionResponseToChannel(ECC_WorldDynamic, ECR_Overlap);
|
|
RightPinkyFingertipTouchCollider->SetCollisionResponseToChannel(ECC_Pawn, ECR_Overlap);
|
|
RightPinkyFingertipTouchCollider->SetCollisionResponseToChannel(ECC_Visibility, ECR_Overlap);
|
|
RightPinkyFingertipTouchCollider->SetCollisionResponseToChannel(ECC_PhysicsBody, ECR_Overlap);
|
|
RightPinkyFingertipTouchCollider->SetCollisionResponseToChannel(ECC_Vehicle, ECR_Overlap);
|
|
RightPinkyFingertipTouchCollider->SetCollisionResponseToChannel(ECC_Destructible, ECR_Overlap);
|
|
|
|
MaxNumberOfHandVelocitySamples = 10;
|
|
|
|
LeftHandGrabState = FSGGrabState(HandLeft, FVector::Zero(), {}, nullptr, nullptr, nullptr, nullptr);
|
|
LeftHandTouchState = FSGTouchState(HandLeft, nullptr, nullptr, nullptr, nullptr, nullptr);
|
|
|
|
RightHandGrabState = FSGGrabState(HandRight, FVector::Zero(), {}, nullptr, nullptr, nullptr, nullptr);
|
|
RightHandTouchState = FSGTouchState(HandRight, nullptr, nullptr, nullptr, nullptr, nullptr);
|
|
}
|
|
|
|
void ASGPawn::OnGrabStateUpdated_Implementation(const FSGGrabState& GrabState)
|
|
{
|
|
}
|
|
|
|
void ASGPawn::OnTouchStateUpdated_Implementation(const FSGTouchState& TouchState)
|
|
{
|
|
}
|
|
|
|
void ASGPawn::OnActorGrabbed_Implementation(const USGVirtualHandComponent* Hand, const AActor* Actor)
|
|
{
|
|
}
|
|
|
|
void ASGPawn::OnActorReleased_Implementation(const USGVirtualHandComponent* Hand, const AActor* Actor)
|
|
{
|
|
}
|
|
|
|
void ASGPawn::OnActorBeginTouch_Implementation(const USGVirtualHandComponent* Hand, const AActor* Actor)
|
|
{
|
|
}
|
|
|
|
void ASGPawn::OnActorEndTouch_Implementation(const USGVirtualHandComponent* Hand, const AActor* Actor)
|
|
{
|
|
}
|
|
|
|
void ASGPawn::BeginPlay()
|
|
{
|
|
Super::BeginPlay();
|
|
|
|
ensureAlwaysMsgf(
|
|
WristTrackerLeft->IsLeft() && HandLeft->IsLeft(),
|
|
TEXT("The left hand and the left wrist do not track the left hand!"));
|
|
ensureAlwaysMsgf(
|
|
WristTrackerRight->IsRight() && HandRight->IsRight(),
|
|
TEXT("The right hand and the right wrist do not track the right hand!"));
|
|
|
|
WristTrackerLeft->OnWristLocationChanged().AddWeakLambda(this, [&](const FVector& Location)-> void
|
|
{
|
|
Pimpl->UpdateLeftHandLocation(Location, !Pimpl->IsLeftHandOverlappingWithAnyActor());
|
|
});
|
|
|
|
WristTrackerLeft->OnWristRotationChanged().AddWeakLambda(this, [&](const FRotator& Rotation)-> void
|
|
{
|
|
Pimpl->UpdateLeftHandRotation(Rotation, !Pimpl->IsLeftHandOverlappingWithAnyActor());
|
|
});
|
|
|
|
WristTrackerRight->OnWristLocationChanged().AddWeakLambda(this, [&](const FVector& Location)-> void
|
|
{
|
|
Pimpl->UpdateRightHandLocation(Location, !Pimpl->IsRightHandOverlappingWithAnyActor());
|
|
});
|
|
|
|
WristTrackerRight->OnWristRotationChanged().AddWeakLambda(this, [&](const FRotator& Rotation)-> void
|
|
{
|
|
Pimpl->UpdateRightHandRotation(Rotation, !Pimpl->IsRightHandOverlappingWithAnyActor());
|
|
});
|
|
|
|
Pimpl->BindRealHandsOverlapEvents();
|
|
|
|
Pimpl->BindFingerGrabOverlapEvents();
|
|
Pimpl->BindFingerTouchOverlapEvents();
|
|
}
|
|
|
|
void ASGPawn::EndPlay(const EEndPlayReason::Type EndPlayReason)
|
|
{
|
|
Super::EndPlay(EndPlayReason);
|
|
|
|
Pimpl->UnbindRealHandsOverlapEvents();
|
|
|
|
Pimpl->UnbindFingerGrabOverlapEvents();
|
|
Pimpl->UnbindFingerTouchOverlapEvents();
|
|
}
|
|
|
|
void ASGPawn::Tick(const float DeltaSeconds)
|
|
{
|
|
Super::Tick(DeltaSeconds);
|
|
|
|
Pimpl->RecordHandVelocity(LeftHandGrabState, DeltaSeconds);
|
|
Pimpl->RecordHandVelocity(RightHandGrabState, DeltaSeconds);
|
|
}
|
|
|
|
void ASGPawn::PreInitializeComponents()
|
|
{
|
|
Super::PreInitializeComponents();
|
|
|
|
WristTrackerLeft->SetRight(HandLeft->IsRight());
|
|
WristTrackerRight->SetRight(HandRight->IsRight());
|
|
}
|
|
|
|
void ASGPawn::PostInitializeComponents()
|
|
{
|
|
Super::PostInitializeComponents();
|
|
}
|
|
|
|
void ASGPawn::OnRealLeftHandOverlapBegins(
|
|
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 (OtherActor == this)
|
|
{
|
|
return;
|
|
}
|
|
|
|
if (OtherActor == LeftHandGrabState.GrabbedActor)
|
|
{
|
|
return;
|
|
}
|
|
|
|
Pimpl->RegisterLeftHandOverlappedActor(OtherActor);
|
|
}
|
|
|
|
void ASGPawn::OnRealLeftHandOverlapEnds(
|
|
UPrimitiveComponent* OverlappedComponent,
|
|
AActor* OtherActor,
|
|
UPrimitiveComponent* OtherComp,
|
|
const int32 OtherBodyIndex)
|
|
{
|
|
(void) OverlappedComponent;
|
|
(void) OtherComp;
|
|
(void) OtherBodyIndex;
|
|
|
|
if (OtherActor == this)
|
|
{
|
|
return;
|
|
}
|
|
|
|
Pimpl->UnregisterLeftHandOverlappedActor(OtherActor);
|
|
}
|
|
|
|
void ASGPawn::OnRealRightHandOverlapBegins(
|
|
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 (OtherActor == this)
|
|
{
|
|
return;
|
|
}
|
|
|
|
if (OtherActor == RightHandGrabState.GrabbedActor)
|
|
{
|
|
return;
|
|
}
|
|
|
|
Pimpl->RegisterRightHandOverlappedActor(OtherActor);
|
|
}
|
|
|
|
void ASGPawn::OnRealRightHandOverlapEnds(
|
|
UPrimitiveComponent* OverlappedComponent,
|
|
AActor* OtherActor,
|
|
UPrimitiveComponent* OtherComp,
|
|
const int32 OtherBodyIndex)
|
|
{
|
|
(void) OverlappedComponent;
|
|
(void) OtherComp;
|
|
(void) OtherBodyIndex;
|
|
|
|
if (OtherActor == this)
|
|
{
|
|
return;
|
|
}
|
|
|
|
Pimpl->UnregisterRightHandOverlappedActor(OtherActor);
|
|
}
|
|
|
|
void ASGPawn::OnLeftThumbFingertipGrabColliderOverlapBegins(
|
|
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))
|
|
{
|
|
LeftHandGrabState.ActorThumbCanGrab = OtherActor;
|
|
Pimpl->TriggerGrabStateUpdatedEvent(LeftHandGrabState);
|
|
}
|
|
}
|
|
|
|
void ASGPawn::OnLeftThumbFingertipGrabColliderOverlapEnds(
|
|
UPrimitiveComponent* OverlappedComponent,
|
|
AActor* OtherActor,
|
|
UPrimitiveComponent* OtherComp,
|
|
const int32 OtherBodyIndex)
|
|
{
|
|
(void) OverlappedComponent;
|
|
(void) OtherComp;
|
|
(void) OtherBodyIndex;
|
|
|
|
if (LeftHandGrabState.ActorThumbCanGrab == OtherActor)
|
|
{
|
|
LeftHandGrabState.ActorThumbCanGrab = nullptr;
|
|
Pimpl->TriggerGrabStateUpdatedEvent(LeftHandGrabState);
|
|
}
|
|
}
|
|
|
|
void ASGPawn::OnLeftIndexFingertipGrabColliderOverlapBegins(
|
|
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))
|
|
{
|
|
LeftHandGrabState.ActorIndexCanGrab = OtherActor;
|
|
Pimpl->TriggerGrabStateUpdatedEvent(LeftHandGrabState);
|
|
}
|
|
}
|
|
|
|
void ASGPawn::OnLeftIndexFingertipGrabColliderOverlapEnds(
|
|
UPrimitiveComponent* OverlappedComponent,
|
|
AActor* OtherActor,
|
|
UPrimitiveComponent* OtherComp,
|
|
const int32 OtherBodyIndex)
|
|
{
|
|
(void) OverlappedComponent;
|
|
(void) OtherComp;
|
|
(void) OtherBodyIndex;
|
|
|
|
if (LeftHandGrabState.ActorIndexCanGrab == OtherActor)
|
|
{
|
|
LeftHandGrabState.ActorIndexCanGrab = nullptr;
|
|
Pimpl->TriggerGrabStateUpdatedEvent(LeftHandGrabState);
|
|
}
|
|
}
|
|
|
|
void ASGPawn::OnLeftMiddleFingertipGrabColliderOverlapBegins(
|
|
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))
|
|
{
|
|
LeftHandGrabState.ActorMiddleCanGrab = OtherActor;
|
|
Pimpl->TriggerGrabStateUpdatedEvent(LeftHandGrabState);
|
|
}
|
|
}
|
|
|
|
void ASGPawn::OnLeftMiddleFingertipGrabColliderOverlapEnds(
|
|
UPrimitiveComponent* OverlappedComponent,
|
|
AActor* OtherActor,
|
|
UPrimitiveComponent* OtherComp,
|
|
const int32 OtherBodyIndex)
|
|
{
|
|
(void) OverlappedComponent;
|
|
(void) OtherComp;
|
|
(void) OtherBodyIndex;
|
|
|
|
if (LeftHandGrabState.ActorMiddleCanGrab == OtherActor)
|
|
{
|
|
LeftHandGrabState.ActorMiddleCanGrab = nullptr;
|
|
Pimpl->TriggerGrabStateUpdatedEvent(LeftHandGrabState);
|
|
}
|
|
}
|
|
|
|
void ASGPawn::OnLeftThumbFingertipTouchColliderOverlapBegins(
|
|
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))
|
|
{
|
|
LeftHandTouchState.ActorThumbTouching = OtherActor;
|
|
Pimpl->TriggerTouchStateUpdatedEvent(LeftHandTouchState);
|
|
Pimpl->TriggerBeginTouch(LeftHandTouchState.Hand, OtherActor);
|
|
}
|
|
}
|
|
|
|
void ASGPawn::OnLeftThumbFingertipTouchColliderOverlapEnds(
|
|
UPrimitiveComponent* OverlappedComponent,
|
|
AActor* OtherActor,
|
|
UPrimitiveComponent* OtherComp,
|
|
const int32 OtherBodyIndex)
|
|
{
|
|
(void) OverlappedComponent;
|
|
(void) OtherComp;
|
|
(void) OtherBodyIndex;
|
|
|
|
if (LeftHandTouchState.ActorThumbTouching == OtherActor)
|
|
{
|
|
LeftHandTouchState.ActorThumbTouching = nullptr;
|
|
Pimpl->TriggerTouchStateUpdatedEvent(LeftHandTouchState);
|
|
Pimpl->TriggerEndTouch(LeftHandTouchState.Hand, OtherActor);
|
|
}
|
|
}
|
|
|
|
void ASGPawn::OnLeftIndexFingertipTouchColliderOverlapBegins(
|
|
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))
|
|
{
|
|
LeftHandTouchState.ActorIndexTouching = OtherActor;
|
|
Pimpl->TriggerTouchStateUpdatedEvent(LeftHandTouchState);
|
|
Pimpl->TriggerBeginTouch(LeftHandTouchState.Hand, OtherActor);
|
|
}
|
|
}
|
|
|
|
void ASGPawn::OnLeftIndexFingertipTouchColliderOverlapEnds(
|
|
UPrimitiveComponent* OverlappedComponent,
|
|
AActor* OtherActor,
|
|
UPrimitiveComponent* OtherComp,
|
|
const int32 OtherBodyIndex)
|
|
{
|
|
(void) OverlappedComponent;
|
|
(void) OtherComp;
|
|
(void) OtherBodyIndex;
|
|
|
|
if (LeftHandTouchState.ActorIndexTouching == OtherActor)
|
|
{
|
|
LeftHandTouchState.ActorIndexTouching = nullptr;
|
|
Pimpl->TriggerTouchStateUpdatedEvent(LeftHandTouchState);
|
|
Pimpl->TriggerEndTouch(LeftHandTouchState.Hand, OtherActor);
|
|
}
|
|
}
|
|
|
|
void ASGPawn::OnLeftMiddleFingertipTouchColliderOverlapBegins(
|
|
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))
|
|
{
|
|
LeftHandTouchState.ActorMiddleTouching = OtherActor;
|
|
Pimpl->TriggerTouchStateUpdatedEvent(LeftHandTouchState);
|
|
Pimpl->TriggerBeginTouch(LeftHandTouchState.Hand, OtherActor);
|
|
}
|
|
}
|
|
|
|
void ASGPawn::OnLeftMiddleFingertipTouchColliderOverlapEnds(
|
|
UPrimitiveComponent* OverlappedComponent,
|
|
AActor* OtherActor,
|
|
UPrimitiveComponent* OtherComp,
|
|
const int32 OtherBodyIndex)
|
|
{
|
|
(void) OverlappedComponent;
|
|
(void) OtherComp;
|
|
(void) OtherBodyIndex;
|
|
|
|
if (LeftHandTouchState.ActorMiddleTouching == OtherActor)
|
|
{
|
|
LeftHandTouchState.ActorMiddleTouching = nullptr;
|
|
Pimpl->TriggerTouchStateUpdatedEvent(LeftHandTouchState);
|
|
Pimpl->TriggerEndTouch(LeftHandTouchState.Hand, OtherActor);
|
|
}
|
|
}
|
|
|
|
void ASGPawn::OnLeftRingFingertipTouchColliderOverlapBegins(
|
|
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))
|
|
{
|
|
LeftHandTouchState.ActorRingTouching = OtherActor;
|
|
Pimpl->TriggerTouchStateUpdatedEvent(LeftHandTouchState);
|
|
Pimpl->TriggerBeginTouch(LeftHandTouchState.Hand, OtherActor);
|
|
}
|
|
}
|
|
|
|
void ASGPawn::OnLeftRingFingertipTouchColliderOverlapEnds(
|
|
UPrimitiveComponent* OverlappedComponent,
|
|
AActor* OtherActor,
|
|
UPrimitiveComponent* OtherComp,
|
|
const int32 OtherBodyIndex)
|
|
{
|
|
(void) OverlappedComponent;
|
|
(void) OtherComp;
|
|
(void) OtherBodyIndex;
|
|
|
|
if (LeftHandTouchState.ActorRingTouching == OtherActor)
|
|
{
|
|
LeftHandTouchState.ActorRingTouching = nullptr;
|
|
Pimpl->TriggerTouchStateUpdatedEvent(LeftHandTouchState);
|
|
Pimpl->TriggerEndTouch(LeftHandTouchState.Hand, OtherActor);
|
|
}
|
|
}
|
|
|
|
void ASGPawn::OnLeftPinkyFingertipTouchColliderOverlapBegins(
|
|
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))
|
|
{
|
|
LeftHandTouchState.ActorPinkyTouching = OtherActor;
|
|
Pimpl->TriggerTouchStateUpdatedEvent(LeftHandTouchState);
|
|
Pimpl->TriggerBeginTouch(LeftHandTouchState.Hand, OtherActor);
|
|
}
|
|
}
|
|
|
|
void ASGPawn::OnLeftPinkyFingertipTouchColliderOverlapEnds(
|
|
UPrimitiveComponent* OverlappedComponent,
|
|
AActor* OtherActor,
|
|
UPrimitiveComponent* OtherComp,
|
|
const int32 OtherBodyIndex)
|
|
{
|
|
(void) OverlappedComponent;
|
|
(void) OtherComp;
|
|
(void) OtherBodyIndex;
|
|
|
|
if (LeftHandTouchState.ActorPinkyTouching == OtherActor)
|
|
{
|
|
LeftHandTouchState.ActorPinkyTouching = nullptr;
|
|
Pimpl->TriggerTouchStateUpdatedEvent(LeftHandTouchState);
|
|
Pimpl->TriggerEndTouch(LeftHandTouchState.Hand, OtherActor);
|
|
}
|
|
}
|
|
|
|
void ASGPawn::OnRightThumbFingertipGrabColliderOverlapBegins(
|
|
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))
|
|
{
|
|
RightHandGrabState.ActorThumbCanGrab = OtherActor;
|
|
Pimpl->TriggerGrabStateUpdatedEvent(RightHandGrabState);
|
|
}
|
|
}
|
|
|
|
void ASGPawn::OnRightThumbFingertipGrabColliderOverlapEnds(
|
|
UPrimitiveComponent* OverlappedComponent,
|
|
AActor* OtherActor,
|
|
UPrimitiveComponent* OtherComp,
|
|
const int32 OtherBodyIndex)
|
|
{
|
|
(void) OverlappedComponent;
|
|
(void) OtherComp;
|
|
(void) OtherBodyIndex;
|
|
|
|
if (RightHandGrabState.ActorThumbCanGrab == OtherActor)
|
|
{
|
|
RightHandGrabState.ActorThumbCanGrab = nullptr;
|
|
Pimpl->TriggerGrabStateUpdatedEvent(RightHandGrabState);
|
|
}
|
|
}
|
|
|
|
void ASGPawn::OnRightIndexFingertipGrabColliderOverlapBegins(
|
|
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))
|
|
{
|
|
RightHandGrabState.ActorIndexCanGrab = OtherActor;
|
|
Pimpl->TriggerGrabStateUpdatedEvent(RightHandGrabState);
|
|
}
|
|
}
|
|
|
|
void ASGPawn::OnRightIndexFingertipGrabColliderOverlapEnds(
|
|
UPrimitiveComponent* OverlappedComponent,
|
|
AActor* OtherActor,
|
|
UPrimitiveComponent* OtherComp,
|
|
const int32 OtherBodyIndex)
|
|
{
|
|
(void) OverlappedComponent;
|
|
(void) OtherComp;
|
|
(void) OtherBodyIndex;
|
|
|
|
if (RightHandGrabState.ActorThumbCanGrab == OtherActor)
|
|
{
|
|
RightHandGrabState.ActorIndexCanGrab = nullptr;
|
|
Pimpl->TriggerGrabStateUpdatedEvent(RightHandGrabState);
|
|
}
|
|
}
|
|
|
|
void ASGPawn::OnRightMiddleFingertipGrabColliderOverlapBegins(
|
|
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))
|
|
{
|
|
RightHandGrabState.ActorMiddleCanGrab = OtherActor;
|
|
Pimpl->TriggerGrabStateUpdatedEvent(RightHandGrabState);
|
|
}
|
|
}
|
|
|
|
void ASGPawn::OnRightMiddleFingertipGrabColliderOverlapEnds(
|
|
UPrimitiveComponent* OverlappedComponent,
|
|
AActor* OtherActor,
|
|
UPrimitiveComponent* OtherComp,
|
|
const int32 OtherBodyIndex)
|
|
{
|
|
(void) OverlappedComponent;
|
|
(void) OtherComp;
|
|
(void) OtherBodyIndex;
|
|
|
|
if (RightHandGrabState.ActorMiddleCanGrab == OtherActor)
|
|
{
|
|
RightHandGrabState.ActorMiddleCanGrab = nullptr;
|
|
Pimpl->TriggerGrabStateUpdatedEvent(RightHandGrabState);
|
|
}
|
|
}
|
|
|
|
void ASGPawn::OnRightThumbFingertipTouchColliderOverlapBegins(
|
|
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))
|
|
{
|
|
RightHandTouchState.ActorThumbTouching = OtherActor;
|
|
Pimpl->TriggerTouchStateUpdatedEvent(RightHandTouchState);
|
|
Pimpl->TriggerBeginTouch(RightHandTouchState.Hand, OtherActor);
|
|
}
|
|
}
|
|
|
|
void ASGPawn::OnRightThumbFingertipTouchColliderOverlapEnds(
|
|
UPrimitiveComponent* OverlappedComponent,
|
|
AActor* OtherActor,
|
|
UPrimitiveComponent* OtherComp,
|
|
const int32 OtherBodyIndex)
|
|
{
|
|
(void) OverlappedComponent;
|
|
(void) OtherComp;
|
|
(void) OtherBodyIndex;
|
|
|
|
if (RightHandTouchState.ActorThumbTouching == OtherActor)
|
|
{
|
|
RightHandTouchState.ActorThumbTouching = nullptr;
|
|
Pimpl->TriggerTouchStateUpdatedEvent(RightHandTouchState);
|
|
Pimpl->TriggerEndTouch(RightHandTouchState.Hand, OtherActor);
|
|
}
|
|
}
|
|
|
|
void ASGPawn::OnRightIndexFingertipTouchColliderOverlapBegins(
|
|
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))
|
|
{
|
|
RightHandTouchState.ActorIndexTouching = OtherActor;
|
|
Pimpl->TriggerTouchStateUpdatedEvent(RightHandTouchState);
|
|
Pimpl->TriggerBeginTouch(RightHandTouchState.Hand, OtherActor);
|
|
}
|
|
}
|
|
|
|
void ASGPawn::OnRightIndexFingertipTouchColliderOverlapEnds(
|
|
UPrimitiveComponent* OverlappedComponent,
|
|
AActor* OtherActor,
|
|
UPrimitiveComponent* OtherComp,
|
|
const int32 OtherBodyIndex)
|
|
{
|
|
(void) OverlappedComponent;
|
|
(void) OtherComp;
|
|
(void) OtherBodyIndex;
|
|
|
|
if (RightHandTouchState.ActorIndexTouching == OtherActor)
|
|
{
|
|
RightHandTouchState.ActorIndexTouching = nullptr;
|
|
Pimpl->TriggerTouchStateUpdatedEvent(RightHandTouchState);
|
|
Pimpl->TriggerEndTouch(RightHandTouchState.Hand, OtherActor);
|
|
}
|
|
}
|
|
|
|
void ASGPawn::OnRightMiddleFingertipTouchColliderOverlapBegins(
|
|
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))
|
|
{
|
|
RightHandTouchState.ActorMiddleTouching = OtherActor;
|
|
Pimpl->TriggerTouchStateUpdatedEvent(RightHandTouchState);
|
|
Pimpl->TriggerBeginTouch(RightHandTouchState.Hand, OtherActor);
|
|
}
|
|
}
|
|
|
|
void ASGPawn::OnRightMiddleFingertipTouchColliderOverlapEnds(
|
|
UPrimitiveComponent* OverlappedComponent,
|
|
AActor* OtherActor,
|
|
UPrimitiveComponent* OtherComp,
|
|
const int32 OtherBodyIndex)
|
|
{
|
|
(void) OverlappedComponent;
|
|
(void) OtherComp;
|
|
(void) OtherBodyIndex;
|
|
|
|
if (RightHandTouchState.ActorMiddleTouching == OtherActor)
|
|
{
|
|
RightHandTouchState.ActorMiddleTouching = nullptr;
|
|
Pimpl->TriggerTouchStateUpdatedEvent(RightHandTouchState);
|
|
Pimpl->TriggerEndTouch(RightHandTouchState.Hand, OtherActor);
|
|
}
|
|
}
|
|
|
|
void ASGPawn::OnRightRingFingertipTouchColliderOverlapBegins(
|
|
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))
|
|
{
|
|
RightHandTouchState.ActorRingTouching = OtherActor;
|
|
Pimpl->TriggerTouchStateUpdatedEvent(RightHandTouchState);
|
|
Pimpl->TriggerBeginTouch(RightHandTouchState.Hand, OtherActor);
|
|
}
|
|
}
|
|
|
|
void ASGPawn::OnRightRingFingertipTouchColliderOverlapEnds(
|
|
UPrimitiveComponent* OverlappedComponent,
|
|
AActor* OtherActor,
|
|
UPrimitiveComponent* OtherComp,
|
|
const int32 OtherBodyIndex)
|
|
{
|
|
(void) OverlappedComponent;
|
|
(void) OtherComp;
|
|
(void) OtherBodyIndex;
|
|
|
|
if (RightHandTouchState.ActorRingTouching == OtherActor)
|
|
{
|
|
RightHandTouchState.ActorRingTouching = nullptr;
|
|
Pimpl->TriggerTouchStateUpdatedEvent(RightHandTouchState);
|
|
Pimpl->TriggerEndTouch(RightHandTouchState.Hand, OtherActor);
|
|
}
|
|
}
|
|
|
|
void ASGPawn::OnRightPinkyFingertipTouchColliderOverlapBegins(
|
|
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))
|
|
{
|
|
RightHandTouchState.ActorPinkyTouching = OtherActor;
|
|
Pimpl->TriggerTouchStateUpdatedEvent(RightHandTouchState);
|
|
Pimpl->TriggerBeginTouch(RightHandTouchState.Hand, OtherActor);
|
|
}
|
|
}
|
|
|
|
void ASGPawn::OnRightPinkyFingertipTouchColliderOverlapEnds(
|
|
UPrimitiveComponent* OverlappedComponent,
|
|
AActor* OtherActor,
|
|
UPrimitiveComponent* OtherComp,
|
|
const int32 OtherBodyIndex)
|
|
{
|
|
(void) OverlappedComponent;
|
|
(void) OtherComp;
|
|
(void) OtherBodyIndex;
|
|
|
|
if (RightHandTouchState.ActorPinkyTouching == OtherActor)
|
|
{
|
|
RightHandTouchState.ActorPinkyTouching = nullptr;
|
|
Pimpl->TriggerTouchStateUpdatedEvent(RightHandTouchState);
|
|
Pimpl->TriggerEndTouch(RightHandTouchState.Hand, OtherActor);
|
|
}
|
|
}
|
|
|
|
bool ASGPawn::IsLeftHandGrabbing(AActor*& OutActor) const
|
|
{
|
|
if (IsValid(LeftHandGrabState.GrabbedActor))
|
|
{
|
|
OutActor = LeftHandGrabState.GrabbedActor;
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
bool ASGPawn::IsRightHandGrabbing(AActor*& OutActor) const
|
|
{
|
|
if (IsValid(RightHandGrabState.GrabbedActor))
|
|
{
|
|
OutActor = RightHandGrabState.GrabbedActor;
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
bool ASGPawn::IsGrabbing(const USGVirtualHandComponent* Hand, AActor*& OutActor) const
|
|
{
|
|
return Hand == HandLeft ? IsLeftHandGrabbing(OutActor) : IsRightHandGrabbing(OutActor);
|
|
}
|
|
|
|
void ASGPawn::Grab(USGVirtualHandComponent* Hand, AActor* Actor)
|
|
{
|
|
if (!ensureAlwaysMsgf(IsValid(Actor), TEXT("%s"), TEXT("ERROR: invalid actor!")))
|
|
{
|
|
return;
|
|
}
|
|
|
|
const USGGrabComponent* GrabComponent{USGGrabComponent::GetGrabComponent(Actor)};
|
|
if (!GrabComponent)
|
|
{
|
|
return;
|
|
}
|
|
|
|
FAttachmentTransformRules AttachmentRules{
|
|
FAttachmentTransformRules(GrabComponent->GetAttachmentLocationRule(),
|
|
GrabComponent->GetAttachmentRotationRule(),
|
|
GrabComponent->GetAttachmentScaleRule(),
|
|
GrabComponent->GetAttachmentWeldSimulatedBodies())
|
|
};
|
|
|
|
const FName SocketName{GrabComponent->GetAttachmentSocketName()};
|
|
ensureAlwaysMsgf(SocketName != NAME_None, TEXT("invalid attachment socket name!"));
|
|
|
|
if (GrabComponent->GetAffectPhysicsState())
|
|
{
|
|
Pimpl->DisableActorPhysics(Actor);
|
|
}
|
|
|
|
if (Hand->IsRight())
|
|
{
|
|
Pimpl->UnregisterRightHandOverlappedActor(Actor);
|
|
}
|
|
else
|
|
{
|
|
Pimpl->UnregisterLeftHandOverlappedActor(Actor);
|
|
}
|
|
|
|
#if ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 2
|
|
const bool bAttached = Actor->AttachToComponent(Hand, MoveTemp(AttachmentRules), SocketName);
|
|
if (bAttached)
|
|
{
|
|
if (Hand->IsRight())
|
|
{
|
|
Pimpl->SetRightHandGrabbedActor(Actor);
|
|
}
|
|
else
|
|
{
|
|
Pimpl->SetLeftHandGrabbedActor(Actor);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (Hand->IsRight())
|
|
{
|
|
SGLOG_ERROR("Failed to grab the actor with the right hand!", Actor, SocketName);
|
|
}
|
|
else
|
|
{
|
|
SGLOG_ERROR("Failed to grab the actor with the left hand!", Actor, SocketName);
|
|
}
|
|
}
|
|
#else
|
|
Actor->AttachToComponent(Hand, MoveTemp(AttachmentRules), SocketName);
|
|
if (Hand->IsRight())
|
|
{
|
|
Pimpl->SetRightHandGrabbedActor(Actor);
|
|
}
|
|
else
|
|
{
|
|
Pimpl->SetLeftHandGrabbedActor(Actor);
|
|
}
|
|
#endif /* ENGINE_MAJOR_VERSION >= 5 && ENGINE_MINOR_VERSION >= 2 */
|
|
|
|
Pimpl->TriggerActorGrabbedEvent(Hand, Actor);
|
|
}
|
|
|
|
void ASGPawn::ReleaseLeft()
|
|
{
|
|
Pimpl->Release(LeftHandGrabState);
|
|
}
|
|
|
|
void ASGPawn::ReleaseRight()
|
|
{
|
|
Pimpl->Release(RightHandGrabState);
|
|
}
|
|
|
|
ASGPawn::FImpl::FImpl(ASGPawn* InOwner)
|
|
: Owner(InOwner)
|
|
{
|
|
}
|
|
|
|
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);
|
|
}
|
|
|
|
void ASGPawn::FImpl::BindFingerGrabOverlapEvents()
|
|
{
|
|
Owner->LeftThumbFingertipGrabCollider->OnComponentBeginOverlap.AddDynamic(
|
|
Owner, &ASGPawn::OnLeftThumbFingertipGrabColliderOverlapBegins);
|
|
Owner->LeftThumbFingertipGrabCollider->OnComponentEndOverlap.AddDynamic(
|
|
Owner, &ASGPawn::OnLeftThumbFingertipGrabColliderOverlapEnds);
|
|
|
|
Owner->LeftIndexFingertipGrabCollider->OnComponentBeginOverlap.AddDynamic(
|
|
Owner, &ASGPawn::OnLeftIndexFingertipGrabColliderOverlapBegins);
|
|
Owner->LeftIndexFingertipGrabCollider->OnComponentEndOverlap.AddDynamic(
|
|
Owner, &ASGPawn::OnLeftIndexFingertipGrabColliderOverlapEnds);
|
|
|
|
Owner->LeftMiddleFingertipGrabCollider->OnComponentBeginOverlap.AddDynamic(
|
|
Owner, &ASGPawn::OnLeftMiddleFingertipGrabColliderOverlapBegins);
|
|
Owner->LeftMiddleFingertipGrabCollider->OnComponentEndOverlap.AddDynamic(
|
|
Owner, &ASGPawn::OnLeftMiddleFingertipGrabColliderOverlapEnds);
|
|
|
|
Owner->RightThumbFingertipGrabCollider->OnComponentBeginOverlap.AddDynamic(
|
|
Owner, &ASGPawn::OnRightThumbFingertipGrabColliderOverlapBegins);
|
|
Owner->RightThumbFingertipGrabCollider->OnComponentEndOverlap.AddDynamic(
|
|
Owner, &ASGPawn::OnRightThumbFingertipGrabColliderOverlapEnds);
|
|
|
|
Owner->RightIndexFingertipGrabCollider->OnComponentBeginOverlap.AddDynamic(
|
|
Owner, &ASGPawn::OnRightIndexFingertipGrabColliderOverlapBegins);
|
|
Owner->RightIndexFingertipGrabCollider->OnComponentEndOverlap.AddDynamic(
|
|
Owner, &ASGPawn::OnRightIndexFingertipGrabColliderOverlapEnds);
|
|
|
|
Owner->RightMiddleFingertipGrabCollider->OnComponentBeginOverlap.AddDynamic(
|
|
Owner, &ASGPawn::OnRightMiddleFingertipGrabColliderOverlapBegins);
|
|
Owner->RightMiddleFingertipGrabCollider->OnComponentEndOverlap.AddDynamic(
|
|
Owner, &ASGPawn::OnRightMiddleFingertipGrabColliderOverlapEnds);
|
|
}
|
|
|
|
void ASGPawn::FImpl::UnbindFingerGrabOverlapEvents()
|
|
{
|
|
Owner->LeftThumbFingertipGrabCollider->OnComponentBeginOverlap.RemoveDynamic(
|
|
Owner, &ASGPawn::OnLeftThumbFingertipGrabColliderOverlapBegins);
|
|
Owner->LeftThumbFingertipGrabCollider->OnComponentEndOverlap.RemoveDynamic(
|
|
Owner, &ASGPawn::OnLeftThumbFingertipGrabColliderOverlapEnds);
|
|
|
|
Owner->LeftIndexFingertipGrabCollider->OnComponentBeginOverlap.RemoveDynamic(
|
|
Owner, &ASGPawn::OnLeftIndexFingertipGrabColliderOverlapBegins);
|
|
Owner->LeftIndexFingertipGrabCollider->OnComponentEndOverlap.RemoveDynamic(
|
|
Owner, &ASGPawn::OnLeftIndexFingertipGrabColliderOverlapEnds);
|
|
|
|
Owner->LeftMiddleFingertipGrabCollider->OnComponentBeginOverlap.RemoveDynamic(
|
|
Owner, &ASGPawn::OnLeftMiddleFingertipGrabColliderOverlapBegins);
|
|
Owner->LeftMiddleFingertipGrabCollider->OnComponentEndOverlap.RemoveDynamic(
|
|
Owner, &ASGPawn::OnLeftMiddleFingertipGrabColliderOverlapEnds);
|
|
|
|
Owner->RightThumbFingertipGrabCollider->OnComponentBeginOverlap.RemoveDynamic(
|
|
Owner, &ASGPawn::OnRightThumbFingertipGrabColliderOverlapBegins);
|
|
Owner->RightThumbFingertipGrabCollider->OnComponentEndOverlap.RemoveDynamic(
|
|
Owner, &ASGPawn::OnRightThumbFingertipGrabColliderOverlapEnds);
|
|
|
|
Owner->RightIndexFingertipGrabCollider->OnComponentBeginOverlap.RemoveDynamic(
|
|
Owner, &ASGPawn::OnRightIndexFingertipGrabColliderOverlapBegins);
|
|
Owner->RightIndexFingertipGrabCollider->OnComponentEndOverlap.RemoveDynamic(
|
|
Owner, &ASGPawn::OnRightIndexFingertipGrabColliderOverlapEnds);
|
|
|
|
Owner->RightMiddleFingertipGrabCollider->OnComponentBeginOverlap.RemoveDynamic(
|
|
Owner, &ASGPawn::OnRightMiddleFingertipGrabColliderOverlapBegins);
|
|
Owner->RightMiddleFingertipGrabCollider->OnComponentEndOverlap.RemoveDynamic(
|
|
Owner, &ASGPawn::OnRightMiddleFingertipGrabColliderOverlapEnds);
|
|
}
|
|
|
|
void ASGPawn::FImpl::BindFingerTouchOverlapEvents()
|
|
{
|
|
Owner->LeftThumbFingertipTouchCollider->OnComponentBeginOverlap.AddDynamic(
|
|
Owner, &ASGPawn::OnLeftThumbFingertipTouchColliderOverlapBegins);
|
|
Owner->LeftThumbFingertipTouchCollider->OnComponentEndOverlap.AddDynamic(
|
|
Owner, &ASGPawn::OnLeftThumbFingertipTouchColliderOverlapEnds);
|
|
|
|
Owner->LeftIndexFingertipTouchCollider->OnComponentBeginOverlap.AddDynamic(
|
|
Owner, &ASGPawn::OnLeftIndexFingertipTouchColliderOverlapBegins);
|
|
Owner->LeftIndexFingertipTouchCollider->OnComponentEndOverlap.AddDynamic(
|
|
Owner, &ASGPawn::OnLeftIndexFingertipTouchColliderOverlapEnds);
|
|
|
|
Owner->LeftMiddleFingertipTouchCollider->OnComponentBeginOverlap.AddDynamic(
|
|
Owner, &ASGPawn::OnLeftMiddleFingertipTouchColliderOverlapBegins);
|
|
Owner->LeftMiddleFingertipTouchCollider->OnComponentEndOverlap.AddDynamic(
|
|
Owner, &ASGPawn::OnLeftMiddleFingertipTouchColliderOverlapEnds);
|
|
|
|
Owner->LeftRingFingertipTouchCollider->OnComponentBeginOverlap.AddDynamic(
|
|
Owner, &ASGPawn::OnLeftRingFingertipTouchColliderOverlapBegins);
|
|
Owner->LeftRingFingertipTouchCollider->OnComponentEndOverlap.AddDynamic(
|
|
Owner, &ASGPawn::OnLeftRingFingertipTouchColliderOverlapEnds);
|
|
|
|
Owner->LeftPinkyFingertipTouchCollider->OnComponentBeginOverlap.AddDynamic(
|
|
Owner, &ASGPawn::OnLeftPinkyFingertipTouchColliderOverlapBegins);
|
|
Owner->LeftPinkyFingertipTouchCollider->OnComponentEndOverlap.AddDynamic(
|
|
Owner, &ASGPawn::OnLeftPinkyFingertipTouchColliderOverlapEnds);
|
|
|
|
Owner->RightThumbFingertipTouchCollider->OnComponentBeginOverlap.AddDynamic(
|
|
Owner, &ASGPawn::OnRightThumbFingertipTouchColliderOverlapBegins);
|
|
Owner->RightThumbFingertipTouchCollider->OnComponentEndOverlap.AddDynamic(
|
|
Owner, &ASGPawn::OnRightThumbFingertipTouchColliderOverlapEnds);
|
|
|
|
Owner->RightIndexFingertipTouchCollider->OnComponentBeginOverlap.AddDynamic(
|
|
Owner, &ASGPawn::OnRightIndexFingertipTouchColliderOverlapBegins);
|
|
Owner->RightIndexFingertipTouchCollider->OnComponentEndOverlap.AddDynamic(
|
|
Owner, &ASGPawn::OnRightIndexFingertipTouchColliderOverlapEnds);
|
|
|
|
Owner->RightMiddleFingertipTouchCollider->OnComponentBeginOverlap.AddDynamic(
|
|
Owner, &ASGPawn::OnRightMiddleFingertipTouchColliderOverlapBegins);
|
|
Owner->RightMiddleFingertipTouchCollider->OnComponentEndOverlap.AddDynamic(
|
|
Owner, &ASGPawn::OnRightMiddleFingertipTouchColliderOverlapEnds);
|
|
|
|
Owner->RightRingFingertipTouchCollider->OnComponentBeginOverlap.AddDynamic(
|
|
Owner, &ASGPawn::OnRightRingFingertipTouchColliderOverlapBegins);
|
|
Owner->RightRingFingertipTouchCollider->OnComponentEndOverlap.AddDynamic(
|
|
Owner, &ASGPawn::OnRightRingFingertipTouchColliderOverlapEnds);
|
|
|
|
Owner->RightPinkyFingertipTouchCollider->OnComponentBeginOverlap.AddDynamic(
|
|
Owner, &ASGPawn::OnRightPinkyFingertipTouchColliderOverlapBegins);
|
|
Owner->RightPinkyFingertipTouchCollider->OnComponentEndOverlap.AddDynamic(
|
|
Owner, &ASGPawn::OnRightPinkyFingertipTouchColliderOverlapEnds);
|
|
}
|
|
|
|
void ASGPawn::FImpl::UnbindFingerTouchOverlapEvents()
|
|
{
|
|
Owner->LeftThumbFingertipTouchCollider->OnComponentBeginOverlap.RemoveDynamic(
|
|
Owner, &ASGPawn::OnLeftThumbFingertipTouchColliderOverlapBegins);
|
|
Owner->LeftThumbFingertipTouchCollider->OnComponentEndOverlap.RemoveDynamic(
|
|
Owner, &ASGPawn::OnLeftThumbFingertipTouchColliderOverlapEnds);
|
|
|
|
Owner->LeftIndexFingertipTouchCollider->OnComponentBeginOverlap.RemoveDynamic(
|
|
Owner, &ASGPawn::OnLeftIndexFingertipTouchColliderOverlapBegins);
|
|
Owner->LeftIndexFingertipTouchCollider->OnComponentEndOverlap.RemoveDynamic(
|
|
Owner, &ASGPawn::OnLeftIndexFingertipTouchColliderOverlapEnds);
|
|
|
|
Owner->LeftMiddleFingertipTouchCollider->OnComponentBeginOverlap.RemoveDynamic(
|
|
Owner, &ASGPawn::OnLeftMiddleFingertipTouchColliderOverlapBegins);
|
|
Owner->LeftMiddleFingertipTouchCollider->OnComponentEndOverlap.RemoveDynamic(
|
|
Owner, &ASGPawn::OnLeftMiddleFingertipTouchColliderOverlapEnds);
|
|
|
|
Owner->LeftRingFingertipTouchCollider->OnComponentBeginOverlap.RemoveDynamic(
|
|
Owner, &ASGPawn::OnLeftRingFingertipTouchColliderOverlapBegins);
|
|
Owner->LeftRingFingertipTouchCollider->OnComponentEndOverlap.RemoveDynamic(
|
|
Owner, &ASGPawn::OnLeftRingFingertipTouchColliderOverlapEnds);
|
|
|
|
Owner->LeftPinkyFingertipTouchCollider->OnComponentBeginOverlap.RemoveDynamic(
|
|
Owner, &ASGPawn::OnLeftPinkyFingertipTouchColliderOverlapBegins);
|
|
Owner->LeftPinkyFingertipTouchCollider->OnComponentEndOverlap.RemoveDynamic(
|
|
Owner, &ASGPawn::OnLeftPinkyFingertipTouchColliderOverlapEnds);
|
|
|
|
Owner->RightThumbFingertipGrabCollider->OnComponentBeginOverlap.RemoveDynamic(
|
|
Owner, &ASGPawn::OnRightThumbFingertipGrabColliderOverlapBegins);
|
|
Owner->RightThumbFingertipGrabCollider->OnComponentEndOverlap.RemoveDynamic(
|
|
Owner, &ASGPawn::OnRightThumbFingertipGrabColliderOverlapEnds);
|
|
|
|
Owner->RightIndexFingertipGrabCollider->OnComponentBeginOverlap.RemoveDynamic(
|
|
Owner, &ASGPawn::OnRightIndexFingertipGrabColliderOverlapBegins);
|
|
Owner->RightIndexFingertipGrabCollider->OnComponentEndOverlap.RemoveDynamic(
|
|
Owner, &ASGPawn::OnRightIndexFingertipGrabColliderOverlapEnds);
|
|
|
|
Owner->RightMiddleFingertipGrabCollider->OnComponentBeginOverlap.RemoveDynamic(
|
|
Owner, &ASGPawn::OnRightMiddleFingertipGrabColliderOverlapBegins);
|
|
Owner->RightMiddleFingertipGrabCollider->OnComponentEndOverlap.RemoveDynamic(
|
|
Owner, &ASGPawn::OnRightMiddleFingertipGrabColliderOverlapEnds);
|
|
|
|
Owner->RightThumbFingertipTouchCollider->OnComponentBeginOverlap.RemoveDynamic(
|
|
Owner, &ASGPawn::OnRightThumbFingertipTouchColliderOverlapBegins);
|
|
Owner->RightThumbFingertipTouchCollider->OnComponentEndOverlap.RemoveDynamic(
|
|
Owner, &ASGPawn::OnRightThumbFingertipTouchColliderOverlapEnds);
|
|
|
|
Owner->RightIndexFingertipTouchCollider->OnComponentBeginOverlap.RemoveDynamic(
|
|
Owner, &ASGPawn::OnRightIndexFingertipTouchColliderOverlapBegins);
|
|
Owner->RightIndexFingertipTouchCollider->OnComponentEndOverlap.RemoveDynamic(
|
|
Owner, &ASGPawn::OnRightIndexFingertipTouchColliderOverlapEnds);
|
|
|
|
Owner->RightMiddleFingertipTouchCollider->OnComponentBeginOverlap.RemoveDynamic(
|
|
Owner, &ASGPawn::OnRightMiddleFingertipTouchColliderOverlapBegins);
|
|
Owner->RightMiddleFingertipTouchCollider->OnComponentEndOverlap.RemoveDynamic(
|
|
Owner, &ASGPawn::OnRightMiddleFingertipTouchColliderOverlapEnds);
|
|
|
|
Owner->RightRingFingertipTouchCollider->OnComponentBeginOverlap.RemoveDynamic(
|
|
Owner, &ASGPawn::OnRightRingFingertipTouchColliderOverlapBegins);
|
|
Owner->RightRingFingertipTouchCollider->OnComponentEndOverlap.RemoveDynamic(
|
|
Owner, &ASGPawn::OnRightRingFingertipTouchColliderOverlapEnds);
|
|
|
|
Owner->RightPinkyFingertipTouchCollider->OnComponentBeginOverlap.RemoveDynamic(
|
|
Owner, &ASGPawn::OnRightPinkyFingertipTouchColliderOverlapBegins);
|
|
Owner->RightPinkyFingertipTouchCollider->OnComponentEndOverlap.RemoveDynamic(
|
|
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<UPrimitiveComponent>(Actor->GetRootComponent())};
|
|
if (!ensureAlwaysMsgf(IsValid(ActorRootComponent), TEXT("RootComponent is not a valid UPrimativeComponent!")))
|
|
{
|
|
return;
|
|
}
|
|
|
|
ActorRootComponent->SetEnableGravity(false);
|
|
ActorRootComponent->SetSimulatePhysics(false);
|
|
ActorRootComponent->PutRigidBodyToSleep();
|
|
}
|
|
|
|
void ASGPawn::FImpl::EnableActorPhysics(const AActor* Actor) const
|
|
{
|
|
if (!IsValid(Actor))
|
|
{
|
|
return;
|
|
}
|
|
|
|
UPrimitiveComponent* ActorRootComponent{Cast<UPrimitiveComponent>(Actor->GetRootComponent())};
|
|
if (!ensureAlwaysMsgf(IsValid(ActorRootComponent), TEXT("RootComponent is not a valid UPrimativeComponent!")))
|
|
{
|
|
return;
|
|
}
|
|
|
|
ActorRootComponent->SetEnableGravity(true);
|
|
ActorRootComponent->SetSimulatePhysics(true);
|
|
ActorRootComponent->WakeRigidBody();
|
|
}
|
|
|
|
void ASGPawn::FImpl::ApplyHandVelocityToGrabbedActor(const FSGGrabState& GrabState) const
|
|
{
|
|
if (!IsValid(GrabState.Hand))
|
|
{
|
|
return;
|
|
}
|
|
|
|
if (!IsValid(GrabState.GrabbedActor))
|
|
{
|
|
return;
|
|
}
|
|
|
|
UPrimitiveComponent* ActorRootComponent{Cast<UPrimitiveComponent>(GrabState.GrabbedActor->GetRootComponent())};
|
|
if (!ensureAlwaysMsgf(IsValid(ActorRootComponent), TEXT("RootComponent is not a valid UPrimativeComponent!")))
|
|
{
|
|
return;
|
|
}
|
|
|
|
FVector HandVelocity{UKismetMathLibrary::GetVectorArrayAverage(GrabState.HandVelocityHistory)};
|
|
|
|
ActorRootComponent->SetPhysicsLinearVelocity(HandVelocity);
|
|
ActorRootComponent->AddImpulse(MoveTemp(HandVelocity), NAME_None, true);
|
|
}
|
|
|
|
void ASGPawn::FImpl::SetGrabbedActor(FSGGrabState& GrabState, AActor* Actor) const
|
|
{
|
|
GrabState.GrabbedActor = Actor;
|
|
}
|
|
|
|
void ASGPawn::FImpl::SetLeftHandGrabbedActor(AActor* Actor) const
|
|
{
|
|
SetGrabbedActor(Owner->LeftHandGrabState, Actor);
|
|
}
|
|
|
|
void ASGPawn::FImpl::SetRightHandGrabbedActor(AActor* Actor) const
|
|
{
|
|
SetGrabbedActor(Owner->RightHandGrabState, Actor);
|
|
}
|
|
|
|
void ASGPawn::FImpl::RecordHandVelocity(FSGGrabState& GrabState, const float DeltaSeconds) const
|
|
{
|
|
if (!IsValid(GrabState.Hand))
|
|
{
|
|
return;
|
|
}
|
|
|
|
FVector HandVelocity{
|
|
(GrabState.Hand->GetComponentLocation() - GrabState.PreviousHandLocation) / DeltaSeconds
|
|
};
|
|
|
|
if (GrabState.HandVelocityHistory.Num() >= Owner->MaxNumberOfHandVelocitySamples)
|
|
{
|
|
if (GrabState.HandVelocityHistory.IsValidIndex(0))
|
|
{
|
|
GrabState.HandVelocityHistory.RemoveAt(0, 1, false);
|
|
GrabState.HandVelocityHistory.Emplace(MoveTemp(HandVelocity));
|
|
}
|
|
}
|
|
else
|
|
{
|
|
GrabState.HandVelocityHistory.Emplace(MoveTemp(HandVelocity));
|
|
}
|
|
|
|
GrabState.PreviousHandLocation = GrabState.Hand->GetComponentLocation();
|
|
}
|
|
|
|
void ASGPawn::FImpl::Release(FSGGrabState& GrabState) const
|
|
{
|
|
if (!IsValid(GrabState.GrabbedActor))
|
|
{
|
|
return;
|
|
}
|
|
|
|
const USGGrabComponent* GrabComponent{USGGrabComponent::GetGrabComponent(GrabState.GrabbedActor)};
|
|
if (!IsValid(GrabComponent))
|
|
{
|
|
return;
|
|
}
|
|
|
|
GrabState.GrabbedActor->DetachFromActor(
|
|
FDetachmentTransformRules(GrabComponent->GetDetachmentLocationRule(),
|
|
GrabComponent->GetDetachmentRotationRule(),
|
|
GrabComponent->GetDetachmentScaleRule(),
|
|
GrabComponent->GetDetachmentInCallModify())
|
|
);
|
|
|
|
if (GrabComponent->GetAffectPhysicsState())
|
|
{
|
|
EnableActorPhysics(GrabState.GrabbedActor);
|
|
}
|
|
|
|
ApplyHandVelocityToGrabbedActor(GrabState);
|
|
|
|
SetGrabbedActor(GrabState, nullptr);
|
|
|
|
TriggerActorReleasedEvent(GrabState.Hand, GrabState.GrabbedActor);
|
|
}
|
|
|
|
void ASGPawn::FImpl::TriggerGrabStateUpdatedEvent(const FSGGrabState& GrabState) const
|
|
{
|
|
Owner->GrabStateUpdatedEvent.Broadcast(GrabState);
|
|
Owner->OnGrabStateUpdated(GrabState);
|
|
}
|
|
|
|
void ASGPawn::FImpl::TriggerTouchStateUpdatedEvent(const FSGTouchState& TouchState) const
|
|
{
|
|
Owner->TouchStateUpdatedEvent.Broadcast(TouchState);
|
|
Owner->OnTouchStateUpdated(TouchState);
|
|
}
|
|
|
|
void ASGPawn::FImpl::TriggerActorGrabbedEvent(const USGVirtualHandComponent* Hand, const AActor* Actor) const
|
|
{
|
|
Owner->ActorGrabbedEvent.Broadcast(Hand, Actor);
|
|
Owner->OnActorGrabbed(Hand, Actor);
|
|
}
|
|
|
|
void ASGPawn::FImpl::TriggerActorReleasedEvent(const USGVirtualHandComponent* Hand, const AActor* Actor) const
|
|
{
|
|
Owner->ActorReleasedEvent.Broadcast(Hand, Actor);
|
|
Owner->OnActorReleased(Hand, Actor);
|
|
}
|
|
|
|
void ASGPawn::FImpl::TriggerBeginTouch(const USGVirtualHandComponent* Hand, const AActor* Actor) const
|
|
{
|
|
Owner->ActorBeginTouchEvent.Broadcast(Hand, Actor);
|
|
Owner->OnActorBeginTouch(Hand, Actor);
|
|
}
|
|
|
|
void ASGPawn::FImpl::TriggerEndTouch(const USGVirtualHandComponent* Hand, const AActor* Actor) const
|
|
{
|
|
Owner->ActorEndTouchEvent.Broadcast(Hand, Actor);
|
|
Owner->OnActorEndTouch(Hand, Actor);
|
|
}
|
|
|
|
ASGPawn::FImpl::~FImpl() = default;
|
|
|
|
void ASGPawn::FImplDeleter::operator()(const FImpl* P) const
|
|
{
|
|
delete P;
|
|
} |