From 193a009aab78ea8af1f4415ffe5d022b546b14ec Mon Sep 17 00:00:00 2001 From: Kris Helwig <helwig@vr.rwth-aachen.de> Date: Fri, 11 Apr 2025 09:45:06 +0200 Subject: [PATCH] Fix(Pawn): Fixed config interface casting --- .../RWTHVRToolkit/Private/Pawn/RWTHVRPawn.cpp | 22 ++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/Source/RWTHVRToolkit/Private/Pawn/RWTHVRPawn.cpp b/Source/RWTHVRToolkit/Private/Pawn/RWTHVRPawn.cpp index b79168b..8f0ecb4 100644 --- a/Source/RWTHVRToolkit/Private/Pawn/RWTHVRPawn.cpp +++ b/Source/RWTHVRToolkit/Private/Pawn/RWTHVRPawn.cpp @@ -84,7 +84,6 @@ void ARWTHVRPawn::Tick(float DeltaSeconds) */ void ARWTHVRPawn::SetScale(float NewScale) { - FVector OldScale = GetActorScale(); UniformScale = NewScale; FVector NewScaleVector = FVector(UniformScale, UniformScale, UniformScale); GetWorldSettings()->WorldToMeters = InitialWorldToMeters * UniformScale; @@ -92,11 +91,24 @@ void ARWTHVRPawn::SetScale(float NewScale) #if PLATFORM_SUPPORTS_CLUSTER const ARWTHVRPlayerState* State = GetPlayerState<ARWTHVRPlayerState>(); - if (URWTHVRUtilities::IsHeadMountedMode() && State && State->GetCorrespondingClusterActor()) + if (URWTHVRUtilities::IsRoomMountedMode() && State && State->GetCorrespondingClusterActor()) { - const auto ClusterRootActor = IDisplayCluster::Get().GetGameMgr()->GetRootActor(); - IScalableConfigInterface* ConfigInterface = Cast<IScalableConfigInterface>(ClusterRootActor); - ConfigInterface->OnScaleChanged(NewScale); + 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 } -- GitLab