Rewrite absurd implementation of lxCrosshairWidget to use FAnchors instead

This commit is contained in:
2025-04-02 23:22:16 -04:00
parent b4f918e15d
commit e81134473e
8 changed files with 119 additions and 26 deletions

View File

@@ -47,17 +47,35 @@ public:
// Get the enhanced input local player subsystem from a controller. If the controller
// is not a player controller, or if it is a player controller but it doesn't have an
// enhanced input subsystem, return nullptr.
UFUNCTION(BlueprintCallable, BlueprintPure, Category="Player Controller|Local Player Subsystems")
UFUNCTION(BlueprintPure, Category="Player Controller|Local Player Subsystems")
static UEnhancedInputLocalPlayerSubsystem *GetEnhancedInputLocalPlayerSubsystem(AController *Controller);
// Given a Pixel XY coordinate, convert it to a viewport position.
//
// The input should be in the range (0.0, 0.0) to (ViewportX, ViewportY).
// The output XY will be in the range 0.0 to 1.0. The input
// may specify a fraction of a pixel. So the input (0.0, 0.0)
// represents the upper-left corner of the upper-left pixel, whereas the
// input (0.5, 0.5) represents the center of the upper-left pixel.
UFUNCTION(BlueprintPure, meta = (ReturnDisplayName = "Percent XY"), Category="Luprex|Utility")
static FVector2D PixelToViewportPosition(FVector2D PixelXY);
// Given a viewport position, convert it to a Pixel XY coordinate.
//
// The input X and Y coordinates should be in the range 0 to 1. The output
// will be in the range (0,0) to (ViewportX, ViewportY). The output may
// specify a fraction of a pixel. If SnapToCenter is true, the output is
// rounded to the center of the nearest pixel.
UFUNCTION(BlueprintPure, meta = (ReturnDisplayName = "Pixel XY"), Category="Luprex|Utility")
static FVector2D ViewportPositionToPixel(FVector2D PercentXY, bool SnapToCenter);
// Do a Line Trace from the camera through a specified pixel.
//
// This can be used when you have a crosshair on the screen and you want to
// determine the object that the crosshairs are pointing at. It can also
// be used to do a line trace through the mouse.
//
// Fractional pixels are allowed. Therefore, (0.0, 0.0) is the upper-left corner
// of the upper-left pixel, whereas (0.5, 0.5) is the center of the upper-left pixel.
// be used to do a line trace through the mouse. Fractional pixels are allowed.
// Be aware that (0.0, 0.0) is the upper-left corner of the upper-left pixel,
// whereas (0.5, 0.5) is the center of the upper-left pixel.
//
UFUNCTION(BlueprintCallable, Category="Collision", meta=(AutoCreateRefTerm="ActorsToIgnore", Keywords="raycast"))
static bool LineTraceThroughPixel(const APlayerController* PlayerController,