Ark Server API (ASE) - Wiki
Loading...
Searching...
No Matches
FGenericPlatformMath Struct Reference

#include <GenericPlatformMath.h>

+ Inheritance diagram for FGenericPlatformMath:

Public Member Functions

template<>
FORCEINLINE float Abs (const float A)
 

Static Public Member Functions

static CONSTEXPR FORCEINLINE int32 TruncToInt (float F)
 
static CONSTEXPR FORCEINLINE float TruncToFloat (float F)
 
static FORCEINLINE int32 FloorToInt (float F)
 
static FORCEINLINE float FloorToFloat (float F)
 
static FORCEINLINE double FloorToDouble (double F)
 
static FORCEINLINE int32 RoundToInt (float F)
 
static FORCEINLINE float RoundToFloat (float F)
 
static FORCEINLINE double RoundToDouble (double F)
 
static FORCEINLINE int32 CeilToInt (float F)
 
static FORCEINLINE float CeilToFloat (float F)
 
static FORCEINLINE double CeilToDouble (double F)
 
static FORCEINLINE float Fractional (float Value)
 
static FORCEINLINE float Frac (float Value)
 
static FORCEINLINE float Modf (const float InValue, float *OutIntPart)
 
static FORCEINLINE double Modf (const double InValue, double *OutIntPart)
 
static FORCEINLINE float Exp (float Value)
 
static FORCEINLINE float Exp2 (float Value)
 
static FORCEINLINE float Loge (float Value)
 
static FORCEINLINE float LogX (float Base, float Value)
 
static FORCEINLINE float Log2 (float Value)
 
static FORCEINLINE float Fmod (float X, float Y)
 
static FORCEINLINE float Sin (float Value)
 
static FORCEINLINE float Asin (float Value)
 
static FORCEINLINE float Sinh (float Value)
 
static FORCEINLINE float Cos (float Value)
 
static FORCEINLINE float Acos (float Value)
 
static FORCEINLINE float Tan (float Value)
 
static FORCEINLINE float Atan (float Value)
 
static FORCEINLINE float Sqrt (float Value)
 
static FORCEINLINE float Pow (float A, float B)
 
static FORCEINLINE float InvSqrt (float F)
 
static FORCEINLINE float InvSqrtEst (float F)
 
static FORCEINLINE bool IsNaN (float A)
 
static FORCEINLINE bool IsFinite (float A)
 
static FORCEINLINE bool IsNegativeFloat (const float &A)
 
static FORCEINLINE bool IsNegativeDouble (const double &A)
 
static FORCEINLINE int32 Rand ()
 
static FORCEINLINE void RandInit (int32 Seed)
 
static FORCEINLINE float FRand ()
 
static FORCEINLINE uint32 FloorLog2 (uint32 Value)
 
static FORCEINLINE uint64 FloorLog2_64 (uint64 Value)
 
static FORCEINLINE uint32 CountLeadingZeros (uint32 Value)
 
static FORCEINLINE uint64 CountLeadingZeros64 (uint64 Value)
 
static FORCEINLINE uint32 CountTrailingZeros (uint32 Value)
 
static FORCEINLINE uint32 CeilLogTwo (uint32 Arg)
 
static FORCEINLINE uint64 CeilLogTwo64 (uint64 Arg)
 
static FORCEINLINE uint32 RoundUpToPowerOfTwo (uint32 Arg)
 
static FORCEINLINE uint32 MortonCode2 (uint32 x)
 
static FORCEINLINE uint32 ReverseMortonCode2 (uint32 x)
 
static FORCEINLINE uint32 MortonCode3 (uint32 x)
 
static FORCEINLINE uint32 ReverseMortonCode3 (uint32 x)
 
static CONSTEXPR FORCEINLINE float FloatSelect (float Comparand, float ValueGEZero, float ValueLTZero)
 
static CONSTEXPR FORCEINLINE double FloatSelect (double Comparand, double ValueGEZero, double ValueLTZero)
 
