Ark Server API (ASA) - Wiki
Loading...
Searching...
No Matches
ScaleMatrix.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/**
13 * Scale matrix.
14 */
15template<typename T>
16struct TScaleMatrix
17 : public TMatrix<T>
18{
19public:
20
21 /**
22 * @param Scale uniform scale to apply to matrix.
23 */
24 TScaleMatrix( T Scale );
25
26 /**
27 * @param Scale Non-uniform scale to apply to matrix.
28 */
29 TScaleMatrix( const TVector<T>& Scale );
30
31 // Conversion to other type.
32 template<typename FArg, TEMPLATE_REQUIRES(!std::is_same_v<T, FArg>)>
33 explicit TScaleMatrix(const TScaleMatrix<FArg>& From) : TMatrix<T>(From) {}
34
35 /** Matrix factory. Return an TMatrix<T> so we don't have type conversion issues in expressions. */
36 static TMatrix<T> Make(T Scale)
37 {
38 return TScaleMatrix<T>(Scale);
39 }
40
41 /** Matrix factory. Return an TMatrix<T> so we don't have type conversion issues in expressions. */
42 static TMatrix<T> Make(const TVector<T>& Scale)
43 {
44 return TScaleMatrix<T>(Scale);
45 }
46};
47
48
49/* FScaleMatrix inline functions
50 *****************************************************************************/
51
52template<typename T>
53FORCEINLINE TScaleMatrix<T>::TScaleMatrix( T Scale )
54 : TMatrix<T>(
55 TPlane<T>(Scale, 0.0f, 0.0f, 0.0f),
56 TPlane<T>(0.0f, Scale, 0.0f, 0.0f),
57 TPlane<T>(0.0f, 0.0f, Scale, 0.0f),
58 TPlane<T>(0.0f, 0.0f, 0.0f, 1.0f)
59 )
60{ }
61
62
63template<typename T>
64FORCEINLINE TScaleMatrix<T>::TScaleMatrix( const TVector<T>& Scale )
65 : TMatrix<T>(
66 TPlane<T>(Scale.X, 0.0f, 0.0f, 0.0f),
67 TPlane<T>(0.0f, Scale.Y, 0.0f, 0.0f),
68 TPlane<T>(0.0f, 0.0f, Scale.Z, 0.0f),
69 TPlane<T>(0.0f, 0.0f, 0.0f, 1.0f)
70 )
71{ }
72
73} // namespace Math
74} // namespace UE
75
76UE_DECLARE_LWC_TYPE(ScaleMatrix, 44);
77
78template<> struct TIsUECoreVariant<FScaleMatrix44f> { enum { Value = true }; };
79template<> struct TIsUECoreVariant<FScaleMatrix44d> { enum { Value = true }; };
#define UE_DECLARE_LWC_TYPE(...)
#define FORCEINLINE
Definition Platform.h:644
#define TEMPLATE_REQUIRES(...)