7#include "Math/UnrealMathUtility.h"
8#include "Math/Vector.h"
9#include "Math/Matrix.h"
10#include "Math/RotationMatrix.h"
11#include "Math/Transform.h"
12#include "HAL/PlatformTime.h"
15
16
17
18
21 friend struct Z_Construct_UScriptStruct_FRandomStream_Statics;
26
27
28
29
36
37
38
39
46
47
48
49
50
59
60
61
62
66 Seed = uint32(InSeed);
70
71
72
73
74
77 if (InName
!= NAME_None)
90
91
103
104
107 Initialize(FMath::Rand());
111
112
113
114
121 *(uint32*)&Result = 0x3F800000U | (
Seed >> 9);
123 return Result - 1.0f;
127
128
129
130
139
140
141
142
151 Result.X = GetFraction() * 2.f - 1.f;
152 Result.Y = GetFraction() * 2.f - 1.f;
153 Result.Z = GetFraction() * 2.f - 1.f;
154 L = Result.SizeSquared();
158 return Result.GetUnsafeNormal();
162
163
164
165
172
173
174
175
182
183
184
185
189 return ((A > 0) ? FMath::TruncToInt(GetFraction() *
float(A)) : 0);
193
194
195
196
199 const int32 Range = (Max - Min) + 1;
205
206
207
208
211 return InMin + (InMax - InMin) * FRand();
215
216
217
218
221 return GetUnitVector();
226 return FVector( FRandRange(Box.Min.X, Box.Max.X),
227 FRandRange(Box.Min.Y, Box.Max.Y),
228 FRandRange(Box.Min.Z, Box.Max.Z) );
232
233
234
235
236
237
240 if (ConeHalfAngleRad > 0.f)
247 float Theta = 2.f *
UE_PI * RandU;
248 float Phi = FMath::Acos((2.f * RandV) - 1.f);
253 Phi = FMath::Fmod(Phi, ConeHalfAngleRad);
256 FMatrix
const DirMat = FRotationMatrix(Dir.Rotation());
258 FVector
const DirZ = DirMat.GetUnitAxis( EAxis::X );
259 FVector
const DirY = DirMat.GetUnitAxis( EAxis::Y );
261 FVector Result = Dir.RotateAngleAxis(Phi * 180.f /
UE_PI, DirY);
262 Result = Result.RotateAngleAxis(Theta * 180.f /
UE_PI, DirZ);
265 Result = Result.GetSafeNormal();
271 return Dir.GetSafeNormal();
276
277
278
279
280
281
282
283 FORCEINLINE FVector
VRandCone( FVector
const& Dir,
float HorizontalConeHalfAngleRad,
float VerticalConeHalfAngleRad )
const
285 if ( (VerticalConeHalfAngleRad > 0.f) && (HorizontalConeHalfAngleRad > 0.f) )
292 float Theta = 2.f *
UE_PI * RandU;
293 float Phi = FMath::Acos((2.f * RandV) - 1.f);
299 float ConeHalfAngleRad = FMath::Square(FMath::Cos(Theta) / VerticalConeHalfAngleRad) + FMath::Square(FMath::Sin(Theta) / HorizontalConeHalfAngleRad);
300 ConeHalfAngleRad = FMath::Sqrt(1.f / ConeHalfAngleRad);
303 Phi = FMath::Fmod(Phi, ConeHalfAngleRad);
306 FMatrix
const DirMat = FRotationMatrix(Dir.Rotation());
308 FVector
const DirZ = DirMat.GetUnitAxis( EAxis::X );
309 FVector
const DirY = DirMat.GetUnitAxis( EAxis::Y );
311 FVector Result = Dir.RotateAngleAxis(Phi * 180.f /
UE_PI, DirY);
312 Result = Result.RotateAngleAxis(Theta * 180.f /
UE_PI, DirZ);
315 Result = Result.GetSafeNormal();
321 return Dir.GetSafeNormal();
326
327
328
329
338
339
342 Seed = (
Seed * 196314165U) + 907633515U;
#define UE_KINDA_SMALL_NUMBER
FORCEINLINE bool operator!=(EName Ename) const
friend FORCEINLINE uint32 GetTypeHash(const FString &S)
int32 GetCurrentSeed() const
FORCEINLINE FVector VRand() const
uint32 GetUnsignedInt() const
FORCEINLINE FVector VRandCone(FVector const &Dir, float HorizontalConeHalfAngleRad, float VerticalConeHalfAngleRad) const
FRandomStream(int32 InSeed)
void Initialize(int32 InSeed)
FVector GetUnitVector() const
void Initialize(FName InName)
int32 GetInitialSeed() const
FRandomStream(FName InName)
FORCEINLINE FVector VRandCone(FVector const &Dir, float ConeHalfAngleRad) const
FORCEINLINE int32 RandHelper(int32 A) const
float GetFraction() const
FORCEINLINE FVector::FReal FRandRange(FVector::FReal InMin, FVector::FReal InMax) const
FORCEINLINE float FRand() const
FORCEINLINE FVector RandPointInBox(const FBox &Box) const
FORCEINLINE int32 RandRange(int32 Min, int32 Max) const