diff --git a/Content/Components/Movement/Teleportation/Arrow.uasset b/Content/Components/Movement/Teleportation/Arrow.uasset index 7b64317bd560683e5a80444e0f62325d778623ee..785e36d4d9f7c1d84fc3b1a8d3c981aa3e6978cf 100644 Binary files a/Content/Components/Movement/Teleportation/Arrow.uasset and b/Content/Components/Movement/Teleportation/Arrow.uasset differ diff --git a/Content/Components/Movement/Teleportation/mat5.uasset b/Content/Components/Movement/Teleportation/mat5.uasset index d49a23804eeb6f40a5e49e209b2b221001be8ca5..cb48701751bc525b3d4505bc8823278cb0c6a576 100644 Binary files a/Content/Components/Movement/Teleportation/mat5.uasset and b/Content/Components/Movement/Teleportation/mat5.uasset differ diff --git a/Content/Components/Movement/Turn/IA_Turn.uasset b/Content/Components/Movement/Turn/IA_Turn.uasset index eb14d702537bd15f6d2e6ae3badcd935bc4126c0..2aac54666c3a2fb25e56ea58e46bf0ac568714eb 100644 Binary files a/Content/Components/Movement/Turn/IA_Turn.uasset and b/Content/Components/Movement/Turn/IA_Turn.uasset differ diff --git a/Content/Input/Default_IMC/IMC_MovementLeftHand.uasset b/Content/Input/Default_IMC/IMC_MovementLeftHand.uasset index 0aed5008caf02d89df79d46b4267a447a5e0d9cb..eb84fc53621cf78c25ba27b837daaa8c3a5e87e1 100644 Binary files a/Content/Input/Default_IMC/IMC_MovementLeftHand.uasset and b/Content/Input/Default_IMC/IMC_MovementLeftHand.uasset differ diff --git a/Content/Input/Default_IMC/IMC_MovementRightHand.uasset b/Content/Input/Default_IMC/IMC_MovementRightHand.uasset index 153723ca229bab41ed167983d4751d2d7312a5d6..bd56a8497914d8321ac7eabc6eb0a82d33a09fee 100644 Binary files a/Content/Input/Default_IMC/IMC_MovementRightHand.uasset and b/Content/Input/Default_IMC/IMC_MovementRightHand.uasset differ diff --git a/Content/IntenSelect/DebugConeMesh.uasset b/Content/IntenSelect/DebugConeMesh.uasset index d0980e3b7ff615b970f3cb6e664e21d95a5c8370..b43d5fb7f505dc38c334a3f7fb1a4f5e94e1765e 100644 Binary files a/Content/IntenSelect/DebugConeMesh.uasset and b/Content/IntenSelect/DebugConeMesh.uasset differ diff --git a/Content/IntenSelect/RayMesh.uasset b/Content/IntenSelect/RayMesh.uasset index fd84f10b97df7c4733e742fffc20818b1b2d48ae..6484f7c7781ef319382bfd44b7b478b7ca578d54 100644 Binary files a/Content/IntenSelect/RayMesh.uasset and b/Content/IntenSelect/RayMesh.uasset differ diff --git a/Content/IntenSelect/sectionedCubeMesh.uasset b/Content/IntenSelect/sectionedCubeMesh.uasset index 536e047dcc5dad08d21ef951d97c71c4887e2b7d..db22a36b597245f0207a0432ce7aa7af4fb5b3a4 100644 Binary files a/Content/IntenSelect/sectionedCubeMesh.uasset and b/Content/IntenSelect/sectionedCubeMesh.uasset differ diff --git a/Content/PointingRay/Ray_Material.uasset b/Content/PointingRay/Ray_Material.uasset index 4ae373bdf3e090fe996f4c48f4ccfc8ec9555b65..693a0fe93c2f20fa31bb3f56b6d72c8bc29162a2 100644 Binary files a/Content/PointingRay/Ray_Material.uasset and b/Content/PointingRay/Ray_Material.uasset differ diff --git a/Content/PointingRay/Ray_Mesh.uasset b/Content/PointingRay/Ray_Mesh.uasset index e502ceb154ffeb022d651c033f6e0e6ed9b5fbe2..f2d74c0ce3191de11f60da033f62f62a9bb10f9f 100644 Binary files a/Content/PointingRay/Ray_Mesh.uasset and b/Content/PointingRay/Ray_Mesh.uasset differ diff --git a/Source/RWTHVRToolkit/Private/Pawn/Navigation/CollisionHandlingMovement.cpp b/Source/RWTHVRToolkit/Private/Pawn/Navigation/CollisionHandlingMovement.cpp index 62bfa4602491506185646dfd769a3876ca4b8ccb..912fe0c1d74a99afb6a7ae6dfd9cd33a40771088 100644 --- a/Source/RWTHVRToolkit/Private/Pawn/Navigation/CollisionHandlingMovement.cpp +++ b/Source/RWTHVRToolkit/Private/Pawn/Navigation/CollisionHandlingMovement.cpp @@ -189,6 +189,9 @@ void UCollisionHandlingMovement::SetCapsuleColliderToUserSize() const } CapsuleColliderComponent->SetWorldRotation(FRotator::ZeroRotator); + + // Counteract Pawn Scaling + CapsuleColliderComponent->SetWorldScale3D(FVector::One()); } void UCollisionHandlingMovement::CheckAndRevertCollisionSinceLastTick() diff --git a/Source/RWTHVRToolkit/Private/Pawn/Navigation/TurnComponent.cpp b/Source/RWTHVRToolkit/Private/Pawn/Navigation/TurnComponent.cpp index 7e3aee8e16027a8d7e55379c38ca4fe0bc2ac537..b4b5183612f7eb2b1d98471d63866464c52b9673 100644 --- a/Source/RWTHVRToolkit/Private/Pawn/Navigation/TurnComponent.cpp +++ b/Source/RWTHVRToolkit/Private/Pawn/Navigation/TurnComponent.cpp @@ -42,7 +42,7 @@ void UTurnComponent::SetupPlayerInput(UInputComponent* PlayerInputComponent) // no snap turning for desktop mode if (!URWTHVRUtilities::IsDesktopMode()) { - EI->BindAction(XRTurn, ETriggerEvent::Started, this, &UTurnComponent::OnBeginSnapTurn); + EI->BindAction(XRTurn, ETriggerEvent::Triggered, this, &UTurnComponent::OnBeginSnapTurn); } else { diff --git a/Source/RWTHVRToolkit/Private/Pawn/RWTHVRPawn.cpp b/Source/RWTHVRToolkit/Private/Pawn/RWTHVRPawn.cpp index f6f9f1c01e9cb475c0ae7975b2a412bf0302ee2a..bf5b24da956e845fd2c1f48d2dbb83fae5dfc9f9 100644 --- a/Source/RWTHVRToolkit/Private/Pawn/RWTHVRPawn.cpp +++ b/Source/RWTHVRToolkit/Private/Pawn/RWTHVRPawn.cpp @@ -41,8 +41,26 @@ ARWTHVRPawn::ARWTHVRPawn(const FObjectInitializer& ObjectInitializer) : Super(Ob LeftHand = CreateDefaultSubobject<UReplicatedMotionControllerComponent>(TEXT("Left Hand MCC")); LeftHand->SetupAttachment(RootComponent); + + UniformScale = GetActorScale3D().X; + GetRootComponent()->TransformUpdated.AddLambda( + [this](USceneComponent*, EUpdateTransformFlags, ETeleportType) + { + FVector CurrentScale = this->GetActorScale3D(); + if (CurrentScale.X != UniformScale || CurrentScale.Y != UniformScale || CurrentScale.Z != UniformScale) + { + UE_LOGFMT(Toolkit, Warning, + "ARWTHVRPawn: Do not adjust the scale of the pawn directly. This will not work in VR. Use " + "ARWTHVRPawn::SetScale(float) instead."); + } + }); +} + +void ARWTHVRPawn::BeginPlay() +{ + Super::BeginPlay(); + InitialWorldToMeters = GetWorldSettings()->WorldToMeters; } -void ARWTHVRPawn::BeginPlay() { Super::BeginPlay(); } void ARWTHVRPawn::Tick(float DeltaSeconds) { @@ -56,6 +74,22 @@ void ARWTHVRPawn::Tick(float DeltaSeconds) EvaluateLivelink(); } +/* + * Scales the Pawn while also adjusting the WorldToMeters ratio to adjust for pupillary distance. + * Only supports uniform scaling. + */ +void ARWTHVRPawn::SetScale(float NewScale) +{ + FVector OldScale = GetActorScale(); + UniformScale = NewScale; + FVector NewScaleVector = FVector(UniformScale, UniformScale, UniformScale); + GetWorldSettings()->WorldToMeters = InitialWorldToMeters * UniformScale; + SetActorRelativeScale3D(NewScaleVector); + OnScaleChanged.Broadcast(OldScale, NewScale); +} + +float ARWTHVRPawn::GetScale() { return UniformScale; } + /* * The alternative would be to do this only on the server on possess and check for player state/type, * as connections now send their playertype over. @@ -368,4 +402,4 @@ void ARWTHVRPawn::ApplyLiveLinkTransform(const FTransform& Transform, HeadCameraComponent->SetRelativeScale3D(Transform.GetScale3D()); } } -} +} \ No newline at end of file diff --git a/Source/RWTHVRToolkit/Public/Pawn/RWTHVRPawn.h b/Source/RWTHVRToolkit/Public/Pawn/RWTHVRPawn.h index cd81e497181dcfef757b067ccae8c862c022fa34..40eb174f5f82b11a9c30b3130fca1f702a687409 100644 --- a/Source/RWTHVRToolkit/Public/Pawn/RWTHVRPawn.h +++ b/Source/RWTHVRToolkit/Public/Pawn/RWTHVRPawn.h @@ -14,6 +14,8 @@ class UCameraComponent; class UMotionControllerComponent; struct FLiveLinkTransformStaticData; +DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FOnScaleChangedDelegate, FVector, OldScale, float, NewUniformScale); + /** * Pawn implementation with additional VR functionality, can be used in the Cave, with an HMD and on desktop. */ @@ -31,6 +33,15 @@ public: virtual void NotifyControllerChanged() override; + UFUNCTION(BlueprintCallable) + void SetScale(float NewScale); + + UFUNCTION(BlueprintCallable) + float GetScale(); + + UPROPERTY(BlueprintAssignable) + FOnScaleChangedDelegate OnScaleChanged; + UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Pawn|Input") TArray<UInputMappingContext*> InputMappingContexts; @@ -111,4 +122,6 @@ protected: private: UInputComponent* ActivePlayerInputComponent; + float InitialWorldToMeters; + float UniformScale; };