mirror of
https://github.com/sinbad/StevesUEHelpers.git
synced 2025-02-23 17:45:23 +00:00
Add line support to vis component
This commit is contained in:
parent
94a783e0d4
commit
056bae4719
@ -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);
|
||||
|
@ -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<FStevesEditorVisLine> Lines;
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
||||
TArray<FStevesEditorVisCircle> Circles;
|
||||
|
||||
UStevesEditorVisComponent(const FObjectInitializer& ObjectInitializer);
|
||||
|
Loading…
x
Reference in New Issue
Block a user