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-01 15:40:51 -05:00
|
|
|
#if UE_ENABLE_DEBUG_DRAWING
|
2022-11-01 15:11:25 -04:00
|
|
|
|
|
|
|
|
void FSmartObjectSlotLinkAnnotation::DrawVisualization(FSmartObjectVisualizationContext& VisContext) const
|
|
|
|
|
{
|
|
|
|
|
if (!LinkedSlot.IsValid() || !VisContext.Definition.IsValidSlotIndex(LinkedSlot.GetIndex()))
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const FSmartObjectSlotIndex SlotIndex(VisContext.SlotIndex);
|
|
|
|
|
const FSmartObjectSlotIndex LinkedSlotIndex(LinkedSlot.GetIndex());
|
|
|
|
|
const TOptional<FTransform> Transform = VisContext.Definition.GetSlotTransform(VisContext.OwnerLocalToWorld, SlotIndex);
|
|
|
|
|
const TOptional<FTransform> TargetTransform = VisContext.Definition.GetSlotTransform(VisContext.OwnerLocalToWorld, LinkedSlotIndex);
|
|
|
|
|
|
|
|
|
|
if (Transform.IsSet() && TargetTransform.IsSet())
|
|
|
|
|
{
|
|
|
|
|
FLinearColor Color = FLinearColor::White;
|
2023-01-18 06:27:31 -05:00
|
|
|
if (VisContext.bIsSlotSelected)
|
2022-11-01 15:11:25 -04:00
|
|
|
{
|
2023-01-18 06:27:31 -05:00
|
|
|
Color = VisContext.SelectedColor;
|
2022-11-01 15:11:25 -04:00
|
|
|
}
|
|
|
|
|
VisContext.DrawArrow(Transform.GetValue().GetLocation(), TargetTransform.GetValue().GetLocation(), Color, 15.0f, 15.0f, /*DepthPrioGroup*/0, /*Thickness*/1.0f, /*DepthBias*/2.0);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void FSmartObjectSlotLinkAnnotation::DrawVisualizationHUD(FSmartObjectVisualizationContext& VisContext) const
|
|
|
|
|
{
|
|
|
|
|
if (!LinkedSlot.IsValid() || !VisContext.Definition.IsValidSlotIndex(LinkedSlot.GetIndex()))
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
const FSmartObjectSlotIndex SlotIndex(VisContext.SlotIndex);
|
|
|
|
|
const FSmartObjectSlotIndex LinkedSlotIndex(LinkedSlot.GetIndex());
|
|
|
|
|
const TOptional<FTransform> Transform = VisContext.Definition.GetSlotTransform(VisContext.OwnerLocalToWorld, SlotIndex);
|
|
|
|
|
const TOptional<FTransform> TargetTransform = VisContext.Definition.GetSlotTransform(VisContext.OwnerLocalToWorld, LinkedSlotIndex);
|
|
|
|
|
|
|
|
|
|
if (VisContext.bIsSlotSelected
|
|
|
|
|
&& Transform.IsSet() && TargetTransform.IsSet())
|
|
|
|
|
{
|
|
|
|
|
const FVector LabelPos = FMath::Lerp(Transform.GetValue().GetLocation(), TargetTransform.GetValue().GetLocation(), 0.3f);
|
|
|
|
|
VisContext.DrawString(LabelPos, *Tag.ToString(), FLinearColor::White);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-01 15:40:51 -05:00
|
|
|
#endif
|