From 3df12a017e6d76494f800620bf44a71f4c5786b7 Mon Sep 17 00:00:00 2001 From: Sebastian Pape <Sebastian.Pape@rwth-aachen.de> Date: Mon, 5 Aug 2019 14:59:02 +0200 Subject: [PATCH] Altered calculation and added debug output for attachment --- Source/CAVEOverlay/Private/CAVEOverlayController.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Source/CAVEOverlay/Private/CAVEOverlayController.cpp b/Source/CAVEOverlay/Private/CAVEOverlayController.cpp index d859093..312f084 100644 --- a/Source/CAVEOverlay/Private/CAVEOverlayController.cpp +++ b/Source/CAVEOverlay/Private/CAVEOverlayController.cpp @@ -184,11 +184,15 @@ void ACAVEOverlayController::BeginPlay() if (!attached_ && cave_origin_) { AttachToComponent(cave_origin_, FAttachmentTransformRules::SnapToTargetNotIncludingScale); attached_ = true; + UE_LOG(CAVEOverlayLog, Log, TEXT("Attached to CaveOrigin")); } } float ACAVEOverlayController::calculateOpacityFromPosition(FVector position) { - return 1 - FMath::Clamp(((FVector2D(position).GetAbs() - FVector2D(wall_distance_ - wall_close_distance_, wall_distance_ - wall_close_distance_)) / wall_fade_distance_).GetAbsMax(), 0.0f, 1.0f); + return FMath::Max( + FMath::Clamp((FMath::Abs(position.X) - (wall_distance_ - wall_close_distance_)) / wall_fade_distance_, 0.0f, 1.0f), + FMath::Clamp((FMath::Abs(position.Y) - (wall_distance_ - wall_close_distance_)) / wall_fade_distance_, 0.0f, 1.0f) + ); } bool ACAVEOverlayController::positionInDoorOpening(FVector position) { @@ -216,6 +220,7 @@ void ACAVEOverlayController::Tick(float DeltaTime) if (!attached_ && cave_origin_) { AttachToComponent(cave_origin_, FAttachmentTransformRules::SnapToTargetNotIncludingScale); attached_ = true; + UE_LOG(CAVEOverlayLog, Log, TEXT("Attached to CaveOrigin")); } if (!shutter_glasses_) return; //Display Cluster not initialized -- GitLab