Files
UnrealEngineUWP/Engine/Source/Runtime/InteractiveToolsFramework/Private/BaseGizmos/GizmoElementHitTargets.cpp
Christina TempelaarL 4966988cf5 New TRS gizmo: add support for hovering.
#jira UETOOL-4781
#rb brooke.hubert
#preflight 62747612594b7a20312da916

[CL 20067991 by Christina TempelaarL in ue5-main branch]
2022-05-05 21:17:09 -04:00

120 lines
2.8 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#include "BaseGizmos/GizmoElementHitTargets.h"
#include "BaseGizmos/GizmoElementBase.h"
#include "Engine/EngineTypes.h" // FHitResult
FInputRayHit UGizmoElementHitTarget::IsHit(const FInputDeviceRay& ClickPos) const
{
if (GizmoElement && (!Condition || Condition(ClickPos)))
{
return GizmoElement->LineTrace(ClickPos.WorldRay.Origin, ClickPos.WorldRay.Direction);
}
return FInputRayHit();
}
void UGizmoElementHitTarget::UpdateHoverState(bool bHovering)
{
if (!GizmoElement)
{
return;
}
if (bHovering)
{
GizmoElement->SetElementInteractionState(EGizmoElementInteractionState::Hovering);
}
else
{
GizmoElement->SetElementInteractionState(EGizmoElementInteractionState::None);
}
}
void UGizmoElementHitTarget::UpdateInteractingState(bool bInteracting)
{
if (!GizmoElement)
{
return;
}
if (bInteracting)
{
GizmoElement->SetElementInteractionState(EGizmoElementInteractionState::Interacting);
}
else
{
GizmoElement->SetElementInteractionState(EGizmoElementInteractionState::None);
}
}
UGizmoElementHitTarget* UGizmoElementHitTarget::Construct(UGizmoElementBase* InGizmoElement, UObject* Outer)
{
UGizmoElementHitTarget* NewHitTarget = NewObject<UGizmoElementHitTarget>(Outer);
NewHitTarget->GizmoElement = InGizmoElement;
return NewHitTarget;
}
FInputRayHit UGizmoElementHitMultiTarget::IsHit(const FInputDeviceRay& ClickPos) const
{
if (GizmoElement && (!Condition || Condition(ClickPos)))
{
return GizmoElement->LineTrace(ClickPos.WorldRay.Origin, ClickPos.WorldRay.Direction);
}
return FInputRayHit();
}
void UGizmoElementHitMultiTarget::UpdateHoverState(bool bHovering, uint32 PartIdentifier)
{
if (!GizmoElement)
{
return;
}
if (bHovering)
{
GizmoElement->UpdatePartInteractionState(EGizmoElementInteractionState::Hovering, PartIdentifier);
}
else
{
GizmoElement->UpdatePartInteractionState(EGizmoElementInteractionState::None, PartIdentifier);
}
}
void UGizmoElementHitMultiTarget::UpdateInteractingState(bool bInteracting, uint32 PartIdentifier)
{
if (!GizmoElement)
{
return;
}
if (bInteracting)
{
GizmoElement->UpdatePartInteractionState(EGizmoElementInteractionState::Interacting, PartIdentifier);
}
else
{
GizmoElement->UpdatePartInteractionState(EGizmoElementInteractionState::None, PartIdentifier);
}
}
void UGizmoElementHitMultiTarget::UpdateHittableState(bool bHittable, uint32 PartIdentifier)
{
if (!GizmoElement)
{
return;
}
GizmoElement->UpdatePartHittableState(bHittable, PartIdentifier);
}
UGizmoElementHitMultiTarget* UGizmoElementHitMultiTarget::Construct(UGizmoElementBase* InGizmoElement, UObject* Outer)
{
UGizmoElementHitMultiTarget* NewHitTarget = NewObject<UGizmoElementHitMultiTarget>(Outer);
NewHitTarget->GizmoElement = InGizmoElement;
return NewHitTarget;
}