template<class T >
static CONSTEXPR FORCEINLINE T Abs (const T A)
 
template<class T >
static CONSTEXPR FORCEINLINE T Sign (const T A)
 
template<class T >
static CONSTEXPR FORCEINLINE T Max (const T A, const T B)
 
template<class T >
static CONSTEXPR FORCEINLINE T Min (const T A, const T B)
 
template<class T >
static FORCEINLINE T Min (const TArray< T > &Values, int32 *MinIndex=NULL)
 
template<class T >
static FORCEINLINE T Max (const TArray< T > &Values, int32 *MaxIndex=NULL)
 
static FORCEINLINE int32 CountBits (uint64 Bits)
 

Detailed Description

Generic implementation for most platforms

Definition at line 23 of file GenericPlatformMath.h.

Member Function Documentation

◆ Abs() [1/2]

template<>
FORCEINLINE float FGenericPlatformMath::Abs ( const float A)

Float specialization

Definition at line 621 of file GenericPlatformMath.h.

◆ Abs() [2/2]

template<class T >
static CONSTEXPR FORCEINLINE T FGenericPlatformMath::Abs ( const T A)
inlinestatic

Computes absolute value in a generic way

Definition at line 509 of file GenericPlatformMath.h.

+ Here is the caller graph for this function:

◆ Acos()

static FORCEINLINE float FGenericPlatformMath::Acos ( float Value)
inlinestatic

Definition at line 216 of file GenericPlatformMath.h.

+ Here is the caller graph for this function:

◆ Asin()

static FORCEINLINE float FGenericPlatformMath::Asin ( float Value)
inlinestatic

Definition at line 213 of file GenericPlatformMath.h.

◆ Atan()

static FORCEINLINE float FGenericPlatformMath::Atan ( float Value)
inlinestatic

Definition at line 218 of file GenericPlatformMath.h.

◆ CeilLogTwo()

static FORCEINLINE uint32 FGenericPlatformMath::CeilLogTwo ( uint32 Arg)
inlinestatic

Returns smallest N such that (1<<N)>=Arg. Note: CeilLogTwo(0)=0 because (1<<0)=1 >= 0.

Definition at line 407 of file GenericPlatformMath.h.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ CeilLogTwo64()

static FORCEINLINE uint64 FGenericPlatformMath::CeilLogTwo64 ( uint64 Arg)
inlinestatic

Definition at line 413 of file GenericPlatformMath.h.

+ Here is the call graph for this function:

◆ CeilToDouble()

static FORCEINLINE double FGenericPlatformMath::CeilToDouble ( double F)
inlinestatic

Converts a double to the nearest greater or equal integer.

Parameters
FFloating point value to convert
Returns
An integer greater or equal to 'F'.

Definition at line 130 of file GenericPlatformMath.h.

+ Here is the caller graph for this function:

◆ CeilToFloat()

static FORCEINLINE float FGenericPlatformMath::CeilToFloat ( float F)
inlinestatic

Converts a float to the nearest greater or equal integer.

Parameters
FFloating point value to convert
Returns
An integer greater or equal to 'F'.

Definition at line 120 of file GenericPlatformMath.h.

+ Here is the caller graph for this function:

◆ CeilToInt()

static FORCEINLINE int32 FGenericPlatformMath::CeilToInt ( float F)
inlinestatic

Converts a float to the nearest greater or equal integer.

Parameters
FFloating point value to convert
Returns
An integer greater or equal to 'F'.

Definition at line 110 of file GenericPlatformMath.h.

+ Here is the call graph for this function:

◆ Cos()

static FORCEINLINE float FGenericPlatformMath::Cos ( float Value)
inlinestatic

Definition at line 215 of file GenericPlatformMath.h.

+ Here is the caller graph for this function:

◆ CountBits()

static FORCEINLINE int32 FGenericPlatformMath::CountBits ( uint64 Bits)
inlinestatic

