From 447744072b615a1940b65d1ed4c64d218a2e9eda Mon Sep 17 00:00:00 2001 From: divverent Date: Wed, 23 Jan 2013 12:52:13 +0000 Subject: [PATCH] skel_build: fix wrong 4th matrix row of skeleton matrices Matrix4x4_Scale doesn't affect the 4th row, but Matrix4x4_Accumulate does, leading to wrong result. This broke weapon to player attachment when the player has a skeletonobject. git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@11886 d7cf8633-e32d-0410-b094-e92efae38249 --- clvm_cmds.c | 5 +---- svvm_cmds.c | 5 +---- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/clvm_cmds.c b/clvm_cmds.c index c7b24a4a..ce253af6 100644 --- a/clvm_cmds.c +++ b/clvm_cmds.c @@ -3964,7 +3964,6 @@ static void VM_CL_skel_build(prvm_prog_t *prog) int firstbone = PRVM_G_FLOAT(OFS_PARM4) - 1; int lastbone = PRVM_G_FLOAT(OFS_PARM5) - 1; dp_model_t *model = CL_GetModelByIndex(modelindex); - float blendfrac; int numblends; int bonenum; int blendindex; @@ -3980,7 +3979,6 @@ static void VM_CL_skel_build(prvm_prog_t *prog) lastbone = min(lastbone, skeleton->model->num_bones - 1); VM_GenerateFrameGroupBlend(prog, framegroupblend, ed); VM_FrameBlendFromFrameGroupBlend(frameblend, framegroupblend, model, cl.time); - blendfrac = 1.0f - retainfrac; for (numblends = 0;numblends < MAX_FRAMEBLENDS && frameblend[numblends].lerp;numblends++) ; for (bonenum = firstbone;bonenum <= lastbone;bonenum++) @@ -3992,8 +3990,7 @@ static void VM_CL_skel_build(prvm_prog_t *prog) Matrix4x4_Accumulate(&bonematrix, &matrix, frameblend[blendindex].lerp); } Matrix4x4_Normalize3(&bonematrix, &bonematrix); - Matrix4x4_Scale(&skeleton->relativetransforms[bonenum], retainfrac, retainfrac); - Matrix4x4_Accumulate(&skeleton->relativetransforms[bonenum], &bonematrix, blendfrac); + Matrix4x4_Interpolate(&skeleton->relativetransforms[bonenum], &bonematrix, &skeleton->relativetransforms[bonenum], retainfrac); } PRVM_G_FLOAT(OFS_RETURN) = skeletonindex + 1; } diff --git a/svvm_cmds.c b/svvm_cmds.c index 1c5c00a6..de270a2a 100644 --- a/svvm_cmds.c +++ b/svvm_cmds.c @@ -2906,7 +2906,6 @@ static void VM_SV_skel_build(prvm_prog_t *prog) int firstbone = PRVM_G_FLOAT(OFS_PARM4) - 1; int lastbone = PRVM_G_FLOAT(OFS_PARM5) - 1; dp_model_t *model = SV_GetModelByIndex(modelindex); - float blendfrac; int numblends; int bonenum; int blendindex; @@ -2922,7 +2921,6 @@ static void VM_SV_skel_build(prvm_prog_t *prog) lastbone = min(lastbone, skeleton->model->num_bones - 1); VM_GenerateFrameGroupBlend(prog, framegroupblend, ed); VM_FrameBlendFromFrameGroupBlend(frameblend, framegroupblend, model, sv.time); - blendfrac = 1.0f - retainfrac; for (numblends = 0;numblends < MAX_FRAMEBLENDS && frameblend[numblends].lerp;numblends++) ; for (bonenum = firstbone;bonenum <= lastbone;bonenum++) @@ -2934,8 +2932,7 @@ static void VM_SV_skel_build(prvm_prog_t *prog) Matrix4x4_Accumulate(&bonematrix, &matrix, frameblend[blendindex].lerp); } Matrix4x4_Normalize3(&bonematrix, &bonematrix); - Matrix4x4_Scale(&skeleton->relativetransforms[bonenum], retainfrac, retainfrac); - Matrix4x4_Accumulate(&skeleton->relativetransforms[bonenum], &bonematrix, blendfrac); + Matrix4x4_Interpolate(&skeleton->relativetransforms[bonenum], &bonematrix, &skeleton->relativetransforms[bonenum], retainfrac); } PRVM_G_FLOAT(OFS_RETURN) = skeletonindex + 1; } -- 2.39.2