From 1b8a5a805c18ae664fd34a3fcd1da6cdc6c48004 Mon Sep 17 00:00:00 2001 From: Steve Streeting Date: Tue, 14 Sep 2021 14:29:07 +0100 Subject: [PATCH] Add arrows and spheres --- .../Private/StevesEditorVisComponent.cpp | 23 ++++++++++++ .../Public/StevesEditorVisComponent.h | 36 +++++++++++++++++++ 2 files changed, 59 insertions(+) diff --git a/Source/StevesUEHelpers/Private/StevesEditorVisComponent.cpp b/Source/StevesUEHelpers/Private/StevesEditorVisComponent.cpp index 013b0f5..be9dee5 100644 --- a/Source/StevesUEHelpers/Private/StevesEditorVisComponent.cpp +++ b/Source/StevesUEHelpers/Private/StevesEditorVisComponent.cpp @@ -33,6 +33,11 @@ FPrimitiveSceneProxy* UStevesEditorVisComponent::CreateSceneProxy() Ret->Lines.Add(FDebugRenderSceneProxy::FDebugLine(XForm.TransformPosition(L.Start), XForm.TransformPosition(L.End), L.Colour)); } + for (auto& A : Arrows) + { + Ret->ArrowLines.Add(FDebugRenderSceneProxy::FArrowLine(XForm.TransformPosition(A.Start), + XForm.TransformPosition(A.End), A.Colour)); + } for (auto& C : Circles) { FQuat WorldRot = XForm.TransformRotation(C.Rotation.Quaternion()); @@ -54,6 +59,14 @@ FPrimitiveSceneProxy* UStevesEditorVisComponent::CreateSceneProxy() Arc.NumSegments, Arc.Colour )); } + for (auto& S : Spheres) + { + Ret->Spheres.Add(FStevesDebugRenderSceneProxy::FSphere( + XForm.GetMaximumAxisScale() * S.Radius, + XForm.TransformPosition(S.Location), + S.Colour + )); + } return Ret; @@ -70,6 +83,12 @@ FBoxSphereBounds UStevesEditorVisComponent::CalcBounds(const FTransform& LocalTo FVector Extents = L.Start.GetAbs().ComponentMax(L.End.GetAbs()); B = B + FBoxSphereBounds(FVector::ZeroVector, Extents, Extents.GetMax()); } + for (auto& A : Arrows) + { + // Re-centre the origin of the line to make box extents + FVector Extents = A.Start.GetAbs().ComponentMax(A.End.GetAbs()); + B = B + FBoxSphereBounds(FVector::ZeroVector, Extents, Extents.GetMax()); + } for (auto& C : Circles) { B = B + FBoxSphereBounds(C.Location, FVector(C.Radius), C.Radius); @@ -79,6 +98,10 @@ FBoxSphereBounds UStevesEditorVisComponent::CalcBounds(const FTransform& LocalTo // Just use the entire circle for simplicity B = B + FBoxSphereBounds(Arc.Location, FVector(Arc.Radius), Arc.Radius); } + for (auto& S : Spheres) + { + B = B + FBoxSphereBounds(S.Location, FVector(S.Radius), S.Radius); + } return B.TransformBy(LocalToWorld); } diff --git a/Source/StevesUEHelpers/Public/StevesEditorVisComponent.h b/Source/StevesUEHelpers/Public/StevesEditorVisComponent.h index 74a805b..c674020 100644 --- a/Source/StevesUEHelpers/Public/StevesEditorVisComponent.h +++ b/Source/StevesUEHelpers/Public/StevesEditorVisComponent.h @@ -129,6 +129,38 @@ struct FStevesEditorVisArc } }; +USTRUCT(BlueprintType) +struct FStevesEditorVisSphere +{ + GENERATED_BODY() + + /// Location relative to component + UPROPERTY(EditAnywhere) + FVector Location; + /// Sphere radius + UPROPERTY(EditAnywhere) + float Radius; + /// The colour of the line render + UPROPERTY(EditAnywhere) + FColor Colour; + + FStevesEditorVisSphere(const FVector& InLocation, float InRadius, const FColor& InColour) : + Location(InLocation), + Radius(InRadius), + Colour(InColour) + { + } + + FStevesEditorVisSphere(): + Location(FVector::ZeroVector), + Radius(50), + Colour(FColor::White) + { + } +}; + + + /** * * A component that solely exists to provide arbitrary editor visualisation when not selected. @@ -151,9 +183,13 @@ public: UPROPERTY(EditAnywhere, BlueprintReadWrite) TArray Lines; UPROPERTY(EditAnywhere, BlueprintReadWrite) + TArray Arrows; + UPROPERTY(EditAnywhere, BlueprintReadWrite) TArray Circles; UPROPERTY(EditAnywhere, BlueprintReadWrite) TArray Arcs; + UPROPERTY(EditAnywhere, BlueprintReadWrite) + TArray Spheres; UStevesEditorVisComponent(const FObjectInitializer& ObjectInitializer);