UKismetMathLibrary::Matrix_ContainsNaN
#include "Kismet/KismetMathLibrary.h"
Access: public
Specifiers: staticUFUNCTIONBlueprintPure
Description
Returns true if any of the 16 float elements of the matrix is NaN. Use this as a guard before operations that would propagate NaN silently (inverse, rotation extraction, etc.).
Caveats & Gotchas
- • Checks for NaN only, not for Inf. A matrix can pass this check and still be degenerate if it contains infinite values — pair with a separate Inf check if the matrix originates from user-supplied or network data.
- • In Shipping builds UE may disable some floating-point checks; behaviour of NaN propagation is platform-dependent on consoles with aggressive FP optimisations. Validate at the boundary where data enters the system, not deep inside the simulation.
Signature
static UE_INL_API bool Matrix_ContainsNaN(const FMatrix& M) Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| M | const FMatrix& | The matrix to check for NaN values. | — |
Return Type
bool Example
Guard before matrix inversion C++
FMatrix M = ComputeSomething();
if (UKismetMathLibrary::Matrix_ContainsNaN(M))
{
UE_LOG(LogTemp, Warning, TEXT("Degenerate matrix detected, skipping inversion"));
return;
}
FMatrix Inv = UKismetMathLibrary::Matrix_GetInverse(M); Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?