From 620b960d3d8cfd90b9f0df6ba3671c33eccb8309 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 22 Apr 2019 09:19:45 +1000 Subject: Cleanup: style, use braces for editors --- source/blender/editors/object/object_transform.c | 126 +++++++++++++++-------- 1 file changed, 84 insertions(+), 42 deletions(-) (limited to 'source/blender/editors/object/object_transform.c') diff --git a/source/blender/editors/object/object_transform.c b/source/blender/editors/object/object_transform.c index b7efb22a628..9e1ef96ab93 100644 --- a/source/blender/editors/object/object_transform.c +++ b/source/blender/editors/object/object_transform.c @@ -82,18 +82,21 @@ static void object_clear_loc(Object *ob, const bool clear_delta) /* clear location if not locked */ if ((ob->protectflag & OB_LOCK_LOCX) == 0) { ob->loc[0] = 0.0f; - if (clear_delta) + if (clear_delta) { ob->dloc[0] = 0.0f; + } } if ((ob->protectflag & OB_LOCK_LOCY) == 0) { ob->loc[1] = 0.0f; - if (clear_delta) + if (clear_delta) { ob->dloc[1] = 0.0f; + } } if ((ob->protectflag & OB_LOCK_LOCZ) == 0) { ob->loc[2] = 0.0f; - if (clear_delta) + if (clear_delta) { ob->dloc[2] = 0.0f; + } } } @@ -107,53 +110,63 @@ static void object_clear_rot(Object *ob, const bool clear_delta) if (ob->rotmode == ROT_MODE_AXISANGLE) { if ((ob->protectflag & OB_LOCK_ROTW) == 0) { ob->rotAngle = 0.0f; - if (clear_delta) + if (clear_delta) { ob->drotAngle = 0.0f; + } } if ((ob->protectflag & OB_LOCK_ROTX) == 0) { ob->rotAxis[0] = 0.0f; - if (clear_delta) + if (clear_delta) { ob->drotAxis[0] = 0.0f; + } } if ((ob->protectflag & OB_LOCK_ROTY) == 0) { ob->rotAxis[1] = 0.0f; - if (clear_delta) + if (clear_delta) { ob->drotAxis[1] = 0.0f; + } } if ((ob->protectflag & OB_LOCK_ROTZ) == 0) { ob->rotAxis[2] = 0.0f; - if (clear_delta) + if (clear_delta) { ob->drotAxis[2] = 0.0f; + } } /* Check validity of axis - axis should never be 0,0,0 * (if so, then we make it rotate about y). */ - if (IS_EQF(ob->rotAxis[0], ob->rotAxis[1]) && IS_EQF(ob->rotAxis[1], ob->rotAxis[2])) + if (IS_EQF(ob->rotAxis[0], ob->rotAxis[1]) && IS_EQF(ob->rotAxis[1], ob->rotAxis[2])) { ob->rotAxis[1] = 1.0f; + } if (IS_EQF(ob->drotAxis[0], ob->drotAxis[1]) && IS_EQF(ob->drotAxis[1], ob->drotAxis[2]) && - clear_delta) + clear_delta) { ob->drotAxis[1] = 1.0f; + } } else if (ob->rotmode == ROT_MODE_QUAT) { if ((ob->protectflag & OB_LOCK_ROTW) == 0) { ob->quat[0] = 1.0f; - if (clear_delta) + if (clear_delta) { ob->dquat[0] = 1.0f; + } } if ((ob->protectflag & OB_LOCK_ROTX) == 0) { ob->quat[1] = 0.0f; - if (clear_delta) + if (clear_delta) { ob->dquat[1] = 0.0f; + } } if ((ob->protectflag & OB_LOCK_ROTY) == 0) { ob->quat[2] = 0.0f; - if (clear_delta) + if (clear_delta) { ob->dquat[2] = 0.0f; + } } if ((ob->protectflag & OB_LOCK_ROTZ) == 0) { ob->quat[3] = 0.0f; - if (clear_delta) + if (clear_delta) { ob->dquat[3] = 0.0f; + } } /* TODO: does this quat need normalizing now? */ } @@ -161,18 +174,21 @@ static void object_clear_rot(Object *ob, const bool clear_delta) /* the flag may have been set for the other modes, so just ignore the extra flag... */ if ((ob->protectflag & OB_LOCK_ROTX) == 0) { ob->rot[0] = 0.0f; - if (clear_delta) + if (clear_delta) { ob->drot[0] = 0.0f; + } } if ((ob->protectflag & OB_LOCK_ROTY) == 0) { ob->rot[1] = 0.0f; - if (clear_delta) + if (clear_delta) { ob->drot[1] = 0.0f; + } } if ((ob->protectflag & OB_LOCK_ROTZ) == 0) { ob->rot[2] = 0.0f; - if (clear_delta) + if (clear_delta) { ob->drot[2] = 0.0f; + } } } } @@ -194,12 +210,15 @@ static void object_clear_rot(Object *ob, const bool clear_delta) eul[0] = eul[1] = eul[2] = 0.0f; - if (ob->protectflag & OB_LOCK_ROTX) + if (ob->protectflag & OB_LOCK_ROTX) { eul[0] = oldeul[0]; - if (ob->protectflag & OB_LOCK_ROTY) + } + if (ob->protectflag & OB_LOCK_ROTY) { eul[1] = oldeul[1]; - if (ob->protectflag & OB_LOCK_ROTZ) + } + if (ob->protectflag & OB_LOCK_ROTZ) { eul[2] = oldeul[2]; + } if (ob->rotmode == ROT_MODE_QUAT) { eul_to_quat(ob->quat, eul); @@ -219,18 +238,21 @@ static void object_clear_rot(Object *ob, const bool clear_delta) else { if (ob->rotmode == ROT_MODE_QUAT) { unit_qt(ob->quat); - if (clear_delta) + if (clear_delta) { unit_qt(ob->dquat); + } } else if (ob->rotmode == ROT_MODE_AXISANGLE) { unit_axis_angle(ob->rotAxis, &ob->rotAngle); - if (clear_delta) + if (clear_delta) { unit_axis_angle(ob->drotAxis, &ob->drotAngle); + } } else { zero_v3(ob->rot); - if (clear_delta) + if (clear_delta) { zero_v3(ob->drot); + } } } } @@ -241,18 +263,21 @@ static void object_clear_scale(Object *ob, const bool clear_delta) /* clear scale factors which are not locked */ if ((ob->protectflag & OB_LOCK_SCALEX) == 0) { ob->scale[0] = 1.0f; - if (clear_delta) + if (clear_delta) { ob->dscale[0] = 1.0f; + } } if ((ob->protectflag & OB_LOCK_SCALEY) == 0) { ob->scale[1] = 1.0f; - if (clear_delta) + if (clear_delta) { ob->dscale[1] = 1.0f; + } } if ((ob->protectflag & OB_LOCK_SCALEZ) == 0) { ob->scale[2] = 1.0f; - if (clear_delta) + if (clear_delta) { ob->dscale[2] = 1.0f; + } } } @@ -585,8 +610,9 @@ static int apply_objects_internal(bContext *C, } CTX_DATA_END; - if (!changed) + if (!changed) { return OPERATOR_CANCELLED; + } changed = false; @@ -594,10 +620,12 @@ static int apply_objects_internal(bContext *C, CTX_DATA_BEGIN (C, Object *, ob, selected_editable_objects) { /* calculate rotation/scale matrix */ - if (apply_scale && apply_rot) + if (apply_scale && apply_rot) { BKE_object_to_mat3(ob, rsmat); - else if (apply_scale) + } + else if (apply_scale) { BKE_object_scale_to_mat3(ob, rsmat); + } else if (apply_rot) { float tmat[3][3], timat[3][3]; @@ -610,8 +638,9 @@ static int apply_objects_internal(bContext *C, mul_m3_m3m3(rsmat, timat, rsmat); mul_m3_m3m3(rsmat, rsmat, tmat); } - else + else { unit_m3(rsmat); + } copy_m4_m3(mat, rsmat); @@ -633,8 +662,9 @@ static int apply_objects_internal(bContext *C, if (ob->type == OB_MESH) { Mesh *me = ob->data; - if (apply_scale) + if (apply_scale) { multiresModifier_scale_disp(depsgraph, scene, ob); + } /* adjust data */ BKE_mesh_transform(me, mat, true); @@ -687,11 +717,13 @@ static int apply_objects_internal(bContext *C, /* applying scale on camera actually scales clip's reconstruction. * of there's clip assigned to camera nothing to do actually. */ - if (!clip) + if (!clip) { continue; + } - if (apply_scale) + if (apply_scale) { BKE_tracking_reconstruction_scale(&clip->tracking, ob->scale); + } } else if (ob->type == OB_EMPTY) { /* It's possible for empties too, even though they don't @@ -735,10 +767,12 @@ static int apply_objects_internal(bContext *C, continue; } - if (apply_loc) + if (apply_loc) { zero_v3(ob->loc); - if (apply_scale) + } + if (apply_scale) { ob->scale[0] = ob->scale[1] = ob->scale[2] = 1.0f; + } if (apply_rot) { zero_v3(ob->rot); unit_qt(ob->quat); @@ -785,8 +819,9 @@ static int visual_transform_apply_exec(bContext *C, wmOperator *UNUSED(op)) } CTX_DATA_END; - if (!changed) + if (!changed) { return OPERATOR_CANCELLED; + } WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL); return OPERATOR_FINISHED; @@ -959,10 +994,12 @@ static int object_origin_set_exec(bContext *C, wmOperator *op) } for (tob = bmain->objects.first; tob; tob = tob->id.next) { - if (tob->data) + if (tob->data) { ((ID *)tob->data)->tag &= ~LIB_TAG_DOIT; - if (tob->instance_collection) + } + if (tob->instance_collection) { ((ID *)tob->instance_collection)->tag &= ~LIB_TAG_DOIT; + } } for (ctx_ob = ctx_data_list.first; ctx_ob; ctx_ob = ctx_ob->next) { @@ -1050,8 +1087,9 @@ static int object_origin_set_exec(bContext *C, wmOperator *op) } /* don't allow Z change if curve is 2D */ - if ((ob->type == OB_CURVE) && !(cu->flag & CU_3D)) + if ((ob->type == OB_CURVE) && !(cu->flag & CU_3D)) { cent[2] = 0.0; + } negate_v3_v3(cent_neg, cent); BKE_curve_translate(cu, cent_neg, 1); @@ -1120,8 +1158,9 @@ static int object_origin_set_exec(bContext *C, wmOperator *op) ignore_parent_tx(C, bmain, scene, ob); - if (obedit) + if (obedit) { break; + } } } else if (ob->type == OB_MBALL) { @@ -1207,8 +1246,9 @@ static int object_origin_set_exec(bContext *C, wmOperator *op) for (bGPDframe *gpf = gpl->frames.first; gpf; gpf = gpf->next) { for (bGPDstroke *gps = gpf->strokes.first; gps; gps = gps->next) { /* skip strokes that are invalid for current view */ - if (ED_gpencil_stroke_can_use(C, gps) == false) + if (ED_gpencil_stroke_can_use(C, gps) == false) { continue; + } for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) { float mpt[3]; @@ -1308,11 +1348,13 @@ static int object_origin_set_exec(bContext *C, wmOperator *op) "%i object(s) not centered, %i changed:", tot_lib_error + tot_multiuser_arm_error, tot_change); - if (tot_lib_error) + if (tot_lib_error) { BKE_reportf(op->reports, RPT_WARNING, "|%i linked library object(s)", tot_lib_error); - if (tot_multiuser_arm_error) + } + if (tot_multiuser_arm_error) { BKE_reportf( op->reports, RPT_WARNING, "|%i multiuser armature object(s)", tot_multiuser_arm_error); + } } return OPERATOR_FINISHED; -- cgit v1.2.3