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.
This commit is contained in:
Germano Cavalcante 2021-02-10 12:27:01 -03:00
parent d9eeb7840f
commit bdb83cc32c
Notes: blender-bot 2023-02-14 03:44:41 +01:00
Referenced by issue #85471, Rotation pivot uses mesh object instead of pose bone while in weight paint mode
4 changed files with 36 additions and 15 deletions

View File

@ -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 */

View File

@ -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) &&

View File

@ -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;
}

View File

@ -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;