Files
UnrealEngineUWP/Engine/Plugins/Runtime/SmartObjects/Source/SmartObjectsModule/Private/Annotations/SmartObjectSlotLinkAnnotation.cpp
mikko mononen c06beb8571 SmartObject improvements
- Fixed hashing when adding shared fragment for smart object slot definition
- Added per slot Runtime Tags
- Added common event handling for Smart Object and Slot changes and events
- Added annotations, which are slot definition data that has visualization
- Added linked slot annotation which allows behavior reuse on slots
- Added editor only ID for each slot so that they can be identified during edits
- Added SmartObject slot reference type that can be used to reference other slots in the Smart Object
- Changed Smart Object bDisable to bEnabled
- Added separate enabled state for slots
- Changed Smart Object disable to send an event, not forcefully unclaim
- Added more visualization support for Smart Object editor (canvas, visualize annotations)
- Changed Smart Object editor to use the commonly transform for slots
- Remove Smart Object Component instance from the asset editor as it was not needed

#rb Stephen.Holmes
#preflight 6360f0cf63608aee36e01ba5

[CL 22888712 by mikko mononen in ue5-main branch]
2022-11-01 15:11:25 -04:00

52 lines
2.1 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#include "Annotations/SmartObjectSlotLinkAnnotation.h"
#include "SmartObjectDefinition.h"
#include "SmartObjectTypes.h"
#include "SmartObjectVisualizationContext.h"
#if UE_ENABLE_DEBUG_DRAWING
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;
if (!VisContext.bIsSlotSelected)
{
Color.A *= 0.5f;
}
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);
}
}
#endif