diff --git a/Source/StevesUEHelpers/Private/StevesEditorVisComponent.cpp b/Source/StevesUEHelpers/Private/StevesEditorVisComponent.cpp index 0e26477..b0e0b29 100644 --- a/Source/StevesUEHelpers/Private/StevesEditorVisComponent.cpp +++ b/Source/StevesUEHelpers/Private/StevesEditorVisComponent.cpp @@ -27,6 +27,11 @@ FPrimitiveSceneProxy* UStevesEditorVisComponent::CreateSceneProxy() auto Ret = new FStevesDebugRenderSceneProxy(this); const FTransform& XForm = GetComponentTransform(); + for (auto& L : Lines) + { + Ret->Lines.Add(FDebugRenderSceneProxy::FDebugLine(XForm.TransformPosition(L.Start), + XForm.TransformPosition(L.End), L.Colour)); + } for (auto& C : Circles) { FQuat WorldRot = XForm.TransformRotation(C.Rotation.Quaternion()); @@ -47,6 +52,12 @@ FBoxSphereBounds UStevesEditorVisComponent::CalcBounds(const FTransform& LocalTo FBoxSphereBounds B = Super::CalcBounds(LocalToWorld); // Now we need to merge in all components + for (auto& L : Lines) + { + // Re-centre the origin of the line to make box extents + FVector Extents = L.Start.GetAbs().ComponentMax(L.End.GetAbs()); + B = B + FBoxSphereBounds(FVector::ZeroVector, Extents, Extents.GetMax()); + } for (auto& C : Circles) { B = B + FBoxSphereBounds(C.Location, FVector(C.Radius), C.Radius); diff --git a/Source/StevesUEHelpers/Public/StevesEditorVisComponent.h b/Source/StevesUEHelpers/Public/StevesEditorVisComponent.h index 1e25f28..c3a923b 100644 --- a/Source/StevesUEHelpers/Public/StevesEditorVisComponent.h +++ b/Source/StevesUEHelpers/Public/StevesEditorVisComponent.h @@ -7,6 +7,37 @@ #include "StevesEditorVisComponent.generated.h" +USTRUCT(BlueprintType) +struct FStevesEditorVisLine +{ + GENERATED_BODY() + + /// Start location relative to component + UPROPERTY(EditAnywhere) + FVector Start; + /// End location relative to component + UPROPERTY(EditAnywhere) + FVector End; + /// The colour of the line render + UPROPERTY(EditAnywhere) + FColor Colour; + + FStevesEditorVisLine(const FVector& InStart, const FVector& InEnd, + const FColor& InColour) + : Start(InStart), + End(InEnd), + Colour(Colour) + { + } + + FStevesEditorVisLine(): + Start(FVector::ZeroVector), + End(FVector(100,0,0)), + Colour(FColor::White) + { + } +}; + USTRUCT(BlueprintType) struct FStevesEditorVisCircle { @@ -28,13 +59,13 @@ struct FStevesEditorVisCircle UPROPERTY(EditAnywhere) FColor Colour; - FStevesEditorVisCircle(const FVector& Location, const FRotator& Rotation, float Radius, int NumSegments, - const FColor& Colour) - : Location(Location), - Rotation(Rotation), - Radius(Radius), - NumSegments(NumSegments), - Colour(Colour) + FStevesEditorVisCircle(const FVector& InLocation, const FRotator& InRotation, float InRadius, int InNumSegments, + const FColor& InColour) + : Location(InLocation), + Rotation(InRotation), + Radius(InRadius), + NumSegments(InNumSegments), + Colour(InColour) { } @@ -58,13 +89,16 @@ struct FStevesEditorVisCircle * If you want to, you can add this to your Blueprints too. This component automatically marks itself as "visualisation * only" so shouldn't have a runtime impact. */ -UCLASS(ClassGroup="Debug", hidecategories=(Collision,Physics,Object,LOD,Lighting,TextureStreaming), meta=(DisplayName="Steves Editor Visualisation", BlueprintSpawnableComponent)) +UCLASS(Blueprintable, ClassGroup="Utility", hidecategories=(Collision,Physics,Object,LOD,Lighting,TextureStreaming), meta=(DisplayName="Steves Editor Visualisation", BlueprintSpawnableComponent)) class STEVESUEHELPERS_API UStevesEditorVisComponent : public UPrimitiveComponent { GENERATED_BODY() public: + /// Circles to render UPROPERTY(EditAnywhere, BlueprintReadWrite) + TArray Lines; + UPROPERTY(EditAnywhere, BlueprintReadWrite) TArray Circles; UStevesEditorVisComponent(const FObjectInitializer& ObjectInitializer);