Ark Server API (ASA) - Wiki
Loading...
Searching...
No Matches
OrthoMatrix.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
12
13template<typename T>
14struct TOrthoMatrix
15 : public TMatrix<T>
16{
17public:
18
19 /**
20 * Constructor
21 *
22 * @param Width view space width
23 * @param Height view space height
24 * @param ZScale scale in the Z axis
25 * @param ZOffset offset in the Z axis
26 */
27 TOrthoMatrix(T Width,T Height,T ZScale,T ZOffset);
28
29 // Conversion to other type.
30 template<typename FArg, TEMPLATE_REQUIRES(!std::is_same_v<T, FArg>)>
31 explicit TOrthoMatrix(const TOrthoMatrix<FArg>& From) : TMatrix<T>(From) {}
32};
33
34
35template<typename T>
36struct TReversedZOrthoMatrix : public TMatrix<T>
37{
38public:
39 TReversedZOrthoMatrix(T Width,T Height,T ZScale,T ZOffset);
40 TReversedZOrthoMatrix(T Left, T Right, T Bottom, T Top, T ZScale, T ZOffset);
41
42 // Conversion to other type.
43 template<typename FArg, TEMPLATE_REQUIRES(!std::is_same_v<T, FArg>)>
44 explicit TReversedZOrthoMatrix(const TReversedZOrthoMatrix<FArg>& From) : TMatrix<T>(From) {}
45};
46
47template<typename T>
48FORCEINLINE TOrthoMatrix<T>::TOrthoMatrix(T Width, T Height, T ZScale, T ZOffset)
49 : TMatrix<T>(
50 TPlane<T>((Width != 0.0f) ? (1.0f / Width) : 1.0f, 0.0f, 0.0f, 0.0f),
51 TPlane<T>(0.0f, (Height != 0.0f) ? (1.0f / Height) : 1.f, 0.0f, 0.0f),
52 TPlane<T>(0.0f, 0.0f, ZScale, 0.0f),
53 TPlane<T>(0.0f, 0.0f, ZOffset * ZScale, 1.0f)
54 )
55{ }
56
57
58template<typename T>
59FORCEINLINE TReversedZOrthoMatrix<T>::TReversedZOrthoMatrix(T Width, T Height, T ZScale, T ZOffset)
60 : TMatrix<T>(
61 TPlane<T>((Width != 0.0f) ? (1.0f / Width) : 1.0f, 0.0f, 0.0f, 0.0f),
62 TPlane<T>(0.0f, (Height != 0.0f) ? (1.0f / Height) : 1.f, 0.0f, 0.0f),
63 TPlane<T>(0.0f, 0.0f, -ZScale, 0.0f),
64 TPlane<T>(0.0f, 0.0f, 1.0f - ZOffset * ZScale, 1.0f)
65 )
66{ }
67
68template<typename T>
69FORCEINLINE TReversedZOrthoMatrix<T>::TReversedZOrthoMatrix(T Left, T Right, T Bottom, T Top, T ZScale, T ZOffset)
70 : TMatrix<T>(
71 TPlane<T>(1.0f / (Right - Left), 0.0f, 0.0f, 0.0f),
72 TPlane<T>(0.0f, 1.0f / (Top - Bottom), 0.0f, 0.0f),
73 TPlane<T>(0.0f, 0.0f, -ZScale, 0.0f),
74 TPlane<T>((Left + Right) / (Left - Right), (Top + Bottom) / (Bottom - Top), 1.0f - ZOffset * ZScale, 1.0f)
75 )
76{ }
77
78 } // namespace Math
79 } // namespace UE
80
81UE_DECLARE_LWC_TYPE(OrthoMatrix, 44);
82UE_DECLARE_LWC_TYPE(ReversedZOrthoMatrix, 44);
83
84template<> struct TIsUECoreVariant<FOrthoMatrix44f> { enum { Value = true }; };
85template<> struct TIsUECoreVariant<FOrthoMatrix44d> { enum { Value = true }; };
86template<> struct TIsUECoreVariant<FReversedZOrthoMatrix44f> { enum { Value = true }; };
87template<> struct TIsUECoreVariant<FReversedZOrthoMatrix44d> { enum { Value = true }; };
#define UE_DECLARE_LWC_TYPE(...)
#define FORCEINLINE
Definition Platform.h:644
#define TEMPLATE_REQUIRES(...)