UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
RenderMath.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#include "CoreMinimal.h"
6#include "PackedNormal.h"
7
16inline float GetBasisDeterminantSign(const FVector& XAxis, const FVector& YAxis, const FVector& ZAxis)
17{
18 FMatrix Basis(
19 FPlane(XAxis, 0),
20 FPlane(YAxis, 0),
21 FPlane(ZAxis, 0),
22 FPlane(0, 0, 0, 1)
23 );
24 // RotDeterminant is the determinant of the upper left 3x3 matrix and equivalent to the full 4x4 determinant for this matrix
25 // at one fourth the cost.
26 return (Basis.RotDeterminant() < 0) ? -1.0f : +1.0f;
27}
28
37inline int8 GetBasisDeterminantSignByte(const FPackedNormal& XAxis, const FPackedNormal& YAxis, const FPackedNormal& ZAxis)
38{
39 return GetBasisDeterminantSign(XAxis.ToFVector(), YAxis.ToFVector(), ZAxis.ToFVector()) < 0 ? -127 : 127;
40}
41
48template<typename VectorType>
49inline FVector GenerateYAxis(const VectorType& XAxis, const VectorType& ZAxis)
50{
51 static_assert(std::is_same_v<VectorType, FPackedNormal> ||
52 std::is_same_v<VectorType, FPackedRGBA16N>, "ERROR: Must be FPackedNormal or FPackedRGBA16N");
53 FVector x = XAxis.ToFVector();
54 FVector4 z = ZAxis.ToFVector4();
55 return (FVector(z) ^ x) * z.W;
56}
FPlatformTypes::int8 int8
An 8-bit signed integer.
Definition Platform.h:1121
#define FVector
Definition IOSSystemIncludes.h:8
UE::Math::TPlane< double > FPlane
Definition MathFwd.h:52
int8 GetBasisDeterminantSignByte(const FPackedNormal &XAxis, const FPackedNormal &YAxis, const FPackedNormal &ZAxis)
Definition RenderMath.h:37
FVector GenerateYAxis(const VectorType &XAxis, const VectorType &ZAxis)
Definition RenderMath.h:49
float GetBasisDeterminantSign(const FVector &XAxis, const FVector &YAxis, const FVector &ZAxis)
Definition RenderMath.h:16
Definition PackedNormal.h:13
FVector ToFVector() const
Definition PackedNormal.h:162
T RotDeterminant() const
Definition Matrix.inl:344
T W
Definition Vector4.h:52