Fix T78045: CTL-ALT-S does nothing in pose mode and crashes when called from the menu
This commit is contained in:
@@ -1819,6 +1819,8 @@ bool initTransform(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve
|
||||
int options = 0;
|
||||
PropertyRNA *prop;
|
||||
|
||||
mode = transform_mode_really_used(C, mode);
|
||||
|
||||
t->context = C;
|
||||
|
||||
/* added initialize, for external calls to set stuff in TransInfo, like undo string */
|
||||
|
||||
@@ -1294,19 +1294,6 @@ void createTransData(bContext *C, TransInfo *t)
|
||||
}
|
||||
}
|
||||
|
||||
/* exception... hackish, we want bonesize to use bone orientation matrix (ton) */
|
||||
if (t->mode == TFM_BONESIZE) {
|
||||
t->flag &= ~(T_EDIT | T_POINTS);
|
||||
t->flag |= T_POSE;
|
||||
t->obedit_type = -1;
|
||||
t->data_type = TC_NONE;
|
||||
|
||||
FOREACH_TRANS_DATA_CONTAINER (t, tc) {
|
||||
tc->poseobj = tc->obedit;
|
||||
tc->obedit = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
BLI_assert((!(t->flag & T_EDIT)) == (!(t->obedit_type != -1)));
|
||||
}
|
||||
|
||||
|
||||
@@ -667,20 +667,16 @@ static void add_pose_transdata(
|
||||
mul_m3_m3m3(td->axismtx, omat, pmat);
|
||||
normalize_m3(td->axismtx);
|
||||
|
||||
if (ELEM(t->mode, TFM_BONESIZE, TFM_BONE_ENVELOPE_DIST)) {
|
||||
bArmature *arm = tc->poseobj->data;
|
||||
|
||||
if ((t->mode == TFM_BONE_ENVELOPE_DIST) || (arm->drawtype == ARM_ENVELOPE)) {
|
||||
td->loc = NULL;
|
||||
td->val = &bone->dist;
|
||||
td->ival = bone->dist;
|
||||
}
|
||||
else {
|
||||
// abusive storage of scale in the loc pointer :)
|
||||
td->loc = &bone->xwidth;
|
||||
copy_v3_v3(td->iloc, td->loc);
|
||||
td->val = NULL;
|
||||
}
|
||||
if (t->mode == TFM_BONE_ENVELOPE_DIST) {
|
||||
td->loc = NULL;
|
||||
td->val = &bone->dist;
|
||||
td->ival = bone->dist;
|
||||
}
|
||||
else if (t->mode == TFM_BONESIZE) {
|
||||
// abusive storage of scale in the loc pointer :)
|
||||
td->loc = &bone->xwidth;
|
||||
copy_v3_v3(td->iloc, td->loc);
|
||||
td->val = NULL;
|
||||
}
|
||||
|
||||
/* in this case we can do target-less IK grabbing */
|
||||
@@ -988,7 +984,7 @@ void createTransArmatureVerts(TransInfo *t)
|
||||
}
|
||||
else if (ELEM(t->mode, TFM_BONESIZE, TFM_BONE_ENVELOPE_DIST)) {
|
||||
if (ebo->flag & BONE_SELECTED) {
|
||||
if ((t->mode == TFM_BONE_ENVELOPE_DIST) || (arm->drawtype == ARM_ENVELOPE)) {
|
||||
if (t->mode == TFM_BONE_ENVELOPE_DIST) {
|
||||
td->loc = NULL;
|
||||
td->val = &ebo->dist;
|
||||
td->ival = ebo->dist;
|
||||
|
||||
@@ -50,6 +50,23 @@
|
||||
/* Own include. */
|
||||
#include "transform_mode.h"
|
||||
|
||||
int transform_mode_really_used(bContext *C, int mode)
|
||||
{
|
||||
if (mode == TFM_BONESIZE) {
|
||||
Object *ob = CTX_data_active_object(C);
|
||||
BLI_assert(ob);
|
||||
if (ob->type != OB_ARMATURE) {
|
||||
return TFM_RESIZE;
|
||||
}
|
||||
bArmature *arm = ob->data;
|
||||
if (arm->drawtype == ARM_ENVELOPE) {
|
||||
return TFM_BONE_ENVELOPE_DIST;
|
||||
}
|
||||
}
|
||||
|
||||
return mode;
|
||||
}
|
||||
|
||||
bool transdata_check_local_center(TransInfo *t, short around)
|
||||
{
|
||||
return ((around == V3D_AROUND_LOCAL_ORIGINS) &&
|
||||
@@ -1174,25 +1191,12 @@ void transform_mode_init(TransInfo *t, wmOperator *op, const int mode)
|
||||
case TFM_CREASE:
|
||||
initCrease(t);
|
||||
break;
|
||||
case TFM_BONESIZE: { /* used for both B-Bone width (bonesize) as for deform-dist (envelope) */
|
||||
/* Note: we have to pick one, use the active object. */
|
||||
TransDataContainer *tc = TRANS_DATA_CONTAINER_FIRST_OK(t);
|
||||
bArmature *arm = tc->poseobj->data;
|
||||
if (arm->drawtype == ARM_ENVELOPE) {
|
||||
initBoneEnvelope(t);
|
||||
t->mode = TFM_BONE_ENVELOPE_DIST;
|
||||
}
|
||||
else {
|
||||
initBoneSize(t);
|
||||
}
|
||||
case TFM_BONESIZE:
|
||||
initBoneSize(t);
|
||||
break;
|
||||
}
|
||||
case TFM_BONE_ENVELOPE:
|
||||
initBoneEnvelope(t);
|
||||
break;
|
||||
case TFM_BONE_ENVELOPE_DIST:
|
||||
initBoneEnvelope(t);
|
||||
t->mode = TFM_BONE_ENVELOPE_DIST;
|
||||
break;
|
||||
case TFM_EDGE_SLIDE:
|
||||
case TFM_VERT_SLIDE: {
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#define __TRANSFORM_MODE_H__
|
||||
|
||||
struct AnimData;
|
||||
struct bContext;
|
||||
struct LinkNode;
|
||||
struct TransData;
|
||||
struct TransDataContainer;
|
||||
@@ -40,6 +41,7 @@ typedef struct TransDataGenericSlideVert {
|
||||
} TransDataGenericSlideVert;
|
||||
|
||||
/* transform_mode.c */
|
||||
int transform_mode_really_used(struct bContext *C, int mode);
|
||||
bool transdata_check_local_center(TransInfo *t, short around);
|
||||
bool transform_mode_is_changeable(const int mode);
|
||||
void protectedTransBits(short protectflag, float vec[3]);
|
||||
|
||||
@@ -132,6 +132,11 @@ static void applyBoneSize(TransInfo *t, const int UNUSED(mval[2]))
|
||||
|
||||
if (t->con.applySize) {
|
||||
t->con.applySize(t, NULL, NULL, mat);
|
||||
for (i = 0; i < 3; i++) {
|
||||
if (!(t->con.mode & (CON_AXIS0 << i))) {
|
||||
t->values_final[i] = 1.0f;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
copy_m3_m3(t->mat, mat); // used in gizmo
|
||||
|
||||
@@ -96,7 +96,6 @@ static void applyBoneEnvelope(TransInfo *t, const int UNUSED(mval[2]))
|
||||
|
||||
void initBoneEnvelope(TransInfo *t)
|
||||
{
|
||||
t->mode = TFM_BONE_ENVELOPE;
|
||||
t->transform = applyBoneEnvelope;
|
||||
|
||||
initMouseInputMode(t, &t->mouse, INPUT_SPRING);
|
||||
|
||||
@@ -1049,11 +1049,11 @@ static void TRANSFORM_OT_bbone_resize(struct wmOperatorType *ot)
|
||||
ot->exec = transform_exec;
|
||||
ot->modal = transform_modal;
|
||||
ot->cancel = transform_cancel;
|
||||
ot->poll = ED_operator_editarmature;
|
||||
ot->poll = ED_operator_object_active;
|
||||
ot->poll_property = transform_poll_property;
|
||||
|
||||
RNA_def_float_translation(
|
||||
ot->srna, "value", 2, VecOne, -FLT_MAX, FLT_MAX, "Display Size", "", -FLT_MAX, FLT_MAX);
|
||||
ot->srna, "value", 3, VecOne, -FLT_MAX, FLT_MAX, "Display Size", "", -FLT_MAX, FLT_MAX);
|
||||
|
||||
WM_operatortype_props_advanced_begin(ot);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user