Definition at line 609 of file GenericPlatformMath.h.

◆ CountLeadingZeros()

static FORCEINLINE uint32 FGenericPlatformMath::CountLeadingZeros ( uint32 Value)
inlinestatic

Counts the number of leading zeros in the bit representation of the value

Parameters
Valuethe value to determine the number of leading zeros for
Returns
the number of zeros before the first "on" bit

Definition at line 362 of file GenericPlatformMath.h.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ CountLeadingZeros64()

static FORCEINLINE uint64 FGenericPlatformMath::CountLeadingZeros64 ( uint64 Value)
inlinestatic

Counts the number of leading zeros in the bit representation of the 64-bit value

Parameters
Valuethe value to determine the number of leading zeros for
Returns
the number of zeros before the first "on" bit

Definition at line 375 of file GenericPlatformMath.h.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ CountTrailingZeros()

static FORCEINLINE uint32 FGenericPlatformMath::CountTrailingZeros ( uint32 Value)
inlinestatic

Counts the number of trailing zeros in the bit representation of the value

Parameters
Valuethe value to determine the number of trailing zeros for
Returns
the number of zeros after the last "on" bit

Definition at line 388 of file GenericPlatformMath.h.

+ Here is the caller graph for this function:

◆ Exp()

static FORCEINLINE float FGenericPlatformMath::Exp ( float Value)
inlinestatic

Definition at line 178 of file GenericPlatformMath.h.

◆ Exp2()

static FORCEINLINE float FGenericPlatformMath::Exp2 ( float Value)
inlinestatic

Definition at line 180 of file GenericPlatformMath.h.

◆ FloatSelect() [1/2]

static CONSTEXPR FORCEINLINE double FGenericPlatformMath::FloatSelect ( double Comparand,
double ValueGEZero,
double ValueLTZero )
inlinestatic

Returns value based on comparand. The main purpose of this function is to avoid branching based on floating point comparison which can be avoided via compiler intrinsics.

Please note that we don't define what happens in the case of NaNs as there might be platform specific differences.

Parameters
ComparandComparand the results are based on
ValueGEZeroReturn value if Comparand >= 0
ValueLTZeroReturn value if Comparand < 0
Returns
ValueGEZero if Comparand >= 0, ValueLTZero otherwise

Definition at line 502 of file GenericPlatformMath.h.

◆ FloatSelect() [2/2]

static CONSTEXPR FORCEINLINE float FGenericPlatformMath::FloatSelect ( float Comparand,
float ValueGEZero,
float ValueLTZero )
inlinestatic

Returns value based on comparand. The main purpose of this function is to avoid branching based on floating point comparison which can be avoided via compiler intrinsics.

Please note that we don't define what happens in the case of NaNs as there might be platform specific differences.

Parameters
ComparandComparand the results are based on
ValueGEZeroReturn value if Comparand >= 0
ValueLTZeroReturn value if Comparand < 0
Returns
ValueGEZero if Comparand >= 0, ValueLTZero otherwise

Definition at line 483 of file GenericPlatformMath.h.

+ Here is the caller graph for this function:

◆ FloorLog2()

static FORCEINLINE uint32 FGenericPlatformMath::FloorLog2 ( uint32 Value)
inlinestatic

Computes the base 2 logarithm for an integer value that is greater than 0. The result is rounded down to the nearest integer.

Parameters
ValueThe value to compute the log of
Returns
Log2 of Value. 0 if Value is 0.

Definition at line 270 of file GenericPlatformMath.h.

+ Here is the caller graph for this function:

◆ FloorLog2_64()

static FORCEINLINE uint64 FGenericPlatformMath::FloorLog2_64 ( uint64 Value)
inlinestatic

Computes the base 2 logarithm for a 64-bit value that is greater than 0. The result is rounded down to the nearest integer.

Parameters
ValueThe value to compute the log of
Returns
Log2 of Value. 0 if Value is 0.

Definition at line 343 of file GenericPlatformMath.h.

