1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 21:57:35 +00:00

LibGL+LibSoftGPU+LibGfx: Reimplement normal transformation

We now support generating top-left submatrices from a `Gfx::Matrix`
and we move the normal transformation calculation into
`SoftGPU::Device`. No functional changes.
This commit is contained in:
Jelle Raaijmakers 2022-03-23 14:07:27 +01:00 committed by Brian Gianforcaro
parent 74de8e4224
commit 8a3242cb83
4 changed files with 22 additions and 14 deletions

View file

@ -13,6 +13,9 @@ namespace Gfx {
template<size_t N, typename T>
class Matrix {
template<size_t U, typename V>
friend class Matrix;
public:
static constexpr size_t Size = N;
@ -173,6 +176,17 @@ public:
return result;
}
template<size_t U>
[[nodiscard]] constexpr Matrix<U, T> submatrix_from_topleft() const requires(U > 0 && U < N)
{
Matrix<U, T> result;
for (size_t i = 0; i < U; ++i) {
for (size_t j = 0; j < U; ++j)
result.m_elements[i][j] = m_elements[i][j];
}
return result;
}
private:
T m_elements[N][N];
};