From 126cfbeb82556903dd275e7d64daab2ce23ee3ec Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 19 Mar 2025 22:12:47 +0000 Subject: [PATCH] Refactor: rename bPoseChannel::size to scale Match the name of the RNA as well as Object::scale, also rename associated flags. Ref !136151 --- source/blender/blenkernel/intern/action.cc | 8 +++---- .../blenkernel/intern/action_mirror.cc | 8 +++---- source/blender/blenkernel/intern/armature.cc | 10 ++++----- source/blender/blenkernel/intern/object.cc | 2 +- .../draw/engines/overlay/overlay_armature.cc | 2 +- source/blender/editors/armature/pose_slide.cc | 21 ++++++++++--------- .../editors/armature/pose_transform.cc | 10 ++++----- source/blender/editors/armature/pose_utils.cc | 8 +++---- .../transform/transform_convert_armature.cc | 12 +++++------ source/blender/makesdna/DNA_action_types.h | 4 ++-- .../blender/makesdna/intern/dna_rename_defs.h | 1 + source/blender/makesrna/intern/rna_pose.cc | 1 - 12 files changed, 44 insertions(+), 43 deletions(-) diff --git a/source/blender/blenkernel/intern/action.cc b/source/blender/blenkernel/intern/action.cc index 6420eb74cf7..192f16375de 100644 --- a/source/blender/blenkernel/intern/action.cc +++ b/source/blender/blenkernel/intern/action.cc @@ -1156,7 +1156,7 @@ bPoseChannel *BKE_pose_channel_ensure(bPose *pose, const char *name) /* init vars to prevent math errors */ unit_qt(chan->quat); unit_axis_angle(chan->rotAxis, &chan->rotAngle); - chan->size[0] = chan->size[1] = chan->size[2] = 1.0f; + chan->scale[0] = chan->scale[1] = chan->scale[2] = 1.0f; copy_v3_fl(chan->scale_in, 1.0f); copy_v3_fl(chan->scale_out, 1.0f); @@ -1856,7 +1856,7 @@ void BKE_pose_rest(bPose *pose, bool selected_bones_only) zero_v3(pchan->eul); unit_qt(pchan->quat); unit_axis_angle(pchan->rotAxis, &pchan->rotAngle); - pchan->size[0] = pchan->size[1] = pchan->size[2] = 1.0f; + pchan->scale[0] = pchan->scale[1] = pchan->scale[2] = 1.0f; pchan->roll1 = pchan->roll2 = 0.0f; pchan->curve_in_x = pchan->curve_in_z = 0.0f; @@ -1866,7 +1866,7 @@ void BKE_pose_rest(bPose *pose, bool selected_bones_only) copy_v3_fl(pchan->scale_in, 1.0f); copy_v3_fl(pchan->scale_out, 1.0f); - pchan->flag &= ~(POSE_LOC | POSE_ROT | POSE_SIZE | POSE_BBONE_SHAPE); + pchan->flag &= ~(POSE_LOC | POSE_ROT | POSE_SCALE | POSE_BBONE_SHAPE); } } @@ -1879,7 +1879,7 @@ void BKE_pose_copy_pchan_result(bPoseChannel *pchanto, const bPoseChannel *pchan copy_v3_v3(pchanto->loc, pchanfrom->loc); copy_qt_qt(pchanto->quat, pchanfrom->quat); copy_v3_v3(pchanto->eul, pchanfrom->eul); - copy_v3_v3(pchanto->size, pchanfrom->size); + copy_v3_v3(pchanto->scale, pchanfrom->scale); copy_v3_v3(pchanto->pose_head, pchanfrom->pose_head); copy_v3_v3(pchanto->pose_tail, pchanfrom->pose_tail); diff --git a/source/blender/blenkernel/intern/action_mirror.cc b/source/blender/blenkernel/intern/action_mirror.cc index 8d332adc260..1f35bb0e7e4 100644 --- a/source/blender/blenkernel/intern/action_mirror.cc +++ b/source/blender/blenkernel/intern/action_mirror.cc @@ -194,7 +194,7 @@ static void action_flip_pchan(Object *ob_arm, const bPoseChannel *pchan, FCurveP * work well if the rotation happened to swap X/Y alignment, leave this for now. */ struct { - FCurve_KeyCache loc[3], eul[3], quat[4], rotAxis[3], rotAngle, size[3], rotmode; + FCurve_KeyCache loc[3], eul[3], quat[4], rotAxis[3], rotAngle, scale[3], rotmode; } fkc_pchan = {{{nullptr}}}; #define FCURVE_ASSIGN_VALUE(id, path_test_suffix, index) \ @@ -211,7 +211,7 @@ static void action_flip_pchan(Object *ob_arm, const bPoseChannel *pchan, FCurveP FCURVE_ASSIGN_ARRAY(quat, ".rotation_quaternion"); FCURVE_ASSIGN_ARRAY(rotAxis, ".rotation_axis_angle"); FCURVE_ASSIGN_VALUE(rotAngle, ".rotation_axis_angle", 3); - FCURVE_ASSIGN_ARRAY(size, ".scale"); + FCURVE_ASSIGN_ARRAY(scale, ".scale"); FCURVE_ASSIGN_VALUE(rotmode, ".rotation_mode", 0); #undef FCURVE_ASSIGN_VALUE @@ -295,7 +295,7 @@ static void action_flip_pchan(Object *ob_arm, const bPoseChannel *pchan, FCurveP READ_ARRAY_FLT(quat); READ_ARRAY_FLT(rotAxis); READ_VALUE_FLT(rotAngle); - READ_ARRAY_FLT(size); + READ_ARRAY_FLT(scale); READ_VALUE_INT(rotmode); #undef READ_ARRAY_FLT @@ -361,7 +361,7 @@ static void action_flip_pchan(Object *ob_arm, const bPoseChannel *pchan, FCurveP WRITE_ARRAY_FLT(quat); WRITE_ARRAY_FLT(rotAxis); WRITE_VALUE_FLT(rotAngle); - WRITE_ARRAY_FLT(size); + WRITE_ARRAY_FLT(scale); /* No need to write back 'rotmode' as it can't be transformed. */ #undef WRITE_ARRAY_FLT diff --git a/source/blender/blenkernel/intern/armature.cc b/source/blender/blenkernel/intern/armature.cc index de61f5d956e..7e31951834d 100644 --- a/source/blender/blenkernel/intern/armature.cc +++ b/source/blender/blenkernel/intern/armature.cc @@ -2352,7 +2352,7 @@ void BKE_pchan_rot_to_mat3(const bPoseChannel *pchan, float r_mat[3][3]) void BKE_pchan_apply_mat4(bPoseChannel *pchan, const float mat[4][4], bool use_compat) { float rot[3][3]; - mat4_to_loc_rot_size(pchan->loc, rot, pchan->size, mat); + mat4_to_loc_rot_size(pchan->loc, rot, pchan->scale, mat); BKE_pchan_mat3_to_rot(pchan, rot, use_compat); } @@ -2443,13 +2443,13 @@ void BKE_pchan_protected_location_set(bPoseChannel *pchan, const float location[ void BKE_pchan_protected_scale_set(bPoseChannel *pchan, const float scale[3]) { if ((pchan->protectflag & OB_LOCK_SCALEX) == 0) { - pchan->size[0] = scale[0]; + pchan->scale[0] = scale[0]; } if ((pchan->protectflag & OB_LOCK_SCALEY) == 0) { - pchan->size[1] = scale[1]; + pchan->scale[1] = scale[1]; } if ((pchan->protectflag & OB_LOCK_SCALEZ) == 0) { - pchan->size[2] = scale[2]; + pchan->scale[2] = scale[2]; } } @@ -2914,7 +2914,7 @@ void BKE_pchan_to_mat4(const bPoseChannel *pchan, float r_chanmat[4][4]) float tmat[3][3]; /* get scaling matrix */ - size_to_mat3(smat, pchan->size); + size_to_mat3(smat, pchan->scale); /* get rotation matrix */ BKE_pchan_rot_to_mat3(pchan, rmat); diff --git a/source/blender/blenkernel/intern/object.cc b/source/blender/blenkernel/intern/object.cc index f42fa0691b1..184a74b523b 100644 --- a/source/blender/blenkernel/intern/object.cc +++ b/source/blender/blenkernel/intern/object.cc @@ -2316,7 +2316,7 @@ static void copy_object_pose(Object *obn, const Object *ob, const int flag) BKE_pose_copy_data_ex(&obn->pose, ob->pose, flag, true); /* true = copy constraints */ LISTBASE_FOREACH (bPoseChannel *, chan, &obn->pose->chanbase) { - chan->flag &= ~(POSE_LOC | POSE_ROT | POSE_SIZE); + chan->flag &= ~(POSE_LOC | POSE_ROT | POSE_SCALE); /* XXX Remapping object pointing onto itself should be handled by generic * BKE_library_remap stuff, but... diff --git a/source/blender/draw/engines/overlay/overlay_armature.cc b/source/blender/draw/engines/overlay/overlay_armature.cc index 01e956080c2..1483b77205d 100644 --- a/source/blender/draw/engines/overlay/overlay_armature.cc +++ b/source/blender/draw/engines/overlay/overlay_armature.cc @@ -1362,7 +1362,7 @@ static void draw_bone_degrees_of_freedom(const Armatures::DrawContext *ctx, /* ... but its own rest-space. */ mul_m4_m4m3(posetrans, posetrans, pchan->bone->bone_mat); - float scale = pchan->bone->length * pchan->size[1]; + float scale = pchan->bone->length * pchan->scale[1]; scale_m4_fl(tmp, scale); tmp[1][1] = -tmp[1][1]; mul_m4_m4m4(posetrans, posetrans, tmp); diff --git a/source/blender/editors/armature/pose_slide.cc b/source/blender/editors/armature/pose_slide.cc index f326cb66ffc..8a05273466a 100644 --- a/source/blender/editors/armature/pose_slide.cc +++ b/source/blender/editors/armature/pose_slide.cc @@ -100,7 +100,7 @@ enum ePoseSlide_Channels { PS_TFM_LOC, /* Loc/Rot/Scale */ PS_TFM_ROT, - PS_TFM_SIZE, + PS_TFM_SCALE, PS_TFM_BBONE_SHAPE, /* Bendy Bones */ @@ -170,7 +170,8 @@ static const EnumPropertyItem prop_channels_types[] = { "All properties, including transforms, bendy bone shape, and custom properties"}, {PS_TFM_LOC, "LOC", 0, "Location", "Location only"}, {PS_TFM_ROT, "ROT", 0, "Rotation", "Rotation only"}, - {PS_TFM_SIZE, "SIZE", 0, "Scale", "Scale only"}, + /* NOTE: `SIZE` identifier is only used for compatibility, should be `SCALE`. */ + {PS_TFM_SCALE, "SIZE", 0, "Scale", "Scale only"}, {PS_TFM_BBONE_SHAPE, "BBONE", 0, "Bendy Bone", "Bendy Bone shape properties"}, {PS_TFM_PROPS, "CUSTOM", 0, "Custom Properties", "Custom properties"}, {0, nullptr, 0, nullptr, nullptr}, @@ -747,9 +748,9 @@ static void pose_slide_rest_pose_apply(bContext *C, tPoseSlideOp *pso) pose_slide_rest_pose_apply_vec3(pso, pchan->loc, 0.0f); } - if (ELEM(pso->channels, PS_TFM_ALL, PS_TFM_SIZE) && (pchan->flag & POSE_SIZE)) { + if (ELEM(pso->channels, PS_TFM_ALL, PS_TFM_SCALE) && (pchan->flag & POSE_SCALE)) { /* Calculate these for the 'scale' vector, and use scale curves. */ - pose_slide_rest_pose_apply_vec3(pso, pchan->size, 1.0f); + pose_slide_rest_pose_apply_vec3(pso, pchan->scale, 1.0f); } if (ELEM(pso->channels, PS_TFM_ALL, PS_TFM_ROT) && (pchan->flag & POSE_ROT)) { @@ -823,9 +824,9 @@ static void pose_slide_apply(bContext *C, tPoseSlideOp *pso) pose_slide_apply_vec3(pso, pfl, pchan->loc, "location"); } - if (ELEM(pso->channels, PS_TFM_ALL, PS_TFM_SIZE) && (pchan->flag & POSE_SIZE)) { + if (ELEM(pso->channels, PS_TFM_ALL, PS_TFM_SCALE) && (pchan->flag & POSE_SCALE)) { /* Calculate these for the 'scale' vector, and use scale curves. */ - pose_slide_apply_vec3(pso, pfl, pchan->size, "scale"); + pose_slide_apply_vec3(pso, pfl, pchan->scale, "scale"); } if (ELEM(pso->channels, PS_TFM_ALL, PS_TFM_ROT) && (pchan->flag & POSE_ROT)) { @@ -916,7 +917,7 @@ static void pose_slide_draw_status(bContext *C, tPoseSlideOp *pso) status.item_bool("", pso->channels == PS_TFM_LOC, ICON_EVENT_G); status.item_bool("", pso->channels == PS_TFM_ROT, ICON_EVENT_R); - status.item_bool("", pso->channels == PS_TFM_SIZE, ICON_EVENT_S); + status.item_bool("", pso->channels == PS_TFM_SCALE, ICON_EVENT_S); status.item_bool("", pso->channels == PS_TFM_BBONE_SHAPE, ICON_EVENT_B); status.item_bool("", pso->channels == PS_TFM_PROPS, ICON_EVENT_C); @@ -927,7 +928,7 @@ static void pose_slide_draw_status(bContext *C, tPoseSlideOp *pso) case PS_TFM_ROT: status.item("Rotation Only", ICON_NONE); break; - case PS_TFM_SIZE: + case PS_TFM_SCALE: status.item("Scale Only", ICON_NONE); break; case PS_TFM_BBONE_SHAPE: @@ -941,7 +942,7 @@ static void pose_slide_draw_status(bContext *C, tPoseSlideOp *pso) break; } - if (ELEM(pso->channels, PS_TFM_LOC, PS_TFM_ROT, PS_TFM_SIZE)) { + if (ELEM(pso->channels, PS_TFM_LOC, PS_TFM_ROT, PS_TFM_SCALE)) { status.item_bool("", pso->axislock & PS_LOCK_X, ICON_EVENT_X); status.item_bool("", pso->axislock & PS_LOCK_Y, ICON_EVENT_Y); status.item_bool("", pso->axislock & PS_LOCK_Z, ICON_EVENT_Z); @@ -1214,7 +1215,7 @@ static int pose_slide_modal(bContext *C, wmOperator *op, const wmEvent *event) } case EVT_SKEY: /* Scale */ { - pose_slide_toggle_channels_mode(op, pso, PS_TFM_SIZE); + pose_slide_toggle_channels_mode(op, pso, PS_TFM_SCALE); do_pose_update = true; break; } diff --git a/source/blender/editors/armature/pose_transform.cc b/source/blender/editors/armature/pose_transform.cc index 3d17495ee4b..d740a25f075 100644 --- a/source/blender/editors/armature/pose_transform.cc +++ b/source/blender/editors/armature/pose_transform.cc @@ -175,7 +175,7 @@ static void applyarmature_transfer_properties(EditBone *curbone, zero_v3(pchan->eul); unit_qt(pchan->quat); unit_axis_angle(pchan->rotAxis, &pchan->rotAngle); - pchan->size[0] = pchan->size[1] = pchan->size[2] = 1.0f; + pchan->scale[0] = pchan->scale[1] = pchan->scale[2] = 1.0f; } /* Adjust the current edit position of the bone using the pose space matrix. */ @@ -659,7 +659,7 @@ static bPoseChannel *pose_bone_do_paste(Object *ob, * - only copies transform info for the pose */ copy_v3_v3(pchan->loc, chan->loc); - copy_v3_v3(pchan->size, chan->size); + copy_v3_v3(pchan->scale, chan->scale); pchan->flag = chan->flag; /* check if rotation modes are compatible (i.e. do they need any conversions) */ @@ -959,13 +959,13 @@ void POSE_OT_paste(wmOperatorType *ot) static void pchan_clear_scale(bPoseChannel *pchan) { if ((pchan->protectflag & OB_LOCK_SCALEX) == 0) { - pchan->size[0] = 1.0f; + pchan->scale[0] = 1.0f; } if ((pchan->protectflag & OB_LOCK_SCALEY) == 0) { - pchan->size[1] = 1.0f; + pchan->scale[1] = 1.0f; } if ((pchan->protectflag & OB_LOCK_SCALEZ) == 0) { - pchan->size[2] = 1.0f; + pchan->scale[2] = 1.0f; } pchan->ease1 = 0.0f; diff --git a/source/blender/editors/armature/pose_utils.cc b/source/blender/editors/armature/pose_utils.cc index d3ed63ff658..d2957d5d577 100644 --- a/source/blender/editors/armature/pose_utils.cc +++ b/source/blender/editors/armature/pose_utils.cc @@ -171,7 +171,7 @@ static void fcurves_to_pchan_links_get(ListBase &pfLinks, Object &ob, bPoseChann const eAction_TransformFlags transFlags = get_item_transform_flags_and_fcurves( ob, pchan, curves); - pchan.flag &= ~(POSE_LOC | POSE_ROT | POSE_SIZE | POSE_BBONE_SHAPE); + pchan.flag &= ~(POSE_LOC | POSE_ROT | POSE_SCALE | POSE_BBONE_SHAPE); if (!transFlags) { return; @@ -198,7 +198,7 @@ static void fcurves_to_pchan_links_get(ListBase &pfLinks, Object &ob, bPoseChann pchan.flag |= POSE_ROT; } if (transFlags & ACT_TRANS_SCALE) { - pchan.flag |= POSE_SIZE; + pchan.flag |= POSE_SCALE; } if (transFlags & ACT_TRANS_BBONE) { pchan.flag |= POSE_BBONE_SHAPE; @@ -206,7 +206,7 @@ static void fcurves_to_pchan_links_get(ListBase &pfLinks, Object &ob, bPoseChann copy_v3_v3(pfl->oldloc, pchan.loc); copy_v3_v3(pfl->oldrot, pchan.eul); - copy_v3_v3(pfl->oldscale, pchan.size); + copy_v3_v3(pfl->oldscale, pchan.scale); copy_qt_qt(pfl->oldquat, pchan.quat); copy_v3_v3(pfl->oldaxis, pchan.rotAxis); pfl->oldangle = pchan.rotAngle; @@ -341,7 +341,7 @@ void poseAnim_mapping_reset(ListBase *pfLinks) /* just copy all the values over regardless of whether they changed or not */ copy_v3_v3(pchan->loc, pfl->oldloc); copy_v3_v3(pchan->eul, pfl->oldrot); - copy_v3_v3(pchan->size, pfl->oldscale); + copy_v3_v3(pchan->scale, pfl->oldscale); copy_qt_qt(pchan->quat, pfl->oldquat); copy_v3_v3(pchan->rotAxis, pfl->oldaxis); pchan->rotAngle = pfl->oldangle; diff --git a/source/blender/editors/transform/transform_convert_armature.cc b/source/blender/editors/transform/transform_convert_armature.cc index f1e1adf2c57..7d6f62d8483 100644 --- a/source/blender/editors/transform/transform_convert_armature.cc +++ b/source/blender/editors/transform/transform_convert_armature.cc @@ -318,7 +318,7 @@ struct PoseInitData_Mirror { bPoseChannel *pchan; struct { float loc[3]; - float size[3]; + float scale[3]; union { float eul[3]; float quat[4]; @@ -343,7 +343,7 @@ static void pose_mirror_info_init(PoseInitData_Mirror *pid, { pid->pchan = pchan; copy_v3_v3(pid->orig.loc, pchan->loc); - copy_v3_v3(pid->orig.size, pchan->size); + copy_v3_v3(pid->orig.scale, pchan->scale); pid->orig.curve_in_x = pchan->curve_in_x; pid->orig.curve_out_x = pchan->curve_out_x; pid->orig.roll1 = pchan->roll1; @@ -414,8 +414,8 @@ static void add_pose_transdata(TransInfo *t, bPoseChannel *pchan, Object *ob, Tr td->loc = pchan->loc; copy_v3_v3(td->iloc, pchan->loc); - td->ext->scale = pchan->size; - copy_v3_v3(td->ext->iscale, pchan->size); + td->ext->scale = pchan->scale; + copy_v3_v3(td->ext->iscale, pchan->scale); if (pchan->rotmode > 0) { td->ext->rot = pchan->eul; @@ -1228,7 +1228,7 @@ static void pose_mirror_info_restore(const PoseInitData_Mirror *pid) { bPoseChannel *pchan = pid->pchan; copy_v3_v3(pchan->loc, pid->orig.loc); - copy_v3_v3(pchan->size, pid->orig.size); + copy_v3_v3(pchan->scale, pid->orig.scale); pchan->curve_in_x = pid->orig.curve_in_x; pchan->curve_out_x = pid->orig.curve_out_x; pchan->roll1 = pid->orig.roll1; @@ -1581,7 +1581,7 @@ static short apply_targetless_ik(Object *ob) BKE_pchan_rot_to_mat3(parchan, qrmat); invert_m3_m3(imat3, qrmat); mul_m3_m3m3(smat, rmat3, imat3); - mat3_to_size(parchan->size, smat); + mat3_to_size(parchan->scale, smat); } /* Causes problems with some constraints (e.g. child-of), so disable this diff --git a/source/blender/makesdna/DNA_action_types.h b/source/blender/makesdna/DNA_action_types.h index b43c5108f88..11e597e988a 100644 --- a/source/blender/makesdna/DNA_action_types.h +++ b/source/blender/makesdna/DNA_action_types.h @@ -344,7 +344,7 @@ typedef struct bPoseChannel { /** Transforms - written in by actions or transform. */ float loc[3]; - float size[3]; + float scale[3]; /** * Rotations - written in by actions or transform @@ -431,7 +431,7 @@ typedef enum ePchan_Flag { /* has transforms */ POSE_LOC = (1 << 0), POSE_ROT = (1 << 1), - POSE_SIZE = (1 << 2), + POSE_SCALE = (1 << 2), /* old IK/cache stuff * - used to be here from (1 << 3) to (1 << 8) diff --git a/source/blender/makesdna/intern/dna_rename_defs.h b/source/blender/makesdna/intern/dna_rename_defs.h index c030eb0bcec..8bead0cf5fa 100644 --- a/source/blender/makesdna/intern/dna_rename_defs.h +++ b/source/blender/makesdna/intern/dna_rename_defs.h @@ -236,6 +236,7 @@ DNA_STRUCT_RENAME_MEMBER(bPoseChannel, scaleIn, scale_in_x) DNA_STRUCT_RENAME_MEMBER(bPoseChannel, scaleOut, scale_out_x) DNA_STRUCT_RENAME_MEMBER(bPoseChannel, scale_in_y, scale_in_z) DNA_STRUCT_RENAME_MEMBER(bPoseChannel, scale_out_y, scale_out_z) +DNA_STRUCT_RENAME_MEMBER(bPoseChannel, size, scale) DNA_STRUCT_RENAME_MEMBER(bSameVolumeConstraint, flag, free_axis) DNA_STRUCT_RENAME_MEMBER(bSound, name, filepath) DNA_STRUCT_RENAME_MEMBER(bTheme, tact, space_action) diff --git a/source/blender/makesrna/intern/rna_pose.cc b/source/blender/makesrna/intern/rna_pose.cc index 9a540be69fb..e65f6dcfd6c 100644 --- a/source/blender/makesrna/intern/rna_pose.cc +++ b/source/blender/makesrna/intern/rna_pose.cc @@ -817,7 +817,6 @@ static void rna_def_pose_channel(BlenderRNA *brna) RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Pose_IK_update"); prop = RNA_def_property(srna, "scale", PROP_FLOAT, PROP_XYZ); - RNA_def_property_float_sdna(prop, nullptr, "size"); RNA_def_property_flag(prop, PROP_PROPORTIONAL); RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY); RNA_def_property_editable_array_func(prop, "rna_PoseChannel_scale_editable");