+ Here is the caller graph for this function:

◆ FloorToDouble()

static FORCEINLINE double FGenericPlatformMath::FloorToDouble ( double F)
inlinestatic

Converts a double to a less or equal integer.

Parameters
FFloating point value to convert
Returns
The nearest integer value to 'F'.

Definition at line 70 of file GenericPlatformMath.h.

+ Here is the caller graph for this function:

◆ FloorToFloat()

static FORCEINLINE float FGenericPlatformMath::FloorToFloat ( float F)
inlinestatic

Converts a float to the nearest less or equal integer.

Parameters
FFloating point value to convert
Returns
An integer less or equal to 'F'.

Definition at line 60 of file GenericPlatformMath.h.

+ Here is the caller graph for this function:

◆ FloorToInt()

static FORCEINLINE int32 FGenericPlatformMath::FloorToInt ( float F)
inlinestatic

Converts a float to a nearest less or equal integer.

Parameters
FFloating point value to convert
Returns
An integer less or equal to 'F'.

Definition at line 50 of file GenericPlatformMath.h.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Fmod()

static FORCEINLINE float FGenericPlatformMath::Fmod ( float X,
float Y )
inlinestatic

Returns the floating-point remainder of X / Y Warning: Always returns remainder toward 0, not toward the smaller multiple of Y. So for example Fmod(2.8f, 2) gives .8f as you would expect, however, Fmod(-2.8f, 2) gives -.8f, NOT 1.2f Use Floor instead when snapping positions that can be negative to a grid

Definition at line 192 of file GenericPlatformMath.h.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Frac()

static FORCEINLINE float FGenericPlatformMath::Frac ( float Value)
inlinestatic

Returns the fractional part of a float.

Parameters
ValueFloating point value to convert
Returns
A float between >=0 and < 1.

Definition at line 150 of file GenericPlatformMath.h.

+ Here is the call graph for this function:

◆ Fractional()

static FORCEINLINE float FGenericPlatformMath::Fractional ( float Value)
inlinestatic

Returns signed fractional part of a float.

Parameters
ValueFloating point value to convert
Returns
A float between >=0 and < 1 for nonnegative input. A float between >= -1 and < 0 for negative input.

Definition at line 140 of file GenericPlatformMath.h.

+ Here is the call graph for this function:

◆ FRand()

static FORCEINLINE float FGenericPlatformMath::FRand ( )
inlinestatic

Returns a random float between 0 and 1, inclusive.

Definition at line 261 of file GenericPlatformMath.h.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ InvSqrt()

static FORCEINLINE float FGenericPlatformMath::InvSqrt ( float F)
inlinestatic

Computes a fully accurate inverse square root

Definition at line 223 of file GenericPlatformMath.h.

+ Here is the caller graph for this function:

◆ InvSqrtEst()

static FORCEINLINE float FGenericPlatformMath::InvSqrtEst ( float F)
inlinestatic

Computes a faster but less accurate inverse square root

Definition at line 229 of file GenericPlatformMath.h.

+ Here is the call graph for this function:

◆ IsFinite()

static FORCEINLINE bool FGenericPlatformMath::IsFinite ( float A)
inlinestatic

Return true if value is finite (not NaN and not Infinity).

Definition at line 240 of file GenericPlatformMath.h.

+ Here is the caller graph for this function:

◆ IsNaN()

static FORCEINLINE bool FGenericPlatformMath::IsNaN ( float A)
inlinestatic

Return true if value is NaN (not a number).

Definition at line 235 of file GenericPlatformMath.h.

◆ IsNegativeDouble()

static FORCEINLINE bool FGenericPlatformMath::IsNegativeDouble ( const double & A)
inlinestatic

Definition at line 249 of file GenericPlatformMath.h.

◆ IsNegativeFloat()

static FORCEINLINE bool FGenericPlatformMath::IsNegativeFloat ( const float & A)
inlinestatic

Definition at line 244 of file GenericPlatformMath.h.

◆ Log2()

static FORCEINLINE float FGenericPlatformMath::Log2 ( float Value)
inlinestatic

Definition at line 184 of file GenericPlatformMath.h.

+ Here is the call graph for this function:

◆ Loge()

static FORCEINLINE float FGenericPlatformMath::Loge ( float Value)
inlinestatic

Definition at line 181 of file GenericPlatformMath.h.

+ Here is the caller graph for this function:

◆ LogX()

static FORCEINLINE float FGenericPlatformMath::LogX ( float Base,
float Value )
inlinestatic

Definition at line 182 of file GenericPlatformMath.h.

+ Here is the call graph for this function:

◆ Max() [1/2]

template<class T >
static CONSTEXPR FORCEINLINE T FGenericPlatformMath::Max ( const T A,
const T B )
inlinestatic

Returns higher value in a generic way

Definition at line 523 of file GenericPlatformMath.h.

+ Here is the caller graph for this function:

◆ Max() [2/2]

template<class T >
static FORCEINLINE T FGenericPlatformMath::Max ( const TArray< T > & Values,
int32 * MaxIndex = NULL )
inlinestatic

Max of Array

Parameters
Arrayof templated type
Optionalpointer for returning the index of the maximum element, if multiple maximum elements the first index is returned
Returns
The max value found in the array or default value if the array was empty

Definition at line 579 of file GenericPlatformMath.h.

◆ Min() [1/2]

template<class T >
static CONSTEXPR FORCEINLINE T FGenericPlatformMath::Min ( const T A,
const T B )
inlinestatic

Returns lower value in a generic way

Definition at line 530 of file GenericPlatformMath.h.

+ Here is the caller graph for this function:

◆ Min() [2/2]

template<class T >
static FORCEINLINE T FGenericPlatformMath::Min ( const TArray< T > & Values,
int32 * MinIndex = NULL )
inlinestatic

Min of Array

Parameters
Arrayof templated type
Optionalpointer for returning the index of the minimum element, if multiple minimum elements the first index is returned
Returns
The min value found in the array or default value if the array was empty

Definition at line 542 of file GenericPlatformMath.h.

◆ Modf() [1/2]

static FORCEINLINE double FGenericPlatformMath::Modf ( const double InValue,
double * OutIntPart )
inlinestatic

Breaks the given value into an integral and a fractional part.

Parameters
InValueFloating point value to convert
OutIntPartFloating point value that receives the integral part of the number.
Returns
The fractional part of the number.

Definition at line 172 of file GenericPlatformMath.h.

◆ Modf() [2/2]

static FORCEINLINE float FGenericPlatformMath::Modf ( const float InValue,
float * OutIntPart )
inlinestatic

Breaks the given value into an integral and a fractional part.

Parameters
InValueFloating point value to convert
OutIntPartFloating point value that receives the integral part of the number.
Returns
The fractional part of the number.

Definition at line 161 of file GenericPlatformMath.h.

◆ MortonCode2()

static FORCEINLINE uint32 FGenericPlatformMath::MortonCode2 ( uint32 x)
inlinestatic

Spreads bits to every other.

Definition at line 426 of file GenericPlatformMath.h.

◆ MortonCode3()

static FORCEINLINE uint32 FGenericPlatformMath::MortonCode3 ( uint32 x)
inlinestatic

Spreads bits to every 3rd.

Definition at line 448 of file GenericPlatformMath.h.

◆ Pow()

static FORCEINLINE float FGenericPlatformMath::Pow ( float A,
float B )
inlinestatic

Definition at line 220 of file GenericPlatformMath.h.

◆ Rand()

static FORCEINLINE int32 FGenericPlatformMath::Rand ( )
inlinestatic

Returns a random integer between 0 and RAND_MAX, inclusive

Definition at line 255 of file GenericPlatformMath.h.

+ Here is the caller graph for this function:

◆ RandInit()

