diff --git a/Source/RWTHVRToolkit/Private/Interaction/Interactables/IntenSelect/IntenSelectable.cpp b/Source/RWTHVRToolkit/Private/Interaction/Interactables/IntenSelect/IntenSelectable.cpp index b7a39eff0a4abd00e9f8349dc7f60470a81a111f..3cd0e3d97f05cd11f45f107103511fa3ec28c48a 100644 --- a/Source/RWTHVRToolkit/Private/Interaction/Interactables/IntenSelect/IntenSelectable.cpp +++ b/Source/RWTHVRToolkit/Private/Interaction/Interactables/IntenSelect/IntenSelectable.cpp @@ -8,22 +8,21 @@ #include "Misc/MessageDialog.h" #include "Pawn/IntenSelectComponent.h" -UIntenSelectable::UIntenSelectable() -{ - PrimaryComponentTick.bCanEverTick = true; -} +UIntenSelectable::UIntenSelectable() { PrimaryComponentTick.bCanEverTick = true; } TPair<FHitResult, float> UIntenSelectable::GetBestPointScorePair(const FVector& ConeOrigin, - const FVector& ConeForwardDirection, const float ConeBackwardShiftDistance, const float ConeAngle, - const float LastValue, const float DeltaTime) const + const FVector& ConeForwardDirection, + const float ConeBackwardShiftDistance, + const float ConeAngle, const float LastValue, + const float DeltaTime) const { - checkf(ScoringBehaviour,TEXT("%s"),*GetOwner()->GetName()) - return ScoringBehaviour->GetBestPointScorePair(ConeOrigin, ConeForwardDirection, ConeBackwardShiftDistance, ConeAngle, LastValue, DeltaTime); + checkf(ScoringBehaviour, TEXT("%s"), *GetOwner()->GetName()) return ScoringBehaviour->GetBestPointScorePair( + ConeOrigin, ConeForwardDirection, ConeBackwardShiftDistance, ConeAngle, LastValue, DeltaTime); } void UIntenSelectable::HandleOnSelectStartEvents(const UIntenSelectComponent* IntenSelect, const FHitResult& HitResult) { - for(const UHoverBehaviour* b : OnSelectBehaviours) + for (const UHoverBehaviour* b : OnSelectBehaviours) { b->OnHoverStartEvent.Broadcast(IntenSelect, HitResult); } @@ -31,7 +30,7 @@ void UIntenSelectable::HandleOnSelectStartEvents(const UIntenSelectComponent* In void UIntenSelectable::HandleOnSelectEndEvents(const UIntenSelectComponent* IntenSelect) { - for(const UHoverBehaviour* b : OnSelectBehaviours) + for (const UHoverBehaviour* b : OnSelectBehaviours) { b->OnHoverEndEvent.Broadcast(IntenSelect); } @@ -39,7 +38,7 @@ void UIntenSelectable::HandleOnSelectEndEvents(const UIntenSelectComponent* Inte void UIntenSelectable::HandleOnClickStartEvents(UIntenSelectComponent* IntenSelect) { - for(const UActionBehaviour* b : OnClickBehaviours) + for (const UActionBehaviour* b : OnClickBehaviours) { FInputActionValue v{}; const UInputAction* a{}; @@ -49,7 +48,7 @@ void UIntenSelectable::HandleOnClickStartEvents(UIntenSelectComponent* IntenSele void UIntenSelectable::HandleOnClickEndEvents(UIntenSelectComponent* IntenSelect, FInputActionValue& InputValue) { - for(const UActionBehaviour* b : OnClickBehaviours) + for (const UActionBehaviour* b : OnClickBehaviours) { const UInputAction* a{}; b->OnActionEndEvent.Broadcast(IntenSelect, a, InputValue); @@ -58,24 +57,28 @@ void UIntenSelectable::HandleOnClickEndEvents(UIntenSelectComponent* IntenSelect void UIntenSelectable::InitDefaultBehaviourReferences() { - //Scoring - if(UIntenSelectableScoring* AttachedScoring = Cast<UIntenSelectableScoring>(GetOwner()->GetComponentByClass(UIntenSelectableScoring::StaticClass()))) + // Scoring + if (UIntenSelectableScoring* AttachedScoring = + Cast<UIntenSelectableScoring>(GetOwner()->GetComponentByClass(UIntenSelectableScoring::StaticClass()))) { ScoringBehaviour = AttachedScoring; - }else + } + else { - ScoringBehaviour = NewObject<UIntenSelectableSinglePointScoring>(this, UIntenSelectableSinglePointScoring::StaticClass(), "Default Scoring"); + ScoringBehaviour = NewObject<UIntenSelectableSinglePointScoring>( + this, UIntenSelectableSinglePointScoring::StaticClass(), "Default Scoring"); ScoringBehaviour->SetWorldLocation(GetOwner()->GetActorLocation()); - ScoringBehaviour->AttachToComponent(GetOwner()->GetRootComponent(), FAttachmentTransformRules::SnapToTargetNotIncludingScale); + ScoringBehaviour->AttachToComponent(GetOwner()->GetRootComponent(), + FAttachmentTransformRules::SnapToTargetNotIncludingScale); } - //Selecting + // Selecting TInlineComponentArray<UHoverBehaviour*> AttachedSelectionBehaviours; GetOwner()->GetComponents(AttachedSelectionBehaviours, true); this->OnSelectBehaviours = AttachedSelectionBehaviours; - //Clicking + // Clicking TInlineComponentArray<UActionBehaviour*> AttachedClickBehaviours; GetOwner()->GetComponents(AttachedClickBehaviours, true); @@ -97,15 +100,17 @@ void UIntenSelectable::BeginPlay() TInlineComponentArray<UIntenSelectable*> AttachedIntenSelectables; GetOwner()->GetComponents(AttachedIntenSelectables, false); - - if(AttachedIntenSelectables.Num() > 1) + + if (AttachedIntenSelectables.Num() > 1) { - if(!ScoringBehaviour) + if (!ScoringBehaviour) { - ShowErrorAndQuit("Please assign the Scoring Behaviour manually when using more than one IntenSelectable Component!"); + ShowErrorAndQuit( + "Please assign the Scoring Behaviour manually when using more than one IntenSelectable Component!"); } - }else + } + else { - InitDefaultBehaviourReferences(); - } + InitDefaultBehaviourReferences(); + } } diff --git a/Source/RWTHVRToolkit/Private/Interaction/Interactables/IntenSelect/IntenSelectableCircleScoring.cpp b/Source/RWTHVRToolkit/Private/Interaction/Interactables/IntenSelect/IntenSelectableCircleScoring.cpp index 56488bc8db3b921fe11ce4f4deed79609136e726..c323f50d1148d8ecb4fc45930a9ca0f00775c69f 100644 --- a/Source/RWTHVRToolkit/Private/Interaction/Interactables/IntenSelect/IntenSelectableCircleScoring.cpp +++ b/Source/RWTHVRToolkit/Private/Interaction/Interactables/IntenSelect/IntenSelectableCircleScoring.cpp @@ -6,17 +6,16 @@ #include "Kismet/KismetMathLibrary.h" // Sets default values for this component's properties -UIntenSelectableCircleScoring::UIntenSelectableCircleScoring() -{ - PrimaryComponentTick.bCanEverTick = true; -} +UIntenSelectableCircleScoring::UIntenSelectableCircleScoring() { PrimaryComponentTick.bCanEverTick = true; } -TPair<FHitResult, float> UIntenSelectableCircleScoring::GetBestPointScorePair(const FVector& ConeOrigin, - const FVector& ConeForwardDirection, const float ConeBackwardShiftDistance, const float ConeAngle, - const float LastValue, const float DeltaTime) +TPair<FHitResult, float> +UIntenSelectableCircleScoring::GetBestPointScorePair(const FVector& ConeOrigin, const FVector& ConeForwardDirection, + const float ConeBackwardShiftDistance, const float ConeAngle, + const float LastValue, const float DeltaTime) { const FVector Point = GetClosestSelectionPointTo(ConeOrigin, ConeForwardDirection); - float Score = GetScore(ConeOrigin, ConeForwardDirection, ConeBackwardShiftDistance, ConeAngle, Point, LastValue, DeltaTime); + float Score = + GetScore(ConeOrigin, ConeForwardDirection, ConeBackwardShiftDistance, ConeAngle, Point, LastValue, DeltaTime); FHitResult Result = FHitResult{GetOwner(), nullptr, Point, FVector::ForwardVector}; return TPair<FHitResult, float>{Result, Score}; } @@ -24,11 +23,13 @@ TPair<FHitResult, float> UIntenSelectableCircleScoring::GetBestPointScorePair(co FVector UIntenSelectableCircleScoring::GetClosestSelectionPointTo(const FVector& Point, const FVector& Direction) const { const FVector CenterWorld = this->GetComponentLocation(); - const FVector CircleNormalWorld = this->GetComponentTransform().TransformPositionNoScale(FVector::ForwardVector) - CenterWorld; - + 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)) + if (!UKismetMathLibrary::LinePlaneIntersection_OriginNormal(Point, Point + Direction * 100000, CenterWorld, + CircleNormalWorld, t, Intersect)) { return CenterWorld; } @@ -36,17 +37,19 @@ FVector UIntenSelectableCircleScoring::GetClosestSelectionPointTo(const FVector& const FVector CenterToPoint = Intersect - CenterWorld; FVector Result; - if(OnlyOutline) + if (OnlyOutline) { Result = (CenterToPoint.GetSafeNormal() * Radius) + CenterWorld; - }else + } + else { const float DistanceToCenter = CenterToPoint.Size(); - - if(DistanceToCenter >= Radius) + + if (DistanceToCenter >= Radius) { Result = (CenterToPoint.GetSafeNormal() * Radius) + CenterWorld; - }else + } + else { Result = Intersect; } @@ -55,9 +58,9 @@ FVector UIntenSelectableCircleScoring::GetClosestSelectionPointTo(const FVector& FVector Y = CenterToPoint.GetSafeNormal(); FVector Z = FVector::CrossProduct(Y, CircleNormalWorld.GetSafeNormal()); - //Y = FVector(0, 0, 1); - //Z = FVector(1, 0, 0); + // 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 804bdd7c8a46b8388eae1a8d13b8b9c55592631e..f7e8f98116514adc45b63c2b81fa7a66acb95905 100644 --- a/Source/RWTHVRToolkit/Private/Interaction/Interactables/IntenSelect/IntenSelectableCubeScoring.cpp +++ b/Source/RWTHVRToolkit/Private/Interaction/Interactables/IntenSelect/IntenSelectableCubeScoring.cpp @@ -13,17 +13,21 @@ UIntenSelectableCubeScoring::UIntenSelectableCubeScoring() SetRelativeScale3D(FVector::One() * 100); } -TPair<FHitResult, float> UIntenSelectableCubeScoring::GetBestPointScorePair(const FVector& ConeOrigin, - const FVector& ConeForwardDirection, const float ConeBackwardShiftDistance, const float ConeAngle, - const float LastValue, const float DeltaTime) +TPair<FHitResult, float> +UIntenSelectableCubeScoring::GetBestPointScorePair(const FVector& ConeOrigin, const FVector& ConeForwardDirection, + const float ConeBackwardShiftDistance, const float ConeAngle, + const float LastValue, const float DeltaTime) { FVector Point = GetClosestSelectionPointTo(ConeOrigin, ConeForwardDirection); - float Score = Super::GetScore(ConeOrigin, ConeForwardDirection, ConeBackwardShiftDistance, ConeAngle, Point, LastValue, DeltaTime); + float Score = Super::GetScore(ConeOrigin, ConeForwardDirection, ConeBackwardShiftDistance, ConeAngle, Point, + LastValue, DeltaTime); FHitResult Result = FHitResult{GetOwner(), nullptr, Point, FVector::ForwardVector}; return TPair<FHitResult, float>{Result, Score}; } -FVector UIntenSelectableCubeScoring::GetClosestPointToRectangle(const FVector& StartPoint, const FVector& Direction, const FVector& Corner00, const FVector& Corner01, const FVector& Corner10, const FVector& Corner11) const +FVector UIntenSelectableCubeScoring::GetClosestPointToRectangle(const FVector& StartPoint, const FVector& Direction, + const FVector& Corner00, const FVector& Corner01, + const FVector& Corner10, const FVector& Corner11) const { const float X = FVector::Distance(Corner00, Corner10); const float Y = FVector::Distance(Corner00, Corner01); @@ -31,22 +35,25 @@ FVector UIntenSelectableCubeScoring::GetClosestPointToRectangle(const FVector& S FVector Intersection; float T; - UKismetMathLibrary::LinePlaneIntersection_OriginNormal(StartPoint, StartPoint + Direction * 10000, Corner00, PlaneNormal, T, Intersection); + UKismetMathLibrary::LinePlaneIntersection_OriginNormal(StartPoint, StartPoint + Direction * 10000, Corner00, + PlaneNormal, T, Intersection); FVector LocalIntersection = this->GetComponentTransform().InverseTransformPosition(Intersection); - if(LocalIntersection.Y > X / 2) + if (LocalIntersection.Y > X / 2) { LocalIntersection.Y = X / 2; - }else if(LocalIntersection.Y < -X / 2) + } + else if (LocalIntersection.Y < -X / 2) { LocalIntersection.Y = -X / 2; } - - if(LocalIntersection.Z > Y / 2) + + if (LocalIntersection.Z > Y / 2) { LocalIntersection.Z = Y / 2; - }else if(LocalIntersection.Z < -Y / 2) + } + else if (LocalIntersection.Z < -Y / 2) { LocalIntersection.Z = -Y / 2; } @@ -56,7 +63,7 @@ FVector UIntenSelectableCubeScoring::GetClosestPointToRectangle(const FVector& S { const float DistToBottom = LocalIntersection.Z + (YLength / 2); const float DistToLeft = LocalIntersection.Y + (XLength / 2); - + if(LocalIntersection.Z < 0) { if(LocalIntersection.Y < 0) @@ -114,11 +121,12 @@ FVector UIntenSelectableCubeScoring::GetClosestPointToRectangle(const FVector& S } } */ - + return this->GetComponentTransform().TransformPosition(LocalIntersection); } -bool UIntenSelectableCubeScoring::LineToLineIntersection(const FVector& FromA, const FVector& FromB, const FVector& ToA, const FVector& ToB, FVector& OutIntersection) +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; @@ -128,11 +136,12 @@ bool UIntenSelectableCubeScoring::LineToLineIntersection(const FVector& FromA, c const float Prod = CrossDaDb.X * CrossDaDb.X + CrossDaDb.Y * CrossDaDb.Y + CrossDaDb.Z * CrossDaDb.Z; const float Res = FVector::DotProduct(FVector::CrossProduct(DC, DB), FVector::CrossProduct(Da, DB) / Prod); - if (Res >= -0.02f && Res <= 1.02f) { + if (Res >= -0.02f && Res <= 1.02f) + { OutIntersection = FromA + Da * FVector(Res, Res, Res); return true; } - + return false; } @@ -144,28 +153,28 @@ FVector UIntenSelectableCubeScoring::GetClosestSelectionPointTo(const FVector& R const FVector Z = this->GetUpVector() * Scale.Z; TArray<FPlane> CubeSides; - - //bottom - const FVector BottomWorld = this->GetComponentTransform().TransformPositionNoScale(- Z / 2); + + // bottom + const FVector BottomWorld = this->GetComponentTransform().TransformPositionNoScale(-Z / 2); CubeSides.Add(FPlane{BottomWorld, -this->GetUpVector()}); - //top + // top const FVector TopWorld = this->GetComponentTransform().TransformPositionNoScale(Z / 2); CubeSides.Add(FPlane{TopWorld, this->GetUpVector()}); - - //left - const FVector LeftWorld = this->GetComponentTransform().TransformPositionNoScale(- Y / 2); + + // left + const FVector LeftWorld = this->GetComponentTransform().TransformPositionNoScale(-Y / 2); CubeSides.Add(FPlane{LeftWorld, -this->GetRightVector()}); - //right + // right const FVector RightWorld = this->GetComponentTransform().TransformPositionNoScale(Y / 2); CubeSides.Add(FPlane{RightWorld, this->GetRightVector()}); - //front + // front const FVector FrontWorld = this->GetComponentTransform().TransformPositionNoScale(-X / 2); CubeSides.Add(FPlane{FrontWorld, -this->GetForwardVector()}); - //back + // back const FVector BackWorld = this->GetComponentTransform().TransformPositionNoScale(X / 2); CubeSides.Add(FPlane{BackWorld, this->GetForwardVector()}); @@ -175,32 +184,34 @@ FVector UIntenSelectableCubeScoring::GetClosestSelectionPointTo(const FVector& R float OutT; if(TIntrRay3AxisAlignedBox3<float>::FindIntersection(Ray, Box, OutT)) { - + }*/ - + float MinDistance = TNumericLimits<float>::Max(); FVector ClosestPoint = GetComponentLocation(); bool IsSet = false; - for(FPlane Plane : CubeSides) + for (FPlane Plane : CubeSides) { const FVector PlaneToRayOrigin = RayOrigin - Plane.GetOrigin(); - if(FVector::DotProduct(PlaneToRayOrigin.GetSafeNormal(), Plane.GetNormal()) < 0 && BackFaceCulling) + if (FVector::DotProduct(PlaneToRayOrigin.GetSafeNormal(), Plane.GetNormal()) < 0 && BackFaceCulling) { - if(DrawDebug) + if (DrawDebug) { - DrawDebugSolidPlane(GetWorld(), Plane, GetComponentLocation(), 20, FColor::Red.WithAlpha(9), false, -1, 0); + DrawDebugSolidPlane(GetWorld(), Plane, GetComponentLocation(), 20, FColor::Red.WithAlpha(9), false, -1, + 0); } continue; - }else + } + else { - if(DrawDebug) + if (DrawDebug) { - DrawDebugSolidPlane(GetWorld(), Plane, GetComponentLocation(), 20, FColor::Green.WithAlpha(9), false, -1, 0); + DrawDebugSolidPlane(GetWorld(), Plane, GetComponentLocation(), 20, FColor::Green.WithAlpha(9), false, + -1, 0); } } - - - + + FVector CurrentPoint = FMath::RayPlaneIntersection(RayOrigin, RayDirection, Plane); FVector CurrentPointLocal = GetComponentTransform().InverseTransformPositionNoScale(CurrentPoint); @@ -209,74 +220,80 @@ FVector UIntenSelectableCubeScoring::GetClosestSelectionPointTo(const FVector& R CurrentPointLocal.Y = FMath::Clamp(CurrentPointLocal.Y, -Scale.Y / 2, Scale.Y / 2); CurrentPointLocal.Z = FMath::Clamp(CurrentPointLocal.Z, -Scale.Z / 2, Scale.Z / 2); - if(OnlyOutline) + if (OnlyOutline) { - const float XSnapDist = (Scale.X/2) - FMath::Abs(CurrentPointLocal.X); - const float YSnapDist = (Scale.Y/2) - FMath::Abs(CurrentPointLocal.Y); - const float ZSnapDist = (Scale.Z/2) - FMath::Abs(CurrentPointLocal.Z); + const float XSnapDist = (Scale.X / 2) - FMath::Abs(CurrentPointLocal.X); + const float YSnapDist = (Scale.Y / 2) - FMath::Abs(CurrentPointLocal.Y); + const float ZSnapDist = (Scale.Z / 2) - FMath::Abs(CurrentPointLocal.Z); bool SnapX = true; bool SnapY = true; bool SnapZ = true; - - if(FVector::Parallel(Plane.GetNormal(), GetRightVector())) + + if (FVector::Parallel(Plane.GetNormal(), GetRightVector())) { - if(XSnapDist < ZSnapDist) + if (XSnapDist < ZSnapDist) { SnapZ = false; - }else + } + else { SnapX = false; } - - }else if(FVector::Parallel(Plane.GetNormal(), GetUpVector())) + } + else if (FVector::Parallel(Plane.GetNormal(), GetUpVector())) { - if(XSnapDist < YSnapDist) + if (XSnapDist < YSnapDist) { SnapY = false; - }else + } + else { SnapX = false; } - }else if(FVector::Parallel(Plane.GetNormal(), GetForwardVector())) + } + else if (FVector::Parallel(Plane.GetNormal(), GetForwardVector())) { - if(YSnapDist < ZSnapDist) + if (YSnapDist < ZSnapDist) { SnapZ = false; - }else + } + else { SnapY = false; } } - - if(SnapX) + if (SnapX) { - if(CurrentPointLocal.X > 0) + if (CurrentPointLocal.X > 0) { CurrentPointLocal.X = Scale.X / 2; - }else + } + else { CurrentPointLocal.X = -Scale.X / 2; } } - if(SnapY) + if (SnapY) { - if(CurrentPointLocal.Y > 0) + if (CurrentPointLocal.Y > 0) { CurrentPointLocal.Y = Scale.Y / 2; - }else + } + else { CurrentPointLocal.Y = -Scale.Y / 2; } } - if(SnapZ) + if (SnapZ) { - if(CurrentPointLocal.Z > 0) + if (CurrentPointLocal.Z > 0) { CurrentPointLocal.Z = Scale.Z / 2; - }else + } + else { CurrentPointLocal.Z = -Scale.Z / 2; } @@ -287,45 +304,50 @@ 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) + // 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) + if (MinDistance < 0.001) { - const float DistToPlayerOld = IsSet ? FVector::Distance(RayOrigin, ClosestPoint) : TNumericLimits<float>::Max(); + const float DistToPlayerOld = + IsSet ? FVector::Distance(RayOrigin, ClosestPoint) : TNumericLimits<float>::Max(); const float DistToPlayerNew = FVector::Distance(RayOrigin, CurrentPoint); - - if(DistToPlayerNew < DistToPlayerOld) + + if (DistToPlayerNew < DistToPlayerOld) { MinDistance = Distance; ClosestPoint = CurrentPoint; IsSet = true; } - }else + } + else { MinDistance = Distance; ClosestPoint = CurrentPoint; IsSet = true; - } - }else + } + } + else { - if(Distance < MinDistance) + if (Distance < MinDistance) { MinDistance = Distance; ClosestPoint = CurrentPoint; IsSet = true; } - } + } } - if(DrawDebug) DrawDebugBox(GetWorld(), GetComponentLocation(), FVector(Scale.X, Scale.Y, Scale.Z) /2, GetComponentRotation().Quaternion(), FColor::Green, false, -1, 0, 2); + if (DrawDebug) + DrawDebugBox(GetWorld(), GetComponentLocation(), FVector(Scale.X, Scale.Y, Scale.Z) / 2, + GetComponentRotation().Quaternion(), FColor::Green, false, -1, 0, 2); return ClosestPoint; } void UIntenSelectableCubeScoring::TickComponent(float DeltaTime, ELevelTick TickType, - FActorComponentTickFunction* ThisTickFunction) + FActorComponentTickFunction* ThisTickFunction) { Super::TickComponent(DeltaTime, TickType, ThisTickFunction); } diff --git a/Source/RWTHVRToolkit/Private/Interaction/Interactables/IntenSelect/IntenSelectableCylinderScoring.cpp b/Source/RWTHVRToolkit/Private/Interaction/Interactables/IntenSelect/IntenSelectableCylinderScoring.cpp index 5a72732ac3fa9352282cba19ff0101414197e440..b4b08696f52712b1ed9dbcc688fda9787c75152c 100644 --- a/Source/RWTHVRToolkit/Private/Interaction/Interactables/IntenSelect/IntenSelectableCylinderScoring.cpp +++ b/Source/RWTHVRToolkit/Private/Interaction/Interactables/IntenSelect/IntenSelectableCylinderScoring.cpp @@ -7,22 +7,23 @@ #include "Kismet/KismetMathLibrary.h" // Sets default values for this component's properties -UIntenSelectableCylinderScoring::UIntenSelectableCylinderScoring() -{ - PrimaryComponentTick.bCanEverTick = true; -} +UIntenSelectableCylinderScoring::UIntenSelectableCylinderScoring() { PrimaryComponentTick.bCanEverTick = true; } -TPair<FHitResult, float> UIntenSelectableCylinderScoring::GetBestPointScorePair(const FVector& ConeOrigin, - const FVector& ConeForwardDirection, const float ConeBackwardShiftDistance, const float ConeAngle, - const float LastValue, const float DeltaTime) +TPair<FHitResult, float> +UIntenSelectableCylinderScoring::GetBestPointScorePair(const FVector& ConeOrigin, const FVector& ConeForwardDirection, + const float ConeBackwardShiftDistance, const float ConeAngle, + const float LastValue, const float DeltaTime) { FVector Point = GetClosestSelectionPointTo(ConeOrigin, ConeForwardDirection); - float Score = GetScore(ConeOrigin, ConeForwardDirection, ConeBackwardShiftDistance, ConeAngle, Point, LastValue, DeltaTime); + float Score = + GetScore(ConeOrigin, ConeForwardDirection, ConeBackwardShiftDistance, ConeAngle, Point, LastValue, DeltaTime); FHitResult Result = FHitResult{GetOwner(), nullptr, Point, FVector::ForwardVector}; return TPair<FHitResult, float>{Result, Score}; } -bool UIntenSelectableCylinderScoring::LineToLineIntersection(const FVector& FromA, const FVector& FromB, const FVector& ToA, const FVector& ToB, FVector& OutIntersection) +bool UIntenSelectableCylinderScoring::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; @@ -32,24 +33,26 @@ bool UIntenSelectableCylinderScoring::LineToLineIntersection(const FVector& From const float Prod = CrossDaDb.X * CrossDaDb.X + CrossDaDb.Y * CrossDaDb.Y + CrossDaDb.Z * CrossDaDb.Z; const float Res = FVector::DotProduct(FVector::CrossProduct(DC, DB), FVector::CrossProduct(Da, DB) / Prod); - if (Res >= -0.02f && Res <= 1.02f) { + if (Res >= -0.02f && Res <= 1.02f) + { OutIntersection = FromA + Da * FVector(Res, Res, Res); return true; } - + return false; } -FVector UIntenSelectableCylinderScoring::GetClosestSelectionPointTo(const FVector& Point, const FVector& Direction) const +FVector UIntenSelectableCylinderScoring::GetClosestSelectionPointTo(const FVector& Point, + const FVector& Direction) const { const FVector CylinderStartWorld = this->GetComponentTransform().TransformPosition(LinePoints[0]); const FVector CylinderEndWorld = this->GetComponentTransform().TransformPosition(LinePoints[1]); - const FVector CylinderDir = CylinderEndWorld-CylinderStartWorld; - - const FVector CrossProd = UKismetMathLibrary::Cross_VectorVector(CylinderDir, Direction); //v - const FVector LineDifference = CylinderStartWorld - Point; //u + const FVector CylinderDir = CylinderEndWorld - CylinderStartWorld; - //Project v onto u => + const FVector CrossProd = UKismetMathLibrary::Cross_VectorVector(CylinderDir, Direction); // v + const FVector LineDifference = CylinderStartWorld - Point; // u + + // Project v onto u => const FVector Proj = LineDifference.ProjectOnTo(CrossProd); const float ProjLength = Proj.Size(); @@ -64,26 +67,27 @@ FVector UIntenSelectableCylinderScoring::GetClosestSelectionPointTo(const FVecto const FVector LineDirRes = Result - CylinderStartWorld; - if(LineDirRes.Size() > CylinderDir.Size()) + if (LineDirRes.Size() > CylinderDir.Size()) { Result = CylinderEndWorld; } - if(!LineDirRes.GetSafeNormal().Equals(CylinderDir.GetSafeNormal())) + if (!LineDirRes.GetSafeNormal().Equals(CylinderDir.GetSafeNormal())) { Result = CylinderStartWorld; } - + const FVector ToSphere = Result - Point; const FVector Projection = ToSphere.ProjectOnTo(Direction); const FVector ProjectionToSphere = ToSphere - Projection; - if(ProjLength >= Radius) + if (ProjLength >= Radius) { FVector ShiftResult = ProjectionToSphere.GetSafeNormal() * Radius; ShiftResult -= ShiftResult.ProjectOnTo(CylinderDir); return Result - ShiftResult; - }else + } + else { FVector ShiftResult = ProjectionToSphere.GetSafeNormal() * ProjLength; ShiftResult -= ShiftResult.ProjectOnTo(CylinderDir); @@ -92,15 +96,15 @@ FVector UIntenSelectableCylinderScoring::GetClosestSelectionPointTo(const FVecto } void UIntenSelectableCylinderScoring::TickComponent(float DeltaTime, ELevelTick TickType, - FActorComponentTickFunction* ThisTickFunction) + FActorComponentTickFunction* ThisTickFunction) { Super::TickComponent(DeltaTime, TickType, ThisTickFunction); - if(DrawDebug) + if (DrawDebug) { const FVector StartWorld = this->GetComponentTransform().TransformPosition(LinePoints[0]); const FVector EndWorld = this->GetComponentTransform().TransformPosition(LinePoints[1]); - DrawDebugCylinder(GetWorld(), StartWorld, EndWorld, Radius, 20,FColor::Green, false, 0, 0, 2); + DrawDebugCylinder(GetWorld(), StartWorld, EndWorld, Radius, 20, FColor::Green, false, 0, 0, 2); } } diff --git a/Source/RWTHVRToolkit/Private/Interaction/Interactables/IntenSelect/IntenSelectableLineScoring.cpp b/Source/RWTHVRToolkit/Private/Interaction/Interactables/IntenSelect/IntenSelectableLineScoring.cpp index 7af4d28ffb45dea32620ad9bdab03681f15577eb..be4cdd9065f3b92f6d640fc78d3c65afa144bcc7 100644 --- a/Source/RWTHVRToolkit/Private/Interaction/Interactables/IntenSelect/IntenSelectableLineScoring.cpp +++ b/Source/RWTHVRToolkit/Private/Interaction/Interactables/IntenSelect/IntenSelectableLineScoring.cpp @@ -9,7 +9,7 @@ UIntenSelectableLineScoring::UIntenSelectableLineScoring() { PrimaryComponentTick.bCanEverTick = true; - if(this->LinePoints.Num() == 2) + if (this->LinePoints.Num() == 2) { const FVector Average = (this->LinePoints[0] + this->LinePoints[1]) / 2; @@ -19,17 +19,20 @@ UIntenSelectableLineScoring::UIntenSelectableLineScoring() } } -TPair<FHitResult, float> UIntenSelectableLineScoring::GetBestPointScorePair(const FVector& ConeOrigin, - const FVector& ConeForwardDirection, const float ConeBackwardShiftDistance, const float ConeAngle, - const float LastValue, const float DeltaTime) +TPair<FHitResult, float> +UIntenSelectableLineScoring::GetBestPointScorePair(const FVector& ConeOrigin, const FVector& ConeForwardDirection, + const float ConeBackwardShiftDistance, const float ConeAngle, + const float LastValue, const float DeltaTime) { FVector Point = GetClosestSelectionPointTo(ConeOrigin, ConeForwardDirection); - float Score = GetScore(ConeOrigin, ConeForwardDirection, ConeBackwardShiftDistance, ConeAngle, Point, LastValue, DeltaTime); + float Score = + GetScore(ConeOrigin, ConeForwardDirection, ConeBackwardShiftDistance, ConeAngle, Point, LastValue, DeltaTime); FHitResult Result = FHitResult{GetOwner(), nullptr, Point, FVector::ForwardVector}; return TPair<FHitResult, float>{Result, Score}; } -bool UIntenSelectableLineScoring::LineToLineIntersection(const FVector& FromA, const FVector& FromB, const FVector& ToA, const FVector& ToB, FVector& OutIntersection) +bool UIntenSelectableLineScoring::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; @@ -39,11 +42,12 @@ bool UIntenSelectableLineScoring::LineToLineIntersection(const FVector& FromA, c const float Prod = CrossDaDb.X * CrossDaDb.X + CrossDaDb.Y * CrossDaDb.Y + CrossDaDb.Z * CrossDaDb.Z; const float Res = FVector::DotProduct(FVector::CrossProduct(DC, DB), FVector::CrossProduct(Da, DB) / Prod); - if (Res >= -0.02f && Res <= 1.02f) { + if (Res >= -0.02f && Res <= 1.02f) + { OutIntersection = FromA + Da * FVector(Res, Res, Res); return true; } - + return false; } @@ -51,13 +55,13 @@ FVector UIntenSelectableLineScoring::GetClosestSelectionPointTo(const FVector& P { const FVector StartWorld = this->GetComponentTransform().TransformPosition(LinePoints[0]); const FVector EndWorld = this->GetComponentTransform().TransformPosition(LinePoints[1]); - const FVector LineDir = EndWorld-StartWorld; + const FVector LineDir = EndWorld - StartWorld; - const FVector CrossProd = UKismetMathLibrary::Cross_VectorVector(LineDir, Direction); //v - const FVector LineDifference = StartWorld - Point; //u + const FVector CrossProd = UKismetMathLibrary::Cross_VectorVector(LineDir, Direction); // v + const FVector LineDifference = StartWorld - Point; // u - //Project v onto u => + // Project v onto u => const FVector Proj = LineDifference.ProjectOnTo(CrossProd); const FVector OffsetPoint = Point + Proj; @@ -70,12 +74,12 @@ FVector UIntenSelectableLineScoring::GetClosestSelectionPointTo(const FVector& P LineToLineIntersection(FromA, FromB, ToA, ToB, Result); const FVector LineDirRes = Result - StartWorld; - if(LineDirRes.Size() > LineDir.Size()) + if (LineDirRes.Size() > LineDir.Size()) { Result = EndWorld; } - if(!LineDirRes.GetSafeNormal().Equals(LineDir.GetSafeNormal())) + if (!LineDirRes.GetSafeNormal().Equals(LineDir.GetSafeNormal())) { Result = StartWorld; } @@ -84,11 +88,11 @@ FVector UIntenSelectableLineScoring::GetClosestSelectionPointTo(const FVector& P } void UIntenSelectableLineScoring::TickComponent(float DeltaTime, ELevelTick TickType, - FActorComponentTickFunction* ThisTickFunction) + FActorComponentTickFunction* ThisTickFunction) { Super::TickComponent(DeltaTime, TickType, ThisTickFunction); - if(DrawDebug) + if (DrawDebug) { const FVector StartWorld = this->GetComponentTransform().TransformPosition(LinePoints[0]); const FVector EndWorld = this->GetComponentTransform().TransformPosition(LinePoints[1]); diff --git a/Source/RWTHVRToolkit/Private/Interaction/Interactables/IntenSelect/IntenSelectableMultiPointScoring.cpp b/Source/RWTHVRToolkit/Private/Interaction/Interactables/IntenSelect/IntenSelectableMultiPointScoring.cpp index 024d0dfcb4a1fd0abbebe1ec7762d1f2af6a8043..03b04e32b549450947e0d663c4a5757e1ced9b76 100644 --- a/Source/RWTHVRToolkit/Private/Interaction/Interactables/IntenSelect/IntenSelectableMultiPointScoring.cpp +++ b/Source/RWTHVRToolkit/Private/Interaction/Interactables/IntenSelect/IntenSelectableMultiPointScoring.cpp @@ -9,39 +9,40 @@ UIntenSelectableMultiPointScoring::UIntenSelectableMultiPointScoring() { PrimaryComponentTick.bCanEverTick = true; - PointsToSelect = TArray<FVector>{FVector::UpVector * 100, FVector::DownVector * 100, FVector::RightVector * 100, FVector::LeftVector * 100}; + PointsToSelect = TArray<FVector>{FVector::UpVector * 100, FVector::DownVector * 100, FVector::RightVector * 100, + FVector::LeftVector * 100}; } -TPair<FHitResult, float> UIntenSelectableMultiPointScoring::GetBestPointScorePair(const FVector& ConeOrigin, - const FVector& ConeForwardDirection, const float ConeBackwardShiftDistance, const float ConeAngle, - const float LastValue, const float DeltaTime) +TPair<FHitResult, float> +UIntenSelectableMultiPointScoring::GetBestPointScorePair(const FVector& ConeOrigin, const FVector& ConeForwardDirection, + const float ConeBackwardShiftDistance, const float ConeAngle, + const float LastValue, const float DeltaTime) { FVector Point = GetClosestSelectionPointTo(ConeOrigin, ConeForwardDirection); - float Score = Super::GetScore(ConeOrigin, ConeForwardDirection, ConeBackwardShiftDistance, ConeAngle, Point, LastValue, DeltaTime); + float Score = Super::GetScore(ConeOrigin, ConeForwardDirection, ConeBackwardShiftDistance, ConeAngle, Point, + LastValue, DeltaTime); FHitResult Result = FHitResult{GetOwner(), nullptr, Point, FVector::ForwardVector}; return TPair<FHitResult, float>{Result, Score}; } -void UIntenSelectableMultiPointScoring::UpdatePoints() -{ - -} +void UIntenSelectableMultiPointScoring::UpdatePoints() {} -FVector UIntenSelectableMultiPointScoring::GetClosestSelectionPointTo(const FVector& Point, const FVector& Direction) const +FVector UIntenSelectableMultiPointScoring::GetClosestSelectionPointTo(const FVector& Point, + const FVector& Direction) const { - if(PointsToSelect.Num() == 0) + if (PointsToSelect.Num() == 0) { return this->GetComponentLocation(); } FVector ClosestPoint = this->GetComponentTransform().TransformPositionNoScale(PointsToSelect[0]); float MinDistance = UKismetMathLibrary::GetPointDistanceToLine(ClosestPoint, Point, Direction); - - for(const FVector P : PointsToSelect) + + for (const FVector P : PointsToSelect) { const FVector PointToCheck = this->GetComponentTransform().TransformPositionNoScale(P); const float Dist = UKismetMathLibrary::GetPointDistanceToLine(PointToCheck, Point, Direction); - if(Dist < MinDistance) + if (Dist < MinDistance) { MinDistance = Dist; ClosestPoint = PointToCheck; diff --git a/Source/RWTHVRToolkit/Private/Interaction/Interactables/IntenSelect/IntenSelectableRectangleScoring.cpp b/Source/RWTHVRToolkit/Private/Interaction/Interactables/IntenSelect/IntenSelectableRectangleScoring.cpp index 798c7f8eacaded46b54e9ca788792c329b6259a4..62737f8d1b07af27317ade5a57fd58a25eb0d92b 100644 --- a/Source/RWTHVRToolkit/Private/Interaction/Interactables/IntenSelect/IntenSelectableRectangleScoring.cpp +++ b/Source/RWTHVRToolkit/Private/Interaction/Interactables/IntenSelect/IntenSelectableRectangleScoring.cpp @@ -6,22 +6,23 @@ #include "Kismet/KismetMathLibrary.h" // Sets default values for this component's properties -UIntenSelectableRectangleScoring::UIntenSelectableRectangleScoring() -{ - PrimaryComponentTick.bCanEverTick = true; -} +UIntenSelectableRectangleScoring::UIntenSelectableRectangleScoring() { PrimaryComponentTick.bCanEverTick = true; } -TPair<FHitResult, float> UIntenSelectableRectangleScoring::GetBestPointScorePair(const FVector& ConeOrigin, - const FVector& ConeForwardDirection, const float ConeBackwardShiftDistance, const float ConeAngle, - const float LastValue, const float DeltaTime) +TPair<FHitResult, float> +UIntenSelectableRectangleScoring::GetBestPointScorePair(const FVector& ConeOrigin, const FVector& ConeForwardDirection, + const float ConeBackwardShiftDistance, const float ConeAngle, + const float LastValue, const float DeltaTime) { FVector Point = GetClosestSelectionPointTo(ConeOrigin, ConeForwardDirection); - float Score = Super::GetScore(ConeOrigin, ConeForwardDirection, ConeBackwardShiftDistance, ConeAngle, Point, LastValue, DeltaTime); + float Score = Super::GetScore(ConeOrigin, ConeForwardDirection, ConeBackwardShiftDistance, ConeAngle, Point, + LastValue, DeltaTime); FHitResult Result = FHitResult{GetOwner(), nullptr, Point, FVector::ForwardVector}; return TPair<FHitResult, float>{Result, Score}; } -bool UIntenSelectableRectangleScoring::LineToLineIntersection(const FVector& FromA, const FVector& FromB, const FVector& ToA, const FVector& ToB, FVector& OutIntersection) +bool UIntenSelectableRectangleScoring::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; @@ -31,104 +32,118 @@ bool UIntenSelectableRectangleScoring::LineToLineIntersection(const FVector& Fro const float Prod = CrossDaDb.X * CrossDaDb.X + CrossDaDb.Y * CrossDaDb.Y + CrossDaDb.Z * CrossDaDb.Z; const float Res = FVector::DotProduct(FVector::CrossProduct(DC, DB), FVector::CrossProduct(Da, DB) / Prod); - if (Res >= -0.02f && Res <= 1.02f) { + if (Res >= -0.02f && Res <= 1.02f) + { OutIntersection = FromA + Da * FVector(Res, Res, Res); return true; } - + return false; } -FVector UIntenSelectableRectangleScoring::GetClosestSelectionPointTo(const FVector& Point, const FVector& Direction) const +FVector UIntenSelectableRectangleScoring::GetClosestSelectionPointTo(const FVector& Point, + const FVector& Direction) const { const FVector X = this->GetRightVector() * XLength; const FVector Y = this->GetUpVector() * YLength; - const FVector CornerWorld00 = this->GetComponentTransform().TransformPosition(FVector::ZeroVector) - (X / 2) - (Y / 2); + const FVector CornerWorld00 = + this->GetComponentTransform().TransformPosition(FVector::ZeroVector) - (X / 2) - (Y / 2); const FVector CornerWorld10 = CornerWorld00 + X; const FVector CornerWorld01 = CornerWorld00 + Y; const FVector CornerWorld11 = CornerWorld00 + X + Y; - const FVector PlaneNormal = FVector::CrossProduct(CornerWorld10 - CornerWorld00, CornerWorld01 - CornerWorld00).GetSafeNormal(); + const FVector PlaneNormal = + FVector::CrossProduct(CornerWorld10 - CornerWorld00, CornerWorld01 - CornerWorld00).GetSafeNormal(); FVector Intersection; float T; - UKismetMathLibrary::LinePlaneIntersection_OriginNormal(Point, Point + Direction * 10000, CornerWorld00, PlaneNormal, T, Intersection); + UKismetMathLibrary::LinePlaneIntersection_OriginNormal(Point, Point + Direction * 10000, CornerWorld00, PlaneNormal, + T, Intersection); FVector LocalIntersection = this->GetComponentTransform().InverseTransformPosition(Intersection); - if(LocalIntersection.Y > XLength / 2) + if (LocalIntersection.Y > XLength / 2) { LocalIntersection.Y = XLength / 2; - }else if(LocalIntersection.Y < -XLength / 2) + } + else if (LocalIntersection.Y < -XLength / 2) { LocalIntersection.Y = -XLength / 2; } - - if(LocalIntersection.Z > YLength / 2) + + if (LocalIntersection.Z > YLength / 2) { LocalIntersection.Z = YLength / 2; - }else if(LocalIntersection.Z < -YLength / 2) + } + else if (LocalIntersection.Z < -YLength / 2) { LocalIntersection.Z = -YLength / 2; } - if(OnlyOutline) + if (OnlyOutline) { const float DistToBottom = LocalIntersection.Z + (YLength / 2); const float DistToLeft = LocalIntersection.Y + (XLength / 2); - - if(LocalIntersection.Z < 0) + + if (LocalIntersection.Z < 0) { - if(LocalIntersection.Y < 0) + if (LocalIntersection.Y < 0) { - //Bottom and left - if(DistToLeft < DistToBottom) + // Bottom and left + if (DistToLeft < DistToBottom) { - //snap left + // snap left LocalIntersection.Y = -(XLength / 2); - }else + } + else { - //snap bottom + // snap bottom LocalIntersection.Z = -(YLength / 2); } - }else + } + else { - //bottom and right - if(XLength - DistToLeft < DistToBottom) + // bottom and right + if (XLength - DistToLeft < DistToBottom) { - //snap right + // snap right LocalIntersection.Y = XLength / 2; - }else + } + else { - //snap bottom + // snap bottom LocalIntersection.Z = -(YLength / 2); } } - }else + } + else { - if(LocalIntersection.Y < 0) + if (LocalIntersection.Y < 0) { - //top and left - if(DistToLeft < YLength - DistToBottom) + // top and left + if (DistToLeft < YLength - DistToBottom) { - //snap left + // snap left LocalIntersection.Y = -(XLength / 2); - }else + } + else { - //snap top + // snap top LocalIntersection.Z = (YLength / 2); } - }else + } + else { - //top and right - if(XLength - DistToLeft < YLength - DistToBottom) + // top and right + if (XLength - DistToLeft < YLength - DistToBottom) { - //snap right + // snap right LocalIntersection.Y = XLength / 2; - }else + } + else { - //snap top + // snap top LocalIntersection.Z = (YLength / 2); } } @@ -139,20 +154,21 @@ FVector UIntenSelectableRectangleScoring::GetClosestSelectionPointTo(const FVect } void UIntenSelectableRectangleScoring::TickComponent(float DeltaTime, ELevelTick TickType, - FActorComponentTickFunction* ThisTickFunction) + FActorComponentTickFunction* ThisTickFunction) { Super::TickComponent(DeltaTime, TickType, ThisTickFunction); - if(DrawDebug) + if (DrawDebug) { const FVector X = this->GetRightVector() * XLength; const FVector Y = this->GetUpVector() * YLength; - const FVector CornerWorld00 = this->GetComponentTransform().TransformPosition(FVector::ZeroVector) - (X / 2) - (Y / 2); + const FVector CornerWorld00 = + this->GetComponentTransform().TransformPosition(FVector::ZeroVector) - (X / 2) - (Y / 2); const FVector CornerWorld10 = CornerWorld00 + X; const FVector CornerWorld01 = CornerWorld00 + Y; const FVector CornerWorld11 = CornerWorld00 + X + Y; - + DrawDebugLine(GetWorld(), CornerWorld00, CornerWorld01, FColor::Green, false, -1, 0, 2); DrawDebugLine(GetWorld(), CornerWorld00, CornerWorld10, FColor::Green, false, -1, 0, 2); DrawDebugLine(GetWorld(), CornerWorld01, CornerWorld11, FColor::Green, false, -1, 0, 2); diff --git a/Source/RWTHVRToolkit/Private/Interaction/Interactables/IntenSelect/IntenSelectableScoring.cpp b/Source/RWTHVRToolkit/Private/Interaction/Interactables/IntenSelect/IntenSelectableScoring.cpp index f269c863e4b832687579c32a1f15355e02b4accf..82455f7885caea8606e98deb229f0aa51a73cf14 100644 --- a/Source/RWTHVRToolkit/Private/Interaction/Interactables/IntenSelect/IntenSelectableScoring.cpp +++ b/Source/RWTHVRToolkit/Private/Interaction/Interactables/IntenSelect/IntenSelectableScoring.cpp @@ -4,31 +4,38 @@ #include "Interaction/Interactables/IntenSelect/IntenSelectableScoring.h" float UIntenSelectableScoring::GetScore(const FVector& ConeOrigin, const FVector& ConeForwardDirection, - const float ConeBackwardShiftDistance, const float ConeAngle, const FVector& TestPoint, const float LastValue, - const float DeltaTime) + const float ConeBackwardShiftDistance, const float ConeAngle, + const FVector& TestPoint, const float LastValue, const float DeltaTime) { const FVector ShiftedConeOrigin = ConeOrigin - (ConeForwardDirection * ConeBackwardShiftDistance); - + const float D_Perspective = FMath::PointDistToLine(TestPoint, ConeForwardDirection, ShiftedConeOrigin); const float D_Projection = (TestPoint - ShiftedConeOrigin).ProjectOnTo(ConeForwardDirection).Size(); - - const float Angle = FMath::RadiansToDegrees(FMath::Atan(D_Perspective / (FMath::Pow(D_Projection / 100, CompensationConstant) * 100))); + + const float Angle = FMath::RadiansToDegrees( + FMath::Atan(D_Perspective / (FMath::Pow(D_Projection / 100, CompensationConstant) * 100))); float S_Contrib = 1 - (Angle / ConeAngle); - if(S_Contrib < 0) S_Contrib = 0; + if (S_Contrib < 0) + S_Contrib = 0; - //GEngine->AddOnScreenDebugMessage(INDEX_NONE, 0, FColor::Red, GetOwner()->GetName() + " - Contrib: " + FString::FromInt(S_Contrib)); + // GEngine->AddOnScreenDebugMessage(INDEX_NONE, 0, FColor::Red, GetOwner()->GetName() + " - Contrib: " + + // FString::FromInt(S_Contrib)); - if(LastValue != 0) + if (LastValue != 0) { constexpr float Interpolate = 0.5; - if(S_Contrib > LastValue) + if (S_Contrib > LastValue) { - CurrentScore = LastValue + (((LastValue * Interpolate) + (S_Contrib * (1-Interpolate))) - LastValue) * DeltaTime * Snappiness; - }else + CurrentScore = LastValue + + (((LastValue * Interpolate) + (S_Contrib * (1 - Interpolate))) - LastValue) * DeltaTime * Snappiness; + } + else { - CurrentScore = LastValue + (((LastValue * Interpolate) + (S_Contrib * (1-Interpolate))) - LastValue) * DeltaTime * Stickiness; + CurrentScore = LastValue + + (((LastValue * Interpolate) + (S_Contrib * (1 - Interpolate))) - LastValue) * DeltaTime * Stickiness; } - }else + } + else { CurrentScore = S_Contrib * Snappiness * DeltaTime; } @@ -36,20 +43,15 @@ float UIntenSelectableScoring::GetScore(const FVector& ConeOrigin, const FVector } // Sets default values for this component's properties -UIntenSelectableScoring::UIntenSelectableScoring() -{ - PrimaryComponentTick.bCanEverTick = true; -} +UIntenSelectableScoring::UIntenSelectableScoring() { PrimaryComponentTick.bCanEverTick = true; } TPair<FHitResult, float> UIntenSelectableScoring::GetBestPointScorePair(const FVector& ConeOrigin, - const FVector& ConeForwardDirection, const float ConeBackwardShiftDistance, const float ConeAngle, - const float LastValue, const float DeltaTime) + const FVector& ConeForwardDirection, + const float ConeBackwardShiftDistance, + const float ConeAngle, const float LastValue, + const float DeltaTime) { return {}; } -void UIntenSelectableScoring::BeginPlay() -{ - Super::BeginPlay(); -} - +void UIntenSelectableScoring::BeginPlay() { Super::BeginPlay(); } diff --git a/Source/RWTHVRToolkit/Private/Interaction/Interactables/IntenSelect/IntenSelectableSinglePointScoring.cpp b/Source/RWTHVRToolkit/Private/Interaction/Interactables/IntenSelect/IntenSelectableSinglePointScoring.cpp index 5d68040e5e64870a6a6d988651917efe6ccfe702..e42770a89577caa97c2208b2a6905db8ca6bcbba 100644 --- a/Source/RWTHVRToolkit/Private/Interaction/Interactables/IntenSelect/IntenSelectableSinglePointScoring.cpp +++ b/Source/RWTHVRToolkit/Private/Interaction/Interactables/IntenSelect/IntenSelectableSinglePointScoring.cpp @@ -1,21 +1,16 @@ #include "Interaction/Interactables/IntenSelect/IntenSelectableSinglePointScoring.h" -UIntenSelectableSinglePointScoring::UIntenSelectableSinglePointScoring() -{ - PrimaryComponentTick.bCanEverTick = true; -} +UIntenSelectableSinglePointScoring::UIntenSelectableSinglePointScoring() { PrimaryComponentTick.bCanEverTick = true; } -TPair<FHitResult, float> UIntenSelectableSinglePointScoring::GetBestPointScorePair(const FVector& ConeOrigin, const FVector& ConeForwardDirection, const float ConeBackwardShiftDistance, +TPair<FHitResult, float> UIntenSelectableSinglePointScoring::GetBestPointScorePair( + const FVector& ConeOrigin, const FVector& ConeForwardDirection, const float ConeBackwardShiftDistance, const float ConeAngle, const float LastValue, const float DeltaTime) { const FVector Point = this->GetComponentLocation(); - float Score = GetScore(ConeOrigin, ConeForwardDirection, ConeBackwardShiftDistance, ConeAngle, Point, LastValue, DeltaTime); + float Score = + GetScore(ConeOrigin, ConeForwardDirection, ConeBackwardShiftDistance, ConeAngle, Point, LastValue, DeltaTime); FHitResult Result = FHitResult{GetOwner(), nullptr, Point, FVector::ForwardVector}; return TPair<FHitResult, float>{Result, Score}; } -void UIntenSelectableSinglePointScoring::BeginPlay() -{ - Super::BeginPlay(); -} - +void UIntenSelectableSinglePointScoring::BeginPlay() { Super::BeginPlay(); } diff --git a/Source/RWTHVRToolkit/Private/Interaction/Interactables/IntenSelect/IntenSelectableSphereScoring.cpp b/Source/RWTHVRToolkit/Private/Interaction/Interactables/IntenSelect/IntenSelectableSphereScoring.cpp index 8fe6dd277eca4fece49e995c2949626b7030b15c..36ddcbb571c7fe464ed38d9ff6c1cb5b60d40d04 100644 --- a/Source/RWTHVRToolkit/Private/Interaction/Interactables/IntenSelect/IntenSelectableSphereScoring.cpp +++ b/Source/RWTHVRToolkit/Private/Interaction/Interactables/IntenSelect/IntenSelectableSphereScoring.cpp @@ -8,17 +8,16 @@ #include "Kismet/KismetMathLibrary.h" // Sets default values for this component's properties -UIntenSelectableSphereScoring::UIntenSelectableSphereScoring() -{ - PrimaryComponentTick.bCanEverTick = true; -} +UIntenSelectableSphereScoring::UIntenSelectableSphereScoring() { PrimaryComponentTick.bCanEverTick = true; } -TPair<FHitResult, float> UIntenSelectableSphereScoring::GetBestPointScorePair(const FVector& ConeOrigin, - const FVector& ConeForwardDirection, const float ConeBackwardShiftDistance, const float ConeAngle, - const float LastValue, const float DeltaTime) +TPair<FHitResult, float> +UIntenSelectableSphereScoring::GetBestPointScorePair(const FVector& ConeOrigin, const FVector& ConeForwardDirection, + const float ConeBackwardShiftDistance, const float ConeAngle, + const float LastValue, const float DeltaTime) { FVector Point = GetClosestSelectionPointTo(ConeOrigin, ConeForwardDirection); - float Score = GetScore(ConeOrigin, ConeForwardDirection, ConeBackwardShiftDistance, ConeAngle, Point, LastValue, DeltaTime); + float Score = + GetScore(ConeOrigin, ConeForwardDirection, ConeBackwardShiftDistance, ConeAngle, Point, LastValue, DeltaTime); FHitResult Result = FHitResult{GetOwner(), nullptr, Point, FVector::ForwardVector}; return TPair<FHitResult, float>{Result, Score}; } @@ -34,32 +33,34 @@ FVector UIntenSelectableSphereScoring::GetClosestSelectionPointTo(const FVector& FVector Result = CenterWorld - ProjectionToSphere.GetSafeNormal() * Radius; - if(!OnlyOutline) + if (!OnlyOutline) { const float t = FVector::DotProduct(ToSphere, Direction.GetSafeNormal()); const FVector TPoint = Point + Direction.GetSafeNormal() * t; const float Y = (CenterWorld - TPoint).Size(); - - if(Y <= Radius) + + if (Y <= Radius) { - const float X = + FMath::Sqrt((Radius * Radius) - (Y * Y)); + const float X = +FMath::Sqrt((Radius * Radius) - (Y * Y)); const FVector Result1 = Point + Direction.GetSafeNormal() * (t - X); const FVector Result2 = Point + Direction.GetSafeNormal() * (t + X); - if(FVector::Distance(Point, Result1) < FVector::Distance(Point, Result2)) + if (FVector::Distance(Point, Result1) < FVector::Distance(Point, Result2)) { Result = Result1; - }else + } + else { Result = Result2; } } - + /* TArray<FHitResult> Out; const float Dist = FVector::Distance(Point, GetComponentLocation()); - if(GetWorld()->LineTraceMultiByChannel(Out, Point, Point + (Direction.GetSafeNormal() * Dist), ECollisionChannel::ECC_Visibility)) + if(GetWorld()->LineTraceMultiByChannel(Out, Point, Point + (Direction.GetSafeNormal() * Dist), + ECollisionChannel::ECC_Visibility)) { for(auto Hit : Out) { @@ -72,10 +73,10 @@ FVector UIntenSelectableSphereScoring::GetClosestSelectionPointTo(const FVector& }*/ } - if(DrawDebug) + if (DrawDebug) { DrawDebugSphere(GetWorld(), CenterWorld, Radius, 20, FColor::Green, false, -1, 0, 1); } - + return Result; } diff --git a/Source/RWTHVRToolkit/Private/Interaction/Interactors/DirectInteractionComponent.cpp b/Source/RWTHVRToolkit/Private/Interaction/Interactors/DirectInteractionComponent.cpp index c8cf9ce35e45d0bc107cd73da08333ef5ba5b2d9..5de410ffdecabb93d61eb71b4f4560c38a2d6938 100644 --- a/Source/RWTHVRToolkit/Private/Interaction/Interactors/DirectInteractionComponent.cpp +++ b/Source/RWTHVRToolkit/Private/Interaction/Interactors/DirectInteractionComponent.cpp @@ -112,8 +112,7 @@ void UDirectInteractionComponent::OnBeginInteraction(const FInputActionValue& Va if (bOnlyInteractWithClosestActor) { auto MinElement = *Algo::MinElementBy( - CurrentInteractableComponentsInRange, - [&](auto Element) + CurrentInteractableComponentsInRange, [&](auto Element) { return FVector(Element->GetOwner()->GetActorLocation() - InteractionLocation).Size(); }); MinElement->HandleOnActionStartEvents(this, InteractionInputAction, Value, EInteractorType::Direct); CurrentlyInteractedComponents = {MinElement}; diff --git a/Source/RWTHVRToolkit/Private/Pawn/IntenSelectComponent.cpp b/Source/RWTHVRToolkit/Private/Pawn/IntenSelectComponent.cpp index f0570786c4cabe7bf6d52082ff771ce2115f8806..f47d49f7e38109b3a261319fe6863c9d32a70d68 100644 --- a/Source/RWTHVRToolkit/Private/Pawn/IntenSelectComponent.cpp +++ b/Source/RWTHVRToolkit/Private/Pawn/IntenSelectComponent.cpp @@ -1,58 +1,66 @@ #include "Pawn/IntenSelectComponent.h" - #include "EnhancedInputComponent.h" #include "EnhancedInputSubsystems.h" #include "Components/WidgetComponent.h" #include "Haptics/HapticFeedbackEffect_Curve.h" -#include "Materials/MaterialExpressionStrata.h" #include "Materials/MaterialParameterCollection.h" #include "Materials/MaterialParameterCollectionInstance.h" #include "Misc/MessageDialog.h" -#include "UI/IntenSelectableWidget.h" #include "Templates/Tuple.h" // INITIALIZATION // Sets default values for this component's properties -UIntenSelectComponent::UIntenSelectComponent(const FObjectInitializer& ObjectInitializer) - : Super(ObjectInitializer) +UIntenSelectComponent::UIntenSelectComponent(const FObjectInitializer& ObjectInitializer) : Super(ObjectInitializer) { PrimaryComponentTick.bCanEverTick = true; - bShowDebug = false; //otherwise the WidgetInteractionComponent debug vis is shown - InteractionSource = EWidgetInteractionSource::Custom; //can also be kept at default (World), this way, however, we efficiently reuse the line traces + bShowDebug = false; // otherwise the WidgetInteractionComponent debug vis is shown + InteractionSource = EWidgetInteractionSource::Custom; // can also be kept at default (World), this way, however, we + // efficiently reuse the line traces - ConstructorHelpers::FObjectFinder<UStaticMesh> DefaultConeMesh(TEXT("StaticMesh'/RWTHVRToolkit/IntenSelect/DebugConeMesh.DebugConeMesh'")); + ConstructorHelpers::FObjectFinder<UStaticMesh> DefaultConeMesh( + TEXT("StaticMesh'/RWTHVRToolkit/IntenSelect/DebugConeMesh.DebugConeMesh'")); this->DebugConeMesh = DefaultConeMesh.Object; - - ConstructorHelpers::FObjectFinder<UMaterialInterface> DefaultConeMeshMaterial(TEXT("Material'/RWTHVRToolkit/IntenSelect/DebugConeMaterial.DebugConeMaterial'")); + + ConstructorHelpers::FObjectFinder<UMaterialInterface> DefaultConeMeshMaterial( + TEXT("Material'/RWTHVRToolkit/IntenSelect/DebugConeMaterial.DebugConeMaterial'")); this->DebugConeMaterial = DefaultConeMeshMaterial.Object; - ConstructorHelpers::FObjectFinder<UStaticMesh> DefaultSplineMesh(TEXT("StaticMesh'/RWTHVRToolkit/IntenSelect/sectionedCubeMesh.sectionedCubeMesh'")); + ConstructorHelpers::FObjectFinder<UStaticMesh> DefaultSplineMesh( + TEXT("StaticMesh'/RWTHVRToolkit/IntenSelect/sectionedCubeMesh.sectionedCubeMesh'")); this->SplineMesh = DefaultSplineMesh.Object; - - ConstructorHelpers::FObjectFinder<UStaticMesh> DefaultForwardRayMesh(TEXT("StaticMesh'/RWTHVRToolkit/IntenSelect/RayMesh.RayMesh'")); + + ConstructorHelpers::FObjectFinder<UStaticMesh> DefaultForwardRayMesh( + TEXT("StaticMesh'/RWTHVRToolkit/IntenSelect/RayMesh.RayMesh'")); this->ForwardRayMesh = DefaultForwardRayMesh.Object; - ConstructorHelpers::FObjectFinder<UMaterialInterface> DefaultSplineMaterial(TEXT("Material'/RWTHVRToolkit/IntenSelect/SelectionSplineMaterial.SelectionSplineMaterial'")); + ConstructorHelpers::FObjectFinder<UMaterialInterface> DefaultSplineMaterial( + TEXT("Material'/RWTHVRToolkit/IntenSelect/SelectionSplineMaterial.SelectionSplineMaterial'")); this->SplineMaterial = DefaultSplineMaterial.Object; - - ConstructorHelpers::FObjectFinder<UMaterialInterface> DefaultForwardRayMaterial(TEXT("Material'/RWTHVRToolkit/IntenSelect/ForwadRayMaterial.ForwadRayMaterial'")); + + ConstructorHelpers::FObjectFinder<UMaterialInterface> DefaultForwardRayMaterial( + TEXT("Material'/RWTHVRToolkit/IntenSelect/ForwadRayMaterial.ForwadRayMaterial'")); this->ForwardRayMaterial = DefaultForwardRayMaterial.Object; - ConstructorHelpers::FObjectFinder<UHapticFeedbackEffect_Curve> DefaultSelectionFeedbackHaptic(TEXT("HapticFeedbackEffect_Curve'/RWTHVRToolkit/IntenSelect/OnSelectHapticFeedback.OnSelectHapticFeedback'")); + ConstructorHelpers::FObjectFinder<UHapticFeedbackEffect_Curve> DefaultSelectionFeedbackHaptic( + TEXT("HapticFeedbackEffect_Curve'/RWTHVRToolkit/IntenSelect/OnSelectHapticFeedback.OnSelectHapticFeedback'")); this->SelectionFeedbackHaptic = DefaultSelectionFeedbackHaptic.Object; - - ConstructorHelpers::FObjectFinder<USoundBase> DefaultOnSelectSound(TEXT("SoundWave'/RWTHVRToolkit/IntenSelect/OnSelectSound.OnSelectSound'")); + + ConstructorHelpers::FObjectFinder<USoundBase> DefaultOnSelectSound( + TEXT("SoundWave'/RWTHVRToolkit/IntenSelect/OnSelectSound.OnSelectSound'")); this->OnSelectSound = DefaultOnSelectSound.Object; - - ConstructorHelpers::FObjectFinder<UMaterialParameterCollection> DefaultMaterialParamCollection(TEXT("MaterialParameterCollection'/RWTHVRToolkit/IntenSelect/ForwardRayParams.ForwardRayParams'")); + + ConstructorHelpers::FObjectFinder<UMaterialParameterCollection> DefaultMaterialParamCollection( + TEXT("MaterialParameterCollection'/RWTHVRToolkit/IntenSelect/ForwardRayParams.ForwardRayParams'")); this->MaterialParamCollection = DefaultMaterialParamCollection.Object; - - ConstructorHelpers::FObjectFinder<UCurveFloat> DefaultForwardRayTransparencyCurve(TEXT("CurveFloat'/RWTHVRToolkit/IntenSelect/ForwardRayTransparencyCurve.ForwardRayTransparencyCurve'")); + + ConstructorHelpers::FObjectFinder<UCurveFloat> DefaultForwardRayTransparencyCurve( + TEXT("CurveFloat'/RWTHVRToolkit/IntenSelect/ForwardRayTransparencyCurve.ForwardRayTransparencyCurve'")); this->ForwardRayTransparencyCurve = DefaultForwardRayTransparencyCurve.Object; - - ConstructorHelpers::FObjectFinder<UInputAction> InputActionClick(TEXT("/Script/EnhancedInput.InputAction'/RWTHVRToolkit/IntenSelect/IntenSelectClick.IntenSelectClick'")); + + ConstructorHelpers::FObjectFinder<UInputAction> InputActionClick( + TEXT("/Script/EnhancedInput.InputAction'/RWTHVRToolkit/IntenSelect/IntenSelectClick.IntenSelectClick'")); this->InputClick = InputActionClick.Object; } @@ -66,35 +74,38 @@ void UIntenSelectComponent::BeginPlay() this->InitForwardRayMeshComponent(); this->InitDebugConeMeshComponent(); this->InitInputBindings(); - this->InitMaterialParamCollection(); - + this->InitMaterialParamCollection(); + this->SphereCastRadius = CalculateSphereCastRadius(); this->InteractionDistance = this->MaxSelectionDistance; this->SetActive(SetActiveOnStart, false); } -void UIntenSelectComponent::InitInputBindings(){ +void UIntenSelectComponent::InitInputBindings() +{ const APlayerController* PC = UGameplayStatics::GetPlayerController(GetWorld(), 0); - UEnhancedInputLocalPlayerSubsystem* Subsystem = ULocalPlayer::GetSubsystem<UEnhancedInputLocalPlayerSubsystem>(PC->GetLocalPlayer()); + UEnhancedInputLocalPlayerSubsystem* Subsystem = + ULocalPlayer::GetSubsystem<UEnhancedInputLocalPlayerSubsystem>(PC->GetLocalPlayer()); UInputComponent* PlayerInputComponent = PC->InputComponent; UEnhancedInputComponent* PEI = Cast<UEnhancedInputComponent>(PlayerInputComponent); - if(!PEI){ + if (!PEI) + { const FString Message = "Could not get PlayerInputComponent for IntenSelect Input Assignment!"; - - #if WITH_EDITOR - const FText Title = FText::FromString(FString("ERROR")); - FMessageDialog::Open(EAppMsgType::Ok, FText::FromString(Message), Title); - #endif - + +#if WITH_EDITOR + const FText Title = FText::FromString(FString("ERROR")); + FMessageDialog::Open(EAppMsgType::Ok, FText::FromString(Message), Title); +#endif + UE_LOG(LogTemp, Error, TEXT("%s"), *Message) UKismetSystemLibrary::QuitGame(this, nullptr, EQuitPreference::Quit, false); return; - } - + } + // Bind the actions PEI->BindAction(InputClick, ETriggerEvent::Started, this, &UIntenSelectComponent::OnFireDown); PEI->BindAction(InputClick, ETriggerEvent::Completed, this, &UIntenSelectComponent::OnFireUp); @@ -104,29 +115,30 @@ void UIntenSelectComponent::InitSplineComponent() { SplineComponent = NewObject<USplineComponent>(this, TEXT("SplineComponent")); - if(SplineComponent) + if (SplineComponent) { SplineComponent->SetupAttachment(this); SplineComponent->SetMobility(EComponentMobility::Movable); SplineComponent->RegisterComponent(); SplineComponent->CreationMethod = EComponentCreationMethod::Instance; - - }else + } + else { const FString Message = "Error while spawning SplineComponent!"; - #if WITH_EDITOR - const FText Title = FText::FromString(FString("ERROR")); - FMessageDialog::Open(EAppMsgType::Ok, FText::FromString(Message), Title); - #endif - +#if WITH_EDITOR + const FText Title = FText::FromString(FString("ERROR")); + FMessageDialog::Open(EAppMsgType::Ok, FText::FromString(Message), Title); +#endif + UE_LOG(LogTemp, Error, TEXT("%s"), *Message) } } void UIntenSelectComponent::InitSplineMeshComponent() { - SplineMeshComponent = NewObject<USplineMeshComponent>(this, USplineMeshComponent::StaticClass(), TEXT("SplineMeshComponent")); - if(SplineMeshComponent) + SplineMeshComponent = + NewObject<USplineMeshComponent>(this, USplineMeshComponent::StaticClass(), TEXT("SplineMeshComponent")); + if (SplineMeshComponent) { SplineMeshComponent->SetupAttachment(this); SplineMeshComponent->SetMobility(EComponentMobility::Movable); @@ -153,8 +165,8 @@ void UIntenSelectComponent::InitSplineMeshComponent() SplineMeshComponent->SetForwardAxis(ESplineMeshAxis::Z); SplineMeshComponent->CastShadow = false; - - }else + } + else { UE_LOG(LogTemp, Error, TEXT("Error while spawning SplineMeshComponent!")) } @@ -162,9 +174,10 @@ void UIntenSelectComponent::InitSplineMeshComponent() void UIntenSelectComponent::InitForwardRayMeshComponent() { - ForwardRayMeshComponent = NewObject<UStaticMeshComponent>(this, UStaticMeshComponent::StaticClass(), TEXT("ForwardRay")); + ForwardRayMeshComponent = + NewObject<UStaticMeshComponent>(this, UStaticMeshComponent::StaticClass(), TEXT("ForwardRay")); - if(ForwardRayMeshComponent) + if (ForwardRayMeshComponent) { ForwardRayMeshComponent->SetupAttachment(this); ForwardRayMeshComponent->SetMobility((EComponentMobility::Movable)); @@ -178,21 +191,23 @@ void UIntenSelectComponent::InitForwardRayMeshComponent() ForwardRayMeshComponent->SetRelativeScale3D(FVector(MeshLength, ForwardRayWidth, ForwardRayWidth)); ForwardRayMeshComponent->SetRelativeLocation(FVector(MeshLength * 50, 0, 0)); - //const ConstructorHelpers::FObjectFinder<UStaticMesh> CubeMesh(TEXT("/Engine/BasicShapes/Cube.Cube")); - if(ForwardRayMesh) + // const ConstructorHelpers::FObjectFinder<UStaticMesh> CubeMesh(TEXT("/Engine/BasicShapes/Cube.Cube")); + if (ForwardRayMesh) { ForwardRayMeshComponent->SetStaticMesh(ForwardRayMesh); - }else + } + else { UE_LOG(LogTemp, Warning, TEXT("Mesh for RayComponent not set!")); } - UMaterialInstanceDynamic* DynamicMaterial = UMaterialInstanceDynamic::Create(ForwardRayMaterial, ForwardRayMeshComponent); + UMaterialInstanceDynamic* DynamicMaterial = + UMaterialInstanceDynamic::Create(ForwardRayMaterial, ForwardRayMeshComponent); this->ForwardRayMeshComponent->SetMaterial(0, DynamicMaterial); ForwardRayMeshComponent->SetHiddenInGame(!bDrawForwardRay); - - }else + } + else { UE_LOG(LogTemp, Error, TEXT("Error while spawning ForwardRayMesh component!")); } @@ -200,17 +215,20 @@ void UIntenSelectComponent::InitForwardRayMeshComponent() void UIntenSelectComponent::InitMaterialParamCollection() { - if(MaterialParamCollection) + if (MaterialParamCollection) { this->ParameterCollectionInstance = GetWorld()->GetParameterCollectionInstance(MaterialParamCollection); - if(this->ParameterCollectionInstance) + if (this->ParameterCollectionInstance) { this->ParameterCollectionInstance->SetScalarParameterValue("Transparency", DebugRayTransparency); - }else + } + else { - UE_LOG(LogTemp, Warning, TEXT("MaterialParameterCollection required for rendering of IntenSelect could not be found!")) + UE_LOG(LogTemp, Warning, + TEXT("MaterialParameterCollection required for rendering of IntenSelect could not be found!")) } - }else + } + else { UE_LOG(LogTemp, Warning, TEXT("MaterialParameterCollection required for InteSelect visualization is not set!")); } @@ -218,22 +236,24 @@ void UIntenSelectComponent::InitMaterialParamCollection() void UIntenSelectComponent::InitDebugConeMeshComponent() { - DebugConeMeshComponent = NewObject<UStaticMeshComponent>(this, UStaticMeshComponent::StaticClass(), TEXT("DebugCone")); + DebugConeMeshComponent = + NewObject<UStaticMeshComponent>(this, UStaticMeshComponent::StaticClass(), TEXT("DebugCone")); - if(DebugConeMeshComponent) + if (DebugConeMeshComponent) { DebugConeMeshComponent->SetupAttachment(this); DebugConeMeshComponent->SetMobility(EComponentMobility::Movable); DebugConeMeshComponent->RegisterComponent(); DebugConeMeshComponent->CreationMethod = EComponentCreationMethod::Instance; - + FTransform ConeTransform = DebugConeMeshComponent->GetRelativeTransform(); const float ConeScale = MaxSelectionDistance / 50 * FMath::Tan(FMath::DegreesToRadians(SelectionConeAngle)); ConeTransform.SetScale3D(FVector(ConeScale, ConeScale, MaxSelectionDistance / 100)); DebugConeMeshComponent->SetRelativeTransform(ConeTransform); - DebugConeMeshComponent->SetRelativeLocation(FVector(MaxSelectionDistance - ConeBackwardShiftDistance, 0, 0), false); + DebugConeMeshComponent->SetRelativeLocation(FVector(MaxSelectionDistance - ConeBackwardShiftDistance, 0, 0), + false); DebugConeMeshComponent->SetRelativeRotation(DebugConeRotation, false); DebugConeMeshComponent->SetCollisionEnabled(ECollisionEnabled::NoCollision); @@ -255,7 +275,8 @@ void UIntenSelectComponent::InitDebugConeMeshComponent() } DebugConeMeshComponent->SetVisibility(bDrawDebugCone); - }else + } + else { UE_LOG(LogTemp, Error, TEXT("Error while spawning DebugCone component!")) } @@ -269,23 +290,26 @@ float UIntenSelectComponent::CalculateSphereCastRadius() const return FMath::Tan(FMath::DegreesToRadians(SelectionConeAngle)) * MaxSelectionDistance; } -bool UIntenSelectComponent::CheckPointInCone(const FVector ConeStartPoint, const FVector ConeForward, const FVector PointToTest, const float Angle) const +bool UIntenSelectComponent::CheckPointInCone(const FVector ConeStartPoint, const FVector ConeForward, + const FVector PointToTest, const float Angle) const { const FVector ShiftedStartOriginPoint = ConeStartPoint - (ConeForward * ConeBackwardShiftDistance); const FVector DirectionToTestPoint = (PointToTest - ShiftedStartOriginPoint).GetSafeNormal(); - const float AngleToTestPoint = FMath::RadiansToDegrees(FMath::Acos((FVector::DotProduct(ConeForward ,DirectionToTestPoint)))); - + const float AngleToTestPoint = + FMath::RadiansToDegrees(FMath::Acos((FVector::DotProduct(ConeForward, DirectionToTestPoint)))); + return AngleToTestPoint <= Angle; } void UIntenSelectComponent::OnNewSelected_Implementation(UIntenSelectable* Selection) { CurrentSelection = Selection; - - if(FeedbackCooldown == 0) + + if (FeedbackCooldown == 0) { - //UGameplayStatics::GetPlayerController(GetWorld(), 0)->PlayHapticEffect(SelectionFeedbackHaptic, EControllerHand::Right, 0.1, false); + // UGameplayStatics::GetPlayerController(GetWorld(), 0)->PlayHapticEffect(SelectionFeedbackHaptic, + // EControllerHand::Right, 0.1, false); UGameplayStatics::PlaySound2D(GetWorld(), OnSelectSound); FeedbackCooldown = 0.1; } @@ -293,13 +317,17 @@ void UIntenSelectComponent::OnNewSelected_Implementation(UIntenSelectable* Selec bool UIntenSelectComponent::GetActorsFromSphereCast(const FVector& SphereCastStart, TArray<FHitResult>& OutHits) const { - const FVector StartPos = SphereCastStart + (GetComponentTransform().GetRotation().GetForwardVector() * SphereCastRadius); - const FVector EndPos = StartPos + (this->GetComponentTransform().GetRotation().GetForwardVector() * (MaxSelectionDistance)); + const FVector StartPos = + SphereCastStart + (GetComponentTransform().GetRotation().GetForwardVector() * SphereCastRadius); + const FVector EndPos = + StartPos + (this->GetComponentTransform().GetRotation().GetForwardVector() * (MaxSelectionDistance)); const FCollisionQueryParams Params = FCollisionQueryParams(FName(TEXT("SphereTraceMultiForObjects")), false); - //GetWorld()->SweepMultiByChannel(OutHits, StartPos, EndPos, FQuat::Identity, ECC_Visibility, FCollisionShape::MakeSphere(SphereCastRadius), Params); - - GetWorld()->SweepMultiByChannel(OutHits, StartPos, EndPos, FQuat::Identity, ECC_Visibility, FCollisionShape::MakeSphere(SphereCastRadius), Params); + // GetWorld()->SweepMultiByChannel(OutHits, StartPos, EndPos, FQuat::Identity, ECC_Visibility, + // FCollisionShape::MakeSphere(SphereCastRadius), Params); + + GetWorld()->SweepMultiByChannel(OutHits, StartPos, EndPos, FQuat::Identity, ECC_Visibility, + FCollisionShape::MakeSphere(SphereCastRadius), Params); // UKismetSystemLibrary::SphereTraceMulti(GetWorld(),StartPos,EndPos,SphereCastRadius,ETraceTypeQuery::TraceTypeQuery1,false,{},EDrawDebugTrace::ForOneFrame,OutHits,true); return true; } @@ -310,19 +338,19 @@ UIntenSelectable* UIntenSelectComponent::GetMaxScoreActor(const float DeltaTime) const FVector ConeForward = this->GetComponentTransform().GetRotation().GetForwardVector(); TArray<FHitResult> OutHits; - if (GetActorsFromSphereCast(ConeOrigin, OutHits)) { + if (GetActorsFromSphereCast(ConeOrigin, OutHits)) + { for (const FHitResult& Hit : OutHits) { const FVector PointToCheck = Hit.ImpactPoint; const float DistanceToActor = FVector::Dist(ConeOrigin, PointToCheck); const AActor* HitActor = Hit.GetActor(); - if(HitActor) + if (HitActor) { const auto Selectable = HitActor->FindComponentByClass<UIntenSelectable>(); - if(Selectable && Selectable->IsSelectable - && DistanceToActor <= MaxSelectionDistance) + if (Selectable && Selectable->IsSelectable && DistanceToActor <= MaxSelectionDistance) { ScoreMap.FindOrAdd(Selectable, 0); } @@ -334,18 +362,19 @@ UIntenSelectable* UIntenSelectComponent::GetMaxScoreActor(const float DeltaTime) float MaxScore = TNumericLimits<float>::Min(); TArray<UIntenSelectable*> RemoveList; TArray<TPair<UIntenSelectable*, FHitResult>> CandidateList; - + for (TTuple<UIntenSelectable*, float>& OldScoreEntry : ScoreMap) { - //GEngine->AddOnScreenDebugMessage(INDEX_NONE, 0, FColor::Black, OldScoreEntry.Key->GetOwner()->GetName() + " - Score: " + FString::SanitizeFloat(OldScoreEntry.Value)); - if(!OldScoreEntry.Key) + // GEngine->AddOnScreenDebugMessage(INDEX_NONE, 0, FColor::Black, OldScoreEntry.Key->GetOwner()->GetName() + " + // - Score: " + FString::SanitizeFloat(OldScoreEntry.Value)); + if (!OldScoreEntry.Key) { continue; } TPair<FHitResult, float> NewScorePair = OldScoreEntry.Key->GetBestPointScorePair( ConeOrigin, ConeForward, ConeBackwardShiftDistance, SelectionConeAngle, OldScoreEntry.Value, DeltaTime); - + ContactPointMap.Add(OldScoreEntry.Key, NewScorePair.Key); const float DistanceToActor = FVector::Dist(ConeOrigin, NewScorePair.Key.ImpactPoint); @@ -358,13 +387,15 @@ UIntenSelectable* UIntenSelectComponent::GetMaxScoreActor(const float DeltaTime) { OldScoreEntry.Value = NewScorePair.Value; - if (NewScorePair.Value > (1.0 - Eps) && this->CheckPointInCone(ConeOrigin, ConeForward, NewScorePair.Key.ImpactPoint, SelectionConeAngle)) + if (NewScorePair.Value > (1.0 - Eps) && + this->CheckPointInCone(ConeOrigin, ConeForward, NewScorePair.Key.ImpactPoint, SelectionConeAngle)) { CandidateList.Emplace(OldScoreEntry.Key, NewScorePair.Key); MaxScore = NewScorePair.Value; MaxScoreSelectable = OldScoreEntry.Key; } - else if (NewScorePair.Value > MaxScore && this->CheckPointInCone(ConeOrigin, ConeForward, NewScorePair.Key.ImpactPoint, SelectionConeAngle)) + else if (NewScorePair.Value > MaxScore && + this->CheckPointInCone(ConeOrigin, ConeForward, NewScorePair.Key.ImpactPoint, SelectionConeAngle)) { MaxScore = NewScorePair.Value; MaxScoreSelectable = OldScoreEntry.Key; @@ -379,12 +410,13 @@ UIntenSelectable* UIntenSelectComponent::GetMaxScoreActor(const float DeltaTime) } if (CandidateList.Num() > 0) { - auto DistanceToMaxScore = FVector::Distance(MaxScoreSelectable->GetOwner()->GetActorLocation(),GetComponentLocation()); + auto DistanceToMaxScore = + FVector::Distance(MaxScoreSelectable->GetOwner()->GetActorLocation(), GetComponentLocation()); auto Dist = TNumericLimits<float>::Max(); - for(const auto Actor : CandidateList) + for (const auto Actor : CandidateList) { const auto DistanceToCandidate = FVector::Distance(Actor.Value.ImpactPoint, GetComponentLocation()); - if(DistanceToCandidate < Dist) + if (DistanceToCandidate < Dist) { MaxScoreSelectable = Actor.Key; Dist = DistanceToCandidate; @@ -392,7 +424,7 @@ UIntenSelectable* UIntenSelectComponent::GetMaxScoreActor(const float DeltaTime) } } - return MaxScoreSelectable; + return MaxScoreSelectable; } // RAYCASTING @@ -401,15 +433,15 @@ void UIntenSelectComponent::HandleWidgetInteraction() { const FVector Forward = this->GetComponentTransform().GetRotation().GetForwardVector(); const FVector Origin = this->GetComponentTransform().GetLocation(); - + TOptional<FHitResult> Hit = RaytraceForFirstHit(Origin, Origin + Forward * MaxSelectionDistance); - + if (!Hit.IsSet()) { IsWidgetInFocus = false; return; } - + SetCustomHitResult(Hit.GetValue()); UWidgetComponent* FocusedWidget = Cast<UWidgetComponent>(Hit.GetValue().GetComponent()); IsWidgetInFocus = (FocusedWidget != nullptr); @@ -462,8 +494,8 @@ TOptional<FHitResult> UIntenSelectComponent::RaytraceForFirstHit(const FVector& if (GetWorld()->LineTraceSingleByChannel(Hit, Start, End, ECollisionChannel::ECC_Visibility, Params)) { return {Hit}; - - }else + } + else { return {}; } @@ -479,7 +511,7 @@ void UIntenSelectComponent::DrawSelectionCurve(const FVector& EndPoint) const SplineComponent->ClearSplinePoints(true); SplineMeshComponent->SetHiddenInGame(false); - + AddSplinePointsDefault(StartPoint, Forward, EndPoint); const FVector StartPosition = SplineComponent->GetLocationAtSplinePoint(0, ESplineCoordinateSpace::Local); @@ -490,7 +522,8 @@ void UIntenSelectComponent::DrawSelectionCurve(const FVector& EndPoint) const SplineMeshComponent->SetStartAndEnd(StartPosition, StartTangent, EndPosition, EndTangent, true); } -void UIntenSelectComponent::AddSplinePointsDefault(const FVector& StartPoint, const FVector& Forward, const FVector& EndPoint) const +void UIntenSelectComponent::AddSplinePointsDefault(const FVector& StartPoint, const FVector& Forward, + const FVector& EndPoint) const { SplineComponent->AddSplineWorldPoint(StartPoint); @@ -501,22 +534,26 @@ void UIntenSelectComponent::AddSplinePointsDefault(const FVector& StartPoint, co SplineComponent->SetSplinePointType(0, ESplinePointType::Curve, true); SplineComponent->SetSplinePointType(1, ESplinePointType::Curve, true); - - SplineComponent->SetTangentAtSplinePoint(0, Forward * ForwardProjection.Size() * SplineCurvatureStrength, ESplineCoordinateSpace::World, true); + + SplineComponent->SetTangentAtSplinePoint(0, Forward * ForwardProjection.Size() * SplineCurvatureStrength, + ESplineCoordinateSpace::World, true); SplineComponent->SetTangentAtSplinePoint(1, StartToEnd.GetSafeNormal(), ESplineCoordinateSpace::World, true); } void UIntenSelectComponent::UpdateForwardRay(const FVector& ReferencePoint) const { - if(ForwardRayTransparencyCurve) + if (ForwardRayTransparencyCurve) { const FVector ConeForward = this->GetComponentTransform().GetRotation().GetForwardVector(); - const FVector ConeOrigin = this->GetComponentTransform().GetLocation() - (ConeForward * ConeBackwardShiftDistance); + const FVector ConeOrigin = + this->GetComponentTransform().GetLocation() - (ConeForward * ConeBackwardShiftDistance); const FVector TestPointVector = (ReferencePoint - ConeOrigin).GetSafeNormal(); - const float AngleToTestPoint = FMath::RadiansToDegrees(FMath::Acos((FVector::DotProduct(ConeForward, TestPointVector)))); - - const float NewTransparency = ForwardRayTransparencyCurve->GetFloatValue(AngleToTestPoint / SelectionConeAngle) * DebugRayTransparency; + const float AngleToTestPoint = + FMath::RadiansToDegrees(FMath::Acos((FVector::DotProduct(ConeForward, TestPointVector)))); + + const float NewTransparency = + ForwardRayTransparencyCurve->GetFloatValue(AngleToTestPoint / SelectionConeAngle) * DebugRayTransparency; ParameterCollectionInstance->SetScalarParameterValue("Transparency", NewTransparency); } } @@ -525,27 +562,30 @@ void UIntenSelectComponent::UpdateForwardRay(const FVector& ReferencePoint) cons void UIntenSelectComponent::OnFireDown() { - //start interaction of WidgetInteractionComponent + // start interaction of WidgetInteractionComponent PressPointerKey(EKeys::LeftMouseButton); - if(!CurrentSelection) + if (!CurrentSelection) { return; } - - if(CurrentSelection) + + if (CurrentSelection) { const FHitResult GrabbedPoint = *ContactPointMap.Find(CurrentSelection); CurrentSelection->HandleOnClickStartEvents(this); LastKnownSelection = CurrentSelection; - LastKnownGrabPoint = LastKnownSelection->GetOwner()->GetRootComponent()->GetComponentTransform().InverseTransformPosition(GrabbedPoint.ImpactPoint); - }else + LastKnownGrabPoint = + LastKnownSelection->GetOwner()->GetRootComponent()->GetComponentTransform().InverseTransformPosition( + GrabbedPoint.ImpactPoint); + } + else { LastKnownSelection = nullptr; } - + IsGrabbing = true; - + if (bDrawForwardRay && ParameterCollectionInstance) { ParameterCollectionInstance->SetScalarParameterValue("Transparency", 0); @@ -554,11 +594,11 @@ void UIntenSelectComponent::OnFireDown() void UIntenSelectComponent::OnFireUp() { - //end interaction of WidgetInteractionComponent + // end interaction of WidgetInteractionComponent ReleasePointerKey(EKeys::LeftMouseButton); IsGrabbing = false; - + if (LastKnownSelection) { FInputActionValue v; @@ -568,14 +608,15 @@ void UIntenSelectComponent::OnFireUp() // SELECTION-HANDLING -void UIntenSelectComponent::SelectObject(UIntenSelectable* SelectableComponent, AActor* SelectedBy) { +void UIntenSelectComponent::SelectObject(UIntenSelectable* SelectableComponent, AActor* SelectedBy) +{ CurrentSelection = SelectableComponent; } void UIntenSelectComponent::Unselect() { IsGrabbing = false; - + SplineMeshComponent->SetHiddenInGame(true); CurrentSelection = nullptr; @@ -584,27 +625,28 @@ void UIntenSelectComponent::Unselect() void UIntenSelectComponent::SetActive(bool bNewActive, bool bReset) { - if(bNewActive) + if (bNewActive) { ForwardRayMeshComponent->SetVisibility(true); SplineMeshComponent->SetVisibility(true); - + Super::SetActive(true, bReset); - }else + } + else { - if(CurrentSelection) + if (CurrentSelection) { HandleNoActorSelected(); } - if(LastKnownSelection) + if (LastKnownSelection) { OnFireUp(); } ForwardRayMeshComponent->SetVisibility(false); SplineMeshComponent->SetVisibility(false); - + Super::SetActive(false, bReset); } } @@ -623,21 +665,18 @@ void UIntenSelectComponent::HandleCooldown(const float DeltaTime) } } -void UIntenSelectComponent::HandleGrabbing(const float DeltaTime) const -{ - -} +void UIntenSelectComponent::HandleGrabbing(const float DeltaTime) const {} void UIntenSelectComponent::HandleActorSelected(UIntenSelectable* NewSelection) { if (NewSelection != CurrentSelection) { - if(CurrentSelection) + if (CurrentSelection) { CurrentSelection->HandleOnSelectEndEvents(this); } - - if(NewSelection) + + if (NewSelection) { UIntenSelectable* NewIntenSelectable = NewSelection; const FHitResult GrabbedPoint = *ContactPointMap.Find(NewIntenSelectable); @@ -647,8 +686,8 @@ void UIntenSelectComponent::HandleActorSelected(UIntenSelectable* NewSelection) CurrentSelection = NewSelection; OnNewSelected(NewSelection); } - - if(CurrentSelection) + + if (CurrentSelection) { const UIntenSelectable* NewIntenSelectable = NewSelection; const auto V_Net = ContactPointMap.Find(NewIntenSelectable)->ImpactPoint; @@ -676,12 +715,12 @@ FVector UIntenSelectComponent::ConvertNetVector(FVector_NetQuantize v) void UIntenSelectComponent::HandleNoActorSelected() { SplineMeshComponent->SetHiddenInGame(true); - - if(CurrentSelection) + + if (CurrentSelection) { CurrentSelection->HandleOnSelectEndEvents(this); } - + if (bDrawForwardRay && ParameterCollectionInstance) { ParameterCollectionInstance->SetScalarParameterValue("Transparency", DebugRayTransparency); @@ -689,39 +728,42 @@ void UIntenSelectComponent::HandleNoActorSelected() CurrentSelection = nullptr; } -void UIntenSelectComponent::TickComponent(const float DeltaTime, const ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) +void UIntenSelectComponent::TickComponent(const float DeltaTime, const ELevelTick TickType, + FActorComponentTickFunction* ThisTickFunction) { Super::TickComponent(DeltaTime, TickType, ThisTickFunction); - + this->HandleCooldown(DeltaTime); UIntenSelectable* const NewSelection = GetMaxScoreActor(DeltaTime); - - if(IsGrabbing && LastKnownSelection) + + if (IsGrabbing && LastKnownSelection) { - const FVector GrabPointWorld = LastKnownSelection->GetOwner()->GetRootComponent()->GetComponentTransform(). - TransformPosition(LastKnownGrabPoint); + const FVector GrabPointWorld = + LastKnownSelection->GetOwner()->GetRootComponent()->GetComponentTransform().TransformPosition( + LastKnownGrabPoint); DrawSelectionCurve(GrabPointWorld); const FVector ConeOrigin = this->GetComponentLocation(); const FVector ConeForward = this->GetForwardVector().GetSafeNormal(); - - if(!this->CheckPointInCone(ConeOrigin, ConeForward, GrabPointWorld, MaxClickStickAngle)) + + if (!this->CheckPointInCone(ConeOrigin, ConeForward, GrabPointWorld, MaxClickStickAngle)) { OnFireUp(); } - + return; - }else if(CurrentSelection && ContactPointMap.Contains(CurrentSelection)) + } + else if (CurrentSelection && ContactPointMap.Contains(CurrentSelection)) { const FVector GrabbedPoint = ConvertNetVector(ContactPointMap.Find(CurrentSelection)->ImpactPoint); DrawSelectionCurve(GrabbedPoint); } - - //this->HandleWidgetInteraction(); + + // this->HandleWidgetInteraction(); IsWidgetInFocus = false; - if(IsWidgetInFocus) + if (IsWidgetInFocus) { - //GEngine->AddOnScreenDebugMessage(INDEX_NONE, 0, FColor::Red, "Widget focused"); + // GEngine->AddOnScreenDebugMessage(INDEX_NONE, 0, FColor::Red, "Widget focused"); HandleNoActorSelected(); const FVector PointToDrawTo = WidgetFocusPoint; @@ -732,16 +774,17 @@ void UIntenSelectComponent::TickComponent(const float DeltaTime, const ELevelTic } DrawSelectionCurve(PointToDrawTo); - }else + } + else { if (NewSelection) { - //GEngine->AddOnScreenDebugMessage(INDEX_NONE, 0, FColor::Red, "Focused Actor:" + NewSelection->GetName()); + // GEngine->AddOnScreenDebugMessage(INDEX_NONE, 0, FColor::Red, "Focused Actor:" + NewSelection->GetName()); HandleActorSelected(NewSelection); } else { - //GEngine->AddOnScreenDebugMessage(INDEX_NONE, 0, FColor::Red, "No Actor in Focus"); + // GEngine->AddOnScreenDebugMessage(INDEX_NONE, 0, FColor::Red, "No Actor in Focus"); HandleNoActorSelected(); } } diff --git a/Source/RWTHVRToolkit/Public/Interaction/Interactables/IntenSelect/IntenSelectable.h b/Source/RWTHVRToolkit/Public/Interaction/Interactables/IntenSelect/IntenSelectable.h index 9495bcf7dd44b6dfa9fb0be95f50a87e8e34aff6..ea8fccb95d7a1fad3a1a5e87ed78ea2a50c90861 100644 --- a/Source/RWTHVRToolkit/Public/Interaction/Interactables/IntenSelect/IntenSelectable.h +++ b/Source/RWTHVRToolkit/Public/Interaction/Interactables/IntenSelect/IntenSelectable.h @@ -13,7 +13,7 @@ class UClickBehaviour; class USelectionBehaviour; class UIntenSelectComponent; -UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) ) +UCLASS(ClassGroup = (Custom), meta = (BlueprintSpawnableComponent)) class RWTHVRTOOLKIT_API UIntenSelectable : public UActorComponent { GENERATED_BODY() @@ -24,19 +24,21 @@ public: UPROPERTY(EditAnywhere, BlueprintReadWrite) UIntenSelectableScoring* ScoringBehaviour; - + UPROPERTY(EditAnywhere, BlueprintReadWrite) TArray<UHoverBehaviour*> OnSelectBehaviours; - + UPROPERTY(EditAnywhere, BlueprintReadWrite) TArray<UActionBehaviour*> OnClickBehaviours; - + public: UIntenSelectable(); - TPair<FHitResult, float> GetBestPointScorePair(const FVector& ConeOrigin, const FVector& ConeForwardDirection, const float ConeBackwardShiftDistance, const float ConeAngle, const float LastValue, const float DeltaTime) const; - + TPair<FHitResult, float> GetBestPointScorePair(const FVector& ConeOrigin, const FVector& ConeForwardDirection, + 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); diff --git a/Source/RWTHVRToolkit/Public/Interaction/Interactables/IntenSelect/IntenSelectableCircleScoring.h b/Source/RWTHVRToolkit/Public/Interaction/Interactables/IntenSelect/IntenSelectableCircleScoring.h index d77f11e2d9b2e64a160b1c6695105fcd712f14d2..28046b36670ec03e2f8333b7a46d8d4d50ff6c28 100644 --- a/Source/RWTHVRToolkit/Public/Interaction/Interactables/IntenSelect/IntenSelectableCircleScoring.h +++ b/Source/RWTHVRToolkit/Public/Interaction/Interactables/IntenSelect/IntenSelectableCircleScoring.h @@ -6,7 +6,7 @@ #include "IntenSelectableScoring.h" #include "IntenSelectableCircleScoring.generated.h" -UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) ) +UCLASS(ClassGroup = (Custom), meta = (BlueprintSpawnableComponent)) class RWTHVRTOOLKIT_API UIntenSelectableCircleScoring : public UIntenSelectableScoring { GENERATED_BODY() @@ -16,13 +16,15 @@ protected: public: UIntenSelectableCircleScoring(); - + UPROPERTY(EditAnywhere) bool OnlyOutline = true; - + UPROPERTY(EditAnywhere) float Radius = 50; - - virtual TPair<FHitResult, float> GetBestPointScorePair(const FVector& ConeOrigin, const FVector& ConeForwardDirection, const float ConeBackwardShiftDistance, const float ConeAngle, const float LastValue, const float DeltaTime) override; + virtual TPair<FHitResult, float> GetBestPointScorePair(const FVector& ConeOrigin, + const FVector& ConeForwardDirection, + const float ConeBackwardShiftDistance, const float ConeAngle, + const float LastValue, const float DeltaTime) override; }; diff --git a/Source/RWTHVRToolkit/Public/Interaction/Interactables/IntenSelect/IntenSelectableCubeScoring.h b/Source/RWTHVRToolkit/Public/Interaction/Interactables/IntenSelect/IntenSelectableCubeScoring.h index 63fe569ed0019348b8206570efc736b223aaf991..34d8b637040fbfd282cfaeeea6b4891eb4f50e7d 100644 --- a/Source/RWTHVRToolkit/Public/Interaction/Interactables/IntenSelect/IntenSelectableCubeScoring.h +++ b/Source/RWTHVRToolkit/Public/Interaction/Interactables/IntenSelect/IntenSelectableCubeScoring.h @@ -4,17 +4,19 @@ #include "IntenSelectableScoring.h" #include "IntenSelectableCubeScoring.generated.h" -UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) ) +UCLASS(ClassGroup = (Custom), meta = (BlueprintSpawnableComponent)) class RWTHVRTOOLKIT_API UIntenSelectableCubeScoring : public UIntenSelectableScoring { GENERATED_BODY() protected: - static bool LineToLineIntersection(const FVector& FromA, const FVector& FromB, const FVector& ToA, const FVector& ToB, FVector& OutIntersection); - + 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); - virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override; + virtual void TickComponent(float DeltaTime, ELevelTick TickType, + FActorComponentTickFunction* ThisTickFunction) override; public: UIntenSelectableCubeScoring(); @@ -24,20 +26,24 @@ public: UPROPERTY(EditAnywhere) bool BackFaceCulling = false; - + UPROPERTY(EditAnywhere) bool OnlyOutline = false; - //UPROPERTY(EditAnywhere) - //float XLength = 100; - - //UPROPERTY(EditAnywhere) - //float YLength = 100; + // UPROPERTY(EditAnywhere) + // float XLength = 100; + + // UPROPERTY(EditAnywhere) + // float YLength = 100; + + // UPROPERTY(EditAnywhere) + // float ZLength = 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; + 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; + FVector GetClosestPointToRectangle(const FVector& StartPoint, const FVector& Direction, const FVector& Corner00, + const FVector& Corner01, const FVector& Corner10, const FVector& Corner11) const; }; diff --git a/Source/RWTHVRToolkit/Public/Interaction/Interactables/IntenSelect/IntenSelectableCylinderScoring.h b/Source/RWTHVRToolkit/Public/Interaction/Interactables/IntenSelect/IntenSelectableCylinderScoring.h index 658626b44159e53b3c3e3fa8dbe68e8952925f1a..b7fece39b285fe4fbcddc27897e321088a96ac30 100644 --- a/Source/RWTHVRToolkit/Public/Interaction/Interactables/IntenSelect/IntenSelectableCylinderScoring.h +++ b/Source/RWTHVRToolkit/Public/Interaction/Interactables/IntenSelect/IntenSelectableCylinderScoring.h @@ -4,17 +4,19 @@ #include "IntenSelectableScoring.h" #include "IntenSelectableCylinderScoring.generated.h" -UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) ) +UCLASS(ClassGroup = (Custom), meta = (BlueprintSpawnableComponent)) class RWTHVRTOOLKIT_API UIntenSelectableCylinderScoring : public UIntenSelectableScoring { GENERATED_BODY() protected: - static bool LineToLineIntersection(const FVector& FromA, const FVector& FromB, const FVector& ToA, const FVector& ToB, FVector& OutIntersection); - + static bool LineToLineIntersection(const FVector& FromA, const FVector& FromB, const FVector& ToA, + const FVector& ToB, FVector& OutIntersection); + FVector GetClosestSelectionPointTo(const FVector& Point, const FVector& Direction) const; - virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override; + virtual void TickComponent(float DeltaTime, ELevelTick TickType, + FActorComponentTickFunction* ThisTickFunction) override; public: UIntenSelectableCylinderScoring(); @@ -26,18 +28,20 @@ public: // Check if the property changed is MyMonitoredProperty if (PropertyChangedEvent.Property && PropertyChangedEvent.Property->GetName() == TEXT("LinePoints")) { - } } - + UPROPERTY(EditAnywhere) bool DrawDebug = true; - - virtual TPair<FHitResult, float> GetBestPointScorePair(const FVector& ConeOrigin, const FVector& ConeForwardDirection, const float ConeBackwardShiftDistance, const float ConeAngle, const float LastValue, const float DeltaTime) override; + + virtual TPair<FHitResult, float> GetBestPointScorePair(const FVector& ConeOrigin, + const FVector& ConeForwardDirection, + const float ConeBackwardShiftDistance, const float ConeAngle, + const float LastValue, const float DeltaTime) override; UPROPERTY(EditAnywhere) - TArray<FVector> LinePoints{FVector::UpVector * 50, FVector::DownVector * 50}; + TArray<FVector> LinePoints{FVector::UpVector * 50, FVector::DownVector * 50}; UPROPERTY(EditAnywhere) - float Radius = 50; + float Radius = 50; }; diff --git a/Source/RWTHVRToolkit/Public/Interaction/Interactables/IntenSelect/IntenSelectableLineScoring.h b/Source/RWTHVRToolkit/Public/Interaction/Interactables/IntenSelect/IntenSelectableLineScoring.h index 1a08b0f9855feba4d48ec85b5e63d2b3dbcbe0d0..fab919a87338f3bc4a17892f1024116cf320f9ec 100644 --- a/Source/RWTHVRToolkit/Public/Interaction/Interactables/IntenSelect/IntenSelectableLineScoring.h +++ b/Source/RWTHVRToolkit/Public/Interaction/Interactables/IntenSelect/IntenSelectableLineScoring.h @@ -4,26 +4,31 @@ #include "IntenSelectableScoring.h" #include "IntenSelectableLineScoring.generated.h" -UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) ) +UCLASS(ClassGroup = (Custom), meta = (BlueprintSpawnableComponent)) class RWTHVRTOOLKIT_API UIntenSelectableLineScoring : public UIntenSelectableScoring { GENERATED_BODY() protected: - static bool LineToLineIntersection(const FVector& FromA, const FVector& FromB, const FVector& ToA, const FVector& ToB, FVector& OutIntersection); - + static bool LineToLineIntersection(const FVector& FromA, const FVector& FromB, const FVector& ToA, + const FVector& ToB, FVector& OutIntersection); + FVector GetClosestSelectionPointTo(const FVector& Point, const FVector& Direction) const; - virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override; + virtual void TickComponent(float DeltaTime, ELevelTick TickType, + FActorComponentTickFunction* ThisTickFunction) override; public: UIntenSelectableLineScoring(); UPROPERTY(EditAnywhere) bool DrawDebug = true; - - virtual TPair<FHitResult, float> GetBestPointScorePair(const FVector& ConeOrigin, const FVector& ConeForwardDirection, const float ConeBackwardShiftDistance, const float ConeAngle, const float LastValue, const float DeltaTime) override; - UPROPERTY(EditAnywhere, meta=(EditFixedSize)) - TArray<FVector> LinePoints{FVector::RightVector * 50, FVector::LeftVector * 50}; + virtual TPair<FHitResult, float> GetBestPointScorePair(const FVector& ConeOrigin, + const FVector& ConeForwardDirection, + const float ConeBackwardShiftDistance, const float ConeAngle, + const float LastValue, const float DeltaTime) override; + + UPROPERTY(EditAnywhere, meta = (EditFixedSize)) + TArray<FVector> LinePoints{FVector::RightVector * 50, FVector::LeftVector * 50}; }; diff --git a/Source/RWTHVRToolkit/Public/Interaction/Interactables/IntenSelect/IntenSelectableMultiPointScoring.h b/Source/RWTHVRToolkit/Public/Interaction/Interactables/IntenSelect/IntenSelectableMultiPointScoring.h index 07c2f928ef120f7465c9f45359b99112090dfa2a..fa2742e320b50dc7930be04efec380802f6c0e7c 100644 --- a/Source/RWTHVRToolkit/Public/Interaction/Interactables/IntenSelect/IntenSelectableMultiPointScoring.h +++ b/Source/RWTHVRToolkit/Public/Interaction/Interactables/IntenSelect/IntenSelectableMultiPointScoring.h @@ -6,7 +6,7 @@ #include "IntenSelectableScoring.h" #include "IntenSelectableMultiPointScoring.generated.h" -UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) ) +UCLASS(ClassGroup = (Custom), meta = (BlueprintSpawnableComponent)) class RWTHVRTOOLKIT_API UIntenSelectableMultiPointScoring : public UIntenSelectableScoring { GENERATED_BODY() @@ -17,11 +17,13 @@ protected: public: UIntenSelectableMultiPointScoring(); - virtual TPair<FHitResult, float> GetBestPointScorePair(const FVector& ConeOrigin, const FVector& ConeForwardDirection, const float ConeBackwardShiftDistance, const float ConeAngle, const float LastValue, const float DeltaTime) override; + virtual TPair<FHitResult, float> GetBestPointScorePair(const FVector& ConeOrigin, + const FVector& ConeForwardDirection, + const float ConeBackwardShiftDistance, const float ConeAngle, + const float LastValue, const float DeltaTime) override; + + void UpdatePoints(); - void UpdatePoints(); - UPROPERTY(EditAnywhere, BlueprintReadWrite) TArray<FVector> PointsToSelect; - }; diff --git a/Source/RWTHVRToolkit/Public/Interaction/Interactables/IntenSelect/IntenSelectableRectangleScoring.h b/Source/RWTHVRToolkit/Public/Interaction/Interactables/IntenSelect/IntenSelectableRectangleScoring.h index 364b6c6852f272abacac97b96bd3b8510f5b350e..12eceb0e803def69c1672f676b50c0aa14d88014 100644 --- a/Source/RWTHVRToolkit/Public/Interaction/Interactables/IntenSelect/IntenSelectableRectangleScoring.h +++ b/Source/RWTHVRToolkit/Public/Interaction/Interactables/IntenSelect/IntenSelectableRectangleScoring.h @@ -4,17 +4,19 @@ #include "IntenSelectableScoring.h" #include "IntenSelectableRectangleScoring.generated.h" -UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) ) +UCLASS(ClassGroup = (Custom), meta = (BlueprintSpawnableComponent)) class RWTHVRTOOLKIT_API UIntenSelectableRectangleScoring : public UIntenSelectableScoring { GENERATED_BODY() protected: - static bool LineToLineIntersection(const FVector& FromA, const FVector& FromB, const FVector& ToA, const FVector& ToB, FVector& OutIntersection); - + static bool LineToLineIntersection(const FVector& FromA, const FVector& FromB, const FVector& ToA, + const FVector& ToB, FVector& OutIntersection); + FVector GetClosestSelectionPointTo(const FVector& Point, const FVector& Direction) const; - virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override; + virtual void TickComponent(float DeltaTime, ELevelTick TickType, + FActorComponentTickFunction* ThisTickFunction) override; public: UIntenSelectableRectangleScoring(); @@ -27,9 +29,12 @@ public: UPROPERTY(EditAnywhere) float XLength = 100; - + UPROPERTY(EditAnywhere) float YLength = 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; + + virtual TPair<FHitResult, float> GetBestPointScorePair(const FVector& ConeOrigin, + const FVector& ConeForwardDirection, + const float ConeBackwardShiftDistance, const float ConeAngle, + const float LastValue, const float DeltaTime) override; }; diff --git a/Source/RWTHVRToolkit/Public/Interaction/Interactables/IntenSelect/IntenSelectableScoring.h b/Source/RWTHVRToolkit/Public/Interaction/Interactables/IntenSelect/IntenSelectableScoring.h index 76a14940d273a9b89d226ba4714a9419413531b0..529fcd36af3cf04393313110b79f5c0f05a7e6cd 100644 --- a/Source/RWTHVRToolkit/Public/Interaction/Interactables/IntenSelect/IntenSelectableScoring.h +++ b/Source/RWTHVRToolkit/Public/Interaction/Interactables/IntenSelect/IntenSelectableScoring.h @@ -4,32 +4,37 @@ #include "Components/SceneComponent.h" #include "IntenSelectableScoring.generated.h" -UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent)) +UCLASS(ClassGroup = (Custom), meta = (BlueprintSpawnableComponent)) class RWTHVRTOOLKIT_API UIntenSelectableScoring : public USceneComponent { GENERATED_BODY() protected: - float GetScore(const FVector& ConeOrigin, const FVector& ConeForwardDirection, const float ConeBackwardShiftDistance, const float ConeAngle, const FVector& TestPoint, const float LastValue, const float DeltaTime); - + float GetScore(const FVector& ConeOrigin, const FVector& ConeForwardDirection, + const float ConeBackwardShiftDistance, const float ConeAngle, const FVector& TestPoint, + const float LastValue, const float DeltaTime); + public: UIntenSelectableScoring(); UPROPERTY(BlueprintReadOnly) float CurrentScore = 0; UPROPERTY(EditAnywhere) - bool IsSelectable = true; + bool IsSelectable = true; UPROPERTY(EditAnywhere) - float Stickiness = 10; + float Stickiness = 10; UPROPERTY(EditAnywhere) - float Snappiness = 15; + float Snappiness = 15; UPROPERTY(EditAnywhere) - float CompensationConstant = 0.8; + float CompensationConstant = 0.8; bool bOverwritingContrib = false; float Contrib = 0; - virtual TPair<FHitResult, float> GetBestPointScorePair(const FVector& ConeOrigin, const FVector& ConeForwardDirection, const float ConeBackwardShiftDistance, const float ConeAngle, const float LastValue, const float DeltaTime); + virtual TPair<FHitResult, float> GetBestPointScorePair(const FVector& ConeOrigin, + const FVector& ConeForwardDirection, + const float ConeBackwardShiftDistance, const float ConeAngle, + const float LastValue, const float DeltaTime); virtual void BeginPlay() override; }; diff --git a/Source/RWTHVRToolkit/Public/Interaction/Interactables/IntenSelect/IntenSelectableSinglePointScoring.h b/Source/RWTHVRToolkit/Public/Interaction/Interactables/IntenSelect/IntenSelectableSinglePointScoring.h index 8b8e80591cf06ad14145308bb7f046a29106fc7a..e7b53ddb2bf86cc238f946eb4a19d8d0138c5f1c 100644 --- a/Source/RWTHVRToolkit/Public/Interaction/Interactables/IntenSelect/IntenSelectableSinglePointScoring.h +++ b/Source/RWTHVRToolkit/Public/Interaction/Interactables/IntenSelect/IntenSelectableSinglePointScoring.h @@ -4,15 +4,18 @@ #include "IntenSelectableScoring.h" #include "IntenSelectableSinglepointScoring.generated.h" -UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) ) +UCLASS(ClassGroup = (Custom), meta = (BlueprintSpawnableComponent)) class RWTHVRTOOLKIT_API UIntenSelectableSinglePointScoring : public UIntenSelectableScoring { GENERATED_BODY() public: UIntenSelectableSinglePointScoring(); - - virtual TPair<FHitResult, float> GetBestPointScorePair(const FVector& ConeOrigin, const FVector& ConeForwardDirection, const float ConeBackwardShiftDistance, const float ConeAngle, const float LastValue, const float DeltaTime) override; + + virtual TPair<FHitResult, float> GetBestPointScorePair(const FVector& ConeOrigin, + const FVector& ConeForwardDirection, + const float ConeBackwardShiftDistance, const float ConeAngle, + const float LastValue, const float DeltaTime) override; virtual void BeginPlay() override; }; diff --git a/Source/RWTHVRToolkit/Public/Interaction/Interactables/IntenSelect/IntenSelectableSphereScoring.h b/Source/RWTHVRToolkit/Public/Interaction/Interactables/IntenSelect/IntenSelectableSphereScoring.h index a3842bc0c795e7745f7e50d41dfc260d3e4b3d5b..42100b8d9857b49a5e21bb8062ed99602f532cc7 100644 --- a/Source/RWTHVRToolkit/Public/Interaction/Interactables/IntenSelect/IntenSelectableSphereScoring.h +++ b/Source/RWTHVRToolkit/Public/Interaction/Interactables/IntenSelect/IntenSelectableSphereScoring.h @@ -4,7 +4,7 @@ #include "IntenSelectableScoring.h" #include "IntenSelectableSphereScoring.generated.h" -UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) ) +UCLASS(ClassGroup = (Custom), meta = (BlueprintSpawnableComponent)) class RWTHVRTOOLKIT_API UIntenSelectableSphereScoring : public UIntenSelectableScoring { GENERATED_BODY() @@ -17,16 +17,18 @@ public: UPROPERTY(EditAnywhere) UMaterialInstance* DebugMaterial; - + UPROPERTY(EditAnywhere) bool OnlyOutline = false; - + UPROPERTY(EditAnywhere) float Radius = 50; - + UPROPERTY(EditAnywhere) bool DrawDebug = true; - - virtual TPair<FHitResult, float> GetBestPointScorePair(const FVector& ConeOrigin, const FVector& ConeForwardDirection, const float ConeBackwardShiftDistance, const float ConeAngle, const float LastValue, const float DeltaTime) override; + virtual TPair<FHitResult, float> GetBestPointScorePair(const FVector& ConeOrigin, + const FVector& ConeForwardDirection, + const float ConeBackwardShiftDistance, const float ConeAngle, + const float LastValue, const float DeltaTime) override; }; diff --git a/Source/RWTHVRToolkit/Public/Pawn/IntenSelectComponent.h b/Source/RWTHVRToolkit/Public/Pawn/IntenSelectComponent.h index 7414739ee123aebe3006731f8c52854f7b5a6432..ebb11aae55a37e1cd0974a0578c0ea3c712a3715 100644 --- a/Source/RWTHVRToolkit/Public/Pawn/IntenSelectComponent.h +++ b/Source/RWTHVRToolkit/Public/Pawn/IntenSelectComponent.h @@ -3,12 +3,10 @@ #pragma once #pragma region /** Includes */ -#include "Kismet/KismetSystemLibrary.h" #include "Components/SplineComponent.h" #include "Components/SplineMeshComponent.h" #include "CoreMinimal.h" #include "InputAction.h" -#include "Kismet/GameplayStatics.h" #include "Components/WidgetInteractionComponent.h" #include "Interaction/Interactables/IntenSelect/IntenSelectable.h" #include "IntenSelectComponent.generated.h" @@ -16,14 +14,14 @@ DECLARE_DYNAMIC_MULTICAST_DELEGATE(FOnNewComponent); -UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) ) +UCLASS(ClassGroup = (Custom), meta = (BlueprintSpawnableComponent)) class RWTHVRTOOLKIT_API UIntenSelectComponent : public UWidgetInteractionComponent { GENERATED_BODY() - -// VARIABLES - + + // VARIABLES + #pragma region /** INTERNAL VARIABLES */ private: float SphereCastRadius; @@ -33,104 +31,104 @@ private: FVector WidgetFocusPoint; UPROPERTY() - UWidgetComponent* LastFocusedWidget; + UWidgetComponent* LastFocusedWidget; UPROPERTY() - TMap<UIntenSelectable*, float> ScoreMap; + TMap<UIntenSelectable*, float> ScoreMap; UPROPERTY() - TMap<UIntenSelectable*, FHitResult> ContactPointMap; + TMap<UIntenSelectable*, FHitResult> ContactPointMap; UPROPERTY() - UIntenSelectable* CurrentSelection; + UIntenSelectable* CurrentSelection; UPROPERTY() - UIntenSelectable* LastKnownSelection; + UIntenSelectable* LastKnownSelection; UPROPERTY() - FVector LastKnownGrabPoint; + FVector LastKnownGrabPoint; UPROPERTY() - UStaticMeshComponent* DebugConeMeshComponent; + UStaticMeshComponent* DebugConeMeshComponent; UPROPERTY() - UStaticMeshComponent* ForwardRayMeshComponent; + UStaticMeshComponent* ForwardRayMeshComponent; UPROPERTY() - USplineComponent* SplineComponent; + USplineComponent* SplineComponent; UPROPERTY() - USplineMeshComponent* SplineMeshComponent; + USplineMeshComponent* SplineMeshComponent; UPROPERTY() - UMaterialParameterCollectionInstance* ParameterCollectionInstance; + UMaterialParameterCollectionInstance* ParameterCollectionInstance; UPROPERTY() - UStaticMesh* DebugConeMesh; + UStaticMesh* DebugConeMesh; UPROPERTY() - UMaterialInterface* DebugConeMaterial; + UMaterialInterface* DebugConeMaterial; UPROPERTY() - UStaticMesh* ForwardRayMesh; + UStaticMesh* ForwardRayMesh; #pragma endregion #pragma region /** SETTINGS */ public: UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "IntenSelect|Settings") - bool SetActiveOnStart = true; + bool SetActiveOnStart = true; UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "IntenSelect|Settings") - float MaxSelectionDistance = 5000; + float MaxSelectionDistance = 5000; UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "IntenSelect|Settings") - float SelectionConeAngle = 5; + float SelectionConeAngle = 5; UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "IntenSelect|Settings") - float SplineCurvatureStrength = 1; + float SplineCurvatureStrength = 1; UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "IntenSelect|Settings") - float ConeBackwardShiftDistance = 0; + float ConeBackwardShiftDistance = 0; UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "IntenSelect|Settings") - float MaxClickStickAngle = 10; + float MaxClickStickAngle = 10; UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "IntenSelect|Settings") - float ForwardRayWidth = 0.01; + float ForwardRayWidth = 0.01; #pragma endregion #pragma region /** REFERENCES */ public: - UPROPERTY(EditAnywhere, Category= "IntenSelect|References") - UStaticMesh* SplineMesh; UPROPERTY(EditAnywhere, Category = "IntenSelect|References") - UMaterialInterface* SplineMaterial; + UStaticMesh* SplineMesh; UPROPERTY(EditAnywhere, Category = "IntenSelect|References") - UMaterialInterface* ForwardRayMaterial; + UMaterialInterface* SplineMaterial; UPROPERTY(EditAnywhere, Category = "IntenSelect|References") - UHapticFeedbackEffect_Base* SelectionFeedbackHaptic; + UMaterialInterface* ForwardRayMaterial; UPROPERTY(EditAnywhere, Category = "IntenSelect|References") - USoundBase* OnSelectSound; + UHapticFeedbackEffect_Base* SelectionFeedbackHaptic; UPROPERTY(EditAnywhere, Category = "IntenSelect|References") - UMaterialParameterCollection* MaterialParamCollection; + USoundBase* OnSelectSound; UPROPERTY(EditAnywhere, Category = "IntenSelect|References") - UCurveFloat* ForwardRayTransparencyCurve; + UMaterialParameterCollection* MaterialParamCollection; + UPROPERTY(EditAnywhere, Category = "IntenSelect|References") + UCurveFloat* ForwardRayTransparencyCurve; #pragma endregion #pragma region /** DEBUG */ public: UPROPERTY(EditAnywhere, Category = "IntenSelect|Debug") - bool bDrawDebugCone = false; + bool bDrawDebugCone = false; UPROPERTY(EditAnywhere, Category = "IntenSelect|Debug") - bool bDrawForwardRay = true; + bool bDrawForwardRay = true; UPROPERTY(EditAnywhere, Category = "IntenSelect|Debug") - FRotator DebugConeRotation = FRotator(90, 0, 0); + FRotator DebugConeRotation = FRotator(90, 0, 0); UPROPERTY(EditAnywhere, Category = "IntenSelect|Debug") - FVector DebugConeScale = FVector(1,1,1); + FVector DebugConeScale = FVector(1, 1, 1); UPROPERTY(EditAnywhere, Category = "IntenSelect|Debug") - FVector DebugConePosition = FVector(-90, 0, 0); + FVector DebugConePosition = FVector(-90, 0, 0); UPROPERTY(EditAnywhere, Category = "IntenSelect|Debug") - float DebugRayTransparency = 1; + float DebugRayTransparency = 1; #pragma endregion #pragma region /** Input */ public: UPROPERTY(EditAnywhere, Category = "IntenSelect|Input") - UInputAction* InputClick; - + UInputAction* InputClick; + #pragma endregion - + #pragma region /** EVENTS */ public: UPROPERTY(BlueprintAssignable) - FOnNewComponent OnNewSelectedEvent; + FOnNewComponent OnNewSelectedEvent; #pragma endregion -// FUNCTIONS - + // FUNCTIONS + #pragma region /** INITIALIZATION */ private: void InitInputBindings(); @@ -140,28 +138,29 @@ private: void InitForwardRayMeshComponent(); void InitMaterialParamCollection(); #pragma endregion - + #pragma region /** SCORING */ private: float CalculateSphereCastRadius() const; bool GetActorsFromSphereCast(const FVector& SphereCastStart, TArray<FHitResult>& OutHits) const; - bool CheckPointInCone(const FVector ConeStartPoint, const FVector ConeForward, const FVector PointToTest, const float Angle) const; + bool CheckPointInCone(const FVector ConeStartPoint, const FVector ConeForward, const FVector PointToTest, + const float Angle) const; UIntenSelectable* GetMaxScoreActor(const float DeltaTime); #pragma endregion - + #pragma region /** VISUALS */ private: void DrawSelectionCurve(const FVector& EndPoint) const; void AddSplinePointsDefault(const FVector& StartPoint, const FVector& Forward, const FVector& EndPoint) const; void UpdateForwardRay(const FVector& ReferencePoint) const; #pragma endregion - + #pragma region /** RAYCASTING */ private: void HandleWidgetInteraction(); TOptional<FHitResult> RaytraceForFirstHit(const FVector& Start, const FVector& End) const; #pragma endregion - + #pragma region /** INPUT-HANDLING */ private: UFUNCTION(BlueprintCallable) @@ -177,25 +176,26 @@ private: void HandleNoActorSelected(); void HandleActorSelected(UIntenSelectable* NewSelection); FVector ConvertNetVector(FVector_NetQuantize v); -#pragma endregion - -public: +#pragma endregion + +public: UIntenSelectComponent(const FObjectInitializer& ObjectInitializer); #pragma region /** SELECTION */ void SelectObject(UIntenSelectable* SelectableComponent, AActor* SelectedBy); void Unselect(); -#pragma endregion +#pragma endregion virtual void SetActive(bool bNewActive, bool bReset) override; - + UFUNCTION(BlueprintNativeEvent) - void OnNewSelected(UIntenSelectable* Selection); + void OnNewSelected(UIntenSelectable* Selection); protected: // Called when the game starts virtual void BeginPlay() override; // Called every frame - virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override; + virtual void TickComponent(float DeltaTime, ELevelTick TickType, + FActorComponentTickFunction* ThisTickFunction) override; }; diff --git a/Source/RWTHVRToolkitEditor/Private/Interaction/IntenSelectableCircleScoringVisualizer.cpp b/Source/RWTHVRToolkitEditor/Private/Interaction/IntenSelectableCircleScoringVisualizer.cpp index 7a77b74e67202fa90191d7d537dfd33c9a1c986f..b0dc19d143b2f2f2edc95dac79ee2c3f27690ff7 100644 --- a/Source/RWTHVRToolkitEditor/Private/Interaction/IntenSelectableCircleScoringVisualizer.cpp +++ b/Source/RWTHVRToolkitEditor/Private/Interaction/IntenSelectableCircleScoringVisualizer.cpp @@ -9,27 +9,29 @@ IMPLEMENT_HIT_PROXY(FCircleProxy, HComponentVisProxy); FIntenSelectableCircleScoringVisualizer::FIntenSelectableCircleScoringVisualizer() { - PointsProperty = FindFProperty<FProperty>(UIntenSelectableCircleScoring::StaticClass(), GET_MEMBER_NAME_CHECKED(UIntenSelectableCircleScoring, Radius)); + PointsProperty = FindFProperty<FProperty>(UIntenSelectableCircleScoring::StaticClass(), + GET_MEMBER_NAME_CHECKED(UIntenSelectableCircleScoring, Radius)); } -FIntenSelectableCircleScoringVisualizer::~FIntenSelectableCircleScoringVisualizer() -{ -} +FIntenSelectableCircleScoringVisualizer::~FIntenSelectableCircleScoringVisualizer() {} FVector FIntenSelectableCircleScoringVisualizer::GetCurrentVectorWorld() const { switch (CurrentSelectionIndex) { - 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; - } + 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; + } default: return FVector::ZeroVector; } @@ -37,7 +39,8 @@ FVector FIntenSelectableCircleScoringVisualizer::GetCurrentVectorWorld() const bool FIntenSelectableCircleScoringVisualizer::IsVisualizingArchetype() const { - return GetEditedScoringComponent() && GetEditedScoringComponent()->GetOwner() && FActorEditorUtils::IsAPreviewOrInactiveActor(GetEditedScoringComponent()->GetOwner()); + return GetEditedScoringComponent() && GetEditedScoringComponent()->GetOwner() && + FActorEditorUtils::IsAPreviewOrInactiveActor(GetEditedScoringComponent()->GetOwner()); } UIntenSelectableCircleScoring* FIntenSelectableCircleScoringVisualizer::GetEditedScoringComponent() const @@ -45,10 +48,7 @@ UIntenSelectableCircleScoring* FIntenSelectableCircleScoringVisualizer::GetEdite return Cast<UIntenSelectableCircleScoring>(ScoringBehaviourPropertyPath.GetComponent()); } -bool FIntenSelectableCircleScoringVisualizer::ShowWhenSelected() -{ - return false; -} +bool FIntenSelectableCircleScoringVisualizer::ShowWhenSelected() { return false; } bool FIntenSelectableCircleScoringVisualizer::ShouldShowForSelectedSubcomponents(const UActorComponent* Component) { @@ -56,24 +56,27 @@ 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")); - + // UE_LOG(LogTemp, Warning, TEXT("Handling Click")); + if (VisProxy && VisProxy->Component.IsValid()) { bEditing = true; - + if (VisProxy->IsA(FCircleProxy::StaticGetType())) { - const UIntenSelectableCircleScoring* T = Cast<const UIntenSelectableCircleScoring>(VisProxy->Component.Get()); + const UIntenSelectableCircleScoring* T = + Cast<const UIntenSelectableCircleScoring>(VisProxy->Component.Get()); ScoringBehaviourPropertyPath = FComponentPropertyPath(T); - + FCircleProxy* Proxy = (FCircleProxy*)VisProxy; CurrentSelectionIndex = Proxy->TargetIndex; - }else + } + else { CurrentSelectionIndex = INDEX_NONE; } @@ -86,90 +89,96 @@ bool FIntenSelectableCircleScoringVisualizer::VisProxyHandleClick(FEditorViewpor return bEditing; } -void FIntenSelectableCircleScoringVisualizer::DrawVisualization(const UActorComponent* Component, const FSceneView* View, FPrimitiveDrawInterface* PDI) { +void FIntenSelectableCircleScoringVisualizer::DrawVisualization(const UActorComponent* Component, + const FSceneView* View, FPrimitiveDrawInterface* PDI) +{ const UIntenSelectableCircleScoring* ComponentCasted = Cast<UIntenSelectableCircleScoring>(Component); - + if (ComponentCasted != nullptr) { PDI->SetHitProxy(new FCircleProxy(Component, 0)); - + const FVector CenterWorld = ComponentCasted->GetComponentLocation(); PDI->DrawPoint(CenterWorld, FColor::Green, 20.f, SDPG_Foreground); PDI->SetHitProxy(nullptr); - + PDI->SetHitProxy(new FCircleProxy(Component, 1)); - const FVector NormalWorldPoint = ComponentCasted->GetComponentTransform().TransformPosition(FVector::ForwardVector); + const FVector NormalWorldPoint = + ComponentCasted->GetComponentTransform().TransformPosition(FVector::ForwardVector); const FVector WorldNormalDir = NormalWorldPoint - CenterWorld; 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); + DrawCircle(PDI, CenterWorld, Y.GetSafeNormal(), Z.GetSafeNormal(), FColor::Green, ComponentCasted->Radius, 100, + SDPG_Foreground, 2); PDI->SetHitProxy(nullptr); - } } -void FIntenSelectableCircleScoringVisualizer::EndEditing() -{ - -} +void FIntenSelectableCircleScoringVisualizer::EndEditing() {} UActorComponent* FIntenSelectableCircleScoringVisualizer::GetEditedComponent() const { return GetEditedScoringComponent(); } -bool FIntenSelectableCircleScoringVisualizer::HandleInputDelta(FEditorViewportClient* ViewportClient, FViewport* Viewport, - FVector& DeltaTranslate, FRotator& DeltaRotate, FVector& DeltaScale) +bool FIntenSelectableCircleScoringVisualizer::HandleInputDelta(FEditorViewportClient* ViewportClient, + 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()); + // UE_LOG(LogTemp, Warning, TEXT("Current Selection! %s"), *DeltaTranslate.ToString()); - if(CurrentSelectionIndex == 0) + if (CurrentSelectionIndex == 0) { const FVector LocalCenter = GetEditedScoringComponent()->GetComponentLocation(); const FVector NewCenter = LocalCenter + DeltaTranslate; GetEditedScoringComponent()->SetWorldLocation(NewCenter); GetEditedScoringComponent()->AddWorldRotation(DeltaRotate); - + bHandled = true; - }else if(CurrentSelectionIndex == 1) + } + else if (CurrentSelectionIndex == 1) { const FVector CenterWorld = GetEditedScoringComponent()->GetComponentLocation(); - const FVector NormalWorldPoint = GetEditedScoringComponent()->GetComponentTransform().TransformPosition(FVector::ForwardVector); + const FVector NormalWorldPoint = + GetEditedScoringComponent()->GetComponentTransform().TransformPosition(FVector::ForwardVector); const FVector WorldNormalDir = NormalWorldPoint - CenterWorld; - const FVector RadiusVector = WorldNormalDir.RotateAngleAxis(90, GetEditedScoringComponent()->GetRightVector()).GetSafeNormal() * GetEditedScoringComponent()->Radius; - - const FVector ClampedTranslate = DeltaTranslate.Size() > 100 ? DeltaTranslate.GetSafeNormal() * 100 : DeltaTranslate; - GetEditedScoringComponent()->Radius = FVector::Distance(CenterWorld, CenterWorld + RadiusVector + ClampedTranslate); + const FVector RadiusVector = + WorldNormalDir.RotateAngleAxis(90, GetEditedScoringComponent()->GetRightVector()).GetSafeNormal() * + GetEditedScoringComponent()->Radius; + + const FVector ClampedTranslate = + DeltaTranslate.Size() > 100 ? DeltaTranslate.GetSafeNormal() * 100 : DeltaTranslate; + GetEditedScoringComponent()->Radius = + FVector::Distance(CenterWorld, CenterWorld + RadiusVector + ClampedTranslate); bHandled = true; } TArray<FProperty*> Properties; Properties.Add(PointsProperty); NotifyPropertiesModified(GetEditedScoringComponent(), Properties, EPropertyChangeType::ValueSet); - }else + } + else { - //UE_LOG(LogTemp, Warning, TEXT("No Current Selection!")); + // 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) { OutLocation = GetCurrentVectorWorld(); - + return true; } return false; } - - diff --git a/Source/RWTHVRToolkitEditor/Private/Interaction/IntenSelectableCubeScoringVisualizer.cpp b/Source/RWTHVRToolkitEditor/Private/Interaction/IntenSelectableCubeScoringVisualizer.cpp index 97e3f43c8bf5d83c7866c1ab3b87b9998bca8c91..719a5bc4eca4e981730cd047cfff1c21d6a06e39 100644 --- a/Source/RWTHVRToolkitEditor/Private/Interaction/IntenSelectableCubeScoringVisualizer.cpp +++ b/Source/RWTHVRToolkitEditor/Private/Interaction/IntenSelectableCubeScoringVisualizer.cpp @@ -10,14 +10,12 @@ IMPLEMENT_HIT_PROXY(FCubeProxy, HComponentVisProxy); -FIntenSelectableCubeScoringVisualizer::FIntenSelectableCubeScoringVisualizer() : DebugMaterial(FColoredMaterialRenderProxy(GEngine->ConstraintLimitMaterial->GetRenderProxy(), FColor::Green)) +FIntenSelectableCubeScoringVisualizer::FIntenSelectableCubeScoringVisualizer() : + DebugMaterial(FColoredMaterialRenderProxy(GEngine->ConstraintLimitMaterial->GetRenderProxy(), FColor::Green)) { - } -FIntenSelectableCubeScoringVisualizer::~FIntenSelectableCubeScoringVisualizer() -{ -} +FIntenSelectableCubeScoringVisualizer::~FIntenSelectableCubeScoringVisualizer() {} FVector FIntenSelectableCubeScoringVisualizer::GetCurrentVectorWorld() const { @@ -26,7 +24,8 @@ FVector FIntenSelectableCubeScoringVisualizer::GetCurrentVectorWorld() const bool FIntenSelectableCubeScoringVisualizer::IsVisualizingArchetype() const { - return GetEditedScoringComponent() && GetEditedScoringComponent()->GetOwner() && FActorEditorUtils::IsAPreviewOrInactiveActor(GetEditedScoringComponent()->GetOwner()); + return GetEditedScoringComponent() && GetEditedScoringComponent()->GetOwner() && + FActorEditorUtils::IsAPreviewOrInactiveActor(GetEditedScoringComponent()->GetOwner()); } UIntenSelectableCubeScoring* FIntenSelectableCubeScoringVisualizer::GetEditedScoringComponent() const @@ -34,10 +33,7 @@ UIntenSelectableCubeScoring* FIntenSelectableCubeScoringVisualizer::GetEditedSco return Cast<UIntenSelectableCubeScoring>(ScoringBehaviourPropertyPath.GetComponent()); } -bool FIntenSelectableCubeScoringVisualizer::ShowWhenSelected() -{ - return false; -} +bool FIntenSelectableCubeScoringVisualizer::ShowWhenSelected() { return false; } bool FIntenSelectableCubeScoringVisualizer::ShouldShowForSelectedSubcomponents(const UActorComponent* Component) { @@ -45,24 +41,26 @@ bool FIntenSelectableCubeScoringVisualizer::ShouldShowForSelectedSubcomponents(c } bool FIntenSelectableCubeScoringVisualizer::VisProxyHandleClick(FEditorViewportClient* InViewportClient, - HComponentVisProxy* VisProxy, const FViewportClick& Click) + HComponentVisProxy* VisProxy, + const FViewportClick& Click) { bool bEditing = false; - //UE_LOG(LogTemp, Warning, TEXT("Handling Click")); - + // UE_LOG(LogTemp, Warning, TEXT("Handling Click")); + if (VisProxy && VisProxy->Component.IsValid()) { bEditing = true; - + if (VisProxy->IsA(FCubeProxy::StaticGetType())) { const UIntenSelectableCubeScoring* T = Cast<const UIntenSelectableCubeScoring>(VisProxy->Component.Get()); ScoringBehaviourPropertyPath = FComponentPropertyPath(T); - + FCubeProxy* Proxy = (FCubeProxy*)VisProxy; CurrentSelectionIndex = Proxy->TargetIndex; - }else + } + else { CurrentSelectionIndex = INDEX_NONE; } @@ -75,26 +73,25 @@ bool FIntenSelectableCubeScoringVisualizer::VisProxyHandleClick(FEditorViewportC return bEditing; } -void FIntenSelectableCubeScoringVisualizer::DrawVisualization(const UActorComponent* Component, const FSceneView* View, FPrimitiveDrawInterface* PDI) { +void FIntenSelectableCubeScoringVisualizer::DrawVisualization(const UActorComponent* Component, const FSceneView* View, + FPrimitiveDrawInterface* PDI) +{ const UIntenSelectableCubeScoring* ComponentCasted = Cast<UIntenSelectableCubeScoring>(Component); - + if (ComponentCasted != nullptr) { PDI->SetHitProxy(new FCubeProxy(Component, 0)); - + const auto Scale = ComponentCasted->GetRelativeTransform().GetScale3D(); const FVector Radii{Scale.X, Scale.Y, Scale.Z}; DrawBox(PDI, ComponentCasted->GetComponentTransform().ToMatrixNoScale(), Radii / 2, &DebugMaterial, 0); PDI->DrawPoint(ComponentCasted->GetComponentLocation(), FColor::Green, 20, 0); - + PDI->SetHitProxy(nullptr); } } -void FIntenSelectableCubeScoringVisualizer::EndEditing() -{ - -} +void FIntenSelectableCubeScoringVisualizer::EndEditing() {} UActorComponent* FIntenSelectableCubeScoringVisualizer::GetEditedComponent() const { @@ -102,13 +99,14 @@ UActorComponent* FIntenSelectableCubeScoringVisualizer::GetEditedComponent() con } bool FIntenSelectableCubeScoringVisualizer::HandleInputDelta(FEditorViewportClient* ViewportClient, FViewport* Viewport, - FVector& DeltaTranslate, FRotator& DeltaRotate, FVector& DeltaScale) + FVector& DeltaTranslate, FRotator& DeltaRotate, + FVector& DeltaScale) { bool bHandled = false; if (CurrentSelectionIndex != INDEX_NONE) { - //UE_LOG(LogTemp, Warning, TEXT("Current Selection! %s"), *DeltaTranslate.ToString()); + // UE_LOG(LogTemp, Warning, TEXT("Current Selection! %s"), *DeltaTranslate.ToString()); const FVector LocalCenter = GetEditedScoringComponent()->GetComponentLocation(); const FVector NewCenter = LocalCenter + DeltaTranslate; @@ -116,32 +114,31 @@ bool FIntenSelectableCubeScoringVisualizer::HandleInputDelta(FEditorViewportClie GetEditedScoringComponent()->AddWorldRotation(DeltaRotate); auto Scale = GetEditedScoringComponent()->GetRelativeTransform().GetScale3D(); - + Scale.X += DeltaScale.X * 3; Scale.Y += DeltaScale.Y * 3; Scale.Z += DeltaScale.Z * 3; - + GetEditedScoringComponent()->GetRelativeTransform().SetScale3D(Scale); bHandled = true; - }else + } + else { - //UE_LOG(LogTemp, Warning, TEXT("No Current Selection!")); + // UE_LOG(LogTemp, Warning, TEXT("No Current Selection!")); } return bHandled; } bool FIntenSelectableCubeScoringVisualizer::GetWidgetLocation(const FEditorViewportClient* ViewportClient, - FVector& OutLocation) const + FVector& OutLocation) const { if (CurrentSelectionIndex != INDEX_NONE) { OutLocation = GetCurrentVectorWorld(); - + return true; } return false; } - - diff --git a/Source/RWTHVRToolkitEditor/Private/Interaction/IntenSelectableCylinderScoringVisualizer.cpp b/Source/RWTHVRToolkitEditor/Private/Interaction/IntenSelectableCylinderScoringVisualizer.cpp index 7dc319633ee56cc884feb3bb1a01737483afcfc2..076cf8e42e290a4bfb229c3b19c029f664ecdde8 100644 --- a/Source/RWTHVRToolkitEditor/Private/Interaction/IntenSelectableCylinderScoringVisualizer.cpp +++ b/Source/RWTHVRToolkitEditor/Private/Interaction/IntenSelectableCylinderScoringVisualizer.cpp @@ -4,40 +4,39 @@ IMPLEMENT_HIT_PROXY(FCylinderPointProxy, HComponentVisProxy); -FIntenSelectableCylinderScoringVisualizer::FIntenSelectableCylinderScoringVisualizer() : DebugMaterial(FColoredMaterialRenderProxy(GEngine->ConstraintLimitMaterial->GetRenderProxy(), FColor::Green)) +FIntenSelectableCylinderScoringVisualizer::FIntenSelectableCylinderScoringVisualizer() : + DebugMaterial(FColoredMaterialRenderProxy(GEngine->ConstraintLimitMaterial->GetRenderProxy(), FColor::Green)) { - RadiusProperty = FindFProperty<FProperty>(UIntenSelectableCylinderScoring::StaticClass(), GET_MEMBER_NAME_CHECKED(UIntenSelectableCylinderScoring, Radius)); - PointsProperty = FindFProperty<FProperty>(UIntenSelectableCylinderScoring::StaticClass(), GET_MEMBER_NAME_CHECKED(UIntenSelectableCylinderScoring, LinePoints)); + RadiusProperty = FindFProperty<FProperty>(UIntenSelectableCylinderScoring::StaticClass(), + GET_MEMBER_NAME_CHECKED(UIntenSelectableCylinderScoring, Radius)); + PointsProperty = FindFProperty<FProperty>(UIntenSelectableCylinderScoring::StaticClass(), + GET_MEMBER_NAME_CHECKED(UIntenSelectableCylinderScoring, LinePoints)); } -FIntenSelectableCylinderScoringVisualizer::~FIntenSelectableCylinderScoringVisualizer() -{ - -} +FIntenSelectableCylinderScoringVisualizer::~FIntenSelectableCylinderScoringVisualizer() {} bool FIntenSelectableCylinderScoringVisualizer::IsVisualizingArchetype() const { - return GetEditedScoringComponent() && GetEditedScoringComponent()->GetOwner() && FActorEditorUtils::IsAPreviewOrInactiveActor(GetEditedScoringComponent()->GetOwner()); + return GetEditedScoringComponent() && GetEditedScoringComponent()->GetOwner() && + FActorEditorUtils::IsAPreviewOrInactiveActor(GetEditedScoringComponent()->GetOwner()); } FVector FIntenSelectableCylinderScoringVisualizer::GetCurrentVectorWorld() const { - if(GetEditedScoringComponent()) + if (GetEditedScoringComponent()) { - if(CurrentCylinderSelectionIndex == INDEX_NONE) + if (CurrentCylinderSelectionIndex == INDEX_NONE) { return GetEditedScoringComponent()->GetComponentLocation(); } - return GetEditedScoringComponent()->GetComponentTransform().TransformPositionNoScale(GetEditedScoringComponent()->LinePoints[CurrentCylinderSelectionIndex]); + return GetEditedScoringComponent()->GetComponentTransform().TransformPositionNoScale( + GetEditedScoringComponent()->LinePoints[CurrentCylinderSelectionIndex]); } return FVector::ZeroVector; } -bool FIntenSelectableCylinderScoringVisualizer::ShowWhenSelected() -{ - return false; -} +bool FIntenSelectableCylinderScoringVisualizer::ShowWhenSelected() { return false; } bool FIntenSelectableCylinderScoringVisualizer::ShouldShowForSelectedSubcomponents(const UActorComponent* Component) { @@ -45,24 +44,27 @@ bool FIntenSelectableCylinderScoringVisualizer::ShouldShowForSelectedSubcomponen } bool FIntenSelectableCylinderScoringVisualizer::VisProxyHandleClick(FEditorViewportClient* InViewportClient, - HComponentVisProxy* VisProxy, const FViewportClick& Click) + HComponentVisProxy* VisProxy, + const FViewportClick& Click) { bool bEditing = false; - //UE_LOG(LogTemp, Warning, TEXT("Handling Click")); - + // UE_LOG(LogTemp, Warning, TEXT("Handling Click")); + if (VisProxy && VisProxy->Component.IsValid()) { bEditing = true; - + if (VisProxy->IsA(FCylinderPointProxy::StaticGetType())) { - const UIntenSelectableCylinderScoring* T = Cast<const UIntenSelectableCylinderScoring>(VisProxy->Component.Get()); + const UIntenSelectableCylinderScoring* T = + Cast<const UIntenSelectableCylinderScoring>(VisProxy->Component.Get()); ScoringBehaviourPropertyPath = FComponentPropertyPath(T); - + FCylinderPointProxy* Proxy = (FCylinderPointProxy*)VisProxy; CurrentCylinderSelectionIndex = Proxy->TargetIndex; - }else + } + else { CurrentCylinderSelectionIndex = INDEX_NONE; } @@ -75,36 +77,40 @@ bool FIntenSelectableCylinderScoringVisualizer::VisProxyHandleClick(FEditorViewp return bEditing; } -void FIntenSelectableCylinderScoringVisualizer::DrawVisualization(const UActorComponent* Component, const FSceneView* View, FPrimitiveDrawInterface* PDI) { +void FIntenSelectableCylinderScoringVisualizer::DrawVisualization(const UActorComponent* Component, + const FSceneView* View, FPrimitiveDrawInterface* PDI) +{ const UIntenSelectableCylinderScoring* ComponentCasted = Cast<UIntenSelectableCylinderScoring>(Component); - + if (ComponentCasted != nullptr) { - for(int i = 0; i < ComponentCasted->LinePoints.Num(); i++) + for (int i = 0; i < ComponentCasted->LinePoints.Num(); i++) { PDI->SetHitProxy(new FCylinderPointProxy(Component, i)); - - FVector PointWorld = ComponentCasted->GetComponentTransform().TransformPositionNoScale(ComponentCasted->LinePoints[i]); + + FVector PointWorld = + ComponentCasted->GetComponentTransform().TransformPositionNoScale(ComponentCasted->LinePoints[i]); PDI->DrawPoint(PointWorld, FColor::Green, 20.f, SDPG_Foreground); - + PDI->SetHitProxy(nullptr); } - const FVector Start = ComponentCasted->GetComponentTransform().TransformPositionNoScale(ComponentCasted->LinePoints[0]); - const FVector End = ComponentCasted->GetComponentTransform().TransformPositionNoScale(ComponentCasted->LinePoints[1]); + const FVector Start = + ComponentCasted->GetComponentTransform().TransformPositionNoScale(ComponentCasted->LinePoints[0]); + const FVector End = + ComponentCasted->GetComponentTransform().TransformPositionNoScale(ComponentCasted->LinePoints[1]); PDI->DrawLine(Start, End, FColor::Green, SDPG_World); - const float Dist = (End-Start).Size(); - DrawCylinder(PDI, Start, End, ComponentCasted->Radius,20 , &DebugMaterial, 0); - + const float Dist = (End - Start).Size(); + DrawCylinder(PDI, Start, End, ComponentCasted->Radius, 20, &DebugMaterial, 0); } } void FIntenSelectableCylinderScoringVisualizer::EndEditing() { CurrentCylinderSelectionIndex = INDEX_NONE; - //GetEditedScoringComponent()->MarkRenderStateDirty(); - //GEditor->RedrawLevelEditingViewports(true); + // GetEditedScoringComponent()->MarkRenderStateDirty(); + // GEditor->RedrawLevelEditingViewports(true); } UActorComponent* FIntenSelectableCylinderScoringVisualizer::GetEditedComponent() const @@ -117,42 +123,46 @@ UIntenSelectableCylinderScoring* FIntenSelectableCylinderScoringVisualizer::GetE return Cast<UIntenSelectableCylinderScoring>(ScoringBehaviourPropertyPath.GetComponent()); } -bool FIntenSelectableCylinderScoringVisualizer::HandleInputDelta(FEditorViewportClient* ViewportClient, FViewport* Viewport, - FVector& DeltaTranslate, FRotator& DeltaRotate, FVector& DeltaScale) +bool FIntenSelectableCylinderScoringVisualizer::HandleInputDelta(FEditorViewportClient* ViewportClient, + FViewport* Viewport, FVector& DeltaTranslate, + FRotator& DeltaRotate, FVector& DeltaScale) { bool bHandled = false; UIntenSelectableCylinderScoring* ScoringComponent = GetEditedScoringComponent(); - if(ScoringComponent) + if (ScoringComponent) { if (CurrentCylinderSelectionIndex != INDEX_NONE) { ScoringComponent->Modify(); - - const FVector WorldSelection = ScoringComponent->GetComponentTransform().TransformPositionNoScale(ScoringComponent->LinePoints[CurrentCylinderSelectionIndex]); - const FVector NewWorldPos = ScoringComponent->GetComponentTransform().InverseTransformPositionNoScale(WorldSelection + DeltaTranslate); - + + const FVector WorldSelection = ScoringComponent->GetComponentTransform().TransformPositionNoScale( + ScoringComponent->LinePoints[CurrentCylinderSelectionIndex]); + const FVector NewWorldPos = ScoringComponent->GetComponentTransform().InverseTransformPositionNoScale( + WorldSelection + DeltaTranslate); + ScoringComponent->LinePoints[CurrentCylinderSelectionIndex] += DeltaTranslate; - - //UE_LOG(LogTemp, Warning, TEXT("Component: %s"), *(ScoringComponent->LinePoints[CurrentCylinderSelectionIndex]).ToString()); + + // UE_LOG(LogTemp, Warning, TEXT("Component: %s"), + // *(ScoringComponent->LinePoints[CurrentCylinderSelectionIndex]).ToString()); TArray<FProperty*> Properties; Properties.Add(PointsProperty); Properties.Add(RadiusProperty); NotifyPropertiesModified(ScoringComponent, Properties, EPropertyChangeType::ValueSet); - + /* const FVector Average = (ScoringComponent->LinePoints[0] + ScoringComponent->LinePoints[1]) / 2; ScoringComponent->SetWorldLocation(ScoringComponent->GetComponentTransform().TransformPositionNoScale(Average)); ScoringComponent->LinePoints[0] -= Average; ScoringComponent->LinePoints[1] -= Average; - + ScoringComponent->MarkRenderStateDirty(); GEditor->RedrawLevelEditingViewports(true); - + ScoringComponent->PostEditChange(); GEditor->NoteActorMovement(); @@ -162,39 +172,38 @@ bool FIntenSelectableCylinderScoringVisualizer::HandleInputDelta(FEditorViewport // If the component's package might be unsaved, mark it dirty to ensure changes aren't lost ScoringComponent->GetOuter()->MarkPackageDirty();*/ - + GEditor->RedrawLevelEditingViewports(true); - + bHandled = true; - }else + } + else { - //ScoringComponent->AddWorldOffset(DeltaTranslate); - //ScoringComponent->AddWorldRotation(DeltaRotate); - + // ScoringComponent->AddWorldOffset(DeltaTranslate); + // ScoringComponent->AddWorldRotation(DeltaRotate); + ScoringComponent->Modify(); ScoringComponent->MarkRenderStateDirty(); GEditor->RedrawLevelEditingViewports(true); - - //UE_LOG(LogTemp, Warning, TEXT("Cylinder Selected!")); - + + // UE_LOG(LogTemp, Warning, TEXT("Cylinder Selected!")); + return false; } } - + return bHandled; } bool FIntenSelectableCylinderScoringVisualizer::GetWidgetLocation(const FEditorViewportClient* ViewportClient, - FVector& OutLocation) const + FVector& OutLocation) const { if (GetEditedComponent() && CurrentCylinderSelectionIndex != INDEX_NONE) { OutLocation = GetCurrentVectorWorld(); - + return true; } return false; } - - diff --git a/Source/RWTHVRToolkitEditor/Private/Interaction/IntenSelectableLineScoringVisualizer.cpp b/Source/RWTHVRToolkitEditor/Private/Interaction/IntenSelectableLineScoringVisualizer.cpp index 6a5c4514610b7e234da2aabcbb12190969b3b107..59c8e11f79ec3f58b6588e89439f483a096913b1 100644 --- a/Source/RWTHVRToolkitEditor/Private/Interaction/IntenSelectableLineScoringVisualizer.cpp +++ b/Source/RWTHVRToolkitEditor/Private/Interaction/IntenSelectableLineScoringVisualizer.cpp @@ -8,35 +8,33 @@ IMPLEMENT_HIT_PROXY(FLinePointProxy, HComponentVisProxy); FIntenSelectableLineScoringVisualizer::FIntenSelectableLineScoringVisualizer() { - PointsProperty = FindFProperty<FProperty>(UIntenSelectableLineScoring::StaticClass(), GET_MEMBER_NAME_CHECKED(UIntenSelectableLineScoring, LinePoints)); + PointsProperty = FindFProperty<FProperty>(UIntenSelectableLineScoring::StaticClass(), + GET_MEMBER_NAME_CHECKED(UIntenSelectableLineScoring, LinePoints)); } -FIntenSelectableLineScoringVisualizer::~FIntenSelectableLineScoringVisualizer() -{ - -} +FIntenSelectableLineScoringVisualizer::~FIntenSelectableLineScoringVisualizer() {} FVector FIntenSelectableLineScoringVisualizer::GetCurrentVectorWorld() const { - if(CurrentLineSelectionIndex == INDEX_NONE) + if (CurrentLineSelectionIndex == INDEX_NONE) { return FVector::ZeroVector; - }else if(CurrentLineSelectionIndex == 2) + } + else if (CurrentLineSelectionIndex == 2) { return GetEditedScoringComponent()->GetComponentLocation(); } - return GetEditedScoringComponent()->GetComponentTransform().TransformPositionNoScale(GetEditedScoringComponent()->LinePoints[CurrentLineSelectionIndex]); + return GetEditedScoringComponent()->GetComponentTransform().TransformPositionNoScale( + GetEditedScoringComponent()->LinePoints[CurrentLineSelectionIndex]); } bool FIntenSelectableLineScoringVisualizer::IsVisualizingArchetype() const { - return (GetEditedScoringComponent() && GetEditedScoringComponent()->GetOwner() && FActorEditorUtils::IsAPreviewOrInactiveActor(GetEditedScoringComponent()->GetOwner())); + return (GetEditedScoringComponent() && GetEditedScoringComponent()->GetOwner() && + FActorEditorUtils::IsAPreviewOrInactiveActor(GetEditedScoringComponent()->GetOwner())); } -bool FIntenSelectableLineScoringVisualizer::ShowWhenSelected() -{ - return false; -} +bool FIntenSelectableLineScoringVisualizer::ShowWhenSelected() { return false; } bool FIntenSelectableLineScoringVisualizer::ShouldShowForSelectedSubcomponents(const UActorComponent* Component) { @@ -44,24 +42,26 @@ bool FIntenSelectableLineScoringVisualizer::ShouldShowForSelectedSubcomponents(c } bool FIntenSelectableLineScoringVisualizer::VisProxyHandleClick(FEditorViewportClient* InViewportClient, - HComponentVisProxy* VisProxy, const FViewportClick& Click) + HComponentVisProxy* VisProxy, + const FViewportClick& Click) { bool bEditing = false; - //UE_LOG(LogTemp, Warning, TEXT("Handling Click")); - + // UE_LOG(LogTemp, Warning, TEXT("Handling Click")); + if (VisProxy && VisProxy->Component.IsValid()) { bEditing = true; - + if (VisProxy->IsA(FLinePointProxy::StaticGetType())) { const UIntenSelectableLineScoring* T = Cast<const UIntenSelectableLineScoring>(VisProxy->Component.Get()); ScoringBehaviourPropertyPath = FComponentPropertyPath(T); - + FLinePointProxy* Proxy = (FLinePointProxy*)VisProxy; CurrentLineSelectionIndex = Proxy->TargetIndex; - }else + } + else { CurrentLineSelectionIndex = INDEX_NONE; } @@ -74,24 +74,28 @@ bool FIntenSelectableLineScoringVisualizer::VisProxyHandleClick(FEditorViewportC return bEditing; } -void FIntenSelectableLineScoringVisualizer::DrawVisualization(const UActorComponent* Component, const FSceneView* View, FPrimitiveDrawInterface* PDI) { +void FIntenSelectableLineScoringVisualizer::DrawVisualization(const UActorComponent* Component, const FSceneView* View, + FPrimitiveDrawInterface* PDI) +{ const UIntenSelectableLineScoring* ComponentCasted = Cast<UIntenSelectableLineScoring>(Component); - + if (ComponentCasted != nullptr && ComponentCasted->LinePoints.Num() == 2) { - for(int i = 0; i < ComponentCasted->LinePoints.Num() && i <= 2; i++) + for (int i = 0; i < ComponentCasted->LinePoints.Num() && i <= 2; i++) { PDI->SetHitProxy(new FLinePointProxy(Component, i)); - - FVector PointWorld = ComponentCasted->GetComponentTransform().TransformPosition(ComponentCasted->LinePoints[i]); + + FVector PointWorld = + ComponentCasted->GetComponentTransform().TransformPosition(ComponentCasted->LinePoints[i]); PDI->DrawPoint(PointWorld, FColor::Green, 20.f, SDPG_Foreground); - + PDI->SetHitProxy(nullptr); } PDI->SetHitProxy(new FLinePointProxy(Component, 2)); - - const FVector Start = ComponentCasted->GetComponentTransform().TransformPosition(ComponentCasted->LinePoints[0]); + + const FVector Start = + ComponentCasted->GetComponentTransform().TransformPosition(ComponentCasted->LinePoints[0]); const FVector End = ComponentCasted->GetComponentTransform().TransformPosition(ComponentCasted->LinePoints[1]); PDI->DrawLine(Start, End, FColor::Green, SDPG_Foreground, 3); @@ -116,66 +120,68 @@ UIntenSelectableLineScoring* FIntenSelectableLineScoringVisualizer::GetEditedSco } bool FIntenSelectableLineScoringVisualizer::HandleInputDelta(FEditorViewportClient* ViewportClient, FViewport* Viewport, - FVector& DeltaTranslate, FRotator& DeltaRotate, FVector& DeltaScale) + FVector& DeltaTranslate, FRotator& DeltaRotate, + FVector& DeltaScale) { bool bHandled = false; if (CurrentLineSelectionIndex != INDEX_NONE) { UIntenSelectableLineScoring* ScoringComponent = GetEditedScoringComponent(); - - if(ScoringComponent->LinePoints.Num() == 2) + + if (ScoringComponent->LinePoints.Num() == 2) { - if(CurrentLineSelectionIndex == 2) + if (CurrentLineSelectionIndex == 2) { ScoringComponent->AddWorldOffset(DeltaTranslate); ScoringComponent->AddWorldRotation(DeltaRotate); - }else + } + else { - //UE_LOG(LogTemp, Warning, TEXT("Current Selection! %s"), *DeltaTranslate.ToString()); - - const FVector WorldSelection = ScoringComponent->GetComponentTransform().TransformPositionNoScale(GetEditedScoringComponent()->LinePoints[CurrentLineSelectionIndex]); - const FVector NewWorldPos = ScoringComponent->GetComponentTransform().InverseTransformPositionNoScale(WorldSelection + DeltaTranslate); + // UE_LOG(LogTemp, Warning, TEXT("Current Selection! %s"), *DeltaTranslate.ToString()); + + const FVector WorldSelection = ScoringComponent->GetComponentTransform().TransformPositionNoScale( + GetEditedScoringComponent()->LinePoints[CurrentLineSelectionIndex]); + const FVector NewWorldPos = ScoringComponent->GetComponentTransform().InverseTransformPositionNoScale( + WorldSelection + DeltaTranslate); ScoringComponent->LinePoints[CurrentLineSelectionIndex] = NewWorldPos; const FVector Average = (ScoringComponent->LinePoints[0] + ScoringComponent->LinePoints[1]) / 2; - ScoringComponent->SetWorldLocation(ScoringComponent->GetComponentTransform().TransformPositionNoScale(Average)); + ScoringComponent->SetWorldLocation( + ScoringComponent->GetComponentTransform().TransformPositionNoScale(Average)); ScoringComponent->LinePoints[0] -= Average; ScoringComponent->LinePoints[1] -= Average; } - + TArray<FProperty*> Properties; Properties.Add(PointsProperty); NotifyPropertiesModified(ScoringComponent, Properties, EPropertyChangeType::ValueSet); - + ScoringComponent->MarkRenderStateDirty(); GEditor->RedrawLevelEditingViewports(true); bHandled = true; } - - - }else + } + else { - //UE_LOG(LogTemp, Warning, TEXT("No Current Selection!")); + // UE_LOG(LogTemp, Warning, TEXT("No Current Selection!")); } return bHandled; } bool FIntenSelectableLineScoringVisualizer::GetWidgetLocation(const FEditorViewportClient* ViewportClient, - FVector& OutLocation) const + FVector& OutLocation) const { if (GetEditedScoringComponent() && CurrentLineSelectionIndex != INDEX_NONE) { OutLocation = GetCurrentVectorWorld(); - + return true; } return false; } - - diff --git a/Source/RWTHVRToolkitEditor/Private/Interaction/IntenSelectableMultiPointScoringVisualizer.cpp b/Source/RWTHVRToolkitEditor/Private/Interaction/IntenSelectableMultiPointScoringVisualizer.cpp index 305b49b132f927b23622eef3e762c62f07ec0795..fd6d48ce19f48b35dfbb3524f3204b4fda59516c 100644 --- a/Source/RWTHVRToolkitEditor/Private/Interaction/IntenSelectableMultiPointScoringVisualizer.cpp +++ b/Source/RWTHVRToolkitEditor/Private/Interaction/IntenSelectableMultiPointScoringVisualizer.cpp @@ -7,31 +7,30 @@ IMPLEMENT_HIT_PROXY(FMultiPointProxy, HComponentVisProxy); FIntenSelectableMultiPointScoringVisualizer::FIntenSelectableMultiPointScoringVisualizer() { - PointsProperty = FindFProperty<FProperty>(UIntenSelectableMultiPointScoring::StaticClass(), GET_MEMBER_NAME_CHECKED(UIntenSelectableMultiPointScoring, PointsToSelect)); + PointsProperty = + FindFProperty<FProperty>(UIntenSelectableMultiPointScoring::StaticClass(), + GET_MEMBER_NAME_CHECKED(UIntenSelectableMultiPointScoring, PointsToSelect)); } -FIntenSelectableMultiPointScoringVisualizer::~FIntenSelectableMultiPointScoringVisualizer() -{ -} +FIntenSelectableMultiPointScoringVisualizer::~FIntenSelectableMultiPointScoringVisualizer() {} FVector FIntenSelectableMultiPointScoringVisualizer::GetCurrentVectorWorld() const { - if(CurrentSelectionIndex == INDEX_NONE) + if (CurrentSelectionIndex == INDEX_NONE) { return FVector::ZeroVector; } - return GetEditedScoringComponent()->GetComponentTransform().TransformPosition(GetEditedScoringComponent()->PointsToSelect[CurrentSelectionIndex]); + return GetEditedScoringComponent()->GetComponentTransform().TransformPosition( + GetEditedScoringComponent()->PointsToSelect[CurrentSelectionIndex]); } bool FIntenSelectableMultiPointScoringVisualizer::IsVisualizingArchetype() const { - return GetEditedScoringComponent() && GetEditedScoringComponent()->GetOwner() && FActorEditorUtils::IsAPreviewOrInactiveActor(GetEditedScoringComponent()->GetOwner()); + return GetEditedScoringComponent() && GetEditedScoringComponent()->GetOwner() && + FActorEditorUtils::IsAPreviewOrInactiveActor(GetEditedScoringComponent()->GetOwner()); } -bool FIntenSelectableMultiPointScoringVisualizer::ShowWhenSelected() -{ - return false; -} +bool FIntenSelectableMultiPointScoringVisualizer::ShowWhenSelected() { return false; } bool FIntenSelectableMultiPointScoringVisualizer::ShouldShowForSelectedSubcomponents(const UActorComponent* Component) { @@ -39,67 +38,71 @@ bool FIntenSelectableMultiPointScoringVisualizer::ShouldShowForSelectedSubcompon } bool FIntenSelectableMultiPointScoringVisualizer::VisProxyHandleClick(FEditorViewportClient* InViewportClient, - HComponentVisProxy* VisProxy, const FViewportClick& Click) + HComponentVisProxy* VisProxy, + const FViewportClick& Click) { bool bEditing = false; - + if (VisProxy && VisProxy->Component.IsValid()) { bEditing = true; - + if (VisProxy->IsA(FMultiPointProxy::StaticGetType())) { - const UIntenSelectableMultiPointScoring* T = Cast<const UIntenSelectableMultiPointScoring>(VisProxy->Component.Get()); + const UIntenSelectableMultiPointScoring* T = + Cast<const UIntenSelectableMultiPointScoring>(VisProxy->Component.Get()); ScoringBehaviourPropertyPath = FComponentPropertyPath(T); - + FMultiPointProxy* Proxy = (FMultiPointProxy*)VisProxy; CurrentSelectionIndex = Proxy->TargetIndex; - //UE_LOG(LogTemp, Warning, TEXT("Handling Click %i"), CurrentSelectionIndex); - }else + // UE_LOG(LogTemp, Warning, TEXT("Handling Click %i"), CurrentSelectionIndex); + } + else { CurrentSelectionIndex = INDEX_NONE; - //UE_LOG(LogTemp, Warning, TEXT("Handling Click => no selection")); + // UE_LOG(LogTemp, Warning, TEXT("Handling Click => no selection")); } } else { CurrentSelectionIndex = INDEX_NONE; - //UE_LOG(LogTemp, Warning, TEXT("Handling Click => no selection")); - + // UE_LOG(LogTemp, Warning, TEXT("Handling Click => no selection")); } return bEditing; } -void FIntenSelectableMultiPointScoringVisualizer::DrawVisualization(const UActorComponent* Component, const FSceneView* View, FPrimitiveDrawInterface* PDI) { +void FIntenSelectableMultiPointScoringVisualizer::DrawVisualization(const UActorComponent* Component, + const FSceneView* View, + FPrimitiveDrawInterface* PDI) +{ const UIntenSelectableMultiPointScoring* ComponentCasted = Cast<UIntenSelectableMultiPointScoring>(Component); - + if (ComponentCasted != nullptr) { - for(int i = 0; i < ComponentCasted->PointsToSelect.Num(); i++) + for (int i = 0; i < ComponentCasted->PointsToSelect.Num(); i++) { PDI->SetHitProxy(new FMultiPointProxy(Component, i)); - - FVector PointWorld = ComponentCasted->GetComponentTransform().TransformPosition(ComponentCasted->PointsToSelect[i]); + + FVector PointWorld = + ComponentCasted->GetComponentTransform().TransformPosition(ComponentCasted->PointsToSelect[i]); PDI->DrawPoint(PointWorld, FColor::Green, 20.f, SDPG_Foreground); - + PDI->SetHitProxy(nullptr); } } } -void FIntenSelectableMultiPointScoringVisualizer::EndEditing() -{ - -} +void FIntenSelectableMultiPointScoringVisualizer::EndEditing() {} UActorComponent* FIntenSelectableMultiPointScoringVisualizer::GetEditedComponent() const { return GetEditedScoringComponent(); } -bool FIntenSelectableMultiPointScoringVisualizer::HandleInputDelta(FEditorViewportClient* ViewportClient, FViewport* Viewport, - FVector& DeltaTranslate, FRotator& DeltaRotate, FVector& DeltaScale) +bool FIntenSelectableMultiPointScoringVisualizer::HandleInputDelta(FEditorViewportClient* ViewportClient, + FViewport* Viewport, FVector& DeltaTranslate, + FRotator& DeltaRotate, FVector& DeltaScale) { bool bHandled = false; @@ -107,25 +110,28 @@ bool FIntenSelectableMultiPointScoringVisualizer::HandleInputDelta(FEditorViewpo { UIntenSelectableMultiPointScoring* ScoringComponent = GetEditedScoringComponent(); ScoringComponent->Modify(); - - const FVector WorldSelection = ScoringComponent->GetComponentTransform().TransformPosition(GetEditedScoringComponent()->PointsToSelect[CurrentSelectionIndex]); - const FVector NewWorldPos = ScoringComponent->GetComponentTransform().InverseTransformPosition(WorldSelection + DeltaTranslate); + + const FVector WorldSelection = ScoringComponent->GetComponentTransform().TransformPosition( + GetEditedScoringComponent()->PointsToSelect[CurrentSelectionIndex]); + const FVector NewWorldPos = + ScoringComponent->GetComponentTransform().InverseTransformPosition(WorldSelection + DeltaTranslate); ScoringComponent->PointsToSelect[CurrentSelectionIndex] = NewWorldPos; - //UE_LOG(LogTemp, Warning, TEXT("New Pos: %s"), *ScoringComponent->PointsToSelect[CurrentSelectionIndex].ToString()); - + // UE_LOG(LogTemp, Warning, TEXT("New Pos: %s"), + // *ScoringComponent->PointsToSelect[CurrentSelectionIndex].ToString()); + ScoringComponent->MarkRenderStateDirty(); bHandled = true; - + TArray<FProperty*> Properties; Properties.Add(PointsProperty); NotifyPropertiesModified(ScoringComponent, Properties, EPropertyChangeType::ValueSet); - - GEditor->RedrawLevelEditingViewports(false); - }else + GEditor->RedrawLevelEditingViewports(false); + } + else { - //UE_LOG(LogTemp, Warning, TEXT("No Current Selection!")); + // UE_LOG(LogTemp, Warning, TEXT("No Current Selection!")); } return bHandled; @@ -137,12 +143,12 @@ UIntenSelectableMultiPointScoring* FIntenSelectableMultiPointScoringVisualizer:: } bool FIntenSelectableMultiPointScoringVisualizer::GetWidgetLocation(const FEditorViewportClient* ViewportClient, - FVector& OutLocation) const + FVector& OutLocation) const { if (GetEditedScoringComponent() && CurrentSelectionIndex != INDEX_NONE) { OutLocation = GetCurrentVectorWorld(); - + return true; } diff --git a/Source/RWTHVRToolkitEditor/Private/Interaction/IntenSelectableMultiRectangleScoringVisualizer.cpp b/Source/RWTHVRToolkitEditor/Private/Interaction/IntenSelectableMultiRectangleScoringVisualizer.cpp index 077c97102bb94e0f40be3f9f8fcb180820346cf7..8096efefa9a261de88bc6cbc0faf101b7d9bd019 100644 --- a/Source/RWTHVRToolkitEditor/Private/Interaction/IntenSelectableMultiRectangleScoringVisualizer.cpp +++ b/Source/RWTHVRToolkitEditor/Private/Interaction/IntenSelectableMultiRectangleScoringVisualizer.cpp @@ -7,23 +7,23 @@ IMPLEMENT_HIT_PROXY(FRectangleProxy, HComponentVisProxy); FIntenSelectableRectangleScoringVisualizer::FIntenSelectableRectangleScoringVisualizer() { - XLengthProperty = FindFProperty<FProperty>(UIntenSelectableRectangleScoring::StaticClass(), GET_MEMBER_NAME_CHECKED(UIntenSelectableRectangleScoring, XLength)); - YLengthProperty = FindFProperty<FProperty>(UIntenSelectableRectangleScoring::StaticClass(), GET_MEMBER_NAME_CHECKED(UIntenSelectableRectangleScoring, YLength)); + XLengthProperty = FindFProperty<FProperty>(UIntenSelectableRectangleScoring::StaticClass(), + GET_MEMBER_NAME_CHECKED(UIntenSelectableRectangleScoring, XLength)); + YLengthProperty = FindFProperty<FProperty>(UIntenSelectableRectangleScoring::StaticClass(), + GET_MEMBER_NAME_CHECKED(UIntenSelectableRectangleScoring, YLength)); } -FIntenSelectableRectangleScoringVisualizer::~FIntenSelectableRectangleScoringVisualizer() -{ -} +FIntenSelectableRectangleScoringVisualizer::~FIntenSelectableRectangleScoringVisualizer() {} bool FIntenSelectableRectangleScoringVisualizer::IsVisualizingArchetype() const { - return GetEditedScoringComponent() && GetEditedScoringComponent()->GetOwner() && FActorEditorUtils::IsAPreviewOrInactiveActor(GetEditedScoringComponent()->GetOwner()); - + return GetEditedScoringComponent() && GetEditedScoringComponent()->GetOwner() && + FActorEditorUtils::IsAPreviewOrInactiveActor(GetEditedScoringComponent()->GetOwner()); } FVector FIntenSelectableRectangleScoringVisualizer::GetCurrentVectorWorld() const { - if(CurrentSelectionIndex == INDEX_NONE) + if (CurrentSelectionIndex == INDEX_NONE) { return FVector::ZeroVector; } @@ -31,7 +31,8 @@ FVector FIntenSelectableRectangleScoringVisualizer::GetCurrentVectorWorld() cons const FVector X = GetEditedScoringComponent()->GetRightVector() * GetEditedScoringComponent()->XLength; const FVector Y = GetEditedScoringComponent()->GetUpVector() * GetEditedScoringComponent()->YLength; - const FVector CornerWorld00 = GetEditedScoringComponent()->GetComponentTransform().TransformPosition(FVector::ZeroVector) - (X / 2) - (Y / 2); + const FVector CornerWorld00 = + GetEditedScoringComponent()->GetComponentTransform().TransformPosition(FVector::ZeroVector) - (X / 2) - (Y / 2); const FVector CornerWorld10 = CornerWorld00 + X; const FVector CornerWorld01 = CornerWorld00 + Y; const FVector CornerWorld11 = CornerWorld00 + X + Y; @@ -40,51 +41,52 @@ FVector FIntenSelectableRectangleScoringVisualizer::GetCurrentVectorWorld() cons switch (CurrentSelectionIndex) { case 0: - //bottom + // bottom return CornerWorld00 + (CornerWorld10 - CornerWorld00) * 0.5; case 1: - //left + // left return CornerWorld00 + (CornerWorld01 - CornerWorld00) * 0.5; case 2: - //top + // top return CornerWorld01 + (CornerWorld11 - CornerWorld01) * 0.5; case 3: - //right + // right return CornerWorld11 + (CornerWorld10 - CornerWorld11) * 0.5; case 4: - //middle + // middle return CornerWorld00 + ((CornerWorld10 - CornerWorld00) * 0.5) - ((CornerWorld10 - CornerWorld11) * 0.5); default: return FVector::ZeroVector; } } -bool FIntenSelectableRectangleScoringVisualizer::ShowWhenSelected() -{ - return false; -} +bool FIntenSelectableRectangleScoringVisualizer::ShowWhenSelected() { return false; } bool FIntenSelectableRectangleScoringVisualizer::ShouldShowForSelectedSubcomponents(const UActorComponent* Component) { return false; } -bool FIntenSelectableRectangleScoringVisualizer::VisProxyHandleClick(FEditorViewportClient* InViewportClient, HComponentVisProxy* VisProxy, const FViewportClick& Click) +bool FIntenSelectableRectangleScoringVisualizer::VisProxyHandleClick(FEditorViewportClient* InViewportClient, + HComponentVisProxy* VisProxy, + const FViewportClick& Click) { bool bEditing = false; if (VisProxy && VisProxy->Component.IsValid()) { bEditing = true; - + if (VisProxy->IsA(FRectangleProxy::StaticGetType())) { - const UIntenSelectableRectangleScoring* T = Cast<const UIntenSelectableRectangleScoring>(VisProxy->Component.Get()); + const UIntenSelectableRectangleScoring* T = + Cast<const UIntenSelectableRectangleScoring>(VisProxy->Component.Get()); ScoringBehaviourPropertyPath = FComponentPropertyPath(T); - + FRectangleProxy* Proxy = (FRectangleProxy*)VisProxy; CurrentSelectionIndex = Proxy->TargetIndex; - }else + } + else { CurrentSelectionIndex = INDEX_NONE; } @@ -97,52 +99,53 @@ bool FIntenSelectableRectangleScoringVisualizer::VisProxyHandleClick(FEditorView return bEditing; } -void FIntenSelectableRectangleScoringVisualizer::DrawVisualization(const UActorComponent* Component, const FSceneView* View, FPrimitiveDrawInterface* PDI) { +void FIntenSelectableRectangleScoringVisualizer::DrawVisualization(const UActorComponent* Component, + const FSceneView* View, FPrimitiveDrawInterface* PDI) +{ const UIntenSelectableRectangleScoring* ComponentCasted = Cast<UIntenSelectableRectangleScoring>(Component); - + if (ComponentCasted != nullptr) { const FVector X = ComponentCasted->GetRightVector() * ComponentCasted->XLength; const FVector Y = ComponentCasted->GetUpVector() * ComponentCasted->YLength; - const FVector CornerWorld00 = ComponentCasted->GetComponentTransform().TransformPosition(FVector::ZeroVector) - (X / 2) - (Y / 2); + const FVector CornerWorld00 = + ComponentCasted->GetComponentTransform().TransformPosition(FVector::ZeroVector) - (X / 2) - (Y / 2); const FVector CornerWorld10 = CornerWorld00 + X; const FVector CornerWorld01 = CornerWorld00 + Y; const FVector CornerWorld11 = CornerWorld00 + X + Y; - //bottom 0 + // bottom 0 PDI->SetHitProxy(new FRectangleProxy(Component, 0)); PDI->DrawLine(CornerWorld00, CornerWorld10, FColor::Green, SDPG_Foreground, 3); PDI->SetHitProxy(nullptr); - //left 1 + // left 1 PDI->SetHitProxy(new FRectangleProxy(Component, 1)); PDI->DrawLine(CornerWorld00, CornerWorld01, FColor::Green, SDPG_Foreground, 3); PDI->SetHitProxy(nullptr); - //up 2 + // up 2 PDI->SetHitProxy(new FRectangleProxy(Component, 2)); PDI->DrawLine(CornerWorld01, CornerWorld11, FColor::Green, SDPG_Foreground, 3); PDI->SetHitProxy(nullptr); - //right 3 + // right 3 PDI->SetHitProxy(new FRectangleProxy(Component, 3)); PDI->DrawLine(CornerWorld11, CornerWorld10, FColor::Green, SDPG_Foreground, 3); PDI->SetHitProxy(nullptr); - //middle + // middle PDI->SetHitProxy(new FRectangleProxy(Component, 4)); - const FVector Middle = CornerWorld00 + ((CornerWorld10 - CornerWorld00) * 0.5) - ((CornerWorld10 - CornerWorld11) * 0.5); + const FVector Middle = + CornerWorld00 + ((CornerWorld10 - CornerWorld00) * 0.5) - ((CornerWorld10 - CornerWorld11) * 0.5); PDI->DrawPoint(Middle, FColor::Green, 20, SDPG_Foreground); PDI->SetHitProxy(nullptr); } } -void FIntenSelectableRectangleScoringVisualizer::EndEditing() -{ - GEditor->RedrawLevelEditingViewports(true); -} +void FIntenSelectableRectangleScoringVisualizer::EndEditing() { GEditor->RedrawLevelEditingViewports(true); } UActorComponent* FIntenSelectableRectangleScoringVisualizer::GetEditedComponent() const { @@ -154,61 +157,66 @@ UIntenSelectableRectangleScoring* FIntenSelectableRectangleScoringVisualizer::Ge return Cast<UIntenSelectableRectangleScoring>(ScoringBehaviourPropertyPath.GetComponent()); } -bool FIntenSelectableRectangleScoringVisualizer::HandleInputDelta(FEditorViewportClient* ViewportClient, FViewport* Viewport, - FVector& DeltaTranslate, FRotator& DeltaRotate, FVector& DeltaScale) +bool FIntenSelectableRectangleScoringVisualizer::HandleInputDelta(FEditorViewportClient* ViewportClient, + FViewport* Viewport, FVector& DeltaTranslate, + FRotator& DeltaRotate, FVector& DeltaScale) { bool bHandled = false; - + if (CurrentSelectionIndex != INDEX_NONE) { UIntenSelectableRectangleScoring* ScoringComponent = GetEditedScoringComponent(); ScoringComponent->Modify(); - + switch (CurrentSelectionIndex) { case 0: - //bottom + // bottom ScoringComponent->YLength -= DeltaTranslate.Z; - if(ScoringComponent->YLength < 0.1) + if (ScoringComponent->YLength < 0.1) { ScoringComponent->YLength = 0.1; - }else + } + else { ScoringComponent->AddLocalOffset(FVector::UpVector * DeltaTranslate.Z / 2); } bHandled = true; break; case 1: - //left + // left ScoringComponent->XLength -= DeltaTranslate.Y; - if(ScoringComponent->XLength < 0.1) + if (ScoringComponent->XLength < 0.1) { ScoringComponent->XLength = 0.1; - }else + } + else { ScoringComponent->AddLocalOffset(FVector::RightVector * DeltaTranslate.Y / 2); } bHandled = true; break; case 2: - //top + // top ScoringComponent->YLength += DeltaTranslate.Z; - if(ScoringComponent->YLength < 0.1) + if (ScoringComponent->YLength < 0.1) { ScoringComponent->YLength = 0.1; - }else + } + else { ScoringComponent->AddLocalOffset(FVector::UpVector * DeltaTranslate.Z / 2); } bHandled = true; break; case 3: - //right + // right ScoringComponent->XLength += DeltaTranslate.Y; - if(ScoringComponent->XLength < 0.1) + if (ScoringComponent->XLength < 0.1) { ScoringComponent->XLength = 0.1; - }else + } + else { ScoringComponent->AddLocalOffset(FVector::RightVector * DeltaTranslate.Y / 2); } @@ -216,13 +224,14 @@ bool FIntenSelectableRectangleScoringVisualizer::HandleInputDelta(FEditorViewpor break; case 4: { - //middle + // middle const FVector WorldCenter = ScoringComponent->GetComponentLocation(); const FVector NewWorldCenter = WorldCenter + DeltaTranslate; ScoringComponent->SetWorldLocation(NewWorldCenter); ScoringComponent->AddWorldRotation(DeltaRotate); - - const FVector LocalScaleDelta = ScoringComponent->GetComponentTransform().InverseTransformVector(DeltaScale); + + const FVector LocalScaleDelta = + ScoringComponent->GetComponentTransform().InverseTransformVector(DeltaScale); ScoringComponent->XLength += LocalScaleDelta.Y * 4; ScoringComponent->YLength += LocalScaleDelta.Z * 4; bHandled = true; @@ -237,27 +246,26 @@ bool FIntenSelectableRectangleScoringVisualizer::HandleInputDelta(FEditorViewpor Properties.Add(XLengthProperty); Properties.Add(YLengthProperty); NotifyPropertiesModified(ScoringComponent, Properties, EPropertyChangeType::ValueSet); - + return bHandled; - }else + } + else { - //UE_LOG(LogTemp, Warning, TEXT("No Current Selection!")); + // UE_LOG(LogTemp, Warning, TEXT("No Current Selection!")); } return false; } bool FIntenSelectableRectangleScoringVisualizer::GetWidgetLocation(const FEditorViewportClient* ViewportClient, - FVector& OutLocation) const + FVector& OutLocation) const { if (CurrentSelectionIndex != INDEX_NONE) { OutLocation = GetCurrentVectorWorld(); - + return true; } return false; } - - diff --git a/Source/RWTHVRToolkitEditor/Private/Interaction/IntenSelectableSphereScoringVisualizer.cpp b/Source/RWTHVRToolkitEditor/Private/Interaction/IntenSelectableSphereScoringVisualizer.cpp index db203cd61f332a740ebf81ddf33fe82e3b063a4b..34657800ad77a3ee67fffb8124fcbae5dea14a7d 100644 --- a/Source/RWTHVRToolkitEditor/Private/Interaction/IntenSelectableSphereScoringVisualizer.cpp +++ b/Source/RWTHVRToolkitEditor/Private/Interaction/IntenSelectableSphereScoringVisualizer.cpp @@ -9,18 +9,19 @@ IMPLEMENT_HIT_PROXY(FSphereProxy, HComponentVisProxy); -FIntenSelectableSphereScoringVisualizer::FIntenSelectableSphereScoringVisualizer() : DebugMaterial(FColoredMaterialRenderProxy(GEngine->ConstraintLimitMaterial->GetRenderProxy(), FColor::Green)) +FIntenSelectableSphereScoringVisualizer::FIntenSelectableSphereScoringVisualizer() : + DebugMaterial(FColoredMaterialRenderProxy(GEngine->ConstraintLimitMaterial->GetRenderProxy(), FColor::Green)) { - PointsProperty = FindFProperty<FProperty>(UIntenSelectableSphereScoring::StaticClass(), GET_MEMBER_NAME_CHECKED(UIntenSelectableSphereScoring, Radius)); + PointsProperty = FindFProperty<FProperty>(UIntenSelectableSphereScoring::StaticClass(), + GET_MEMBER_NAME_CHECKED(UIntenSelectableSphereScoring, Radius)); } -FIntenSelectableSphereScoringVisualizer::~FIntenSelectableSphereScoringVisualizer() -{ -} +FIntenSelectableSphereScoringVisualizer::~FIntenSelectableSphereScoringVisualizer() {} bool FIntenSelectableSphereScoringVisualizer::IsVisualizingArchetype() const { - return GetEditedScoringComponent() && GetEditedScoringComponent()->GetOwner() && FActorEditorUtils::IsAPreviewOrInactiveActor(GetEditedScoringComponent()->GetOwner()); + return GetEditedScoringComponent() && GetEditedScoringComponent()->GetOwner() && + FActorEditorUtils::IsAPreviewOrInactiveActor(GetEditedScoringComponent()->GetOwner()); } FVector FIntenSelectableSphereScoringVisualizer::GetCurrentVectorWorld() const @@ -28,10 +29,7 @@ FVector FIntenSelectableSphereScoringVisualizer::GetCurrentVectorWorld() const return GetEditedScoringComponent()->GetComponentLocation(); } -bool FIntenSelectableSphereScoringVisualizer::ShowWhenSelected() -{ - return false; -} +bool FIntenSelectableSphereScoringVisualizer::ShowWhenSelected() { return false; } bool FIntenSelectableSphereScoringVisualizer::ShouldShowForSelectedSubcomponents(const UActorComponent* Component) { @@ -39,24 +37,27 @@ bool FIntenSelectableSphereScoringVisualizer::ShouldShowForSelectedSubcomponents } bool FIntenSelectableSphereScoringVisualizer::VisProxyHandleClick(FEditorViewportClient* InViewportClient, - HComponentVisProxy* VisProxy, const FViewportClick& Click) + HComponentVisProxy* VisProxy, + const FViewportClick& Click) { bool bEditing = false; - //UE_LOG(LogTemp, Warning, TEXT("Handling Click")); - + // UE_LOG(LogTemp, Warning, TEXT("Handling Click")); + if (VisProxy && VisProxy->Component.IsValid()) { bEditing = true; - + if (VisProxy->IsA(FSphereProxy::StaticGetType())) { - const UIntenSelectableSphereScoring* T = Cast<const UIntenSelectableSphereScoring>(VisProxy->Component.Get()); + const UIntenSelectableSphereScoring* T = + Cast<const UIntenSelectableSphereScoring>(VisProxy->Component.Get()); ScoringBehaviourPropertyPath = FComponentPropertyPath(T); - + FSphereProxy* Proxy = (FSphereProxy*)VisProxy; CurrentSelectionIndex = Proxy->TargetIndex; - }else + } + else { CurrentSelectionIndex = INDEX_NONE; } @@ -69,23 +70,23 @@ bool FIntenSelectableSphereScoringVisualizer::VisProxyHandleClick(FEditorViewpor return bEditing; } -void FIntenSelectableSphereScoringVisualizer::DrawVisualization(const UActorComponent* Component, const FSceneView* View, FPrimitiveDrawInterface* PDI) { +void FIntenSelectableSphereScoringVisualizer::DrawVisualization(const UActorComponent* Component, + const FSceneView* View, FPrimitiveDrawInterface* PDI) +{ const UIntenSelectableSphereScoring* ComponentCasted = Cast<UIntenSelectableSphereScoring>(Component); - + if (ComponentCasted != nullptr) { PDI->SetHitProxy(new FSphereProxy(Component, 0)); - - DrawSphere(PDI, ComponentCasted->GetComponentLocation(), FRotator::ZeroRotator, FVector::OneVector * ComponentCasted->Radius, 50, 50, &DebugMaterial, 0, false); + + DrawSphere(PDI, ComponentCasted->GetComponentLocation(), FRotator::ZeroRotator, + FVector::OneVector * ComponentCasted->Radius, 50, 50, &DebugMaterial, 0, false); PDI->SetHitProxy(nullptr); } } -void FIntenSelectableSphereScoringVisualizer::EndEditing() -{ - -} +void FIntenSelectableSphereScoringVisualizer::EndEditing() {} UActorComponent* FIntenSelectableSphereScoringVisualizer::GetEditedComponent() const { @@ -97,26 +98,27 @@ UIntenSelectableSphereScoring* FIntenSelectableSphereScoringVisualizer::GetEdite return Cast<UIntenSelectableSphereScoring>(ScoringBehaviourPropertyPath.GetComponent()); } -bool FIntenSelectableSphereScoringVisualizer::HandleInputDelta(FEditorViewportClient* ViewportClient, FViewport* Viewport, - FVector& DeltaTranslate, FRotator& DeltaRotate, FVector& DeltaScale) +bool FIntenSelectableSphereScoringVisualizer::HandleInputDelta(FEditorViewportClient* ViewportClient, + FViewport* Viewport, FVector& DeltaTranslate, + FRotator& DeltaRotate, FVector& DeltaScale) { bool bHandled = false; if (true || CurrentSelectionIndex != INDEX_NONE) { - //UE_LOG(LogTemp, Warning, TEXT("Current Selection! %s"), *DeltaTranslate.ToString()); + // UE_LOG(LogTemp, Warning, TEXT("Current Selection! %s"), *DeltaTranslate.ToString()); - if((true || CurrentSelectionIndex == 0 )&& GetEditedComponent()) + if ((true || CurrentSelectionIndex == 0) && GetEditedComponent()) { UIntenSelectableSphereScoring* ScoringComponent = GetEditedScoringComponent(); ScoringComponent->Modify(); - + const FVector LocalCenter = ScoringComponent->GetComponentLocation(); const FVector NewCenter = LocalCenter + DeltaTranslate; - + ScoringComponent->SetWorldLocation(NewCenter); ScoringComponent->AddWorldRotation(DeltaRotate); - + const float AverageScaleFactor = (DeltaScale.X + DeltaScale.Y + DeltaScale.Z) / 3.0f; // Apply the average scale factor to the original radius @@ -128,7 +130,8 @@ bool FIntenSelectableSphereScoringVisualizer::HandleInputDelta(FEditorViewportCl } else { - // Scale down: Decrease the radius, ensuring not to reduce it below a minimum threshold (e.g., not making it negative) + // Scale down: Decrease the radius, ensuring not to reduce it below a minimum threshold (e.g., not + // making it negative) NewRadius = ScoringComponent->Radius * FMath::Max(0.1f, 1.0f + AverageScaleFactor); } ScoringComponent->Radius = NewRadius; @@ -141,25 +144,24 @@ bool FIntenSelectableSphereScoringVisualizer::HandleInputDelta(FEditorViewportCl GEditor->RedrawLevelEditingViewports(false); bHandled = true; } - }else + } + else { - //UE_LOG(LogTemp, Warning, TEXT("No Current Selection!")); + // UE_LOG(LogTemp, Warning, TEXT("No Current Selection!")); } return bHandled; } bool FIntenSelectableSphereScoringVisualizer::GetWidgetLocation(const FEditorViewportClient* ViewportClient, - FVector& OutLocation) const + FVector& OutLocation) const { if (CurrentSelectionIndex != INDEX_NONE) { OutLocation = GetCurrentVectorWorld(); - + return true; } return false; } - - diff --git a/Source/RWTHVRToolkitEditor/Public/Interaction/IntenSelectableCircleScoringVisualizer.h b/Source/RWTHVRToolkitEditor/Public/Interaction/IntenSelectableCircleScoringVisualizer.h index 4f71ca88dcd1bb3e9495e0ad7e2a232e7e45e5d0..42880d84730f4166abedc015739d26369303bef2 100644 --- a/Source/RWTHVRToolkitEditor/Public/Interaction/IntenSelectableCircleScoringVisualizer.h +++ b/Source/RWTHVRToolkitEditor/Public/Interaction/IntenSelectableCircleScoringVisualizer.h @@ -6,19 +6,19 @@ #include "ComponentVisualizer.h" class UIntenSelectableCircleScoring; /** - * + * */ class FPrimitiveDrawInterface; class FSceneView; -struct FCircleProxy : HComponentVisProxy +struct FCircleProxy : HComponentVisProxy { DECLARE_HIT_PROXY(); - FCircleProxy (const UActorComponent* InComponent, int32 InTargetIndex) - : HComponentVisProxy (InComponent) - , TargetIndex(InTargetIndex) - {} + FCircleProxy(const UActorComponent* InComponent, int32 InTargetIndex) : + HComponentVisProxy(InComponent), TargetIndex(InTargetIndex) + { + } int32 TargetIndex; }; @@ -30,7 +30,7 @@ private: int CurrentSelectionIndex; FProperty* PointsProperty; FComponentPropertyPath ScoringBehaviourPropertyPath; - + public: FIntenSelectableCircleScoringVisualizer(); ~FIntenSelectableCircleScoringVisualizer(); @@ -39,14 +39,16 @@ public: virtual bool IsVisualizingArchetype() const override; UIntenSelectableCircleScoring* GetEditedScoringComponent() const; - + virtual bool ShowWhenSelected() override; virtual bool ShouldShowForSelectedSubcomponents(const UActorComponent* Component) override; - virtual bool VisProxyHandleClick(FEditorViewportClient* InViewportClient, HComponentVisProxy* VisProxy, const FViewportClick& Click) override; - virtual void DrawVisualization(const UActorComponent* Component, const FSceneView* View, FPrimitiveDrawInterface* PDI) override; + virtual bool VisProxyHandleClick(FEditorViewportClient* InViewportClient, HComponentVisProxy* VisProxy, + const FViewportClick& Click) override; + virtual void DrawVisualization(const UActorComponent* Component, const FSceneView* View, + FPrimitiveDrawInterface* PDI) override; virtual void EndEditing() override; virtual UActorComponent* GetEditedComponent() const override; - virtual bool HandleInputDelta(FEditorViewportClient* ViewportClient, FViewport* Viewport, FVector& DeltaTranslate, FRotator& DeltaRotate, FVector& DeltaScale) override; + virtual bool HandleInputDelta(FEditorViewportClient* ViewportClient, FViewport* Viewport, FVector& DeltaTranslate, + FRotator& DeltaRotate, FVector& DeltaScale) override; virtual bool GetWidgetLocation(const FEditorViewportClient* ViewportClient, FVector& OutLocation) const override; - }; diff --git a/Source/RWTHVRToolkitEditor/Public/Interaction/IntenSelectableCubeScoringVisualizer.h b/Source/RWTHVRToolkitEditor/Public/Interaction/IntenSelectableCubeScoringVisualizer.h index 2983aff71fab52bfce477910e0b64201f6d06a87..6ffffcfbdeaa5eed9e91261ee3ec94b9938928a1 100644 --- a/Source/RWTHVRToolkitEditor/Public/Interaction/IntenSelectableCubeScoringVisualizer.h +++ b/Source/RWTHVRToolkitEditor/Public/Interaction/IntenSelectableCubeScoringVisualizer.h @@ -8,14 +8,14 @@ class UIntenSelectableCubeScoring; class FPrimitiveDrawInterface; class FSceneView; -struct FCubeProxy : HComponentVisProxy +struct FCubeProxy : HComponentVisProxy { DECLARE_HIT_PROXY(); - FCubeProxy (const UActorComponent* InComponent, int32 InTargetIndex) - : HComponentVisProxy (InComponent) - , TargetIndex(InTargetIndex) - {} + FCubeProxy(const UActorComponent* InComponent, int32 InTargetIndex) : + HComponentVisProxy(InComponent), TargetIndex(InTargetIndex) + { + } int32 TargetIndex; }; @@ -29,7 +29,7 @@ private: FColoredMaterialRenderProxy DebugMaterial; FProperty* PointsProperty; FComponentPropertyPath ScoringBehaviourPropertyPath; - + public: FIntenSelectableCubeScoringVisualizer(); ~FIntenSelectableCubeScoringVisualizer(); @@ -41,11 +41,13 @@ public: virtual bool ShowWhenSelected() override; virtual bool ShouldShowForSelectedSubcomponents(const UActorComponent* Component) override; - virtual bool VisProxyHandleClick(FEditorViewportClient* InViewportClient, HComponentVisProxy* VisProxy, const FViewportClick& Click) override; - virtual void DrawVisualization(const UActorComponent* Component, const FSceneView* View, FPrimitiveDrawInterface* PDI) override; + virtual bool VisProxyHandleClick(FEditorViewportClient* InViewportClient, HComponentVisProxy* VisProxy, + const FViewportClick& Click) override; + virtual void DrawVisualization(const UActorComponent* Component, const FSceneView* View, + FPrimitiveDrawInterface* PDI) override; virtual void EndEditing() override; virtual UActorComponent* GetEditedComponent() const override; - virtual bool HandleInputDelta(FEditorViewportClient* ViewportClient, FViewport* Viewport, FVector& DeltaTranslate, FRotator& DeltaRotate, FVector& DeltaScale) override; + virtual bool HandleInputDelta(FEditorViewportClient* ViewportClient, FViewport* Viewport, FVector& DeltaTranslate, + FRotator& DeltaRotate, FVector& DeltaScale) override; virtual bool GetWidgetLocation(const FEditorViewportClient* ViewportClient, FVector& OutLocation) const override; - }; diff --git a/Source/RWTHVRToolkitEditor/Public/Interaction/IntenSelectableCylinderScoringVisualizer.h b/Source/RWTHVRToolkitEditor/Public/Interaction/IntenSelectableCylinderScoringVisualizer.h index 507cac5b50179e734cdc754f033ee0be6dd0f366..6e796151b1e75a07b186e71bfbb70aec56ecfa51 100644 --- a/Source/RWTHVRToolkitEditor/Public/Interaction/IntenSelectableCylinderScoringVisualizer.h +++ b/Source/RWTHVRToolkitEditor/Public/Interaction/IntenSelectableCylinderScoringVisualizer.h @@ -14,32 +14,30 @@ struct HTargetingVisProxy : public HComponentVisProxy { DECLARE_HIT_PROXY(); - HTargetingVisProxy (const UActorComponent* InComponent) - : HComponentVisProxy(InComponent, HPP_Wireframe) - {} + HTargetingVisProxy(const UActorComponent* InComponent) : HComponentVisProxy(InComponent, HPP_Wireframe) {} }; /**Proxy for target*/ -struct HTargetProxy : public HTargetingVisProxy +struct HTargetProxy : public HTargetingVisProxy { DECLARE_HIT_PROXY(); - HTargetProxy (const UActorComponent* InComponent, int32 InTargetIndex) - : HTargetingVisProxy (InComponent) - , TargetIndex(InTargetIndex) - {} + HTargetProxy(const UActorComponent* InComponent, int32 InTargetIndex) : + HTargetingVisProxy(InComponent), TargetIndex(InTargetIndex) + { + } int32 TargetIndex; }; -struct FCylinderPointProxy : HComponentVisProxy +struct FCylinderPointProxy : HComponentVisProxy { DECLARE_HIT_PROXY(); - FCylinderPointProxy (const UActorComponent* InComponent, int32 InTargetIndex) - : HComponentVisProxy (InComponent) - , TargetIndex(InTargetIndex) - {} + FCylinderPointProxy(const UActorComponent* InComponent, int32 InTargetIndex) : + HComponentVisProxy(InComponent), TargetIndex(InTargetIndex) + { + } int32 TargetIndex; }; @@ -58,15 +56,18 @@ private: public: FIntenSelectableCylinderScoringVisualizer(); ~FIntenSelectableCylinderScoringVisualizer(); - + virtual bool IsVisualizingArchetype() const override; virtual bool ShowWhenSelected() override; virtual bool ShouldShowForSelectedSubcomponents(const UActorComponent* Component) override; - virtual bool VisProxyHandleClick(FEditorViewportClient* InViewportClient, HComponentVisProxy* VisProxy, const FViewportClick& Click) override; - virtual bool HandleInputDelta(FEditorViewportClient* ViewportClient, FViewport* Viewport, FVector& DeltaTranslate, FRotator& DeltaRotate, FVector& DeltaScale) override; - virtual void DrawVisualization(const UActorComponent* Component, const FSceneView* View, FPrimitiveDrawInterface* PDI) override; - + virtual bool VisProxyHandleClick(FEditorViewportClient* InViewportClient, HComponentVisProxy* VisProxy, + const FViewportClick& Click) override; + virtual bool HandleInputDelta(FEditorViewportClient* ViewportClient, FViewport* Viewport, FVector& DeltaTranslate, + FRotator& DeltaRotate, FVector& DeltaScale) override; + virtual void DrawVisualization(const UActorComponent* Component, const FSceneView* View, + FPrimitiveDrawInterface* PDI) override; + FVector GetCurrentVectorWorld() const; virtual bool GetWidgetLocation(const FEditorViewportClient* ViewportClient, FVector& OutLocation) const override; diff --git a/Source/RWTHVRToolkitEditor/Public/Interaction/IntenSelectableLineScoringVisualizer.h b/Source/RWTHVRToolkitEditor/Public/Interaction/IntenSelectableLineScoringVisualizer.h index 794cb29be684a2911cc7b9ccd1d5ba0c414a608a..1bb024784e513db19713c1f4df74f430c56792a7 100644 --- a/Source/RWTHVRToolkitEditor/Public/Interaction/IntenSelectableLineScoringVisualizer.h +++ b/Source/RWTHVRToolkitEditor/Public/Interaction/IntenSelectableLineScoringVisualizer.h @@ -6,19 +6,19 @@ #include "ComponentVisualizer.h" class UIntenSelectableLineScoring; /** - * + * */ class FPrimitiveDrawInterface; class FSceneView; -struct FLinePointProxy : HComponentVisProxy +struct FLinePointProxy : HComponentVisProxy { DECLARE_HIT_PROXY(); - FLinePointProxy (const UActorComponent* InComponent, int32 InTargetIndex) - : HComponentVisProxy (InComponent) - , TargetIndex(InTargetIndex) - {} + FLinePointProxy(const UActorComponent* InComponent, int32 InTargetIndex) : + HComponentVisProxy(InComponent), TargetIndex(InTargetIndex) + { + } int32 TargetIndex; }; @@ -31,7 +31,7 @@ private: FProperty* PointsProperty; UIntenSelectableLineScoring* LineBehavior; FComponentPropertyPath ScoringBehaviourPropertyPath; - + public: FIntenSelectableLineScoringVisualizer(); ~FIntenSelectableLineScoringVisualizer(); @@ -41,15 +41,17 @@ public: virtual bool IsVisualizingArchetype() const override; virtual bool ShowWhenSelected() override; virtual bool ShouldShowForSelectedSubcomponents(const UActorComponent* Component) override; - virtual void DrawVisualization(const UActorComponent* Component, const FSceneView* View, FPrimitiveDrawInterface* PDI) override; - - virtual bool VisProxyHandleClick(FEditorViewportClient* InViewportClient, HComponentVisProxy* VisProxy, const FViewportClick& Click) override; - virtual bool HandleInputDelta(FEditorViewportClient* ViewportClient, FViewport* Viewport, FVector& DeltaTranslate, FRotator& DeltaRotate, FVector& DeltaScale) override; - + virtual void DrawVisualization(const UActorComponent* Component, const FSceneView* View, + FPrimitiveDrawInterface* PDI) override; + + virtual bool VisProxyHandleClick(FEditorViewportClient* InViewportClient, HComponentVisProxy* VisProxy, + const FViewportClick& Click) override; + virtual bool HandleInputDelta(FEditorViewportClient* ViewportClient, FViewport* Viewport, FVector& DeltaTranslate, + FRotator& DeltaRotate, FVector& DeltaScale) override; + virtual bool GetWidgetLocation(const FEditorViewportClient* ViewportClient, FVector& OutLocation) const override; virtual UActorComponent* GetEditedComponent() const override; UIntenSelectableLineScoring* GetEditedScoringComponent() const; - + virtual void EndEditing() override; - }; diff --git a/Source/RWTHVRToolkitEditor/Public/Interaction/IntenSelectableMultiPointScoringVisualizer.h b/Source/RWTHVRToolkitEditor/Public/Interaction/IntenSelectableMultiPointScoringVisualizer.h index 09c8fdd87ac3d2c94d26846c8cf24acfa8f8312d..c46253283484cdcffee3bc49c15dda61a4a1190a 100644 --- a/Source/RWTHVRToolkitEditor/Public/Interaction/IntenSelectableMultiPointScoringVisualizer.h +++ b/Source/RWTHVRToolkitEditor/Public/Interaction/IntenSelectableMultiPointScoringVisualizer.h @@ -7,14 +7,14 @@ class UIntenSelectableMultiPointScoring; class FPrimitiveDrawInterface; class FSceneView; -struct FMultiPointProxy : HComponentVisProxy +struct FMultiPointProxy : HComponentVisProxy { DECLARE_HIT_PROXY(); - FMultiPointProxy (const UActorComponent* InComponent, int32 InTargetIndex) - : HComponentVisProxy (InComponent) - , TargetIndex(InTargetIndex) - {} + FMultiPointProxy(const UActorComponent* InComponent, int32 InTargetIndex) : + HComponentVisProxy(InComponent), TargetIndex(InTargetIndex) + { + } int32 TargetIndex; }; @@ -26,24 +26,27 @@ private: int CurrentSelectionIndex; FProperty* PointsProperty; FComponentPropertyPath ScoringBehaviourPropertyPath; - + public: FIntenSelectableMultiPointScoringVisualizer(); ~FIntenSelectableMultiPointScoringVisualizer(); - + virtual bool IsVisualizingArchetype() const override; virtual bool ShowWhenSelected() override; virtual bool ShouldShowForSelectedSubcomponents(const UActorComponent* Component) override; - - virtual bool VisProxyHandleClick(FEditorViewportClient* InViewportClient, HComponentVisProxy* VisProxy, const FViewportClick& Click) override; - virtual void DrawVisualization(const UActorComponent* Component, const FSceneView* View, FPrimitiveDrawInterface* PDI) override; - virtual bool HandleInputDelta(FEditorViewportClient* ViewportClient, FViewport* Viewport, FVector& DeltaTranslate, FRotator& DeltaRotate, FVector& DeltaScale) override; + + virtual bool VisProxyHandleClick(FEditorViewportClient* InViewportClient, HComponentVisProxy* VisProxy, + const FViewportClick& Click) override; + virtual void DrawVisualization(const UActorComponent* Component, const FSceneView* View, + FPrimitiveDrawInterface* PDI) override; + virtual bool HandleInputDelta(FEditorViewportClient* ViewportClient, FViewport* Viewport, FVector& DeltaTranslate, + FRotator& DeltaRotate, FVector& DeltaScale) override; FVector GetCurrentVectorWorld() const; virtual bool GetWidgetLocation(const FEditorViewportClient* ViewportClient, FVector& OutLocation) const override; - + virtual UActorComponent* GetEditedComponent() const override; UIntenSelectableMultiPointScoring* GetEditedScoringComponent() const; - + virtual void EndEditing() override; }; diff --git a/Source/RWTHVRToolkitEditor/Public/Interaction/IntenSelectableRectangleScoringVisualizer.h b/Source/RWTHVRToolkitEditor/Public/Interaction/IntenSelectableRectangleScoringVisualizer.h index 0e6025cd89c3f3eb3eebdb4306cf35ff17414134..983c87788e609d99950e365a457bee455d97cdd6 100644 --- a/Source/RWTHVRToolkitEditor/Public/Interaction/IntenSelectableRectangleScoringVisualizer.h +++ b/Source/RWTHVRToolkitEditor/Public/Interaction/IntenSelectableRectangleScoringVisualizer.h @@ -6,19 +6,19 @@ #include "ComponentVisualizer.h" class UIntenSelectableRectangleScoring; /** - * + * */ class FPrimitiveDrawInterface; class FSceneView; -struct FRectangleProxy : HComponentVisProxy +struct FRectangleProxy : HComponentVisProxy { DECLARE_HIT_PROXY(); - FRectangleProxy (const UActorComponent* InComponent, int32 InTargetIndex) - : HComponentVisProxy (InComponent) - , TargetIndex(InTargetIndex) - {} + FRectangleProxy(const UActorComponent* InComponent, int32 InTargetIndex) : + HComponentVisProxy(InComponent), TargetIndex(InTargetIndex) + { + } int32 TargetIndex; }; @@ -31,24 +31,27 @@ private: FProperty* XLengthProperty; FProperty* YLengthProperty; FComponentPropertyPath ScoringBehaviourPropertyPath; - + public: FIntenSelectableRectangleScoringVisualizer(); ~FIntenSelectableRectangleScoringVisualizer(); - + virtual bool IsVisualizingArchetype() const override; virtual bool ShowWhenSelected() override; virtual bool ShouldShowForSelectedSubcomponents(const UActorComponent* Component) override; - - virtual bool VisProxyHandleClick(FEditorViewportClient* InViewportClient, HComponentVisProxy* VisProxy, const FViewportClick& Click) override; - virtual void DrawVisualization(const UActorComponent* Component, const FSceneView* View, FPrimitiveDrawInterface* PDI) override; - virtual bool HandleInputDelta(FEditorViewportClient* ViewportClient, FViewport* Viewport, FVector& DeltaTranslate, FRotator& DeltaRotate, FVector& DeltaScale) override; + + virtual bool VisProxyHandleClick(FEditorViewportClient* InViewportClient, HComponentVisProxy* VisProxy, + const FViewportClick& Click) override; + virtual void DrawVisualization(const UActorComponent* Component, const FSceneView* View, + FPrimitiveDrawInterface* PDI) override; + virtual bool HandleInputDelta(FEditorViewportClient* ViewportClient, FViewport* Viewport, FVector& DeltaTranslate, + FRotator& DeltaRotate, FVector& DeltaScale) override; FVector GetCurrentVectorWorld() const; virtual bool GetWidgetLocation(const FEditorViewportClient* ViewportClient, FVector& OutLocation) const override; - + virtual UActorComponent* GetEditedComponent() const override; UIntenSelectableRectangleScoring* GetEditedScoringComponent() const; - + virtual void EndEditing() override; }; diff --git a/Source/RWTHVRToolkitEditor/Public/Interaction/IntenSelectableSphereScoringVisualizer.h b/Source/RWTHVRToolkitEditor/Public/Interaction/IntenSelectableSphereScoringVisualizer.h index ca499b922417a83d20023290d8dd3a5f33e87860..40e41d1707d63ac812e5e47b6665f43190a4a030 100644 --- a/Source/RWTHVRToolkitEditor/Public/Interaction/IntenSelectableSphereScoringVisualizer.h +++ b/Source/RWTHVRToolkitEditor/Public/Interaction/IntenSelectableSphereScoringVisualizer.h @@ -8,14 +8,14 @@ class UIntenSelectableSphereScoring; class FPrimitiveDrawInterface; class FSceneView; -struct FSphereProxy : HComponentVisProxy +struct FSphereProxy : HComponentVisProxy { DECLARE_HIT_PROXY(); - FSphereProxy (const UActorComponent* InComponent, int32 InTargetIndex) - : HComponentVisProxy (InComponent) - , TargetIndex(InTargetIndex) - {} + FSphereProxy(const UActorComponent* InComponent, int32 InTargetIndex) : + HComponentVisProxy(InComponent), TargetIndex(InTargetIndex) + { + } int32 TargetIndex; }; @@ -28,7 +28,7 @@ private: FColoredMaterialRenderProxy DebugMaterial; FProperty* PointsProperty; FComponentPropertyPath ScoringBehaviourPropertyPath; - + public: FIntenSelectableSphereScoringVisualizer(); ~FIntenSelectableSphereScoringVisualizer(); @@ -37,10 +37,13 @@ public: virtual bool IsVisualizingArchetype() const override; virtual bool ShowWhenSelected() override; virtual bool ShouldShowForSelectedSubcomponents(const UActorComponent* Component) override; - - virtual bool VisProxyHandleClick(FEditorViewportClient* InViewportClient, HComponentVisProxy* VisProxy, const FViewportClick& Click) override; - virtual void DrawVisualization(const UActorComponent* Component, const FSceneView* View, FPrimitiveDrawInterface* PDI) override; - virtual bool HandleInputDelta(FEditorViewportClient* ViewportClient, FViewport* Viewport, FVector& DeltaTranslate, FRotator& DeltaRotate, FVector& DeltaScale) override; + + virtual bool VisProxyHandleClick(FEditorViewportClient* InViewportClient, HComponentVisProxy* VisProxy, + const FViewportClick& Click) override; + virtual void DrawVisualization(const UActorComponent* Component, const FSceneView* View, + FPrimitiveDrawInterface* PDI) override; + virtual bool HandleInputDelta(FEditorViewportClient* ViewportClient, FViewport* Viewport, FVector& DeltaTranslate, + FRotator& DeltaRotate, FVector& DeltaScale) override; virtual UActorComponent* GetEditedComponent() const override; UIntenSelectableSphereScoring* GetEditedScoringComponent() const; @@ -49,6 +52,4 @@ public: virtual bool GetWidgetLocation(const FEditorViewportClient* ViewportClient, FVector& OutLocation) const override; virtual void EndEditing() override; - - };