Skip to content
Snippets Groups Projects
Commit 72232ee1 authored by Kris Tabea Helwig's avatar Kris Tabea Helwig
Browse files

Merge branch 'feature/scaling' into 'dev/5.4'

Feature/scaling

See merge request !115
parents 8df591ea 594b4717
No related branches found
No related tags found
2 merge requests!120UE5.4-2024.1,!115Feature/scaling
...@@ -189,6 +189,9 @@ void UCollisionHandlingMovement::SetCapsuleColliderToUserSize() const ...@@ -189,6 +189,9 @@ void UCollisionHandlingMovement::SetCapsuleColliderToUserSize() const
} }
CapsuleColliderComponent->SetWorldRotation(FRotator::ZeroRotator); CapsuleColliderComponent->SetWorldRotation(FRotator::ZeroRotator);
// Counteract Pawn Scaling
CapsuleColliderComponent->SetWorldScale3D(FVector::One());
} }
void UCollisionHandlingMovement::CheckAndRevertCollisionSinceLastTick() void UCollisionHandlingMovement::CheckAndRevertCollisionSinceLastTick()
......
...@@ -18,6 +18,10 @@ ...@@ -18,6 +18,10 @@
#include "Utility/RWTHVRUtilities.h" #include "Utility/RWTHVRUtilities.h"
#if PLATFORM_SUPPORTS_CLUSTER #if PLATFORM_SUPPORTS_CLUSTER
#include "DisplayClusterRootActor.h"
#include "ScalableConfigInterface.h"
#include "IDisplayCluster.h"
#include "Game/IDisplayClusterGameManager.h"
#include "Components/DisplayClusterSceneComponentSyncParent.h" #include "Components/DisplayClusterSceneComponentSyncParent.h"
#endif #endif
...@@ -41,7 +45,21 @@ ARWTHVRPawn::ARWTHVRPawn(const FObjectInitializer& ObjectInitializer) : Super(Ob ...@@ -41,7 +45,21 @@ ARWTHVRPawn::ARWTHVRPawn(const FObjectInitializer& ObjectInitializer) : Super(Ob
LeftHand = CreateDefaultSubobject<UReplicatedMotionControllerComponent>(TEXT("Left Hand MCC")); LeftHand = CreateDefaultSubobject<UReplicatedMotionControllerComponent>(TEXT("Left Hand MCC"));
LeftHand->SetupAttachment(RootComponent); 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(); } void ARWTHVRPawn::BeginPlay() { Super::BeginPlay(); }
void ARWTHVRPawn::Tick(float DeltaSeconds) void ARWTHVRPawn::Tick(float DeltaSeconds)
...@@ -56,6 +74,42 @@ void ARWTHVRPawn::Tick(float DeltaSeconds) ...@@ -56,6 +74,42 @@ void ARWTHVRPawn::Tick(float DeltaSeconds)
EvaluateLivelink(); EvaluateLivelink();
} }
/*
* Scales the Pawn. Only supports uniform scaling.
*/
void ARWTHVRPawn::SetScale(float NewScale)
{
UniformScale = NewScale;
FVector NewScaleVector = FVector(UniformScale, UniformScale, UniformScale);
SetActorRelativeScale3D(NewScaleVector);
#if PLATFORM_SUPPORTS_CLUSTER
const ARWTHVRPlayerState* State = GetPlayerState<ARWTHVRPlayerState>();
if (URWTHVRUtilities::IsRoomMountedMode() && State && State->GetCorrespondingClusterActor())
{
if (const auto GameMgr = IDisplayCluster::Get().GetGameMgr())
{
if (const auto ClusterRootActor = GameMgr->GetRootActor())
{
if (ClusterRootActor->Implements<UScalableConfigInterface>())
{
IScalableConfigInterface::Execute_OnScaleChanged(ClusterRootActor, NewScale);
}
else
{
UE_LOGFMT(Toolkit, Warning,
"The ClusterRootActor {0} does not implement the ScalableConfigInterface. Scaling the "
"Pawn on the cluster will lead to unintended behavior.",
ClusterRootActor->GetName());
}
}
}
}
#endif
}
float ARWTHVRPawn::GetScale() { return UniformScale; }
/* /*
* The alternative would be to do this only on the server on possess and check for player state/type, * 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. * as connections now send their playertype over.
......
...@@ -14,6 +14,8 @@ class UCameraComponent; ...@@ -14,6 +14,8 @@ class UCameraComponent;
class UMotionControllerComponent; class UMotionControllerComponent;
struct FLiveLinkTransformStaticData; 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. * Pawn implementation with additional VR functionality, can be used in the Cave, with an HMD and on desktop.
*/ */
...@@ -31,6 +33,15 @@ public: ...@@ -31,6 +33,15 @@ public:
virtual void NotifyControllerChanged() override; virtual void NotifyControllerChanged() override;
UFUNCTION(BlueprintCallable)
void SetScale(float NewScale);
UFUNCTION(BlueprintCallable)
float GetScale();
UPROPERTY(BlueprintAssignable)
FOnScaleChangedDelegate OnScaleChanged;
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Pawn|Input") UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Pawn|Input")
TArray<UInputMappingContext*> InputMappingContexts; TArray<UInputMappingContext*> InputMappingContexts;
...@@ -111,4 +122,5 @@ protected: ...@@ -111,4 +122,5 @@ protected:
private: private:
UInputComponent* ActivePlayerInputComponent; UInputComponent* ActivePlayerInputComponent;
float UniformScale;
}; };
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment