Plasma Engine  2.0
Loading...
Searching...
No Matches
Float16.h
1#pragma once
2
3#include <Foundation/Basics.h>
4#include <Foundation/Math/Declarations.h>
5
10class PL_FOUNDATION_DLL plFloat16
11{
12public:
13 // Means that vectors can be copied using memcpy instead of copy construction.
14 PL_DECLARE_POD_TYPE();
15
17 plFloat16() = default;
18
20 plFloat16(float f); // [tested]
21
23 void operator=(float f); // [tested]
24
26 void SetRawData(plUInt16 uiData) { m_uiData = uiData; } // [tested]
27
29 plUInt16 GetRawData() const { return m_uiData; } // [tested]
30
32 operator float() const; // [tested]
33
35 bool operator==(const plFloat16& c2) { return m_uiData == c2.m_uiData; } // [tested]
36
38 bool operator!=(const plFloat16& c2) { return m_uiData != c2.m_uiData; } // [tested]
39
40private:
42 plUInt16 m_uiData;
43};
44
46class PL_FOUNDATION_DLL plFloat16Vec2
47{
48public:
49 // Means that vectors can be copied using memcpy instead of copy construction.
50 PL_DECLARE_POD_TYPE();
51
52 plFloat16Vec2() = default;
53 plFloat16Vec2(const plVec2& vVec);
54
55 void operator=(const plVec2& vVec);
56 operator plVec2() const;
57
58 plFloat16 x, y;
59};
60
62class PL_FOUNDATION_DLL plFloat16Vec3
63{
64public:
65 // Means that vectors can be copied using memcpy instead of copy construction.
66 PL_DECLARE_POD_TYPE();
67
68 plFloat16Vec3() = default;
69 plFloat16Vec3(const plVec3& vVec);
70
71 void operator=(const plVec3& vVec);
72 operator plVec3() const;
73
74 plFloat16 x, y, z;
75};
76
78class PL_FOUNDATION_DLL plFloat16Vec4
79{
80public:
81 // Means that vectors can be copied using memcpy instead of copy construction.
82 PL_DECLARE_POD_TYPE();
83
84 plFloat16Vec4() = default;
85 plFloat16Vec4(const plVec4& vVec);
86
87 void operator=(const plVec4& vVec);
88 operator plVec4() const;
89
90 plFloat16 x, y, z, w;
91};
A 16 bit IEEE float class. Often called "half".
Definition Float16.h:11
bool operator!=(const plFloat16 &c2)
Returns true, if both values are not identical.
Definition Float16.h:38
bool operator==(const plFloat16 &c2)
Returns true, if both values are identical.
Definition Float16.h:35
plUInt16 GetRawData() const
Returns the raw 16 Bit data.
Definition Float16.h:29
void SetRawData(plUInt16 uiData)
Create float16 from raw data.
Definition Float16.h:26
plFloat16()=default
Default constructor does not initialize the value.
A simple helper class to use half-precision floats (plFloat16) as vectors.
Definition Float16.h:47
A simple helper class to use half-precision floats (plFloat16) as vectors.
Definition Float16.h:63
A simple helper class to use half-precision floats (plFloat16) as vectors.
Definition Float16.h:79