From 5d516f33398fb1a1cf3c791e367c8c81e3379dd6 Mon Sep 17 00:00:00 2001 From: Timon Roemer <t.roemer@vis.rwth-aachen.de> Date: Mon, 11 Mar 2024 16:51:10 +0100 Subject: [PATCH] Applies Blueprint Update Fix for all Visualizers --- .../IntenSelectableLineScoring.cpp | 8 + .../IntenSelectableSphereScoring.h | 4 +- ...IntenSelectableCircleScoringVisualizer.cpp | 49 +++-- .../IntenSelectableCubeScoringVisualizer.cpp | 35 ++-- ...tenSelectableCylinderScoringVisualizer.cpp | 118 +++++++---- .../IntenSelectableLineScoringVisualizer.cpp | 88 ++++++--- ...nSelectableMultiPointScoringVisualizer.cpp | 186 ++---------------- ...ectableMultiRectangleScoringVisualizer.cpp | 104 ++++++---- ...IntenSelectableSphereScoringVisualizer.cpp | 65 ++++-- .../IntenSelectableCircleScoringVisualizer.h | 7 +- .../IntenSelectableCubeScoringVisualizer.h | 12 +- ...IntenSelectableCylinderScoringVisualizer.h | 30 +-- .../IntenSelectableLineScoringVisualizer.h | 14 +- ...tenSelectableMultiPointScoringVisualizer.h | 47 +---- ...ntenSelectableRectangleScoringVisualizer.h | 19 +- .../IntenSelectableSphereScoringVisualizer.h | 23 ++- 16 files changed, 406 insertions(+), 403 deletions(-) diff --git a/Source/RWTHVRToolkit/Private/Interaction/Interactables/IntenSelect/IntenSelectableLineScoring.cpp b/Source/RWTHVRToolkit/Private/Interaction/Interactables/IntenSelect/IntenSelectableLineScoring.cpp index a76741c4..7af4d28f 100644 --- a/Source/RWTHVRToolkit/Private/Interaction/Interactables/IntenSelect/IntenSelectableLineScoring.cpp +++ b/Source/RWTHVRToolkit/Private/Interaction/Interactables/IntenSelect/IntenSelectableLineScoring.cpp @@ -9,6 +9,14 @@ UIntenSelectableLineScoring::UIntenSelectableLineScoring() { PrimaryComponentTick.bCanEverTick = true; + if(this->LinePoints.Num() == 2) + { + const FVector Average = (this->LinePoints[0] + this->LinePoints[1]) / 2; + + this->SetWorldLocation(this->GetComponentTransform().TransformPositionNoScale(Average)); + this->LinePoints[0] -= Average; + this->LinePoints[1] -= Average; + } } TPair<FHitResult, float> UIntenSelectableLineScoring::GetBestPointScorePair(const FVector& ConeOrigin, diff --git a/Source/RWTHVRToolkit/Public/Interaction/Interactables/IntenSelect/IntenSelectableSphereScoring.h b/Source/RWTHVRToolkit/Public/Interaction/Interactables/IntenSelect/IntenSelectableSphereScoring.h index 8d7c7d64..a3842bc0 100644 --- a/Source/RWTHVRToolkit/Public/Interaction/Interactables/IntenSelect/IntenSelectableSphereScoring.h +++ b/Source/RWTHVRToolkit/Public/Interaction/Interactables/IntenSelect/IntenSelectableSphereScoring.h @@ -1,5 +1,3 @@ -// Fill out your copyright notice in the Description page of Project Settings. - #pragma once #include "CoreMinimal.h" @@ -27,7 +25,7 @@ public: float Radius = 50; UPROPERTY(EditAnywhere) - bool DrawDebug = false; + 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; diff --git a/Source/RWTHVRToolkitEditor/Private/Interaction/IntenSelectableCircleScoringVisualizer.cpp b/Source/RWTHVRToolkitEditor/Private/Interaction/IntenSelectableCircleScoringVisualizer.cpp index 8dc8bb1b..447a1ee5 100644 --- a/Source/RWTHVRToolkitEditor/Private/Interaction/IntenSelectableCircleScoringVisualizer.cpp +++ b/Source/RWTHVRToolkitEditor/Private/Interaction/IntenSelectableCircleScoringVisualizer.cpp @@ -1,5 +1,6 @@ #include "Interaction/IntenSelectableCircleScoringVisualizer.h" +#include "ActorEditorUtils.h" #include "SceneManagement.h" #include "Interaction/Interactables/IntenSelect/IntenSelectableCircleScoring.h" #include "Kismet/KismetMathLibrary.h" @@ -8,7 +9,7 @@ IMPLEMENT_HIT_PROXY(FCircleProxy, HComponentVisProxy); FIntenSelectableCircleScoringVisualizer::FIntenSelectableCircleScoringVisualizer() { - + PointsProperty = FindFProperty<FProperty>(UIntenSelectableCircleScoring::StaticClass(), GET_MEMBER_NAME_CHECKED(UIntenSelectableCircleScoring, Radius)); } FIntenSelectableCircleScoringVisualizer::~FIntenSelectableCircleScoringVisualizer() @@ -20,13 +21,13 @@ FVector FIntenSelectableCircleScoringVisualizer::GetCurrentVectorWorld() const switch (CurrentSelectionIndex) { case 0: - return CircleBehaviour->GetComponentLocation(); + return GetEditedScoringComponent()->GetComponentLocation(); case 1: { - const FVector CenterWorld = CircleBehaviour->GetComponentLocation(); - const FVector NormalWorldPoint = CircleBehaviour->GetComponentTransform().TransformPosition(FVector::ForwardVector); + const FVector CenterWorld = GetEditedScoringComponent()->GetComponentLocation(); + const FVector NormalWorldPoint = GetEditedScoringComponent()->GetComponentTransform().TransformPosition(FVector::ForwardVector); const FVector WorldNormalDir = NormalWorldPoint - CenterWorld; - const FVector Y = WorldNormalDir.RotateAngleAxis(90, CircleBehaviour->GetRightVector()).GetSafeNormal() * CircleBehaviour->Radius; + const FVector Y = WorldNormalDir.RotateAngleAxis(90, GetEditedScoringComponent()->GetRightVector()).GetSafeNormal() * GetEditedScoringComponent()->Radius; return CenterWorld + Y; } default: @@ -34,6 +35,16 @@ FVector FIntenSelectableCircleScoringVisualizer::GetCurrentVectorWorld() const } } +bool FIntenSelectableCircleScoringVisualizer::IsVisualizingArchetype() const +{ + return GetEditedScoringComponent() && GetEditedScoringComponent()->GetOwner() && FActorEditorUtils::IsAPreviewOrInactiveActor(GetEditedScoringComponent()->GetOwner()); +} + +UIntenSelectableCircleScoring* FIntenSelectableCircleScoringVisualizer::GetEditedScoringComponent() const +{ + return Cast<UIntenSelectableCircleScoring>(ScoringBehaviourPropertyPath.GetComponent()); +} + bool FIntenSelectableCircleScoringVisualizer::ShowWhenSelected() { return false; @@ -58,7 +69,8 @@ bool FIntenSelectableCircleScoringVisualizer::VisProxyHandleClick(FEditorViewpor if (VisProxy->IsA(FCircleProxy::StaticGetType())) { const UIntenSelectableCircleScoring* T = Cast<const UIntenSelectableCircleScoring>(VisProxy->Component.Get()); - CircleBehaviour = const_cast<UIntenSelectableCircleScoring*>(T); + ScoringBehaviourPropertyPath = FComponentPropertyPath(T); + FCircleProxy* Proxy = (FCircleProxy*)VisProxy; CurrentSelectionIndex = Proxy->TargetIndex; }else @@ -74,15 +86,13 @@ bool FIntenSelectableCircleScoringVisualizer::VisProxyHandleClick(FEditorViewpor return bEditing; } - -// Fill out your copyright notice in the Description page of Project Settings. - 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); @@ -93,6 +103,7 @@ void FIntenSelectableCircleScoringVisualizer::DrawVisualization(const UActorComp const FVector Y = WorldNormalDir.RotateAngleAxis(90, ComponentCasted->GetRightVector()); const FVector Z = FVector::CrossProduct(Y.GetSafeNormal(), WorldNormalDir); DrawCircle(PDI, CenterWorld, Y.GetSafeNormal(), Z.GetSafeNormal(), FColor::Green, ComponentCasted->Radius, 100, SDPG_Foreground, 2); + PDI->SetHitProxy(nullptr); } @@ -105,7 +116,7 @@ void FIntenSelectableCircleScoringVisualizer::EndEditing() UActorComponent* FIntenSelectableCircleScoringVisualizer::GetEditedComponent() const { - return CircleBehaviour; + return GetEditedScoringComponent(); } bool FIntenSelectableCircleScoringVisualizer::HandleInputDelta(FEditorViewportClient* ViewportClient, FViewport* Viewport, @@ -119,23 +130,27 @@ bool FIntenSelectableCircleScoringVisualizer::HandleInputDelta(FEditorViewportCl if(CurrentSelectionIndex == 0) { - const FVector LocalCenter = CircleBehaviour->GetComponentLocation(); + const FVector LocalCenter = GetEditedScoringComponent()->GetComponentLocation(); const FVector NewCenter = LocalCenter + DeltaTranslate; - CircleBehaviour->SetWorldLocation(NewCenter); - CircleBehaviour->AddWorldRotation(DeltaRotate); + GetEditedScoringComponent()->SetWorldLocation(NewCenter); + GetEditedScoringComponent()->AddWorldRotation(DeltaRotate); bHandled = true; }else if(CurrentSelectionIndex == 1) { - const FVector CenterWorld = CircleBehaviour->GetComponentLocation(); - const FVector NormalWorldPoint = CircleBehaviour->GetComponentTransform().TransformPosition(FVector::ForwardVector); + const FVector CenterWorld = GetEditedScoringComponent()->GetComponentLocation(); + const FVector NormalWorldPoint = GetEditedScoringComponent()->GetComponentTransform().TransformPosition(FVector::ForwardVector); const FVector WorldNormalDir = NormalWorldPoint - CenterWorld; - const FVector RadiusVector = WorldNormalDir.RotateAngleAxis(90, CircleBehaviour->GetRightVector()).GetSafeNormal() * CircleBehaviour->Radius; + const FVector RadiusVector = WorldNormalDir.RotateAngleAxis(90, GetEditedScoringComponent()->GetRightVector()).GetSafeNormal() * GetEditedScoringComponent()->Radius; const FVector ClampedTranslate = DeltaTranslate.Size() > 100 ? DeltaTranslate.GetSafeNormal() * 100 : DeltaTranslate; - CircleBehaviour->Radius = FVector::Distance(CenterWorld, CenterWorld + RadiusVector + ClampedTranslate); + GetEditedScoringComponent()->Radius = FVector::Distance(CenterWorld, CenterWorld + RadiusVector + ClampedTranslate); bHandled = true; } + + TArray<FProperty*> Properties; + Properties.Add(PointsProperty); + NotifyPropertiesModified(GetEditedScoringComponent(), Properties, EPropertyChangeType::ValueSet); }else { UE_LOG(LogTemp, Warning, TEXT("No Current Selection!")); diff --git a/Source/RWTHVRToolkitEditor/Private/Interaction/IntenSelectableCubeScoringVisualizer.cpp b/Source/RWTHVRToolkitEditor/Private/Interaction/IntenSelectableCubeScoringVisualizer.cpp index 2244e049..68b87f25 100644 --- a/Source/RWTHVRToolkitEditor/Private/Interaction/IntenSelectableCubeScoringVisualizer.cpp +++ b/Source/RWTHVRToolkitEditor/Private/Interaction/IntenSelectableCubeScoringVisualizer.cpp @@ -1,11 +1,10 @@ #include "Interaction/IntenSelectableCubeScoringVisualizer.h" +#include "ActorEditorUtils.h" #include "DrawDebugHelpers.h" - #include "SceneManagement.h" #include "MaterialShared.h" #include "Interaction/Interactables/IntenSelect/IntenSelectableCubeScoring.h" -#include "Kismet/KismetMathLibrary.h" #include "Materials/MaterialInstance.h" #include "Materials/MaterialRenderProxy.h" @@ -22,7 +21,17 @@ FIntenSelectableCubeScoringVisualizer::~FIntenSelectableCubeScoringVisualizer() FVector FIntenSelectableCubeScoringVisualizer::GetCurrentVectorWorld() const { - return CubeBehaviour->GetComponentLocation(); + return GetEditedScoringComponent()->GetComponentLocation(); +} + +bool FIntenSelectableCubeScoringVisualizer::IsVisualizingArchetype() const +{ + return GetEditedScoringComponent() && GetEditedScoringComponent()->GetOwner() && FActorEditorUtils::IsAPreviewOrInactiveActor(GetEditedScoringComponent()->GetOwner()); +} + +UIntenSelectableCubeScoring* FIntenSelectableCubeScoringVisualizer::GetEditedScoringComponent() const +{ + return Cast<UIntenSelectableCubeScoring>(ScoringBehaviourPropertyPath.GetComponent()); } bool FIntenSelectableCubeScoringVisualizer::ShowWhenSelected() @@ -49,7 +58,8 @@ bool FIntenSelectableCubeScoringVisualizer::VisProxyHandleClick(FEditorViewportC if (VisProxy->IsA(FCubeProxy::StaticGetType())) { const UIntenSelectableCubeScoring* T = Cast<const UIntenSelectableCubeScoring>(VisProxy->Component.Get()); - CubeBehaviour = const_cast<UIntenSelectableCubeScoring*>(T); + ScoringBehaviourPropertyPath = FComponentPropertyPath(T); + FCubeProxy* Proxy = (FCubeProxy*)VisProxy; CurrentSelectionIndex = Proxy->TargetIndex; }else @@ -65,19 +75,18 @@ bool FIntenSelectableCubeScoringVisualizer::VisProxyHandleClick(FEditorViewportC return bEditing; } - -// Fill out your copyright notice in the Description page of Project Settings. - 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); } } @@ -89,7 +98,7 @@ void FIntenSelectableCubeScoringVisualizer::EndEditing() UActorComponent* FIntenSelectableCubeScoringVisualizer::GetEditedComponent() const { - return CubeBehaviour; + return GetEditedScoringComponent(); } bool FIntenSelectableCubeScoringVisualizer::HandleInputDelta(FEditorViewportClient* ViewportClient, FViewport* Viewport, @@ -101,18 +110,18 @@ bool FIntenSelectableCubeScoringVisualizer::HandleInputDelta(FEditorViewportClie { UE_LOG(LogTemp, Warning, TEXT("Current Selection! %s"), *DeltaTranslate.ToString()); - const FVector LocalCenter = CubeBehaviour->GetComponentLocation(); + const FVector LocalCenter = GetEditedScoringComponent()->GetComponentLocation(); const FVector NewCenter = LocalCenter + DeltaTranslate; - CubeBehaviour->SetWorldLocation(NewCenter); - CubeBehaviour->AddWorldRotation(DeltaRotate); + GetEditedScoringComponent()->SetWorldLocation(NewCenter); + GetEditedScoringComponent()->AddWorldRotation(DeltaRotate); - auto Scale = CubeBehaviour->GetRelativeTransform().GetScale3D(); + auto Scale = GetEditedScoringComponent()->GetRelativeTransform().GetScale3D(); Scale.X += DeltaScale.X * 3; Scale.Y += DeltaScale.Y * 3; Scale.Z += DeltaScale.Z * 3; - CubeBehaviour->GetRelativeTransform().SetScale3D(Scale); + GetEditedScoringComponent()->GetRelativeTransform().SetScale3D(Scale); bHandled = true; }else { diff --git a/Source/RWTHVRToolkitEditor/Private/Interaction/IntenSelectableCylinderScoringVisualizer.cpp b/Source/RWTHVRToolkitEditor/Private/Interaction/IntenSelectableCylinderScoringVisualizer.cpp index 59895f5b..450c040f 100644 --- a/Source/RWTHVRToolkitEditor/Private/Interaction/IntenSelectableCylinderScoringVisualizer.cpp +++ b/Source/RWTHVRToolkitEditor/Private/Interaction/IntenSelectableCylinderScoringVisualizer.cpp @@ -1,12 +1,14 @@ #include "Interaction/IntenSelectableCylinderScoringVisualizer.h" +#include "ActorEditorUtils.h" #include "SceneManagement.h" IMPLEMENT_HIT_PROXY(FCylinderPointProxy, HComponentVisProxy); 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)); } FIntenSelectableCylinderScoringVisualizer::~FIntenSelectableCylinderScoringVisualizer() @@ -14,13 +16,23 @@ FIntenSelectableCylinderScoringVisualizer::~FIntenSelectableCylinderScoringVisua } +bool FIntenSelectableCylinderScoringVisualizer::IsVisualizingArchetype() const +{ + return GetEditedScoringComponent() && GetEditedScoringComponent()->GetOwner() && FActorEditorUtils::IsAPreviewOrInactiveActor(GetEditedScoringComponent()->GetOwner()); +} + FVector FIntenSelectableCylinderScoringVisualizer::GetCurrentVectorWorld() const { - if(CurrentCylinderSelectionIndex == INDEX_NONE) + if(GetEditedScoringComponent()) { - return FVector::ZeroVector; + if(CurrentCylinderSelectionIndex == INDEX_NONE) + { + return GetEditedScoringComponent()->GetComponentLocation(); + } + return GetEditedScoringComponent()->GetComponentTransform().TransformPositionNoScale(GetEditedScoringComponent()->LinePoints[CurrentCylinderSelectionIndex]); } - return CylinderBehavior->GetComponentTransform().TransformPosition(CylinderBehavior->LinePoints[CurrentCylinderSelectionIndex]); + + return FVector::ZeroVector; } bool FIntenSelectableCylinderScoringVisualizer::ShowWhenSelected() @@ -47,7 +59,8 @@ bool FIntenSelectableCylinderScoringVisualizer::VisProxyHandleClick(FEditorViewp if (VisProxy->IsA(FCylinderPointProxy::StaticGetType())) { const UIntenSelectableCylinderScoring* T = Cast<const UIntenSelectableCylinderScoring>(VisProxy->Component.Get()); - CylinderBehavior = const_cast<UIntenSelectableCylinderScoring*>(T); + ScoringBehaviourPropertyPath = FComponentPropertyPath(T); + FCylinderPointProxy* Proxy = (FCylinderPointProxy*)VisProxy; CurrentCylinderSelectionIndex = Proxy->TargetIndex; }else @@ -72,67 +85,98 @@ void FIntenSelectableCylinderScoringVisualizer::DrawVisualization(const UActorCo { PDI->SetHitProxy(new FCylinderPointProxy(Component, i)); - FVector PointWorld = ComponentCasted->GetComponentTransform().TransformPosition(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().TransformPosition(ComponentCasted->LinePoints[0]); - const FVector End = ComponentCasted->GetComponentTransform().TransformPosition(ComponentCasted->LinePoints[1]); + + PDI->SetHitProxy(new FCylinderPointProxy(Component, INDEX_NONE)); + + 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); + + PDI->SetHitProxy(nullptr); } } void FIntenSelectableCylinderScoringVisualizer::EndEditing() { CurrentCylinderSelectionIndex = INDEX_NONE; - //CylinderBehavior->MarkRenderStateDirty(); + //GetEditedScoringComponent()->MarkRenderStateDirty(); //GEditor->RedrawLevelEditingViewports(true); } UActorComponent* FIntenSelectableCylinderScoringVisualizer::GetEditedComponent() const { - return CylinderBehavior; + return GetEditedScoringComponent(); +} + +UIntenSelectableCylinderScoring* FIntenSelectableCylinderScoringVisualizer::GetEditedScoringComponent() const +{ + return Cast<UIntenSelectableCylinderScoring>(ScoringBehaviourPropertyPath.GetComponent()); } bool FIntenSelectableCylinderScoringVisualizer::HandleInputDelta(FEditorViewportClient* ViewportClient, FViewport* Viewport, - FVector& DeltaTranslate, FRotator& DeltaRotate, FVector& DeltaScale) + FVector& DeltaTranslate, FRotator& DeltaRotate, FVector& DeltaScale) { bool bHandled = false; - if (CurrentCylinderSelectionIndex != INDEX_NONE) + UIntenSelectableCylinderScoring* ScoringComponent = GetEditedScoringComponent(); + + if(ScoringComponent) { - UE_LOG(LogTemp, Warning, TEXT("Current Delta: %s"), *DeltaTranslate.ToString()); - UE_LOG(LogTemp, Warning, TEXT("Current Index: %d"), CurrentCylinderSelectionIndex); + if (CurrentCylinderSelectionIndex != INDEX_NONE) + { + ScoringComponent->Modify(); - const FVector WorldSelection = CylinderBehavior->GetComponentTransform().TransformPosition(CylinderBehavior->LinePoints[CurrentCylinderSelectionIndex]); - const FVector NewWorldPos = CylinderBehavior->GetComponentTransform().InverseTransformPosition(WorldSelection + DeltaTranslate); - //CylinderBehavior->LinePoints[CurrentCylinderSelectionIndex] = NewWorldPos; - CylinderBehavior->LinePoints[CurrentCylinderSelectionIndex] += DeltaTranslate; - //CylinderBehavior->LinePoints[CurrentCylinderSelectionIndex] += DeltaTranslate; - - UE_LOG(LogTemp, Warning, TEXT("Component: %s"), *(CylinderBehavior->LinePoints[CurrentCylinderSelectionIndex]).ToString()); - //UE_LOG(LogTemp, Warning, TEXT("self: %s"), *(LinePoints[CurrentCylinderSelectionIndex]).ToString()); - - //CylinderBehavior->MarkRenderStateDirty(); - //GEditor->RedrawLevelEditingViewports(true); - - const FVector Average = (CylinderBehavior->LinePoints[0] + CylinderBehavior->LinePoints[1])/ 2; - const FVector ShiftToMiddle = Average; - - CylinderBehavior->SetWorldLocation(CylinderBehavior->GetComponentTransform().TransformPositionNoScale(Average)); - CylinderBehavior->LinePoints[0] -= ShiftToMiddle; - CylinderBehavior->LinePoints[1] -= ShiftToMiddle; + UE_LOG(LogTemp, Warning, TEXT("Current Delta: %s"), *DeltaTranslate.ToString()); + UE_LOG(LogTemp, Warning, TEXT("Current Index: %d"), CurrentCylinderSelectionIndex); - bHandled = true; - }else - { - UE_LOG(LogTemp, Warning, TEXT("No Current Selection!")); + 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()); + + ScoringComponent->MarkRenderStateDirty(); + GEditor->RedrawLevelEditingViewports(true); + + const FVector Average = (ScoringComponent->LinePoints[0] + ScoringComponent->LinePoints[1])/ 2; + const FVector ShiftToMiddle = Average; + + ScoringComponent->SetWorldLocation(ScoringComponent->GetComponentTransform().TransformPositionNoScale(Average)); + ScoringComponent->LinePoints[0] -= ShiftToMiddle; + ScoringComponent->LinePoints[1] -= ShiftToMiddle; + + TArray<FProperty*> Properties; + Properties.Add(PointsProperty); + Properties.Add(RadiusProperty); + NotifyPropertiesModified(ScoringComponent, Properties, EPropertyChangeType::ValueSet); + + GEditor->RedrawLevelEditingViewports(true); + + bHandled = true; + }else + { + //ScoringComponent->AddWorldOffset(DeltaTranslate); + //ScoringComponent->AddWorldRotation(DeltaRotate); + + ScoringComponent->Modify(); + ScoringComponent->MarkRenderStateDirty(); + GEditor->RedrawLevelEditingViewports(true); + + UE_LOG(LogTemp, Warning, TEXT("Cylinder Selected!")); + + return false; + } } - + return bHandled; } diff --git a/Source/RWTHVRToolkitEditor/Private/Interaction/IntenSelectableLineScoringVisualizer.cpp b/Source/RWTHVRToolkitEditor/Private/Interaction/IntenSelectableLineScoringVisualizer.cpp index 9dbbfb4d..a0f3d658 100644 --- a/Source/RWTHVRToolkitEditor/Private/Interaction/IntenSelectableLineScoringVisualizer.cpp +++ b/Source/RWTHVRToolkitEditor/Private/Interaction/IntenSelectableLineScoringVisualizer.cpp @@ -1,5 +1,6 @@ #include "Interaction/IntenSelectableLineScoringVisualizer.h" +#include "ActorEditorUtils.h" #include "SceneManagement.h" #include "Interaction/Interactables/IntenSelect/IntenSelectableLineScoring.h" @@ -7,7 +8,7 @@ IMPLEMENT_HIT_PROXY(FLinePointProxy, HComponentVisProxy); FIntenSelectableLineScoringVisualizer::FIntenSelectableLineScoringVisualizer() { - + PointsProperty = FindFProperty<FProperty>(UIntenSelectableLineScoring::StaticClass(), GET_MEMBER_NAME_CHECKED(UIntenSelectableLineScoring, LinePoints)); } FIntenSelectableLineScoringVisualizer::~FIntenSelectableLineScoringVisualizer() @@ -20,13 +21,21 @@ FVector FIntenSelectableLineScoringVisualizer::GetCurrentVectorWorld() const if(CurrentLineSelectionIndex == INDEX_NONE) { return FVector::ZeroVector; + }else if(CurrentLineSelectionIndex == 2) + { + return GetEditedScoringComponent()->GetComponentLocation(); } - return LineBehavior->GetComponentTransform().TransformPosition(LineBehavior->LinePoints[CurrentLineSelectionIndex]); + return GetEditedScoringComponent()->GetComponentTransform().TransformPositionNoScale(GetEditedScoringComponent()->LinePoints[CurrentLineSelectionIndex]); +} + +bool FIntenSelectableLineScoringVisualizer::IsVisualizingArchetype() const +{ + return (GetEditedScoringComponent() && GetEditedScoringComponent()->GetOwner() && FActorEditorUtils::IsAPreviewOrInactiveActor(GetEditedScoringComponent()->GetOwner())); } bool FIntenSelectableLineScoringVisualizer::ShowWhenSelected() { - return true; + return false; } bool FIntenSelectableLineScoringVisualizer::ShouldShowForSelectedSubcomponents(const UActorComponent* Component) @@ -48,7 +57,8 @@ bool FIntenSelectableLineScoringVisualizer::VisProxyHandleClick(FEditorViewportC if (VisProxy->IsA(FLinePointProxy::StaticGetType())) { const UIntenSelectableLineScoring* T = Cast<const UIntenSelectableLineScoring>(VisProxy->Component.Get()); - LineBehavior = const_cast<UIntenSelectableLineScoring*>(T); + ScoringBehaviourPropertyPath = FComponentPropertyPath(T); + FLinePointProxy* Proxy = (FLinePointProxy*)VisProxy; CurrentLineSelectionIndex = Proxy->TargetIndex; }else @@ -67,18 +77,10 @@ bool FIntenSelectableLineScoringVisualizer::VisProxyHandleClick(FEditorViewportC void FIntenSelectableLineScoringVisualizer::DrawVisualization(const UActorComponent* Component, const FSceneView* View, FPrimitiveDrawInterface* PDI) { const UIntenSelectableLineScoring* ComponentCasted = Cast<UIntenSelectableLineScoring>(Component); - if (ComponentCasted != nullptr) + if (ComponentCasted != nullptr && ComponentCasted->LinePoints.Num() == 2) { - if(ComponentCasted->LinePoints.Num() < 2) + for(int i = 0; i < ComponentCasted->LinePoints.Num() && i <= 2; i++) { - return; - } - for(int i = 0; i < ComponentCasted->LinePoints.Num(); i++) - { - if(i > 1) - { - break; - } PDI->SetHitProxy(new FLinePointProxy(Component, i)); FVector PointWorld = ComponentCasted->GetComponentTransform().TransformPosition(ComponentCasted->LinePoints[i]); @@ -86,21 +88,31 @@ void FIntenSelectableLineScoringVisualizer::DrawVisualization(const UActorCompon PDI->SetHitProxy(nullptr); } + + PDI->SetHitProxy(new FLinePointProxy(Component, 2)); + 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_World, 10); + PDI->DrawLine(Start, End, FColor::Green, SDPG_Foreground, 3); + + PDI->SetHitProxy(nullptr); } } void FIntenSelectableLineScoringVisualizer::EndEditing() { - LineBehavior->MarkRenderStateDirty(); + GetEditedScoringComponent()->MarkRenderStateDirty(); GEditor->RedrawLevelEditingViewports(true); } UActorComponent* FIntenSelectableLineScoringVisualizer::GetEditedComponent() const { - return LineBehavior; + return GetEditedScoringComponent(); +} + +UIntenSelectableLineScoring* FIntenSelectableLineScoringVisualizer::GetEditedScoringComponent() const +{ + return Cast<UIntenSelectableLineScoring>(ScoringBehaviourPropertyPath.GetComponent()); } bool FIntenSelectableLineScoringVisualizer::HandleInputDelta(FEditorViewportClient* ViewportClient, FViewport* Viewport, @@ -110,15 +122,41 @@ bool FIntenSelectableLineScoringVisualizer::HandleInputDelta(FEditorViewportClie if (CurrentLineSelectionIndex != INDEX_NONE) { - UE_LOG(LogTemp, Warning, TEXT("Current Selection! %s"), *DeltaTranslate.ToString()); + UIntenSelectableLineScoring* ScoringComponent = GetEditedScoringComponent(); + + if(ScoringComponent->LinePoints.Num() == 2) + { + + if(CurrentLineSelectionIndex == 2) + { + ScoringComponent->AddWorldOffset(DeltaTranslate); + ScoringComponent->AddWorldRotation(DeltaRotate); + }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); + ScoringComponent->LinePoints[CurrentLineSelectionIndex] = NewWorldPos; + + const FVector Average = (ScoringComponent->LinePoints[0] + ScoringComponent->LinePoints[1]) / 2; + + 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; + } - const FVector WorldSelection = LineBehavior->GetComponentTransform().TransformPosition(LineBehavior->LinePoints[CurrentLineSelectionIndex]); - const FVector NewWorldPos = LineBehavior->GetComponentTransform().InverseTransformPosition(WorldSelection + DeltaTranslate); - LineBehavior->LinePoints[CurrentLineSelectionIndex] = NewWorldPos; - LineBehavior->MarkRenderStateDirty(); - GEditor->RedrawLevelEditingViewports(true); - bHandled = true; }else { UE_LOG(LogTemp, Warning, TEXT("No Current Selection!")); @@ -130,7 +168,7 @@ bool FIntenSelectableLineScoringVisualizer::HandleInputDelta(FEditorViewportClie bool FIntenSelectableLineScoringVisualizer::GetWidgetLocation(const FEditorViewportClient* ViewportClient, FVector& OutLocation) const { - if (LineBehavior && CurrentLineSelectionIndex != INDEX_NONE) + if (GetEditedScoringComponent() && CurrentLineSelectionIndex != INDEX_NONE) { OutLocation = GetCurrentVectorWorld(); diff --git a/Source/RWTHVRToolkitEditor/Private/Interaction/IntenSelectableMultiPointScoringVisualizer.cpp b/Source/RWTHVRToolkitEditor/Private/Interaction/IntenSelectableMultiPointScoringVisualizer.cpp index b40ee03d..bf5799f5 100644 --- a/Source/RWTHVRToolkitEditor/Private/Interaction/IntenSelectableMultiPointScoringVisualizer.cpp +++ b/Source/RWTHVRToolkitEditor/Private/Interaction/IntenSelectableMultiPointScoringVisualizer.cpp @@ -1,15 +1,7 @@ #include "Interaction/IntenSelectableMultiPointScoringVisualizer.h" - #include "ActorEditorUtils.h" -#include "AsyncTreeDifferences.h" #include "SceneManagement.h" #include "Interaction/Interactables/IntenSelect/IntenSelectableMultiPointScoring.h" -#include "Kismet2/BlueprintEditorUtils.h" -#include "Net/Core/PushModel/PushModel.h" - -void UMyComponentVisualizerSelectionState::Reset() -{ -} IMPLEMENT_HIT_PROXY(FMultiPointProxy, HComponentVisProxy); @@ -33,7 +25,7 @@ FVector FIntenSelectableMultiPointScoringVisualizer::GetCurrentVectorWorld() con bool FIntenSelectableMultiPointScoringVisualizer::IsVisualizingArchetype() const { - return (GetEditedScoringComponent() && GetEditedScoringComponent()->GetOwner() && FActorEditorUtils::IsAPreviewOrInactiveActor(GetEditedScoringComponent()->GetOwner())); + return GetEditedScoringComponent() && GetEditedScoringComponent()->GetOwner() && FActorEditorUtils::IsAPreviewOrInactiveActor(GetEditedScoringComponent()->GetOwner()); } bool FIntenSelectableMultiPointScoringVisualizer::ShowWhenSelected() @@ -58,9 +50,7 @@ bool FIntenSelectableMultiPointScoringVisualizer::VisProxyHandleClick(FEditorVie if (VisProxy->IsA(FMultiPointProxy::StaticGetType())) { const UIntenSelectableMultiPointScoring* T = Cast<const UIntenSelectableMultiPointScoring>(VisProxy->Component.Get()); - //GetEditedScoringComponent() = const_cast<UIntenSelectableMultiPointScoring*>(T); - SplinePropertyPath = FComponentPropertyPath(T); - + ScoringBehaviourPropertyPath = FComponentPropertyPath(T); FMultiPointProxy* Proxy = (FMultiPointProxy*)VisProxy; CurrentSelectionIndex = Proxy->TargetIndex; @@ -86,12 +76,6 @@ void FIntenSelectableMultiPointScoringVisualizer::DrawVisualization(const UActor if (ComponentCasted != nullptr) { - - if(IsVisualizingArchetype()) - { - //SplinePropertyPath = FComponentPropertyPath(Component); - } - for(int i = 0; i < ComponentCasted->PointsToSelect.Num(); i++) { PDI->SetHitProxy(new FMultiPointProxy(Component, i)); @@ -106,8 +90,7 @@ void FIntenSelectableMultiPointScoringVisualizer::DrawVisualization(const UActor void FIntenSelectableMultiPointScoringVisualizer::EndEditing() { - //GetEditedScoringComponent()->MarkRenderStateDirty(); - //GEditor->RedrawLevelEditingViewports(true); + } UActorComponent* FIntenSelectableMultiPointScoringVisualizer::GetEditedComponent() const @@ -122,33 +105,24 @@ bool FIntenSelectableMultiPointScoringVisualizer::HandleInputDelta(FEditorViewpo if (CurrentSelectionIndex != INDEX_NONE) { - GetEditedScoringComponent()->Modify(); + UIntenSelectableMultiPointScoring* ScoringComponent = GetEditedScoringComponent(); + ScoringComponent->Modify(); - const FVector WorldSelection = GetEditedScoringComponent()->GetComponentTransform().TransformPosition(GetEditedScoringComponent()->PointsToSelect[CurrentSelectionIndex]); - const FVector NewWorldPos = GetEditedScoringComponent()->GetComponentTransform().InverseTransformPosition(WorldSelection + DeltaTranslate); - GetEditedScoringComponent()->PointsToSelect[CurrentSelectionIndex] = NewWorldPos; - - UE_LOG(LogTemp, Warning, TEXT("New Pos: %s"), *GetEditedScoringComponent()->PointsToSelect[CurrentSelectionIndex].ToString()); + 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()); - GetEditedScoringComponent()->MarkRenderStateDirty(); + ScoringComponent->MarkRenderStateDirty(); bHandled = true; TArray<FProperty*> Properties; Properties.Add(PointsProperty); - - - //GetEditedScoringComponent()->UpdatePoints(); - MyNotifyPropertiesModified(GetEditedScoringComponent(), Properties, EPropertyChangeType::ValueSet); - + NotifyPropertiesModified(ScoringComponent, Properties, EPropertyChangeType::ValueSet); GEditor->RedrawLevelEditingViewports(false); - if (GetEditedScoringComponent()->GetOwner() && GetEditedScoringComponent()->GetOwner()->GetClass()->IsInBlueprint()) - { - FBlueprintEditorUtils::MarkBlueprintAsModified(Cast<UBlueprint>(GetEditedScoringComponent()->GetOwner()->GetClass()->ClassGeneratedBy)); - } - }else { UE_LOG(LogTemp, Warning, TEXT("No Current Selection!")); @@ -157,143 +131,9 @@ bool FIntenSelectableMultiPointScoringVisualizer::HandleInputDelta(FEditorViewpo return bHandled; } -void FIntenSelectableMultiPointScoringVisualizer::MyNotifyPropertiesModified(USceneComponent* Component, const TArray<FProperty*>& Properties, EPropertyChangeType::Type PropertyChangeType) -{ - if (Component == nullptr) - { - return; - } - - for (FProperty* Property : Properties) - { - FPropertyChangedEvent PropertyChangedEvent(Property, PropertyChangeType); - Component->PostEditChangeProperty(PropertyChangedEvent); - } - - AActor* Owner = Component->GetOwner(); - - if (Owner && FActorEditorUtils::IsAPreviewOrInactiveActor(Owner)) - { - // The component belongs to the preview actor in the BP editor, so we need to propagate the property change to the archetype. - // Before this, we exploit the fact that the archetype and the preview actor have the old and new value of the property, respectively. - // So we can go through all archetype instances, and if they hold the (old) archetype value, update it to the new value. - - // Get archetype - USceneComponent* Archetype = Cast<USceneComponent>(Component->GetArchetype()); - check(Archetype); - - - - for (FProperty* Property : Properties) - { - uint8* ArchetypePtr = Property->ContainerPtrToValuePtr<uint8>(Archetype); - uint8* PreviewPtr = Property->ContainerPtrToValuePtr<uint8>(Component); - Property->CopyCompleteValue(ArchetypePtr, PreviewPtr); - - FPropertyChangedEvent PropertyChangedEvent(Property); - Archetype->PostEditChangeProperty(PropertyChangedEvent); - } - - // Get all archetype instances (the preview actor passed in should be amongst them) - TArray<UObject*> ArchetypeInstances; - Archetype->GetArchetypeInstances(ArchetypeInstances); - check(ArchetypeInstances.Contains(Component)); - - // Identify which of the modified properties are at their default values in the archetype instances, - // and thus need the new value to be propagated to them - struct FInstanceDefaultProperties - { - USceneComponent* ArchetypeInstance; - TArray<FProperty*, TInlineAllocator<8>> Properties; - }; - - TArray<FInstanceDefaultProperties> InstanceDefaultProperties; - InstanceDefaultProperties.Reserve(ArchetypeInstances.Num()); - - - for (UObject* ArchetypeInstance : ArchetypeInstances) - { - USceneComponent* InstanceComp = Cast<USceneComponent>(ArchetypeInstance); - if (InstanceComp != Component) - { - FInstanceDefaultProperties Entry; - for (FProperty* Property : Properties) - { - uint8* ArchetypePtr = Property->ContainerPtrToValuePtr<uint8>(Archetype); - uint8* InstancePtr = Property->ContainerPtrToValuePtr<uint8>(InstanceComp); - if (Property->Identical(ArchetypePtr, InstancePtr)) - { - Entry.Properties.Add(Property); - } - } - - if (Entry.Properties.Num() > 0) - { - Entry.ArchetypeInstance = InstanceComp; - InstanceDefaultProperties.Add(MoveTemp(Entry)); - } - } - } - // Propagate all modified properties to the archetype - Archetype->SetFlags(RF_Transactional); - Archetype->Modify(); - - if (Archetype->GetOwner()) - { - Archetype->GetOwner()->Modify(); - } - - for (FProperty* Property : Properties) - { - uint8* ArchetypePtr = Property->ContainerPtrToValuePtr<uint8>(Archetype); - uint8* PreviewPtr = Property->ContainerPtrToValuePtr<uint8>(Component); - Property->CopyCompleteValue(ArchetypePtr, PreviewPtr); - - FPropertyChangedEvent PropertyChangedEvent(Property); - Archetype->PostEditChangeProperty(PropertyChangedEvent); - } - - // Apply changes to each archetype instance - for (const auto& Instance : InstanceDefaultProperties) - { - Instance.ArchetypeInstance->SetFlags(RF_Transactional); - Instance.ArchetypeInstance->Modify(); - - AActor* InstanceOwner = Instance.ArchetypeInstance->GetOwner(); - - if (InstanceOwner) - { - InstanceOwner->Modify(); - } - - for (FProperty* Property : Instance.Properties) - { - uint8* InstancePtr = Property->ContainerPtrToValuePtr<uint8>(Instance.ArchetypeInstance); - uint8* PreviewPtr = Property->ContainerPtrToValuePtr<uint8>(Component); - Property->CopyCompleteValue(InstancePtr, PreviewPtr); - - FPropertyChangedEvent PropertyChangedEvent(Property); - Instance.ArchetypeInstance->PostEditChangeProperty(PropertyChangedEvent); - } - - // Rerun construction script on instance - if (InstanceOwner) - { - InstanceOwner->PostEditMove(PropertyChangeType == EPropertyChangeType::ValueSet); - } - } - } - - // Rerun construction script on preview actor - if (Owner) - { - Owner->PostEditMove(PropertyChangeType == EPropertyChangeType::ValueSet); - } -} - UIntenSelectableMultiPointScoring* FIntenSelectableMultiPointScoringVisualizer::GetEditedScoringComponent() const { - return Cast<UIntenSelectableMultiPointScoring>(SplinePropertyPath.GetComponent()); + return Cast<UIntenSelectableMultiPointScoring>(ScoringBehaviourPropertyPath.GetComponent()); } bool FIntenSelectableMultiPointScoringVisualizer::GetWidgetLocation(const FEditorViewportClient* ViewportClient, @@ -308,5 +148,3 @@ bool FIntenSelectableMultiPointScoringVisualizer::GetWidgetLocation(const FEdito return false; } - - diff --git a/Source/RWTHVRToolkitEditor/Private/Interaction/IntenSelectableMultiRectangleScoringVisualizer.cpp b/Source/RWTHVRToolkitEditor/Private/Interaction/IntenSelectableMultiRectangleScoringVisualizer.cpp index b092861e..3136547d 100644 --- a/Source/RWTHVRToolkitEditor/Private/Interaction/IntenSelectableMultiRectangleScoringVisualizer.cpp +++ b/Source/RWTHVRToolkitEditor/Private/Interaction/IntenSelectableMultiRectangleScoringVisualizer.cpp @@ -1,20 +1,26 @@ +#include "ActorEditorUtils.h" #include "Interaction/IntenSelectableRectangleScoringVisualizer.h" - #include "SceneManagement.h" #include "Interaction/Interactables/IntenSelect/IntenSelectableRectangleScoring.h" -#include "Kismet/KismetMathLibrary.h" 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)); } FIntenSelectableRectangleScoringVisualizer::~FIntenSelectableRectangleScoringVisualizer() { } +bool FIntenSelectableRectangleScoringVisualizer::IsVisualizingArchetype() const +{ + return GetEditedScoringComponent() && GetEditedScoringComponent()->GetOwner() && FActorEditorUtils::IsAPreviewOrInactiveActor(GetEditedScoringComponent()->GetOwner()); + +} + FVector FIntenSelectableRectangleScoringVisualizer::GetCurrentVectorWorld() const { if(CurrentSelectionIndex == INDEX_NONE) @@ -22,10 +28,10 @@ FVector FIntenSelectableRectangleScoringVisualizer::GetCurrentVectorWorld() cons return FVector::ZeroVector; } - const FVector X = RectangleBehaviour->GetRightVector() * RectangleBehaviour->XLength; - const FVector Y = RectangleBehaviour->GetUpVector() * RectangleBehaviour->YLength; + const FVector X = GetEditedScoringComponent()->GetRightVector() * GetEditedScoringComponent()->XLength; + const FVector Y = GetEditedScoringComponent()->GetUpVector() * GetEditedScoringComponent()->YLength; - const FVector CornerWorld00 = RectangleBehaviour->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; @@ -74,7 +80,8 @@ bool FIntenSelectableRectangleScoringVisualizer::VisProxyHandleClick(FEditorView if (VisProxy->IsA(FRectangleProxy::StaticGetType())) { const UIntenSelectableRectangleScoring* T = Cast<const UIntenSelectableRectangleScoring>(VisProxy->Component.Get()); - RectangleBehaviour = const_cast<UIntenSelectableRectangleScoring*>(T); + ScoringBehaviourPropertyPath = FComponentPropertyPath(T); + FRectangleProxy* Proxy = (FRectangleProxy*)VisProxy; CurrentSelectionIndex = Proxy->TargetIndex; }else @@ -139,76 +146,99 @@ void FIntenSelectableRectangleScoringVisualizer::EndEditing() UActorComponent* FIntenSelectableRectangleScoringVisualizer::GetEditedComponent() const { - return RectangleBehaviour; + return GetEditedScoringComponent(); +} + +UIntenSelectableRectangleScoring* FIntenSelectableRectangleScoringVisualizer::GetEditedScoringComponent() const +{ + return Cast<UIntenSelectableRectangleScoring>(ScoringBehaviourPropertyPath.GetComponent()); } bool FIntenSelectableRectangleScoringVisualizer::HandleInputDelta(FEditorViewportClient* ViewportClient, FViewport* Viewport, - FVector& DeltaTranslate, FRotator& DeltaRotate, FVector& DeltaScale) + FVector& DeltaTranslate, FRotator& DeltaRotate, FVector& DeltaScale) { + bool bHandled = false; + if (CurrentSelectionIndex != INDEX_NONE) { + UIntenSelectableRectangleScoring* ScoringComponent = GetEditedScoringComponent(); + ScoringComponent->Modify(); + switch (CurrentSelectionIndex) { case 0: //bottom - RectangleBehaviour->YLength -= DeltaTranslate.Z; - if(RectangleBehaviour->YLength < 0.1) + ScoringComponent->YLength -= DeltaTranslate.Z; + if(ScoringComponent->YLength < 0.1) { - RectangleBehaviour->YLength = 0.1; + ScoringComponent->YLength = 0.1; }else { - RectangleBehaviour->AddLocalOffset(FVector::UpVector * DeltaTranslate.Z / 2); + ScoringComponent->AddLocalOffset(FVector::UpVector * DeltaTranslate.Z / 2); } - return true; + bHandled = true; + break; case 1: //left - RectangleBehaviour->XLength -= DeltaTranslate.Y; - if(RectangleBehaviour->XLength < 0.1) + ScoringComponent->XLength -= DeltaTranslate.Y; + if(ScoringComponent->XLength < 0.1) { - RectangleBehaviour->XLength = 0.1; + ScoringComponent->XLength = 0.1; }else { - RectangleBehaviour->AddLocalOffset(FVector::RightVector * DeltaTranslate.Y / 2); + ScoringComponent->AddLocalOffset(FVector::RightVector * DeltaTranslate.Y / 2); } - return true; + bHandled = true; + break; case 2: //top - RectangleBehaviour->YLength += DeltaTranslate.Z; - if(RectangleBehaviour->YLength < 0.1) + ScoringComponent->YLength += DeltaTranslate.Z; + if(ScoringComponent->YLength < 0.1) { - RectangleBehaviour->YLength = 0.1; + ScoringComponent->YLength = 0.1; }else { - RectangleBehaviour->AddLocalOffset(FVector::UpVector * DeltaTranslate.Z / 2); + ScoringComponent->AddLocalOffset(FVector::UpVector * DeltaTranslate.Z / 2); } - return true; + bHandled = true; + break; case 3: //right - RectangleBehaviour->XLength += DeltaTranslate.Y; - if(RectangleBehaviour->XLength < 0.1) + ScoringComponent->XLength += DeltaTranslate.Y; + if(ScoringComponent->XLength < 0.1) { - RectangleBehaviour->XLength = 0.1; + ScoringComponent->XLength = 0.1; }else { - RectangleBehaviour->AddLocalOffset(FVector::RightVector * DeltaTranslate.Y / 2); + ScoringComponent->AddLocalOffset(FVector::RightVector * DeltaTranslate.Y / 2); } - return true; + bHandled = true; + break; case 4: { //middle - const FVector WorldCenter = RectangleBehaviour->GetComponentLocation(); + const FVector WorldCenter = ScoringComponent->GetComponentLocation(); const FVector NewWorldCenter = WorldCenter + DeltaTranslate; - RectangleBehaviour->SetWorldLocation(NewWorldCenter); - RectangleBehaviour->AddWorldRotation(DeltaRotate); + ScoringComponent->SetWorldLocation(NewWorldCenter); + ScoringComponent->AddWorldRotation(DeltaRotate); - const FVector LocalScaleDelta = RectangleBehaviour->GetComponentTransform().InverseTransformVector(DeltaScale); - RectangleBehaviour->XLength += LocalScaleDelta.Y * 4; - RectangleBehaviour->YLength += LocalScaleDelta.Z * 4; - return true; + const FVector LocalScaleDelta = ScoringComponent->GetComponentTransform().InverseTransformVector(DeltaScale); + ScoringComponent->XLength += LocalScaleDelta.Y * 4; + ScoringComponent->YLength += LocalScaleDelta.Z * 4; + bHandled = true; + break; } default: - return false; + bHandled = false; + break; } + + TArray<FProperty*> Properties; + Properties.Add(XLengthProperty); + Properties.Add(YLengthProperty); + NotifyPropertiesModified(ScoringComponent, Properties, EPropertyChangeType::ValueSet); + + return bHandled; }else { UE_LOG(LogTemp, Warning, TEXT("No Current Selection!")); diff --git a/Source/RWTHVRToolkitEditor/Private/Interaction/IntenSelectableSphereScoringVisualizer.cpp b/Source/RWTHVRToolkitEditor/Private/Interaction/IntenSelectableSphereScoringVisualizer.cpp index 8cf64a03..f6059cf7 100644 --- a/Source/RWTHVRToolkitEditor/Private/Interaction/IntenSelectableSphereScoringVisualizer.cpp +++ b/Source/RWTHVRToolkitEditor/Private/Interaction/IntenSelectableSphereScoringVisualizer.cpp @@ -1,4 +1,6 @@ #include "Interaction/IntenSelectableSphereScoringVisualizer.h" + +#include "ActorEditorUtils.h" #include "SceneManagement.h" #include "MaterialShared.h" #include "Interaction/Interactables/IntenSelect/IntenSelectableSphereScoring.h" @@ -9,16 +11,21 @@ IMPLEMENT_HIT_PROXY(FSphereProxy, HComponentVisProxy); FIntenSelectableSphereScoringVisualizer::FIntenSelectableSphereScoringVisualizer() : DebugMaterial(FColoredMaterialRenderProxy(GEngine->ConstraintLimitMaterial->GetRenderProxy(), FColor::Green)) { - + PointsProperty = FindFProperty<FProperty>(UIntenSelectableSphereScoring::StaticClass(), GET_MEMBER_NAME_CHECKED(UIntenSelectableSphereScoring, Radius)); } FIntenSelectableSphereScoringVisualizer::~FIntenSelectableSphereScoringVisualizer() { } +bool FIntenSelectableSphereScoringVisualizer::IsVisualizingArchetype() const +{ + return GetEditedScoringComponent() && GetEditedScoringComponent()->GetOwner() && FActorEditorUtils::IsAPreviewOrInactiveActor(GetEditedScoringComponent()->GetOwner()); +} + FVector FIntenSelectableSphereScoringVisualizer::GetCurrentVectorWorld() const { - return SphereBehaviour->GetComponentLocation(); + return GetEditedScoringComponent()->GetComponentLocation(); } bool FIntenSelectableSphereScoringVisualizer::ShowWhenSelected() @@ -45,7 +52,8 @@ bool FIntenSelectableSphereScoringVisualizer::VisProxyHandleClick(FEditorViewpor if (VisProxy->IsA(FSphereProxy::StaticGetType())) { const UIntenSelectableSphereScoring* T = Cast<const UIntenSelectableSphereScoring>(VisProxy->Component.Get()); - SphereBehaviour = const_cast<UIntenSelectableSphereScoring*>(T); + ScoringBehaviourPropertyPath = FComponentPropertyPath(T); + FSphereProxy* Proxy = (FSphereProxy*)VisProxy; CurrentSelectionIndex = Proxy->TargetIndex; }else @@ -61,16 +69,15 @@ bool FIntenSelectableSphereScoringVisualizer::VisProxyHandleClick(FEditorViewpor return bEditing; } - -// Fill out your copyright notice in the Description page of Project Settings. - 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); + PDI->SetHitProxy(nullptr); } } @@ -82,26 +89,56 @@ void FIntenSelectableSphereScoringVisualizer::EndEditing() UActorComponent* FIntenSelectableSphereScoringVisualizer::GetEditedComponent() const { - return SphereBehaviour; + return GetEditedScoringComponent(); +} + +UIntenSelectableSphereScoring* FIntenSelectableSphereScoringVisualizer::GetEditedScoringComponent() const +{ + return Cast<UIntenSelectableSphereScoring>(ScoringBehaviourPropertyPath.GetComponent()); } bool FIntenSelectableSphereScoringVisualizer::HandleInputDelta(FEditorViewportClient* ViewportClient, FViewport* Viewport, - FVector& DeltaTranslate, FRotator& DeltaRotate, FVector& DeltaScale) + FVector& DeltaTranslate, FRotator& DeltaRotate, FVector& DeltaScale) { bool bHandled = false; - if (CurrentSelectionIndex != INDEX_NONE) + if (true || CurrentSelectionIndex != INDEX_NONE) { UE_LOG(LogTemp, Warning, TEXT("Current Selection! %s"), *DeltaTranslate.ToString()); - if(CurrentSelectionIndex == 0) + if((true || CurrentSelectionIndex == 0 )&& GetEditedComponent()) { - const FVector LocalCenter = SphereBehaviour->GetComponentLocation(); + UIntenSelectableSphereScoring* ScoringComponent = GetEditedScoringComponent(); + ScoringComponent->Modify(); + + const FVector LocalCenter = ScoringComponent->GetComponentLocation(); const FVector NewCenter = LocalCenter + DeltaTranslate; - SphereBehaviour->SetWorldLocation(NewCenter); - SphereBehaviour->AddWorldRotation(DeltaRotate); - SphereBehaviour->Radius += (DeltaScale.X + DeltaScale.Y + DeltaScale.Z) * 2; + 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 + float NewRadius; + if (AverageScaleFactor > 0) + { + // Scale up: Increase the radius + NewRadius = ScoringComponent->Radius * (1.0f + FMath::Abs(AverageScaleFactor)); + } + else + { + // 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; + + TArray<FProperty*> Properties; + Properties.Add(PointsProperty); + NotifyPropertiesModified(ScoringComponent, Properties, EPropertyChangeType::ValueSet); + + ScoringComponent->MarkRenderStateDirty(); + GEditor->RedrawLevelEditingViewports(false); bHandled = true; } }else diff --git a/Source/RWTHVRToolkitEditor/Public/Interaction/IntenSelectableCircleScoringVisualizer.h b/Source/RWTHVRToolkitEditor/Public/Interaction/IntenSelectableCircleScoringVisualizer.h index 6082994a..4f71ca88 100644 --- a/Source/RWTHVRToolkitEditor/Public/Interaction/IntenSelectableCircleScoringVisualizer.h +++ b/Source/RWTHVRToolkitEditor/Public/Interaction/IntenSelectableCircleScoringVisualizer.h @@ -28,8 +28,8 @@ class RWTHVRTOOLKITEDITOR_API FIntenSelectableCircleScoringVisualizer : public F { private: int CurrentSelectionIndex; - - UIntenSelectableCircleScoring* CircleBehaviour; + FProperty* PointsProperty; + FComponentPropertyPath ScoringBehaviourPropertyPath; public: FIntenSelectableCircleScoringVisualizer(); @@ -37,6 +37,9 @@ public: FVector GetCurrentVectorWorld() const; + 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; diff --git a/Source/RWTHVRToolkitEditor/Public/Interaction/IntenSelectableCubeScoringVisualizer.h b/Source/RWTHVRToolkitEditor/Public/Interaction/IntenSelectableCubeScoringVisualizer.h index 441d187d..2983aff7 100644 --- a/Source/RWTHVRToolkitEditor/Public/Interaction/IntenSelectableCubeScoringVisualizer.h +++ b/Source/RWTHVRToolkitEditor/Public/Interaction/IntenSelectableCubeScoringVisualizer.h @@ -1,14 +1,10 @@ -// Fill out your copyright notice in the Description page of Project Settings. - #pragma once #include "CoreMinimal.h" #include "ComponentVisualizer.h" #include "Materials/MaterialRenderProxy.h" + class UIntenSelectableCubeScoring; -/** - * - */ class FPrimitiveDrawInterface; class FSceneView; @@ -31,7 +27,8 @@ private: int CurrentSelectionIndex; FColoredMaterialRenderProxy DebugMaterial; - UIntenSelectableCubeScoring* CubeBehaviour; + FProperty* PointsProperty; + FComponentPropertyPath ScoringBehaviourPropertyPath; public: FIntenSelectableCubeScoringVisualizer(); @@ -39,6 +36,9 @@ public: FVector GetCurrentVectorWorld() const; + virtual bool IsVisualizingArchetype() const override; + UIntenSelectableCubeScoring* GetEditedScoringComponent() const; + virtual bool ShowWhenSelected() override; virtual bool ShouldShowForSelectedSubcomponents(const UActorComponent* Component) override; virtual bool VisProxyHandleClick(FEditorViewportClient* InViewportClient, HComponentVisProxy* VisProxy, const FViewportClick& Click) override; diff --git a/Source/RWTHVRToolkitEditor/Public/Interaction/IntenSelectableCylinderScoringVisualizer.h b/Source/RWTHVRToolkitEditor/Public/Interaction/IntenSelectableCylinderScoringVisualizer.h index 8300420a..6b9797e5 100644 --- a/Source/RWTHVRToolkitEditor/Public/Interaction/IntenSelectableCylinderScoringVisualizer.h +++ b/Source/RWTHVRToolkitEditor/Public/Interaction/IntenSelectableCylinderScoringVisualizer.h @@ -1,15 +1,11 @@ -// Fill out your copyright notice in the Description page of Project Settings. - #pragma once #include "CoreMinimal.h" #include "ComponentVisualizer.h" #include "Interaction/Interactables/IntenSelect/IntenSelectableCylinderScoring.h" #include "Materials/MaterialRenderProxy.h" + class UIntenSelectableLineScoring; -/** - * - */ class FPrimitiveDrawInterface; class FSceneView; @@ -53,24 +49,28 @@ class RWTHVRTOOLKITEDITOR_API FIntenSelectableCylinderScoringVisualizer : public { private: int CurrentCylinderSelectionIndex; - - UIntenSelectableCylinderScoring* CylinderBehavior; FColoredMaterialRenderProxy DebugMaterial; - - //TArray<FVector> LinePoints{FVector::ZeroVector, FVector::ZeroVector}; + FProperty* RadiusProperty; + FProperty* PointsProperty; + FComponentPropertyPath ScoringBehaviourPropertyPath; public: FIntenSelectableCylinderScoringVisualizer(); ~FIntenSelectableCylinderScoringVisualizer(); - - FVector GetCurrentVectorWorld() const; - + + 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 void EndEditing() override; - virtual UActorComponent* GetEditedComponent() const 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; + + virtual UActorComponent* GetEditedComponent() const override; + UIntenSelectableCylinderScoring* GetEditedScoringComponent() const; + + virtual void EndEditing() override; }; diff --git a/Source/RWTHVRToolkitEditor/Public/Interaction/IntenSelectableLineScoringVisualizer.h b/Source/RWTHVRToolkitEditor/Public/Interaction/IntenSelectableLineScoringVisualizer.h index 8e5efad0..794cb29b 100644 --- a/Source/RWTHVRToolkitEditor/Public/Interaction/IntenSelectableLineScoringVisualizer.h +++ b/Source/RWTHVRToolkitEditor/Public/Interaction/IntenSelectableLineScoringVisualizer.h @@ -28,8 +28,9 @@ class RWTHVRTOOLKITEDITOR_API FIntenSelectableLineScoringVisualizer : public FCo { private: int CurrentLineSelectionIndex; - + FProperty* PointsProperty; UIntenSelectableLineScoring* LineBehavior; + FComponentPropertyPath ScoringBehaviourPropertyPath; public: FIntenSelectableLineScoringVisualizer(); @@ -37,13 +38,18 @@ public: FVector GetCurrentVectorWorld() const; + 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 void EndEditing() override; - virtual UActorComponent* GetEditedComponent() const 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 fef5d08c..09c8fdd8 100644 --- a/Source/RWTHVRToolkitEditor/Public/Interaction/IntenSelectableMultiPointScoringVisualizer.h +++ b/Source/RWTHVRToolkitEditor/Public/Interaction/IntenSelectableMultiPointScoringVisualizer.h @@ -1,35 +1,12 @@ -// Fill out your copyright notice in the Description page of Project Settings. - #pragma once #include "CoreMinimal.h" #include "ComponentVisualizer.h" -#include "IntenSelectableMultiPointScoringVisualizer.generated.h" class UIntenSelectableMultiPointScoring; class FPrimitiveDrawInterface; class FSceneView; -/** Selection state data that will be captured by scoped transactions.*/ -UCLASS() -class UMyComponentVisualizerSelectionState : public UObject -{ - GENERATED_BODY() -public: - void Reset(); - void SetSplinePropertyPath(const FComponentPropertyPath& InSplinePropertyPath) { SplinePropertyPath = InSplinePropertyPath; } - const FComponentPropertyPath GetSplinePropertyPath() const { return SplinePropertyPath; } -protected: - /** Property path from the parent actor to the component */ - UPROPERTY() - FComponentPropertyPath SplinePropertyPath; - - /** Position on spline we have selected */ - UPROPERTY() - FVector SelectedSplinePosition; -}; - - struct FMultiPointProxy : HComponentVisProxy { DECLARE_HIT_PROXY(); @@ -47,34 +24,26 @@ class RWTHVRTOOLKITEDITOR_API FIntenSelectableMultiPointScoringVisualizer : publ { private: int CurrentSelectionIndex; - FProperty* PointsProperty; - - TObjectPtr<UMyComponentVisualizerSelectionState> SelectionState; - - UIntenSelectableMultiPointScoring* MultiPointBehaviour; - - FComponentPropertyPath SplinePropertyPath; + FComponentPropertyPath ScoringBehaviourPropertyPath; public: FIntenSelectableMultiPointScoringVisualizer(); ~FIntenSelectableMultiPointScoringVisualizer(); - - FVector GetCurrentVectorWorld() const; 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 void EndEditing() override; - virtual UActorComponent* GetEditedComponent() const override; - - UIntenSelectableMultiPointScoring* GetEdited() const; virtual bool HandleInputDelta(FEditorViewportClient* ViewportClient, FViewport* Viewport, FVector& DeltaTranslate, FRotator& DeltaRotate, FVector& DeltaScale) override; - virtual bool GetWidgetLocation(const FEditorViewportClient* ViewportClient, FVector& OutLocation) const override; - - static void MyNotifyPropertiesModified(USceneComponent* Component, const TArray<FProperty*>& Properties, EPropertyChangeType::Type PropertyChangeType = EPropertyChangeType::Unspecified); + 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 8c36a302..0e6025cd 100644 --- a/Source/RWTHVRToolkitEditor/Public/Interaction/IntenSelectableRectangleScoringVisualizer.h +++ b/Source/RWTHVRToolkitEditor/Public/Interaction/IntenSelectableRectangleScoringVisualizer.h @@ -28,22 +28,27 @@ class RWTHVRTOOLKITEDITOR_API FIntenSelectableRectangleScoringVisualizer : publi { private: int CurrentSelectionIndex; - - UIntenSelectableRectangleScoring* RectangleBehaviour; + FProperty* XLengthProperty; + FProperty* YLengthProperty; + FComponentPropertyPath ScoringBehaviourPropertyPath; public: FIntenSelectableRectangleScoringVisualizer(); ~FIntenSelectableRectangleScoringVisualizer(); - - FVector GetCurrentVectorWorld() const; - + + 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 void EndEditing() override; - virtual UActorComponent* GetEditedComponent() const 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 938455a3..ca499b92 100644 --- a/Source/RWTHVRToolkitEditor/Public/Interaction/IntenSelectableSphereScoringVisualizer.h +++ b/Source/RWTHVRToolkitEditor/Public/Interaction/IntenSelectableSphereScoringVisualizer.h @@ -1,14 +1,10 @@ -// Fill out your copyright notice in the Description page of Project Settings. - #pragma once #include "CoreMinimal.h" #include "ComponentVisualizer.h" #include "Materials/MaterialRenderProxy.h" + class UIntenSelectableSphereScoring; -/** - * - */ class FPrimitiveDrawInterface; class FSceneView; @@ -29,23 +25,30 @@ class RWTHVRTOOLKITEDITOR_API FIntenSelectableSphereScoringVisualizer : public F { private: int CurrentSelectionIndex; - FColoredMaterialRenderProxy DebugMaterial; - UIntenSelectableSphereScoring* SphereBehaviour; + FProperty* PointsProperty; + FComponentPropertyPath ScoringBehaviourPropertyPath; public: FIntenSelectableSphereScoringVisualizer(); ~FIntenSelectableSphereScoringVisualizer(); - FVector GetCurrentVectorWorld() const; + 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 void EndEditing() override; - virtual UActorComponent* GetEditedComponent() const override; virtual bool HandleInputDelta(FEditorViewportClient* ViewportClient, FViewport* Viewport, FVector& DeltaTranslate, FRotator& DeltaRotate, FVector& DeltaScale) override; + + virtual UActorComponent* GetEditedComponent() const override; + UIntenSelectableSphereScoring* GetEditedScoringComponent() const; + + FVector GetCurrentVectorWorld() const; virtual bool GetWidgetLocation(const FEditorViewportClient* ViewportClient, FVector& OutLocation) const override; + + virtual void EndEditing() override; + }; -- GitLab