Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Copyright Epic Games, Inc. All Rights Reserved.
- #include "LibNebulaNodesBPLibrary.h"
- #include "LibNebulaNodes.h"
- ULibNebulaNodesBPLibrary::ULibNebulaNodesBPLibrary(const FObjectInitializer& ObjectInitializer)
- : Super(ObjectInitializer)
- {
- }
- FVector2f ULibNebulaNodesBPLibrary::RandomVector2(float fMin, float fMax, bool bPreventDuplicates, bool bRoundToInteger, float &x, float &y)
- {
- float X, Y;
- int iAttempts = 0;
- int iMaxAttempts = 25;
- do
- {
- X = FMath::RandRange(fMin, fMax);
- Y = FMath::RandRange(fMin, fMax);
- iAttempts++;
- } while (bPreventDuplicates && iAttempts < iMaxAttempts && FMath::IsNearlyEqual(X, Y));
- if (bRoundToInteger)
- {
- x = X;
- y = Y;
- return FVector2f(FMath::RoundToInt(X), FMath::RoundToInt(Y));
- }
- else
- {
- x = X;
- y = Y;
- return FVector2f(X, Y);
- }
- }
Add Comment
Please, Sign In to add comment