Crafter.Math/Crafter.Math-BasicTypes.cppm
2025-05-05 02:01:44 +02:00

43 lines
No EOL
948 B
C++
Executable file

module;
#include <cstdint>
#include <stdfloat>
#include <format>
export module Crafter.Math:BasicTypes;
namespace Crafter {
export struct Float2 {
float x;
float y;
};
export struct Float3 {
float x;
float y;
float z;
};
export struct Float4 {
float x;
float y;
float z;
float w;
};
export struct Float4x4 {
float c1[4];
float c2[4];
float c3[4];
float c4[4];
};
}
template <>
struct std::formatter<Crafter::Float4x4> : std::formatter<std::string> {
auto format(const Crafter::Float4x4& obj, format_context& ctx) const {
return std::formatter<std::string>::format(std::format("{{{}, {}, {}, {}\n{}, {}, {}, {}\n{}, {}, {}, {}\n{}, {}, {}, {}}}",
obj.c1[0], obj.c2[0], obj.c3[0], obj.c4[0],
obj.c1[1], obj.c2[1], obj.c3[1], obj.c4[1],
obj.c1[2], obj.c2[2], obj.c3[2], obj.c4[2],
obj.c1[3], obj.c2[3], obj.c3[3], obj.c4[3]
), ctx);
}
};