[Bf-blender-cvs] [41e40793650] blender-v2.90-release: Fix T80437: Auto IK Double Generates IK constraints

Philipp Oeser noreply at git.blender.org
Mon Sep 21 09:50:37 CEST 2020


Commit: 41e40793650aa23ad525c395706eae15ec82bff9
Author: Philipp Oeser
Date:   Thu Sep 17 18:22:42 2020 +0200
Branches: blender-v2.90-release
https://developer.blender.org/rB41e40793650aa23ad525c395706eae15ec82bff9

Fix T80437: Auto IK Double Generates IK constraints

Caused by rB9a7f5f1bb422.

If using Auto IK (or targetless IK and Auto IK together), two temporary
constraints were added.
- from pose_grab_with_ik_add (even for targetless IK)
- from add_pose_transdata (even for Auto IK)

Since both both do similar things, but cannot work in tandem (with
possibly different chainlengths for example), we have to decide which
type to prefer over the other (as in: do not create a constraint for the
other).
It seems better to ignore the 'Auto IK' option on bones that will
have targetless IK set up for them specificallly [e.g. defining special
chainlength]. This way you can still work with 'Auto IK' ON generally
[with interactive chainlength control], but also have specific bones that
need their own custom chainlength.

For now, the most straightforward fix is to
- only add constraints for Auto IK from pose_grab_with_ik_add()
- only add constraints for targetless IK from add_pose_transdata()

Note: this area has some potential for later refactoring:
- move creation of all temporary constraints to a single place
[preferably pose_grab_with_ik_add]
- use only those temporary constraints in transform code [atm. we still
flip CONSTRAINT_IK_AUTO around on the "original" -- unneccesarily, after
rB9a7f5f1bb422 a dedicated temporary constraint is now always available]
- clarify CONSTRAINT_IK_AUTO vs. CONSTRAINT_IK_TEMP
- obeying standard rotation locks on bones in the chain (not just the
the IK locks) is not consistent between targetless IK and Auto IK

Potential candidate for 2.90.1 as well as 2.83 LTS

Maniphest Tasks: T80437

Differential Revision: https://developer.blender.org/D8930

===================================================================

M	source/blender/editors/transform/transform_convert_armature.c

===================================================================

diff --git a/source/blender/editors/transform/transform_convert_armature.c b/source/blender/editors/transform/transform_convert_armature.c
index 9885c8fc3a6..5cc6a62894d 100644
--- a/source/blender/editors/transform/transform_convert_armature.c
+++ b/source/blender/editors/transform/transform_convert_armature.c
@@ -349,6 +349,10 @@ static short pose_grab_with_ik_add(bPoseChannel *pchan)
               }
             }
           }
+
+          /* Return early (as in: don't actually create a temporary constraint here), since adding
+           * will take place later in add_pose_transdata() for targetless constraints. */
+          return 0;
         }
       }
 
@@ -702,10 +706,14 @@ static void add_pose_transdata(TransInfo *t, bPoseChannel *pchan, Object *ob, Tr
 
       /* Add a temporary auto IK constraint here, as we will only temporarily active this
        * targetless bone during transform. (Targetless IK constraints are treated as if they are
-       * disabled unless they are transformed). */
-      add_temporary_ik_constraint(pchan, data);
-      Main *bmain = CTX_data_main(t->context);
-      update_deg_with_temporary_ik(bmain, ob);
+       * disabled unless they are transformed).
+       * Only do this for targetless IK though, AutoIK already added a constraint in
+       * pose_grab_with_ik_add() beforehand. */
+      if ((data->flag & CONSTRAINT_IK_TEMP) == 0) {
+        add_temporary_ik_constraint(pchan, data);
+        Main *bmain = CTX_data_main(t->context);
+        update_deg_with_temporary_ik(bmain, ob);
+      }
 
       /* only object matrix correction */
       copy_m3_m3(td->mtx, omat);
@@ -1350,10 +1358,14 @@ static void pose_transform_mirror_update(TransInfo *t, TransDataContainer *tc, O
       data->flag |= CONSTRAINT_IK_AUTO;
       /* Add a temporary auto IK constraint here, as we will only temporarily active this
        * target-less bone during transform. (Target-less IK constraints are treated as if they are
-       * disabled unless they are transformed) */
-      add_temporary_ik_constraint(pchan, data);
-      Main *bmain = CTX_data_main(t->context);
-      update_deg_with_temporary_ik(bmain, ob);
+       * disabled unless they are transformed).
+       * Only do this for targetless IK though, AutoIK already added a constraint in
+       * pose_grab_with_ik_add() beforehand. */
+      if ((data->flag & CONSTRAINT_IK_TEMP) == 0) {
+        add_temporary_ik_constraint(pchan, data);
+        Main *bmain = CTX_data_main(t->context);
+        update_deg_with_temporary_ik(bmain, ob);
+      }
     }
 
     if (pid) {



More information about the Bf-blender-cvs mailing list