diff options
Diffstat (limited to 'source/blender/editors')
10 files changed, 142 insertions, 168 deletions
diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index eb60273fc79..76cce5e725f 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -673,10 +673,10 @@ static bool transform_modal_item_poll(const wmOperator *op, int value) if (t->spacetype != SPACE_VIEW3D) { return false; } - else if ((t->tsnap.mode & ~(SCE_SNAP_MODE_INCREMENT | SCE_SNAP_MODE_GRID)) == 0) { + if ((t->tsnap.mode & ~(SCE_SNAP_MODE_INCREMENT | SCE_SNAP_MODE_GRID)) == 0) { return false; } - else if (!validSnap(t)) { + if (!validSnap(t)) { return false; } break; @@ -1417,9 +1417,7 @@ int transformEvent(TransInfo *t, const wmEvent *event) if (handled || t->redraw) { return 0; } - else { - return OPERATOR_PASS_THROUGH; - } + return OPERATOR_PASS_THROUGH; } bool calculateTransformCenter(bContext *C, int centerMode, float cent3d[3], float cent2d[2]) diff --git a/source/blender/editors/transform/transform_convert.c b/source/blender/editors/transform/transform_convert.c index 5d1fd1543df..d68489759fe 100644 --- a/source/blender/editors/transform/transform_convert.c +++ b/source/blender/editors/transform/transform_convert.c @@ -96,12 +96,10 @@ static int trans_data_compare_dist(const void *a, const void *b) if (td_a->dist < td_b->dist) { return -1; } - else if (td_a->dist > td_b->dist) { + if (td_a->dist > td_b->dist) { return 1; } - else { - return 0; - } + return 0; } static int trans_data_compare_rdist(const void *a, const void *b) @@ -112,12 +110,10 @@ static int trans_data_compare_rdist(const void *a, const void *b) if (td_a->rdist < td_b->rdist) { return -1; } - else if (td_a->rdist > td_b->rdist) { + if (td_a->rdist > td_b->rdist) { return 1; } - else { - return 0; - } + return 0; } static void sort_trans_data_dist_container(const TransInfo *t, TransDataContainer *tc) @@ -610,9 +606,7 @@ bool FrameOnMouseSide(char side, float frame, float cframe) if (side == 'R') { return (frame >= cframe); } - else { - return (frame <= cframe); - } + return (frame <= cframe); } /** \} */ @@ -670,7 +664,7 @@ void posttrans_fcurve_clean(FCurve *fcu, const int sel_flag, const bool use_hand found = true; break; } - else if (rk->frame < bezt->vec[1][0]) { + if (rk->frame < bezt->vec[1][0]) { /* Terminate early if have passed the supposed insertion point? */ break; } @@ -696,11 +690,10 @@ void posttrans_fcurve_clean(FCurve *fcu, const int sel_flag, const bool use_hand } return; } - else { - /* Compute the average values for each retained keyframe */ - LISTBASE_FOREACH (tRetainedKeyframe *, rk, &retained_keys) { - rk->val = rk->val / (float)rk->tot_count; - } + + /* Compute the average values for each retained keyframe */ + LISTBASE_FOREACH (tRetainedKeyframe *, rk, &retained_keys) { + rk->val = rk->val / (float)rk->tot_count; } /* 2) Delete all keyframes duplicating the "retained keys" found above @@ -925,13 +918,13 @@ int special_transform_moving(TransInfo *t) if (t->spacetype == SPACE_SEQ) { return G_TRANSFORM_SEQ; } - else if (t->spacetype == SPACE_GRAPH) { + if (t->spacetype == SPACE_GRAPH) { return G_TRANSFORM_FCURVES; } - else if ((t->flag & T_EDIT) || (t->flag & T_POSE)) { + if ((t->flag & T_EDIT) || (t->flag & T_POSE)) { return G_TRANSFORM_EDIT; } - else if (t->flag & (T_OBJECT | T_TEXTURE)) { + if (t->flag & (T_OBJECT | T_TEXTURE)) { return G_TRANSFORM_OBJ; } diff --git a/source/blender/editors/transform/transform_convert_action.c b/source/blender/editors/transform/transform_convert_action.c index b9292aa151c..40e60544642 100644 --- a/source/blender/editors/transform/transform_convert_action.c +++ b/source/blender/editors/transform/transform_convert_action.c @@ -84,9 +84,7 @@ static int count_fcurve_keys(FCurve *fcu, char side, float cfra, bool is_prop_ed if (is_prop_edit && count > 0) { return count_all; } - else { - return count; - } + return count; } /* fully select selected beztriples, but only include if it's on the right side of cfra */ @@ -112,9 +110,7 @@ static int count_gplayer_frames(bGPDlayer *gpl, char side, float cfra, bool is_p if (is_prop_edit && count > 0) { return count_all; } - else { - return count; - } + return count; } /* fully select selected beztriples, but only include if it's on the right side of cfra */ @@ -141,9 +137,7 @@ static int count_masklayer_frames(MaskLayer *masklay, char side, float cfra, boo if (is_prop_edit && count > 0) { return count_all; } - else { - return count; - } + return count; } /* This function assigns the information to transdata */ diff --git a/source/blender/editors/transform/transform_convert_mesh.c b/source/blender/editors/transform/transform_convert_mesh.c index 5e27fd3c4ce..90e45253afa 100644 --- a/source/blender/editors/transform/transform_convert_mesh.c +++ b/source/blender/editors/transform/transform_convert_mesh.c @@ -830,101 +830,100 @@ void createTransEditVerts(TransInfo *t) if (BM_elem_flag_test(eve, BM_ELEM_HIDDEN)) { continue; } - else { - int island_index = -1; - if (island_data.island_vert_map) { - const int connected_index = (dists_index && dists_index[a] != -1) ? dists_index[a] : a; - island_index = island_data.island_vert_map[connected_index]; - } - if (mirror_data.vert_map && mirror_data.vert_map[a].index != -1) { - int elem_index = mirror_data.vert_map[a].index; - BMVert *v_src = BM_vert_at_index(bm, elem_index); + int island_index = -1; + if (island_data.island_vert_map) { + const int connected_index = (dists_index && dists_index[a] != -1) ? dists_index[a] : a; + island_index = island_data.island_vert_map[connected_index]; + } - if (BM_elem_flag_test(eve, BM_ELEM_SELECT)) { - mirror_data.vert_map[a].flag |= TD_SELECTED; - } + if (mirror_data.vert_map && mirror_data.vert_map[a].index != -1) { + int elem_index = mirror_data.vert_map[a].index; + BMVert *v_src = BM_vert_at_index(bm, elem_index); - td_mirror->extra = eve; - td_mirror->loc = eve->co; - copy_v3_v3(td_mirror->iloc, eve->co); - td_mirror->flag = mirror_data.vert_map[a].flag; - td_mirror->loc_src = v_src->co; - transdata_center_get(&island_data, island_index, td_mirror->iloc, td_mirror->center); + if (BM_elem_flag_test(eve, BM_ELEM_SELECT)) { + mirror_data.vert_map[a].flag |= TD_SELECTED; + } + + td_mirror->extra = eve; + td_mirror->loc = eve->co; + copy_v3_v3(td_mirror->iloc, eve->co); + td_mirror->flag = mirror_data.vert_map[a].flag; + td_mirror->loc_src = v_src->co; + transdata_center_get(&island_data, island_index, td_mirror->iloc, td_mirror->center); - td_mirror++; + td_mirror++; + } + else if (prop_mode || BM_elem_flag_test(eve, BM_ELEM_SELECT)) { + float *bweight = (cd_vert_bweight_offset != -1) ? + BM_ELEM_CD_GET_VOID_P(eve, cd_vert_bweight_offset) : + NULL; + + /* Do not use the island center in case we are using islands + * only to get axis for snap/rotate to normal... */ + VertsToTransData(t, tob, tx, em, eve, bweight, &island_data, island_index); + if (tx) { + tx++; } - else if (prop_mode || BM_elem_flag_test(eve, BM_ELEM_SELECT)) { - float *bweight = (cd_vert_bweight_offset != -1) ? - BM_ELEM_CD_GET_VOID_P(eve, cd_vert_bweight_offset) : - NULL; - - /* Do not use the island center in case we are using islands - * only to get axis for snap/rotate to normal... */ - VertsToTransData(t, tob, tx, em, eve, bweight, &island_data, island_index); - if (tx) { - tx++; - } - /* selected */ - if (BM_elem_flag_test(eve, BM_ELEM_SELECT)) { - tob->flag |= TD_SELECTED; - } + /* selected */ + if (BM_elem_flag_test(eve, BM_ELEM_SELECT)) { + tob->flag |= TD_SELECTED; + } - if (prop_mode) { - if (prop_mode & T_PROP_CONNECTED) { - tob->dist = dists[a]; - } - else { - tob->flag |= TD_NOTCONNECTED; - tob->dist = FLT_MAX; - } + if (prop_mode) { + if (prop_mode & T_PROP_CONNECTED) { + tob->dist = dists[a]; + } + else { + tob->flag |= TD_NOTCONNECTED; + tob->dist = FLT_MAX; } + } - /* CrazySpace */ - const bool use_quats = quats && BM_elem_flag_test(eve, BM_ELEM_TAG); - if (use_quats || defmats) { - float mat[3][3], qmat[3][3], imat[3][3]; + /* CrazySpace */ + const bool use_quats = quats && BM_elem_flag_test(eve, BM_ELEM_TAG); + if (use_quats || defmats) { + float mat[3][3], qmat[3][3], imat[3][3]; - /* Use both or either quat and defmat correction. */ - if (use_quats) { - quat_to_mat3(qmat, quats[BM_elem_index_get(eve)]); + /* Use both or either quat and defmat correction. */ + if (use_quats) { + quat_to_mat3(qmat, quats[BM_elem_index_get(eve)]); - if (defmats) { - mul_m3_series(mat, defmats[a], qmat, mtx); - } - else { - mul_m3_m3m3(mat, mtx, qmat); - } + if (defmats) { + mul_m3_series(mat, defmats[a], qmat, mtx); } else { - mul_m3_m3m3(mat, mtx, defmats[a]); + mul_m3_m3m3(mat, mtx, qmat); } - - invert_m3_m3(imat, mat); - - copy_m3_m3(tob->smtx, imat); - copy_m3_m3(tob->mtx, mat); } else { - copy_m3_m3(tob->smtx, smtx); - copy_m3_m3(tob->mtx, mtx); + mul_m3_m3m3(mat, mtx, defmats[a]); } - if (tc->use_mirror_axis_any) { - if (tc->use_mirror_axis_x && fabsf(tob->loc[0]) < TRANSFORM_MAXDIST_MIRROR) { - tob->flag |= TD_MIRROR_EDGE_X; - } - if (tc->use_mirror_axis_y && fabsf(tob->loc[1]) < TRANSFORM_MAXDIST_MIRROR) { - tob->flag |= TD_MIRROR_EDGE_Y; - } - if (tc->use_mirror_axis_z && fabsf(tob->loc[2]) < TRANSFORM_MAXDIST_MIRROR) { - tob->flag |= TD_MIRROR_EDGE_Z; - } - } + invert_m3_m3(imat, mat); - tob++; + copy_m3_m3(tob->smtx, imat); + copy_m3_m3(tob->mtx, mat); } + else { + copy_m3_m3(tob->smtx, smtx); + copy_m3_m3(tob->mtx, mtx); + } + + if (tc->use_mirror_axis_any) { + if (tc->use_mirror_axis_x && fabsf(tob->loc[0]) < TRANSFORM_MAXDIST_MIRROR) { + tob->flag |= TD_MIRROR_EDGE_X; + } + if (tc->use_mirror_axis_y && fabsf(tob->loc[1]) < TRANSFORM_MAXDIST_MIRROR) { + tob->flag |= TD_MIRROR_EDGE_Y; + } + if (tc->use_mirror_axis_z && fabsf(tob->loc[2]) < TRANSFORM_MAXDIST_MIRROR) { + tob->flag |= TD_MIRROR_EDGE_Z; + } + } + + tob++; } } diff --git a/source/blender/editors/transform/transform_convert_paintcurve.c b/source/blender/editors/transform/transform_convert_paintcurve.c index 4dbe57fc143..47859896673 100644 --- a/source/blender/editors/transform/transform_convert_paintcurve.c +++ b/source/blender/editors/transform/transform_convert_paintcurve.c @@ -154,13 +154,11 @@ void createTransPaintCurveVerts(bContext *C, TransInfo *t) total += 3; continue; } - else { - if (pcp->bez.f1 & SELECT) { - total++; - } - if (pcp->bez.f3 & SELECT) { - total++; - } + if (pcp->bez.f1 & SELECT) { + total++; + } + if (pcp->bez.f3 & SELECT) { + total++; } } } diff --git a/source/blender/editors/transform/transform_generics.c b/source/blender/editors/transform/transform_generics.c index cce6ef1f3bd..8f590d87f4c 100644 --- a/source/blender/editors/transform/transform_generics.c +++ b/source/blender/editors/transform/transform_generics.c @@ -1116,7 +1116,7 @@ bool calculateCenterActive(TransInfo *t, bool select_only, float r_center[3]) if (t->spacetype != SPACE_VIEW3D) { return false; } - else if (tc->obedit) { + if (tc->obedit) { if (ED_object_calc_active_center_for_editmode(tc->obedit, select_only, r_center)) { mul_m4_v3(tc->obedit->obmat, r_center); return true; diff --git a/source/blender/editors/transform/transform_mode.c b/source/blender/editors/transform/transform_mode.c index 831ea90b4e4..5988f5a0f83 100644 --- a/source/blender/editors/transform/transform_mode.c +++ b/source/blender/editors/transform/transform_mode.c @@ -448,21 +448,20 @@ static void constraintSizeLim(TransInfo *t, TransData *td) /* scale val and reset size */ return; // TODO: fix this case } - else { - /* Reset val if SINGLESIZE but using a constraint */ - if (td->flag & TD_SINGLESIZE) { - return; - } - /* separate out sign to apply back later */ - for (i = 0; i < 3; i++) { - size_sign[i] = signf(td->ext->size[i]); - size_abs[i] = fabsf(td->ext->size[i]); - } + /* Reset val if SINGLESIZE but using a constraint */ + if (td->flag & TD_SINGLESIZE) { + return; + } - size_to_mat4(cob.matrix, size_abs); + /* separate out sign to apply back later */ + for (i = 0; i < 3; i++) { + size_sign[i] = signf(td->ext->size[i]); + size_abs[i] = fabsf(td->ext->size[i]); } + size_to_mat4(cob.matrix, size_abs); + /* Evaluate valid constraints */ for (con = td->con; con; con = con->next) { /* only consider constraint if enabled */ @@ -508,16 +507,15 @@ static void constraintSizeLim(TransInfo *t, TransData *td) /* scale val and reset size */ return; // TODO: fix this case } - else { - /* Reset val if SINGLESIZE but using a constraint */ - if (td->flag & TD_SINGLESIZE) { - return; - } - /* extrace scale from matrix and apply back sign */ - mat4_to_size(td->ext->size, cob.matrix); - mul_v3_v3(td->ext->size, size_sign); + /* Reset val if SINGLESIZE but using a constraint */ + if (td->flag & TD_SINGLESIZE) { + return; } + + /* extrace scale from matrix and apply back sign */ + mat4_to_size(td->ext->size, cob.matrix); + mul_v3_v3(td->ext->size, size_sign); } } diff --git a/source/blender/editors/transform/transform_mode_edge_slide.c b/source/blender/editors/transform/transform_mode_edge_slide.c index 750962047db..4a648a77fe1 100644 --- a/source/blender/editors/transform/transform_mode_edge_slide.c +++ b/source/blender/editors/transform/transform_mode_edge_slide.c @@ -281,15 +281,14 @@ static BMLoop *get_next_loop( copy_v3_v3(r_slide_vec, vec_accum); return l; } - else { - /* accumulate the normalized edge vector, - * normalize so some edges don't skew the result */ - float tvec[3]; - sub_v3_v3v3(tvec, BM_edge_other_vert(l->e, v)->co, v->co); - vec_accum_len += normalize_v3(tvec); - add_v3_v3(vec_accum, tvec); - i += 1; - } + + /* accumulate the normalized edge vector, + * normalize so some edges don't skew the result */ + float tvec[3]; + sub_v3_v3v3(tvec, BM_edge_other_vert(l->e, v)->co, v->co); + vec_accum_len += normalize_v3(tvec); + add_v3_v3(vec_accum, tvec); + i += 1; if (BM_loop_other_edge_loop(l, v)->e == e_next) { if (i) { diff --git a/source/blender/editors/transform/transform_ops.c b/source/blender/editors/transform/transform_ops.c index f86bcc41bee..ab9548ad52e 100644 --- a/source/blender/editors/transform/transform_ops.c +++ b/source/blender/editors/transform/transform_ops.c @@ -516,22 +516,19 @@ static int transform_invoke(bContext *C, wmOperator *op, const wmEvent *event) if ((event == NULL) && RNA_struct_property_is_set(op->ptr, "value")) { return transform_exec(C, op); } - else { - /* add temp handler */ - WM_event_add_modal_handler(C, op); - op->flag |= OP_IS_MODAL_GRAB_CURSOR; // XXX maybe we want this with the gizmo only? + /* add temp handler */ + WM_event_add_modal_handler(C, op); - /* Use when modal input has some transformation to begin with. */ - { - TransInfo *t = op->customdata; - if (UNLIKELY(!is_zero_v4(t->values_modal_offset))) { - transformApply(C, t); - } - } + op->flag |= OP_IS_MODAL_GRAB_CURSOR; // XXX maybe we want this with the gizmo only? - return OPERATOR_RUNNING_MODAL; + /* Use when modal input has some transformation to begin with. */ + TransInfo *t = op->customdata; + if (UNLIKELY(!is_zero_v4(t->values_modal_offset))) { + transformApply(C, t); } + + return OPERATOR_RUNNING_MODAL; } static bool transform_poll_property(const bContext *UNUSED(C), diff --git a/source/blender/editors/transform/transform_snap_object.c b/source/blender/editors/transform/transform_snap_object.c index 4198b4c02a3..3af176f5aef 100644 --- a/source/blender/editors/transform/transform_snap_object.c +++ b/source/blender/editors/transform/transform_snap_object.c @@ -1014,12 +1014,11 @@ static void raycast_obj_fn(SnapObjectContext *sctx, dt->r_hit_list); break; } - else { - BMEditMesh *em = BKE_editmesh_from_object(ob); - if (em->mesh_eval_final) { - me = em->mesh_eval_final; - use_hide = true; - } + + BMEditMesh *em = BKE_editmesh_from_object(ob); + if (em->mesh_eval_final) { + me = em->mesh_eval_final; + use_hide = true; } } retval = raycastMesh(sctx, @@ -2689,11 +2688,10 @@ static void snap_obj_fn(SnapObjectContext *sctx, dt->r_index); break; } - else { - BMEditMesh *em = BKE_editmesh_from_object(ob); - if (em->mesh_eval_final) { - me = em->mesh_eval_final; - } + + BMEditMesh *em = BKE_editmesh_from_object(ob); + if (em->mesh_eval_final) { + me = em->mesh_eval_final; } } else if (ob->dt == OB_BOUNDBOX) { |