Fix T55177: pose-mode manipulator placement w/ COW

This commit is contained in:
Campbell Barton 2018-05-24 15:12:40 +02:00
parent 40dfb3eed6
commit 0d768cca65
Notes: blender-bot 2023-02-14 08:10:10 +01:00
Referenced by issue #55177, Pose mode manipulators do not show up on the right orientation/location
2 changed files with 15 additions and 11 deletions

View File

@ -596,8 +596,8 @@ int ED_transform_calc_manipulator_stats(
RegionView3D *rv3d = ar->regiondata;
Base *base;
Object *ob = OBACT(view_layer);
const Object *ob_eval = NULL;
const Object *obedit_eval = NULL;
Object *ob_eval = NULL;
Object *obedit_eval = NULL;
bGPdata *gpd = CTX_data_gpencil_data(C);
const bool is_gp_edit = ((gpd) && (gpd->flag & GP_DATA_STROKE_EDITMODE));
int a, totsel = 0;
@ -629,7 +629,7 @@ int ED_transform_calc_manipulator_stats(
case V3D_MANIP_GIMBAL:
{
float mat[3][3];
if (gimbal_axis(ob, mat)) {
if (gimbal_axis(ob_eval, mat)) {
copy_m4_m3(rv3d->twmat, mat);
break;
}
@ -947,7 +947,7 @@ int ED_transform_calc_manipulator_stats(
int mode = TFM_ROTATION; // mislead counting bones... bah. We don't know the manipulator mode, could be mixed
bool ok = false;
if ((pivot_point == V3D_AROUND_ACTIVE) && (pchan = BKE_pose_channel_active(ob))) {
if ((pivot_point == V3D_AROUND_ACTIVE) && (pchan = BKE_pose_channel_active(ob_eval))) {
/* doesn't check selection or visibility intentionally */
Bone *bone = pchan->bone;
if (bone) {
@ -958,11 +958,11 @@ int ED_transform_calc_manipulator_stats(
}
}
else {
totsel = count_set_pose_transflags(&mode, 0, ob);
totsel = count_set_pose_transflags(&mode, 0, ob_eval);
if (totsel) {
/* use channels to get stats */
for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
for (pchan = ob_eval->pose->chanbase.first; pchan; pchan = pchan->next) {
Bone *bone = pchan->bone;
if (bone && (bone->flag & BONE_TRANSFORM)) {
calc_tw_center(tbounds, pchan->pose_head);
@ -1018,7 +1018,7 @@ int ED_transform_calc_manipulator_stats(
if (!TESTBASELIB(base)) {
continue;
}
const Object *base_object_eval = DEG_get_evaluated_object(depsgraph, base->object);
Object *base_object_eval = DEG_get_evaluated_object(depsgraph, base->object);
if (ob == NULL) {
ob = base->object;
ob_eval = base_object_eval;

View File

@ -56,6 +56,8 @@
#include "BKE_scene.h"
#include "BKE_workspace.h"
#include "DEG_depsgraph_query.h"
#include "BLT_translation.h"
#include "ED_armature.h"
@ -1014,12 +1016,14 @@ int getTransformOrientation_ex(const bContext *C, float normal[3], float plane[3
}
}
else if (ob && (ob->mode & OB_MODE_POSE)) {
bArmature *arm = ob->data;
const Depsgraph *depsgraph = CTX_data_depsgraph(C);
Object *ob_eval = DEG_get_evaluated_object(depsgraph, ob);
bArmature *arm = ob_eval->data;
bPoseChannel *pchan;
float imat[3][3], mat[3][3];
bool ok = false;
if (activeOnly && (pchan = BKE_pose_channel_active(ob))) {
if (activeOnly && (pchan = BKE_pose_channel_active(ob_eval))) {
add_v3_v3(normal, pchan->pose_mat[2]);
add_v3_v3(plane, pchan->pose_mat[1]);
ok = true;
@ -1030,7 +1034,7 @@ int getTransformOrientation_ex(const bContext *C, float normal[3], float plane[3
totsel = count_bone_select(arm, &arm->bonebase, true);
if (totsel) {
/* use channels to get stats */
for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
for (pchan = ob_eval->pose->chanbase.first; pchan; pchan = pchan->next) {
if (pchan->bone && pchan->bone->flag & BONE_TRANSFORM) {
add_v3_v3(normal, pchan->pose_mat[2]);
add_v3_v3(plane, pchan->pose_mat[1]);
@ -1043,7 +1047,7 @@ int getTransformOrientation_ex(const bContext *C, float normal[3], float plane[3
/* use for both active & all */
if (ok) {
/* we need the transpose of the inverse for a normal... */
copy_m3_m4(imat, ob->obmat);
copy_m3_m4(imat, ob_eval->obmat);
invert_m3_m3(mat, imat);
transpose_m3(mat);