CeresEngine 0.2.0
A game development framework
Loading...
Searching...
No Matches
Matrix.hpp
Go to the documentation of this file.
1//
2// CeresEngine - A game development framework
3//
4// Created by Rogiel Sulzbach.
5// Copyright (c) 2018-2022 Rogiel Sulzbach. All rights reserved.
6//
7
8#pragma once
9
10#include "Forward.hpp"
12
14
15#include <glm/gtc/matrix_transform.hpp>
16#include <glm/mat2x2.hpp>
17#include <glm/mat3x3.hpp>
18#include <glm/mat4x4.hpp>
19
20namespace CeresEngine::inline Math {
21
23 template<glm::length_t C, glm::length_t R, typename T = double> using TMatrix = glm::mat<C, R, T, glm::highp>;
24
25 // ---------------------------------------------------------------------------------------------
26
28 template<typename T = double> using TMatrix2 = TMatrix<2, 2, T>;
29
31 using Matrix2 CE_SCRIPT_EXPORT(name = "Matrix2", external = true, plain = true)
33
35 using Matrix2f CE_SCRIPT_EXPORT(name = "Matrix2", external = true, plain = true)
37
38 // ---------------------------------------------------------------------------------------------
39
41 template<typename T = double> using TMatrix3 = TMatrix<3, 3, T>;
42
44 using Matrix3 CE_SCRIPT_EXPORT(name = "Matrix3", external = true, plain = true)
46
48 using Matrix3f CE_SCRIPT_EXPORT(name = "Matrix3", external = true, plain = true)
50
51 // ---------------------------------------------------------------------------------------------
52
54 template<typename T = double> using TMatrix4 = TMatrix<4, 4, T>;
55
57 using Matrix4 CE_SCRIPT_EXPORT(name = "Matrix4", external = true, plain = true)
59
61 using Matrix4f CE_SCRIPT_EXPORT(name = "Matrix4", external = true, plain = true)
63
64 // ---------------------------------------------------------------------------------------------
65
67 template<typename T = double> using TMatrix2x3 = TMatrix<2, 3, T>;
68
70 using Matrix2x3 CE_SCRIPT_EXPORT(name = "Matrix2x3", external = true, plain = true)
72
74 using Matrix2x3f CE_SCRIPT_EXPORT(name = "Matrix2x3", external = true, plain = true)
76
77 // ---------------------------------------------------------------------------------------------
78
80 template<typename T = double> using TMatrix2x4 = TMatrix<2, 4, T>;
81
83 using Matrix2x4 CE_SCRIPT_EXPORT(name = "Matrix2x4", external = true, plain = true)
85
87 using Matrix2x4f CE_SCRIPT_EXPORT(name = "Matrix2x4", external = true, plain = true)
89
90 // ---------------------------------------------------------------------------------------------
91
93 template<typename T = double> using TMatrix3x2 = TMatrix<3, 2, T>;
94
96 using Matrix3x2 CE_SCRIPT_EXPORT(name = "Matrix3x2", external = true, plain = true)
98
100 using Matrix3x2f CE_SCRIPT_EXPORT(name = "Matrix3x2", external = true, plain = true)
102
103 // ---------------------------------------------------------------------------------------------
104
106 template<typename T = double> using TMatrix3x4 = TMatrix<3, 4, T>;
107
109 using Matrix3x4 CE_SCRIPT_EXPORT(name = "Matrix3x4", external = true, plain = true)
111
113 using Matrix3x4f CE_SCRIPT_EXPORT(name = "Matrix3x4", external = true, plain = true)
115
116 // ---------------------------------------------------------------------------------------------
117
119 template<typename T = double> using TMatrix4x2 = TMatrix<4, 2, T>;
120
122 using Matrix4x2 CE_SCRIPT_EXPORT(name = "Matrix4x2", external = true, plain = true)
124
126 using Matrix4x2f CE_SCRIPT_EXPORT(name = "Matrix4x2", external = true, plain = true)
128
129 // ---------------------------------------------------------------------------------------------
130
132 template<typename T = double> using TMatrix4x3 = TMatrix<4, 3, T>;
133
135 using Matrix4x3 CE_SCRIPT_EXPORT(name = "Matrix4x3", external = true, plain = true)
137
139 using Matrix4x3f CE_SCRIPT_EXPORT(name = "Matrix4x3", external = true, plain = true)
141
142} // namespace CeresEngine::inline Math
143
144template<glm::length_t C, glm::length_t R, typename T> struct std::hash<CeresEngine::TMatrix<C, R, T>> {
146 constexpr size_t operator()(const Type& obj) const {
147 using namespace CeresEngine;
148
149 size_t seed = 0;
150 for(glm::length_t i = 0; i < C; i++) {
151 for(glm::length_t j = 0; j < R; j++) {
152 combine(seed, obj[i][j]);
153 }
154 }
155 return seed;
156 }
157};
158
159#define REFL_DECLARE_CE_MATRIX(T) \
160 \
161 \
162 \
163 \
164 \
165 \
166 \
167 \
168
#define CE_SCRIPT_EXPORT(...)
The CE_SCRIPT_EXPORT macro marks a class or method as exportable and available in scripting environme...
Definition Macros.hpp:247
#define REFL_DECLARE_CE_MATRIX(T)
Definition Matrix.hpp:159
Definition Application.hpp:19
constexpr size_t hash(const T &v)
Generates a hash for the provided type.
Definition Hash.hpp:25
Definition Angle.hpp:20
TMatrix4< double > Matrix4
A 4x4 matrix matrix. Data is internally represented as double.
Definition Matrix.hpp:58
TMatrix4x2< float > Matrix4x2f
A 4x2 matrix matrix. Data is internally represented as float.
Definition Matrix.hpp:127
TMatrix4x2< double > Matrix4x2
A 4x2 matrix matrix. Data is internally represented as double.
Definition Matrix.hpp:123
TMatrix< 3, 4, T > TMatrix3x4
A 3x4 type that uses a internal representation of type T
Definition Matrix.hpp:106
TMatrix4x3< float > Matrix4x3f
A 4x3 matrix matrix. Data is internally represented as float.
Definition Matrix.hpp:140
TMatrix< 3, 2, T > TMatrix3x2
A 3x2 type that uses a internal representation of type T
Definition Matrix.hpp:93
TMatrix2x4< double > Matrix2x4
A 2x4 matrix matrix. Data is internally represented as double.
Definition Matrix.hpp:84
TMatrix3x2< float > Matrix3x2f
A 3x2 matrix matrix. Data is internally represented as float.
Definition Matrix.hpp:101
TMatrix2x3< float > Matrix2x3f
A 2x3 matrix matrix. Data is internally represented as float.
Definition Matrix.hpp:75
TMatrix3x4< double > Matrix3x4
A 3x4 matrix matrix. Data is internally represented as double.
Definition Matrix.hpp:110
TMatrix< 4, 2, T > TMatrix4x2
A 4x2 type that uses a internal representation of type T
Definition Matrix.hpp:119
TMatrix< 3, 3, T > TMatrix3
A 3x3 type that uses a internal representation of type T
Definition Matrix.hpp:41
TMatrix2x3< double > Matrix2x3
A 2x3 matrix matrix. Data is internally represented as double.
Definition Matrix.hpp:71
TMatrix3< double > Matrix3
A 3x3 matrix matrix. Data is internally represented as double.
Definition Matrix.hpp:45
TMatrix< 2, 2, T > TMatrix2
A 2x2 type that uses a internal representation of type T
Definition Matrix.hpp:28
TMatrix< 4, 4, T > TMatrix4
A 4x4 type that uses a internal representation of type T
Definition Matrix.hpp:54
TMatrix2x4< float > Matrix2x4f
A 2x4 matrix matrix. Data is internally represented as float.
Definition Matrix.hpp:88
TMatrix< 2, 3, T > TMatrix2x3
A 2x3 type that uses a internal representation of type T
Definition Matrix.hpp:67
glm::mat< C, R, T, glm::highp > TMatrix
A CxR matrix that uses a internal representation of type T.
Definition Matrix.hpp:23
TMatrix2< float > Matrix2f
A 2x2 matrix matrix. Data is internally represented as float.
Definition Matrix.hpp:36
TMatrix3x2< double > Matrix3x2
A 3x2 matrix matrix. Data is internally represented as double.
Definition Matrix.hpp:97
TMatrix4x3< double > Matrix4x3
A 4x3 matrix matrix. Data is internally represented as double.
Definition Matrix.hpp:136
TMatrix< 4, 3, T > TMatrix4x3
A 4x3 type that uses a internal representation of type T
Definition Matrix.hpp:132
TMatrix< 2, 4, T > TMatrix2x4
A 2x4 type that uses a internal representation of type T
Definition Matrix.hpp:80
TMatrix3< float > Matrix3f
A 3x3 matrix matrix. Data is internally represented as float.
Definition Matrix.hpp:49
TMatrix2< double > Matrix2
A 2x2 matrix matrix. Data is internally represented as double.
Definition Matrix.hpp:32
TMatrix4< float > Matrix4f
A 4x4 matrix matrix. Data is internally represented as float.
Definition Matrix.hpp:62
TMatrix3x4< float > Matrix3x4f
A 3x4 matrix matrix. Data is internally represented as float.
Definition Matrix.hpp:114