svn merge ^/trunk/blender -r43751:43819, need to look into changes made to editmesh_l...
[blender-staging.git] / source / blender / blenkernel / intern / constraint.c
index e207334bd4528cab4490b63d5115839b57a8534e..efeacabdba9be320fcef934be0135a4231b5f6a3 100644 (file)
@@ -303,6 +303,12 @@ void constraint_mat_convertspace (Object *ob, bPoseChannel *pchan, float mat[][4
                                                
                                                copy_m4_m4(tempmat, mat);
                                                mult_m4_m4m4(mat, imat, tempmat);
+
+                                               /* override with local location */
+                                               if ((pchan->parent) && (pchan->bone->flag & BONE_NO_LOCAL_LOCATION)) {
+                                                       armature_mat_pose_to_bone_ex(ob, pchan, pchan->pose_mat, tempmat);
+                                                       copy_v3_v3(mat[3], tempmat[3]);
+                                               }
                                        }
                                }
                                /* pose to local with parent */
@@ -508,13 +514,17 @@ static void contarget_get_mesh_mat (Object *ob, const char *substring, float mat
                        normalize_v3(normal);
                        copy_v3_v3(plane, tmat[1]);
                        
-                       copy_v3_v3(tmat[2], normal);
-                       cross_v3_v3v3(tmat[0], normal, plane);
-                       cross_v3_v3v3(tmat[1], tmat[2], tmat[0]);
-                       
-                       copy_m4_m3(mat, tmat);
+                       cross_v3_v3v3(mat[0], normal, plane);
+                       if(len_v3(mat[0]) < 1e-3) {
+                               copy_v3_v3(plane, tmat[0]);
+                               cross_v3_v3v3(mat[0], normal, plane);
+                       }
+
+                       copy_v3_v3(mat[2], normal);
+                       cross_v3_v3v3(mat[1], mat[2], mat[0]);
+
                        normalize_m4(mat);
-                       
+
                        
                        /* apply the average coordinate as the new location */
                        mul_v3_m4v3(mat[3], ob->obmat, vec);