From 631538d569af4d629bfaf06246747f6da7381c18 Mon Sep 17 00:00:00 2001
From: Lab1 <account@vr.rwth-aachen.de>
Date: Fri, 3 Mar 2023 21:28:36 +0100
Subject: [PATCH] remove second default values (in initialize parameters) and
 scale ray in beginplay (when the values are actually set)

---
 .../Private/Pawn/BasicVRInteractionComponent.cpp          | 8 +++-----
 .../Public/Pawn/BasicVRInteractionComponent.h             | 2 +-
 2 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/Source/RWTHVRToolkit/Private/Pawn/BasicVRInteractionComponent.cpp b/Source/RWTHVRToolkit/Private/Pawn/BasicVRInteractionComponent.cpp
index 14cf5e0f..e0d9f8c0 100644
--- a/Source/RWTHVRToolkit/Private/Pawn/BasicVRInteractionComponent.cpp
+++ b/Source/RWTHVRToolkit/Private/Pawn/BasicVRInteractionComponent.cpp
@@ -41,7 +41,8 @@ void UBasicVRInteractionComponent::BeginPlay()
 	Super::BeginPlay();
 	
 	//WidgetInteractionComponent
-	// InteractionDistance = MaxClickDistance;
+	InteractionDistance = MaxClickDistance;
+	InteractionRay->SetRelativeScale3D(FVector(MaxClickDistance / 100.0f, 0.5f, 0.5f)); //the ray model has a length of 100cm (and is a bit too big in Y/Z dir)
 	SetInteractionRayVisibility(InteractionRayVisibility);
 }
 
@@ -195,16 +196,13 @@ void UBasicVRInteractionComponent::TickComponent(float DeltaTime, ELevelTick Tic
 	LastActorHit = HitActor; // Store the actor that was hit to have access to it in the next frame as well
 }
 
-void UBasicVRInteractionComponent::Initialize(USceneComponent* RayEmitter, float InMaxGrabDistance, float InMaxClickDistance)
+void UBasicVRInteractionComponent::Initialize(USceneComponent* RayEmitter)
 {
 	if(InteractionRayEmitter) return; /* Return if already initialized */
 
 	InteractionRayEmitter = RayEmitter;
-	MaxGrabDistance = InMaxGrabDistance;
-	MaxClickDistance = InMaxClickDistance;
 
 	InteractionRay->AttachToComponent(RayEmitter, FAttachmentTransformRules::KeepRelativeTransform);
-	InteractionRay->SetRelativeScale3D(FVector(MaxClickDistance/100.0f, 1.0f, 1.0f)); //the ray model has a length of 100cm
 	this->AttachToComponent(RayEmitter, FAttachmentTransformRules::KeepRelativeTransform);
 }
 
diff --git a/Source/RWTHVRToolkit/Public/Pawn/BasicVRInteractionComponent.h b/Source/RWTHVRToolkit/Public/Pawn/BasicVRInteractionComponent.h
index 2e6e24e8..e62fbf21 100644
--- a/Source/RWTHVRToolkit/Public/Pawn/BasicVRInteractionComponent.h
+++ b/Source/RWTHVRToolkit/Public/Pawn/BasicVRInteractionComponent.h
@@ -42,7 +42,7 @@ public:
 	UPROPERTY(EditAnywhere) bool bCanRaytraceEveryTick = false;
 	UPROPERTY(EditAnywhere) TEnumAsByte<EInteractionRayVisibility> InteractionRayVisibility = EInteractionRayVisibility::Invisible;
 
-	UFUNCTION(BlueprintCallable) void Initialize(USceneComponent* RayEmitter, float InMaxGrabDistance = 50, float InMaxClickDistance = 500);
+	UFUNCTION(BlueprintCallable) void Initialize(USceneComponent* RayEmitter);
 	
 	UFUNCTION(BlueprintCallable, BlueprintPure) AActor* GetGrabbedActor() const { return GrabbedActor;}
 	UFUNCTION(BlueprintCallable, BlueprintPure) USceneComponent* GetInteractionRayEmitter() const { return InteractionRayEmitter;	}
-- 
GitLab