Files
UnrealEngineUWP/Engine/Source/Runtime/InteractiveToolsFramework/Private/BaseGizmos/HitTargets.cpp
semion piskarev 5989ed564b MeshModelingTools: Remove infinite loop in UGizmoLabdaHitTarget.
#rb Jimmy.Andrews
#jira UE-149765
#preflight 626070fd080c6600634c1c1b

#ROBOMERGE-AUTHOR: semion.piskarev
#ROBOMERGE-SOURCE: CL 19839717 in //UE5/Release-5.0/... via CL 19840853
#ROBOMERGE-BOT: UE5 (Release-Engine-Staging -> Main) (v940-19807014)

[CL 19842651 by semion piskarev in ue5-main branch]
2022-04-20 20:27:33 -04:00

81 lines
1.9 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#include "BaseGizmos/HitTargets.h"
#include "Components/PrimitiveComponent.h"
#include "Engine/HitResult.h"
FInputRayHit UGizmoLambdaHitTarget::IsHit(const FInputDeviceRay& ClickPos) const
{
if (IsHitFunction)
{
return IsHitFunction(ClickPos);
}
return FInputRayHit();
}
void UGizmoLambdaHitTarget::UpdateHoverState(bool bHovering)
{
if (UpdateHoverFunction)
{
UpdateHoverFunction(bHovering);
}
}
void UGizmoLambdaHitTarget::UpdateInteractingState(bool bHovering)
{
if (UpdateInteractingFunction)
{
UpdateInteractingFunction(bHovering);
}
}
FInputRayHit UGizmoComponentHitTarget::IsHit(const FInputDeviceRay& ClickPos) const
{
FInputRayHit Hit;
if (Component && (!Condition || Condition(ClickPos)))
{
// if a gizmo is not visible it cannot be hit
bool bVisible = Component->IsVisible() && ( Component->GetOwner() && Component->GetOwner()->IsHidden() == false );
#if WITH_EDITOR
bVisible = bVisible && Component->IsVisibleInEditor() && (Component->GetOwner() && Component->GetOwner()->IsHiddenEd() == false);
#endif
if (bVisible)
{
FVector End = ClickPos.WorldRay.PointAt(HALF_WORLD_MAX);
FHitResult OutHit;
if (Component->LineTraceComponent(OutHit, ClickPos.WorldRay.Origin, End, FCollisionQueryParams(SCENE_QUERY_STAT(HitTest), true)))
{
return FInputRayHit(OutHit.Distance);
}
}
}
return Hit;
}
void UGizmoComponentHitTarget::UpdateHoverState(bool bHovering)
{
if (UpdateHoverFunction)
{
UpdateHoverFunction(bHovering);
}
}
void UGizmoComponentHitTarget::UpdateInteractingState(bool bHovering)
{
if (UpdateInteractingFunction)
{
UpdateInteractingFunction(bHovering);
}
}
UGizmoComponentHitTarget* UGizmoComponentHitTarget::Construct(UPrimitiveComponent* Component, UObject* Outer)
{
UGizmoComponentHitTarget* NewHitTarget = NewObject<UGizmoComponentHitTarget>(Outer);
NewHitTarget->Component = Component;
return NewHitTarget;
}