IK Solver:
authorBrecht Van Lommel <brechtvanlommel@pandora.be>
Sat, 24 Nov 2012 00:18:34 +0000 (00:18 +0000)
committerBrecht Van Lommel <brechtvanlommel@pandora.be>
Sat, 24 Nov 2012 00:18:34 +0000 (00:18 +0000)
* Rename Legacy to Standard, it's not being deprecated as far as I know.
* Make option to toggle off Location solving work with Standard.
* Make it converge a bit better in some cases by enforcing a minimum number of
  iterations before giving up.
* Move IK solver choice out of bone panel, it's an armature level setting and
  should be set there.

intern/iksolver/intern/IK_QJacobianSolver.cpp
release/scripts/startup/bl_ui/properties_data_armature.py
release/scripts/startup/bl_ui/properties_data_bone.py
release/scripts/startup/bl_ui/properties_object_constraint.py
source/blender/blenkernel/intern/action.c
source/blender/ikplugin/intern/iksolver_plugin.c
source/blender/makesdna/DNA_action_types.h
source/blender/makesrna/intern/rna_constraint.c
source/blender/makesrna/intern/rna_pose.c

index 43d177d06511422734c8f8aca10f2b0393b877c9..75f51f566c922c614cc40c49b29de35c96099417 100644 (file)
@@ -377,7 +377,7 @@ bool IK_QJacobianSolver::Solve(
                        norm = maxnorm;
 
                // check for convergence
-               if (norm < 1e-3) {
+               if (norm < 1e-3 && iterations > 10) {
                        solved = true;
                        break;
                }
index 50c34be141404cdcff15f7b44ce81344fd538b9b..845beb0f86232f950fa68014a9fde9b5ac413afd 100644 (file)
@@ -239,7 +239,7 @@ class DATA_PT_ghost(ArmatureButtonsPanel, Panel):
 
 
 class DATA_PT_iksolver_itasc(ArmatureButtonsPanel, Panel):
-    bl_label = "iTaSC parameters"
+    bl_label = "Inverse Kinematics"
     bl_options = {'DEFAULT_CLOSED'}
 
     @classmethod
index 1441c642d513b59e3e4ea412af914060c996e9af..fdaee6b7cdeb77c1ab77b0e50ce1dd2c6fd81047 100644 (file)
@@ -244,7 +244,6 @@ class BONE_PT_inverse_kinematics(BoneButtonsPanel, Panel):
         pchan = ob.pose.bones[bone.name]
 
         row = layout.row()
-        row.prop(ob.pose, "ik_solver")
 
         active = pchan.is_in_ik_chain
 
index 3fa63bac13c6bf52343294114343dff9d0528d74..eb0929895f87c59572f35b757dbb2d71a6d406b4 100644 (file)
@@ -134,7 +134,7 @@ class ConstraintButtonsPanel():
             layout.prop(con, "ik_type")
             getattr(self, 'IK_' + con.ik_type)(context, layout, con)
         else:
-            # Legacy IK constraint
+            # Standard IK constraint
             self.target_template(layout, con)
             layout.prop(con, "pole_target")
 
@@ -151,17 +151,27 @@ class ConstraintButtonsPanel():
             col.prop(con, "iterations")
             col.prop(con, "chain_count")
 
-            col.label(text="Weight:")
-            col.prop(con, "weight", text="Position", slider=True)
-            sub = col.column()
-            sub.active = con.use_rotation
-            sub.prop(con, "orient_weight", text="Rotation", slider=True)
-
             col = split.column()
             col.prop(con, "use_tail")
             col.prop(con, "use_stretch")
-            col.separator()
-            col.prop(con, "use_rotation")
+
+            layout.label(text="Weight:")
+
+            split = layout.split()
+            col = split.column()
+            row = col.row(align=True)
+            row.prop(con, "use_location", text="")
+            sub = row.row()
+            sub.active = con.use_location
+            sub.prop(con, "weight", text="Position", slider=True)
+
+            col = split.column()
+            row = col.row(align=True)
+            row.prop(con, "use_rotation", text="")
+            sub = row.row()
+            sub.active = con.use_rotation
+            sub.prop(con, "orient_weight", text="Rotation", slider=True)
+
 
     def IK_COPY_POSE(self, context, layout, con):
         self.target_template(layout, con)
index e95451252d0c0ad22aa69aa5540a434c9decf596..dd27cc70ba37f48388f98b35991b907506928a23 100644 (file)
@@ -512,7 +512,7 @@ const char *BKE_pose_ikparam_get_name(bPose *pose)
 {
        if (pose) {
                switch (pose->iksolver) {
-                       case IKSOLVER_LEGACY:
+                       case IKSOLVER_STANDARD:
                                return NULL;
                        case IKSOLVER_ITASC:
                                return "bItasc";
@@ -587,7 +587,7 @@ void BKE_pose_ikparam_init(bPose *pose)
                        BKE_pose_itasc_init(itasc);
                        pose->ikparam = itasc;
                        break;
-               case IKSOLVER_LEGACY:
+               case IKSOLVER_STANDARD:
                default:
                        pose->ikparam = NULL;
                        break;
index af15333ece57b39f22eed935db6e9493a23d74cb..ca81f4c915a252d4f9434f0b343a31646bec6b98 100644 (file)
@@ -379,6 +379,7 @@ static void execute_posetree(struct Scene *scene, Object *ob, PoseTree *tree)
 
                copy_v3_v3(goalpos, goal[3]);
                copy_m3_m4(goalrot, goal);
+               normalize_m3(goalrot);
 
                /* same for pole vector target */
                if (data->poletar) {
@@ -433,7 +434,7 @@ static void execute_posetree(struct Scene *scene, Object *ob, PoseTree *tree)
 
                iktarget = iktree[target->tip];
 
-               if (data->weight != 0.0f) {
+               if ((data->flag & CONSTRAINT_IK_POS) && data->weight != 0.0f) {
                        if (poleconstrain)
                                IK_SolverSetPoleVectorConstraint(solver, iktarget, goalpos,
                                                                 polepos, data->poleangle, (poleangledata == data));
index d8d1ad784510faee60c00d15cbde4ea3e5f0a066..f227af78dabfa444423a227436d36c87f2f10ba2 100644 (file)
@@ -372,7 +372,7 @@ typedef enum ePose_Flags {
 
 /* bPose->iksolver and bPose->ikparam->iksolver */
 typedef enum ePose_IKSolverType {
-       IKSOLVER_LEGACY = 0,
+       IKSOLVER_STANDARD = 0,
        IKSOLVER_ITASC = 1
 } ePose_IKSolverType;
 
index 7b6b629ca82f47c76208e16da4ce4f7f333dc41d..30a9bfd81f66ec18ae5ee8d51ad6e4d9f3ed5aa0 100644 (file)
@@ -614,7 +614,7 @@ static void rna_def_constraint_kinematic(BlenderRNA *brna)
        RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_dependency_update");
 
        prop = RNA_def_property(srna, "iterations", PROP_INT, PROP_NONE);
-       RNA_def_property_range(prop, 1, 10000);
+       RNA_def_property_range(prop, 0, 10000);
        RNA_def_property_ui_text(prop, "Iterations", "Maximum number of solving iterations");
        RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_update");
 
index 412aad20a415ff82b037c389a4692b6373ed9ff6..5c90fb8787c167a37302950ffe3fc4b617edc1ef 100644 (file)
@@ -675,7 +675,7 @@ static void rna_def_bone_group(BlenderRNA *brna)
 }
 
 static EnumPropertyItem prop_iksolver_items[] = {
-       {IKSOLVER_LEGACY, "LEGACY", 0, "Legacy", "Original IK solver"},
+       {IKSOLVER_STANDARD, "LEGACY", 0, "Standard", "Original IK solver"},
        {IKSOLVER_ITASC, "ITASC", 0, "iTaSC", "Multi constraint, stateful IK solver"},
        {0, NULL, 0, NULL, NULL}
 };
@@ -1126,7 +1126,7 @@ static void rna_def_pose_itasc(BlenderRNA *brna)
 
        prop = RNA_def_property(srna, "iterations", PROP_INT, PROP_NONE);
        RNA_def_property_int_sdna(prop, NULL, "numiter");
-       RNA_def_property_range(prop, 1.f, 1000.f);
+       RNA_def_property_range(prop, 0, 1000);
        RNA_def_property_ui_text(prop, "Iterations",
                                 "Maximum number of iterations for convergence in case of reiteration");
        RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Itasc_update");
@@ -1221,8 +1221,7 @@ static void rna_def_pose_ikparam(BlenderRNA *brna)
        RNA_def_property_enum_sdna(prop, NULL, "iksolver");
        RNA_def_property_clear_flag(prop, PROP_EDITABLE);
        RNA_def_property_enum_items(prop, prop_iksolver_items);
-       RNA_def_property_ui_text(prop, "IK Solver",
-                                "IK solver for which these parameters are defined, 0 for Legacy, 1 for iTaSC");
+       RNA_def_property_ui_text(prop, "IK Solver", "IK solver for which these parameters are defined");
 }
 
 /* pose.bone_groups */
@@ -1285,8 +1284,7 @@ static void rna_def_pose(BlenderRNA *brna)
        RNA_def_property_enum_sdna(prop, NULL, "iksolver");
        RNA_def_property_enum_funcs(prop, NULL, "rna_Pose_ik_solver_set", NULL);
        RNA_def_property_enum_items(prop, prop_iksolver_items);
-       RNA_def_property_ui_text(prop, "IK Solver",
-                                "Selection of IK solver for IK chain, current choice is 0 for Legacy, 1 for iTaSC");
+       RNA_def_property_ui_text(prop, "IK Solver", "Selection of IK solver for IK chain");
        RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Pose_ik_solver_update");
 
        prop = RNA_def_property(srna, "ik_param", PROP_POINTER, PROP_NONE);