Add boxes

This commit is contained in:
Steve Streeting 2021-09-14 14:48:39 +01:00
parent 1b8a5a805c
commit 266c8cc1b8
2 changed files with 61 additions and 7 deletions

View File

@ -67,6 +67,15 @@ FPrimitiveSceneProxy* UStevesEditorVisComponent::CreateSceneProxy()
S.Colour
));
}
for (auto& Box : Boxes)
{
FVector HalfSize = Box.Size * 0.5f;
FBox DBox(-HalfSize, HalfSize);
// Apply local rotation first then parent transform
FTransform CombinedXForm = FTransform(Box.Rotation, Box.Location) * XForm;
Ret->Boxes.Add(FStevesDebugRenderSceneProxy::FDebugBox(
DBox, Box.Colour, CombinedXForm));
}
return Ret;
@ -102,7 +111,15 @@ FBoxSphereBounds UStevesEditorVisComponent::CalcBounds(const FTransform& LocalTo
{
B = B + FBoxSphereBounds(S.Location, FVector(S.Radius), S.Radius);
}
for (auto& Box : Boxes)
{
FVector HalfSize = Box.Size * 0.5f;
FBox DBox(-HalfSize, HalfSize);
// Apply local rotation only, world is done later
FTransform BoxXForm = FTransform(Box.Rotation, Box.Location);
DBox = DBox.TransformBy(BoxXForm);
B = B + FBoxSphereBounds(DBox);
}
return B.TransformBy(LocalToWorld);
}

View File

@ -32,7 +32,7 @@ struct FStevesEditorVisLine
FStevesEditorVisLine():
Start(FVector::ZeroVector),
End(FVector(100,0,0)),
End(FVector(100, 0, 0)),
Colour(FColor::White)
{
}
@ -159,6 +159,41 @@ struct FStevesEditorVisSphere
}
};
USTRUCT(BlueprintType)
struct FStevesEditorVisBox
{
GENERATED_BODY()
/// Location relative to component
UPROPERTY(EditAnywhere)
FVector Location;
/// Size of box in each axis
UPROPERTY(EditAnywhere)
FVector Size;
/// Rotation relative to component
UPROPERTY(EditAnywhere)
FRotator Rotation;
/// The colour of the line render
UPROPERTY(EditAnywhere)
FColor Colour;
FStevesEditorVisBox(const FVector& InLocation, const FVector& InSize, const FRotator& InRot,
const FColor& InColour) :
Location(InLocation),
Size(InSize),
Rotation(InRot),
Colour(InColour)
{
}
FStevesEditorVisBox():
Location(FVector::ZeroVector),
Size(FVector(50, 50, 50)),
Rotation(FRotator::ZeroRotator),
Colour(FColor::White)
{
}
};
/**
@ -190,6 +225,8 @@ public:
TArray<FStevesEditorVisArc> Arcs;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
TArray<FStevesEditorVisSphere> Spheres;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
TArray<FStevesEditorVisBox> Boxes;
UStevesEditorVisComponent(const FObjectInitializer& ObjectInitializer);