You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
#jira UETOOL-3823 #rb brooke.hubert #preflight 6109d1e9b4288d0001acb7ef [CL 17055606 by michael balzer in ue5-main branch]
54 lines
1.6 KiB
C++
54 lines
1.6 KiB
C++
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
#include "BaseGizmos/AxisSources.h"
|
|
#include "Components/SceneComponent.h"
|
|
|
|
FVector UGizmoComponentAxisSource::GetOrigin() const
|
|
{
|
|
const FTransform& WorldTransform = Component->GetComponentToWorld();
|
|
return WorldTransform.GetLocation();
|
|
}
|
|
|
|
FVector UGizmoComponentAxisSource::GetDirection() const
|
|
{
|
|
const FTransform& WorldTransform = Component->GetComponentToWorld();
|
|
FVector Axis(0, 0, 0);
|
|
Axis[FMath::Clamp(AxisIndex, 0, 2)] = 1.0;
|
|
if (bLocalAxes)
|
|
{
|
|
return WorldTransform.GetRotation().RotateVector(Axis);
|
|
}
|
|
else
|
|
{
|
|
return Axis;
|
|
}
|
|
}
|
|
|
|
void UGizmoComponentAxisSource::GetTangentVectors(FVector& TangentXOut, FVector& TangentYOut) const
|
|
{
|
|
// Note that in giving the tangent vectors, we need to give them in an order that
|
|
// preserves the handedness of our coordinate system so that we can use the function
|
|
// for generating planes in which we can measure rotation angles about the input axis.
|
|
// So, TangentXOut, TangentYOut, and Input(Z) should give a left-handed frame (since
|
|
// unreal is left handed).
|
|
|
|
const FTransform& WorldTransform = Component->GetComponentToWorld();
|
|
TangentXOut = FVector(0, 1, 0);
|
|
TangentYOut = FVector(0, 0, 1);
|
|
int Index = FMath::Clamp(AxisIndex, 0, 2);
|
|
if (Index == 1)
|
|
{
|
|
TangentXOut = FVector(0, 0, 1);
|
|
TangentYOut = FVector(1, 0, 0);
|
|
}
|
|
else if (Index == 2)
|
|
{
|
|
TangentXOut = FVector(1, 0, 0);
|
|
TangentYOut = FVector(0, 1, 0);
|
|
}
|
|
if (bLocalAxes)
|
|
{
|
|
TangentXOut = WorldTransform.GetRotation().RotateVector(TangentXOut);
|
|
TangentYOut = WorldTransform.GetRotation().RotateVector(TangentYOut);
|
|
}
|
|
} |