diff --git a/Source/RWTHVRToolkit/Private/Pawn/RWTHVRPawn.cpp b/Source/RWTHVRToolkit/Private/Pawn/RWTHVRPawn.cpp index 7e32a90d719d6f0fd489352bd9d38d4149baf206..f773fa9f77004f397b035bc6e8942aa43ef506b8 100644 --- a/Source/RWTHVRToolkit/Private/Pawn/RWTHVRPawn.cpp +++ b/Source/RWTHVRToolkit/Private/Pawn/RWTHVRPawn.cpp @@ -43,16 +43,17 @@ ARWTHVRPawn::ARWTHVRPawn(const FObjectInitializer& ObjectInitializer) : Super(Ob 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) + GetRootComponent()->TransformUpdated.AddLambda( + [this](USceneComponent*, EUpdateTransformFlags, ETeleportType) { - 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.") - ; - } - }); + 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() @@ -87,10 +88,7 @@ void ARWTHVRPawn::SetScale(float NewScale) OnScaleChanged.Broadcast(OldScale, NewScale); } -float ARWTHVRPawn::GetScale() -{ - return UniformScale; -} +float ARWTHVRPawn::GetScale() { return UniformScale; } /* * The alternative would be to do this only on the server on possess and check for player state/type, @@ -107,7 +105,7 @@ void ARWTHVRPawn::NotifyControllerChanged() if (HasAuthority()) { UE_LOG(Toolkit, Display, - TEXT("ARWTHVRPawn: Player Controller has changed, trying to change Cluster attachment if possible...")); + TEXT("ARWTHVRPawn: Player Controller has changed, trying to change Cluster attachment if possible...")); if (const ARWTHVRPlayerState* State = GetPlayerState<ARWTHVRPlayerState>()) { const EPlayerType Type = State->GetPlayerType(); @@ -137,7 +135,7 @@ void ARWTHVRPawn::SetupPlayerInputComponent(UInputComponent* PlayerInputComponen } UE_LOGFMT(Toolkit, Display, "SetupPlayerInputComponent: Player Controller is valid, setting up input for {Pawn}", - GetName()); + GetName()); // Set the control rotation of the PC to zero again. There is a small period of 2 frames where, when the pawn gets @@ -209,7 +207,7 @@ void ARWTHVRPawn::AddInputMappingContext(const APlayerController* PC, const UInp else { UE_LOGFMT(Toolkit, Warning, - "ARWTHVRPawn::AddInputMappingContext: UEnhancedInputLocalPlayerSubsystem is nullptr!"); + "ARWTHVRPawn::AddInputMappingContext: UEnhancedInputLocalPlayerSubsystem is nullptr!"); } } else @@ -237,7 +235,7 @@ void ARWTHVRPawn::EvaluateLivelink() const IModularFeatures::Get().GetModularFeature<ILiveLinkClient>(ILiveLinkClient::ModularFeatureName); FLiveLinkSubjectFrameData SubjectData; const bool bHasValidData = LiveLinkClient.EvaluateFrame_AnyThread(HeadSubjectRepresentation.Subject, - HeadSubjectRepresentation.Role, SubjectData); + HeadSubjectRepresentation.Role, SubjectData); if (!bHasValidData) { @@ -314,12 +312,12 @@ void ARWTHVRPawn::AttachClustertoPawn() bool bAttached = ClusterActor->AttachToComponent(GetRootComponent(), AttachmentRules); // State->GetCorrespondingClusterActor()->OnAttached(); UE_LOGFMT(Toolkit, Display, - "ARWTHVRPawn: Attaching corresponding cluster actor to our pawn returned: {Attached}", bAttached); + "ARWTHVRPawn: Attaching corresponding cluster actor to our pawn returned: {Attached}", bAttached); } else { UE_LOGFMT(Toolkit, Error, - "ARWTHVRPawn::AttachClustertoPawn: No ARWTHVRPlayerState set! This won't work on the Cave."); + "ARWTHVRPawn::AttachClustertoPawn: No ARWTHVRPlayerState set! This won't work on the Cave."); } if (HasAuthority()) // Should always be the case here, but double check @@ -357,19 +355,19 @@ void ARWTHVRPawn::SetCameraOffset() const } void ARWTHVRPawn::ApplyLiveLinkTransform(const FTransform& Transform, - const FLiveLinkTransformStaticData& StaticData) const + const FLiveLinkTransformStaticData& StaticData) const { if (StaticData.bIsLocationSupported) { if (bWorldTransform) { HeadCameraComponent->SetWorldLocation(Transform.GetLocation(), false, nullptr, - ETeleportType::TeleportPhysics); + ETeleportType::TeleportPhysics); } else { HeadCameraComponent->SetRelativeLocation(Transform.GetLocation(), false, nullptr, - ETeleportType::TeleportPhysics); + ETeleportType::TeleportPhysics); } } @@ -378,12 +376,12 @@ void ARWTHVRPawn::ApplyLiveLinkTransform(const FTransform& Transform, if (bWorldTransform) { HeadCameraComponent->SetWorldRotation(Transform.GetRotation(), false, nullptr, - ETeleportType::TeleportPhysics); + ETeleportType::TeleportPhysics); } else { HeadCameraComponent->SetRelativeRotation(Transform.GetRotation(), false, nullptr, - ETeleportType::TeleportPhysics); + ETeleportType::TeleportPhysics); } } diff --git a/Source/RWTHVRToolkit/Public/Pawn/RWTHVRPawn.h b/Source/RWTHVRToolkit/Public/Pawn/RWTHVRPawn.h index bad99461296fe3e58a0fb8a0ca45827aa4959f7c..40eb174f5f82b11a9c30b3130fca1f702a687409 100644 --- a/Source/RWTHVRToolkit/Public/Pawn/RWTHVRPawn.h +++ b/Source/RWTHVRToolkit/Public/Pawn/RWTHVRPawn.h @@ -32,7 +32,7 @@ public: virtual void Tick(float DeltaSeconds) override; virtual void NotifyControllerChanged() override; - + UFUNCTION(BlueprintCallable) void SetScale(float NewScale);