3#include <SDL3/SDL_stdinc.h>
12using Vec3u8 = Eigen::Matrix<Uint8, 3, 1>;
13using Vec4u8 = Eigen::Matrix<Uint8, 4, 1>;
17using GpuVec2 = Eigen::Matrix<float, 2, 1, Eigen::DontAlign>;
18using GpuVec3 = Eigen::Matrix<float, 3, 1, Eigen::DontAlign>;
19using GpuVec4 = Eigen::Matrix<float, 4, 1, Eigen::DontAlign>;
22 GpuMat3(Eigen::Matrix3f value) : _data() {
23 _data.topRows<3>() = value;
25 operator auto &() {
return _data; }
26 operator const auto &()
const {
return _data; }
29 Eigen::Matrix<float, 4, 3, Eigen::DontAlign> _data;
31using GpuMat4 = Eigen::Matrix<float, 4, 4, Eigen::ColMajor | Eigen::DontAlign>;
34 inline constexpr double Pi = 3.1415926535897932;
35 inline constexpr float Pif = 3.141592654f;
36 inline constexpr double Pi_2 = 1.5707963267948966;
37 inline constexpr float Pi_2f = 1.5707963267f;
52template <std::
floating_po
int T>
struct Rad;
53template <std::
floating_po
int T>
struct Deg;
58template <std::
floating_po
int T>
struct Rad {
59 constexpr Rad() : _value(static_cast<T>(0.)) {}
60 constexpr Rad(T value) : _value(value) {}
62 constexpr operator T &() {
return _value; }
63 constexpr operator T()
const {
return _value; }
64 constexpr operator T *() {
return &_value; }
66 return _value == other._value;
69 return (*
this) ==
Rad(other);
80template <std::
floating_po
int T>
struct Deg {
81 constexpr Deg() : _value(static_cast<T>(0.)) {}
82 constexpr Deg(T value) : _value(value) {}
84 constexpr operator T &() {
return _value; }
85 constexpr operator T()
const {
return _value; }
86 constexpr operator T *() {
return &_value; }
88 return _value == other._value;
91 return _value ==
Deg(other);
99template <std::
floating_po
int T>
101 return Rad<T>{T(left) * right};
104template <std::
floating_po
int T>
106 return Rad<T>{left * T(right)};
109inline constexpr auto operator""_radf(
long double t) {
113inline constexpr auto operator""_rad(
long double t) {
117inline constexpr auto operator""_deg(
long double t) {
121inline constexpr auto operator""_degf(
long double t) {
138 return hexToRgbi(hex).cast<
float>() / 255.f;
147inline Float4 operator""_rgbaf(
unsigned long long hex) {
151inline Eigen::Vector3d
operator""_rgb(
unsigned long long hex) {
152 return hexToRgbi(hex).cast<
double>() / 255.;
155inline Eigen::Vector4d
operator""_rgba(
unsigned long long hex) {
161 Uint32 q = value / 16;
162 Uint32 r = value % 16;
165 return (q + 1) * 16u;
169 return M.topLeftCorner<3, 3>().inverse().transpose();
Deg< float > Degf
Definition math_types.h:126
constexpr Rad< T > operator*(const Rad< T > &left, const T &right)
Definition math_types.h:100
Rad< float > Radf
Definition math_types.h:125
Definition math_types.h:33
constexpr float Pi_2f
Definition math_types.h:37
constexpr double Pi_2
Definition math_types.h:36
constexpr float Pif
Definition math_types.h:35
constexpr double Pi
Definition math_types.h:34
constexpr Uint32 roundUpTo16(Uint32 value)
Definition math_types.h:160
Mat3f computeNormalMatrix(const Eigen::Affine3f &M)
Definition Camera.h:11
Eigen::Vector3f Float3
Definition math_types.h:8
Eigen::Matrix< float, 2, 1, Eigen::DontAlign > GpuVec2
Definition math_types.h:17
Eigen::Matrix< float, 4, 4, Eigen::ColMajor|Eigen::DontAlign > GpuMat4
Definition math_types.h:31
Eigen::Matrix< Uint8, 3, 1 > Vec3u8
Definition math_types.h:12
Eigen::Matrix3f Mat3f
Definition math_types.h:10
constexpr float rad2deg(float t)
Definition math_types.h:42
constexpr double deg2rad(double t)
Definition math_types.h:40
Float3 hexToRgbf(unsigned long hex)
Definition math_types.h:137
Vec4u8 hexToRgbai(unsigned long hex)
Eigen::Matrix< float, 3, 1, Eigen::DontAlign > GpuVec3
Definition math_types.h:18
Eigen::Vector4f Float4
Definition math_types.h:9
Eigen::Matrix< Uint8, 4, 1 > Vec4u8
Definition math_types.h:13
Float4 hexToRgbaf(unsigned long hex)
Definition math_types.h:141
Vec3u8 hexToRgbi(unsigned long hex)
std::tuple< const Mesh &, Mat4f > OpaqueCastable
Intermediary argument type for shadow-casting or opaque objects. For use in depth or light pre-passes...
Definition math_types.h:177
Eigen::Matrix< float, 4, 1, Eigen::DontAlign > GpuVec4
Definition math_types.h:19
std::array< Float3, 8ul > FrustumCornersType
Definition math_types.h:15
Eigen::Vector2f Float2
Definition math_types.h:7
Eigen::Matrix4f Mat4f
Definition math_types.h:11
Strong type for floating-point variables representing angles (in degrees).
Definition math_types.h:80
constexpr Deg()
Definition math_types.h:81
constexpr Deg(Rad< T > value)
Definition math_types.h:83
constexpr bool operator==(const Deg< U > &other) const
Definition math_types.h:87
constexpr bool operator==(const Rad< U > &other) const
Definition math_types.h:90
constexpr Deg(T value)
Definition math_types.h:82
GpuMat3(Eigen::Matrix3f value)
Definition math_types.h:22
Strong type for floating-point variables representing angles (in radians).
Definition math_types.h:58
constexpr bool operator==(const Rad< U > &other) const
Definition math_types.h:65
constexpr bool operator==(const Deg< U > &other) const
Definition math_types.h:68
constexpr Rad(T value)
Definition math_types.h:60
constexpr Rad(Deg< T > value)
Definition math_types.h:61
constexpr Rad()
Definition math_types.h:59