Files
UnrealEngineUWP/Engine/Source/Runtime/Experimental/InteractiveToolsFramework/Private/BaseTools/SingleSelectionTool.cpp
Ryan Schmidt c0ba0d5235 ModelingMode: Add support for selection-focus and point-focus at Tool level.
- New UInteractiveToolCameraFocusAPI UInterface defines functions a Tool can implement to publish its ability to provide a focus-box and focus-point
- ModelingMode uses this API to customize behavior. Box-focus (f hotkey) will now always focus on Tool-provided focus-box if available. Point-focus (c hotkey) will focus on nearer of world-hit and Tool focus-point.
- Default implementations for PrimitiveComponentToolTarget in SingleSelectionTool and MultiSelectionTool
- Custom focus-box implementations for PolyEdit-derived and TriSelect-derived tools, to focus on active selection if available
- Custom focus-point implementations for MeshSurfacePointTool

#rnx
#jira none

[CL 16246252 by Ryan Schmidt in ue5-main branch]
2021-05-10 01:17:30 -04:00

60 lines
1.3 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#include "SingleSelectionTool.h"
#include "InteractiveToolManager.h"
#include "ToolTargets/PrimitiveComponentToolTarget.h"
#include "Components/PrimitiveComponent.h"
#define LOCTEXT_NAMESPACE "USingleSelectionTool"
bool USingleSelectionTool::SupportsWorldSpaceFocusBox()
{
return Target && Cast<UPrimitiveComponentToolTarget>(Target) != nullptr;
}
FBox USingleSelectionTool::GetWorldSpaceFocusBox()
{
if (Target)
{
UPrimitiveComponentToolTarget* PrimTarget = Cast<UPrimitiveComponentToolTarget>(Target);
if (PrimTarget)
{
UPrimitiveComponent* Component = PrimTarget->GetOwnerComponent();
if (Component)
{
return Component->Bounds.GetBox();
}
}
}
return FBox();
}
bool USingleSelectionTool::SupportsWorldSpaceFocusPoint()
{
return Target && Cast<UPrimitiveComponentToolTarget>(Target) != nullptr;
}
bool USingleSelectionTool::GetWorldSpaceFocusPoint(const FRay& WorldRay, FVector& PointOut)
{
if (Target)
{
UPrimitiveComponentToolTarget* PrimTarget = Cast<UPrimitiveComponentToolTarget>(Target);
if (PrimTarget)
{
FHitResult HitResult;
if (PrimTarget->HitTestComponent(WorldRay, HitResult))
{
PointOut = HitResult.ImpactPoint;
return true;
}
}
}
return false;
}
#undef LOCTEXT_NAMESPACE