static FORCEINLINE void FGenericPlatformMath::RandInit ( int32 Seed)
inlinestatic

Seeds global random number functions Rand() and FRand()

Definition at line 258 of file GenericPlatformMath.h.

◆ ReverseMortonCode2()

static FORCEINLINE uint32 FGenericPlatformMath::ReverseMortonCode2 ( uint32 x)
inlinestatic

Reverses MortonCode2. Compacts every other bit to the right.

Definition at line 437 of file GenericPlatformMath.h.

◆ ReverseMortonCode3()

static FORCEINLINE uint32 FGenericPlatformMath::ReverseMortonCode3 ( uint32 x)
inlinestatic

Reverses MortonCode3. Compacts every 3rd bit to the right.

Definition at line 459 of file GenericPlatformMath.h.

◆ RoundToDouble()

static FORCEINLINE double FGenericPlatformMath::RoundToDouble ( double F)
inlinestatic

Converts a double to the nearest integer. Rounds up when the fraction is .5

Parameters
FFloating point value to convert
Returns
The nearest integer to 'F'.

Definition at line 100 of file GenericPlatformMath.h.

+ Here is the call graph for this function:

◆ RoundToFloat()

static FORCEINLINE float FGenericPlatformMath::RoundToFloat ( float F)
inlinestatic

Converts a float to the nearest integer. Rounds up when the fraction is .5

Parameters
FFloating point value to convert
Returns
The nearest integer to 'F'.

Definition at line 90 of file GenericPlatformMath.h.

+ Here is the call graph for this function:

◆ RoundToInt()

static FORCEINLINE int32 FGenericPlatformMath::RoundToInt ( float F)
inlinestatic

Converts a float to the nearest integer. Rounds up when the fraction is .5

Parameters
FFloating point value to convert
Returns
The nearest integer to 'F'.

Definition at line 80 of file GenericPlatformMath.h.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ RoundUpToPowerOfTwo()

static FORCEINLINE uint32 FGenericPlatformMath::RoundUpToPowerOfTwo ( uint32 Arg)
inlinestatic
Returns
Rounds the given number up to the next highest power of two.

Definition at line 420 of file GenericPlatformMath.h.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Sign()

template<class T >
static CONSTEXPR FORCEINLINE T FGenericPlatformMath::Sign ( const T A)
inlinestatic

Returns 1, 0, or -1 depending on relation of T to 0

Definition at line 516 of file GenericPlatformMath.h.

◆ Sin()

static FORCEINLINE float FGenericPlatformMath::Sin ( float Value)
inlinestatic

Definition at line 212 of file GenericPlatformMath.h.

+ Here is the caller graph for this function:

◆ Sinh()

static FORCEINLINE float FGenericPlatformMath::Sinh ( float Value)
inlinestatic

Definition at line 214 of file GenericPlatformMath.h.

◆ Sqrt()

static FORCEINLINE float FGenericPlatformMath::Sqrt ( float Value)
inlinestatic

Definition at line 219 of file GenericPlatformMath.h.

+ Here is the caller graph for this function:

◆ Tan()

static FORCEINLINE float FGenericPlatformMath::Tan ( float Value)
inlinestatic

Definition at line 217 of file GenericPlatformMath.h.

◆ TruncToFloat()

static CONSTEXPR FORCEINLINE float FGenericPlatformMath::TruncToFloat ( float F)
inlinestatic

Converts a float to an integer value with truncation towards zero.

Parameters
FFloating point value to convert
Returns
Truncated integer value.

Definition at line 40 of file GenericPlatformMath.h.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ TruncToInt()

static CONSTEXPR FORCEINLINE int32 FGenericPlatformMath::TruncToInt ( float F)
inlinestatic

Converts a float to an integer with truncation towards zero.

Parameters
FFloating point value to convert
Returns
Truncated integer.

Definition at line 30 of file GenericPlatformMath.h.

+ Here is the caller graph for this function:

The documentation for this struct was generated from the following file: