Rewrite absurd implementation of lxCrosshairWidget to use FAnchors instead
This commit is contained in:
@@ -77,6 +77,34 @@ UEnhancedInputLocalPlayerSubsystem *UlxUtilityLibrary::GetEnhancedInputLocalPlay
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
FVector2D UlxUtilityLibrary::PixelToViewportPosition(FVector2D Pixel)
|
||||
{
|
||||
FVector2D ViewportSize;
|
||||
GEngine->GameViewport->GetViewportSize(ViewportSize);
|
||||
return Pixel / ViewportSize;
|
||||
}
|
||||
|
||||
FVector2D UlxUtilityLibrary::ViewportPositionToPixel(FVector2D Fraction, bool Snap)
|
||||
{
|
||||
FVector2D ViewportSize;
|
||||
GEngine->GameViewport->GetViewportSize(ViewportSize);
|
||||
FVector2D Pixel = Fraction * ViewportSize;
|
||||
if (Snap)
|
||||
{
|
||||
Pixel.X = FMath::FloorToDouble(Pixel.X) + 0.5;
|
||||
Pixel.Y = FMath::FloorToDouble(Pixel.Y) + 0.5;
|
||||
Pixel.X = FMath::Min(ViewportSize.X - 0.5, FMath::Max(0.5, Pixel.X));
|
||||
Pixel.Y = FMath::Min(ViewportSize.Y - 0.5, FMath::Max(0.5, Pixel.Y));
|
||||
}
|
||||
else
|
||||
{
|
||||
Pixel.X = FMath::Min(ViewportSize.X, FMath::Max(0.0, Pixel.X));
|
||||
Pixel.Y = FMath::Min(ViewportSize.Y, FMath::Max(0.0, Pixel.Y));
|
||||
}
|
||||
return Pixel;
|
||||
}
|
||||
|
||||
|
||||
bool UlxUtilityLibrary::LineTraceThroughPixel(const APlayerController* PlayerController,
|
||||
FVector2D PixelXY, double MaxDistanceFromCamera,
|
||||
ETraceTypeQuery TraceChannel, bool bTraceComplex, EDrawDebugTrace::Type DrawDebugType, bool bIgnorePlayerPawn,
|
||||
|
||||
Reference in New Issue
Block a user