minor rewrite
This commit is contained in:
parent
8639deac1e
commit
20ecd2ab9d
8 changed files with 173 additions and 279 deletions
|
|
@ -19,9 +19,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|||
|
||||
export module Crafter.Math:MatrixRowMajor;
|
||||
|
||||
import :BasicTypes;
|
||||
import :Basic;
|
||||
import :Vector;
|
||||
import :Misc;
|
||||
import std;
|
||||
|
||||
namespace Crafter {
|
||||
|
|
@ -142,46 +141,6 @@ namespace Crafter {
|
|||
return result;
|
||||
}
|
||||
|
||||
static MatrixRowMajor<T, CollumSize, RowSize, Repeats> Perspective(float fovAngleY, float aspectRatio, float nearZ, float farZ) requires(CollumSize == 4 && RowSize == 4 && Repeats == 1 && std::same_as<T, float>) {
|
||||
MatrixRowMajor<T, CollumSize, RowSize, Repeats> M;
|
||||
float SinFov;
|
||||
float CosFov;
|
||||
XMScalarSinCos(&SinFov, &CosFov, 0.5f * fovAngleY);
|
||||
|
||||
float Height = CosFov / SinFov;
|
||||
float Width = Height / aspectRatio;
|
||||
float fRange = farZ / (nearZ - farZ);
|
||||
|
||||
M.m[0][0] = Width;
|
||||
M.m[0][1] = 0.0f;
|
||||
M.m[0][2] = 0.0f;
|
||||
M.m[0][3] = 0.0f;
|
||||
|
||||
M.m[1][0] = 0.0f;
|
||||
M.m[1][1] = Height;
|
||||
M.m[1][2] = 0.0f;
|
||||
M.m[1][3] = 0.0f;
|
||||
|
||||
M.m[2][0] = 0.0f;
|
||||
M.m[2][1] = 0.0f;
|
||||
M.m[2][2] = fRange;
|
||||
M.m[2][3] = -1.0f;
|
||||
|
||||
M.m[3][0] = 0.0f;
|
||||
M.m[3][1] = 0.0f;
|
||||
M.m[3][2] = fRange * nearZ;
|
||||
M.m[3][3] = 0.0f;
|
||||
return M;
|
||||
}
|
||||
|
||||
static MatrixRowMajor<T, CollumSize, RowSize, Repeats> Identity() requires(CollumSize == 4 && RowSize == 4 && Repeats == 1 && std::same_as<T, float>) {
|
||||
return MatrixRowMajor<T, CollumSize, RowSize, Repeats>(
|
||||
1, 0, 0, 0,
|
||||
0, 1, 0, 0,
|
||||
0, 0, 1, 0,
|
||||
0, 0, 0, 1
|
||||
);
|
||||
}
|
||||
static MatrixRowMajor<T, CollumSize, RowSize, Repeats> Identity() requires(CollumSize == 4 && RowSize == 3 && Repeats == 1 && std::same_as<T, float>) {
|
||||
return MatrixRowMajor<T, CollumSize, RowSize, Repeats>(
|
||||
1, 0, 0, 0,
|
||||
|
|
@ -189,8 +148,7 @@ namespace Crafter {
|
|||
0, 0, 1, 0
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static MatrixRowMajor<T, CollumSize, RowSize, Repeats> Scaling(float x, float y, float z) requires(CollumSize == 4 && RowSize == 4 && Repeats == 1 && std::same_as<T, float>) {
|
||||
return MatrixRowMajor<T, CollumSize, RowSize, Repeats>(
|
||||
x, 0, 0, 0,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue