2022-11-22 20:17:33 -05:00
|
|
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
2022-11-01 15:11:25 -04:00
|
|
|
|
|
|
|
|
#include "Annotations/SmartObjectSlotLinkAnnotation.h"
|
|
|
|
|
#include "SmartObjectDefinition.h"
|
|
|
|
|
#include "SmartObjectVisualizationContext.h"
|
|
|
|
|
|
2022-11-22 20:17:33 -05:00
|
|
|
#include UE_INLINE_GENERATED_CPP_BY_NAME(SmartObjectSlotLinkAnnotation)
|
|
|
|
|
|
2023-03-02 05:58:30 -05:00
|
|
|
#if WITH_EDITOR
|
2022-11-01 15:11:25 -04:00
|
|
|
|
|
|
|
|
void FSmartObjectSlotLinkAnnotation::DrawVisualization(FSmartObjectVisualizationContext& VisContext) const
|
|
|
|
|
{
|
2023-03-14 06:26:29 -04:00
|
|
|
constexpr float DepthBias = 2.0f;
|
|
|
|
|
constexpr bool Screenspace = true;
|
|
|
|
|
|
2022-11-01 15:11:25 -04:00
|
|
|
if (!LinkedSlot.IsValid() || !VisContext.Definition.IsValidSlotIndex(LinkedSlot.GetIndex()))
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2023-07-18 09:00:26 -04:00
|
|
|
const FTransform Transform = VisContext.Definition.GetSlotWorldTransform(VisContext.SlotIndex, VisContext.OwnerLocalToWorld);
|
|
|
|
|
const FTransform TargetTransform = VisContext.Definition.GetSlotWorldTransform(LinkedSlot.GetIndex(), VisContext.OwnerLocalToWorld);
|
2022-11-01 15:11:25 -04:00
|
|
|
|
2023-07-18 09:00:26 -04:00
|
|
|
FLinearColor Color = FLinearColor::White;
|
|
|
|
|
if (VisContext.bIsSlotSelected)
|
2022-11-01 15:11:25 -04:00
|
|
|
{
|
2023-07-18 09:00:26 -04:00
|
|
|
Color = VisContext.SelectedColor;
|
2022-11-01 15:11:25 -04:00
|
|
|
}
|
2023-07-18 09:00:26 -04:00
|
|
|
VisContext.DrawArrow(Transform.GetLocation(), TargetTransform.GetLocation(), Color, 5.0f, 5.0f, /*DepthPrioGroup*/0, /*Thickness*/1.0f, DepthBias, Screenspace);
|
2022-11-01 15:11:25 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void FSmartObjectSlotLinkAnnotation::DrawVisualizationHUD(FSmartObjectVisualizationContext& VisContext) const
|
|
|
|
|
{
|
|
|
|
|
if (!LinkedSlot.IsValid() || !VisContext.Definition.IsValidSlotIndex(LinkedSlot.GetIndex()))
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
2023-07-18 09:00:26 -04:00
|
|
|
const FTransform Transform = VisContext.Definition.GetSlotWorldTransform(VisContext.SlotIndex, VisContext.OwnerLocalToWorld);
|
|
|
|
|
const FTransform TargetTransform = VisContext.Definition.GetSlotWorldTransform(LinkedSlot.GetIndex(), VisContext.OwnerLocalToWorld);
|
2022-11-01 15:11:25 -04:00
|
|
|
|
2023-07-18 09:00:26 -04:00
|
|
|
if (VisContext.bIsSlotSelected)
|
2022-11-01 15:11:25 -04:00
|
|
|
{
|
2023-07-18 09:00:26 -04:00
|
|
|
const FVector LabelPos = FMath::Lerp(Transform.GetLocation(), TargetTransform.GetLocation(), 0.3);
|
2022-11-01 15:11:25 -04:00
|
|
|
VisContext.DrawString(LabelPos, *Tag.ToString(), FLinearColor::White);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-02 05:58:30 -05:00
|
|
|
#endif // WITH_EDITOR
|