Created
March 28, 2023 18:15
-
-
Save jonahwilliams/bfb6767f9c0a2198260164ba65e0cf67 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// @brief A storage only class for half precision 4x4 matrix. | |
struct HalfMatrix { | |
union { | |
Half m[16]; | |
Half e[4][4]; | |
HalfVector4 vec[4]; | |
}; | |
constexpr HalfMatrix(const Matrix& m) | |
: vec{Vector4(m.m[0], m.m[1], m.m[2], m.m[3]), | |
Vector4(m.m[4], m.m[5], m.m[6], m.m[7]), | |
Vector4(m.m[8], m.m[9], m.m[10], m.m[11]), | |
Vector4(m.m[12], m.m[13], m.m[14], m.m[15])} {} | |
constexpr bool operator==(const HalfMatrix& m) const { | |
// clang-format off | |
return vec[0] == m.vec[0] | |
&& vec[1] == m.vec[1] | |
&& vec[2] == m.vec[2] | |
&& vec[3] == m.vec[3]; | |
// clang-format on | |
} | |
constexpr bool operator!=(const HalfMatrix& m) const { | |
// clang-format off | |
return vec[0] != m.vec[0] | |
|| vec[1] != m.vec[1] | |
|| vec[2] != m.vec[2] | |
|| vec[3] != m.vec[3]; | |
// clang-format on | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment