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);
|
auto Ret = new FStevesDebugRenderSceneProxy(this);
|
||||||
|
|
||||||
const FTransform& XForm = GetComponentTransform();
|
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)
|
for (auto& C : Circles)
|
||||||
{
|
{
|
||||||
FQuat WorldRot = XForm.TransformRotation(C.Rotation.Quaternion());
|
FQuat WorldRot = XForm.TransformRotation(C.Rotation.Quaternion());
|
||||||
@ -47,6 +52,12 @@ FBoxSphereBounds UStevesEditorVisComponent::CalcBounds(const FTransform& LocalTo
|
|||||||
FBoxSphereBounds B = Super::CalcBounds(LocalToWorld);
|
FBoxSphereBounds B = Super::CalcBounds(LocalToWorld);
|
||||||
|
|
||||||
// Now we need to merge in all components
|
// 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)
|
for (auto& C : Circles)
|
||||||
{
|
{
|
||||||
B = B + FBoxSphereBounds(C.Location, FVector(C.Radius), C.Radius);
|
B = B + FBoxSphereBounds(C.Location, FVector(C.Radius), C.Radius);
|
||||||
|
@ -7,6 +7,37 @@
|
|||||||
#include "StevesEditorVisComponent.generated.h"
|
#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)
|
USTRUCT(BlueprintType)
|
||||||
struct FStevesEditorVisCircle
|
struct FStevesEditorVisCircle
|
||||||
{
|
{
|
||||||
@ -28,13 +59,13 @@ struct FStevesEditorVisCircle
|
|||||||
UPROPERTY(EditAnywhere)
|
UPROPERTY(EditAnywhere)
|
||||||
FColor Colour;
|
FColor Colour;
|
||||||
|
|
||||||
FStevesEditorVisCircle(const FVector& Location, const FRotator& Rotation, float Radius, int NumSegments,
|
FStevesEditorVisCircle(const FVector& InLocation, const FRotator& InRotation, float InRadius, int InNumSegments,
|
||||||
const FColor& Colour)
|
const FColor& InColour)
|
||||||
: Location(Location),
|
: Location(InLocation),
|
||||||
Rotation(Rotation),
|
Rotation(InRotation),
|
||||||
Radius(Radius),
|
Radius(InRadius),
|
||||||
NumSegments(NumSegments),
|
NumSegments(InNumSegments),
|
||||||
Colour(Colour)
|
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
|
* 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.
|
* 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
|
class STEVESUEHELPERS_API UStevesEditorVisComponent : public UPrimitiveComponent
|
||||||
{
|
{
|
||||||
GENERATED_BODY()
|
GENERATED_BODY()
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/// Circles to render
|
/// Circles to render
|
||||||
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
||||||
|
TArray<FStevesEditorVisLine> Lines;
|
||||||
|
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
||||||
TArray<FStevesEditorVisCircle> Circles;
|
TArray<FStevesEditorVisCircle> Circles;
|
||||||
|
|
||||||
UStevesEditorVisComponent(const FObjectInitializer& ObjectInitializer);
|
UStevesEditorVisComponent(const FObjectInitializer& ObjectInitializer);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user