From 245ce97d12ce9f07f296e1fe67f1ec5994c21e85 Mon Sep 17 00:00:00 2001 From: himisa Date: Sat, 3 Jun 2023 19:00:07 +0200 Subject: [PATCH 1/3] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E8=87=B3=20source/blender/blenkernel/intern?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/blender/blenkernel/intern/armature_deform.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/source/blender/blenkernel/intern/armature_deform.c b/source/blender/blenkernel/intern/armature_deform.c index 647c937737d..685abb61b81 100644 --- a/source/blender/blenkernel/intern/armature_deform.c +++ b/source/blender/blenkernel/intern/armature_deform.c @@ -62,8 +62,10 @@ static void pchan_deform_accumulate(const DualQuat *deform_dq, if (dq_accum) { BLI_assert(!co_accum); - - add_weighted_dq_dq(dq_accum, deform_dq, weight); + DualQuat dq; + memcpy(&dq, deform_dq, sizeof(DualQuat)); + set_scale_pivot_dq(&dq, co_in); + add_weighted_dq_dq(dq_accum, &dq, weight); } else { float tmp[3]; -- 2.30.2 From 51351dea16e82a415b26de9f651cfd681ab60943 Mon Sep 17 00:00:00 2001 From: himisa Date: Sat, 3 Jun 2023 19:12:40 +0200 Subject: [PATCH 2/3] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E8=87=B3=20source/blender/blenkernel/intern?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../blenkernel/intern/armature_deform.c | 25 ++++++++++++++++--- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/source/blender/blenkernel/intern/armature_deform.c b/source/blender/blenkernel/intern/armature_deform.c index 685abb61b81..b57cd3f85d1 100644 --- a/source/blender/blenkernel/intern/armature_deform.c +++ b/source/blender/blenkernel/intern/armature_deform.c @@ -62,10 +62,27 @@ static void pchan_deform_accumulate(const DualQuat *deform_dq, if (dq_accum) { BLI_assert(!co_accum); - DualQuat dq; - memcpy(&dq, deform_dq, sizeof(DualQuat)); - set_scale_pivot_dq(&dq, co_in); - add_weighted_dq_dq(dq_accum, &dq, weight); + + /* FIX https://projects.blender.org/blender/blender/issues/32022 */ + DualQuat mdq; + if (deform_dq->scale_weight) { + 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]; + float dstx = mdq.scale[3][0], dsty = mdq.scale[3][1], dstz = mdq.scale[3][2]; + mdq.scale[3][0] -= dst[0]; + mdq.scale[3][1] -= dst[1]; + mdq.scale[3][2] -= dst[2]; + 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]); + deform_dq = &mdq; + } + + add_weighted_dq_dq(dq_accum, deform_dq, weight); } else { float tmp[3]; -- 2.30.2 From 14f96c67ea62047c0b747adc893d8babf85ab92b Mon Sep 17 00:00:00 2001 From: himisa Date: Sat, 3 Jun 2023 19:13:51 +0200 Subject: [PATCH 3/3] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E8=87=B3=20source/blender/blenlib/intern?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/blender/blenlib/intern/math_rotation.c | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/source/blender/blenlib/intern/math_rotation.c b/source/blender/blenlib/intern/math_rotation.c index 57f28030c81..516651fdb89 100644 --- a/source/blender/blenlib/intern/math_rotation.c +++ b/source/blender/blenlib/intern/math_rotation.c @@ -2049,22 +2049,6 @@ void add_weighted_dq_dq(DualQuat *dq_sum, const DualQuat *dq, float weight) { bool flipped = false; - /* FIX https://projects.blender.org/blender/blender/issues/32022 */ - DualQuat mdq; - if (dq->scale_weight) { - memcpy(&mdq, dq, sizeof(DualQuat)); - float w = mdq.quat[0], x = mdq.quat[1], y = mdq.quat[2], z = mdq.quat[3]; - float dstx = mdq.scale[3][0], dsty = mdq.scale[3][1], dstz = mdq.scale[3][2]; - mdq.scale[3][0] -= dstx; - mdq.scale[3][1] -= dsty; - mdq.scale[3][2] -= dstz; - mdq.trans[0] -= .5f * (x * dstx + y * dsty + z * dstz); - mdq.trans[1] += .5f * (w * dstx + y * dstz - z * dsty); - mdq.trans[2] += .5f * (w * dsty + z * dstx - x * dstz); - mdq.trans[3] += .5f * (w * dstz + x * dsty - y * dstx); - dq = &mdq; - } - /* make sure we interpolate quats in the right direction */ if (dot_qtqt(dq->quat, dq_sum->quat) < 0) { flipped = true; -- 2.30.2