From a1c6e92bc2bd87d1b54deb458df42b958b8d03fb Mon Sep 17 00:00:00 2001 From: Qudix <17361645+Qudix@users.noreply.github.com> Date: Tue, 5 Nov 2024 15:04:42 -0600 Subject: [PATCH] feat: more formatters --- include/RE/N/NiQuaternion.h | 37 +++++++++++++++++++++++++++---------- include/RE/N/NiRect.h | 16 ++++++++++++++++ 2 files changed, 43 insertions(+), 10 deletions(-) diff --git a/include/RE/N/NiQuaternion.h b/include/RE/N/NiQuaternion.h index 93d2045b..9e0f0a1e 100644 --- a/include/RE/N/NiQuaternion.h +++ b/include/RE/N/NiQuaternion.h @@ -5,19 +5,14 @@ namespace RE class NiQuaternion { public: - float w{ 1.0f }; - float x{ 0.0f }; - float y{ 0.0f }; - float z{ 0.0f }; + NiQuaternion() noexcept = default; - NiQuaternion() {} + NiQuaternion(float a_w, float a_x, float a_y, float a_z) noexcept : + w(a_w), x(a_x), y(a_y), z(a_z) {} - NiQuaternion(float w, float x, float y, float z) : - w(w), x(x), y(y), z(z) {} - - NiQuaternion(const NiMatrix3& mat) + NiQuaternion(const NiMatrix3& a_mat) noexcept { - FromMatrix(mat); + FromMatrix(a_mat); } static NiQuaternion Slerp(const NiQuaternion& prev, NiQuaternion next, float t) @@ -260,6 +255,28 @@ namespace RE { return { -w, -x, -y, -z }; } + + // members + float w{ 1.0F }; // 00 + float x{ 0.0F }; // 04 + float y{ 0.0F }; // 08 + float z{ 0.0F }; // 0C }; static_assert(sizeof(NiQuaternion) == 0x10); } + +template <> +struct std::formatter +{ + template + constexpr auto parse(ParseContext& a_ctx) + { + return a_ctx.begin(); + } + + template + constexpr auto format(const RE::NiQuaternion& a_quat, FormatContext& a_ctx) const + { + return format_to(a_ctx.out(), "({}, {}, {}, {})", a_quat.w, a_quat.x, a_quat.y, a_quat.z); + } +}; diff --git a/include/RE/N/NiRect.h b/include/RE/N/NiRect.h index 5182ec15..6e433e36 100644 --- a/include/RE/N/NiRect.h +++ b/include/RE/N/NiRect.h @@ -16,3 +16,19 @@ namespace RE static_assert(sizeof(NiRect) == 0x10); static_assert(sizeof(NiRect) == 0x10); } + +template +struct std::formatter> +{ + template + constexpr auto parse(ParseContext& a_ctx) + { + return a_ctx.begin(); + } + + template + constexpr auto format(const RE::NiRect& a_rect, FormatContext& a_ctx) const + { + return format_to(a_ctx.out(), "({}, {}, {}, {})", a_rect.left, a_rect.right, a_rect.top, a_rect.bottom); + } +};