diff --git a/source/blender/blenkernel/intern/armature_deform.c b/source/blender/blenkernel/intern/armature_deform.c index ad6cb43b4a2..feeb8c58c63 100644 --- a/source/blender/blenkernel/intern/armature_deform.c +++ b/source/blender/blenkernel/intern/armature_deform.c @@ -63,23 +63,22 @@ static void pchan_deform_accumulate(const DualQuat *deform_dq, if (dq_accum) { BLI_assert(!co_accum); - /* FIX https://projects.blender.org/blender/blender/issues/32022 */ - DualQuat mdq; if (deform_dq->scale_weight) { + /* FIX https://projects.blender.org/blender/blender/issues/32022 */ + DualQuat mdq = *deform_dq; float dst[3]; - memcpy(&mdq, deform_dq, sizeof(DualQuat)); mul_v3_m4v3(dst, mdq.scale, co_in); sub_v3_v3(dst, co_in); - float w = mdq.quat[0], x = mdq.quat[1], y = mdq.quat[2], z = mdq.quat[3]; - mdq.trans[0] -= .5f * (x * dst[0] + y * dst[1] + z * dst[2]); - mdq.trans[1] += .5f * (w * dst[0] + y * dst[2] - z * dst[1]); - mdq.trans[2] += .5f * (w * dst[1] + z * dst[0] - x * dst[2]); - mdq.trans[3] += .5f * (w * dst[2] + x * dst[1] - y * dst[0]); + mdq.trans[0] -= .5f * (mdq.quat[1] * dst[0] + mdq.quat[2] * dst[1] + mdq.quat[3] * dst[2]); + mdq.trans[1] += .5f * (mdq.quat[0] * dst[0] + mdq.quat[2] * dst[2] - mdq.quat[3] * dst[1]); + mdq.trans[2] += .5f * (mdq.quat[0] * dst[1] + mdq.quat[3] * dst[0] - mdq.quat[1] * dst[2]); + mdq.trans[3] += .5f * (mdq.quat[0] * dst[2] + mdq.quat[1] * dst[1] - mdq.quat[2] * dst[0]); mdq.scale_weight = 0.f; - deform_dq = &mdq; + add_weighted_dq_dq(dq_accum, &mdq, weight); + } + else { + add_weighted_dq_dq(dq_accum, deform_dq, weight); } - - add_weighted_dq_dq(dq_accum, deform_dq, weight); } else { float tmp[3];