Common: Move Matrix classes out of MathUtil into their own files and make their interface more friendly.

This commit is contained in:
Jordan Woyak
2019-01-29 16:05:51 -06:00
parent 3b4486bad3
commit b9a00a40a9
8 changed files with 272 additions and 193 deletions

View File

@ -5,8 +5,6 @@
#pragma once
#include <algorithm>
#include <array>
#include <cstdlib>
#include <vector>
#include "Common/CommonTypes.h"
@ -113,38 +111,3 @@ inline int IntLog2(u64 val)
return result;
#endif
}
// Tiny matrix/vector library.
// Used for things like Free-Look in the gfx backend.
class Matrix33
{
public:
static void LoadIdentity(Matrix33& mtx);
// set mtx to be a rotation matrix around the x axis
static void RotateX(Matrix33& mtx, float rad);
// set mtx to be a rotation matrix around the y axis
static void RotateY(Matrix33& mtx, float rad);
// set result = a x b
static void Multiply(const Matrix33& a, const Matrix33& b, Matrix33& result);
static void Multiply(const Matrix33& a, const float vec[3], float result[3]);
float data[9];
};
class Matrix44
{
public:
static void LoadIdentity(Matrix44& mtx);
static void LoadMatrix33(Matrix44& mtx, const Matrix33& m33);
static void Set(Matrix44& mtx, const float mtxArray[16]);
static void Translate(Matrix44& mtx, const float vec[3]);
static void Shear(Matrix44& mtx, const float a, const float b = 0);
static void Multiply(const Matrix44& a, const Matrix44& b, Matrix44& result);
float data[16];
};