FRandomStream

Implements a thread-safe SRand based RNG.

Windows
MacOS
Linux

References

Module

Core

Header

/Engine/Source/Runtime/Core/Public/Math/RandomStream.h

Include

#include "Math/RandomStream.h"

Syntax

struct FRandomStream

Remarks

Implements a thread-safe SRand based RNG.

Very bad quality in the lower bits. Don't use the modulus (%) operator.

Constructors

Name Description

Public function

FRandomStream()

Default constructor.

The seed should be set prior to use.

Public function

FRandomStream

(
    int32 InSeed
)

Creates and initializes a new random stream from the specified seed value.

Public function

FRandomStream

(
    FName InName
)

Creates and initializes a new random stream from the specified name.

Functions

Name Description

Public function Const

bool

 

ExportTextItem

(
    FString& ValueStr,
    FRandomStream const& DefaultValue,
    UObject* Parent,
    int32 PortFlags,
    UObject* ExportRootScope
)

Exports the RandomStreams value to a string.

Public function Const

float

 

FRand()

Mirrors the random number API in FMath

Public function Const

float

 

FRandRange

(
    float InMin,
    float InMax
)

Helper function for rand implementations.

Public function

void

 

GenerateNewSeed()

Generates a new random seed.

Public function Const

int32

 

GetCurrentSeed()

Gets the current seed.

Public function Const

float

 

GetFraction()

Returns a random float number in the range [0, 1).

Public function Const

int32

 

GetInitialSeed()

Public function Const

FVector

 

GetUnitVector()

Returns a random vector of unit size.

Public function Const

uint32

 

GetUnsignedInt()

Returns a random number between 0 and MAXUINT.

Public function

void

 

Initialize

(
    FName InName
)

Initializes this random stream using the specified name.

Public function

void

 

Initialize

(
    int32 InSeed
)

Initializes this random stream with the specified seed value.

Protected function Const

void

 

MutateSeed()

Mutates the current seed into the next seed.

Public function Const

int32

 

RandHelper

(
    int32 A
)

Helper function for rand implementations.

Public function Const

int32

 

RandRange

(
    int32 Min,
    int32 Max
)

Helper function for rand implementations.

Public function Const

void

 

Reset()

Resets this random stream to the initial seed value.

Public function Const

FString

 

ToString()

Get a textual representation of the RandomStream.

Public function Const

FVector

 

VRand()

Returns a random vector of unit size.

Public function Const

FVector

 

VRandCone

(
    FVector const& Dir,
    float ConeHalfAngleRad
)

Returns a random unit vector, uniformly distributed, within the specified cone.

Public function Const

FVector

 

VRandCone

(
    FVector const& Dir,
    float HorizontalConeHalfAngleRad,
    float VerticalConeHalfAngleRad
)

Returns a random unit vector, uniformly distributed, within the specified cone.

Help shape the future of Unreal Engine documentation! Tell us how we're doing so we can serve you better.
Take our survey
Dismiss