Ark Server API (ASA) - Wiki
Loading...
Searching...
No Matches
Vector2DHalf.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 "Containers/UnrealString.h"
7#include "Math/Vector2D.h"
8#include "Math/Float16.h"
9
10/**
11 * Structure for two dimensional vectors with half floating point precision.
12 */
14{
15 /** Holds the vector's X-component. */
17
18 /** Holds the vector's Y-component. */
20
21public:
22
23 /** Default Constructor (no initialization). */
25
26 /**
27 * Constructor.
28 *
29 * InX half float X value
30 * Iny half float Y value
31 */
32 FORCEINLINE FVector2DHalf( const FFloat16& InX,const FFloat16& InY );
33
34 /** Constructor
35 *
36 * InX float X value
37 * Iny float Y value
38 */
39 FORCEINLINE FVector2DHalf( float InX,float InY );
40
41 /** Constructor
42 *
43 * Vector2D float vector
44 */
45 FORCEINLINE FVector2DHalf( const FVector2f& Vector2D );
46 FORCEINLINE FVector2DHalf( const FVector2d& Vector2D );// LWC_TODO: This should probably be explicit
47
48public:
49
50 /**
51 * Assignment operator.
52 *
53 * @param Vector2D The value to assign.
54 */
55 FVector2DHalf& operator=( const FVector2f& Vector2D );
56 FVector2DHalf& operator=( const FVector2d& Vector2D ); // LWC_TODO: This should probably be explicit
57
58 /** Implicit conversion operator for conversion to FVector2D. */
59 operator FVector2f() const;
60 operator FVector2d() const;
61
62 /** Conversion with backwards-compatible Truncate rounding mode (default is RTNE) */
63 void SetTruncate( float InX, float InY );
64 void SetTruncate( const FVector2f& Vector2D );
65 void SetTruncate( const FVector2d& Vector2D );
66
67public:
68
69 /**
70 * Get a textual representation of the vector.
71 *
72 * @return Text describing the vector.
73 */
74 FString ToString() const;
75
76public:
77
78 /**
79 * Serializes the FVector2DHalf.
80 *
81 * @param Ar Reference to the serialization archive.
82 * @param V Reference to the FVector2DHalf being serialized.
83 * @return Reference to the Archive after serialization.
84 */
85 friend FArchive& operator<<( FArchive& Ar, FVector2DHalf& V )
86 {
87 return Ar << V.X << V.Y;
88 }
89};
90
91
92/* FVector2DHalf inline functions
93 *****************************************************************************/
94
96 : X(InX), Y(InY)
97{ }
98
99
101 : X(InX), Y(InY)
102{ }
103
104FORCEINLINE FVector2DHalf::FVector2DHalf( const FVector2f& Vector2D )
105 : X(Vector2D.X), Y(Vector2D.Y)
106{ }
107
108// LWC_TODO: Precision loss.
109FORCEINLINE FVector2DHalf::FVector2DHalf( const FVector2d& Vector2D )
110 : X((float)Vector2D.X), Y((float)Vector2D.Y)
111{ }
112
113FORCEINLINE FVector2DHalf& FVector2DHalf::operator=( const FVector2f& Vector2D )
114{
115 X = FFloat16(Vector2D.X);
116 Y = FFloat16(Vector2D.Y);
117
118 return *this;
119}
120
121// LWC_TODO: Precision loss.
122FORCEINLINE FVector2DHalf& FVector2DHalf::operator=( const FVector2d& Vector2D )
123{
124 X = FFloat16((float)Vector2D.X);
125 Y = FFloat16((float)Vector2D.Y);
126
127 return *this;
128}
129
131{
132 return FString::Printf(TEXT("X=%3.3f Y=%3.3f"), (float)X, (float)Y );
133}
134
135
137{
138 return FVector2f((float)X,(float)Y);
139}
140
142{
143 return FVector2d((float)X,(float)Y);
144}
145
146FORCEINLINE void FVector2DHalf::SetTruncate( float InX, float InY )
147{
150}
151
152FORCEINLINE void FVector2DHalf::SetTruncate( const FVector2f& Vector2D )
153{
154 SetTruncate(Vector2D.X,Vector2D.Y);
155}
156
157FORCEINLINE void FVector2DHalf::SetTruncate( const FVector2d& Vector2D )
158{
159 SetTruncate((float)Vector2D.X,(float)Vector2D.Y);
160}
#define TEXT(x)
Definition Platform.h:1108
#define FORCEINLINE
Definition Platform.h:644
FFloat16(const FFloat16 &FP16Value)
Definition Float16.h:128
void SetTruncate(float FP32Value)
Definition Float16.h:176
FFloat16(float FP32Value)
Definition Float16.h:134
FORCEINLINE FVector2DHalf(const FVector2d &Vector2D)
FORCEINLINE FVector2DHalf(const FVector2f &Vector2D)
FVector2DHalf & operator=(const FVector2d &Vector2D)
operator FVector2f() const
FORCEINLINE FVector2DHalf()
FORCEINLINE FVector2DHalf(float InX, float InY)
FORCEINLINE FVector2DHalf(const FFloat16 &InX, const FFloat16 &InY)
FString ToString() const
void SetTruncate(const FVector2f &Vector2D)
FVector2DHalf & operator=(const FVector2f &Vector2D)
void SetTruncate(float InX, float InY)
void SetTruncate(const FVector2d &Vector2D)