[Bf-blender-cvs] [bdb83cc32cb] master: Fix T85471: Wrong orientation in transforming objects in weight paint mode

Germano Cavalcante noreply at git.blender.org
Wed Feb 10 16:32:54 CET 2021


Commit: bdb83cc32cbd0997752420ef95c791f66dca54c8
Author: Germano Cavalcante
Date:   Wed Feb 10 12:27:01 2021 -0300
Branches: master
https://developer.blender.org/rBbdb83cc32cbd0997752420ef95c791f66dca54c8

Fix T85471: Wrong orientation in transforming objects in weight paint mode

The local orientation chosen was that of the active object, but as
confirmed in other parts of the code, the orientation of the selected
Bone has priority.

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

M	source/blender/editors/transform/transform.h
M	source/blender/editors/transform/transform_convert.c
M	source/blender/editors/transform/transform_generics.c
M	source/blender/editors/transform/transform_orientations.c

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

diff --git a/source/blender/editors/transform/transform.h b/source/blender/editors/transform/transform.h
index be04feb17c8..02a7f41b384 100644
--- a/source/blender/editors/transform/transform.h
+++ b/source/blender/editors/transform/transform.h
@@ -776,6 +776,8 @@ void calculatePropRatio(TransInfo *t);
 
 void transform_data_ext_rotate(TransData *td, float mat[3][3], bool use_drot);
 
+struct Object *transform_object_deform_pose_armature_get(TransInfo *t, struct Object *ob);
+
 void freeCustomNormalArray(TransInfo *t, TransDataContainer *tc, TransCustomData *custom_data);
 
 /* TODO. transform_query.c */
diff --git a/source/blender/editors/transform/transform_convert.c b/source/blender/editors/transform/transform_convert.c
index 4f581ad962d..848aa06238e 100644
--- a/source/blender/editors/transform/transform_convert.c
+++ b/source/blender/editors/transform/transform_convert.c
@@ -1103,21 +1103,13 @@ void createTransData(bContext *C, TransInfo *t)
     convert_type = TC_POSE;
   }
   else if (ob && (ob->mode & OB_MODE_ALL_WEIGHT_PAINT) && !(t->options & CTX_PAINT_CURVE)) {
-    /* Important that ob_armature can be set even when its not selected T23412.
-     * Lines below just check is also visible. */
-    Object *ob_armature = BKE_modifiers_is_deformed_by_armature(ob);
-    if (ob_armature && ob_armature->mode & OB_MODE_POSE) {
-      Base *base_arm = BKE_view_layer_base_find(t->view_layer, ob_armature);
-      if (base_arm) {
-        View3D *v3d = t->view;
-        if (BASE_VISIBLE(v3d, base_arm)) {
-          Object *objects[1];
-          objects[0] = ob_armature;
-          uint objects_len = 1;
-          initTransDataContainers_FromObjectData(t, ob_armature, objects, objects_len);
-          convert_type = TC_POSE;
-        }
-      }
+    Object *ob_armature = transform_object_deform_pose_armature_get(t, ob);
+    if (ob_armature) {
+      Object *objects[1];
+      objects[0] = ob_armature;
+      uint objects_len = 1;
+      initTransDataContainers_FromObjectData(t, ob_armature, objects, objects_len);
+      convert_type = TC_POSE;
     }
   }
   else if (ob && (ob->mode & OB_MODE_PARTICLE_EDIT) &&
diff --git a/source/blender/editors/transform/transform_generics.c b/source/blender/editors/transform/transform_generics.c
index 16fb9cc6eab..92719933afb 100644
--- a/source/blender/editors/transform/transform_generics.c
+++ b/source/blender/editors/transform/transform_generics.c
@@ -44,6 +44,7 @@
 #include "BKE_context.h"
 #include "BKE_layer.h"
 #include "BKE_mask.h"
+#include "BKE_modifier.h"
 #include "BKE_paint.h"
 
 #include "ED_clip.h"
@@ -1454,3 +1455,23 @@ void transform_data_ext_rotate(TransData *td, float mat[3][3], bool use_drot)
     copy_v3_v3(td->ext->rot, eul);
   }
 }
+
+Object *transform_object_deform_pose_armature_get(TransInfo *t, Object *ob)
+{
+  if (!(ob->mode & OB_MODE_ALL_WEIGHT_PAINT)) {
+    return NULL;
+  }
+  /* Important that ob_armature can be set even when its not selected T23412.
+   * Lines below just check is also visible. */
+  Object *ob_armature = BKE_modifiers_is_deformed_by_armature(ob);
+  if (ob_armature && ob_armature->mode & OB_MODE_POSE) {
+    Base *base_arm = BKE_view_layer_base_find(t->view_layer, ob_armature);
+    if (base_arm) {
+      View3D *v3d = t->view;
+      if (BASE_VISIBLE(v3d, base_arm)) {
+        return ob_armature;
+      }
+    }
+  }
+  return NULL;
+}
diff --git a/source/blender/editors/transform/transform_orientations.c b/source/blender/editors/transform/transform_orientations.c
index 6d1bb9cc0de..1470d3b7059 100644
--- a/source/blender/editors/transform/transform_orientations.c
+++ b/source/blender/editors/transform/transform_orientations.c
@@ -609,6 +609,12 @@ short transform_orientation_matrix_get(
     orientation_index_custom = orientation - V3D_ORIENT_CUSTOM;
     orientation = V3D_ORIENT_CUSTOM;
   }
+  else if (ob && (ob->mode & OB_MODE_ALL_WEIGHT_PAINT) && !(t->options & CTX_PAINT_CURVE)) {
+    Object *ob_armature = transform_object_deform_pose_armature_get(t, ob);
+    if (ob_armature) {
+      ob = ob_armature;
+    }
+  }
 
   if ((t->spacetype == SPACE_VIEW3D) && t->region && (t->region->regiontype == RGN_TYPE_WINDOW)) {
     rv3d = t->region->regiondata;



More information about the Bf-blender-cvs mailing list