cache transpose

This commit is contained in:
2023-06-06 12:45:34 +02:00
parent ccdcdac7c6
commit 83ab8c70f0

View File

@@ -106,7 +106,7 @@ void Renderer::SetCamPos(const Vec3f& newPos) {
m_Camera.CamPos = newPos; m_Camera.CamPos = newPos;
m_Camera.viewMatrix = maths::Look(m_Camera.CamPos, front, { 0, 1, 0 }); m_Camera.viewMatrix = maths::Look(m_Camera.CamPos, front, { 0, 1, 0 });
m_Camera.InvViewMatrix = maths::Inverse(m_Camera.viewMatrix); m_Camera.InvViewMatrix = maths::Transpose(maths::Inverse(m_Camera.viewMatrix)); // why transpose ? I don't know
m_WorldShader->Start(); m_WorldShader->Start();
m_WorldShader->SetViewMatrix(m_Camera.viewMatrix); m_WorldShader->SetViewMatrix(m_Camera.viewMatrix);
@@ -125,7 +125,7 @@ Vec2f Renderer::GetCursorWorldPos(const Vec2f& cursorPos, float windowWidth, flo
rayEye = { rayEye.x, rayEye.y, -1.0f, 0.0f }; rayEye = { rayEye.x, rayEye.y, -1.0f, 0.0f };
Vec4f rayWorld = maths::Dot(maths::Transpose(m_Camera.InvViewMatrix), rayEye); // why transpose ? I don't know Vec4f rayWorld = maths::Dot(m_Camera.InvViewMatrix, rayEye);
float lambda = -m_Camera.CamPos.y / rayWorld.y; float lambda = -m_Camera.CamPos.y / rayWorld.y;