From b2666dc39e7b02a89aed0db6fab5dd9044eb0c24 Mon Sep 17 00:00:00 2001 From: Brett Date: Tue, 28 Feb 2023 23:43:56 -0500 Subject: [PATCH] fix transpose --- include/blt/math/matrix.h | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/include/blt/math/matrix.h b/include/blt/math/matrix.h index f1662af..0c935a1 100644 --- a/include/blt/math/matrix.h +++ b/include/blt/math/matrix.h @@ -268,14 +268,11 @@ namespace blt { float oneOverNearMFar = 1.0f / (near - far); float halfTan = tanf(fov * 0.5f * (float)M_PI / 180.0f); - // this should be all it takes to create a mostly correct projection matrix - // the values are transposed because my matrix implementation is terrible. - // TODO: redo matrix implementation perspectiveMat4x4.m00(float(1.0 / (aspect_ratio * halfTan))); perspectiveMat4x4.m11(float(1.0 / halfTan)); perspectiveMat4x4.m22(float(-((far + near) / (far - near)))); - perspectiveMat4x4.m23(-1); - perspectiveMat4x4.m32(float(-((2 * near * far) / (far - near)))); + perspectiveMat4x4.m32(-1); + perspectiveMat4x4.m23(float(-((2 * near * far) / (far - near)))); return perspectiveMat4x4; } @@ -287,9 +284,9 @@ namespace blt { perspectiveMat4x4.m11(2/(top-bottom)); perspectiveMat4x4.m22(2/(far-near)); perspectiveMat4x4.m33(1); - perspectiveMat4x4.m30(-(right + left) / (right - left)); - perspectiveMat4x4.m31(-(top + bottom) / (top - bottom)); - perspectiveMat4x4.m32(-(far + near) / (far - near)); + perspectiveMat4x4.m03(-(right + left) / (right - left)); + perspectiveMat4x4.m13(-(top + bottom) / (top - bottom)); + perspectiveMat4x4.m23(-(far + near) / (far - near)); return perspectiveMat4x4; }