Files
UnrealEngineUWP/Engine/Plugins/Runtime/SmartObjects/Source/SmartObjectsModule/Private/Annotations/SmartObjectSlotLinkAnnotation.cpp
mikko mononen 1ca6e4407c Smart Objects: Added way to project navigation locations on ground and to check collisions between nav location and slot.
- Changed entry annotation to navigation annotation
- Added option for nav annotations to project location on ground
- Added option and settings for nav annotations to check simple trajectory collisions towards slot location
- Added logic in entry location query to project on ground and check trajectory collisions
- Added physics settings struct that handles common query combinations
- Added USmartObjectSlotValidationFilter to define shareable settings for validation (kinda similar to nav query filter)
- Fixed double rendering of preview actor/mesh in SO editor
- added debug draw for the new features

#jira UE-174418
#preflight 641036e470639dfc943ed981

[CL 24632583 by mikko mononen in ue5-main branch]
2023-03-14 06:26:29 -04:00

57 lines
2.2 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#include "Annotations/SmartObjectSlotLinkAnnotation.h"
#include "SmartObjectDefinition.h"
#include "SmartObjectVisualizationContext.h"
#include UE_INLINE_GENERATED_CPP_BY_NAME(SmartObjectSlotLinkAnnotation)
#if WITH_EDITOR
void FSmartObjectSlotLinkAnnotation::DrawVisualization(FSmartObjectVisualizationContext& VisContext) const
{
constexpr float DepthBias = 2.0f;
constexpr bool Screenspace = true;
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 = VisContext.SelectedColor;
}
VisContext.DrawArrow(Transform.GetValue().GetLocation(), TargetTransform.GetValue().GetLocation(), Color, 5.0f, 5.0f, /*DepthPrioGroup*/0, /*Thickness*/1.0f, DepthBias, Screenspace);
}
}
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 // WITH_EDITOR