UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
ClipProjectionMatrix.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#include "CoreTypes.h"
6#include "Math/Plane.h"
7#include "Math/Matrix.h"
8
9namespace UE {
10namespace Math {
11
18template<typename T>
20{
21public:
22 using TMatrix<T>::M;
30
31 // Conversion to other type.
32 template<typename FArg UE_REQUIRES(!std::is_same_v<T, FArg>)>
34 : TMatrix<T>(From)
35 {
36 }
37
38private:
40 inline T sgn(T a );
41};
42
43
44template<typename T>
47{
48 // Calculate the clip-space corner point opposite the clipping plane
49 // as (sgn(clipPlane.x), sgn(clipPlane.y), 1, 1) and
50 // transform it into camera space by multiplying it
51 // by the inverse of the projection matrix
53 sgn(Plane.X) / SrcProjMat.M[0][0],
54 sgn(Plane.Y) / SrcProjMat.M[1][1],
55 1.0f,
56 -(1.0f - SrcProjMat.M[2][2]) / SrcProjMat.M[3][2]
57 );
58
59 // Calculate the scaled plane vector
60 TPlane<T> ProjPlane( Plane * (1.0f / (Plane | CornerPlane)) );
61
62 // use the projected space clip plane in z column
63 // Note: (account for our negated W coefficient)
64 M[0][2] = ProjPlane.X;
65 M[1][2] = ProjPlane.Y;
66 M[2][2] = ProjPlane.Z;
67 M[3][2] = -ProjPlane.W;
68}
69
70template<typename T>
72{
73 if (a > 0.0f) return (1.0f);
74 if (a < 0.0f) return (-1.0f);
75 return (0.0f);
76}
77
78} // namespace Math
79} // namespace UE
80
82
83template<> struct TIsUECoreVariant<FClipProjectionMatrix44f> { enum { Value = true }; };
84template<> struct TIsUECoreVariant<FClipProjectionMatrix44d> { enum { Value = true }; };
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
#define UE_DECLARE_LWC_TYPE(...)
Definition LargeWorldCoordinates.h:27
Definition AdvancedWidgetsModule.cpp:13
Definition IsUECoreType.h:19
@ Value
Definition IsUECoreType.h:20
Definition ClipProjectionMatrix.h:20
TClipProjectionMatrix(const TClipProjectionMatrix< FArg > &From)
Definition ClipProjectionMatrix.h:33
TClipProjectionMatrix(const TMatrix< T > &SrcProjMat, const TPlane< T > &Plane)
Definition ClipProjectionMatrix.h:45
Definition Matrix.h:43
T M[4][4]
Definition Matrix.h:49
Definition Plane.h:35