]> git.rm.cloudns.org Git - xonotic/darkplaces.git/commitdiff
skel_build: fix wrong 4th matrix row of skeleton matrices
authordivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Wed, 23 Jan 2013 12:52:13 +0000 (12:52 +0000)
committerdivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Wed, 23 Jan 2013 12:52:13 +0000 (12:52 +0000)
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
svvm_cmds.c

index c7b24a4a9dc9bd5b924581473eff9f3d8524d7d8..ce253af6852530d0ea50b96248585e60abd80af1 100644 (file)
@@ -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;
 }
index 1c5c00a61708955d31ab2dc5e68a4beda44be61e..de270a2aae2ba329d2d95834c4464d0f7644875b 100644 (file)
@@ -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;
 }