diff --git a/Source/RWTHVRToolkit/Private/Interaction/Interactables/IntenSelect/IntenSelectable.cpp b/Source/RWTHVRToolkit/Private/Interaction/Interactables/IntenSelect/IntenSelectable.cpp index 2daca7dc065500f290846490555275997d6d8831..b7fcb074af54a0003247301cf89ce16519bcc451 100644 --- a/Source/RWTHVRToolkit/Private/Interaction/Interactables/IntenSelect/IntenSelectable.cpp +++ b/Source/RWTHVRToolkit/Private/Interaction/Interactables/IntenSelect/IntenSelectable.cpp @@ -56,7 +56,7 @@ void UIntenSelectable::BeginPlay() } } -void UIntenSelectable::HandleOnSelectStartEvents(const UIntenSelectComponent* IntenSelect, const FHitResult& HitResult) +void UIntenSelectable::HandleOnHoverStartEvents(const UIntenSelectComponent* IntenSelect, const FHitResult& HitResult) { for (const UHoverBehaviour* CurrentHoverBehaviour : OnHoverBehaviours) { @@ -64,7 +64,7 @@ void UIntenSelectable::HandleOnSelectStartEvents(const UIntenSelectComponent* In } } -void UIntenSelectable::HandleOnSelectEndEvents(const UIntenSelectComponent* IntenSelect) +void UIntenSelectable::HandleOnHoverEndEvents(const UIntenSelectComponent* IntenSelect) { for (const UHoverBehaviour* CurrentHoverBehaviour : OnHoverBehaviours) { @@ -72,7 +72,7 @@ void UIntenSelectable::HandleOnSelectEndEvents(const UIntenSelectComponent* Inte } } -void UIntenSelectable::HandleOnClickStartEvents(UIntenSelectComponent* IntenSelect) +void UIntenSelectable::HandleOnActionStartEvents(UIntenSelectComponent* IntenSelect) { for (const UActionBehaviour* CurrentActionBehaviour : OnActionBehaviours) { @@ -82,7 +82,7 @@ void UIntenSelectable::HandleOnClickStartEvents(UIntenSelectComponent* IntenSele } } -void UIntenSelectable::HandleOnClickEndEvents(UIntenSelectComponent* IntenSelect, FInputActionValue& InputValue) +void UIntenSelectable::HandleOnActionEndEvents(UIntenSelectComponent* IntenSelect, FInputActionValue& InputValue) { for (const UActionBehaviour* CurrentActionBehaviour : OnActionBehaviours) { diff --git a/Source/RWTHVRToolkit/Private/Interaction/Interactables/IntenSelect/IntenSelectableCircleScoring.cpp b/Source/RWTHVRToolkit/Private/Interaction/Interactables/IntenSelect/IntenSelectableCircleScoring.cpp index c323f50d1148d8ecb4fc45930a9ca0f00775c69f..9e4a0b22792550abeae84efc8641ba725f22655a 100644 --- a/Source/RWTHVRToolkit/Private/Interaction/Interactables/IntenSelect/IntenSelectableCircleScoring.cpp +++ b/Source/RWTHVRToolkit/Private/Interaction/Interactables/IntenSelect/IntenSelectableCircleScoring.cpp @@ -1,7 +1,4 @@ -// Fill out your copyright notice in the Description page of Project Settings. - #include "Interaction/Interactables/IntenSelect/IntenSelectableCircleScoring.h" - #include "DrawDebugHelpers.h" #include "Kismet/KismetMathLibrary.h" @@ -10,8 +7,8 @@ UIntenSelectableCircleScoring::UIntenSelectableCircleScoring() { PrimaryComponen TPair<FHitResult, float> UIntenSelectableCircleScoring::GetBestPointScorePair(const FVector& ConeOrigin, const FVector& ConeForwardDirection, - const float ConeBackwardShiftDistance, const float ConeAngle, - const float LastValue, const float DeltaTime) + const float ConeBackwardShiftDistance, const float ConeAngle, + const float LastValue, const float DeltaTime) { const FVector Point = GetClosestSelectionPointTo(ConeOrigin, ConeForwardDirection); float Score = @@ -26,15 +23,17 @@ FVector UIntenSelectableCircleScoring::GetClosestSelectionPointTo(const FVector& const FVector CircleNormalWorld = this->GetComponentTransform().TransformPositionNoScale(FVector::ForwardVector) - CenterWorld; - float t; - FVector Intersect; - if (!UKismetMathLibrary::LinePlaneIntersection_OriginNormal(Point, Point + Direction * 100000, CenterWorld, - CircleNormalWorld, t, Intersect)) + float IntersectionRatio; + FVector IntersectionPoint; + constexpr float MaxDistance = 100000; + if (!UKismetMathLibrary::LinePlaneIntersection_OriginNormal(Point, Point + Direction * MaxDistance, CenterWorld, + CircleNormalWorld, IntersectionRatio, + IntersectionPoint)) { return CenterWorld; } - const FVector CenterToPoint = Intersect - CenterWorld; + const FVector CenterToPoint = IntersectionPoint - CenterWorld; FVector Result; if (OnlyOutline) @@ -51,15 +50,13 @@ FVector UIntenSelectableCircleScoring::GetClosestSelectionPointTo(const FVector& } else { - Result = Intersect; + Result = IntersectionPoint; } } FVector Y = CenterToPoint.GetSafeNormal(); FVector Z = FVector::CrossProduct(Y, CircleNormalWorld.GetSafeNormal()); - // Y = FVector(0, 0, 1); - // Z = FVector(1, 0, 0); DrawDebugCircle(GetWorld(), CenterWorld, Radius, 80, FColor::Green, false, -1, 0, 1, Y, Z, false); return Result; diff --git a/Source/RWTHVRToolkit/Private/Interaction/Interactables/IntenSelect/IntenSelectableCubeScoring.cpp b/Source/RWTHVRToolkit/Private/Interaction/Interactables/IntenSelect/IntenSelectableCubeScoring.cpp index f7e8f98116514adc45b63c2b81fa7a66acb95905..450a54baf9e0253cfa0e715479faa04876ce3ac7 100644 --- a/Source/RWTHVRToolkit/Private/Interaction/Interactables/IntenSelect/IntenSelectableCubeScoring.cpp +++ b/Source/RWTHVRToolkit/Private/Interaction/Interactables/IntenSelect/IntenSelectableCubeScoring.cpp @@ -1,9 +1,5 @@ -// Fill out your copyright notice in the Description page of Project Settings. - #include "Interaction/Interactables/IntenSelect/IntenSelectableCubeScoring.h" - #include "DrawDebugHelpers.h" -#include "Intersection/IntrRay3AxisAlignedBox3.h" #include "Kismet/KismetMathLibrary.h" // Sets default values for this component's properties @@ -18,7 +14,7 @@ UIntenSelectableCubeScoring::GetBestPointScorePair(const FVector& ConeOrigin, co const float ConeBackwardShiftDistance, const float ConeAngle, const float LastValue, const float DeltaTime) { - FVector Point = GetClosestSelectionPointTo(ConeOrigin, ConeForwardDirection); + const FVector Point = GetClosestSelectionPointTo(ConeOrigin, ConeForwardDirection); float Score = Super::GetScore(ConeOrigin, ConeForwardDirection, ConeBackwardShiftDistance, ConeAngle, Point, LastValue, DeltaTime); FHitResult Result = FHitResult{GetOwner(), nullptr, Point, FVector::ForwardVector}; @@ -27,10 +23,10 @@ UIntenSelectableCubeScoring::GetBestPointScorePair(const FVector& ConeOrigin, co FVector UIntenSelectableCubeScoring::GetClosestPointToRectangle(const FVector& StartPoint, const FVector& Direction, const FVector& Corner00, const FVector& Corner01, - const FVector& Corner10, const FVector& Corner11) const + const FVector& Corner10) const { - const float X = FVector::Distance(Corner00, Corner10); - const float Y = FVector::Distance(Corner00, Corner01); + const float LengthX = FVector::Distance(Corner00, Corner10); + const float LengthY = FVector::Distance(Corner00, Corner01); const FVector PlaneNormal = FVector::CrossProduct(Corner10 - Corner00, Corner01 - Corner00).GetSafeNormal(); FVector Intersection; @@ -40,87 +36,9 @@ FVector UIntenSelectableCubeScoring::GetClosestPointToRectangle(const FVector& S FVector LocalIntersection = this->GetComponentTransform().InverseTransformPosition(Intersection); - if (LocalIntersection.Y > X / 2) - { - LocalIntersection.Y = X / 2; - } - else if (LocalIntersection.Y < -X / 2) - { - LocalIntersection.Y = -X / 2; - } - - if (LocalIntersection.Z > Y / 2) - { - LocalIntersection.Z = Y / 2; - } - else if (LocalIntersection.Z < -Y / 2) - { - LocalIntersection.Z = -Y / 2; - } - - /* - if(OnlyOutline) - { - const float DistToBottom = LocalIntersection.Z + (YLength / 2); - const float DistToLeft = LocalIntersection.Y + (XLength / 2); + LocalIntersection.Y = FMath::Clamp(LocalIntersection.Y, -LengthX / 2, LengthX / 2); + LocalIntersection.Z = FMath::Clamp(LocalIntersection.Z, -LengthY / 2, LengthY / 2); - if(LocalIntersection.Z < 0) - { - if(LocalIntersection.Y < 0) - { - //Bottom and left - if(DistToLeft < DistToBottom) - { - //snap left - LocalIntersection.Y = -(XLength / 2); - }else - { - //snap bottom - LocalIntersection.Z = -(YLength / 2); - } - }else - { - //bottom and right - if(XLength - DistToLeft < DistToBottom) - { - //snap right - LocalIntersection.Y = XLength / 2; - }else - { - //snap bottom - LocalIntersection.Z = -(YLength / 2); - } - } - }else - { - if(LocalIntersection.Y < 0) - { - //top and left - if(DistToLeft < YLength - DistToBottom) - { - //snap left - LocalIntersection.Y = -(XLength / 2); - }else - { - //snap top - LocalIntersection.Z = (YLength / 2); - } - }else - { - //top and right - if(XLength - DistToLeft < YLength - DistToBottom) - { - //snap right - LocalIntersection.Y = XLength / 2; - }else - { - //snap top - LocalIntersection.Z = (YLength / 2); - } - } - } - } -*/ return this->GetComponentTransform().TransformPosition(LocalIntersection); } @@ -128,65 +46,61 @@ FVector UIntenSelectableCubeScoring::GetClosestPointToRectangle(const FVector& S bool UIntenSelectableCubeScoring::LineToLineIntersection(const FVector& FromA, const FVector& FromB, const FVector& ToA, const FVector& ToB, FVector& OutIntersection) { - const FVector Da = ToA - FromA; - const FVector DB = ToB - FromB; - const FVector DC = FromB - FromA; + const FVector DistanceA = ToA - FromA; + const FVector DistanceB = ToB - FromB; + const FVector DistanceC = FromB - FromA; - const FVector CrossDaDb = FVector::CrossProduct(Da, DB); - const float Prod = CrossDaDb.X * CrossDaDb.X + CrossDaDb.Y * CrossDaDb.Y + CrossDaDb.Z * CrossDaDb.Z; + const FVector CrossProductAB = FVector::CrossProduct(DistanceA, DistanceB); + const float Prod = + CrossProductAB.X * CrossProductAB.X + CrossProductAB.Y * CrossProductAB.Y + CrossProductAB.Z * CrossProductAB.Z; - const float Res = FVector::DotProduct(FVector::CrossProduct(DC, DB), FVector::CrossProduct(Da, DB) / Prod); - if (Res >= -0.02f && Res <= 1.02f) + const float Result = FVector::DotProduct(FVector::CrossProduct(DistanceC, DistanceB), + FVector::CrossProduct(DistanceA, DistanceB) / Prod); + + constexpr float IntersectionThreshold = 0.02f; + if (Result >= -IntersectionThreshold && Result <= 1 + IntersectionThreshold) { - OutIntersection = FromA + Da * FVector(Res, Res, Res); + OutIntersection = FromA + DistanceA * FVector(Result, Result, Result); return true; } return false; } -FVector UIntenSelectableCubeScoring::GetClosestSelectionPointTo(const FVector& RayOrigin, const FVector& RayDirection) +FVector UIntenSelectableCubeScoring::GetClosestSelectionPointTo(const FVector& RayOrigin, + const FVector& RayDirection) const { auto Scale = GetRelativeTransform().GetScale3D(); - const FVector X = this->GetForwardVector() * Scale.X; - const FVector Y = this->GetRightVector() * Scale.Y; - const FVector Z = this->GetUpVector() * Scale.Z; + const FVector ForwardVectorScaled = this->GetForwardVector() * Scale.X; + const FVector RightVectorScaled = this->GetRightVector() * Scale.Y; + const FVector UpVectorScaled = this->GetUpVector() * Scale.Z; TArray<FPlane> CubeSides; // bottom - const FVector BottomWorld = this->GetComponentTransform().TransformPositionNoScale(-Z / 2); + const FVector BottomWorld = this->GetComponentTransform().TransformPositionNoScale(-UpVectorScaled / 2); CubeSides.Add(FPlane{BottomWorld, -this->GetUpVector()}); // top - const FVector TopWorld = this->GetComponentTransform().TransformPositionNoScale(Z / 2); + const FVector TopWorld = this->GetComponentTransform().TransformPositionNoScale(UpVectorScaled / 2); CubeSides.Add(FPlane{TopWorld, this->GetUpVector()}); // left - const FVector LeftWorld = this->GetComponentTransform().TransformPositionNoScale(-Y / 2); + const FVector LeftWorld = this->GetComponentTransform().TransformPositionNoScale(-RightVectorScaled / 2); CubeSides.Add(FPlane{LeftWorld, -this->GetRightVector()}); // right - const FVector RightWorld = this->GetComponentTransform().TransformPositionNoScale(Y / 2); + const FVector RightWorld = this->GetComponentTransform().TransformPositionNoScale(RightVectorScaled / 2); CubeSides.Add(FPlane{RightWorld, this->GetRightVector()}); // front - const FVector FrontWorld = this->GetComponentTransform().TransformPositionNoScale(-X / 2); + const FVector FrontWorld = this->GetComponentTransform().TransformPositionNoScale(-ForwardVectorScaled / 2); CubeSides.Add(FPlane{FrontWorld, -this->GetForwardVector()}); // back - const FVector BackWorld = this->GetComponentTransform().TransformPositionNoScale(X / 2); + const FVector BackWorld = this->GetComponentTransform().TransformPositionNoScale(ForwardVectorScaled / 2); CubeSides.Add(FPlane{BackWorld, this->GetForwardVector()}); - /* - const TRay3<float> Ray{Point, Direction, false}; - const TAxisAlignedBox3<float> Box; - float OutT; - if(TIntrRay3AxisAlignedBox3<float>::FindIntersection(Ray, Box, OutT)) - { - - }*/ - float MinDistance = TNumericLimits<float>::Max(); FVector ClosestPoint = GetComponentLocation(); bool IsSet = false; @@ -304,9 +218,6 @@ FVector UIntenSelectableCubeScoring::GetClosestSelectionPointTo(const FVector& R const float Distance = FMath::PointDistToLine(CurrentPoint, RayDirection, RayOrigin); - // DrawDebugPoint(GetWorld(), CurrentPoint, 10, FColor::Black.WithAlpha(1), false, -1, 0); - // GEngine->AddOnScreenDebugMessage(INDEX_NONE, -1, FColor::Red, FString::SanitizeFloat(Distance)); - if (Distance < 0.001) { if (MinDistance < 0.001) diff --git a/Source/RWTHVRToolkit/Private/Pawn/IntenSelectComponent.cpp b/Source/RWTHVRToolkit/Private/Pawn/IntenSelectComponent.cpp index 385e2b2e4a8f1818446f7385cf68b2672f0f851e..9231f2a899ec4addf35cfa11fadd5d00aa9979cb 100644 --- a/Source/RWTHVRToolkit/Private/Pawn/IntenSelectComponent.cpp +++ b/Source/RWTHVRToolkit/Private/Pawn/IntenSelectComponent.cpp @@ -564,7 +564,7 @@ void UIntenSelectComponent::OnFireDown() if (CurrentSelection) { const FHitResult GrabbedPoint = *ContactPointMap.Find(CurrentSelection); - CurrentSelection->HandleOnClickStartEvents(this); + CurrentSelection->HandleOnActionStartEvents(this); LastKnownSelection = CurrentSelection; LastKnownGrabPoint = LastKnownSelection->GetOwner()->GetRootComponent()->GetComponentTransform().InverseTransformPosition( @@ -593,7 +593,7 @@ void UIntenSelectComponent::OnFireUp() if (LastKnownSelection) { FInputActionValue v; - LastKnownSelection->HandleOnClickEndEvents(this, v); + LastKnownSelection->HandleOnActionEndEvents(this, v); } } @@ -664,14 +664,14 @@ void UIntenSelectComponent::HandleActorSelected(UIntenSelectable* NewSelection) { if (CurrentSelection) { - CurrentSelection->HandleOnSelectEndEvents(this); + CurrentSelection->HandleOnHoverEndEvents(this); } if (NewSelection) { UIntenSelectable* NewIntenSelectable = NewSelection; const FHitResult GrabbedPoint = *ContactPointMap.Find(NewIntenSelectable); - NewIntenSelectable->HandleOnSelectStartEvents(this, GrabbedPoint); + NewIntenSelectable->HandleOnHoverStartEvents(this, GrabbedPoint); } CurrentSelection = NewSelection; @@ -709,7 +709,7 @@ void UIntenSelectComponent::HandleNoActorSelected() if (CurrentSelection) { - CurrentSelection->HandleOnSelectEndEvents(this); + CurrentSelection->HandleOnHoverEndEvents(this); } if (bDrawForwardRay && ParameterCollectionInstance) diff --git a/Source/RWTHVRToolkit/Public/Interaction/Interactables/IntenSelect/IntenSelectable.h b/Source/RWTHVRToolkit/Public/Interaction/Interactables/IntenSelect/IntenSelectable.h index 892a478ea50ec84ae7966759577738fec88d34a7..88cabe2430b6c7422a61595dd6c1c7c099e795c8 100644 --- a/Source/RWTHVRToolkit/Public/Interaction/Interactables/IntenSelect/IntenSelectable.h +++ b/Source/RWTHVRToolkit/Public/Interaction/Interactables/IntenSelect/IntenSelectable.h @@ -1,5 +1,3 @@ -// Fill out your copyright notice in the Description page of Project Settings. - #pragma once #include "CoreMinimal.h" @@ -9,7 +7,6 @@ #include "Interaction/Interactables/HoverBehaviour.h" #include "IntenSelectable.generated.h" - class UIntenSelectableScoring; class UClickBehaviour; class USelectionBehaviour; @@ -41,10 +38,10 @@ public: const float ConeBackwardShiftDistance, const float ConeAngle, const float LastValue, const float DeltaTime) const; - void HandleOnSelectStartEvents(const UIntenSelectComponent* IntenSelect, const FHitResult& HitResult); - void HandleOnSelectEndEvents(const UIntenSelectComponent* IntenSelect); - void HandleOnClickStartEvents(UIntenSelectComponent* IntenSelect); - void HandleOnClickEndEvents(UIntenSelectComponent* IntenSelect, FInputActionValue& InputValue); + void HandleOnHoverStartEvents(const UIntenSelectComponent* IntenSelect, const FHitResult& HitResult); + void HandleOnHoverEndEvents(const UIntenSelectComponent* IntenSelect); + void HandleOnActionStartEvents(UIntenSelectComponent* IntenSelect); + void HandleOnActionEndEvents(UIntenSelectComponent* IntenSelect, FInputActionValue& InputValue); void InitDefaultBehaviourReferences(); diff --git a/Source/RWTHVRToolkit/Public/Interaction/Interactables/IntenSelect/IntenSelectableCubeScoring.h b/Source/RWTHVRToolkit/Public/Interaction/Interactables/IntenSelect/IntenSelectableCubeScoring.h index 34d8b637040fbfd282cfaeeea6b4891eb4f50e7d..5646520a1557c8c957feb51e089f36e16f820abf 100644 --- a/Source/RWTHVRToolkit/Public/Interaction/Interactables/IntenSelect/IntenSelectableCubeScoring.h +++ b/Source/RWTHVRToolkit/Public/Interaction/Interactables/IntenSelect/IntenSelectableCubeScoring.h @@ -13,7 +13,7 @@ protected: static bool LineToLineIntersection(const FVector& FromA, const FVector& FromB, const FVector& ToA, const FVector& ToB, FVector& OutIntersection); - FVector GetClosestSelectionPointTo(const FVector& RayOrigin, const FVector& RayDirection); + FVector GetClosestSelectionPointTo(const FVector& RayOrigin, const FVector& RayDirection) const; virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override; @@ -30,20 +30,11 @@ public: UPROPERTY(EditAnywhere) bool OnlyOutline = false; - // UPROPERTY(EditAnywhere) - // float XLength = 100; - - // UPROPERTY(EditAnywhere) - // float YLength = 100; - - // UPROPERTY(EditAnywhere) - // float ZLength = 100; - virtual TPair<FHitResult, float> GetBestPointScorePair(const FVector& ConeOrigin, const FVector& ConeForwardDirection, const float ConeBackwardShiftDistance, const float ConeAngle, const float LastValue, const float DeltaTime) override; FVector GetClosestPointToRectangle(const FVector& StartPoint, const FVector& Direction, const FVector& Corner00, - const FVector& Corner01, const FVector& Corner10, const FVector& Corner11) const; + const FVector& Corner01, const FVector& Corner10) const; }; diff --git a/Source/RWTHVRToolkit/Public/Interaction/Interactables/IntenSelect/IntenSelectableScoring.h b/Source/RWTHVRToolkit/Public/Interaction/Interactables/IntenSelect/IntenSelectableScoring.h index 529fcd36af3cf04393313110b79f5c0f05a7e6cd..542c8c97ca7dbf0583a558ac32cc6311d8b860b4 100644 --- a/Source/RWTHVRToolkit/Public/Interaction/Interactables/IntenSelect/IntenSelectableScoring.h +++ b/Source/RWTHVRToolkit/Public/Interaction/Interactables/IntenSelect/IntenSelectableScoring.h @@ -19,16 +19,21 @@ public: UPROPERTY(BlueprintReadOnly) float CurrentScore = 0; + UPROPERTY(EditAnywhere) bool IsSelectable = true; + UPROPERTY(EditAnywhere) float Stickiness = 10; + UPROPERTY(EditAnywhere) float Snappiness = 15; + UPROPERTY(EditAnywhere) float CompensationConstant = 0.8; bool bOverwritingContrib = false; + float Contrib = 0; virtual TPair<FHitResult, float> GetBestPointScorePair(const FVector& ConeOrigin, diff --git a/Source/RWTHVRToolkitEditor/Private/Interaction/IntenSelectableCircleScoringVisualizer.cpp b/Source/RWTHVRToolkitEditor/Private/Interaction/IntenSelectableCircleScoringVisualizer.cpp index b0dc19d143b2f2f2edc95dac79ee2c3f27690ff7..e2531b109775e8869db00c55899d9b8ae9e205f0 100644 --- a/Source/RWTHVRToolkitEditor/Private/Interaction/IntenSelectableCircleScoringVisualizer.cpp +++ b/Source/RWTHVRToolkitEditor/Private/Interaction/IntenSelectableCircleScoringVisualizer.cpp @@ -10,10 +10,12 @@ IMPLEMENT_HIT_PROXY(FCircleProxy, HComponentVisProxy); FIntenSelectableCircleScoringVisualizer::FIntenSelectableCircleScoringVisualizer() { PointsProperty = FindFProperty<FProperty>(UIntenSelectableCircleScoring::StaticClass(), - GET_MEMBER_NAME_CHECKED(UIntenSelectableCircleScoring, Radius)); + GET_MEMBER_NAME_CHECKED(UIntenSelectableCircleScoring, Radius)); } -FIntenSelectableCircleScoringVisualizer::~FIntenSelectableCircleScoringVisualizer() {} +FIntenSelectableCircleScoringVisualizer::~FIntenSelectableCircleScoringVisualizer() +{ +} FVector FIntenSelectableCircleScoringVisualizer::GetCurrentVectorWorld() const { @@ -22,16 +24,16 @@ FVector FIntenSelectableCircleScoringVisualizer::GetCurrentVectorWorld() const case 0: return GetEditedScoringComponent()->GetComponentLocation(); case 1: - { - const FVector CenterWorld = GetEditedScoringComponent()->GetComponentLocation(); - const FVector NormalWorldPoint = - GetEditedScoringComponent()->GetComponentTransform().TransformPosition(FVector::ForwardVector); - const FVector WorldNormalDir = NormalWorldPoint - CenterWorld; - const FVector Y = - WorldNormalDir.RotateAngleAxis(90, GetEditedScoringComponent()->GetRightVector()).GetSafeNormal() * - GetEditedScoringComponent()->Radius; - return CenterWorld + Y; - } + { + const FVector CenterWorld = GetEditedScoringComponent()->GetComponentLocation(); + const FVector NormalWorldPoint = + GetEditedScoringComponent()->GetComponentTransform().TransformPosition(FVector::ForwardVector); + const FVector WorldNormalDir = NormalWorldPoint - CenterWorld; + const FVector Y = + WorldNormalDir.RotateAngleAxis(90, GetEditedScoringComponent()->GetRightVector()).GetSafeNormal() * + GetEditedScoringComponent()->Radius; + return CenterWorld + Y; + } default: return FVector::ZeroVector; } @@ -56,13 +58,11 @@ bool FIntenSelectableCircleScoringVisualizer::ShouldShowForSelectedSubcomponents } bool FIntenSelectableCircleScoringVisualizer::VisProxyHandleClick(FEditorViewportClient* InViewportClient, - HComponentVisProxy* VisProxy, - const FViewportClick& Click) + HComponentVisProxy* VisProxy, + const FViewportClick& Click) { bool bEditing = false; - // UE_LOG(LogTemp, Warning, TEXT("Handling Click")); - if (VisProxy && VisProxy->Component.IsValid()) { bEditing = true; @@ -90,7 +90,7 @@ bool FIntenSelectableCircleScoringVisualizer::VisProxyHandleClick(FEditorViewpor } void FIntenSelectableCircleScoringVisualizer::DrawVisualization(const UActorComponent* Component, - const FSceneView* View, FPrimitiveDrawInterface* PDI) + const FSceneView* View, FPrimitiveDrawInterface* PDI) { const UIntenSelectableCircleScoring* ComponentCasted = Cast<UIntenSelectableCircleScoring>(Component); @@ -109,13 +109,15 @@ void FIntenSelectableCircleScoringVisualizer::DrawVisualization(const UActorComp const FVector Y = WorldNormalDir.RotateAngleAxis(90, ComponentCasted->GetRightVector()); const FVector Z = FVector::CrossProduct(Y.GetSafeNormal(), WorldNormalDir); DrawCircle(PDI, CenterWorld, Y.GetSafeNormal(), Z.GetSafeNormal(), FColor::Green, ComponentCasted->Radius, 100, - SDPG_Foreground, 2); + SDPG_Foreground, 2); PDI->SetHitProxy(nullptr); } } -void FIntenSelectableCircleScoringVisualizer::EndEditing() {} +void FIntenSelectableCircleScoringVisualizer::EndEditing() +{ +} UActorComponent* FIntenSelectableCircleScoringVisualizer::GetEditedComponent() const { @@ -123,15 +125,13 @@ UActorComponent* FIntenSelectableCircleScoringVisualizer::GetEditedComponent() c } bool FIntenSelectableCircleScoringVisualizer::HandleInputDelta(FEditorViewportClient* ViewportClient, - FViewport* Viewport, FVector& DeltaTranslate, - FRotator& DeltaRotate, FVector& DeltaScale) + FViewport* Viewport, FVector& DeltaTranslate, + FRotator& DeltaRotate, FVector& DeltaScale) { bool bHandled = false; if (CurrentSelectionIndex != INDEX_NONE) { - // UE_LOG(LogTemp, Warning, TEXT("Current Selection! %s"), *DeltaTranslate.ToString()); - if (CurrentSelectionIndex == 0) { const FVector LocalCenter = GetEditedScoringComponent()->GetComponentLocation(); @@ -162,16 +162,12 @@ bool FIntenSelectableCircleScoringVisualizer::HandleInputDelta(FEditorViewportCl Properties.Add(PointsProperty); NotifyPropertiesModified(GetEditedScoringComponent(), Properties, EPropertyChangeType::ValueSet); } - else - { - // UE_LOG(LogTemp, Warning, TEXT("No Current Selection!")); - } return bHandled; } bool FIntenSelectableCircleScoringVisualizer::GetWidgetLocation(const FEditorViewportClient* ViewportClient, - FVector& OutLocation) const + FVector& OutLocation) const { if (CurrentSelectionIndex != INDEX_NONE) {