From 7d6c12218f2de531cc6a753146fa164ce1da7839 Mon Sep 17 00:00:00 2001 From: Ivan Avdeev Date: Mon, 15 May 2023 09:35:19 -0700 Subject: [PATCH] vk: comment on why we need inverse model matrix --- ref/vk/vk_studio.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ref/vk/vk_studio.c b/ref/vk/vk_studio.c index 3a3f4764..aa2c3b37 100644 --- a/ref/vk/vk_studio.c +++ b/ref/vk/vk_studio.c @@ -2165,6 +2165,8 @@ static void R_StudioDrawPoints( void ) pskinref = (short *)((byte *)m_pStudioHeader + m_pStudioHeader->skinindex); if( m_skinnum != 0 ) pskinref += (m_skinnum * m_pStudioHeader->numskinref); + // Compute inverse entity matrix, as we need vertices to be in local model space instead of global world space. + // Ideally, we'd just avoid multiplying vertices by entity matrix in R_StudioMergeBones and friends. But unfortunately games themselves seem to be premultiplying bone matrices by entity matrix, so we need to manually undo this multiplication here. matrix4x4 rotationmatrix = {0}, rotationmatrix_inv = {0}; Matrix3x4_Copy(rotationmatrix, g_studio.rotationmatrix); Matrix4x4_Invert_Simple(rotationmatrix_inv, rotationmatrix);