ezEngine  Milestone 9
Float16.h
1 #pragma once
2 
7 class EZ_FOUNDATION_DLL ezFloat16
8 {
9 public:
10  // Means that vectors can be copied using memcpy instead of copy construction.
12 
14  ezFloat16() = default;
15 
17  ezFloat16(float f); // [tested]
18 
20  void operator=(float f); // [tested]
21 
23  void SetRawData(ezUInt16 data) { m_uiData = data; } // [tested]
24 
26  ezUInt16 GetRawData() const { return m_uiData; } // [tested]
27 
29  operator float() const; // [tested]
30 
32  bool operator==(const ezFloat16& c2) { return m_uiData == c2.m_uiData; } // [tested]
33 
35  bool operator!=(const ezFloat16& c2) { return m_uiData != c2.m_uiData; } // [tested]
36 
37 private:
39  ezUInt16 m_uiData;
40 };
41 
43 class EZ_FOUNDATION_DLL ezFloat16Vec2
44 {
45 public:
46  // Means that vectors can be copied using memcpy instead of copy construction.
48 
49  ezFloat16Vec2() = default;
50  ezFloat16Vec2(const ezVec2& vec);
51 
52  void operator=(const ezVec2& vec);
53  operator ezVec2() const;
54 
55  ezFloat16 x, y;
56 };
57 
59 class EZ_FOUNDATION_DLL ezFloat16Vec3
60 {
61 public:
62  // Means that vectors can be copied using memcpy instead of copy construction.
64 
65  ezFloat16Vec3() = default;
66  ezFloat16Vec3(const ezVec3& vec);
67 
68  void operator=(const ezVec3& vec);
69  operator ezVec3() const;
70 
71  ezFloat16 x, y, z;
72 };
73 
75 class EZ_FOUNDATION_DLL ezFloat16Vec4
76 {
77 public:
78  // Means that vectors can be copied using memcpy instead of copy construction.
80 
81  ezFloat16Vec4() = default;
82  ezFloat16Vec4(const ezVec4& vec);
83 
84  void operator=(const ezVec4& vec);
85  operator ezVec4() const;
86 
87  ezFloat16 x, y, z, w;
88 };
89 
A simple helper class to use half-precision floats (ezFloat16) as vectors.
Definition: Float16.h:59
A 16 bit IEEE float class. Often called "half".
Definition: Float16.h:7
A simple helper class to use half-precision floats (ezFloat16) as vectors.
Definition: Float16.h:43
#define EZ_DECLARE_POD_TYPE()
Embed this into a class to mark it as a POD type. POD types will get special treatment from allocator...
Definition: TypeTraits.h:128
bool operator!=(const ezFloat16 &c2)
Returns true, if both values are not identical.
Definition: Float16.h:35
A 4-component vector class.
Definition: Declarations.h:82
bool operator==(const ezFloat16 &c2)
Returns true, if both values are identical.
Definition: Float16.h:32
A simple helper class to use half-precision floats (ezFloat16) as vectors.
Definition: Float16.h:75
void SetRawData(ezUInt16 data)
Create float16 from raw data.
Definition: Float16.h:23
ezUInt16 GetRawData() const
Returns the raw 16 Bit data.
Definition: Float16.h:26