This flow almost exactly matches WidgetComponent.cpp line 1107 (UWidgetComponent::GetLocalHitLocation(…)) in the UE 4.11.2 source code:
[FONT=Courier New]
void UWidgetComponent::GetLocalHitLocation(FVector WorldHitLocation, FVector2D& OutLocalWidgetHitLocation) const
{
// Find the hit location on the component
FVector ComponentHitLocation = ComponentToWorld.InverseTransformPosition(WorldHitLocation);
// Convert the 3D position of component space, into the 2D equivalent
if ( bUseLegacyRotation )
{
OutLocalWidgetHitLocation = FVector2D(ComponentHitLocation.X, ComponentHitLocation.Y);
}
else
{
OutLocalWidgetHitLocation = FVector2D(-ComponentHitLocation.Y, -ComponentHitLocation.Z);
}
// Offset the position by the pivot to get the position in widget space.
OutLocalWidgetHitLocation.X += DrawSize.X * Pivot.X;
OutLocalWidgetHitLocation.Y += DrawSize.Y * Pivot.Y;
// Apply the parabola distortion
FVector2D NormalizedLocation = OutLocalWidgetHitLocation / DrawSize;
NormalizedLocation.Y += ParabolaDistortion * ( -2.0f * NormalizedLocation.Y + 1.0f ) * NormalizedLocation.X * ( NormalizedLocation.X - 1.0f );
OutLocalWidgetHitLocation.Y = DrawSize.Y * NormalizedLocation.Y;
}
So you’re on the right track
I’m working on a tiny plugin that you can just pop into UE4 editor and expose this stuff to BluePrints… because… well yeah
For anyone wondering what the “ParabolaDistortion” is - it’s in the same file:
[FONT=Courier New]
/**
* When enabled, distorts the UI along a parabola shape giving the UI the appearance
* that it’s on a curved surface in front of the users face. This only works for UI
* rendered to a render target.
*/
UPROPERTY(EditAnywhere, Category=Rendering)
float ParabolaDistortion;