diff options
author | Campbell Barton <ideasman42@gmail.com> | 2019-04-22 02:19:45 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2019-04-22 12:48:16 +0300 |
commit | 620b960d3d8cfd90b9f0df6ba3671c33eccb8309 (patch) | |
tree | 64f69db4bf9d44f0a32d1c92b0714bf2dc98ff2d /source/blender/editors/transform | |
parent | bba60bb564cf5a16cfcac744d4ba82cf8eba3da9 (diff) |
Cleanup: style, use braces for editors
Diffstat (limited to 'source/blender/editors/transform')
11 files changed, 1162 insertions, 580 deletions
diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index 499971b9a50..c80a0eaa597 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -586,15 +586,18 @@ static void viewRedrawForce(const bContext *C, TransInfo *t) } else { /* Do we need more refined tags? */ - if (t->flag & T_POSE) + if (t->flag & T_POSE) { WM_event_add_notifier(C, NC_OBJECT | ND_POSE, NULL); - else + } + else { WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL); + } /* For real-time animation record - send notifiers recognized by animation editors */ // XXX: is this notifier a lame duck? - if ((t->animtimer) && IS_AUTOKEY_ON(t->scene)) + if ((t->animtimer) && IS_AUTOKEY_ON(t->scene)) { WM_event_add_notifier(C, NC_OBJECT | ND_KEYS, NULL); + } } } else if (t->spacetype == SPACE_ACTION) { @@ -664,8 +667,9 @@ static void viewRedrawPost(bContext *C, TransInfo *t) if (t->spacetype == SPACE_VIEW3D) { /* if autokeying is enabled, send notifiers that keyframes were added */ - if (IS_AUTOKEY_ON(t->scene)) + if (IS_AUTOKEY_ON(t->scene)) { WM_main_add_notifier(NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL); + } /* redraw UV editor */ if (ELEM(t->mode, TFM_VERT_SLIDE, TFM_EDGE_SLIDE) && @@ -1046,8 +1050,9 @@ int transformEvent(TransInfo *t, const wmEvent *event) handled = true; } else if (event->type == MOUSEMOVE) { - if (t->modifiers & MOD_CONSTRAINT_SELECT) + if (t->modifiers & MOD_CONSTRAINT_SELECT) { t->con.mode |= CON_SELECT; + } copy_v2_v2_int(t->mval, event->mval); @@ -1381,8 +1386,9 @@ int transformEvent(TransInfo *t, const wmEvent *event) if ((t->flag & T_NO_CONSTRAINT) == 0) { /* exception for switching to dolly, or trackball, in camera view */ if (t->flag & T_CAMERA) { - if (t->mode == TFM_TRANSLATION) + if (t->mode == TFM_TRANSLATION) { setLocalConstraint(t, (CON_AXIS2), IFACE_("along local Z")); + } else if (t->mode == TFM_ROTATION) { restoreTransObjects(t); initTrackball(t); @@ -1487,8 +1493,9 @@ int transformEvent(TransInfo *t, const wmEvent *event) case PADPLUSKEY: if (event->alt && t->flag & T_PROP_EDIT) { t->prop_size *= (t->modifiers & MOD_PRECISION) ? 1.01f : 1.1f; - if (t->spacetype == SPACE_VIEW3D && t->persp != RV3D_ORTHO) + if (t->spacetype == SPACE_VIEW3D && t->persp != RV3D_ORTHO) { t->prop_size = min_ff(t->prop_size, ((View3D *)t->view)->clip_end); + } calculatePropRatio(t); t->redraw = TREDRAW_HARD; handled = true; @@ -1770,8 +1777,9 @@ static bool helpline_poll(bContext *C) { ARegion *ar = CTX_wm_region(C); - if (ar && ar->regiontype == RGN_TYPE_WINDOW) + if (ar && ar->regiontype == RGN_TYPE_WINDOW) { return 1; + } return 0; } @@ -2117,16 +2125,21 @@ void saveTransform(bContext *C, TransInfo *t, wmOperator *op) if (!(t->options & CTX_NO_PET)) { if ((prop = RNA_struct_find_property(op->ptr, "proportional")) && !RNA_property_is_set(op->ptr, prop)) { - if (t->spacetype == SPACE_GRAPH) + if (t->spacetype == SPACE_GRAPH) { ts->proportional_fcurve = proportional; - else if (t->spacetype == SPACE_ACTION) + } + else if (t->spacetype == SPACE_ACTION) { ts->proportional_action = proportional; - else if (t->obedit_type != -1) + } + else if (t->obedit_type != -1) { ts->proportional = proportional; - else if (t->options & CTX_MASK) + } + else if (t->options & CTX_MASK) { ts->proportional_mask = (proportional != PROP_EDIT_OFF); - else + } + else { ts->proportional_objects = (proportional != PROP_EDIT_OFF); + } } if ((prop = RNA_struct_find_property(op->ptr, "proportional_size"))) { @@ -2586,10 +2599,12 @@ bool initTransform(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve /* same as TFM_TIME_EXTEND, but we need the mode info for later * so that duplicate-culling will work properly */ - if (ELEM(t->spacetype, SPACE_GRAPH, SPACE_NLA)) + if (ELEM(t->spacetype, SPACE_GRAPH, SPACE_NLA)) { initTranslation(t); - else + } + else { initTimeTranslate(t); + } t->mode = mode; break; case TFM_TIME_EXTEND: @@ -2598,10 +2613,12 @@ bool initTransform(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve * (for Graph/NLA Editors only since they uses 'standard' transforms to get 2D movement) * depending on which editor this was called from */ - if (ELEM(t->spacetype, SPACE_GRAPH, SPACE_NLA)) + if (ELEM(t->spacetype, SPACE_GRAPH, SPACE_NLA)) { initTranslation(t); - else + } + else { initTimeTranslate(t); + } break; case TFM_BAKE_TIME: initBakeTime(t); @@ -2808,32 +2825,41 @@ int transformEnd(bContext *C, TransInfo *t) static void protectedTransBits(short protectflag, float vec[3]) { - if (protectflag & OB_LOCK_LOCX) + if (protectflag & OB_LOCK_LOCX) { vec[0] = 0.0f; - if (protectflag & OB_LOCK_LOCY) + } + if (protectflag & OB_LOCK_LOCY) { vec[1] = 0.0f; - if (protectflag & OB_LOCK_LOCZ) + } + if (protectflag & OB_LOCK_LOCZ) { vec[2] = 0.0f; + } } static void protectedSizeBits(short protectflag, float size[3]) { - if (protectflag & OB_LOCK_SCALEX) + if (protectflag & OB_LOCK_SCALEX) { size[0] = 1.0f; - if (protectflag & OB_LOCK_SCALEY) + } + if (protectflag & OB_LOCK_SCALEY) { size[1] = 1.0f; - if (protectflag & OB_LOCK_SCALEZ) + } + if (protectflag & OB_LOCK_SCALEZ) { size[2] = 1.0f; + } } static void protectedRotateBits(short protectflag, float eul[3], const float oldeul[3]) { - if (protectflag & OB_LOCK_ROTX) + if (protectflag & OB_LOCK_ROTX) { eul[0] = oldeul[0]; - if (protectflag & OB_LOCK_ROTY) + } + if (protectflag & OB_LOCK_ROTY) { eul[1] = oldeul[1]; - if (protectflag & OB_LOCK_ROTZ) + } + if (protectflag & OB_LOCK_ROTZ) { eul[2] = oldeul[2]; + } } /* this function only does the delta rotation */ @@ -2842,19 +2868,24 @@ static void protectedAxisAngleBits( short protectflag, float axis[3], float *angle, float oldAxis[3], float oldAngle) { /* check that protection flags are set */ - if ((protectflag & (OB_LOCK_ROTX | OB_LOCK_ROTY | OB_LOCK_ROTZ | OB_LOCK_ROTW)) == 0) + if ((protectflag & (OB_LOCK_ROTX | OB_LOCK_ROTY | OB_LOCK_ROTZ | OB_LOCK_ROTW)) == 0) { return; + } if (protectflag & OB_LOCK_ROT4D) { /* axis-angle getting limited as 4D entities that they are... */ - if (protectflag & OB_LOCK_ROTW) + if (protectflag & OB_LOCK_ROTW) { *angle = oldAngle; - if (protectflag & OB_LOCK_ROTX) + } + if (protectflag & OB_LOCK_ROTX) { axis[0] = oldAxis[0]; - if (protectflag & OB_LOCK_ROTY) + } + if (protectflag & OB_LOCK_ROTY) { axis[1] = oldAxis[1]; - if (protectflag & OB_LOCK_ROTZ) + } + if (protectflag & OB_LOCK_ROTZ) { axis[2] = oldAxis[2]; + } } else { /* axis-angle get limited with euler... */ @@ -2863,12 +2894,15 @@ static void protectedAxisAngleBits( axis_angle_to_eulO(eul, EULER_ORDER_DEFAULT, axis, *angle); axis_angle_to_eulO(oldeul, EULER_ORDER_DEFAULT, oldAxis, oldAngle); - if (protectflag & OB_LOCK_ROTX) + if (protectflag & OB_LOCK_ROTX) { eul[0] = oldeul[0]; - if (protectflag & OB_LOCK_ROTY) + } + if (protectflag & OB_LOCK_ROTY) { eul[1] = oldeul[1]; - if (protectflag & OB_LOCK_ROTZ) + } + if (protectflag & OB_LOCK_ROTZ) { eul[2] = oldeul[2]; + } eulO_to_axis_angle(axis, angle, eul, EULER_ORDER_DEFAULT); @@ -2885,19 +2919,24 @@ static void protectedAxisAngleBits( static void protectedQuaternionBits(short protectflag, float quat[4], const float oldquat[4]) { /* check that protection flags are set */ - if ((protectflag & (OB_LOCK_ROTX | OB_LOCK_ROTY | OB_LOCK_ROTZ | OB_LOCK_ROTW)) == 0) + if ((protectflag & (OB_LOCK_ROTX | OB_LOCK_ROTY | OB_LOCK_ROTZ | OB_LOCK_ROTW)) == 0) { return; + } if (protectflag & OB_LOCK_ROT4D) { /* quaternions getting limited as 4D entities that they are... */ - if (protectflag & OB_LOCK_ROTW) + if (protectflag & OB_LOCK_ROTW) { quat[0] = oldquat[0]; - if (protectflag & OB_LOCK_ROTX) + } + if (protectflag & OB_LOCK_ROTX) { quat[1] = oldquat[1]; - if (protectflag & OB_LOCK_ROTY) + } + if (protectflag & OB_LOCK_ROTY) { quat[2] = oldquat[2]; - if (protectflag & OB_LOCK_ROTZ) + } + if (protectflag & OB_LOCK_ROTZ) { quat[3] = oldquat[3]; + } } else { /* quaternions get limited with euler... (compatibility mode) */ @@ -2910,12 +2949,15 @@ static void protectedQuaternionBits(short protectflag, float quat[4], const floa quat_to_eul(eul, nquat); quat_to_eul(oldeul, noldquat); - if (protectflag & OB_LOCK_ROTX) + if (protectflag & OB_LOCK_ROTX) { eul[0] = oldeul[0]; - if (protectflag & OB_LOCK_ROTY) + } + if (protectflag & OB_LOCK_ROTY) { eul[1] = oldeul[1]; - if (protectflag & OB_LOCK_ROTZ) + } + if (protectflag & OB_LOCK_ROTZ) { eul[2] = oldeul[2]; + } eul_to_quat(quat, eul); @@ -2956,24 +2998,28 @@ static void constraintTransLim(TransInfo *t, TransData *td) ListBase targets = {NULL, NULL}; /* only consider constraint if enabled */ - if (con->flag & (CONSTRAINT_DISABLE | CONSTRAINT_OFF)) + if (con->flag & (CONSTRAINT_DISABLE | CONSTRAINT_OFF)) { continue; - if (con->enforce == 0.0f) + } + if (con->enforce == 0.0f) { continue; + } /* only use it if it's tagged for this purpose (and the right type) */ if (con->type == CONSTRAINT_TYPE_LOCLIMIT) { bLocLimitConstraint *data = con->data; - if ((data->flag2 & LIMIT_TRANSFORM) == 0) + if ((data->flag2 & LIMIT_TRANSFORM) == 0) { continue; + } cti = ctiLoc; } else if (con->type == CONSTRAINT_TYPE_DISTLIMIT) { bDistLimitConstraint *data = con->data; - if ((data->flag & LIMITDIST_TRANSFORM) == 0) + if ((data->flag & LIMITDIST_TRANSFORM) == 0) { continue; + } cti = ctiDist; } @@ -3049,22 +3095,26 @@ static void constraintRotLim(TransInfo *UNUSED(t), TransData *td) /* Evaluate valid constraints */ for (con = td->con; con; con = con->next) { /* only consider constraint if enabled */ - if (con->flag & (CONSTRAINT_DISABLE | CONSTRAINT_OFF)) + if (con->flag & (CONSTRAINT_DISABLE | CONSTRAINT_OFF)) { continue; - if (con->enforce == 0.0f) + } + if (con->enforce == 0.0f) { continue; + } /* we're only interested in Limit-Rotation constraints */ if (con->type == CONSTRAINT_TYPE_ROTLIMIT) { bRotLimitConstraint *data = con->data; /* only use it if it's tagged for this purpose */ - if ((data->flag2 & LIMIT_TRANSFORM) == 0) + if ((data->flag2 & LIMIT_TRANSFORM) == 0) { continue; + } /* skip incompatible spacetypes */ - if (!ELEM(con->ownspace, CONSTRAINT_SPACE_WORLD, CONSTRAINT_SPACE_LOCAL)) + if (!ELEM(con->ownspace, CONSTRAINT_SPACE_WORLD, CONSTRAINT_SPACE_LOCAL)) { continue; + } /* only do conversion if necessary, to preserve quats and eulers */ if (do_limit == false) { @@ -3126,8 +3176,9 @@ static void constraintSizeLim(TransInfo *t, TransData *td) } else { /* Reset val if SINGLESIZE but using a constraint */ - if (td->flag & TD_SINGLESIZE) + if (td->flag & TD_SINGLESIZE) { return; + } /* separate out sign to apply back later */ for (i = 0; i < 3; i++) { @@ -3141,18 +3192,21 @@ static void constraintSizeLim(TransInfo *t, TransData *td) /* Evaluate valid constraints */ for (con = td->con; con; con = con->next) { /* only consider constraint if enabled */ - if (con->flag & (CONSTRAINT_DISABLE | CONSTRAINT_OFF)) + if (con->flag & (CONSTRAINT_DISABLE | CONSTRAINT_OFF)) { continue; - if (con->enforce == 0.0f) + } + if (con->enforce == 0.0f) { continue; + } /* we're only interested in Limit-Scale constraints */ if (con->type == CONSTRAINT_TYPE_SIZELIMIT) { bSizeLimitConstraint *data = con->data; /* only use it if it's tagged for this purpose */ - if ((data->flag2 & LIMIT_TRANSFORM) == 0) + if ((data->flag2 & LIMIT_TRANSFORM) == 0) { continue; + } /* do space conversions */ if (con->ownspace == CONSTRAINT_SPACE_WORLD) { @@ -3182,8 +3236,9 @@ static void constraintSizeLim(TransInfo *t, TransData *td) } else { /* Reset val if SINGLESIZE but using a constraint */ - if (td->flag & TD_SINGLESIZE) + if (td->flag & TD_SINGLESIZE) { return; + } /* extrace scale from matrix and apply back sign */ mat4_to_size(td->ext->size, cob.matrix); @@ -3388,11 +3443,13 @@ static void Bend(TransInfo *t, const int UNUSED(mval[2])) float delta[3]; float fac, fac_scaled; - if (td->flag & TD_NOACTION) + if (td->flag & TD_NOACTION) { break; + } - if (td->flag & TD_SKIP) + if (td->flag & TD_SKIP) { continue; + } if (UNLIKELY(values.angle == 0.0f)) { copy_v3_v3(td->loc, td->iloc); @@ -3576,10 +3633,12 @@ static void applyShear(TransInfo *t, const int UNUSED(mval[2])) unit_m3(smat); // Custom data signals shear direction - if (t->custom.mode.data == NULL) + if (t->custom.mode.data == NULL) { smat[1][0] = value; - else + } + else { smat[0][1] = value; + } copy_v3_v3(axismat_inv[0], t->orient_matrix[t->orient_axis_ortho]); copy_v3_v3(axismat_inv[2], t->orient_matrix[t->orient_axis]); @@ -3593,11 +3652,13 @@ static void applyShear(TransInfo *t, const int UNUSED(mval[2])) for (i = 0; i < tc->data_len; i++, td++) { const float *center, *co; - if (td->flag & TD_NOACTION) + if (td->flag & TD_NOACTION) { break; + } - if (td->flag & TD_SKIP) + if (td->flag & TD_SKIP) { continue; + } if (t->flag & T_EDIT) { mul_m3_series(tmat, td->smtx, totmat, td->mtx); @@ -3770,12 +3831,15 @@ static void TransMat3ToSize(float mat[3][3], float smat[3][3], float size[3]) mat3_to_rot_size(rmat, size, mat); /* first tried with dotproduct... but the sign flip is crucial */ - if (dot_v3v3(rmat[0], smat[0]) < 0.0f) + if (dot_v3v3(rmat[0], smat[0]) < 0.0f) { size[0] = -size[0]; - if (dot_v3v3(rmat[1], smat[1]) < 0.0f) + } + if (dot_v3v3(rmat[1], smat[1]) < 0.0f) { size[1] = -size[1]; - if (dot_v3v3(rmat[2], smat[2]) < 0.0f) + } + if (dot_v3v3(rmat[2], smat[2]) < 0.0f) { size[2] = -size[2]; + } } static void ElementResize(TransInfo *t, TransDataContainer *tc, TransData *td, float mat[3][3]) @@ -3840,8 +3904,9 @@ static void ElementResize(TransInfo *t, TransDataContainer *tc, TransData *td, f } else { /* Reset val if SINGLESIZE but using a constraint */ - if (td->flag & TD_SINGLESIZE) + if (td->flag & TD_SINGLESIZE) { *td->val = td->ival; + } td->ext->size[0] = td->ext->isize[0] * (1 + (fsize[0] - 1) * td->factor); td->ext->size[1] = td->ext->isize[1] * (1 + (fsize[1] - 1) * td->factor); @@ -3853,18 +3918,22 @@ static void ElementResize(TransInfo *t, TransDataContainer *tc, TransData *td, f } /* For individual element center, Editmode need to use iloc */ - if (t->flag & T_POINTS) + if (t->flag & T_POINTS) { sub_v3_v3v3(vec, td->iloc, center); - else + } + else { sub_v3_v3v3(vec, td->center, center); + } mul_m3_v3(tmat, vec); add_v3_v3(vec, center); - if (t->flag & T_POINTS) + if (t->flag & T_POINTS) { sub_v3_v3(vec, td->iloc); - else + } + else { sub_v3_v3(vec, td->center); + } /* grease pencil falloff */ if (t->options & CTX_GPENCIL_STROKES) { @@ -3946,11 +4015,13 @@ static void applyResize(TransInfo *t, const int UNUSED(mval[2])) FOREACH_TRANS_DATA_CONTAINER (t, tc) { TransData *td = tc->data; for (i = 0; i < tc->data_len; i++, td++) { - if (td->flag & TD_NOACTION) + if (td->flag & TD_NOACTION) { break; + } - if (td->flag & TD_SKIP) + if (td->flag & TD_SKIP) { continue; + } ElementResize(t, tc, td, mat); } @@ -3966,8 +4037,9 @@ static void applyResize(TransInfo *t, const int UNUSED(mval[2])) FOREACH_TRANS_DATA_CONTAINER (t, tc) { TransData *td = tc->data; - for (i = 0; i < tc->data_len; i++, td++) + for (i = 0; i < tc->data_len; i++, td++) { ElementResize(t, tc, td, mat); + } /* In proportional edit it can happen that */ /* vertices in the radius of the brush end */ @@ -4057,11 +4129,13 @@ static void applySkinResize(TransInfo *t, const int UNUSED(mval[2])) float tmat[3][3], smat[3][3]; float fsize[3]; - if (td->flag & TD_NOACTION) + if (td->flag & TD_NOACTION) { break; + } - if (td->flag & TD_SKIP) + if (td->flag & TD_SKIP) { continue; + } if (t->flag & T_EDIT) { mul_m3_m3m3(smat, mat, td->mtx); @@ -4160,11 +4234,13 @@ static void applyToSphere(TransInfo *t, const int UNUSED(mval[2])) TransData *td = tc->data; for (i = 0; i < tc->data_len; i++, td++) { float tratio; - if (td->flag & TD_NOACTION) + if (td->flag & TD_NOACTION) { break; + } - if (td->flag & TD_SKIP) + if (td->flag & TD_SKIP) { continue; + } sub_v3_v3v3(vec, td->iloc, tc->center_local); @@ -4218,8 +4294,9 @@ static void initRotation(TransInfo *t) t->num.unit_use_radians = (t->scene->unit.system_rotation == USER_UNIT_ROT_RADIANS); t->num.unit_type[0] = B_UNIT_ROTATION; - if (t->flag & T_2D_EDIT) + if (t->flag & T_2D_EDIT) { t->flag |= T_NO_CONSTRAINT; + } } /* Used by Transform Rotation and Transform Normal Rotation */ @@ -4514,11 +4591,13 @@ static void applyRotationValue(TransInfo *t, float angle, float axis[3]) TransData *td = tc->data; for (i = 0; i < tc->data_len; i++, td++) { - if (td->flag & TD_NOACTION) + if (td->flag & TD_NOACTION) { break; + } - if (td->flag & TD_SKIP) + if (td->flag & TD_SKIP) { continue; + } if (t->con.applyRot) { t->con.applyRot(t, tc, td, axis, NULL); @@ -4614,11 +4693,13 @@ static void applyTrackballValue(TransInfo *t, FOREACH_TRANS_DATA_CONTAINER (t, tc) { TransData *td = tc->data; for (i = 0; i < tc->data_len; i++, td++) { - if (td->flag & TD_NOACTION) + if (td->flag & TD_NOACTION) { break; + } - if (td->flag & TD_SKIP) + if (td->flag & TD_SKIP) { continue; + } if (t->flag & T_PROP_EDIT) { axis_angle_normalized_to_mat3(mat, axis, td->factor * angle); @@ -4952,13 +5033,16 @@ static void headerTranslation(TransInfo *t, const float vec[3], char str[UI_MAX_ if (t->flag & T_AUTOIK) { short chainlen = t->settings->autoik_chainlen; - if (chainlen) + if (chainlen) { BLI_snprintf(autoik, NUM_STR_REP_LEN, IFACE_("AutoIK-Len: %d"), chainlen); - else + } + else { autoik[0] = '\0'; + } } - else + else { autoik[0] = '\0'; + } if (t->con.mode & CON_APPLY) { switch (t->num.idx_max) { @@ -5074,11 +5158,13 @@ static void applyTranslationValue(TransInfo *t, const float vec[3]) TransData *td = tc->data; for (int i = 0; i < tc->data_len; i++, td++) { - if (td->flag & TD_NOACTION) + if (td->flag & TD_NOACTION) { break; + } - if (td->flag & TD_SKIP) + if (td->flag & TD_SKIP) { continue; + } float rotate_offset[3] = {0}; bool use_rotate_offset = false; @@ -5091,10 +5177,12 @@ static void applyTranslationValue(TransInfo *t, const float vec[3]) const float *original_normal; /* In pose mode, we want to align normals with Y axis of bones... */ - if (t->flag & T_POSE) + if (t->flag & T_POSE) { original_normal = td->axismtx[1]; - else + } + else { original_normal = td->axismtx[2]; + } rotation_between_vecs_to_mat3(mat, original_normal, t->tsnap.snapNormal); } @@ -5141,8 +5229,9 @@ static void applyTranslationValue(TransInfo *t, const float vec[3]) protectedTransBits(td->protectflag, tvec); - if (td->loc) + if (td->loc) { add_v3_v3v3(td->loc, td->iloc, tvec); + } constraintTransLim(t, td); } @@ -5285,11 +5374,13 @@ static void applyShrinkFatten(TransInfo *t, const int UNUSED(mval[2])) TransData *td = tc->data; for (i = 0; i < tc->data_len; i++, td++) { float tdistance; /* temp dist */ - if (td->flag & TD_NOACTION) + if (td->flag & TD_NOACTION) { break; + } - if (td->flag & TD_SKIP) + if (td->flag & TD_SKIP) { continue; + } /* get the final offset */ tdistance = distance * td->factor; @@ -5366,11 +5457,13 @@ static void applyTilt(TransInfo *t, const int UNUSED(mval[2])) FOREACH_TRANS_DATA_CONTAINER (t, tc) { TransData *td = tc->data; for (i = 0; i < tc->data_len; i++, td++) { - if (td->flag & TD_NOACTION) + if (td->flag & TD_NOACTION) { break; + } - if (td->flag & TD_SKIP) + if (td->flag & TD_SKIP) { continue; + } if (td->val) { *td->val = td->ival + final * td->factor; @@ -5443,18 +5536,21 @@ static void applyCurveShrinkFatten(TransInfo *t, const int UNUSED(mval[2])) FOREACH_TRANS_DATA_CONTAINER (t, tc) { TransData *td = tc->data; for (i = 0; i < tc->data_len; i++, td++) { - if (td->flag & TD_NOACTION) + if (td->flag & TD_NOACTION) { break; + } - if (td->flag & TD_SKIP) + if (td->flag & TD_SKIP) { continue; + } if (td->val) { *td->val = td->ival * ratio; /* apply PET */ *td->val = (*td->val * td->factor) + ((1.0f - td->factor) * td->ival); - if (*td->val <= 0.0f) + if (*td->val <= 0.0f) { *td->val = 0.001f; + } } } } @@ -5529,14 +5625,17 @@ static void applyMaskShrinkFatten(TransInfo *t, const int UNUSED(mval[2])) FOREACH_TRANS_DATA_CONTAINER (t, tc) { TransData *td = tc->data; for (i = 0; i < tc->data_len; i++, td++) { - if (td->flag & TD_NOACTION) + if (td->flag & TD_NOACTION) { break; + } - if (td->flag & TD_SKIP) + if (td->flag & TD_SKIP) { continue; + } - if (td->ival >= 0.001f) + if (td->ival >= 0.001f) { initial_feather = false; + } } } } @@ -5545,22 +5644,27 @@ static void applyMaskShrinkFatten(TransInfo *t, const int UNUSED(mval[2])) FOREACH_TRANS_DATA_CONTAINER (t, tc) { TransData *td = tc->data; for (td = tc->data, i = 0; i < tc->data_len; i++, td++) { - if (td->flag & TD_NOACTION) + if (td->flag & TD_NOACTION) { break; + } - if (td->flag & TD_SKIP) + if (td->flag & TD_SKIP) { continue; + } if (td->val) { - if (initial_feather) + if (initial_feather) { *td->val = td->ival + (ratio - 1.0f) * 0.01f; - else + } + else { *td->val = td->ival * ratio; + } /* apply PET */ *td->val = (*td->val * td->factor) + ((1.0f - td->factor) * td->ival); - if (*td->val <= 0.0f) + if (*td->val <= 0.0f) { *td->val = 0.001f; + } } } } @@ -5630,18 +5734,21 @@ static void applyGPShrinkFatten(TransInfo *t, const int UNUSED(mval[2])) FOREACH_TRANS_DATA_CONTAINER (t, tc) { TransData *td = tc->data; for (i = 0; i < tc->data_len; i++, td++) { - if (td->flag & TD_NOACTION) + if (td->flag & TD_NOACTION) { break; + } - if (td->flag & TD_SKIP) + if (td->flag & TD_SKIP) { continue; + } if (td->val) { *td->val = td->ival * ratio; /* apply PET */ *td->val = (*td->val * td->factor) + ((1.0f - td->factor) * td->ival); - if (*td->val <= 0.0f) + if (*td->val <= 0.0f) { *td->val = 0.001f; + } } } } @@ -5709,11 +5816,13 @@ static void applyGPOpacity(TransInfo *t, const int UNUSED(mval[2])) FOREACH_TRANS_DATA_CONTAINER (t, tc) { TransData *td = tc->data; for (i = 0; i < tc->data_len; i++, td++) { - if (td->flag & TD_NOACTION) + if (td->flag & TD_NOACTION) { break; + } - if (td->flag & TD_SKIP) + if (td->flag & TD_SKIP) { continue; + } if (td->val) { *td->val = td->ival * ratio; @@ -5788,11 +5897,13 @@ static void applyPushPull(TransInfo *t, const int UNUSED(mval[2])) FOREACH_TRANS_DATA_CONTAINER (t, tc) { TransData *td = tc->data; for (i = 0; i < tc->data_len; i++, td++) { - if (td->flag & TD_NOACTION) + if (td->flag & TD_NOACTION) { break; + } - if (td->flag & TD_SKIP) + if (td->flag & TD_SKIP) { continue; + } sub_v3_v3v3(vec, tc->center_local, td->center); if (t->con.applyRot && t->con.mode & CON_APPLY) { @@ -5870,31 +5981,38 @@ static void applyBevelWeight(TransInfo *t, const int UNUSED(mval[2])) outputNumInput(&(t->num), c, &t->scene->unit); - if (weight >= 0.0f) + if (weight >= 0.0f) { BLI_snprintf(str, sizeof(str), IFACE_("Bevel Weight: +%s %s"), c, t->proptext); - else + } + else { BLI_snprintf(str, sizeof(str), IFACE_("Bevel Weight: %s %s"), c, t->proptext); + } } else { /* default header print */ - if (weight >= 0.0f) + if (weight >= 0.0f) { BLI_snprintf(str, sizeof(str), IFACE_("Bevel Weight: +%.3f %s"), weight, t->proptext); - else + } + else { BLI_snprintf(str, sizeof(str), IFACE_("Bevel Weight: %.3f %s"), weight, t->proptext); + } } FOREACH_TRANS_DATA_CONTAINER (t, tc) { TransData *td = tc->data; for (i = 0; i < tc->data_len; i++, td++) { - if (td->flag & TD_NOACTION) + if (td->flag & TD_NOACTION) { break; + } if (td->val) { *td->val = td->ival + weight * td->factor; - if (*td->val < 0.0f) + if (*td->val < 0.0f) { *td->val = 0.0f; - if (*td->val > 1.0f) + } + if (*td->val > 1.0f) { *td->val = 1.0f; + } } } } @@ -5953,34 +6071,42 @@ static void applyCrease(TransInfo *t, const int UNUSED(mval[2])) outputNumInput(&(t->num), c, &t->scene->unit); - if (crease >= 0.0f) + if (crease >= 0.0f) { BLI_snprintf(str, sizeof(str), IFACE_("Crease: +%s %s"), c, t->proptext); - else + } + else { BLI_snprintf(str, sizeof(str), IFACE_("Crease: %s %s"), c, t->proptext); + } } else { /* default header print */ - if (crease >= 0.0f) + if (crease >= 0.0f) { BLI_snprintf(str, sizeof(str), IFACE_("Crease: +%.3f %s"), crease, t->proptext); - else + } + else { BLI_snprintf(str, sizeof(str), IFACE_("Crease: %.3f %s"), crease, t->proptext); + } } FOREACH_TRANS_DATA_CONTAINER (t, tc) { TransData *td = tc->data; for (i = 0; i < tc->data_len; i++, td++) { - if (td->flag & TD_NOACTION) + if (td->flag & TD_NOACTION) { break; + } - if (td->flag & TD_SKIP) + if (td->flag & TD_SKIP) { continue; + } if (td->val) { *td->val = td->ival + crease * td->factor; - if (*td->val < 0.0f) + if (*td->val < 0.0f) { *td->val = 0.0f; - if (*td->val > 1.0f) + } + if (*td->val > 1.0f) { *td->val = 1.0f; + } } } } @@ -6035,10 +6161,11 @@ static void headerBoneSize(TransInfo *t, const float vec[3], char str[UI_MAX_DRA /* hmm... perhaps the y-axis values don't need to be shown? */ if (t->con.mode & CON_APPLY) { - if (t->num.idx_max == 0) + if (t->num.idx_max == 0) { BLI_snprintf( str, UI_MAX_DRAW_STR, IFACE_("ScaleB: %s%s %s"), &tvec[0], t->con.text, t->proptext); - else + } + else { BLI_snprintf(str, UI_MAX_DRAW_STR, IFACE_("ScaleB: %s : %s : %s%s %s"), @@ -6047,6 +6174,7 @@ static void headerBoneSize(TransInfo *t, const float vec[3], char str[UI_MAX_DRA &tvec[NUM_STR_REP_LEN * 2], t->con.text, t->proptext); + } } else { BLI_snprintf(str, @@ -6110,11 +6238,13 @@ static void applyBoneSize(TransInfo *t, const int UNUSED(mval[2])) FOREACH_TRANS_DATA_CONTAINER (t, tc) { TransData *td = tc->data; for (i = 0; i < tc->data_len; i++, td++) { - if (td->flag & TD_NOACTION) + if (td->flag & TD_NOACTION) { break; + } - if (td->flag & TD_SKIP) + if (td->flag & TD_SKIP) { continue; + } ElementBoneSize(t, tc, td, mat); } @@ -6180,18 +6310,22 @@ static void applyBoneEnvelope(TransInfo *t, const int UNUSED(mval[2])) FOREACH_TRANS_DATA_CONTAINER (t, tc) { TransData *td = tc->data; for (i = 0; i < tc->data_len; i++, td++) { - if (td->flag & TD_NOACTION) + if (td->flag & TD_NOACTION) { break; + } - if (td->flag & TD_SKIP) + if (td->flag & TD_SKIP) { continue; + } if (td->val) { /* if the old/original value was 0.0f, then just use ratio */ - if (td->ival) + if (td->ival) { *td->val = td->ival * ratio; - else + } + else { *td->val = ratio; + } } } } @@ -6837,8 +6971,9 @@ static void calcEdgeSlide_mval_range(TransInfo *t, float dist_sq; int j, l_nr; - if (BM_elem_flag_test(e_other, BM_ELEM_SELECT)) + if (BM_elem_flag_test(e_other, BM_ELEM_SELECT)) { continue; + } /* This test is only relevant if object is not wire-drawn! See [#32068]. */ if (use_occlude_geometry && @@ -7080,15 +7215,18 @@ static bool createEdgeSlideVerts_double_side(TransInfo *t, TransDataContainer *t v = NULL; BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) { - if (BM_elem_flag_test(v, BM_ELEM_TAG)) + if (BM_elem_flag_test(v, BM_ELEM_TAG)) { break; + } } - if (!v) + if (!v) { break; + } - if (!v->e) + if (!v->e) { continue; + } v_first = v; @@ -7103,8 +7241,9 @@ static bool createEdgeSlideVerts_double_side(TransInfo *t, TransDataContainer *t break; } - if (!BM_elem_flag_test(BM_edge_other_vert(e, v), BM_ELEM_TAG)) + if (!BM_elem_flag_test(BM_edge_other_vert(e, v), BM_ELEM_TAG)) { break; + } v = BM_edge_other_vert(e, v); } while (e != v_first->e); @@ -7258,10 +7397,12 @@ static bool createEdgeSlideVerts_double_side(TransInfo *t, TransDataContainer *t else { if (l_a || l_b) { /* find the opposite loop if it was missing previously */ - if (l_a == NULL && l_b && (l_b->radial_next != l_b)) + if (l_a == NULL && l_b && (l_b->radial_next != l_b)) { l_a = l_b->radial_next; - else if (l_b == NULL && l_a && (l_a->radial_next != l_a)) + } + else if (l_b == NULL && l_a && (l_a->radial_next != l_a)) { l_b = l_a->radial_next; + } } else if (e->l != NULL) { /* if there are non-contiguous faces, we can still recover @@ -7562,8 +7703,9 @@ void freeEdgeSlideVerts(TransInfo *UNUSED(t), { EdgeSlideData *sld = custom_data->data; - if (!sld) + if (!sld) { return; + } freeEdgeSlideTempFaces(sld); @@ -7754,12 +7896,14 @@ static void drawEdgeSlide(TransInfo *t) GPU_point_size(ctrl_size); immBegin(GPU_PRIM_POINTS, 1); if (slp->flipped) { - if (curr_sv->v_side[1]) + if (curr_sv->v_side[1]) { immVertex3fv(pos, curr_sv->v_side[1]->co); + } } else { - if (curr_sv->v_side[0]) + if (curr_sv->v_side[0]) { immVertex3fv(pos, curr_sv->v_side[0]->co); + } } immEnd(); @@ -8209,8 +8353,9 @@ void freeVertSlideVerts(TransInfo *UNUSED(t), { VertSlideData *sld = custom_data->data; - if (!sld) + if (!sld) { return; + } freeVertSlideTempFaces(sld); @@ -8622,11 +8767,13 @@ static void applyBoneRoll(TransInfo *t, const int UNUSED(mval[2])) FOREACH_TRANS_DATA_CONTAINER (t, tc) { TransData *td = tc->data; for (i = 0; i < tc->data_len; i++, td++) { - if (td->flag & TD_NOACTION) + if (td->flag & TD_NOACTION) { break; + } - if (td->flag & TD_SKIP) + if (td->flag & TD_SKIP) { continue; + } *(td->val) = td->ival - final; } @@ -8692,34 +8839,42 @@ static void applyBakeTime(TransInfo *t, const int mval[2]) outputNumInput(&(t->num), c, &t->scene->unit); - if (time >= 0.0f) + if (time >= 0.0f) { BLI_snprintf(str, sizeof(str), IFACE_("Time: +%s %s"), c, t->proptext); - else + } + else { BLI_snprintf(str, sizeof(str), IFACE_("Time: %s %s"), c, t->proptext); + } } else { /* default header print */ - if (time >= 0.0f) + if (time >= 0.0f) { BLI_snprintf(str, sizeof(str), IFACE_("Time: +%.3f %s"), time, t->proptext); - else + } + else { BLI_snprintf(str, sizeof(str), IFACE_("Time: %.3f %s"), time, t->proptext); + } } FOREACH_TRANS_DATA_CONTAINER (t, tc) { TransData *td = tc->data; for (i = 0; i < tc->data_len; i++, td++) { - if (td->flag & TD_NOACTION) + if (td->flag & TD_NOACTION) { break; + } - if (td->flag & TD_SKIP) + if (td->flag & TD_SKIP) { continue; + } if (td->val) { *td->val = td->ival + time * td->factor; - if (td->ext->size && *td->val < *td->ext->size) + if (td->ext->size && *td->val < *td->ext->size) { *td->val = *td->ext->size; - if (td->ext->quat && *td->val > *td->ext->quat) + } + if (td->ext->quat && *td->val > *td->ext->quat) { *td->val = *td->ext->quat; + } } } } @@ -8774,11 +8929,13 @@ static void applyMirror(TransInfo *t, const int UNUSED(mval[2])) FOREACH_TRANS_DATA_CONTAINER (t, tc) { TransData *td = tc->data; for (i = 0; i < tc->data_len; i++, td++) { - if (td->flag & TD_NOACTION) + if (td->flag & TD_NOACTION) { break; + } - if (td->flag & TD_SKIP) + if (td->flag & TD_SKIP) { continue; + } ElementResize(t, tc, td, mat); } @@ -8796,11 +8953,13 @@ static void applyMirror(TransInfo *t, const int UNUSED(mval[2])) FOREACH_TRANS_DATA_CONTAINER (t, tc) { TransData *td = tc->data; for (i = 0; i < tc->data_len; i++, td++) { - if (td->flag & TD_NOACTION) + if (td->flag & TD_NOACTION) { break; + } - if (td->flag & TD_SKIP) + if (td->flag & TD_SKIP) { continue; + } ElementResize(t, tc, td, mat); } @@ -8808,10 +8967,12 @@ static void applyMirror(TransInfo *t, const int UNUSED(mval[2])) recalcData(t); - if (t->flag & T_2D_EDIT) + if (t->flag & T_2D_EDIT) { ED_area_status_text(t->sa, IFACE_("Select a mirror axis (X, Y)")); - else + } + else { ED_area_status_text(t->sa, IFACE_("Select a mirror axis (X, Y, Z)")); + } } } /** \} */ @@ -8843,11 +9004,13 @@ static void applyAlign(TransInfo *t, const int UNUSED(mval[2])) for (i = 0; i < tc->data_len; i++, td++) { float mat[3][3], invmat[3][3]; - if (td->flag & TD_NOACTION) + if (td->flag & TD_NOACTION) { break; + } - if (td->flag & TD_SKIP) + if (td->flag & TD_SKIP) { continue; + } /* around local centers */ if (t->flag & (T_OBJECT | T_POSE)) { @@ -8937,11 +9100,13 @@ static void applySeqSlideValue(TransInfo *t, const float val[2]) FOREACH_TRANS_DATA_CONTAINER (t, tc) { TransData *td = tc->data; for (i = 0; i < tc->data_len; i++, td++) { - if (td->flag & TD_NOACTION) + if (td->flag & TD_NOACTION) { break; + } - if (td->flag & TD_SKIP) + if (td->flag & TD_SKIP) { continue; + } madd_v2_v2v2fl(td->loc, td->iloc, val, td->factor); } @@ -8997,20 +9162,23 @@ static short getAnimEdit_SnapMode(TransInfo *t) if (t->spacetype == SPACE_ACTION) { SpaceAction *saction = (SpaceAction *)t->sa->spacedata.first; - if (saction) + if (saction) { autosnap = saction->autosnap; + } } else if (t->spacetype == SPACE_GRAPH) { SpaceGraph *sipo = (SpaceGraph *)t->sa->spacedata.first; - if (sipo) + if (sipo) { autosnap = sipo->autosnap; + } } else if (t->spacetype == SPACE_NLA) { SpaceNla *snla = (SpaceNla *)t->sa->spacedata.first; - if (snla) + if (snla) { autosnap = snla->autosnap; + } } else { autosnap = SACTSNAP_OFF; @@ -9020,10 +9188,12 @@ static short getAnimEdit_SnapMode(TransInfo *t) * - when toggling on, prefer nearest frame over 1.0 frame increments */ if (t->modifiers & MOD_SNAP_INVERT) { - if (autosnap) + if (autosnap) { autosnap = SACTSNAP_OFF; - else + } + else { autosnap = SACTSNAP_FRAME; + } } return autosnap; @@ -9042,10 +9212,12 @@ static void doAnimEdit_SnapFrame( double val; /* convert frame to nla-action time (if needed) */ - if (adt) + if (adt) { val = BKE_nla_tweakedit_remap(adt, *(td->val), NLATIME_CONVERT_MAP); - else + } + else { val = *(td->val); + } /* do the snapping to nearest frame/second */ if (autosnap == SACTSNAP_FRAME) { @@ -9056,30 +9228,36 @@ static void doAnimEdit_SnapFrame( } /* convert frame out of nla-action time */ - if (adt) + if (adt) { *(td->val) = BKE_nla_tweakedit_remap(adt, val, NLATIME_CONVERT_UNMAP); - else + } + else { *(td->val) = val; + } } /* snap key to nearest marker? */ else if (autosnap == SACTSNAP_MARKER) { float val; /* convert frame to nla-action time (if needed) */ - if (adt) + if (adt) { val = BKE_nla_tweakedit_remap(adt, *(td->val), NLATIME_CONVERT_MAP); - else + } + else { val = *(td->val); + } /* snap to nearest marker */ // TODO: need some more careful checks for where data comes from val = (float)ED_markers_find_nearest_marker_time(&t->scene->markers, val); /* convert frame out of nla-action time */ - if (adt) + if (adt) { *(td->val) = BKE_nla_tweakedit_remap(adt, val, NLATIME_CONVERT_UNMAP); - else + } + else { *(td->val) = val; + } } /* If the handles are to be moved too @@ -9158,14 +9336,18 @@ static void headerTimeTranslate(TransInfo *t, char str[UI_MAX_DRAW_STR]) val = (float)((double)val / secf); } - if (autosnap == SACTSNAP_FRAME) + if (autosnap == SACTSNAP_FRAME) { BLI_snprintf(&tvec[0], NUM_STR_REP_LEN, "%d.00 (%.4f)", (int)val, val); - else if (autosnap == SACTSNAP_SECOND) + } + else if (autosnap == SACTSNAP_SECOND) { BLI_snprintf(&tvec[0], NUM_STR_REP_LEN, "%d.00 sec (%.4f)", (int)val, val); - else if (autosnap == SACTSNAP_TSTEP) + } + else if (autosnap == SACTSNAP_TSTEP) { BLI_snprintf(&tvec[0], NUM_STR_REP_LEN, "%.4f sec", val); - else + } + else { BLI_snprintf(&tvec[0], NUM_STR_REP_LEN, "%.4f", val); + } } ofs += BLI_snprintf(str, UI_MAX_DRAW_STR, IFACE_("DeltaX: %s"), &tvec[0]); @@ -9302,13 +9484,16 @@ static void initTimeSlide(TransInfo *t) float val = *(td->val); /* strip/action time to global (mapped) time */ - if (adt) + if (adt) { val = BKE_nla_tweakedit_remap(adt, val, NLATIME_CONVERT_MAP); + } - if (min > val) + if (min > val) { min = val; - if (max < val) + } + if (max < val) { max = val; + } } } @@ -9508,10 +9693,12 @@ static void headerTimeScale(TransInfo *t, char str[UI_MAX_DRAW_STR]) { char tvec[NUM_STR_REP_LEN * 3]; - if (hasNumInput(&t->num)) + if (hasNumInput(&t->num)) { outputNumInput(&(t->num), tvec, &t->scene->unit); - else + } + else { BLI_snprintf(&tvec[0], NUM_STR_REP_LEN, "%.4f", t->values[0]); + } BLI_snprintf(str, UI_MAX_DRAW_STR, IFACE_("ScaleX: %s"), &tvec[0]); } @@ -9547,8 +9734,9 @@ static void applyTimeScaleValue(TransInfo *t) fac = ((fac - 1.0f) * td->factor) + 1; /* check if any need to apply nla-mapping */ - if (adt) + if (adt) { startx = BKE_nla_tweakedit_remap(adt, startx, NLATIME_CONVERT_UNMAP); + } /* now, calculate the new value */ *(td->val) = ((td->ival - startx) * fac) + startx; diff --git a/source/blender/editors/transform/transform_constraints.c b/source/blender/editors/transform/transform_constraints.c index 9414d5862b6..ee08eb20ea3 100644 --- a/source/blender/editors/transform/transform_constraints.c +++ b/source/blender/editors/transform/transform_constraints.c @@ -129,14 +129,17 @@ static void postConstraintChecks(TransInfo *t, float vec[3], float pvec[3]) snapGridIncrement(t, vec); if (t->flag & T_NULL_ONE) { - if (!(t->con.mode & CON_AXIS0)) + if (!(t->con.mode & CON_AXIS0)) { vec[0] = 1.0f; + } - if (!(t->con.mode & CON_AXIS1)) + if (!(t->con.mode & CON_AXIS1)) { vec[1] = 1.0f; + } - if (!(t->con.mode & CON_AXIS2)) + if (!(t->con.mode & CON_AXIS2)) { vec[2] = 1.0f; + } } if (applyNumInput(&t->num, vec)) { @@ -221,10 +224,12 @@ static void axisProjection(const TransInfo *t, factor = dot_v3v3(t->viewinv[1], vec) * 2.0f; /* Since camera distance is quite relative, use quadratic relationship. * holding shift can compensate. */ - if (factor < 0.0f) + if (factor < 0.0f) { factor *= -factor; - else + } + else { factor *= factor; + } /* -factor makes move down going backwards */ normalize_v3_v3_length(out, axis, -factor); @@ -267,12 +272,15 @@ static void axisProjection(const TransInfo *t, /* possible some values become nan when * viewpoint and object are both zero */ - if (!isfinite(out[0])) + if (!isfinite(out[0])) { out[0] = 0.0f; - if (!isfinite(out[1])) + } + if (!isfinite(out[1])) { out[1] = 0.0f; - if (!isfinite(out[2])) + } + if (!isfinite(out[2])) { out[2] = 0.0f; + } } } } @@ -741,12 +749,15 @@ void drawConstraint(TransInfo *t) { TransCon *tc = &(t->con); - if (!ELEM(t->spacetype, SPACE_VIEW3D, SPACE_IMAGE, SPACE_NODE)) + if (!ELEM(t->spacetype, SPACE_VIEW3D, SPACE_IMAGE, SPACE_NODE)) { return; - if (!(tc->mode & CON_APPLY)) + } + if (!(tc->mode & CON_APPLY)) { return; - if (t->flag & T_NO_CONSTRAINT) + } + if (t->flag & T_NO_CONSTRAINT) { return; + } if (tc->drawExtra) { tc->drawExtra(t); @@ -764,8 +775,9 @@ void drawConstraint(TransInfo *t) drawLine(t, t->center_global, tc->mtx[2], 'Z', 0); depth_test_enabled = GPU_depth_test_enabled(); - if (depth_test_enabled) + if (depth_test_enabled) { GPU_depth_test(false); + } const uint shdr_pos = GPU_vertformat_attr_add( immVertexFormat(), "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); @@ -788,8 +800,9 @@ void drawConstraint(TransInfo *t) immUnbindProgram(); - if (depth_test_enabled) + if (depth_test_enabled) { GPU_depth_test(true); + } } if (tc->mode & CON_AXIS0) { @@ -841,8 +854,9 @@ void drawPropCircle(const struct bContext *C, TransInfo *t) } depth_test_enabled = GPU_depth_test_enabled(); - if (depth_test_enabled) + if (depth_test_enabled) { GPU_depth_test(false); + } uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); @@ -855,8 +869,9 @@ void drawPropCircle(const struct bContext *C, TransInfo *t) immUnbindProgram(); - if (depth_test_enabled) + if (depth_test_enabled) { GPU_depth_test(true); + } GPU_matrix_pop(); } @@ -990,8 +1005,9 @@ void selectConstraint(TransInfo *t) void postSelectConstraint(TransInfo *t) { - if (!(t->con.mode & CON_SELECT)) + if (!(t->con.mode & CON_SELECT)) { return; + } t->con.mode &= ~CON_AXIS0; t->con.mode &= ~CON_AXIS1; @@ -1150,14 +1166,17 @@ bool isLockConstraint(TransInfo *t) { int mode = t->con.mode; - if ((mode & (CON_AXIS0 | CON_AXIS1)) == (CON_AXIS0 | CON_AXIS1)) + if ((mode & (CON_AXIS0 | CON_AXIS1)) == (CON_AXIS0 | CON_AXIS1)) { return true; + } - if ((mode & (CON_AXIS1 | CON_AXIS2)) == (CON_AXIS1 | CON_AXIS2)) + if ((mode & (CON_AXIS1 | CON_AXIS2)) == (CON_AXIS1 | CON_AXIS2)) { return true; + } - if ((mode & (CON_AXIS0 | CON_AXIS2)) == (CON_AXIS0 | CON_AXIS2)) + if ((mode & (CON_AXIS0 | CON_AXIS2)) == (CON_AXIS0 | CON_AXIS2)) { return true; + } return false; } @@ -1174,14 +1193,17 @@ int getConstraintSpaceDimension(TransInfo *t) { int n = 0; - if (t->con.mode & CON_AXIS0) + if (t->con.mode & CON_AXIS0) { n++; + } - if (t->con.mode & CON_AXIS1) + if (t->con.mode & CON_AXIS1) { n++; + } - if (t->con.mode & CON_AXIS2) + if (t->con.mode & CON_AXIS2) { n++; + } return n; /* diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c index 49817db35a8..e4f2adff77d 100644 --- a/source/blender/editors/transform/transform_conversions.c +++ b/source/blender/editors/transform/transform_conversions.c @@ -146,12 +146,15 @@ static int trans_data_compare_dist(const void *a, const void *b) const TransData *td_a = (const TransData *)a; const TransData *td_b = (const TransData *)b; - if (td_a->dist < td_b->dist) + if (td_a->dist < td_b->dist) { return -1; - else if (td_a->dist > td_b->dist) + } + else if (td_a->dist > td_b->dist) { return 1; - else + } + else { return 0; + } } static int trans_data_compare_rdist(const void *a, const void *b) @@ -159,12 +162,15 @@ static int trans_data_compare_rdist(const void *a, const void *b) const TransData *td_a = (const TransData *)a; const TransData *td_b = (const TransData *)b; - if (td_a->rdist < td_b->rdist) + if (td_a->rdist < td_b->rdist) { return -1; - else if (td_a->rdist > td_b->rdist) + } + else if (td_a->rdist > td_b->rdist) { return 1; - else + } + else { return 0; + } } static void sort_trans_data_dist_container(const TransInfo *t, TransDataContainer *tc) @@ -463,10 +469,12 @@ static void createTransEdge(TransInfo *t) BM_ITER_MESH (eed, &iter, em->bm, BM_EDGES_OF_MESH) { if (!BM_elem_flag_test(eed, BM_ELEM_HIDDEN)) { - if (BM_elem_flag_test(eed, BM_ELEM_SELECT)) + if (BM_elem_flag_test(eed, BM_ELEM_SELECT)) { countsel++; - if (is_prop_edit) + } + if (is_prop_edit) { count++; + } } } @@ -508,10 +516,12 @@ static void createTransEdge(TransInfo *t) mid_v3_v3v3(td->center, eed->v1->co, eed->v2->co); td->loc = NULL; - if (BM_elem_flag_test(eed, BM_ELEM_SELECT)) + if (BM_elem_flag_test(eed, BM_ELEM_SELECT)) { td->flag = TD_SELECTED; - else + } + else { td->flag = 0; + } copy_m3_m3(td->smtx, smtx); copy_m3_m3(td->mtx, mtx); @@ -538,10 +548,12 @@ static bKinematicConstraint *has_targetless_ik(bPoseChannel *pchan) if (con->type == CONSTRAINT_TYPE_KINEMATIC && (con->enforce != 0.0f)) { bKinematicConstraint *data = con->data; - if (data->tar == NULL) + if (data->tar == NULL) { return data; - if (data->tar->type == OB_ARMATURE && data->subtarget[0] == 0) + } + if (data->tar->type == OB_ARMATURE && data->subtarget[0] == 0) { return data; + } } } return NULL; @@ -565,18 +577,21 @@ static short apply_targetless_ik(Object *ob) segcount = 0; /* exclude tip from chain? */ - if (!(data->flag & CONSTRAINT_IK_TIP)) + if (!(data->flag & CONSTRAINT_IK_TIP)) { parchan = pchan->parent; - else + } + else { parchan = pchan; + } /* Find the chain's root & count the segments needed */ for (; parchan; parchan = parchan->parent) { chanlist[segcount] = parchan; segcount++; - if (segcount == data->rootbone || segcount > 255) + if (segcount == data->rootbone || segcount > 255) { break; // 255 is weak + } } for (; segcount; segcount--) { Bone *bone; @@ -605,22 +620,28 @@ static short apply_targetless_ik(Object *ob) * the values here, or else there are huge discrepancies between IK-solver (interactive) * and applied poses. */ - if (parchan->rotmode > 0) + if (parchan->rotmode > 0) { mat3_to_eulO(parchan->eul, parchan->rotmode, rmat3); - else if (parchan->rotmode == ROT_MODE_AXISANGLE) + } + else if (parchan->rotmode == ROT_MODE_AXISANGLE) { mat3_to_axis_angle(parchan->rotAxis, &parchan->rotAngle, rmat3); - else + } + else { mat3_to_quat(parchan->quat, rmat3); + } /* for size, remove rotation */ /* causes problems with some constraints (so apply only if needed) */ if (data->flag & CONSTRAINT_IK_STRETCH) { - if (parchan->rotmode > 0) + if (parchan->rotmode > 0) { eulO_to_mat3(qrmat, parchan->eul, parchan->rotmode); - else if (parchan->rotmode == ROT_MODE_AXISANGLE) + } + else if (parchan->rotmode == ROT_MODE_AXISANGLE) { axis_angle_to_mat3(qrmat, parchan->rotAxis, parchan->rotAngle); - else + } + else { quat_to_mat3(qrmat, parchan->quat); + } invert_m3_m3(imat3, qrmat); mul_m3_m3m3(smat, rmat3, imat3); @@ -707,10 +728,12 @@ static void add_pose_transdata( float rpmat[3][3]; BKE_bone_parent_transform_calc_from_pchan(pchan, &bpt); - if (t->mode == TFM_TRANSLATION) + if (t->mode == TFM_TRANSLATION) { copy_m3_m4(pmat, bpt.loc_mat); - else + } + else { copy_m3_m4(pmat, bpt.rotscale_mat); + } /* Grrr! Exceptional case: When translating pose bones that are either Hinge or NoLocal, * and want align snapping, we just need both loc_mat and rotscale_mat. @@ -827,16 +850,19 @@ int count_set_pose_transflags(Object *ob, for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) { bone = pchan->bone; if (PBONE_VISIBLE(arm, bone)) { - if ((bone->flag & BONE_SELECTED)) + if ((bone->flag & BONE_SELECTED)) { bone->flag |= BONE_TRANSFORM; - else + } + else { bone->flag &= ~BONE_TRANSFORM; + } bone->flag &= ~BONE_HINGE_CHILD_TRANSFORM; bone->flag &= ~BONE_TRANSFORM_CHILD; } - else + else { bone->flag &= ~BONE_TRANSFORM; + } } /* make sure no bone can be transformed when a parent is transformed */ @@ -844,8 +870,9 @@ int count_set_pose_transflags(Object *ob, if (!ELEM(mode, TFM_BONESIZE, TFM_BONE_ENVELOPE_DIST)) { for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) { bone = pchan->bone; - if (bone->flag & BONE_TRANSFORM) + if (bone->flag & BONE_TRANSFORM) { bone_children_clear_transflag(mode, around, &bone->childbase); + } } } /* now count, and check if we have autoIK or have to switch from translate to rotate */ @@ -992,8 +1019,9 @@ static void pose_grab_with_ik_clear(Main *bmain, Object *ob) continue; } pchan->constflag |= PCHAN_HAS_IK; - if (data->tar == NULL || (data->tar->type == OB_ARMATURE && data->subtarget[0] == 0)) + if (data->tar == NULL || (data->tar->type == OB_ARMATURE && data->subtarget[0] == 0)) { pchan->constflag |= PCHAN_HAS_TARGET; + } } } } @@ -1012,8 +1040,9 @@ static short pose_grab_with_ik_add(bPoseChannel *pchan) bConstraint *con; /* Sanity check */ - if (pchan == NULL) + if (pchan == NULL) { return 0; + } /* Rule: not if there's already an IK on this channel */ for (con = pchan->constraints.first; con; con = con->next) { @@ -1035,12 +1064,15 @@ static short pose_grab_with_ik_add(bPoseChannel *pchan) for (; pchan; pchan = pchan->parent) { /* here, we set ik-settings for bone from pchan->protectflag */ // XXX: careful with quats/axis-angle rotations where we're locking 4d components - if (pchan->protectflag & OB_LOCK_ROTX) + if (pchan->protectflag & OB_LOCK_ROTX) { pchan->ikflag |= BONE_IK_NO_XDOF_TEMP; - if (pchan->protectflag & OB_LOCK_ROTY) + } + if (pchan->protectflag & OB_LOCK_ROTY) { pchan->ikflag |= BONE_IK_NO_YDOF_TEMP; - if (pchan->protectflag & OB_LOCK_ROTZ) + } + if (pchan->protectflag & OB_LOCK_ROTZ) { pchan->ikflag |= BONE_IK_NO_ZDOF_TEMP; + } } } @@ -1048,8 +1080,9 @@ static short pose_grab_with_ik_add(bPoseChannel *pchan) } } - if ((con->flag & CONSTRAINT_DISABLE) == 0 && (con->enforce != 0.0f)) + if ((con->flag & CONSTRAINT_DISABLE) == 0 && (con->enforce != 0.0f)) { return 0; + } } } @@ -1063,8 +1096,9 @@ static short pose_grab_with_ik_add(bPoseChannel *pchan) /* if exists, use values from last targetless (but disabled) IK-constraint as base */ *data = *targetless; } - else + else { data->flag = CONSTRAINT_IK_TIP; + } data->flag |= CONSTRAINT_IK_TEMP | CONSTRAINT_IK_AUTO | CONSTRAINT_IK_POS; copy_v3_v3(data->grabtarget, pchan->pose_tail); @@ -1076,21 +1110,26 @@ static short pose_grab_with_ik_add(bPoseChannel *pchan) do { /* here, we set ik-settings for bone from pchan->protectflag */ // XXX: careful with quats/axis-angle rotations where we're locking 4d components - if (pchan->protectflag & OB_LOCK_ROTX) + if (pchan->protectflag & OB_LOCK_ROTX) { pchan->ikflag |= BONE_IK_NO_XDOF_TEMP; - if (pchan->protectflag & OB_LOCK_ROTY) + } + if (pchan->protectflag & OB_LOCK_ROTY) { pchan->ikflag |= BONE_IK_NO_YDOF_TEMP; - if (pchan->protectflag & OB_LOCK_ROTZ) + } + if (pchan->protectflag & OB_LOCK_ROTZ) { pchan->ikflag |= BONE_IK_NO_ZDOF_TEMP; + } /* now we count this pchan as being included */ data->rootbone++; /* continue to parent, but only if we're connected to it */ - if (pchan->bone->flag & BONE_CONNECTED) + if (pchan->bone->flag & BONE_CONNECTED) { pchan = pchan->parent; - else + } + else { pchan = NULL; + } } while (pchan); /* make a copy of maximum chain-length */ @@ -1114,8 +1153,9 @@ static short pose_grab_with_ik_children(bPose *pose, Bone *bone) } if (wentdeeper == 0) { bPoseChannel *pchan = BKE_pose_channel_find_name(pose, bone->name); - if (pchan) + if (pchan) { added += pose_grab_with_ik_add(pchan); + } } return added; @@ -1129,8 +1169,9 @@ static short pose_grab_with_ik(Main *bmain, Object *ob) Bone *bonec; short tot_ik = 0; - if ((ob == NULL) || (ob->pose == NULL) || (ob->mode & OB_MODE_POSE) == 0) + if ((ob == NULL) || (ob->pose == NULL) || (ob->mode & OB_MODE_POSE) == 0) { return 0; + } arm = ob->data; @@ -1145,18 +1186,21 @@ static short pose_grab_with_ik(Main *bmain, Object *ob) break; } } - if ((pchan->bone->flag & BONE_CONNECTED) == 0 && (bonec == NULL)) + if ((pchan->bone->flag & BONE_CONNECTED) == 0 && (bonec == NULL)) { continue; + } /* rule: if selected Bone is not a root bone, it gets a temporal IK */ if (pchan->parent) { /* only adds if there's no IK yet (and no parent bone was selected) */ for (parent = pchan->parent; parent; parent = parent->parent) { - if (parent->bone->flag & BONE_SELECTED) + if (parent->bone->flag & BONE_SELECTED) { break; + } } - if (parent == NULL) + if (parent == NULL) { tot_ik += pose_grab_with_ik_add(pchan); + } } else { /* rule: go over the children and add IK to the tips */ @@ -1337,25 +1381,30 @@ static void createTransArmatureVerts(TransInfo *t) if (EBONE_VISIBLE(arm, ebo) && !(ebo->flag & BONE_EDITMODE_LOCKED)) { if (ELEM(t->mode, TFM_BONESIZE, TFM_BONE_ENVELOPE_DIST)) { - if (ebo->flag & BONE_SELECTED) + if (ebo->flag & BONE_SELECTED) { tc->data_len++; + } } else if (t->mode == TFM_BONE_ROLL) { - if (ebo->flag & BONE_SELECTED) + if (ebo->flag & BONE_SELECTED) { tc->data_len++; + } } else { - if (ebo->flag & BONE_TIPSEL) + if (ebo->flag & BONE_TIPSEL) { tc->data_len++; - if (ebo->flag & BONE_ROOTSEL) + } + if (ebo->flag & BONE_ROOTSEL) { tc->data_len++; + } } } if (mirror && (data_len_prev < tc->data_len)) { eboflip = ED_armature_ebone_get_mirrored(arm->edbo, ebo); - if (eboflip) + if (eboflip) { total_mirrored++; + } } } if (!tc->data_len) { @@ -1498,8 +1547,9 @@ static void createTransArmatureVerts(TransInfo *t) td->loc = ebo->tail; td->flag = TD_SELECTED; - if (ebo->flag & BONE_EDITMODE_LOCKED) + if (ebo->flag & BONE_EDITMODE_LOCKED) { td->protectflag = OB_LOCK_LOC | OB_LOCK_ROT | OB_LOCK_SCALE; + } copy_m3_m3(td->smtx, smtx); copy_m3_m3(td->mtx, mtx); @@ -1522,8 +1572,9 @@ static void createTransArmatureVerts(TransInfo *t) copy_v3_v3(td->center, td->iloc); td->loc = ebo->head; td->flag = TD_SELECTED; - if (ebo->flag & BONE_EDITMODE_LOCKED) + if (ebo->flag & BONE_EDITMODE_LOCKED) { td->protectflag = OB_LOCK_LOC | OB_LOCK_ROT | OB_LOCK_SCALE; + } copy_m3_m3(td->smtx, smtx); copy_m3_m3(td->mtx, mtx); @@ -1581,10 +1632,12 @@ static void createTransMBallVerts(TransInfo *t) /* count totals */ for (ml = mb->editelems->first; ml; ml = ml->next) { - if (ml->flag & SELECT) + if (ml->flag & SELECT) { countsel++; - if (is_prop_edit) + } + if (is_prop_edit) { count++; + } } /* note: in prop mode we need at least 1 selected */ @@ -1592,10 +1645,12 @@ static void createTransMBallVerts(TransInfo *t) continue; } - if (is_prop_edit) + if (is_prop_edit) { tc->data_len = count; - else + } + else { tc->data_len = countsel; + } td = tc->data = MEM_callocN(tc->data_len * sizeof(TransData), "TransObData(MBall EditMode)"); tx = tc->data_ext = MEM_callocN(tc->data_len * sizeof(TransDataExtension), @@ -1612,10 +1667,12 @@ static void createTransMBallVerts(TransInfo *t) quat_to_mat3(td->axismtx, ml->quat); - if (ml->flag & SELECT) + if (ml->flag & SELECT) { td->flag = TD_SELECTED | TD_USEQUAT | TD_SINGLESIZE; - else + } + else { td->flag = TD_USEQUAT; + } copy_m3_m3(td->smtx, smtx); copy_m3_m3(td->mtx, mtx); @@ -1785,18 +1842,21 @@ static void createTransCurveVerts(TransInfo *t) if (bezt_tx & SEL_F3) { countsel++; } - if (is_prop_edit) + if (is_prop_edit) { count += 3; + } } } } else { for (a = nu->pntsu * nu->pntsv, bp = nu->bp; a > 0; a--, bp++) { if (bp->hide == 0) { - if (is_prop_edit) + if (is_prop_edit) { count++; - if (bp->f1 & SELECT) + } + if (bp->f1 & SELECT) { countsel++; + } } } } @@ -1807,10 +1867,12 @@ static void createTransCurveVerts(TransInfo *t) continue; } - if (is_prop_edit) + if (is_prop_edit) { tc->data_len = count; - else + } + else { tc->data_len = countsel; + } tc->data = MEM_callocN(tc->data_len * sizeof(TransData), "TransObData(Curve EditMode)"); t->data_len_all += tc->data_len; @@ -1878,16 +1940,20 @@ static void createTransCurveVerts(TransInfo *t) 1 : 0]); if (hide_handles) { - if (bezt->f2 & SELECT) + if (bezt->f2 & SELECT) { td->flag = TD_SELECTED; - else + } + else { td->flag = 0; + } } else { - if (bezt->f1 & SELECT) + if (bezt->f1 & SELECT) { td->flag = TD_SELECTED; - else + } + else { td->flag = 0; + } } td->ext = NULL; td->val = NULL; @@ -1909,10 +1975,12 @@ static void createTransCurveVerts(TransInfo *t) copy_v3_v3(td->iloc, bezt->vec[1]); td->loc = bezt->vec[1]; copy_v3_v3(td->center, td->loc); - if (bezt->f2 & SELECT) + if (bezt->f2 & SELECT) { td->flag = TD_SELECTED; - else + } + else { td->flag = 0; + } td->ext = NULL; /* TODO - make points scale */ @@ -1934,12 +2002,13 @@ static void createTransCurveVerts(TransInfo *t) copy_m3_m3(td->axismtx, axismtx); } - if ((bezt_tx & SEL_F1) == 0 && (bezt_tx & SEL_F3) == 0) + if ((bezt_tx & SEL_F1) == 0 && (bezt_tx & SEL_F3) == 0) { /* If the middle is selected but the sides arnt, this is needed */ if (hdata == NULL) { /* if the handle was not saved by the previous handle */ hdata = initTransDataCurveHandles(td, bezt); } + } td++; tail++; @@ -1953,16 +2022,20 @@ static void createTransCurveVerts(TransInfo *t) 1 : 2]); if (hide_handles) { - if (bezt->f2 & SELECT) + if (bezt->f2 & SELECT) { td->flag = TD_SELECTED; - else + } + else { td->flag = 0; + } } else { - if (bezt->f3 & SELECT) + if (bezt->f3 & SELECT) { td->flag = TD_SELECTED; - else + } + else { td->flag = 0; + } } td->ext = NULL; td->val = NULL; @@ -1989,8 +2062,9 @@ static void createTransCurveVerts(TransInfo *t) head = tail; } } - if (is_prop_edit && head != tail) + if (is_prop_edit && head != tail) { calc_distanceCurveVerts(head, tail - 1); + } /* TODO - in the case of tilt and radius we can also avoid allocating the * initTransDataCurveHandles but for now just don't change handle types */ @@ -2029,10 +2103,12 @@ static void createTransCurveVerts(TransInfo *t) copy_v3_v3(td->iloc, bp->vec); td->loc = bp->vec; copy_v3_v3(td->center, td->loc); - if (bp->f1 & SELECT) + if (bp->f1 & SELECT) { td->flag = TD_SELECTED; - else + } + else { td->flag = 0; + } td->ext = NULL; if (t->mode == TFM_CURVE_SHRINKFATTEN || t->mode == TFM_RESIZE) { @@ -2061,8 +2137,9 @@ static void createTransCurveVerts(TransInfo *t) head = tail; } } - if (is_prop_edit && head != tail) + if (is_prop_edit && head != tail) { calc_distanceCurveVerts(head, tail - 1); + } } } } @@ -2089,22 +2166,27 @@ static void createTransLatticeVerts(TransInfo *t) a = latt->pntsu * latt->pntsv * latt->pntsw; while (a--) { if (bp->hide == 0) { - if (bp->f1 & SELECT) + if (bp->f1 & SELECT) { countsel++; - if (is_prop_edit) + } + if (is_prop_edit) { count++; + } } bp++; } /* note: in prop mode we need at least 1 selected */ - if (countsel == 0) + if (countsel == 0) { return; + } - if (is_prop_edit) + if (is_prop_edit) { tc->data_len = count; - else + } + else { tc->data_len = countsel; + } tc->data = MEM_callocN(tc->data_len * sizeof(TransData), "TransObData(Lattice EditMode)"); copy_m3_m4(mtx, tc->obedit->obmat); @@ -2157,8 +2239,9 @@ static void createTransParticleVerts(bContext *C, TransInfo *t) int count = 0, hasselected = 0; const bool is_prop_edit = (t->flag & T_PROP_EDIT) != 0; - if (edit == NULL || t->settings->particle.selectmode == SCE_SELECT_PATH) + if (edit == NULL || t->settings->particle.selectmode == SCE_SELECT_PATH) { return; + } psys = edit->psys; @@ -2173,8 +2256,9 @@ static void createTransParticleVerts(bContext *C, TransInfo *t) hasselected = 1; transformparticle = 1; } - else if (is_prop_edit) + else if (is_prop_edit) { transformparticle = 1; + } } } } @@ -2186,17 +2270,20 @@ static void createTransParticleVerts(bContext *C, TransInfo *t) } /* note: in prop mode we need at least 1 selected */ - if (hasselected == 0) + if (hasselected == 0) { return; + } tc->data_len = count; td = tc->data = MEM_callocN(tc->data_len * sizeof(TransData), "TransObData(Particle Mode)"); - if (t->mode == TFM_BAKE_TIME) + if (t->mode == TFM_BAKE_TIME) { tx = tc->data_ext = MEM_callocN(tc->data_len * sizeof(TransDataExtension), "Particle_TransExtension"); - else + } + else { tx = tc->data_ext = NULL; + } unit_m4(mat); @@ -2206,8 +2293,9 @@ static void createTransParticleVerts(bContext *C, TransInfo *t) TransData *head, *tail; head = tail = td; - if (!(point->flag & PEP_TRANSFORM)) + if (!(point->flag & PEP_TRANSFORM)) { continue; + } if (psys && !(psys->flag & PSYS_GLOBAL_HAIR)) { ParticleSystemModifierData *psmd_eval = edit->psmd_eval; @@ -2221,23 +2309,27 @@ static void createTransParticleVerts(bContext *C, TransInfo *t) mul_m4_v3(mat, key->world_co); td->loc = key->world_co; } - else + else { td->loc = key->co; + } copy_v3_v3(td->iloc, td->loc); copy_v3_v3(td->center, td->loc); - if (key->flag & PEK_SELECT) + if (key->flag & PEK_SELECT) { td->flag |= TD_SELECTED; - else if (!is_prop_edit) + } + else if (!is_prop_edit) { td->flag |= TD_SKIP; + } unit_m3(td->mtx); unit_m3(td->smtx); /* don't allow moving roots */ - if (k == 0 && pset->flag & PE_LOCK_FIRST && (!psys || !(psys->flag & PSYS_GLOBAL_HAIR))) + if (k == 0 && pset->flag & PE_LOCK_FIRST && (!psys || !(psys->flag & PSYS_GLOBAL_HAIR))) { td->protectflag |= OB_LOCK_LOC; + } td->ob = ob; td->ext = tx; @@ -2246,24 +2338,30 @@ static void createTransParticleVerts(bContext *C, TransInfo *t) td->ival = *(key->time); /* abuse size and quat for min/max values */ td->flag |= TD_NO_EXT; - if (k == 0) + if (k == 0) { tx->size = NULL; - else + } + else { tx->size = (key - 1)->time; + } - if (k == point->totkey - 1) + if (k == point->totkey - 1) { tx->quat = NULL; - else + } + else { tx->quat = (key + 1)->time; + } } td++; - if (tx) + if (tx) { tx++; + } tail++; } - if (is_prop_edit && head != tail) + if (is_prop_edit && head != tail) { calc_distanceCurveVerts(head, tail - 1); + } } } } @@ -2287,8 +2385,9 @@ void flushTransParticles(TransInfo *t) * back to particle local space (only for hair particles) */ td = tc->data; for (i = 0, point = edit->points; i < edit->totpoint; i++, point++, td++) { - if (!(point->flag & PEP_TRANSFORM)) + if (!(point->flag & PEP_TRANSFORM)) { continue; + } if (psys && !(psys->flag & PSYS_GLOBAL_HAIR)) { ParticleSystemModifierData *psmd_eval = edit->psmd_eval; @@ -2307,8 +2406,9 @@ void flushTransParticles(TransInfo *t) } } } - else + else { point->flag |= PEP_EDIT_RECALC; + } } PE_update_object(t->depsgraph, scene, OBACT(view_layer), 1); @@ -2860,8 +2960,9 @@ static void createTransEditVerts(TransInfo *t) mappedcos = BKE_crazyspace_get_mapped_editverts(t->depsgraph, t->scene, tc->obedit); quats = MEM_mallocN(em->bm->totvert * sizeof(*quats), "crazy quats"); BKE_crazyspace_set_quats_editmesh(em, defcos, mappedcos, quats, !prop_mode); - if (mappedcos) + if (mappedcos) { MEM_freeN(mappedcos); + } } if (defcos) { @@ -2900,12 +3001,14 @@ static void createTransEditVerts(TransInfo *t) /* 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, v_island, is_snap_rotate); - if (tx) + if (tx) { tx++; + } /* selected */ - if (BM_elem_flag_test(eve, BM_ELEM_SELECT)) + if (BM_elem_flag_test(eve, BM_ELEM_SELECT)) { tob->flag |= TD_SELECTED; + } if (prop_mode) { if (prop_mode & T_PROP_CONNECTED) { @@ -2975,14 +3078,18 @@ static void createTransEditVerts(TransInfo *t) cleanup: /* crazy space free */ - if (quats) + if (quats) { MEM_freeN(quats); - if (defmats) + } + if (defmats) { MEM_freeN(defmats); - if (dists) + } + if (dists) { MEM_freeN(dists); - if (dists_index) + } + if (dists_index) { MEM_freeN(dists_index); + } if (tc->mirror.axis_flag) { EDBM_verts_mirror_cache_end(em); @@ -3052,8 +3159,9 @@ BLI_INLINE void trans_update_seq(Scene *sce, Sequence *seq, int old_start, int s BKE_sequence_calc_disp(sce, seq); } - if (sel_flag == SELECT) + if (sel_flag == SELECT) { BKE_sequencer_offset_animdata(sce, seq, seq->start - old_start); + } } void flushTransSeq(TransInfo *t) @@ -3338,8 +3446,9 @@ static void createTransUVs(bContext *C, TransInfo *t) * treated just as if they were 3d verts */ tc->data_2d = MEM_callocN(tc->data_len * sizeof(TransData2D), "TransObData2D(UV Editing)"); - if (sima->flag & SI_CLIP_UV) + if (sima->flag & SI_CLIP_UV) { t->flag |= T_CLIP_UV; + } td = tc->data; td2d = tc->data_2d; @@ -3347,16 +3456,18 @@ static void createTransUVs(bContext *C, TransInfo *t) BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) { BMLoop *l; - if (!BM_elem_flag_test(efa, BM_ELEM_TAG)) + if (!BM_elem_flag_test(efa, BM_ELEM_TAG)) { continue; + } BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) { const bool selected = uvedit_uv_select_test(scene, l, cd_loop_uv_offset); MLoopUV *luv; const float *center = NULL; - if (!is_prop_edit && !selected) + if (!is_prop_edit && !selected) { continue; + } if (is_prop_connected || is_island_center) { UvElement *element = BM_uv_element_get(elementmap, efa, l); @@ -3469,34 +3580,48 @@ bool clipUVTransform(TransInfo *t, float vec[2], const bool resize) } if (resize) { - if (min[0] < 0.0f && t->center_global[0] > 0.0f && t->center_global[0] < t->aspect[0] * 0.5f) + if (min[0] < 0.0f && t->center_global[0] > 0.0f && + t->center_global[0] < t->aspect[0] * 0.5f) { vec[0] *= t->center_global[0] / (t->center_global[0] - min[0]); - else if (max[0] > t->aspect[0] && t->center_global[0] < t->aspect[0]) + } + else if (max[0] > t->aspect[0] && t->center_global[0] < t->aspect[0]) { vec[0] *= (t->center_global[0] - t->aspect[0]) / (t->center_global[0] - max[0]); - else + } + else { clipx = 0; + } - if (min[1] < 0.0f && t->center_global[1] > 0.0f && t->center_global[1] < t->aspect[1] * 0.5f) + if (min[1] < 0.0f && t->center_global[1] > 0.0f && + t->center_global[1] < t->aspect[1] * 0.5f) { vec[1] *= t->center_global[1] / (t->center_global[1] - min[1]); - else if (max[1] > t->aspect[1] && t->center_global[1] < t->aspect[1]) + } + else if (max[1] > t->aspect[1] && t->center_global[1] < t->aspect[1]) { vec[1] *= (t->center_global[1] - t->aspect[1]) / (t->center_global[1] - max[1]); - else + } + else { clipy = 0; + } } else { - if (min[0] < 0.0f) + if (min[0] < 0.0f) { vec[0] -= min[0]; - else if (max[0] > t->aspect[0]) + } + else if (max[0] > t->aspect[0]) { vec[0] -= max[0] - t->aspect[0]; - else + } + else { clipx = 0; + } - if (min[1] < 0.0f) + if (min[1] < 0.0f) { vec[1] -= min[1]; - else if (max[1] > t->aspect[1]) + } + else if (max[1] > t->aspect[1]) { vec[1] -= max[1] - t->aspect[1]; - else + } + else { clipy = 0; + } } } @@ -3508,11 +3633,13 @@ void clipUVData(TransInfo *t) FOREACH_TRANS_DATA_CONTAINER (t, tc) { TransData *td = tc->data; for (int a = 0; a < tc->data_len; a++, td++) { - if (td->flag & TD_NOACTION) + if (td->flag & TD_NOACTION) { break; + } - if ((td->flag & TD_SKIP) || (!td->loc)) + if ((td->flag & TD_SKIP) || (!td->loc)) { continue; + } td->loc[0] = min_ff(max_ff(0.0f, td->loc[0]), t->aspect[0]); td->loc[1] = min_ff(max_ff(0.0f, td->loc[1]), t->aspect[1]); @@ -3526,14 +3653,17 @@ void clipUVData(TransInfo *t) static bool FrameOnMouseSide(char side, float frame, float cframe) { /* both sides, so it doesn't matter */ - if (side == 'B') + if (side == 'B') { return true; + } /* only on the named side */ - if (side == 'R') + if (side == 'R') { return (frame >= cframe); - else + } + else { return (frame <= cframe); + } } /* ********************* NLA EDITOR ************************* */ @@ -3555,8 +3685,9 @@ static void createTransNlaData(bContext *C, TransInfo *t) TransDataContainer *tc = TRANS_DATA_CONTAINER_FIRST_SINGLE(t); /* determine what type of data we are operating on */ - if (ANIM_animdata_get_context(C, &ac) == 0) + if (ANIM_animdata_get_context(C, &ac) == 0) { return; + } snla = (SpaceNla *)ac.sl; /* filter data */ @@ -3590,10 +3721,12 @@ static void createTransNlaData(bContext *C, TransInfo *t) /* transition strips can't get directly transformed */ if (strip->type != NLASTRIP_TYPE_TRANSITION) { if (strip->flag & NLASTRIP_FLAG_SELECT) { - if (FrameOnMouseSide(t->frame_side, strip->start, (float)CFRA)) + if (FrameOnMouseSide(t->frame_side, strip->start, (float)CFRA)) { count++; - if (FrameOnMouseSide(t->frame_side, strip->end, (float)CFRA)) + } + if (FrameOnMouseSide(t->frame_side, strip->end, (float)CFRA)) { count++; + } } } } @@ -3736,10 +3869,12 @@ static void createTransNlaData(bContext *C, TransInfo *t) * since the counting code is dumb. * Otherwise, just advance to the next one. */ - if (tdn->handle == 2) + if (tdn->handle == 2) { tdn += 2; - else + } + else { tdn++; + } } } } @@ -3757,10 +3892,12 @@ static int gpf_cmp_frame(void *thunk, const void *a, const void *b) const bGPDframe *frame_a = a; const bGPDframe *frame_b = b; - if (frame_a->framenum < frame_b->framenum) + if (frame_a->framenum < frame_b->framenum) { return -1; - if (frame_a->framenum > frame_b->framenum) + } + if (frame_a->framenum > frame_b->framenum) { return 1; + } *((bool *)thunk) = true; /* selected last */ if ((frame_a->flag & GP_FRAME_SELECT) && ((frame_b->flag & GP_FRAME_SELECT) == 0)) { @@ -3774,10 +3911,12 @@ static int masklay_shape_cmp_frame(void *thunk, const void *a, const void *b) const MaskLayerShape *frame_a = a; const MaskLayerShape *frame_b = b; - if (frame_a->frame < frame_b->frame) + if (frame_a->frame < frame_b->frame) { return -1; - if (frame_a->frame > frame_b->frame) + } + if (frame_a->frame > frame_b->frame) { return 1; + } *((bool *)thunk) = true; /* selected last */ if ((frame_a->flag & MASK_SHAPE_SELECT) && ((frame_b->flag & MASK_SHAPE_SELECT) == 0)) { @@ -3870,8 +4009,9 @@ static void posttrans_fcurve_clean(FCurve *fcu, const bool use_handle) 0); /* sanity checks */ - if ((fcu->totvert == 0) || (fcu->bezt == NULL)) + if ((fcu->totvert == 0) || (fcu->bezt == NULL)) { return; + } /* 1) Identify selected keyframes, and average the values on those * in case there are collisions due to multiple keys getting scaled @@ -4004,8 +4144,9 @@ static void posttrans_action_clean(bAnimContext *ac, bAction *act) posttrans_fcurve_clean(ale->key_data, false); /* only use handles in graph editor */ ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, 0); } - else + else { posttrans_fcurve_clean(ale->key_data, false); /* only use handles in graph editor */ + } } /* free temp data */ @@ -4020,25 +4161,29 @@ static int count_fcurve_keys(FCurve *fcu, char side, float cfra, bool is_prop_ed BezTriple *bezt; int i, count = 0, count_all = 0; - if (ELEM(NULL, fcu, fcu->bezt)) + if (ELEM(NULL, fcu, fcu->bezt)) { return count; + } /* only include points that occur on the right side of cfra */ for (i = 0, bezt = fcu->bezt; i < fcu->totvert; i++, bezt++) { if (FrameOnMouseSide(side, bezt->vec[1][0], cfra)) { /* no need to adjust the handle selection since they are assumed * selected (like graph editor with SIPO_NOHANDLES) */ - if (bezt->f2 & SELECT) + if (bezt->f2 & SELECT) { count++; + } count_all++; } } - if (is_prop_edit && count > 0) + if (is_prop_edit && count > 0) { return count_all; - else + } + else { return count; + } } /* fully select selected beztriples, but only include if it's on the right side of cfra */ @@ -4047,22 +4192,26 @@ static int count_gplayer_frames(bGPDlayer *gpl, char side, float cfra, bool is_p bGPDframe *gpf; int count = 0, count_all = 0; - if (gpl == NULL) + if (gpl == NULL) { return count; + } /* only include points that occur on the right side of cfra */ for (gpf = gpl->frames.first; gpf; gpf = gpf->next) { if (FrameOnMouseSide(side, (float)gpf->framenum, cfra)) { - if (gpf->flag & GP_FRAME_SELECT) + if (gpf->flag & GP_FRAME_SELECT) { count++; + } count_all++; } } - if (is_prop_edit && count > 0) + if (is_prop_edit && count > 0) { return count_all; - else + } + else { return count; + } } /* fully select selected beztriples, but only include if it's on the right side of cfra */ @@ -4071,23 +4220,27 @@ static int count_masklayer_frames(MaskLayer *masklay, char side, float cfra, boo MaskLayerShape *masklayer_shape; int count = 0, count_all = 0; - if (masklay == NULL) + if (masklay == NULL) { return count; + } /* only include points that occur on the right side of cfra */ for (masklayer_shape = masklay->splines_shapes.first; masklayer_shape; masklayer_shape = masklayer_shape->next) { if (FrameOnMouseSide(side, (float)masklayer_shape->frame, cfra)) { - if (masklayer_shape->flag & MASK_SHAPE_SELECT) + if (masklayer_shape->flag & MASK_SHAPE_SELECT) { count++; + } count_all++; } } - if (is_prop_edit && count > 0) + if (is_prop_edit && count > 0) { return count_all; - else + } + else { return count; + } } /* This function assigns the information to transdata */ @@ -4126,8 +4279,9 @@ static TransData *ActionFCurveToTransData(TransData *td, TransData2D *td2d = *td2dv; int i; - if (ELEM(NULL, fcu, fcu->bezt)) + if (ELEM(NULL, fcu, fcu->bezt)) { return td; + } for (i = 0, bezt = fcu->bezt; i < fcu->totvert; i++, bezt++) { /* only add selected keyframes (for now, proportional edit is not enabled) */ @@ -4137,8 +4291,9 @@ static TransData *ActionFCurveToTransData(TransData *td, if (FrameOnMouseSide(side, bezt->vec[1][0], cfra)) { TimeToTransData(td, bezt->vec[1], adt, ypos); - if (bezt->f2 & SELECT) + if (bezt->f2 & SELECT) { td->flag |= TD_SELECTED; + } /*set flags to move handles as necessary*/ td->flag |= TD_MOVEHANDLE1 | TD_MOVEHANDLE2; @@ -4284,14 +4439,17 @@ static void createTransActionData(bContext *C, TransInfo *t) float ypos = 1.0f / ((ysize / xsize) * (xmask / ymask)) * BLI_rctf_cent_y(&t->ar->v2d.cur); /* determine what type of data we are operating on */ - if (ANIM_animdata_get_context(C, &ac) == 0) + if (ANIM_animdata_get_context(C, &ac) == 0) { return; + } /* filter data */ - if (ELEM(ac.datatype, ANIMCONT_GPENCIL, ANIMCONT_MASK)) + if (ELEM(ac.datatype, ANIMCONT_GPENCIL, ANIMCONT_MASK)) { filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_FOREDIT); - else + } + else { filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_FOREDIT /*| ANIMFILTER_CURVESONLY*/); + } ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); /* which side of the current frame should be allowed */ @@ -4314,19 +4472,25 @@ static void createTransActionData(bContext *C, TransInfo *t) /* convert current-frame to action-time (slightly less accurate, especially under * higher scaling ratios, but is faster than converting all points) */ - if (adt) + if (adt) { cfra = BKE_nla_tweakedit_remap(adt, (float)CFRA, NLATIME_CONVERT_UNMAP); - else + } + else { cfra = (float)CFRA; + } - if (ELEM(ale->type, ANIMTYPE_FCURVE, ANIMTYPE_NLACURVE)) + if (ELEM(ale->type, ANIMTYPE_FCURVE, ANIMTYPE_NLACURVE)) { adt_count = count_fcurve_keys(ale->key_data, t->frame_side, cfra, is_prop_edit); - else if (ale->type == ANIMTYPE_GPLAYER) + } + else if (ale->type == ANIMTYPE_GPLAYER) { adt_count = count_gplayer_frames(ale->data, t->frame_side, cfra, is_prop_edit); - else if (ale->type == ANIMTYPE_MASKLAYER) + } + else if (ale->type == ANIMTYPE_MASKLAYER) { adt_count = count_masklayer_frames(ale->data, t->frame_side, cfra, is_prop_edit); - else + } + else { BLI_assert(0); + } if (adt_count > 0) { count += adt_count; @@ -4359,8 +4523,9 @@ static void createTransActionData(bContext *C, TransInfo *t) /* loop 2: build transdata array */ for (ale = anim_data.first; ale; ale = ale->next) { - if (is_prop_edit && !ale->tag) + if (is_prop_edit && !ale->tag) { continue; + } cfra = (float)CFRA; @@ -4404,14 +4569,17 @@ static void createTransActionData(bContext *C, TransInfo *t) AnimData *adt; /* F-Curve may not have any keyframes */ - if (!ale->tag) + if (!ale->tag) { continue; + } adt = ANIM_nla_mapping_get(&ac, ale); - if (adt) + if (adt) { cfra = BKE_nla_tweakedit_remap(adt, (float)CFRA, NLATIME_CONVERT_UNMAP); - else + } + else { cfra = (float)CFRA; + } if (ale->type == ANIMTYPE_GPLAYER) { bGPDlayer *gpl = (bGPDlayer *)ale->data; @@ -4487,8 +4655,9 @@ static void createTransActionData(bContext *C, TransInfo *t) if (bezt_iter->f2 & SELECT) { if (FrameOnMouseSide(t->frame_side, (float)bezt_iter->vec[1][0], cfra)) { float val = fabs(bezt->vec[1][0] - bezt_iter->vec[1][0]); - if (val < min) + if (val < min) { min = val; + } } } } @@ -4588,13 +4757,16 @@ static void bezt_to_transdata(TransData *td, td->flag |= TD_SELECTED; td->dist = 0.0f; } - else + else { td->dist = FLT_MAX; + } - if (ishandle) + if (ishandle) { td->flag |= TD_NOTIMESNAP; - if (intvals) + } + if (intvals) { td->flag |= TD_INTVALUES; + } /* copy space-conversion matrices for dealing with non-uniform scales */ copy_m3_m3(td->mtx, mtx); @@ -4663,8 +4835,9 @@ static void createTransGraphEditData(bContext *C, TransInfo *t) short anim_map_flag = ANIM_UNITCONV_ONLYSEL | ANIM_UNITCONV_SELVERTS; /* determine what type of data we are operating on */ - if (ANIM_animdata_get_context(C, &ac) == 0) + if (ANIM_animdata_get_context(C, &ac) == 0) { return; + } anim_map_flag |= ANIM_get_normalization_flags(&ac); @@ -4696,16 +4869,19 @@ static void createTransGraphEditData(bContext *C, TransInfo *t) bool selected = false; /* F-Curve may not have any keyframes */ - if (fcu->bezt == NULL) + if (fcu->bezt == NULL) { continue; + } /* convert current-frame to action-time (slightly less accurate, especially under * higher scaling ratios, but is faster than converting all points) */ - if (adt) + if (adt) { cfra = BKE_nla_tweakedit_remap(adt, (float)CFRA, NLATIME_CONVERT_UNMAP); - else + } + else { cfra = (float)CFRA; + } /* Only include BezTriples whose 'keyframe' * occurs on the same side of the current frame as mouse. */ @@ -4717,8 +4893,9 @@ static void createTransGraphEditData(bContext *C, TransInfo *t) if (is_prop_edit) { curvecount += 3; - if (sel2 || sel1 || sel3) + if (sel2 || sel1 || sel3) { selected = true; + } } else { if (!is_translation_mode || !(sel2)) { @@ -4785,10 +4962,12 @@ static void createTransGraphEditData(bContext *C, TransInfo *t) mul_v3_fl(mtx[1], yscale); /* smtx is global (i.e. view) to data conversion */ - if (IS_EQF(xscale, 0.0f) == 0) + if (IS_EQF(xscale, 0.0f) == 0) { mul_v3_fl(smtx[0], 1.0f / xscale); - if (IS_EQF(yscale, 0.0f) == 0) + } + if (IS_EQF(yscale, 0.0f) == 0) { mul_v3_fl(smtx[1], 1.0f / yscale); + } } /* loop 2: build transdata arrays */ @@ -4800,16 +4979,19 @@ static void createTransGraphEditData(bContext *C, TransInfo *t) float cfra; /* F-Curve may not have any keyframes */ - if (fcu->bezt == NULL || (is_prop_edit && ale->tag == 0)) + if (fcu->bezt == NULL || (is_prop_edit && ale->tag == 0)) { continue; + } /* convert current-frame to action-time (slightly less accurate, especially under * higher scaling ratios, but is faster than converting all points) */ - if (adt) + if (adt) { cfra = BKE_nla_tweakedit_remap(adt, (float)CFRA, NLATIME_CONVERT_UNMAP); - else + } + else { cfra = (float)CFRA; + } unit_scale = ANIM_unit_mapping_get_factor( ac.scene, ale->id, ale->key_data, anim_map_flag, &offset); @@ -4897,8 +5079,9 @@ static void createTransGraphEditData(bContext *C, TransInfo *t) } if (sel3) { - if (hdata == NULL) + if (hdata == NULL) { hdata = initTransDataCurveHandles(td, bezt); + } bezt_to_transdata(td++, td2d++, tdg++, @@ -4922,16 +5105,19 @@ static void createTransGraphEditData(bContext *C, TransInfo *t) if (sel2 && !use_local_center) { /* move handles relative to center */ if (is_translation_mode) { - if (sel1) + if (sel1) { td->flag |= TD_MOVEHANDLE1; - if (sel3) + } + if (sel3) { td->flag |= TD_MOVEHANDLE2; + } } /* if handles were not selected, store their selection status */ if (!(sel1) || !(sel3)) { - if (hdata == NULL) + if (hdata == NULL) { hdata = initTransDataCurveHandles(td, bezt); + } } bezt_to_transdata(td++, @@ -4981,16 +5167,19 @@ static void createTransGraphEditData(bContext *C, TransInfo *t) float cfra; /* F-Curve may not have any keyframes */ - if (fcu->bezt == NULL || (ale->tag == 0)) + if (fcu->bezt == NULL || (ale->tag == 0)) { continue; + } /* convert current-frame to action-time (slightly less accurate, especially under * higher scaling ratios, but is faster than converting all points) */ - if (adt) + if (adt) { cfra = BKE_nla_tweakedit_remap(adt, (float)CFRA, NLATIME_CONVERT_UNMAP); - else + } + else { cfra = (float)CFRA; + } /* only include BezTriples whose 'keyframe' occurs on the * same side of the current frame as mouse (if applicable) */ @@ -5054,8 +5243,9 @@ static BeztMap *bezt_to_beztmaps(BezTriple *bezts, int totvert, const short UNUS int i; /* allocate memory for this array */ - if (totvert == 0 || bezts == NULL) + if (totvert == 0 || bezts == NULL) { return NULL; + } bezm = bezms = MEM_callocN(sizeof(BeztMap) * totvert, "BeztMaps"); /* assign beztriples to beztmaps */ @@ -5146,34 +5336,41 @@ static void beztmap_to_data( td = tc->data; for (j = 0; j < tc->data_len; j++, td2d++, td++) { /* skip item if already marked */ - if (adjusted[j] != 0) + if (adjusted[j] != 0) { continue; + } /* update all transdata pointers, no need to check for selections etc, * since only points that are really needed were created as transdata */ if (td2d->loc2d == bezm->bezt->vec[0]) { - if (bezm->swapHs == 1) + if (bezm->swapHs == 1) { td2d->loc2d = (bezts + bezm->newIndex)->vec[2]; - else + } + else { td2d->loc2d = (bezts + bezm->newIndex)->vec[0]; + } adjusted[j] = 1; } else if (td2d->loc2d == bezm->bezt->vec[2]) { - if (bezm->swapHs == 1) + if (bezm->swapHs == 1) { td2d->loc2d = (bezts + bezm->newIndex)->vec[0]; - else + } + else { td2d->loc2d = (bezts + bezm->newIndex)->vec[2]; + } adjusted[j] = 1; } else if (td2d->loc2d == bezm->bezt->vec[1]) { td2d->loc2d = (bezts + bezm->newIndex)->vec[1]; /* if only control point is selected, the handle pointers need to be updated as well */ - if (td2d->h1) + if (td2d->h1) { td2d->h1 = (bezts + bezm->newIndex)->vec[0]; - if (td2d->h2) + } + if (td2d->h2) { td2d->h2 = (bezts + bezm->newIndex)->vec[2]; + } adjusted[j] = 1; } @@ -5280,10 +5477,12 @@ void flushTransGraphData(TransInfo *t) } /* we need to unapply the nla-mapping from the time in some situations */ - if (adt) + if (adt) { td2d->loc2d[0] = BKE_nla_tweakedit_remap(adt, td2d->loc[0], NLATIME_CONVERT_UNMAP); - else + } + else { td2d->loc2d[0] = td2d->loc[0]; + } /** Time-stepping auto-snapping modes don't get applied for Graph Editor transforms, * as these use the generic transform modes which don't account for this sort of thing. @@ -5312,10 +5511,12 @@ void flushTransGraphData(TransInfo *t) } /* if int-values only, truncate to integers */ - if (td->flag & TD_INTVALUES) + if (td->flag & TD_INTVALUES) { td2d->loc2d[1] = floorf(td2d->loc[1] * inv_unit_scale - tdg->offset + 0.5f); - else + } + else { td2d->loc2d[1] = td2d->loc[1] * inv_unit_scale - tdg->offset; + } if ((td->flag & TD_MOVEHANDLE1) && td2d->h1) { td2d->h1[0] = td2d->ih1[0] + td->loc[0] - td->iloc[0]; @@ -5360,12 +5561,15 @@ static void SeqTransInfo(TransInfo *t, Sequence *seq, int *recursive, int *count /* for meta's we only ever need to extend their children, no matter what depth * just check the meta's are in the bounds */ - if (t->frame_side == 'R' && right <= cfra) + if (t->frame_side == 'R' && right <= cfra) { *recursive = false; - else if (t->frame_side == 'L' && left >= cfra) + } + else if (t->frame_side == 'L' && left >= cfra) { *recursive = false; - else + } + else { *recursive = true; + } *count = 1; *flag = (seq->flag | SELECT) & ~(SEQ_LEFTSEL | SEQ_RIGHTSEL); @@ -5382,8 +5586,9 @@ static void SeqTransInfo(TransInfo *t, Sequence *seq, int *recursive, int *count } /* ignore */ else if (left > cfra) { } /* keep the selection */ - else + else { *flag |= SEQ_RIGHTSEL; + } } else { if (left >= cfra) { @@ -5391,8 +5596,9 @@ static void SeqTransInfo(TransInfo *t, Sequence *seq, int *recursive, int *count } /* ignore */ else if (right < cfra) { } /* keep the selection */ - else + else { *flag |= SEQ_LEFTSEL; + } } } } @@ -5667,8 +5873,9 @@ static void freeSeqData(TransInfo *t, TransDataContainer *tc, TransCustomData *c if (overlap) { bool has_effect_root = false, has_effect_any = false; - for (seq = seqbasep->first; seq; seq = seq->next) + for (seq = seqbasep->first; seq; seq = seq->next) { seq->tmp = NULL; + } td = tc->data; for (a = 0, seq_prev = NULL; a < tc->data_len; a++, td++, seq_prev = seq) { @@ -5762,12 +5969,15 @@ static void freeSeqData(TransInfo *t, TransDataContainer *tc, TransCustomData *c for (seq = seqbasep->first; seq; seq = seq->next) { /* We might want to build a list of effects that need to be updated during transform */ if (seq->type & SEQ_TYPE_EFFECT) { - if (seq->seq1 && seq->seq1->flag & SELECT) + if (seq->seq1 && seq->seq1->flag & SELECT) { BKE_sequence_calc(t->scene, seq); - else if (seq->seq2 && seq->seq2->flag & SELECT) + } + else if (seq->seq2 && seq->seq2->flag & SELECT) { BKE_sequence_calc(t->scene, seq); - else if (seq->seq3 && seq->seq3->flag & SELECT) + } + else if (seq->seq3 && seq->seq3->flag & SELECT) { BKE_sequence_calc(t->scene, seq); + } } } @@ -5778,8 +5988,9 @@ static void freeSeqData(TransInfo *t, TransDataContainer *tc, TransCustomData *c for (a = 0; a < tc->data_len; a++, td++) { seq = ((TransDataSeq *)td->extra)->seq; if ((seq != seq_prev) && (seq->depth == 0)) { - if (seq->flag & SEQ_OVERLAP) + if (seq->flag & SEQ_OVERLAP) { BKE_sequence_base_shuffle(seqbasep, seq, t->scene); + } BKE_sequence_calc_disp(t->scene, seq); } @@ -5873,8 +6084,9 @@ static void createTransSeqData(bContext *C, TransInfo *t) SeqTransDataBounds(t, ed->seqbasep, ts); /* set the snap mode based on how close the mouse is at the end/start points */ - if (abs(xmouse - ts->max) > abs(xmouse - ts->min)) + if (abs(xmouse - ts->max) > abs(xmouse - ts->min)) { ts->snap_left = true; + } #undef XXX_DURIAN_ANIM_TX_HACK } @@ -5915,23 +6127,26 @@ static bool constraints_list_needinv(TransInfo *t, ListBase *list) bChildOfConstraint *data = (bChildOfConstraint *)con->data; if ((data->flag & CHILDOF_LOCX) && (data->flag & CHILDOF_LOCY) && - (data->flag & CHILDOF_LOCZ)) + (data->flag & CHILDOF_LOCZ)) { return true; + } } else if (con->type == CONSTRAINT_TYPE_ROTLIKE) { /* CopyRot constraint only does this when rotating, and offset is on */ bRotateLikeConstraint *data = (bRotateLikeConstraint *)con->data; - if ((data->flag & ROTLIKE_OFFSET) && (t->mode == TFM_ROTATION)) + if ((data->flag & ROTLIKE_OFFSET) && (t->mode == TFM_ROTATION)) { return true; + } } else if (con->type == CONSTRAINT_TYPE_TRANSFORM) { /* Transform constraint needs it for rotation at least (r.57309), * but doing so when translating may also mess things up [#36203] */ - if (t->mode == TFM_ROTATION) + if (t->mode == TFM_ROTATION) { return true; + } /* ??? (t->mode == TFM_SCALE) ? */ } } @@ -5991,8 +6206,9 @@ static void ObjectToTransData(TransInfo *t, TransData *td, Object *ob) constinv = constraints_list_needinv(t, &ob->constraints); /* disable constraints inversion for dummy pass */ - if (t->mode == TFM_DUMMY) + if (t->mode == TFM_DUMMY) { skip_invert = true; + } /* NOTE: This is not really following copy-on-write design and we should not * be re-evaluating the evaluated object. But as the comment above mentioned @@ -6181,8 +6397,9 @@ static void set_trans_object_base_flags(TransInfo *t) static bool mark_children(Object *ob) { - if (ob->flag & (SELECT | BA_TRANSFORM_CHILD)) + if (ob->flag & (SELECT | BA_TRANSFORM_CHILD)) { return true; + } if (ob->parent) { if (mark_children(ob->parent)) { @@ -6334,8 +6551,9 @@ void autokeyframe_object(bContext *C, Scene *scene, ViewLayer *view_layer, Objec } else if (ELEM(tmode, TFM_ROTATION, TFM_TRACKBALL)) { if (scene->toolsettings->transform_pivot_point == V3D_AROUND_ACTIVE) { - if (ob != OBACT(view_layer)) + if (ob != OBACT(view_layer)) { do_loc = true; + } } else if (scene->toolsettings->transform_pivot_point == V3D_AROUND_CURSOR) { do_loc = true; @@ -6347,8 +6565,9 @@ void autokeyframe_object(bContext *C, Scene *scene, ViewLayer *view_layer, Objec } else if (tmode == TFM_RESIZE) { if (scene->toolsettings->transform_pivot_point == V3D_AROUND_ACTIVE) { - if (ob != OBACT(view_layer)) + if (ob != OBACT(view_layer)) { do_loc = true; + } } else if (scene->toolsettings->transform_pivot_point == V3D_AROUND_CURSOR) { do_loc = true; @@ -6437,8 +6656,9 @@ void autokeyframe_pose(bContext *C, Scene *scene, Object *ob, int tmode, short t */ flag = ANIM_get_keyframing_flags(scene, 1); - if (targetless_ik) + if (targetless_ik) { flag |= INSERTKEY_MATRIX; + } for (pchan = pose->chanbase.first; pchan; pchan = pchan->next) { if (pchan->bone->flag & BONE_TRANSFORM) { @@ -6481,8 +6701,9 @@ void autokeyframe_pose(bContext *C, Scene *scene, Object *ob, int tmode, short t flag); } - if (pchanName) + if (pchanName) { MEM_freeN(pchanName); + } } } } @@ -6494,10 +6715,12 @@ void autokeyframe_pose(bContext *C, Scene *scene, Object *ob, int tmode, short t /* Filter the conditions when this happens * (assume that 'curarea->spacetype == SPACE_VIEW3D'). */ if (tmode == TFM_TRANSLATION) { - if (targetless_ik) + if (targetless_ik) { do_rot = true; - else + } + else { do_loc = true; + } } else if (ELEM(tmode, TFM_ROTATION, TFM_TRACKBALL)) { if (ELEM(scene->toolsettings->transform_pivot_point, @@ -6655,8 +6878,9 @@ static void special_aftertrans_update__node(bContext *C, TransInfo *t) bNode *node, *node_next; for (node = ntree->nodes.first; node; node = node_next) { node_next = node->next; - if (node->flag & NODE_SELECT) + if (node->flag & NODE_SELECT) { nodeRemoveNode(bmain, ntree, node, true); + } } } } @@ -6790,9 +7014,10 @@ void special_aftertrans_update(bContext *C, TransInfo *t) * for some reason EXTEND is changed into TRANSLATE, so use frame_side instead */ if (t->mode == TFM_SEQ_SLIDE) { - if (t->frame_side == 'B') + if (t->frame_side == 'B') { ED_markers_post_apply_transform( &t->scene->markers, t->scene, TFM_TIME_TRANSLATE, t->values[0], t->frame_side); + } } else if (ELEM(t->frame_side, 'L', 'R')) { ED_markers_post_apply_transform( @@ -6830,8 +7055,9 @@ void special_aftertrans_update(bContext *C, TransInfo *t) bAnimContext ac; /* initialize relevant anim-context 'context' data */ - if (ANIM_animdata_get_context(C, &ac) == 0) + if (ANIM_animdata_get_context(C, &ac) == 0) { return; + } ob = ac.obact; @@ -6861,8 +7087,9 @@ void special_aftertrans_update(bContext *C, TransInfo *t) posttrans_fcurve_clean(fcu, false); /* only use handles in graph editor */ ANIM_nla_mapping_apply_fcurve(adt, fcu, 1, 0); } - else + else { posttrans_fcurve_clean(fcu, false); /* only use handles in graph editor */ + } } } @@ -6873,11 +7100,13 @@ void special_aftertrans_update(bContext *C, TransInfo *t) /* Depending on the lock status, draw necessary views */ // fixme... some of this stuff is not good if (ob) { - if (ob->pose || BKE_key_from_object(ob)) + if (ob->pose || BKE_key_from_object(ob)) { DEG_id_tag_update(&ob->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY | ID_RECALC_ANIMATION); - else + } + else { DEG_id_tag_update(&ob->id, ID_RECALC_TRANSFORM); + } } /* 3 cases here for curve cleanups: @@ -6906,8 +7135,9 @@ void special_aftertrans_update(bContext *C, TransInfo *t) // XXX: BAD! this get gpencil datablocks directly from main db... // but that's how this currently works :/ for (gpd = bmain->gpencils.first; gpd; gpd = gpd->id.next) { - if (ID_REAL_USERS(gpd)) + if (ID_REAL_USERS(gpd)) { posttrans_gpd_clean(gpd); + } } } } @@ -6927,8 +7157,9 @@ void special_aftertrans_update(bContext *C, TransInfo *t) // XXX: BAD! this get gpencil datablocks directly from main db... // but that's how this currently works :/ for (mask = bmain->masks.first; mask; mask = mask->id.next) { - if (ID_REAL_USERS(mask)) + if (ID_REAL_USERS(mask)) { posttrans_mask_clean(mask); + } } } } @@ -6958,8 +7189,9 @@ void special_aftertrans_update(bContext *C, TransInfo *t) } /* make sure all F-Curves are set correctly */ - if (!ELEM(ac.datatype, ANIMCONT_GPENCIL, ANIMCONT_MASK)) + if (!ELEM(ac.datatype, ANIMCONT_GPENCIL, ANIMCONT_MASK)) { ANIM_editkeyframes_refresh(&ac); + } /* clear flag that was set for time-slide drawing */ saction->flag &= ~SACTION_MOVING; @@ -6970,8 +7202,9 @@ void special_aftertrans_update(bContext *C, TransInfo *t) const bool use_handle = (sipo->flag & SIPO_NOHANDLES) == 0; /* initialize relevant anim-context 'context' data */ - if (ANIM_animdata_get_context(C, &ac) == 0) + if (ANIM_animdata_get_context(C, &ac) == 0) { return; + } if (ac.datatype) { ListBase anim_data = {NULL, NULL}; @@ -6998,8 +7231,9 @@ void special_aftertrans_update(bContext *C, TransInfo *t) posttrans_fcurve_clean(fcu, use_handle); ANIM_nla_mapping_apply_fcurve(adt, fcu, 1, 0); } - else + else { posttrans_fcurve_clean(fcu, use_handle); + } } } @@ -7012,15 +7246,17 @@ void special_aftertrans_update(bContext *C, TransInfo *t) * Note: if the refresh is really needed after cancel then some way * has to be added to not update handle types (see bug 22289). */ - if (!canceled) + if (!canceled) { ANIM_editkeyframes_refresh(&ac); + } } else if (t->spacetype == SPACE_NLA) { bAnimContext ac; /* initialize relevant anim-context 'context' data */ - if (ANIM_animdata_get_context(C, &ac) == 0) + if (ANIM_animdata_get_context(C, &ac) == 0) { return; + } if (ac.datatype) { ListBase anim_data = {NULL, NULL}; @@ -7093,19 +7329,22 @@ void special_aftertrans_update(bContext *C, TransInfo *t) } /* if target-less IK grabbing, we calculate the pchan transforms and clear flag */ - if (!canceled && t->mode == TFM_TRANSLATION) + if (!canceled && t->mode == TFM_TRANSLATION) { targetless_ik = apply_targetless_ik(ob); + } else { /* not forget to clear the auto flag */ for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) { bKinematicConstraint *data = has_targetless_ik(pchan); - if (data) + if (data) { data->flag &= ~CONSTRAINT_IK_AUTO; + } } } - if (t->mode == TFM_TRANSLATION) + if (t->mode == TFM_TRANSLATION) { pose_grab_with_ik_clear(bmain, ob); + } /* automatic inserting of keys and unkeyed tagging - * only if transform wasn't canceled (or TFM_DUMMY) */ @@ -7161,11 +7400,13 @@ void special_aftertrans_update(bContext *C, TransInfo *t) PTCacheID *pid; ob = td->ob; - if (td->flag & TD_NOACTION) + if (td->flag & TD_NOACTION) { break; + } - if (td->flag & TD_SKIP) + if (td->flag & TD_SKIP) { continue; + } /* flag object caches as outdated */ BKE_ptcache_ids_from_object(&pidlist, ob, t->scene, MAX_DUPLI_RECUR); @@ -7178,8 +7419,9 @@ void special_aftertrans_update(bContext *C, TransInfo *t) BLI_freelistN(&pidlist); /* pointcache refresh */ - if (BKE_ptcache_object_reset(t->scene, ob, PTCACHE_RESET_OUTDATED)) + if (BKE_ptcache_object_reset(t->scene, ob, PTCACHE_RESET_OUTDATED)) { DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY); + } /* Needed for proper updating of "quick cached" dynamics. */ /* Creates troubles for moving animated objects without */ @@ -7197,13 +7439,14 @@ void special_aftertrans_update(bContext *C, TransInfo *t) /* restore rigid body transform */ if (ob->rigidbody_object && canceled) { float ctime = BKE_scene_frame_get(t->scene); - if (BKE_rigidbody_check_sim_running(t->scene->rigidbody_world, ctime)) + if (BKE_rigidbody_check_sim_running(t->scene->rigidbody_world, ctime)) { BKE_rigidbody_aftertrans_update(ob, td->ext->oloc, td->ext->orot, td->ext->oquat, td->ext->orotAxis, td->ext->orotAngle); + } } } @@ -7489,8 +7732,9 @@ static void markerToTransDataInit(TransData *td, copy_v2_v2(tdt->srelative, rel); } - if (off) + if (off) { copy_v2_v2(tdt->soffset, off); + } td->flag = 0; td->loc = td2d->loc; @@ -7642,8 +7886,9 @@ static void transDataTrackingFree(TransInfo *UNUSED(t), { if (custom_data->data) { TransDataTracking *tdt = custom_data->data; - if (tdt->smarkers) + if (tdt->smarkers) { MEM_freeN(tdt->smarkers); + } MEM_freeN(tdt); custom_data->data = NULL; @@ -7673,14 +7918,17 @@ static void createTransTrackingTracksData(bContext *C, TransInfo *t) if (TRACK_VIEW_SELECTED(sc, track) && (track->flag & TRACK_LOCKED) == 0) { tc->data_len++; /* offset */ - if (track->flag & SELECT) + if (track->flag & SELECT) { tc->data_len++; + } - if (track->pat_flag & SELECT) + if (track->pat_flag & SELECT) { tc->data_len += 4; + } - if (track->search_flag & SELECT) + if (track->search_flag & SELECT) { tc->data_len += 2; + } } track = track->next; @@ -7692,8 +7940,9 @@ static void createTransTrackingTracksData(bContext *C, TransInfo *t) } } - if (tc->data_len == 0) + if (tc->data_len == 0) { return; + } td = tc->data = MEM_callocN(tc->data_len * sizeof(TransData), "TransTracking TransData"); td2d = tc->data_2d = MEM_callocN(tc->data_len * sizeof(TransData2D), @@ -7821,22 +8070,26 @@ static void createTransTrackingCurvesData(bContext *C, TransInfo *t) marker = &track->markers[i]; prev_marker = &track->markers[i - 1]; - if ((marker->flag & MARKER_DISABLED) || (prev_marker->flag & MARKER_DISABLED)) + if ((marker->flag & MARKER_DISABLED) || (prev_marker->flag & MARKER_DISABLED)) { continue; + } - if (marker->flag & MARKER_GRAPH_SEL_X) + if (marker->flag & MARKER_GRAPH_SEL_X) { tc->data_len += 1; + } - if (marker->flag & MARKER_GRAPH_SEL_Y) + if (marker->flag & MARKER_GRAPH_SEL_Y) { tc->data_len += 1; + } } } track = track->next; } - if (tc->data_len == 0) + if (tc->data_len == 0) { return; + } td = tc->data = MEM_callocN(tc->data_len * sizeof(TransData), "TransTracking TransData"); td2d = tc->data_2d = MEM_callocN(tc->data_len * sizeof(TransData2D), @@ -7853,8 +8106,9 @@ static void createTransTrackingCurvesData(bContext *C, TransInfo *t) marker = &track->markers[i]; prev_marker = &track->markers[i - 1]; - if ((marker->flag & MARKER_DISABLED) || (prev_marker->flag & MARKER_DISABLED)) + if ((marker->flag & MARKER_DISABLED) || (prev_marker->flag & MARKER_DISABLED)) { continue; + } if (marker->flag & MARKER_GRAPH_SEL_X) { markerToTransCurveDataInit( @@ -7890,13 +8144,15 @@ static void createTransTrackingData(bContext *C, TransInfo *t) tc->data_len = 0; - if (!clip) + if (!clip) { return; + } BKE_movieclip_get_size(clip, &sc->user, &width, &height); - if (width == 0 || height == 0) + if (width == 0 || height == 0) { return; + } if (ar->regiontype == RGN_TYPE_PREVIEW) { /* transformation was called from graph editor */ @@ -7924,14 +8180,17 @@ static void cancelTransTracking(TransInfo *t) marker->flag = tdt->flag; - if (track->flag & SELECT) + if (track->flag & SELECT) { i++; + } - if (track->pat_flag & SELECT) + if (track->pat_flag & SELECT) { i += 4; + } - if (track->search_flag & SELECT) + if (track->search_flag & SELECT) { i += 2; + } } else if (tdt->mode == transDataTracking_ModeCurves) { MovieTrackingTrack *track = tdt->track; @@ -7942,8 +8201,9 @@ static void cancelTransTracking(TransInfo *t) marker = &track->markers[a]; prev_marker = &track->markers[a - 1]; - if ((marker->flag & MARKER_DISABLED) || (prev_marker->flag & MARKER_DISABLED)) + if ((marker->flag & MARKER_DISABLED) || (prev_marker->flag & MARKER_DISABLED)) { continue; + } if (marker->flag & (MARKER_GRAPH_SEL_X | MARKER_GRAPH_SEL_Y)) { marker->flag = tdt->flag; @@ -7969,8 +8229,9 @@ void flushTransTracking(TransInfo *t) TransDataTracking *tdt; int a; - if (t->state == TRANS_CANCEL) + if (t->state == TRANS_CANCEL) { cancelTransTracking(t); + } TransDataContainer *tc = TRANS_DATA_CONTAINER_FIRST_SINGLE(t); @@ -7989,8 +8250,9 @@ void flushTransTracking(TransInfo *t) if (t->flag & T_ALT_TRANSFORM) { if (t->mode == TFM_RESIZE) { - if (tdt->area != TRACK_AREA_PAT) + if (tdt->area != TRACK_AREA_PAT) { continue; + } } else if (t->mode == TFM_TRANSLATION) { if (tdt->area == TRACK_AREA_POINT && tdt->relative) { @@ -7999,8 +8261,9 @@ void flushTransTracking(TransInfo *t) if (!tdt->smarkers) { tdt->smarkers = MEM_callocN(sizeof(*tdt->smarkers) * tdt->markersnr, "flushTransTracking markers"); - for (a = 0; a < tdt->markersnr; a++) + for (a = 0; a < tdt->markersnr; a++) { copy_v2_v2(tdt->smarkers[a], tdt->markers[a].pos); + } } sub_v2_v2v2(d, loc2d, tdt->soffset); @@ -8008,8 +8271,9 @@ void flushTransTracking(TransInfo *t) sub_v2_v2v2(d2, loc2d, tdt->srelative); - for (a = 0; a < tdt->markersnr; a++) + for (a = 0; a < tdt->markersnr; a++) { add_v2_v2v2(tdt->markers[a].pos, tdt->smarkers[a], d2); + } negate_v2_v2(td2d->loc2d, d); } @@ -8020,8 +8284,9 @@ void flushTransTracking(TransInfo *t) td2d->loc2d[0] = loc2d[0]; td2d->loc2d[1] = loc2d[1]; - if (tdt->relative) + if (tdt->relative) { sub_v2_v2(td2d->loc2d, tdt->relative); + } } } else if (tdt->mode == transDataTracking_ModeCurves) { @@ -8268,8 +8533,9 @@ static void createTransMaskingData(bContext *C, TransInfo *t) tc->data_len = 0; - if (!mask) + if (!mask) { return; + } if (t->spacetype == SPACE_CLIP) { SpaceClip *sc = t->sa->spacedata.first; @@ -8313,8 +8579,9 @@ static void createTransMaskingData(bContext *C, TransInfo *t) } } - if (is_prop_edit) + if (is_prop_edit) { count += 3; + } } } } @@ -8526,8 +8793,9 @@ static void createTransPaintCurveVerts(bContext *C, TransInfo *t) tc->data_len = 0; - if (!paint || !paint->brush || !paint->brush->paint_curve) + if (!paint || !paint->brush || !paint->brush->paint_curve) { return; + } br = paint->brush; pc = br->paint_curve; @@ -8539,16 +8807,19 @@ static void createTransPaintCurveVerts(bContext *C, TransInfo *t) continue; } else { - if (pcp->bez.f1 & SELECT) + if (pcp->bez.f1 & SELECT) { total++; - if (pcp->bez.f3 & SELECT) + } + if (pcp->bez.f3 & SELECT) { total++; + } } } } - if (!total) + if (!total) { return; + } tc->data_len = total; td2d = tc->data_2d = MEM_callocN(tc->data_len * sizeof(TransData2D), "TransData2D"); @@ -8646,8 +8917,9 @@ static void createTransGPencil(bContext *C, TransInfo *t) */ tc->data_len = 0; - if (gpd == NULL) + if (gpd == NULL) { return; + } /* initialize falloff curve */ if (is_multiedit) { @@ -8683,8 +8955,9 @@ static void createTransGPencil(bContext *C, TransInfo *t) /* Proportional Editing... */ if (is_prop_edit_connected) { /* connected only - so only if selected */ - if (gps->flag & GP_STROKE_SELECT) + if (gps->flag & GP_STROKE_SELECT) { tc->data_len += gps->totpoints; + } } else { /* everything goes - connection status doesn't matter */ @@ -8699,8 +8972,9 @@ static void createTransGPencil(bContext *C, TransInfo *t) // TODO: 2D vs 3D? for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) { - if (pt->flag & GP_SPOINT_SELECT) + if (pt->flag & GP_SPOINT_SELECT) { tc->data_len++; + } } } } diff --git a/source/blender/editors/transform/transform_generics.c b/source/blender/editors/transform/transform_generics.c index 09593a44a54..e816f4b31ff 100644 --- a/source/blender/editors/transform/transform_generics.c +++ b/source/blender/editors/transform/transform_generics.c @@ -167,13 +167,16 @@ static void clipMirrorModifier(TransInfo *t) int clip; float loc[3], iloc[3]; - if (td->flag & TD_NOACTION) + if (td->flag & TD_NOACTION) { break; - if (td->loc == NULL) + } + if (td->loc == NULL) { break; + } - if (td->flag & TD_SKIP) + if (td->flag & TD_SKIP) { continue; + } copy_v3_v3(loc, td->loc); copy_v3_v3(iloc, td->iloc); @@ -227,12 +230,15 @@ static void editbmesh_apply_to_mirror(TransInfo *t) int i; for (i = 0; i < tc->data_len; i++, td++) { - if (td->flag & TD_NOACTION) + if (td->flag & TD_NOACTION) { break; - if (td->loc == NULL) + } + if (td->loc == NULL) { break; - if (td->flag & TD_SKIP) + } + if (td->flag & TD_SKIP) { continue; + } eve = td->extra; if (eve) { @@ -255,8 +261,9 @@ static void animrecord_check_state(Scene *scene, ID *id, wmTimer *animtimer) ScreenAnimData *sad = (animtimer) ? animtimer->customdata : NULL; /* sanity checks */ - if (ELEM(NULL, scene, id, sad)) + if (ELEM(NULL, scene, id, sad)) { return; + } /* check if we need a new strip if: * - if animtimer is running @@ -329,12 +336,14 @@ static bool fcu_test_selected(FCurve *fcu) BezTriple *bezt = fcu->bezt; unsigned int i; - if (bezt == NULL) /* ignore baked */ + if (bezt == NULL) { /* ignore baked */ return 0; + } for (i = 0; i < fcu->totvert; i++, bezt++) { - if (BEZT_ISSEL_ANY(bezt)) + if (BEZT_ISSEL_ANY(bezt)) { return 1; + } } return 0; @@ -430,25 +439,30 @@ static void recalcData_graphedit(TransInfo *t) FCurve *fcu = (FCurve *)ale->key_data; /* ignore FC-Curves without any selected verts */ - if (!fcu_test_selected(fcu)) + if (!fcu_test_selected(fcu)) { continue; + } /* watch it: if the time is wrong: do not correct handles yet */ - if (test_time_fcurve(fcu)) + if (test_time_fcurve(fcu)) { dosort++; - else + } + else { calchandles_fcurve(fcu); + } /* set refresh tags for objects using this animation, * BUT only if realtime updates are enabled */ - if ((sipo->flag & SIPO_NOREALTIMEUPDATES) == 0) + if ((sipo->flag & SIPO_NOREALTIMEUPDATES) == 0) { ANIM_list_elem_update(CTX_data_main(t->context), t->scene, ale); + } } /* do resort and other updates? */ - if (dosort) + if (dosort) { remake_graph_transdata(t, &anim_data); + } /* now free temp channels */ ANIM_animdata_freelist(&anim_data); @@ -476,14 +490,16 @@ static void recalcData_nla(TransInfo *t) int delta_y1, delta_y2; /* if this tdn has no handles, that means it is just a dummy that should be skipped */ - if (tdn->handle == 0) + if (tdn->handle == 0) { continue; + } /* set refresh tags for objects using this animation, * BUT only if realtime updates are enabled */ - if ((snla->flag & SNLA_NOREALTIMEUPDATES) == 0) + if ((snla->flag & SNLA_NOREALTIMEUPDATES) == 0) { ANIM_id_update(CTX_data_main(t->context), tdn->id); + } /* if canceling transform, just write the values without validating, then move on */ if (t->state == TRANS_CANCEL) { @@ -494,14 +510,16 @@ static void recalcData_nla(TransInfo *t) /* start */ strip->start = tdn->h1[0]; - if ((strip->prev) && (strip->prev->type == NLASTRIP_TYPE_TRANSITION)) + if ((strip->prev) && (strip->prev->type == NLASTRIP_TYPE_TRANSITION)) { strip->prev->end = tdn->h1[0]; + } /* end */ strip->end = tdn->h2[0]; - if ((strip->next) && (strip->next->type == NLASTRIP_TYPE_TRANSITION)) + if ((strip->next) && (strip->next->type == NLASTRIP_TYPE_TRANSITION)) { strip->next->start = tdn->h2[0]; + } /* flush transforms to child strips (since this should be a meta) */ BKE_nlameta_flush_transforms(strip); @@ -557,8 +575,9 @@ static void recalcData_nla(TransInfo *t) tdn->h1[0] += offset; tdn->h2[0] += offset; } - else /* all is fine and well */ + else { /* all is fine and well */ break; + } } /* handle auto-snapping @@ -649,8 +668,9 @@ static void recalcData_nla(TransInfo *t) tdn->nlt = track; tdn->trackIndex++; } - else /* can't move any further */ + else { /* can't move any further */ break; + } } } else { @@ -667,8 +687,9 @@ static void recalcData_nla(TransInfo *t) tdn->nlt = track; tdn->trackIndex--; } - else /* can't move any further */ + else { /* can't move any further */ break; + } } } } @@ -697,8 +718,9 @@ static void recalcData_image(TransInfo *t) SpaceImage *sima = t->sa->spacedata.first; flushTransUVs(t); - if (sima->flag & SI_LIVE_UNWRAP) + if (sima->flag & SI_LIVE_UNWRAP) { ED_uvedit_live_unwrap_re_solve(); + } FOREACH_TRANS_DATA_CONTAINER (t, tc) { if (tc->data_len) { @@ -727,20 +749,25 @@ static void recalcData_spaceclip(TransInfo *t) MovieTrackingMarker *marker = BKE_tracking_marker_get(track, framenr); if (t->mode == TFM_TRANSLATION) { - if (TRACK_AREA_SELECTED(track, TRACK_AREA_PAT)) + if (TRACK_AREA_SELECTED(track, TRACK_AREA_PAT)) { BKE_tracking_marker_clamp(marker, CLAMP_PAT_POS); - if (TRACK_AREA_SELECTED(track, TRACK_AREA_SEARCH)) + } + if (TRACK_AREA_SELECTED(track, TRACK_AREA_SEARCH)) { BKE_tracking_marker_clamp(marker, CLAMP_SEARCH_POS); + } } else if (t->mode == TFM_RESIZE) { - if (TRACK_AREA_SELECTED(track, TRACK_AREA_PAT)) + if (TRACK_AREA_SELECTED(track, TRACK_AREA_PAT)) { BKE_tracking_marker_clamp(marker, CLAMP_PAT_DIM); - if (TRACK_AREA_SELECTED(track, TRACK_AREA_SEARCH)) + } + if (TRACK_AREA_SELECTED(track, TRACK_AREA_SEARCH)) { BKE_tracking_marker_clamp(marker, CLAMP_SEARCH_DIM); + } } else if (t->mode == TFM_ROTATION) { - if (TRACK_AREA_SELECTED(track, TRACK_AREA_PAT)) + if (TRACK_AREA_SELECTED(track, TRACK_AREA_PAT)) { BKE_tracking_marker_clamp(marker, CLAMP_PAT_POS); + } } } @@ -851,14 +878,16 @@ static void recalcData_objects(TransInfo *t) /* If this bone has a parent tip that has been moved */ if (ebo_parent->flag & BONE_TIPSEL) { copy_v3_v3(ebo->head, ebo_parent->tail); - if (t->mode == TFM_BONE_ENVELOPE) + if (t->mode == TFM_BONE_ENVELOPE) { ebo->rad_head = ebo_parent->rad_tail; + } } /* If this bone has a parent tip that has NOT been moved */ else { copy_v3_v3(ebo_parent->tail, ebo->head); - if (t->mode == TFM_BONE_ENVELOPE) + if (t->mode == TFM_BONE_ENVELOPE) { ebo_parent->rad_tail = ebo->rad_head; + } } } @@ -869,8 +898,9 @@ static void recalcData_objects(TransInfo *t) ebo->rad_tail = 0.10f * ebo->length; ebo->dist = 0.25f * ebo->length; if (ebo->parent) { - if (ebo->rad_head > ebo->parent->rad_tail) + if (ebo->rad_head > ebo->parent->rad_tail) { ebo->rad_head = ebo->parent->rad_tail; + } } } else if (t->mode != TFM_BONE_ENVELOPE) { @@ -1005,11 +1035,13 @@ static void recalcData_objects(TransInfo *t) for (int i = 0; i < tc->data_len; i++, td++) { Object *ob = td->ob; - if (td->flag & TD_NOACTION) + if (td->flag & TD_NOACTION) { break; + } - if (td->flag & TD_SKIP) + if (td->flag & TD_SKIP) { continue; + } /* if animtimer is running, and the object already has animation data, * check if the auto-record feature means that we should record 'samples' @@ -1029,8 +1061,9 @@ static void recalcData_objects(TransInfo *t) */ DEG_id_tag_update(&ob->id, ID_RECALC_TRANSFORM); - if (t->flag & T_TEXTURE) + if (t->flag & T_TEXTURE) { DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY); + } } } @@ -1513,10 +1546,12 @@ void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve t->view = &ar->v2d; t->around = sclip->around; - if (ED_space_clip_check_show_trackedit(sclip)) + if (ED_space_clip_check_show_trackedit(sclip)) { t->options |= CTX_MOVIECLIP; - else if (ED_space_clip_check_show_maskedit(sclip)) + } + else if (ED_space_clip_check_show_maskedit(sclip)) { t->options |= CTX_MASK; + } } else { if (ar) { @@ -1724,14 +1759,18 @@ void freeTransCustomDataForMode(TransInfo *t) /* Here I would suggest only TransInfo related issues, like free data & reset vars. Not redraws */ void postTrans(bContext *C, TransInfo *t) { - if (t->draw_handle_view) + if (t->draw_handle_view) { ED_region_draw_cb_exit(t->ar->type, t->draw_handle_view); - if (t->draw_handle_apply) + } + if (t->draw_handle_apply) { ED_region_draw_cb_exit(t->ar->type, t->draw_handle_apply); - if (t->draw_handle_pixel) + } + if (t->draw_handle_pixel) { ED_region_draw_cb_exit(t->ar->type, t->draw_handle_pixel); - if (t->draw_handle_cursor) + } + if (t->draw_handle_cursor) { WM_paint_cursor_end(CTX_wm_manager(C), t->draw_handle_cursor); + } if (t->flag & T_MODAL_CURSOR_SET) { WM_cursor_modal_restore(CTX_wm_window(C)); @@ -1773,8 +1812,9 @@ void postTrans(bContext *C, TransInfo *t) } else { SpaceImage *sima = t->sa->spacedata.first; - if (sima->flag & SI_LIVE_UNWRAP) + if (sima->flag & SI_LIVE_UNWRAP) { ED_uvedit_live_unwrap_end(t->state == TRANS_CANCEL); + } } } else if (t->spacetype == SPACE_VIEW3D) { @@ -2085,12 +2125,15 @@ static void calculateCenter_FromAround(TransInfo *t, int around, float r_center[ calculateCenterMedian(t, r_center); break; case V3D_AROUND_CURSOR: - if (ELEM(t->spacetype, SPACE_IMAGE, SPACE_CLIP)) + if (ELEM(t->spacetype, SPACE_IMAGE, SPACE_CLIP)) { calculateCenterCursor2D(t, r_center); - else if (t->spacetype == SPACE_GRAPH) + } + else if (t->spacetype == SPACE_GRAPH) { calculateCenterCursorGraph2D(t, r_center); - else + } + else { calculateCenterCursor(t, r_center); + } break; case V3D_AROUND_LOCAL_ORIGINS: /* Individual element center uses median center for helpline and such */ @@ -2222,18 +2265,21 @@ void calculatePropRatio(TransInfo *t) /* Use rdist for falloff calculations, it is the real distance */ td->flag &= ~TD_NOACTION; - if (connected) + if (connected) { dist = (t->prop_size - td->dist) / t->prop_size; - else + } + else { dist = (t->prop_size - td->rdist) / t->prop_size; + } /* * Clamp to positive numbers. * Certain corner cases with connectivity and individual centers * can give values of rdist larger than propsize. */ - if (dist < 0.0f) + if (dist < 0.0f) { dist = 0.0f; + } switch (t->prop_mode) { case PROP_SHARP: diff --git a/source/blender/editors/transform/transform_gizmo_2d.c b/source/blender/editors/transform/transform_gizmo_2d.c index f5b8f19ed02..1015b47c304 100644 --- a/source/blender/editors/transform/transform_gizmo_2d.c +++ b/source/blender/editors/transform/transform_gizmo_2d.c @@ -231,8 +231,9 @@ void ED_widgetgroup_gizmo2d_setup(const bContext *UNUSED(C), wmGizmoGroup *gzgro PointerRNA *ptr = WM_gizmo_operator_set(axis, 0, ot_translate, NULL); bool constraint[3] = {0}; constraint[(axis_idx + 1) % 2] = 1; - if (RNA_struct_find_property(ptr, "constraint_axis")) + if (RNA_struct_find_property(ptr, "constraint_axis")) { RNA_boolean_set_array(ptr, "constraint_axis", constraint); + } RNA_boolean_set(ptr, "release_confirm", 1); } MAN2D_ITER_AXES_END; @@ -385,8 +386,9 @@ bool ED_widgetgroup_gizmo2d_poll(const bContext *C, wmGizmoGroupType *UNUSED(gzg /* check if there's a selected poly */ BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) { - if (!uvedit_face_visible_test(scene, obedit, ima, efa)) + if (!uvedit_face_visible_test(scene, obedit, ima, efa)) { continue; + } BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) { if (uvedit_uv_select_test(scene, l, cd_loop_uv_offset)) { diff --git a/source/blender/editors/transform/transform_gizmo_3d.c b/source/blender/editors/transform/transform_gizmo_3d.c index 58762a933c9..50610f1b3da 100644 --- a/source/blender/editors/transform/transform_gizmo_3d.c +++ b/source/blender/editors/transform/transform_gizmo_3d.c @@ -485,26 +485,35 @@ static void calc_tw_center_with_matrix(struct TransformBounds *tbounds, static void protectflag_to_drawflags(short protectflag, short *drawflags) { - if (protectflag & OB_LOCK_LOCX) + if (protectflag & OB_LOCK_LOCX) { *drawflags &= ~MAN_TRANS_X; - if (protectflag & OB_LOCK_LOCY) + } + if (protectflag & OB_LOCK_LOCY) { *drawflags &= ~MAN_TRANS_Y; - if (protectflag & OB_LOCK_LOCZ) + } + if (protectflag & OB_LOCK_LOCZ) { *drawflags &= ~MAN_TRANS_Z; + } - if (protectflag & OB_LOCK_ROTX) + if (protectflag & OB_LOCK_ROTX) { *drawflags &= ~MAN_ROT_X; - if (protectflag & OB_LOCK_ROTY) + } + if (protectflag & OB_LOCK_ROTY) { *drawflags &= ~MAN_ROT_Y; - if (protectflag & OB_LOCK_ROTZ) + } + if (protectflag & OB_LOCK_ROTZ) { *drawflags &= ~MAN_ROT_Z; + } - if (protectflag & OB_LOCK_SCALEX) + if (protectflag & OB_LOCK_SCALEX) { *drawflags &= ~MAN_SCALE_X; - if (protectflag & OB_LOCK_SCALEY) + } + if (protectflag & OB_LOCK_SCALEY) { *drawflags &= ~MAN_SCALE_Y; - if (protectflag & OB_LOCK_SCALEZ) + } + if (protectflag & OB_LOCK_SCALEZ) { *drawflags &= ~MAN_SCALE_Z; + } } /* for pose mode */ @@ -1055,8 +1064,9 @@ int ED_transform_calc_gizmo_stats(const bContext *C, if (edit) { point = edit->points; for (a = 0; a < edit->totpoint; a++, point++) { - if (point->flag & PEP_HIDE) + if (point->flag & PEP_HIDE) { continue; + } for (k = 0, ek = point->keys; k < point->totkey; k++, ek++) { if (ek->flag & PEK_SELECT) { @@ -1067,8 +1077,9 @@ int ED_transform_calc_gizmo_stats(const bContext *C, } /* selection center */ - if (totsel) + if (totsel) { mul_v3_fl(tbounds->center, 1.0f / (float)totsel); // centroid! + } } } else { @@ -1076,8 +1087,9 @@ int ED_transform_calc_gizmo_stats(const bContext *C, /* we need the one selected object, if its not active */ base = BASACT(view_layer); ob = OBACT(view_layer); - if (base && ((base->flag & BASE_SELECTED) == 0)) + if (base && ((base->flag & BASE_SELECTED) == 0)) { ob = NULL; + } for (base = view_layer->object_bases.first; base; base = base->next) { if (!BASE_SELECTED_EDITABLE(v3d, base)) { diff --git a/source/blender/editors/transform/transform_input.c b/source/blender/editors/transform/transform_input.c index 46f6e576cf4..6ebed88878f 100644 --- a/source/blender/editors/transform/transform_input.c +++ b/source/blender/editors/transform/transform_input.c @@ -223,8 +223,9 @@ static void InputAngle(TransInfo *UNUSED(t), MouseInput *mi, const double mval[2 float dphi; dphi = saacos((float)deler); - if ((dx1 * dy2 - dx2 * dy1) > 0.0) + if ((dx1 * dy2 - dx2 * dy1) > 0.0) { dphi = -dphi; + } /* If the angle is zero, because of lack of precision close to the 1.0 value in acos * approximate the angle with the opposite side of the normalized triangle @@ -244,8 +245,9 @@ static void InputAngle(TransInfo *UNUSED(t), MouseInput *mi, const double mval[2 dy = dy1 - dy2; dphi = sqrt(dx * dx + dy * dy); - if ((dx1 * dy2 - dx2 * dy1) > 0.0) + if ((dx1 * dy2 - dx2 * dy1) > 0.0) { dphi = -dphi; + } } data->angle += ((double)dphi) * (mi->precision ? (double)mi->precision_factor : 1.0); diff --git a/source/blender/editors/transform/transform_ops.c b/source/blender/editors/transform/transform_ops.c index 14d904fdc6d..b4c539fba8e 100644 --- a/source/blender/editors/transform/transform_ops.c +++ b/source/blender/editors/transform/transform_ops.c @@ -230,8 +230,9 @@ static bool delete_orientation_poll(bContext *C) { Scene *scene = CTX_data_scene(C); - if (ED_operator_areaactive(C) == 0) + if (ED_operator_areaactive(C) == 0) { return 0; + } return ((scene->orientation_slots[SCE_ORIENT_DEFAULT].type >= V3D_ORIENT_CUSTOM) && (scene->orientation_slots[SCE_ORIENT_DEFAULT].index_custom != -1)); @@ -403,8 +404,9 @@ static int transform_modal(bContext *C, wmOperator *op, const wmEvent *event) // in other words, 2D deltas are no longer good enough! // disable until individual 'transformers' behave better - if (event->type == NDOF_MOTION) + if (event->type == NDOF_MOTION) { return OPERATOR_PASS_THROUGH; + } #endif /* XXX insert keys are called here, and require context */ diff --git a/source/blender/editors/transform/transform_orientations.c b/source/blender/editors/transform/transform_orientations.c index c0770392eff..e16579aba64 100644 --- a/source/blender/editors/transform/transform_orientations.c +++ b/source/blender/editors/transform/transform_orientations.c @@ -100,8 +100,9 @@ static TransformOrientation *createViewSpace(bContext *C, RegionView3D *rv3d = CTX_wm_region_view3d(C); float mat[3][3]; - if (!rv3d) + if (!rv3d) { return NULL; + } copy_m3_m4(mat, rv3d->viewinv); normalize_m3(mat); @@ -129,8 +130,9 @@ static TransformOrientation *createObjectSpace(bContext *C, Object *ob; float mat[3][3]; - if (base == NULL) + if (base == NULL) { return NULL; + } ob = base->object; @@ -309,12 +311,15 @@ void BIF_createTransformOrientation(bContext *C, Object *obedit = CTX_data_edit_object(C); Object *ob = CTX_data_active_object(C); if (obedit) { - if (obedit->type == OB_MESH) + if (obedit->type == OB_MESH) { ts = createMeshSpace(C, reports, name, overwrite); - else if (obedit->type == OB_ARMATURE) + } + else if (obedit->type == OB_ARMATURE) { ts = createBoneSpace(C, reports, name, overwrite); - else if (obedit->type == OB_CURVE) + } + else if (obedit->type == OB_CURVE) { ts = createCurveSpace(C, reports, name, overwrite); + } } else if (ob && (ob->mode & OB_MODE_POSE)) { ts = createBoneSpace(C, reports, name, overwrite); @@ -868,12 +873,15 @@ int getTransformOrientation_ex(const bContext *C, #define SEL_F3 (1 << 2) if (use_handle) { - if (bezt->f1 & SELECT) + if (bezt->f1 & SELECT) { flag |= SEL_F1; - if (bezt->f2 & SELECT) + } + if (bezt->f2 & SELECT) { flag |= SEL_F2; - if (bezt->f3 & SELECT) + } + if (bezt->f3 & SELECT) { flag |= SEL_F3; + } } else { flag = (bezt->f2 & SELECT) ? (SEL_F1 | SEL_F2 | SEL_F3) : 0; diff --git a/source/blender/editors/transform/transform_snap.c b/source/blender/editors/transform/transform_snap.c index da32908363a..e8bd8e905c9 100644 --- a/source/blender/editors/transform/transform_snap.c +++ b/source/blender/editors/transform/transform_snap.c @@ -152,8 +152,9 @@ void drawSnapping(const struct bContext *C, TransInfo *t) { unsigned char col[4], selectedCol[4], activeCol[4]; - if (!activeSnap(t)) + if (!activeSnap(t)) { return; + } UI_GetThemeColor3ubv(TH_TRANSFORM, col); col[3] = 128; @@ -295,14 +296,17 @@ void applyProject(TransInfo *t) float iloc[3], loc[3], no[3]; float mval_fl[2]; - if (td->flag & TD_NOACTION) + if (td->flag & TD_NOACTION) { break; + } - if (td->flag & TD_SKIP) + if (td->flag & TD_SKIP) { continue; + } - if ((t->flag & T_PROP_EDIT) && (td->factor == 0.0f)) + if ((t->flag & T_PROP_EDIT) && (td->factor == 0.0f)) { continue; + } copy_v3_v3(iloc, td->loc); if (tc->use_local_mat) { @@ -368,12 +372,14 @@ void applyGridAbsolute(TransInfo *t) GearsType grid_action; int i; - if (!(activeSnap(t) && (t->tsnap.mode & (SCE_SNAP_MODE_INCREMENT | SCE_SNAP_MODE_GRID)))) + if (!(activeSnap(t) && (t->tsnap.mode & (SCE_SNAP_MODE_INCREMENT | SCE_SNAP_MODE_GRID)))) { return; + } grid_action = BIG_GEARS; - if (t->modifiers & MOD_PRECISION) + if (t->modifiers & MOD_PRECISION) { grid_action = SMALL_GEARS; + } switch (grid_action) { case NO_GEARS: @@ -387,8 +393,9 @@ void applyGridAbsolute(TransInfo *t) break; } /* early exit on unusable grid size */ - if (grid_size == 0.0f) + if (grid_size == 0.0f) { return; + } FOREACH_TRANS_DATA_CONTAINER (t, tc) { TransData *td; @@ -396,14 +403,17 @@ void applyGridAbsolute(TransInfo *t) for (i = 0, td = tc->data; i < tc->data_len; i++, td++) { float iloc[3], loc[3], tvec[3]; - if (td->flag & TD_NOACTION) + if (td->flag & TD_NOACTION) { break; + } - if (td->flag & TD_SKIP) + if (td->flag & TD_SKIP) { continue; + } - if ((t->flag & T_PROP_EDIT) && (td->factor == 0.0f)) + if ((t->flag & T_PROP_EDIT) && (td->factor == 0.0f)) { continue; + } copy_v3_v3(iloc, td->loc); if (tc->use_local_mat) { @@ -541,8 +551,9 @@ static void initSnappingMode(TransInfo *t) } else { /* force project off when not supported */ - if ((ts->snap_mode & SCE_SNAP_MODE_FACE) == 0) + if ((ts->snap_mode & SCE_SNAP_MODE_FACE) == 0) { t->tsnap.project = 0; + } t->tsnap.mode = ts->snap_mode; } @@ -851,10 +862,12 @@ static void ApplySnapTranslation(TransInfo *t, float vec[3]) if (t->spacetype == SPACE_NODE) { char border = t->tsnap.snapNodeBorder; - if (border & (NODE_LEFT | NODE_RIGHT)) + if (border & (NODE_LEFT | NODE_RIGHT)) { vec[0] = point[0] - t->tsnap.snapTarget[0]; - if (border & (NODE_BOTTOM | NODE_TOP)) + } + if (border & (NODE_BOTTOM | NODE_TOP)) { vec[1] = point[1] - t->tsnap.snapTarget[1]; + } } else { if (t->spacetype == SPACE_VIEW3D) { @@ -921,10 +934,12 @@ static float RotationBetween(TransInfo *t, const float p1[3], const float p2[3]) cross_v3_v3v3(tmp, start, end); - if (dot_v3v3(tmp, axis) < 0.0f) + if (dot_v3v3(tmp, axis) < 0.0f) { angle = -acosf(dot_v3v3(start, end)); - else + } + else { angle = acosf(dot_v3v3(start, end)); + } } else { float mtx[3][3]; @@ -1062,23 +1077,31 @@ static void TargetSnapOffset(TransInfo *t, TransData *td) float height = BLI_rctf_size_y(&node->totr); #ifdef USE_NODE_CENTER - if (border & NODE_LEFT) + if (border & NODE_LEFT) { t->tsnap.snapTarget[0] -= 0.5f * width; - if (border & NODE_RIGHT) + } + if (border & NODE_RIGHT) { t->tsnap.snapTarget[0] += 0.5f * width; - if (border & NODE_BOTTOM) + } + if (border & NODE_BOTTOM) { t->tsnap.snapTarget[1] -= 0.5f * height; - if (border & NODE_TOP) + } + if (border & NODE_TOP) { t->tsnap.snapTarget[1] += 0.5f * height; + } #else - if (border & NODE_LEFT) + if (border & NODE_LEFT) { t->tsnap.snapTarget[0] -= 0.0f; - if (border & NODE_RIGHT) + } + if (border & NODE_RIGHT) { t->tsnap.snapTarget[0] += width; - if (border & NODE_BOTTOM) + } + if (border & NODE_BOTTOM) { t->tsnap.snapTarget[1] -= height; - if (border & NODE_TOP) + } + if (border & NODE_TOP) { t->tsnap.snapTarget[1] += 0.0f; + } #endif } } @@ -1502,8 +1525,9 @@ void snapSequenceBounds(TransInfo *t, const int mval[2]) int mframe; TransSeq *ts = TRANS_DATA_CONTAINER_FIRST_SINGLE(t)->custom.type.data; /* reuse increment, strictly speaking could be another snap mode, but leave as is */ - if (!(t->modifiers & MOD_SNAP_INVERT)) + if (!(t->modifiers & MOD_SNAP_INVERT)) { return; + } /* convert to frame range */ UI_view2d_region_to_view(&t->ar->v2d, mval[0], mval[1], &xmouse, &ymouse); @@ -1511,8 +1535,9 @@ void snapSequenceBounds(TransInfo *t, const int mval[2]) /* now find the closest sequence */ frame = BKE_sequencer_find_next_prev_edit(t->scene, mframe, SEQ_SIDE_BOTH, true, false, true); - if (!ts->snap_left) + if (!ts->snap_left) { frame = frame - (ts->max - ts->min); + } t->values[0] = frame - ts->min; } diff --git a/source/blender/editors/transform/transform_snap_object.c b/source/blender/editors/transform/transform_snap_object.c index 5d4867f5ef9..9174f6950ae 100644 --- a/source/blender/editors/transform/transform_snap_object.c +++ b/source/blender/editors/transform/transform_snap_object.c @@ -956,8 +956,9 @@ static void cb_mlooptri_edges_get(const int index, int v_index[3], const BVHTree //printf("real edge found\n"); v_index[j] = mloop[lt->tri[j]].e; } - else + else { v_index[j] = -1; + } } } |