From de7c9f41e613a704f8e3258050b952d2ada60083 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Fri, 3 Jul 2020 15:42:22 +0200 Subject: Cleanup: Editors/Object, Clang-Tidy else-after-return fixes This addresses warnings from Clang-Tidy's `readability-else-after-return` rule in the `source/blender/editors/object` module. No functional changes. --- source/blender/editors/object/object_relations.c | 390 +++++++++++------------ 1 file changed, 190 insertions(+), 200 deletions(-) (limited to 'source/blender/editors/object/object_relations.c') diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c index a421fd6315c..d37f03b7f55 100644 --- a/source/blender/editors/object/object_relations.c +++ b/source/blender/editors/object/object_relations.c @@ -359,7 +359,7 @@ static int make_proxy_invoke(bContext *C, wmOperator *op, const wmEvent *event) WM_enum_search_invoke(C, op, event); return OPERATOR_CANCELLED; } - else if (ID_IS_LINKED(ob)) { + if (ID_IS_LINKED(ob)) { uiPopupMenu *pup = UI_popup_menu_begin(C, IFACE_("OK?"), ICON_QUESTION); uiLayout *layout = UI_popup_menu_layout(pup); @@ -374,12 +374,10 @@ static int make_proxy_invoke(bContext *C, wmOperator *op, const wmEvent *event) /* this invoke just calls another instance of this operator... */ return OPERATOR_INTERFACE; } - else { - /* error.. cannot continue */ - BKE_report( - op->reports, RPT_ERROR, "Can only make proxy for a referenced object or collection"); - return OPERATOR_CANCELLED; - } + + /* error.. cannot continue */ + BKE_report(op->reports, RPT_ERROR, "Can only make proxy for a referenced object or collection"); + return OPERATOR_CANCELLED; } static int make_proxy_exec(bContext *C, wmOperator *op) @@ -708,36 +706,34 @@ bool ED_object_parent_set(ReportList *reports, if (par->type != OB_CURVE) { return 0; } + Curve *cu = par->data; + Curve *cu_eval = parent_eval->data; + if ((cu->flag & CU_PATH) == 0) { + cu->flag |= CU_PATH | CU_FOLLOW; + cu_eval->flag |= CU_PATH | CU_FOLLOW; + /* force creation of path data */ + BKE_displist_make_curveTypes(depsgraph, scene, par, false, false); + } else { - Curve *cu = par->data; - Curve *cu_eval = parent_eval->data; - if ((cu->flag & CU_PATH) == 0) { - cu->flag |= CU_PATH | CU_FOLLOW; - cu_eval->flag |= CU_PATH | CU_FOLLOW; - /* force creation of path data */ - BKE_displist_make_curveTypes(depsgraph, scene, par, false, false); - } - else { - cu->flag |= CU_FOLLOW; - cu_eval->flag |= CU_FOLLOW; - } + cu->flag |= CU_FOLLOW; + cu_eval->flag |= CU_FOLLOW; + } - /* if follow, add F-Curve for ctime (i.e. "eval_time") so that path-follow works */ - if (partype == PAR_FOLLOW) { - /* get or create F-Curve */ - bAction *act = ED_id_action_ensure(bmain, &cu->id); - FCurve *fcu = ED_action_fcurve_ensure(bmain, act, NULL, NULL, "eval_time", 0); + /* if follow, add F-Curve for ctime (i.e. "eval_time") so that path-follow works */ + if (partype == PAR_FOLLOW) { + /* get or create F-Curve */ + bAction *act = ED_id_action_ensure(bmain, &cu->id); + FCurve *fcu = ED_action_fcurve_ensure(bmain, act, NULL, NULL, "eval_time", 0); - /* setup dummy 'generator' modifier here to get 1-1 correspondence still working */ - if (!fcu->bezt && !fcu->fpt && !fcu->modifiers.first) { - add_fmodifier(&fcu->modifiers, FMODIFIER_TYPE_GENERATOR, fcu); - } + /* setup dummy 'generator' modifier here to get 1-1 correspondence still working */ + if (!fcu->bezt && !fcu->fpt && !fcu->modifiers.first) { + add_fmodifier(&fcu->modifiers, FMODIFIER_TYPE_GENERATOR, fcu); } + } - /* fall back on regular parenting now (for follow only) */ - if (partype == PAR_FOLLOW) { - partype = PAR_OBJECT; - } + /* fall back on regular parenting now (for follow only) */ + if (partype == PAR_FOLLOW) { + partype = PAR_OBJECT; } } else if (ELEM(partype, PAR_BONE, PAR_BONE_RELATIVE)) { @@ -755,188 +751,185 @@ bool ED_object_parent_set(ReportList *reports, BKE_report(reports, RPT_ERROR, "Loop in parents"); return false; } - else { - Object workob; - /* apply transformation of previous parenting */ - if (keep_transform) { - /* was removed because of bug [#23577], - * but this can be handy in some cases too [#32616], so make optional */ - BKE_object_apply_mat4(ob, ob->obmat, false, false); - } + Object workob; - /* set the parent (except for follow-path constraint option) */ - if (partype != PAR_PATH_CONST) { - ob->parent = par; - /* Always clear parentinv matrix for sake of consistency, see T41950. */ - unit_m4(ob->parentinv); - DEG_id_tag_update(&ob->id, ID_RECALC_TRANSFORM); - } + /* apply transformation of previous parenting */ + if (keep_transform) { + /* was removed because of bug [#23577], + * but this can be handy in some cases too [#32616], so make optional */ + BKE_object_apply_mat4(ob, ob->obmat, false, false); + } - /* handle types */ - if (pchan) { - BLI_strncpy(ob->parsubstr, pchan->name, sizeof(ob->parsubstr)); - } - else { - ob->parsubstr[0] = 0; - } + /* set the parent (except for follow-path constraint option) */ + if (partype != PAR_PATH_CONST) { + ob->parent = par; + /* Always clear parentinv matrix for sake of consistency, see T41950. */ + unit_m4(ob->parentinv); + DEG_id_tag_update(&ob->id, ID_RECALC_TRANSFORM); + } - if (partype == PAR_PATH_CONST) { - /* don't do anything here, since this is not technically "parenting" */ - } - else if (ELEM(partype, PAR_CURVE, PAR_LATTICE) || (pararm)) { - /* partype is now set to PAROBJECT so that invisible 'virtual' - * modifiers don't need to be created. - * NOTE: the old (2.4x) method was to set ob->partype = PARSKEL, - * creating the virtual modifiers. - */ - ob->partype = PAROBJECT; /* note, dna define, not operator property */ - /* ob->partype = PARSKEL; */ /* note, dna define, not operator property */ + /* handle types */ + if (pchan) { + BLI_strncpy(ob->parsubstr, pchan->name, sizeof(ob->parsubstr)); + } + else { + ob->parsubstr[0] = 0; + } - /* BUT, to keep the deforms, we need a modifier, - * and then we need to set the object that it uses - * - We need to ensure that the modifier we're adding doesn't already exist, - * so we check this by assuming that the parent is selected too. - */ - /* XXX currently this should only happen for meshes, curves, surfaces, - * and lattices - this stuff isn't available for metas yet */ - if (ELEM(ob->type, OB_MESH, OB_CURVE, OB_SURF, OB_FONT, OB_LATTICE)) { - ModifierData *md; - - switch (partype) { - case PAR_CURVE: /* curve deform */ - if (BKE_modifiers_is_deformed_by_curve(ob) != par) { - md = ED_object_modifier_add(reports, bmain, scene, ob, NULL, eModifierType_Curve); - if (md) { - ((CurveModifierData *)md)->object = par; - } - if (par->runtime.curve_cache && par->runtime.curve_cache->path == NULL) { - DEG_id_tag_update(&par->id, ID_RECALC_GEOMETRY); - } + if (partype == PAR_PATH_CONST) { + /* don't do anything here, since this is not technically "parenting" */ + } + else if (ELEM(partype, PAR_CURVE, PAR_LATTICE) || (pararm)) { + /* partype is now set to PAROBJECT so that invisible 'virtual' + * modifiers don't need to be created. + * NOTE: the old (2.4x) method was to set ob->partype = PARSKEL, + * creating the virtual modifiers. + */ + ob->partype = PAROBJECT; /* note, dna define, not operator property */ + /* ob->partype = PARSKEL; */ /* note, dna define, not operator property */ + + /* BUT, to keep the deforms, we need a modifier, + * and then we need to set the object that it uses + * - We need to ensure that the modifier we're adding doesn't already exist, + * so we check this by assuming that the parent is selected too. + */ + /* XXX currently this should only happen for meshes, curves, surfaces, + * and lattices - this stuff isn't available for metas yet */ + if (ELEM(ob->type, OB_MESH, OB_CURVE, OB_SURF, OB_FONT, OB_LATTICE)) { + ModifierData *md; + + switch (partype) { + case PAR_CURVE: /* curve deform */ + if (BKE_modifiers_is_deformed_by_curve(ob) != par) { + md = ED_object_modifier_add(reports, bmain, scene, ob, NULL, eModifierType_Curve); + if (md) { + ((CurveModifierData *)md)->object = par; } - break; - case PAR_LATTICE: /* lattice deform */ - if (BKE_modifiers_is_deformed_by_lattice(ob) != par) { - md = ED_object_modifier_add( - reports, bmain, scene, ob, NULL, eModifierType_Lattice); - if (md) { - ((LatticeModifierData *)md)->object = par; - } + if (par->runtime.curve_cache && par->runtime.curve_cache->path == NULL) { + DEG_id_tag_update(&par->id, ID_RECALC_GEOMETRY); } - break; - default: /* armature deform */ - if (BKE_modifiers_is_deformed_by_armature(ob) != par) { - md = ED_object_modifier_add( - reports, bmain, scene, ob, NULL, eModifierType_Armature); - if (md) { - ((ArmatureModifierData *)md)->object = par; - } + } + break; + case PAR_LATTICE: /* lattice deform */ + if (BKE_modifiers_is_deformed_by_lattice(ob) != par) { + md = ED_object_modifier_add(reports, bmain, scene, ob, NULL, eModifierType_Lattice); + if (md) { + ((LatticeModifierData *)md)->object = par; } - break; - } - } - } - else if (partype == PAR_BONE) { - ob->partype = PARBONE; /* note, dna define, not operator property */ - if (pchan->bone) { - pchan->bone->flag &= ~BONE_RELATIVE_PARENTING; - pchan_eval->bone->flag &= ~BONE_RELATIVE_PARENTING; - } - } - else if (partype == PAR_BONE_RELATIVE) { - ob->partype = PARBONE; /* note, dna define, not operator property */ - if (pchan->bone) { - pchan->bone->flag |= BONE_RELATIVE_PARENTING; - pchan_eval->bone->flag |= BONE_RELATIVE_PARENTING; + } + break; + default: /* armature deform */ + if (BKE_modifiers_is_deformed_by_armature(ob) != par) { + md = ED_object_modifier_add(reports, bmain, scene, ob, NULL, eModifierType_Armature); + if (md) { + ((ArmatureModifierData *)md)->object = par; + } + } + break; } } - else if (partype == PAR_VERTEX) { - ob->partype = PARVERT1; - ob->par1 = vert_par[0]; - } - else if (partype == PAR_VERTEX_TRI) { - ob->partype = PARVERT3; - copy_v3_v3_int(&ob->par1, vert_par); + } + else if (partype == PAR_BONE) { + ob->partype = PARBONE; /* note, dna define, not operator property */ + if (pchan->bone) { + pchan->bone->flag &= ~BONE_RELATIVE_PARENTING; + pchan_eval->bone->flag &= ~BONE_RELATIVE_PARENTING; } - else { - ob->partype = PAROBJECT; /* note, dna define, not operator property */ + } + else if (partype == PAR_BONE_RELATIVE) { + ob->partype = PARBONE; /* note, dna define, not operator property */ + if (pchan->bone) { + pchan->bone->flag |= BONE_RELATIVE_PARENTING; + pchan_eval->bone->flag |= BONE_RELATIVE_PARENTING; } + } + else if (partype == PAR_VERTEX) { + ob->partype = PARVERT1; + ob->par1 = vert_par[0]; + } + else if (partype == PAR_VERTEX_TRI) { + ob->partype = PARVERT3; + copy_v3_v3_int(&ob->par1, vert_par); + } + else { + ob->partype = PAROBJECT; /* note, dna define, not operator property */ + } - /* constraint */ - if (partype == PAR_PATH_CONST) { - bConstraint *con; - bFollowPathConstraint *data; - float cmat[4][4], vec[3]; + /* constraint */ + if (partype == PAR_PATH_CONST) { + bConstraint *con; + bFollowPathConstraint *data; + float cmat[4][4], vec[3]; - con = BKE_constraint_add_for_object(ob, "AutoPath", CONSTRAINT_TYPE_FOLLOWPATH); + con = BKE_constraint_add_for_object(ob, "AutoPath", CONSTRAINT_TYPE_FOLLOWPATH); - data = con->data; - data->tar = par; + data = con->data; + data->tar = par; - BKE_constraint_target_matrix_get( - depsgraph, scene, con, 0, CONSTRAINT_OBTYPE_OBJECT, NULL, cmat, scene->r.cfra); - sub_v3_v3v3(vec, ob->obmat[3], cmat[3]); + BKE_constraint_target_matrix_get( + depsgraph, scene, con, 0, CONSTRAINT_OBTYPE_OBJECT, NULL, cmat, scene->r.cfra); + sub_v3_v3v3(vec, ob->obmat[3], cmat[3]); - copy_v3_v3(ob->loc, vec); + copy_v3_v3(ob->loc, vec); + } + else if (pararm && (ob->type == OB_MESH) && (par->type == OB_ARMATURE)) { + if (partype == PAR_ARMATURE_NAME) { + ED_object_vgroup_calc_from_armature( + reports, depsgraph, scene, ob, par, ARM_GROUPS_NAME, false); } - else if (pararm && (ob->type == OB_MESH) && (par->type == OB_ARMATURE)) { - if (partype == PAR_ARMATURE_NAME) { - ED_object_vgroup_calc_from_armature( - reports, depsgraph, scene, ob, par, ARM_GROUPS_NAME, false); - } - else if (partype == PAR_ARMATURE_ENVELOPE) { - ED_object_vgroup_calc_from_armature( - reports, depsgraph, scene, ob, par, ARM_GROUPS_ENVELOPE, xmirror); - } - else if (partype == PAR_ARMATURE_AUTO) { - WM_cursor_wait(1); - ED_object_vgroup_calc_from_armature( - reports, depsgraph, scene, ob, par, ARM_GROUPS_AUTO, xmirror); - WM_cursor_wait(0); - } - /* get corrected inverse */ - ob->partype = PAROBJECT; - BKE_object_workob_calc_parent(depsgraph, scene, ob, &workob); - - invert_m4_m4(ob->parentinv, workob.obmat); + else if (partype == PAR_ARMATURE_ENVELOPE) { + ED_object_vgroup_calc_from_armature( + reports, depsgraph, scene, ob, par, ARM_GROUPS_ENVELOPE, xmirror); } - else if (pararm && (ob->type == OB_GPENCIL) && (par->type == OB_ARMATURE)) { - if (partype == PAR_ARMATURE) { - ED_gpencil_add_armature(C, reports, ob, par); - } - else if (partype == PAR_ARMATURE_NAME) { - ED_gpencil_add_armature_weights(C, reports, ob, par, GP_PAR_ARMATURE_NAME); - } - else if ((partype == PAR_ARMATURE_AUTO) || (partype == PAR_ARMATURE_ENVELOPE)) { - WM_cursor_wait(1); - ED_gpencil_add_armature_weights(C, reports, ob, par, GP_PAR_ARMATURE_AUTO); - WM_cursor_wait(0); - } - /* get corrected inverse */ - ob->partype = PAROBJECT; - BKE_object_workob_calc_parent(depsgraph, scene, ob, &workob); - - invert_m4_m4(ob->parentinv, workob.obmat); + else if (partype == PAR_ARMATURE_AUTO) { + WM_cursor_wait(1); + ED_object_vgroup_calc_from_armature( + reports, depsgraph, scene, ob, par, ARM_GROUPS_AUTO, xmirror); + WM_cursor_wait(0); } - else if ((ob->type == OB_GPENCIL) && (par->type == OB_LATTICE)) { - /* Add Lattice modifier */ - if (partype == PAR_LATTICE) { - ED_gpencil_add_lattice_modifier(C, reports, ob, par); - } - /* get corrected inverse */ - ob->partype = PAROBJECT; - BKE_object_workob_calc_parent(depsgraph, scene, ob, &workob); + /* get corrected inverse */ + ob->partype = PAROBJECT; + BKE_object_workob_calc_parent(depsgraph, scene, ob, &workob); - invert_m4_m4(ob->parentinv, workob.obmat); + invert_m4_m4(ob->parentinv, workob.obmat); + } + else if (pararm && (ob->type == OB_GPENCIL) && (par->type == OB_ARMATURE)) { + if (partype == PAR_ARMATURE) { + ED_gpencil_add_armature(C, reports, ob, par); } - else { - /* calculate inverse parent matrix */ - BKE_object_workob_calc_parent(depsgraph, scene, ob, &workob); - invert_m4_m4(ob->parentinv, workob.obmat); + else if (partype == PAR_ARMATURE_NAME) { + ED_gpencil_add_armature_weights(C, reports, ob, par, GP_PAR_ARMATURE_NAME); + } + else if ((partype == PAR_ARMATURE_AUTO) || (partype == PAR_ARMATURE_ENVELOPE)) { + WM_cursor_wait(1); + ED_gpencil_add_armature_weights(C, reports, ob, par, GP_PAR_ARMATURE_AUTO); + WM_cursor_wait(0); + } + /* get corrected inverse */ + ob->partype = PAROBJECT; + BKE_object_workob_calc_parent(depsgraph, scene, ob, &workob); + + invert_m4_m4(ob->parentinv, workob.obmat); + } + else if ((ob->type == OB_GPENCIL) && (par->type == OB_LATTICE)) { + /* Add Lattice modifier */ + if (partype == PAR_LATTICE) { + ED_gpencil_add_lattice_modifier(C, reports, ob, par); } + /* get corrected inverse */ + ob->partype = PAROBJECT; + BKE_object_workob_calc_parent(depsgraph, scene, ob, &workob); - DEG_id_tag_update(&ob->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY); + invert_m4_m4(ob->parentinv, workob.obmat); } + else { + /* calculate inverse parent matrix */ + BKE_object_workob_calc_parent(depsgraph, scene, ob, &workob); + invert_m4_m4(ob->parentinv, workob.obmat); + } + + DEG_id_tag_update(&ob->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY); } return true; @@ -1124,9 +1117,7 @@ static bool parent_set_poll_property(const bContext *UNUSED(C), if (ELEM(type, PAR_ARMATURE_ENVELOPE, PAR_ARMATURE_AUTO)) { return true; } - else { - return false; - } + return false; } return true; @@ -2331,7 +2322,7 @@ static int make_override_library_invoke(bContext *C, wmOperator *op, const wmEve WM_enum_search_invoke(C, op, event); return OPERATOR_CANCELLED; } - else if (ID_IS_LINKED(obact)) { + if (ID_IS_LINKED(obact)) { uiPopupMenu *pup = UI_popup_menu_begin(C, IFACE_("OK?"), ICON_QUESTION); uiLayout *layout = UI_popup_menu_layout(pup); @@ -2346,13 +2337,12 @@ static int make_override_library_invoke(bContext *C, wmOperator *op, const wmEve /* This invoke just calls another instance of this operator... */ return OPERATOR_INTERFACE; } - else { - /* Error.. cannot continue. */ - BKE_report(op->reports, - RPT_ERROR, - "Can only make library override for a referenced object or collection"); - return OPERATOR_CANCELLED; - } + + /* Error.. cannot continue. */ + BKE_report(op->reports, + RPT_ERROR, + "Can only make library override for a referenced object or collection"); + return OPERATOR_CANCELLED; } static int make_override_library_exec(bContext *C, wmOperator *op) -- cgit v1.2.3