mirror of
https://github.com/sinbad/StevesUEHelpers.git
synced 2025-02-23 17:45:23 +00:00
Add RandPointInBox2D method
This commit is contained in:
parent
54a94ea5b1
commit
244302781b
@ -136,7 +136,7 @@ public:
|
|||||||
return FRotator(PitchYaw.X, PitchYaw.Y, 0).RotateVector(FVector::UpVector);
|
return FRotator(PitchYaw.X, PitchYaw.Y, 0).RotateVector(FVector::UpVector);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Random point in a box
|
/// Random point in a 3D box
|
||||||
FORCEINLINE FVector RandPointInBox(const FBox& Box) const
|
FORCEINLINE FVector RandPointInBox(const FBox& Box) const
|
||||||
{
|
{
|
||||||
const FVector R3 = Rand3D();
|
const FVector R3 = Rand3D();
|
||||||
@ -145,6 +145,14 @@ public:
|
|||||||
FMath::Lerp(Box.Min.Z, Box.Max.Z, R3.Z));
|
FMath::Lerp(Box.Min.Z, Box.Max.Z, R3.Z));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Random point in a 2D rectangle
|
||||||
|
FORCEINLINE FVector2D RandPointInBox2D(const FBox2D& Rect) const
|
||||||
|
{
|
||||||
|
const FVector2D R2 = Rand2D();
|
||||||
|
return FVector2D(FMath::Lerp(Rect.Min.X, Rect.Max.X, R2.X),
|
||||||
|
FMath::Lerp(Rect.Min.Y, Rect.Max.Y, R2.Y));
|
||||||
|
}
|
||||||
|
|
||||||
/// Random value in a range (inclusive)
|
/// Random value in a range (inclusive)
|
||||||
float RandRange(float Min, float Max) const
|
float RandRange(float Min, float Max) const
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user