diff options
author | Jelle Raaijmakers <jelle@gmta.nl> | 2022-03-23 14:07:27 +0100 |
---|---|---|
committer | Brian Gianforcaro <b.gianfo@gmail.com> | 2022-03-27 09:19:43 -0700 |
commit | 8a3242cb83a0031cba8556e2d21cc8230088b432 (patch) | |
tree | 67a1ccd07506a81671c4a72d3f8e0c2b834b97a2 /Userland/Libraries/LibGfx/Matrix.h | |
parent | 74de8e4224e1e883dac71c399b86bfd499f811c8 (diff) | |
download | serenity-8a3242cb83a0031cba8556e2d21cc8230088b432.zip |
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.
Diffstat (limited to 'Userland/Libraries/LibGfx/Matrix.h')
-rw-r--r-- | Userland/Libraries/LibGfx/Matrix.h | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/Userland/Libraries/LibGfx/Matrix.h b/Userland/Libraries/LibGfx/Matrix.h index 2e251de293..78be55f48f 100644 --- a/Userland/Libraries/LibGfx/Matrix.h +++ b/Userland/Libraries/LibGfx/Matrix.h @@ -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]; }; |