From ce3b78c73a7ccc16fdccf7decedb5d1578dfdf0a Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 26 Mar 2019 21:16:47 +1100 Subject: Cleanup: style, use braces for editor/spaces --- source/blender/editors/space_view3d/drawobject.c | 12 +- source/blender/editors/space_view3d/space_view3d.c | 113 +++++++++++------ .../blender/editors/space_view3d/view3d_buttons.c | 44 ++++--- .../editors/space_view3d/view3d_camera_control.c | 3 +- source/blender/editors/space_view3d/view3d_draw.c | 119 ++++++++++++------ .../editors/space_view3d/view3d_draw_legacy.c | 89 +++++++++----- source/blender/editors/space_view3d/view3d_edit.c | 110 ++++++++++++----- source/blender/editors/space_view3d/view3d_fly.c | 135 +++++++++++++++------ .../editors/space_view3d/view3d_gizmo_armature.c | 3 +- .../editors/space_view3d/view3d_gizmo_camera.c | 3 +- source/blender/editors/space_view3d/view3d_ops.c | 6 +- .../blender/editors/space_view3d/view3d_project.c | 8 +- .../blender/editors/space_view3d/view3d_select.c | 107 +++++++++++----- source/blender/editors/space_view3d/view3d_snap.c | 45 ++++--- .../blender/editors/space_view3d/view3d_toolbar.c | 3 +- source/blender/editors/space_view3d/view3d_utils.c | 132 ++++++++++++++------ source/blender/editors/space_view3d/view3d_view.c | 51 +++++--- source/blender/editors/space_view3d/view3d_walk.c | 67 ++++++---- 18 files changed, 736 insertions(+), 314 deletions(-) (limited to 'source/blender/editors/space_view3d') diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c index b976c231841..d4745247ae3 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -63,15 +63,18 @@ int view3d_effective_drawtype(const struct View3D *v3d) static bool check_ob_drawface_dot(Scene *sce, View3D *vd, char dt) { - if ((sce->toolsettings->selectmode & SCE_SELECT_FACE) == 0) + if ((sce->toolsettings->selectmode & SCE_SELECT_FACE) == 0) { return false; + } - if (G.f & G_FLAG_BACKBUFSEL) + if (G.f & G_FLAG_BACKBUFSEL) { return false; + } /* if its drawing textures with zbuf sel, then don't draw dots */ - if (dt == OB_TEXTURE && vd->shading.type == OB_TEXTURE) + if (dt == OB_TEXTURE && vd->shading.type == OB_TEXTURE) { return false; + } return true; } @@ -330,8 +333,9 @@ void draw_object_select_id( bbs_mesh_face_dot(geom_facedots, world_clip_planes); } - if (select_mode & SCE_SELECT_FACE) + if (select_mode & SCE_SELECT_FACE) { bm_solidoffs = 1 + em->bm->totface; + } else { bm_solidoffs = 1; } diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c index 75f6f9f7c9a..d46c7a292cb 100644 --- a/source/blender/editors/space_view3d/space_view3d.c +++ b/source/blender/editors/space_view3d/space_view3d.c @@ -88,13 +88,17 @@ ARegion *view3d_has_buttons_region(ScrArea *sa) ARegion *ar, *arnew; ar = BKE_area_find_region_type(sa, RGN_TYPE_UI); - if (ar) return ar; + if (ar) { + return ar; + } /* add subdiv level; after header */ ar = BKE_area_find_region_type(sa, RGN_TYPE_HEADER); /* is error! */ - if (ar == NULL) return NULL; + if (ar == NULL) { + return NULL; + } arnew = MEM_callocN(sizeof(ARegion), "buttons for view3d"); @@ -112,8 +116,9 @@ ARegion *view3d_has_tools_region(ScrArea *sa) ARegion *ar, *artool = NULL, *arhead; for (ar = sa->regionbase.first; ar; ar = ar->next) { - if (ar->regiontype == RGN_TYPE_TOOLS) + if (ar->regiontype == RGN_TYPE_TOOLS) { artool = ar; + } } /* tool region hide/unhide also hides props */ @@ -123,12 +128,16 @@ ARegion *view3d_has_tools_region(ScrArea *sa) if (artool == NULL) { /* add subdiv level; after header */ - for (arhead = sa->regionbase.first; arhead; arhead = arhead->next) - if (arhead->regiontype == RGN_TYPE_HEADER) + for (arhead = sa->regionbase.first; arhead; arhead = arhead->next) { + if (arhead->regiontype == RGN_TYPE_HEADER) { break; + } + } /* is error! */ - if (arhead == NULL) return NULL; + if (arhead == NULL) { + return NULL; + } artool = MEM_callocN(sizeof(ARegion), "tools for view3d"); @@ -402,14 +411,20 @@ static void view3d_free(SpaceLink *sl) { View3D *vd = (View3D *) sl; - if (vd->localvd) MEM_freeN(vd->localvd); + if (vd->localvd) { + MEM_freeN(vd->localvd); + } - if (vd->properties_storage) MEM_freeN(vd->properties_storage); + if (vd->properties_storage) { + MEM_freeN(vd->properties_storage); + } - if (vd->fx_settings.ssao) + if (vd->fx_settings.ssao) { MEM_freeN(vd->fx_settings.ssao); - if (vd->fx_settings.dof) + } + if (vd->fx_settings.dof) { MEM_freeN(vd->fx_settings.dof); + } } @@ -431,16 +446,19 @@ static SpaceLink *view3d_duplicate(SpaceLink *sl) v3dn->properties_storage = NULL; } - if (v3dn->shading.type == OB_RENDER) + if (v3dn->shading.type == OB_RENDER) { v3dn->shading.type = OB_SOLID; + } /* copy or clear inside new stuff */ v3dn->properties_storage = NULL; - if (v3dn->fx_settings.dof) + if (v3dn->fx_settings.dof) { v3dn->fx_settings.dof = MEM_dupallocN(v3do->fx_settings.dof); - if (v3dn->fx_settings.ssao) + } + if (v3dn->fx_settings.ssao) { v3dn->fx_settings.ssao = MEM_dupallocN(v3do->fx_settings.ssao); + } return (SpaceLink *)v3dn; } @@ -709,14 +727,21 @@ static void view3d_main_region_free(ARegion *ar) RegionView3D *rv3d = ar->regiondata; if (rv3d) { - if (rv3d->localvd) MEM_freeN(rv3d->localvd); - if (rv3d->clipbb) MEM_freeN(rv3d->clipbb); + if (rv3d->localvd) { + MEM_freeN(rv3d->localvd); + } + if (rv3d->clipbb) { + MEM_freeN(rv3d->clipbb); + } - if (rv3d->render_engine) + if (rv3d->render_engine) { RE_engine_free(rv3d->render_engine); + } if (rv3d->depths) { - if (rv3d->depths->depths) MEM_freeN(rv3d->depths->depths); + if (rv3d->depths->depths) { + MEM_freeN(rv3d->depths->depths); + } MEM_freeN(rv3d->depths); } if (rv3d->sms) { @@ -735,10 +760,12 @@ static void *view3d_main_region_duplicate(void *poin) RegionView3D *rv3d = poin, *new; new = MEM_dupallocN(rv3d); - if (rv3d->localvd) + if (rv3d->localvd) { new->localvd = MEM_dupallocN(rv3d->localvd); - if (rv3d->clipbb) + } + if (rv3d->clipbb) { new->clipbb = MEM_dupallocN(rv3d->clipbb); + } new->depths = NULL; new->render_engine = NULL; @@ -773,12 +800,14 @@ static void view3d_main_region_listener( break; case ND_NLA: case ND_KEYFRAME: - if (ELEM(wmn->action, NA_EDITED, NA_ADDED, NA_REMOVED)) + if (ELEM(wmn->action, NA_EDITED, NA_ADDED, NA_REMOVED)) { ED_region_tag_redraw(ar); + } break; case ND_ANIMCHAN: - if (ELEM(wmn->action, NA_EDITED, NA_ADDED, NA_REMOVED, NA_SELECTED)) + if (ELEM(wmn->action, NA_EDITED, NA_ADDED, NA_REMOVED, NA_SELECTED)) { ED_region_tag_redraw(ar); + } break; } break; @@ -821,8 +850,9 @@ static void view3d_main_region_listener( break; } } - if (wmn->action == NA_EDITED) + if (wmn->action == NA_EDITED) { ED_region_tag_redraw(ar); + } break; case NC_OBJECT: switch (wmn->data) { @@ -949,8 +979,9 @@ static void view3d_main_region_listener( ED_region_tag_redraw(ar); break; case NC_MOVIECLIP: - if (wmn->data == ND_DISPLAY || wmn->action == NA_EDITED) + if (wmn->data == ND_DISPLAY || wmn->action == NA_EDITED) { ED_region_tag_redraw(ar); + } break; case NC_SPACE: if (wmn->data == ND_SPACE_VIEW3D) { @@ -962,8 +993,9 @@ static void view3d_main_region_listener( } break; case NC_ID: - if (wmn->action == NA_RENAME) + if (wmn->action == NA_RENAME) { ED_region_tag_redraw(ar); + } break; case NC_SCREEN: switch (wmn->data) { @@ -1136,12 +1168,14 @@ static void view3d_header_region_listener( } break; case NC_SPACE: - if (wmn->data == ND_SPACE_VIEW3D) + if (wmn->data == ND_SPACE_VIEW3D) { ED_region_tag_redraw(ar); + } break; case NC_GPENCIL: - if (wmn->data & ND_GPENCIL_EDITMODE) + if (wmn->data & ND_GPENCIL_EDITMODE) { ED_region_tag_redraw(ar); + } break; } } @@ -1206,8 +1240,9 @@ static void view3d_buttons_region_listener( break; case ND_NLA: case ND_KEYFRAME: - if (ELEM(wmn->action, NA_EDITED, NA_ADDED, NA_REMOVED)) + if (ELEM(wmn->action, NA_EDITED, NA_ADDED, NA_REMOVED)) { ED_region_tag_redraw(ar); + } break; } break; @@ -1251,8 +1286,9 @@ static void view3d_buttons_region_listener( ED_region_tag_redraw(ar); break; } - if (wmn->action == NA_EDITED) + if (wmn->action == NA_EDITED) { ED_region_tag_redraw(ar); + } break; case NC_TEXTURE: case NC_MATERIAL: @@ -1261,25 +1297,30 @@ static void view3d_buttons_region_listener( break; case NC_BRUSH: /* NA_SELECTED is used on brush changes */ - if (ELEM(wmn->action, NA_EDITED, NA_SELECTED)) + if (ELEM(wmn->action, NA_EDITED, NA_SELECTED)) { ED_region_tag_redraw(ar); + } break; case NC_SPACE: - if (wmn->data == ND_SPACE_VIEW3D) + if (wmn->data == ND_SPACE_VIEW3D) { ED_region_tag_redraw(ar); + } break; case NC_ID: - if (wmn->action == NA_RENAME) + if (wmn->action == NA_RENAME) { ED_region_tag_redraw(ar); + } break; case NC_GPENCIL: - if ((wmn->data & (ND_DATA | ND_GPENCIL_EDITMODE)) || (wmn->action == NA_EDITED)) + if ((wmn->data & (ND_DATA | ND_GPENCIL_EDITMODE)) || (wmn->action == NA_EDITED)) { ED_region_tag_redraw(ar); + } break; case NC_IMAGE: /* Update for the image layers in texture paint. */ - if (wmn->action == NA_EDITED) + if (wmn->action == NA_EDITED) { ED_region_tag_redraw(ar); + } break; } } @@ -1311,8 +1352,9 @@ static void space_view3d_listener( case NC_SCENE: switch (wmn->data) { case ND_WORLD: - if (v3d->flag2 & V3D_HIDE_OVERLAYS) + if (v3d->flag2 & V3D_HIDE_OVERLAYS) { ED_area_tag_redraw_regiontype(sa, RGN_TYPE_WINDOW); + } break; } break; @@ -1329,8 +1371,9 @@ static void space_view3d_listener( case NC_MATERIAL: switch (wmn->data) { case ND_NODES: - if (v3d->shading.type == OB_TEXTURE) + if (v3d->shading.type == OB_TEXTURE) { ED_area_tag_redraw_regiontype(sa, RGN_TYPE_WINDOW); + } break; } break; diff --git a/source/blender/editors/space_view3d/view3d_buttons.c b/source/blender/editors/space_view3d/view3d_buttons.c index 706215f8fae..3baf297e580 100644 --- a/source/blender/editors/space_view3d/view3d_buttons.c +++ b/source/blender/editors/space_view3d/view3d_buttons.c @@ -124,10 +124,12 @@ typedef struct { */ static float compute_scale_factor(const float ve_median, const float median) { - if (ve_median <= 0.0f) + if (ve_median <= 0.0f) { return 0.0f; - else if (ve_median >= 1.0f) + } + else if (ve_median >= 1.0f) { return 1.0f; + } else { /* Scale value to target median. */ float median_new = ve_median; @@ -337,8 +339,9 @@ static void v3d_editvertex_buts(uiLayout *layout, View3D *v3d, Object *ob, float nu = nu->next; } - if (totcurvedata == 1) + if (totcurvedata == 1) { RNA_pointer_create(&cu->id, seltype, selp, &data_ptr); + } } else if (ob->type == OB_LATTICE) { Lattice *lt = ob->data; @@ -364,8 +367,9 @@ static void v3d_editvertex_buts(uiLayout *layout, View3D *v3d, Object *ob, float bp++; } - if (totlattdata == 1) + if (totlattdata == 1) { RNA_pointer_create(<->id, seltype, selp, &data_ptr); + } } if (tot == 0) { @@ -375,8 +379,9 @@ static void v3d_editvertex_buts(uiLayout *layout, View3D *v3d, Object *ob, float /* Location, X/Y/Z */ mul_v3_fl(median_basis.generic.location, 1.0f / (float)tot); - if (v3d->flag & V3D_GLOBAL_STATS) + if (v3d->flag & V3D_GLOBAL_STATS) { mul_m4_v3(ob->obmat, median_basis.generic.location); + } if (has_meshdata) { TransformMedian_Mesh *median = &median_basis.mesh; @@ -419,13 +424,18 @@ static void v3d_editvertex_buts(uiLayout *layout, View3D *v3d, Object *ob, float UI_block_align_begin(block); if (tot == 1) { - if (totcurvedata) /* Curve */ + if (totcurvedata) { + /* Curve */ c = IFACE_("Control Point:"); - else /* Mesh or lattice */ + } + else { + /* Mesh or lattice */ c = IFACE_("Vertex:"); + } } - else + else { c = IFACE_("Median:"); + } uiDefBut(block, UI_BTYPE_LABEL, 0, c, 0, yi -= buth, butw, buth, NULL, 0, 0, 0, 0, ""); UI_block_align_begin(block); @@ -993,10 +1003,12 @@ static void v3d_transform_butsR(uiLayout *layout, PointerRNA *ptr) colsub = uiLayoutColumn(split, true); uiLayoutSetEmboss(colsub, UI_EMBOSS_NONE); uiItemR(colsub, ptr, "lock_rotations_4d", UI_ITEM_R_TOGGLE, IFACE_("4L"), ICON_NONE); - if (RNA_boolean_get(ptr, "lock_rotations_4d")) + if (RNA_boolean_get(ptr, "lock_rotations_4d")) { uiItemR(colsub, ptr, "lock_rotation_w", UI_ITEM_R_TOGGLE + UI_ITEM_R_ICON_ONLY, "", ICON_DECORATE_UNLOCKED); - else + } + else { uiItemL(colsub, "", ICON_NONE); + } uiItemR(colsub, ptr, "lock_rotation", UI_ITEM_R_TOGGLE | UI_ITEM_R_ICON_ONLY, "", ICON_DECORATE_UNLOCKED); break; case ROT_MODE_AXISANGLE: /* axis angle */ @@ -1005,10 +1017,12 @@ static void v3d_transform_butsR(uiLayout *layout, PointerRNA *ptr) colsub = uiLayoutColumn(split, true); uiLayoutSetEmboss(colsub, UI_EMBOSS_NONE); uiItemR(colsub, ptr, "lock_rotations_4d", UI_ITEM_R_TOGGLE, IFACE_("4L"), ICON_NONE); - if (RNA_boolean_get(ptr, "lock_rotations_4d")) + if (RNA_boolean_get(ptr, "lock_rotations_4d")) { uiItemR(colsub, ptr, "lock_rotation_w", UI_ITEM_R_TOGGLE | UI_ITEM_R_ICON_ONLY, "", ICON_DECORATE_UNLOCKED); - else + } + else { uiItemL(colsub, "", ICON_NONE); + } uiItemR(colsub, ptr, "lock_rotation", UI_ITEM_R_TOGGLE | UI_ITEM_R_ICON_ONLY, "", ICON_DECORATE_UNLOCKED); break; default: /* euler rotations */ @@ -1093,8 +1107,9 @@ static void v3d_editmetaball_buts(uiLayout *layout, Object *ob) MetaBall *mball = ob->data; uiLayout *col; - if (!mball || !(mball->lastelem)) + if (!mball || !(mball->lastelem)) { return; + } RNA_pointer_create(&mball->id, &RNA_MetaBall, mball, &mbptr); @@ -1257,8 +1272,9 @@ static int view3d_properties_toggle_exec(bContext *C, wmOperator *UNUSED(op)) ScrArea *sa = CTX_wm_area(C); ARegion *ar = view3d_has_buttons_region(sa); - if (ar) + if (ar) { ED_region_toggle_hidden(C, ar); + } return OPERATOR_FINISHED; } diff --git a/source/blender/editors/space_view3d/view3d_camera_control.c b/source/blender/editors/space_view3d/view3d_camera_control.c index d1ff73d1f87..3f7356de465 100644 --- a/source/blender/editors/space_view3d/view3d_camera_control.c +++ b/source/blender/editors/space_view3d/view3d_camera_control.c @@ -162,8 +162,9 @@ struct View3DCameraControl *ED_view3d_cameracontrol_acquire( if (rv3d->persp == RV3D_CAMOB) { Object *ob_back; if (use_parent_root && (vctrl->root_parent = v3d->camera->parent)) { - while (vctrl->root_parent->parent) + while (vctrl->root_parent->parent) { vctrl->root_parent = vctrl->root_parent->parent; + } ob_back = vctrl->root_parent; } else { diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index 5e59c36a80f..cfbc604852b 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -105,10 +105,12 @@ void ED_view3d_update_viewmat( RegionView3D *rv3d = ar->regiondata; /* setup window matrices */ - if (winmat) + if (winmat) { copy_m4_m4(rv3d->winmat, winmat); - else + } + else { view3d_winmatrix_set(depsgraph, ar, v3d, rect); + } /* setup view matrix */ if (viewmat) { @@ -231,8 +233,9 @@ static void view3d_stereo3d_setup( const char *viewname; /* show only left or right camera */ - if (v3d->stereo3d_camera != STEREO_3D_ID) + if (v3d->stereo3d_camera != STEREO_3D_ID) { v3d->multiview_eye = v3d->stereo3d_camera; + } is_left = v3d->multiview_eye == STEREO_LEFT_ID; viewname = names[is_left ? STEREO_LEFT_ID : STEREO_RIGHT_ID]; @@ -305,8 +308,9 @@ static void view3d_camera_border( /* get viewport viewplane */ BKE_camera_params_init(¶ms); BKE_camera_params_from_view3d(¶ms, depsgraph, v3d, rv3d); - if (no_zoom) + if (no_zoom) { params.zoom = 1.0f; + } BKE_camera_params_compute_viewplane(¶ms, ar->winx, ar->winy, 1.0f, 1.0f); rect_view = params.viewplane; @@ -393,7 +397,9 @@ static void drawviewborder_triangle( else { ofs = h * (h / w); } - if (dir == 'B') SWAP(float, y1, y2); + if (dir == 'B') { + SWAP(float, y1, y2); + } immVertex2f(shdr_pos, x1, y1); immVertex2f(shdr_pos, x2, y2); @@ -411,7 +417,9 @@ static void drawviewborder_triangle( else { ofs = w * (w / h); } - if (dir == 'B') SWAP(float, x1, x2); + if (dir == 'B') { + SWAP(float, x1, x2); + } immVertex2f(shdr_pos, x1, y1); immVertex2f(shdr_pos, x2, y2); @@ -435,10 +443,12 @@ static void drawviewborder(Scene *scene, Depsgraph *depsgraph, ARegion *ar, View Camera *ca = NULL; RegionView3D *rv3d = ar->regiondata; - if (v3d->camera == NULL) + if (v3d->camera == NULL) { return; - if (v3d->camera->type == OB_CAMERA) + } + if (v3d->camera->type == OB_CAMERA) { ca = v3d->camera->data; + } ED_view3d_calc_camera_border(scene, depsgraph, ar, v3d, rv3d, &viewborder, false); /* the offsets */ @@ -482,14 +492,18 @@ static void drawviewborder(Scene *scene, Depsgraph *depsgraph, ARegion *ar, View immUniformColor4f(0.0f, 0.0f, 0.0f, alpha); - if (x1i > 0.0f) + if (x1i > 0.0f) { immRectf(shdr_pos, 0.0f, winy, x1i, 0.0f); - if (x2i < winx) + } + if (x2i < winx) { immRectf(shdr_pos, x2i, winy, winx, 0.0f); - if (y2i < winy) + } + if (y2i < winy) { immRectf(shdr_pos, x1i, winy, x2i, y2i); - if (y2i > 0.0f) + } + if (y2i > 0.0f) { immRectf(shdr_pos, x1i, y1i, x2i, 0.0f); + } GPU_blend(false); } @@ -762,8 +776,9 @@ float ED_scene_grid_scale(Scene *scene, const char **grid_unit) if (usys) { int i = bUnit_GetBaseUnit(usys); - if (grid_unit) + if (grid_unit) { *grid_unit = bUnit_GetNameDisplay(usys, i); + } return (float)bUnit_GetScaler(usys, i) / scene->unit.scale_length; } } @@ -963,8 +978,9 @@ static void draw_rotation_guide(const RegionView3D *rv3d) color[3] = 255; /* solid dot */ } - else + else { color[3] = 127; /* see-through dot */ + } immUnbindProgram(); @@ -1026,28 +1042,52 @@ static const char *view3d_get_name(View3D *v3d, RegionView3D *rv3d) switch (rv3d->view) { case RV3D_VIEW_FRONT: - if (rv3d->persp == RV3D_ORTHO) name = IFACE_("Front Orthographic"); - else name = IFACE_("Front Perspective"); + if (rv3d->persp == RV3D_ORTHO) { + name = IFACE_("Front Orthographic"); + } + else { + name = IFACE_("Front Perspective"); + } break; case RV3D_VIEW_BACK: - if (rv3d->persp == RV3D_ORTHO) name = IFACE_("Back Orthographic"); - else name = IFACE_("Back Perspective"); + if (rv3d->persp == RV3D_ORTHO) { + name = IFACE_("Back Orthographic"); + } + else { + name = IFACE_("Back Perspective"); + } break; case RV3D_VIEW_TOP: - if (rv3d->persp == RV3D_ORTHO) name = IFACE_("Top Orthographic"); - else name = IFACE_("Top Perspective"); + if (rv3d->persp == RV3D_ORTHO) { + name = IFACE_("Top Orthographic"); + } + else { + name = IFACE_("Top Perspective"); + } break; case RV3D_VIEW_BOTTOM: - if (rv3d->persp == RV3D_ORTHO) name = IFACE_("Bottom Orthographic"); - else name = IFACE_("Bottom Perspective"); + if (rv3d->persp == RV3D_ORTHO) { + name = IFACE_("Bottom Orthographic"); + } + else { + name = IFACE_("Bottom Perspective"); + } break; case RV3D_VIEW_RIGHT: - if (rv3d->persp == RV3D_ORTHO) name = IFACE_("Right Orthographic"); - else name = IFACE_("Right Perspective"); + if (rv3d->persp == RV3D_ORTHO) { + name = IFACE_("Right Orthographic"); + } + else { + name = IFACE_("Right Perspective"); + } break; case RV3D_VIEW_LEFT: - if (rv3d->persp == RV3D_ORTHO) name = IFACE_("Left Orthographic"); - else name = IFACE_("Left Perspective"); + if (rv3d->persp == RV3D_ORTHO) { + name = IFACE_("Left Orthographic"); + } + else { + name = IFACE_("Left Perspective"); + } break; default: @@ -1217,10 +1257,12 @@ static void draw_selected_name(Scene *scene, ViewLayer *view_layer, Object *ob, } else { /* no object */ - if (ED_gpencil_has_keyframe_v3d(scene, NULL, cfra)) + if (ED_gpencil_has_keyframe_v3d(scene, NULL, cfra)) { UI_FontThemeColor(font_id, TH_TIME_GP_KEYFRAME); - else + } + else { UI_FontThemeColor(font_id, TH_TEXT_HI); + } } if (markern) { @@ -1432,10 +1474,12 @@ void ED_view3d_draw_offscreen( GPU_matrix_push(); GPU_matrix_identity_set(); - if ((viewname != NULL && viewname[0] != '\0') && (viewmat == NULL) && rv3d->persp == RV3D_CAMOB && v3d->camera) + if ((viewname != NULL && viewname[0] != '\0') && (viewmat == NULL) && rv3d->persp == RV3D_CAMOB && v3d->camera) { view3d_stereo3d_setup_offscreen(depsgraph, scene, v3d, ar, winmat, viewname); - else + } + else { view3d_main_region_setup_view(depsgraph, scene, v3d, ar, viewmat, winmat, NULL); + } /* main drawing call */ DRW_draw_render_loop_offscreen( @@ -1638,8 +1682,9 @@ ImBuf *ED_view3d_draw_offscreen_imbuf( GPU_framebuffer_bind(old_fb); } - if (ibuf->rect_float && ibuf->rect) + if (ibuf->rect_float && ibuf->rect) { IMB_rect_from_float(ibuf); + } return ibuf; } @@ -1727,11 +1772,15 @@ ImBuf *ED_view3d_draw_offscreen_imbuf_simple( static bool view3d_clipping_test(const float co[3], const float clip[6][4]) { - if (plane_point_side_v3(clip[0], co) > 0.0f) - if (plane_point_side_v3(clip[1], co) > 0.0f) - if (plane_point_side_v3(clip[2], co) > 0.0f) - if (plane_point_side_v3(clip[3], co) > 0.0f) + if (plane_point_side_v3(clip[0], co) > 0.0f) { + if (plane_point_side_v3(clip[1], co) > 0.0f) { + if (plane_point_side_v3(clip[2], co) > 0.0f) { + if (plane_point_side_v3(clip[3], co) > 0.0f) { return false; + } + } + } + } return true; } diff --git a/source/blender/editors/space_view3d/view3d_draw_legacy.c b/source/blender/editors/space_view3d/view3d_draw_legacy.c index 21e48c24645..3822176b7d5 100644 --- a/source/blender/editors/space_view3d/view3d_draw_legacy.c +++ b/source/blender/editors/space_view3d/view3d_draw_legacy.c @@ -187,8 +187,9 @@ static void validate_object_select_id( return; } - if (!(v3d->flag & V3D_INVALID_BACKBUF)) + if (!(v3d->flag & V3D_INVALID_BACKBUF)) { return; + } #if 0 if (test) { @@ -200,7 +201,9 @@ static void validate_object_select_id( #endif #if 0 /* v3d->zbuf deprecated */ - if (v3d->shading.type > OB_WIRE) v3d->zbuf = true; + if (v3d->shading.type > OB_WIRE) { + v3d->zbuf = true; + } #endif G.f |= G_FLAG_BACKBUFSEL; @@ -450,8 +453,9 @@ static void view3d_draw_bgpic(Scene *scene, Depsgraph *depsgraph, Camera *cam = v3d->camera->data; for (CameraBGImage *bgpic = cam->bg_images.first; bgpic; bgpic = bgpic->next) { - if ((bgpic->flag & CAM_BGIMG_FLAG_FOREGROUND) != fg_flag) + if ((bgpic->flag & CAM_BGIMG_FLAG_FOREGROUND) != fg_flag) { continue; + } { float image_aspect[2]; @@ -462,16 +466,18 @@ static void view3d_draw_bgpic(Scene *scene, Depsgraph *depsgraph, Image *ima = NULL; /* disable individual images */ - if ((bgpic->flag & CAM_BGIMG_FLAG_DISABLED)) + if ((bgpic->flag & CAM_BGIMG_FLAG_DISABLED)) { continue; + } ImBuf *ibuf = NULL; ImBuf *freeibuf = NULL; ImBuf *releaseibuf = NULL; if (bgpic->source == CAM_BGIMG_SOURCE_IMAGE) { ima = bgpic->ima; - if (ima == NULL) + if (ima == NULL) { continue; + } ImageUser iuser = bgpic->iuser; iuser.scene = scene; /* Needed for render results. */ @@ -493,15 +499,17 @@ static void view3d_draw_bgpic(Scene *scene, Depsgraph *depsgraph, MovieClip *clip = NULL; if (bgpic->flag & CAM_BGIMG_FLAG_CAMERACLIP) { - if (scene->camera) + if (scene->camera) { clip = BKE_object_movieclip_get(scene, scene->camera, true); + } } else { clip = bgpic->clip; } - if (clip == NULL) + if (clip == NULL) { continue; + } BKE_movieclip_user_set_frame(&bgpic->cuser, (int)DEG_get_ctime(depsgraph)); ibuf = BKE_movieclip_get_ibuf(clip, &bgpic->cuser); @@ -520,21 +528,25 @@ static void view3d_draw_bgpic(Scene *scene, Depsgraph *depsgraph, copy_v2_fl(image_aspect, 1.0f); } - if (ibuf == NULL) + if (ibuf == NULL) { continue; + } if ((ibuf->rect == NULL && ibuf->rect_float == NULL) || ibuf->channels != 4) { /* invalid image format */ - if (freeibuf) + if (freeibuf) { IMB_freeImBuf(freeibuf); - if (releaseibuf) + } + if (releaseibuf) { BKE_image_release_ibuf(ima, releaseibuf, lock); + } continue; } - if (ibuf->rect == NULL) + if (ibuf->rect == NULL) { IMB_rect_from_float(ibuf); + } BLI_assert(rv3d->persp == RV3D_CAMOB); { @@ -607,10 +619,12 @@ static void view3d_draw_bgpic(Scene *scene, Depsgraph *depsgraph, } if (clip_rect.xmax < 0 || clip_rect.ymax < 0 || clip_rect.xmin > ar->winx || clip_rect.ymin > ar->winy) { - if (freeibuf) + if (freeibuf) { IMB_freeImBuf(freeibuf); - if (releaseibuf) + } + if (releaseibuf) { BKE_image_release_ibuf(ima, releaseibuf, lock); + } continue; } @@ -627,8 +641,9 @@ static void view3d_draw_bgpic(Scene *scene, Depsgraph *depsgraph, IMB_remakemipmap(ibuf, 0); ibuf->userflags &= ~IB_MIPMAP_INVALID; } - else if (ibuf->mipmap[0] == NULL) + else if (ibuf->mipmap[0] == NULL) { IMB_makemipmap(ibuf, 0); + } while (tzoom < 1.0f && mip < 8 && ibuf->mipmap[mip]) { tzoom *= 2.0f; @@ -636,8 +651,9 @@ static void view3d_draw_bgpic(Scene *scene, Depsgraph *depsgraph, zoomy *= 2.0f; mip++; } - if (mip > 0) + if (mip > 0) { ibuf = ibuf->mipmap[mip - 1]; + } } GPU_depth_test(!do_foreground); @@ -676,10 +692,12 @@ static void view3d_draw_bgpic(Scene *scene, Depsgraph *depsgraph, glDepthMask(GL_TRUE); GPU_depth_test(true); - if (freeibuf) + if (freeibuf) { IMB_freeImBuf(freeibuf); - if (releaseibuf) + } + if (releaseibuf) { BKE_image_release_ibuf(ima, releaseibuf, lock); + } } } } @@ -704,8 +722,9 @@ void ED_view3d_draw_bgpic_test( /* disabled - mango request, since footage /w only render is quite useful * and this option is easy to disable all background images at once */ #if 0 - if (v3d->flag2 & V3D_HIDE_OVERLAYS) + if (v3d->flag2 & V3D_HIDE_OVERLAYS) { return; + } #endif if ((rv3d->view == RV3D_VIEW_USER) || (rv3d->persp != RV3D_ORTHO)) { @@ -741,8 +760,9 @@ void view3d_update_depths_rect(ARegion *ar, ViewDepths *d, rcti *rect) int h = BLI_rcti_size_y(rect); if (w <= 0 || h <= 0) { - if (d->depths) + if (d->depths) { MEM_freeN(d->depths); + } d->depths = NULL; d->damaged = false; @@ -759,8 +779,9 @@ void view3d_update_depths_rect(ARegion *ar, ViewDepths *d, rcti *rect) d->w = w; d->h = h; - if (d->depths) + if (d->depths) { MEM_freeN(d->depths); + } d->depths = MEM_mallocN(sizeof(float) * d->w * d->h, "View depths Subset"); @@ -781,7 +802,9 @@ void ED_view3d_depth_update(ARegion *ar) RegionView3D *rv3d = ar->regiondata; /* Create storage for, and, if necessary, copy depth buffer */ - if (!rv3d->depths) rv3d->depths = MEM_callocN(sizeof(ViewDepths), "ViewDepths"); + if (!rv3d->depths) { + rv3d->depths = MEM_callocN(sizeof(ViewDepths), "ViewDepths"); + } if (rv3d->depths) { ViewDepths *d = rv3d->depths; if (d->w != ar->winx || @@ -790,8 +813,9 @@ void ED_view3d_depth_update(ARegion *ar) { d->w = ar->winx; d->h = ar->winy; - if (d->depths) + if (d->depths) { MEM_freeN(d->depths); + } d->depths = MEM_mallocN(sizeof(float) * d->w * d->h, "View depths"); d->damaged = true; } @@ -856,8 +880,9 @@ void ED_view3d_datamask( if (ELEM(drawtype, OB_TEXTURE, OB_MATERIAL)) { r_cddata_masks->lmask |= CD_MASK_MLOOPUV | CD_MASK_MLOOPCOL; - if (drawtype == OB_MATERIAL) + if (drawtype == OB_MATERIAL) { r_cddata_masks->vmask |= CD_MASK_ORCO; + } } if ((CTX_data_mode_enum(C) == CTX_MODE_EDIT_MESH) && @@ -931,8 +956,9 @@ void ED_scene_draw_fps(Scene *scene, int xoffset, int *yoffset) ScreenFrameRateInfo *fpsi = scene->fps_info; char printable[16]; - if (!fpsi || !fpsi->lredrawtime || !fpsi->redrawtime) + if (!fpsi || !fpsi->lredrawtime || !fpsi->redrawtime) { return; + } printable[0] = '\0'; @@ -954,8 +980,9 @@ void ED_scene_draw_fps(Scene *scene, int xoffset, int *yoffset) fpsi->redrawtime_index = (fpsi->redrawtime_index + 1) % REDRAW_FRAME_AVERAGE; //fpsi->redrawtime_index++; - //if (fpsi->redrawtime >= REDRAW_FRAME_AVERAGE) + //if (fpsi->redrawtime >= REDRAW_FRAME_AVERAGE) { // fpsi->redrawtime = 0; + //} fps = fps / tot; } @@ -1000,17 +1027,21 @@ bool ED_view3d_calc_render_border(const Scene *scene, Depsgraph *depsgraph, View bool use_border; /* test if there is a 3d view rendering */ - if (v3d->shading.type != OB_RENDER || !view3d_main_region_do_render_draw(scene)) + if (v3d->shading.type != OB_RENDER || !view3d_main_region_do_render_draw(scene)) { return false; + } /* test if there is a border render */ - if (rv3d->persp == RV3D_CAMOB) + if (rv3d->persp == RV3D_CAMOB) { use_border = (scene->r.mode & R_BORDER) != 0; - else + } + else { use_border = (v3d->flag2 & V3D_RENDER_BORDER) != 0; + } - if (!use_border) + if (!use_border) { return false; + } /* compute border */ if (rv3d->persp == RV3D_CAMOB) { diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c index abcb5495d39..19008ebd122 100644 --- a/source/blender/editors/space_view3d/view3d_edit.c +++ b/source/blender/editors/space_view3d/view3d_edit.c @@ -507,8 +507,9 @@ static void viewops_data_create( } vod->reverse = 1.0f; - if (rv3d->persmat[2][1] < 0.0f) + if (rv3d->persmat[2][1] < 0.0f) { vod->reverse = -1.0f; + } rv3d->rflag |= RV3D_NAVIGATING; } @@ -524,8 +525,9 @@ static void viewops_data_free(bContext *C, wmOperator *op) ar = vod->ar; vod->rv3d->rflag &= ~RV3D_NAVIGATING; - if (vod->timer) + if (vod->timer) { WM_event_remove_timer(CTX_wm_manager(C), vod->timer->win, vod->timer); + } MEM_freeN(vod); op->customdata = NULL; @@ -537,7 +539,9 @@ static void viewops_data_free(bContext *C, wmOperator *op) #if 0 if (p && (p->flags & PAINT_FAST_NAVIGATE)) #endif + { ED_region_tag_redraw(ar); + } } /** \} */ @@ -580,7 +584,9 @@ void viewrotate_modal_keymap(wmKeyConfig *keyconf) wmKeyMap *keymap = WM_modalkeymap_get(keyconf, "View3D Rotate Modal"); /* this function is called for each spacetype, only needs to add map once */ - if (keymap && keymap->modal_items) return; + if (keymap && keymap->modal_items) { + return; + } keymap = WM_modalkeymap_add(keyconf, "View3D Rotate Modal", modal_items); @@ -1070,8 +1076,9 @@ static void view3d_ndof_pan_zoom( if (ndof->tvec[2]) { float zoom_distance = rv3d->dist * ndof->dt * ndof->tvec[2]; - if (U.ndof_flag & NDOF_ZOOM_INVERT) + if (U.ndof_flag & NDOF_ZOOM_INVERT) { zoom_distance = -zoom_distance; + } rv3d->dist += zoom_distance; } @@ -1197,8 +1204,9 @@ void view3d_ndof_fly( float speed = view3d_ndof_pan_speed_calc_from_dist(rv3d, 1.0f); float trans[3], trans_orig_y; - if (use_precision) + if (use_precision) { speed *= 0.2f; + } WM_event_ndof_pan_get(ndof, trans, false); mul_v3_fl(trans, speed * ndof->dt); @@ -1218,9 +1226,15 @@ void view3d_ndof_fly( if (rv3d->persp == RV3D_CAMOB) { /* respect camera position locks */ - if (protectflag & OB_LOCK_LOCX) trans[0] = 0.0f; - if (protectflag & OB_LOCK_LOCY) trans[1] = 0.0f; - if (protectflag & OB_LOCK_LOCZ) trans[2] = 0.0f; + if (protectflag & OB_LOCK_LOCX) { + trans[0] = 0.0f; + } + if (protectflag & OB_LOCK_LOCY) { + trans[1] = 0.0f; + } + if (protectflag & OB_LOCK_LOCZ) { + trans[2] = 0.0f; + } } if (!is_zero_v3(trans)) { @@ -1244,8 +1258,9 @@ void view3d_ndof_fly( if (fabsf(angle) > 0.0001f) { has_rotate = true; - if (use_precision) + if (use_precision) { angle *= 0.2f; + } /* transform rotation axis from view to world coordinates */ mul_qt_v3(view_inv, axis); @@ -1509,8 +1524,9 @@ static int ndof_pan_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent *e /* we're panning here! so erase any leftover rotation from other operators */ rv3d->rot_angle = 0.0f; - if (!(has_translate || has_zoom)) + if (!(has_translate || has_zoom)) { return OPERATOR_CANCELLED; + } ED_view3d_camera_lock_init_ex(depsgraph, v3d, rv3d, false); @@ -1613,7 +1629,9 @@ void viewmove_modal_keymap(wmKeyConfig *keyconf) wmKeyMap *keymap = WM_modalkeymap_get(keyconf, "View3D Move Modal"); /* this function is called for each spacetype, only needs to add map once */ - if (keymap && keymap->modal_items) return; + if (keymap && keymap->modal_items) { + return; + } keymap = WM_modalkeymap_add(keyconf, "View3D Move Modal", modal_items); @@ -1805,7 +1823,9 @@ void viewzoom_modal_keymap(wmKeyConfig *keyconf) wmKeyMap *keymap = WM_modalkeymap_get(keyconf, "View3D Zoom Modal"); /* this function is called for each spacetype, only needs to add map once */ - if (keymap && keymap->modal_items) return; + if (keymap && keymap->modal_items) { + return; + } keymap = WM_modalkeymap_add(keyconf, "View3D Zoom Modal", modal_items); @@ -2336,7 +2356,9 @@ void viewdolly_modal_keymap(wmKeyConfig *keyconf) wmKeyMap *keymap = WM_modalkeymap_get(keyconf, "View3D Dolly Modal"); /* this function is called for each spacetype, only needs to add map once */ - if (keymap && keymap->modal_items) return; + if (keymap && keymap->modal_items) { + return; + } keymap = WM_modalkeymap_add(keyconf, "View3D Dolly Modal", modal_items); @@ -2515,8 +2537,9 @@ static int viewdolly_invoke(bContext *C, wmOperator *op, const wmEvent *event) { ViewOpsData *vod; - if (viewdolly_offset_lock_check(C, op)) + if (viewdolly_offset_lock_check(C, op)) { return OPERATOR_CANCELLED; + } /* makes op->customdata */ viewops_data_alloc(C, op); @@ -2883,13 +2906,16 @@ static int viewselected_exec(bContext *C, wmOperator *op) Base *base_eval; for (base_eval = view_layer_eval->object_bases.first; base_eval; base_eval = base_eval->next) { if (BASE_SELECTED_EDITABLE(v3d, base_eval)) { - if (base_eval->object->type == OB_ARMATURE) - if (base_eval->object->mode & OB_MODE_POSE) + if (base_eval->object->type == OB_ARMATURE) { + if (base_eval->object->mode & OB_MODE_POSE) { break; + } + } } } - if (base_eval) + if (base_eval) { ob_eval = base_eval->object; + } } if (is_gp_edit) { @@ -3330,16 +3356,20 @@ static int render_border_exec(bContext *C, wmOperator *op) /* drawing a border outside the camera view switches off border rendering */ if ((border.xmin == border.xmax || border.ymin == border.ymax)) { - if (rv3d->persp == RV3D_CAMOB) + if (rv3d->persp == RV3D_CAMOB) { scene->r.mode &= ~R_BORDER; - else + } + else { v3d->flag2 &= ~V3D_RENDER_BORDER; + } } else { - if (rv3d->persp == RV3D_CAMOB) + if (rv3d->persp == RV3D_CAMOB) { scene->r.mode |= R_BORDER; - else + } + else { v3d->flag2 |= V3D_RENDER_BORDER; + } } if (rv3d->persp == RV3D_CAMOB) { @@ -3912,15 +3942,18 @@ static int view_camera_exec(bContext *C, wmOperator *op) } /* if the camera isn't found, check a number of options */ - if (v3d->camera == NULL && ob && ob->type == OB_CAMERA) + if (v3d->camera == NULL && ob && ob->type == OB_CAMERA) { v3d->camera = ob; + } - if (v3d->camera == NULL) + if (v3d->camera == NULL) { v3d->camera = BKE_view_layer_camera_find(view_layer); + } /* couldn't find any useful camera, bail out */ - if (v3d->camera == NULL) + if (v3d->camera == NULL) { return OPERATOR_CANCELLED; + } /* important these don't get out of sync for locked scenes */ if (v3d->scenelock && scene->camera != v3d->camera) { @@ -4128,8 +4161,9 @@ static void viewroll_apply(ViewOpsData *vod, int x, int UNUSED(y)) angle = (len1 - len2) * (float)M_PI * 4.0f; } - if (angle != 0.0f) + if (angle != 0.0f) { view_roll_angle(vod->ar, vod->rv3d->viewquat, vod->init.quat, vod->init.mousevec, angle); + } if (vod->use_dyn_ofs) { view3d_orbit_apply_dyn_ofs(vod->rv3d->ofs, vod->init.ofs, vod->init.quat, vod->rv3d->viewquat, vod->dyn_ofs); @@ -4405,9 +4439,12 @@ static int viewpersportho_exec(bContext *C, wmOperator *UNUSED(op)) rv3d = ar->regiondata; if ((rv3d->viewlock & RV3D_LOCKED) == 0) { - if (rv3d->persp != RV3D_ORTHO) + if (rv3d->persp != RV3D_ORTHO) { rv3d->persp = RV3D_ORTHO; - else rv3d->persp = RV3D_PERSP; + } + else { + rv3d->persp = RV3D_PERSP; + } ED_region_tag_redraw(ar); } @@ -4617,8 +4654,9 @@ static void calc_local_clipping(float clip_local[6][4], BoundBox *clipbb, float void ED_view3d_clipping_local(RegionView3D *rv3d, float mat[4][4]) { - if (rv3d->rflag & RV3D_CLIPPING) + if (rv3d->rflag & RV3D_CLIPPING) { calc_local_clipping(rv3d->clip_local, rv3d->clipbb, mat); + } } static int view3d_clipping_exec(bContext *C, wmOperator *op) @@ -4646,7 +4684,9 @@ static int view3d_clipping_invoke(bContext *C, wmOperator *op, const wmEvent *ev if (rv3d->rflag & RV3D_CLIPPING) { rv3d->rflag &= ~RV3D_CLIPPING; ED_region_tag_redraw(ar); - if (rv3d->clipbb) MEM_freeN(rv3d->clipbb); + if (rv3d->clipbb) { + MEM_freeN(rv3d->clipbb); + } rv3d->clipbb = NULL; return OPERATOR_FINISHED; } @@ -4696,8 +4736,9 @@ void ED_view3d_cursor3d_position(bContext *C, const int mval[2], const bool use_ /* normally the caller should ensure this, * but this is called from areas that aren't already dealing with the viewport */ - if (rv3d == NULL) + if (rv3d == NULL) { return; + } ED_view3d_calc_zfac(rv3d, cursor_co, &flip); @@ -4736,8 +4777,9 @@ void ED_view3d_cursor3d_position_rotation( RegionView3D *rv3d = ar->regiondata; /* XXX, caller should check. */ - if (rv3d == NULL) + if (rv3d == NULL) { return; + } ED_view3d_cursor3d_position(C, mval, use_depth, cursor_co); @@ -4872,10 +4914,12 @@ void ED_view3d_cursor3d_update( } } - if (v3d->localvd) + if (v3d->localvd) { WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, v3d); - else + } + else { WM_event_add_notifier(C, NC_SCENE | NA_EDITED, scene); + } { struct wmMsgBus *mbus = CTX_wm_message_bus(C); diff --git a/source/blender/editors/space_view3d/view3d_fly.c b/source/blender/editors/space_view3d/view3d_fly.c index 47961371530..b80ce2c49b0 100644 --- a/source/blender/editors/space_view3d/view3d_fly.c +++ b/source/blender/editors/space_view3d/view3d_fly.c @@ -129,8 +129,9 @@ void fly_modal_keymap(wmKeyConfig *keyconf) wmKeyMap *keymap = WM_modalkeymap_get(keyconf, "View3D Fly Modal"); /* this function is called for each spacetype, only needs to add map once */ - if (keymap && keymap->modal_items) + if (keymap && keymap->modal_items) { return; + } keymap = WM_modalkeymap_add(keyconf, "View3D Fly Modal", modal_items); @@ -402,8 +403,9 @@ static int flyEnd(bContext *C, FlyInfo *fly) wmWindow *win; RegionView3D *rv3d; - if (fly->state == FLY_RUNNING) + if (fly->state == FLY_RUNNING) { return OPERATOR_RUNNING_MODAL; + } #ifdef NDOF_FLY_DEBUG puts("\n-- fly end --"); @@ -421,8 +423,9 @@ static int flyEnd(bContext *C, FlyInfo *fly) rv3d->rflag &= ~RV3D_NAVIGATING; #ifdef WITH_INPUT_NDOF - if (fly->ndof) + if (fly->ndof) { MEM_freeN(fly->ndof); + } #endif if (fly->state == FLY_CONFIRM) { @@ -504,12 +507,15 @@ static void flyEvent(bContext *C, wmOperator *op, FlyInfo *fly, const wmEvent *e float fac = 0.02f * (event->prevy - event->y); /* allowing to brake immediate */ - if (fac > 0.0f && fly->speed < 0.0f) + if (fac > 0.0f && fly->speed < 0.0f) { fly->speed = 0.0f; - else if (fac < 0.0f && fly->speed > 0.0f) + } + else if (fac < 0.0f && fly->speed > 0.0f) { fly->speed = 0.0f; - else + } + else { fly->speed += fly->grid * fac; + } break; } @@ -581,8 +587,12 @@ static void flyEvent(bContext *C, wmOperator *op, FlyInfo *fly, const wmEvent *e else { /* flip speed rather than stopping, game like motion, * else increase like mousewheel if were already moving in that direction */ - if (fly->speed < 0.0f) fly->speed = -fly->speed; - else if (fly->axis == 2) fly->speed += fly->grid; + if (fly->speed < 0.0f) { + fly->speed = -fly->speed; + } + else if (fly->axis == 2) { + fly->speed += fly->grid; + } fly->axis = 2; } break; @@ -591,8 +601,12 @@ static void flyEvent(bContext *C, wmOperator *op, FlyInfo *fly, const wmEvent *e fly->axis = -1; } else { - if (fly->speed > 0.0f) fly->speed = -fly->speed; - else if (fly->axis == 2) fly->speed -= fly->grid; + if (fly->speed > 0.0f) { + fly->speed = -fly->speed; + } + else if (fly->axis == 2) { + fly->speed -= fly->grid; + } fly->axis = 2; } @@ -602,8 +616,12 @@ static void flyEvent(bContext *C, wmOperator *op, FlyInfo *fly, const wmEvent *e fly->axis = -1; } else { - if (fly->speed < 0.0f) fly->speed = -fly->speed; - else if (fly->axis == 0) fly->speed += fly->grid; + if (fly->speed < 0.0f) { + fly->speed = -fly->speed; + } + else if (fly->axis == 0) { + fly->speed += fly->grid; + } fly->axis = 0; } @@ -613,8 +631,12 @@ static void flyEvent(bContext *C, wmOperator *op, FlyInfo *fly, const wmEvent *e fly->axis = -1; } else { - if (fly->speed > 0.0f) fly->speed = -fly->speed; - else if (fly->axis == 0) fly->speed -= fly->grid; + if (fly->speed > 0.0f) { + fly->speed = -fly->speed; + } + else if (fly->axis == 0) { + fly->speed -= fly->grid; + } fly->axis = 0; } @@ -624,8 +646,12 @@ static void flyEvent(bContext *C, wmOperator *op, FlyInfo *fly, const wmEvent *e fly->axis = -1; } else { - if (fly->speed < 0.0f) fly->speed = -fly->speed; - else if (fly->axis == 1) fly->speed += fly->grid; + if (fly->speed < 0.0f) { + fly->speed = -fly->speed; + } + else if (fly->axis == 1) { + fly->speed += fly->grid; + } fly->axis = 1; } break; @@ -634,15 +660,20 @@ static void flyEvent(bContext *C, wmOperator *op, FlyInfo *fly, const wmEvent *e fly->axis = -1; } else { - if (fly->speed > 0.0f) fly->speed = -fly->speed; - else if (fly->axis == 1) fly->speed -= fly->grid; + if (fly->speed > 0.0f) { + fly->speed = -fly->speed; + } + else if (fly->axis == 1) { + fly->speed -= fly->grid; + } fly->axis = 1; } break; case FLY_MODAL_AXIS_LOCK_X: - if (fly->xlock != FLY_AXISLOCK_STATE_OFF) + if (fly->xlock != FLY_AXISLOCK_STATE_OFF) { fly->xlock = FLY_AXISLOCK_STATE_OFF; + } else { fly->xlock = FLY_AXISLOCK_STATE_ACTIVE; fly->xlock_momentum = 0.0; @@ -650,8 +681,9 @@ static void flyEvent(bContext *C, wmOperator *op, FlyInfo *fly, const wmEvent *e fly_update_header(C, op, fly); break; case FLY_MODAL_AXIS_LOCK_Z: - if (fly->zlock != FLY_AXISLOCK_STATE_OFF) + if (fly->zlock != FLY_AXISLOCK_STATE_OFF) { fly->zlock = FLY_AXISLOCK_STATE_OFF; + } else { fly->zlock = FLY_AXISLOCK_STATE_ACTIVE; fly->zlock_momentum = 0.0; @@ -723,13 +755,25 @@ static int flyApply(bContext *C, FlyInfo *fly) moffset[1] = fly->mval[1] - fly->center_mval[1]; /* enforce a view margin */ - if (moffset[0] > xmargin) moffset[0] -= xmargin; - else if (moffset[0] < -xmargin) moffset[0] += xmargin; - else moffset[0] = 0; + if (moffset[0] > xmargin) { + moffset[0] -= xmargin; + } + else if (moffset[0] < -xmargin) { + moffset[0] += xmargin; + } + else { + moffset[0] = 0; + } - if (moffset[1] > ymargin) moffset[1] -= ymargin; - else if (moffset[1] < -ymargin) moffset[1] += ymargin; - else moffset[1] = 0; + if (moffset[1] > ymargin) { + moffset[1] -= ymargin; + } + else if (moffset[1] < -ymargin) { + moffset[1] += ymargin; + } + else { + moffset[1] = 0; + } /* scale the mouse movement by this value - scales mouse movement to the view size @@ -774,8 +818,9 @@ static int flyApply(bContext *C, FlyInfo *fly) /* Scale the time to use shift to scale the speed down- just like * shift slows many other areas of blender down */ - if (fly->use_precision) + if (fly->use_precision) { fly->speed = fly->speed * (1.0f - time_redraw_clamped); + } copy_m3_m4(mat, rv3d->viewinv); @@ -804,10 +849,12 @@ static int flyApply(bContext *C, FlyInfo *fly) axis_angle_to_quat(tmp_quat, upvec, moffset[1] * time_redraw * -FLY_ROTATE_FAC); mul_qt_qtqt(rv3d->viewquat, rv3d->viewquat, tmp_quat); - if (fly->xlock != FLY_AXISLOCK_STATE_OFF) + if (fly->xlock != FLY_AXISLOCK_STATE_OFF) { fly->xlock = FLY_AXISLOCK_STATE_ACTIVE; /* check for rotation */ - if (fly->zlock != FLY_AXISLOCK_STATE_OFF) + } + if (fly->zlock != FLY_AXISLOCK_STATE_OFF) { fly->zlock = FLY_AXISLOCK_STATE_ACTIVE; + } fly->xlock_momentum = 0.0f; } @@ -818,8 +865,9 @@ static int flyApply(bContext *C, FlyInfo *fly) copy_v3_fl3(upvec, 0.0f, 1.0f, 0.0f); mul_m3_v3(mat, upvec); - if (upvec[2] < 0.0f) + if (upvec[2] < 0.0f) { moffset[0] = -moffset[0]; + } /* make the lock vectors */ if (fly->zlock) { @@ -834,10 +882,12 @@ static int flyApply(bContext *C, FlyInfo *fly) axis_angle_to_quat(tmp_quat, upvec, moffset[0] * time_redraw * FLY_ROTATE_FAC); mul_qt_qtqt(rv3d->viewquat, rv3d->viewquat, tmp_quat); - if (fly->xlock != FLY_AXISLOCK_STATE_OFF) + if (fly->xlock != FLY_AXISLOCK_STATE_OFF) { fly->xlock = FLY_AXISLOCK_STATE_ACTIVE; /* check for rotation */ - if (fly->zlock != FLY_AXISLOCK_STATE_OFF) + } + if (fly->zlock != FLY_AXISLOCK_STATE_OFF) { fly->zlock = FLY_AXISLOCK_STATE_ACTIVE; + } } if (fly->zlock == FLY_AXISLOCK_STATE_ACTIVE) { @@ -917,9 +967,15 @@ static int flyApply(bContext *C, FlyInfo *fly) if (rv3d->persp == RV3D_CAMOB) { Object *lock_ob = ED_view3d_cameracontrol_object_get(fly->v3d_camera_control); - if (lock_ob->protectflag & OB_LOCK_LOCX) dvec[0] = 0.0; - if (lock_ob->protectflag & OB_LOCK_LOCY) dvec[1] = 0.0; - if (lock_ob->protectflag & OB_LOCK_LOCZ) dvec[2] = 0.0; + if (lock_ob->protectflag & OB_LOCK_LOCX) { + dvec[0] = 0.0; + } + if (lock_ob->protectflag & OB_LOCK_LOCY) { + dvec[1] = 0.0; + } + if (lock_ob->protectflag & OB_LOCK_LOCZ) { + dvec[2] = 0.0; + } } add_v3_v3(rv3d->ofs, dvec); @@ -970,8 +1026,9 @@ static int fly_invoke(bContext *C, wmOperator *op, const wmEvent *event) RegionView3D *rv3d = CTX_wm_region_view3d(C); FlyInfo *fly; - if (rv3d->viewlock & RV3D_LOCKED) + if (rv3d->viewlock & RV3D_LOCKED) { return OPERATOR_CANCELLED; + } fly = MEM_callocN(sizeof(FlyInfo), "FlyOperation"); @@ -1026,8 +1083,9 @@ static int fly_modal(bContext *C, wmOperator *op, const wmEvent *event) exit_code = flyEnd(C, fly); - if (exit_code != OPERATOR_RUNNING_MODAL) + if (exit_code != OPERATOR_RUNNING_MODAL) { do_draw = true; + } if (do_draw) { if (rv3d->persp == RV3D_CAMOB) { @@ -1038,8 +1096,9 @@ static int fly_modal(bContext *C, wmOperator *op, const wmEvent *event) ED_region_tag_redraw(CTX_wm_region(C)); } - if (ELEM(exit_code, OPERATOR_FINISHED, OPERATOR_CANCELLED)) + if (ELEM(exit_code, OPERATOR_FINISHED, OPERATOR_CANCELLED)) { ED_workspace_status_text(C, NULL); + } return exit_code; } diff --git a/source/blender/editors/space_view3d/view3d_gizmo_armature.c b/source/blender/editors/space_view3d/view3d_gizmo_armature.c index 47f9cc580ea..a2b93dcd309 100644 --- a/source/blender/editors/space_view3d/view3d_gizmo_armature.c +++ b/source/blender/editors/space_view3d/view3d_gizmo_armature.c @@ -185,8 +185,9 @@ static void WIDGETGROUP_armature_spline_refresh(const bContext *C, wmGizmoGroup ViewLayer *view_layer = CTX_data_view_layer(C); Object *ob = BKE_object_pose_armature_get(OBACT(view_layer)); - if (!gzgroup->customdata) + if (!gzgroup->customdata) { return; + } struct BoneSplineWidgetGroup *bspline_group = gzgroup->customdata; bPoseChannel *pchan = BKE_pose_channel_active(ob); diff --git a/source/blender/editors/space_view3d/view3d_gizmo_camera.c b/source/blender/editors/space_view3d/view3d_gizmo_camera.c index c5c8482d550..2aa10dc3040 100644 --- a/source/blender/editors/space_view3d/view3d_gizmo_camera.c +++ b/source/blender/editors/space_view3d/view3d_gizmo_camera.c @@ -130,8 +130,9 @@ static void WIDGETGROUP_camera_setup(const bContext *C, wmGizmoGroup *gzgroup) static void WIDGETGROUP_camera_refresh(const bContext *C, wmGizmoGroup *gzgroup) { - if (!gzgroup->customdata) + if (!gzgroup->customdata) { return; + } struct CameraWidgetGroup *cagzgroup = gzgroup->customdata; ViewLayer *view_layer = CTX_data_view_layer(C); diff --git a/source/blender/editors/space_view3d/view3d_ops.c b/source/blender/editors/space_view3d/view3d_ops.c index e4a6ffb0707..3efd0e32440 100644 --- a/source/blender/editors/space_view3d/view3d_ops.c +++ b/source/blender/editors/space_view3d/view3d_ops.c @@ -104,10 +104,12 @@ static int view3d_pastebuffer_exec(bContext *C, wmOperator *op) char str[FILE_MAX]; short flag = 0; - if (RNA_boolean_get(op->ptr, "autoselect")) + if (RNA_boolean_get(op->ptr, "autoselect")) { flag |= FILE_AUTOSELECT; - if (RNA_boolean_get(op->ptr, "active_collection")) + } + if (RNA_boolean_get(op->ptr, "active_collection")) { flag |= FILE_ACTIVE_COLLECTION; + } BLI_make_file_string("/", str, BKE_tempdir_base(), "copybuffer.blend"); diff --git a/source/blender/editors/space_view3d/view3d_project.c b/source/blender/editors/space_view3d/view3d_project.c index bb5fdeabc2b..760cbb3f3ef 100644 --- a/source/blender/editors/space_view3d/view3d_project.c +++ b/source/blender/editors/space_view3d/view3d_project.c @@ -315,8 +315,12 @@ static void view3d_win_to_ray_segment( RegionView3D *rv3d = ar->regiondata; float _ray_co[3], _ray_dir[3], start_offset, end_offset; - if (!r_ray_co) r_ray_co = _ray_co; - if (!r_ray_dir) r_ray_dir = _ray_dir; + if (!r_ray_co) { + r_ray_co = _ray_co; + } + if (!r_ray_dir) { + r_ray_dir = _ray_dir; + } ED_view3d_win_to_origin(ar, mval, r_ray_co); ED_view3d_win_to_vector(ar, mval, r_ray_dir); diff --git a/source/blender/editors/space_view3d/view3d_select.c b/source/blender/editors/space_view3d/view3d_select.c index b1513b9825b..097a9bb10d3 100644 --- a/source/blender/editors/space_view3d/view3d_select.c +++ b/source/blender/editors/space_view3d/view3d_select.c @@ -344,8 +344,9 @@ static bool view3d_selectable_data(bContext *C) { Object *ob = CTX_data_active_object(C); - if (!ED_operator_region_view3d_active(C)) + if (!ED_operator_region_view3d_active(C)) { return 0; + } if (ob) { if (ob->mode & OB_MODE_EDIT) { @@ -377,13 +378,23 @@ static bool edge_inside_rect(const rctf *rect, const float v1[2], const float v2 int d1, d2, d3, d4; /* check points in rect */ - if (edge_fully_inside_rect(rect, v1, v2)) return 1; + if (edge_fully_inside_rect(rect, v1, v2)) { + return 1; + } /* check points completely out rect */ - if (v1[0] < rect->xmin && v2[0] < rect->xmin) return 0; - if (v1[0] > rect->xmax && v2[0] > rect->xmax) return 0; - if (v1[1] < rect->ymin && v2[1] < rect->ymin) return 0; - if (v1[1] > rect->ymax && v2[1] > rect->ymax) return 0; + if (v1[0] < rect->xmin && v2[0] < rect->xmin) { + return 0; + } + if (v1[0] > rect->xmax && v2[0] > rect->xmax) { + return 0; + } + if (v1[1] < rect->ymin && v2[1] < rect->ymin) { + return 0; + } + if (v1[1] > rect->ymax && v2[1] > rect->ymax) { + return 0; + } /* simple check lines intersecting. */ d1 = (v1[1] - v2[1]) * (v1[0] - rect->xmin) + (v2[0] - v1[0]) * (v1[1] - rect->ymin); @@ -391,8 +402,12 @@ static bool edge_inside_rect(const rctf *rect, const float v1[2], const float v2 d3 = (v1[1] - v2[1]) * (v1[0] - rect->xmax) + (v2[0] - v1[0]) * (v1[1] - rect->ymax); d4 = (v1[1] - v2[1]) * (v1[0] - rect->xmax) + (v2[0] - v1[0]) * (v1[1] - rect->ymin); - if (d1 < 0 && d2 < 0 && d3 < 0 && d4 < 0) return 0; - if (d1 > 0 && d2 > 0 && d3 > 0 && d4 > 0) return 0; + if (d1 < 0 && d2 < 0 && d3 < 0 && d4 < 0) { + return 0; + } + if (d1 > 0 && d2 > 0 && d3 > 0 && d4 > 0) { + return 0; + } return 1; } @@ -929,8 +944,9 @@ static bool do_lasso_select_paintvert(ViewContext *vc, const int mcords[][2], sh Mesh *me = ob->data; rcti rect; - if (me == NULL || me->totvert == 0) + if (me == NULL || me->totvert == 0) { return false; + } bool changed = false; if (SEL_OP_USE_PRE_DESELECT(sel_op)) { @@ -1301,8 +1317,9 @@ static Base *object_mouse_select_menu( baseCount++; BLI_linklist_prepend(&linklist, base); - if (baseCount == SEL_MENU_SIZE) + if (baseCount == SEL_MENU_SIZE) { break; + } } } CTX_DATA_END; @@ -1542,7 +1559,9 @@ static Base *mouse_select_eval_buffer( } base = base->next; } - if (base) basact = base; + if (base) { + basact = base; + } } else { @@ -1552,8 +1571,12 @@ static Base *mouse_select_eval_buffer( * with an un-selectable choice */ if ((base->flag & BASE_SELECTABLE) == 0) { base = base->next; - if (base == NULL) base = FIRSTBASE(view_layer); - if (base == startbase) break; + if (base == NULL) { + base = FIRSTBASE(view_layer); + } + if (base == startbase) { + break; + } } if (BASE_SELECTABLE(v3d, base)) { @@ -1574,11 +1597,17 @@ static Base *mouse_select_eval_buffer( } } - if (basact) break; + if (basact) { + break; + } base = base->next; - if (base == NULL) base = FIRSTBASE(view_layer); - if (base == startbase) break; + if (base == NULL) { + base = FIRSTBASE(view_layer); + } + if (base == startbase) { + break; + } } } @@ -1612,7 +1641,9 @@ Base *ED_view3d_give_base_under_cursor(bContext *C, const int mval[2]) Object *ED_view3d_give_object_under_cursor(bContext *C, const int mval[2]) { Base *base = ED_view3d_give_base_under_cursor(C, mval); - if (base) return base->object; + if (base) { + return base->object; + } return NULL; } @@ -3187,10 +3218,12 @@ static bool pchan_circle_doSelectJoint(void *userData, bPoseChannel *pchan, cons CircleSelectUserData *data = userData; if (len_squared_v2v2(data->mval_fl, screen_co) <= data->radius_squared) { - if (data->select) + if (data->select) { pchan->bone->flag |= BONE_SELECTED; - else + } + else { pchan->bone->flag &= ~BONE_SELECTED; + } return 1; } return 0; @@ -3231,8 +3264,12 @@ static void do_circle_select_pose__doSelectBone( if ((is_point_done == false) && (points_proj_tot == 2) && edge_inside_circle(data->mval_fl, data->radius, screen_co_a, screen_co_b)) { - if (data->select) pchan->bone->flag |= BONE_SELECTED; - else pchan->bone->flag &= ~BONE_SELECTED; + if (data->select) { + pchan->bone->flag |= BONE_SELECTED; + } + else { + pchan->bone->flag &= ~BONE_SELECTED; + } data->is_changed = true; } @@ -3267,16 +3304,20 @@ static bool armature_circle_doSelectJoint(void *userData, EditBone *ebone, const if (len_squared_v2v2(data->mval_fl, screen_co) <= data->radius_squared) { if (head) { - if (data->select) + if (data->select) { ebone->flag |= BONE_ROOTSEL; - else + } + else { ebone->flag &= ~BONE_ROOTSEL; + } } else { - if (data->select) + if (data->select) { ebone->flag |= BONE_TIPSEL; - else + } + else { ebone->flag &= ~BONE_TIPSEL; + } } return 1; } @@ -3318,8 +3359,12 @@ static void do_circle_select_armature__doSelectBone( if ((is_point_done == false) && (points_proj_tot == 2) && edge_inside_circle(data->mval_fl, data->radius, screen_co_a, screen_co_b)) { - if (data->select) ebone->flag |= (BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL); - else ebone->flag &= ~(BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL); + if (data->select) { + ebone->flag |= (BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL); + } + else { + ebone->flag &= ~(BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL); + } data->is_changed = true; } @@ -3356,8 +3401,12 @@ static void do_circle_select_mball__doSelectElem(void *userData, struct MetaElem CircleSelectUserData *data = userData; if (len_squared_v2v2(data->mval_fl, screen_co) <= data->radius_squared) { - if (data->select) ml->flag |= SELECT; - else ml->flag &= ~SELECT; + if (data->select) { + ml->flag |= SELECT; + } + else { + ml->flag &= ~SELECT; + } data->is_changed = true; } } diff --git a/source/blender/editors/space_view3d/view3d_snap.c b/source/blender/editors/space_view3d/view3d_snap.c index 862fc78649f..711e084f2ac 100644 --- a/source/blender/editors/space_view3d/view3d_snap.c +++ b/source/blender/editors/space_view3d/view3d_snap.c @@ -156,12 +156,15 @@ static int snap_sel_to_grid_exec(bContext *C, wmOperator *UNUSED(op)) /* adjust location on the original pchan*/ bPoseChannel *pchan = BKE_pose_channel_find_name(ob->pose, pchan_eval->name); - if ((pchan->protectflag & OB_LOCK_LOCX) == 0) + if ((pchan->protectflag & OB_LOCK_LOCX) == 0) { pchan->loc[0] = vec[0]; - if ((pchan->protectflag & OB_LOCK_LOCY) == 0) + } + if ((pchan->protectflag & OB_LOCK_LOCY) == 0) { pchan->loc[1] = vec[1]; - if ((pchan->protectflag & OB_LOCK_LOCZ) == 0) + } + if ((pchan->protectflag & OB_LOCK_LOCZ) == 0) { pchan->loc[2] = vec[2]; + } /* auto-keyframing */ ED_autokeyframe_pchan(C, scene, ob, pchan, ks); @@ -188,12 +191,15 @@ static int snap_sel_to_grid_exec(bContext *C, wmOperator *UNUSED(op)) invert_m3_m3(imat, originmat); mul_m3_v3(imat, vec); } - if ((ob->protectflag & OB_LOCK_LOCX) == 0) + if ((ob->protectflag & OB_LOCK_LOCX) == 0) { ob->loc[0] = ob_eval->loc[0] + vec[0]; - if ((ob->protectflag & OB_LOCK_LOCY) == 0) + } + if ((ob->protectflag & OB_LOCK_LOCY) == 0) { ob->loc[1] = ob_eval->loc[1] + vec[1]; - if ((ob->protectflag & OB_LOCK_LOCZ) == 0) + } + if ((ob->protectflag & OB_LOCK_LOCZ) == 0) { ob->loc[2] = ob_eval->loc[2] + vec[2]; + } /* auto-keyframing */ ED_autokeyframe_object(C, scene, ob, ks); @@ -359,12 +365,15 @@ static int snap_selected_to_location(bContext *C, const float snap_target_global } /* copy new position */ - if ((pchan->protectflag & OB_LOCK_LOCX) == 0) + if ((pchan->protectflag & OB_LOCK_LOCX) == 0) { pchan->loc[0] = cursor_pose[0]; - if ((pchan->protectflag & OB_LOCK_LOCY) == 0) + } + if ((pchan->protectflag & OB_LOCK_LOCY) == 0) { pchan->loc[1] = cursor_pose[1]; - if ((pchan->protectflag & OB_LOCK_LOCZ) == 0) + } + if ((pchan->protectflag & OB_LOCK_LOCZ) == 0) { pchan->loc[2] = cursor_pose[2]; + } /* auto-keyframing */ ED_autokeyframe_pchan(C, scene, ob, pchan, ks); @@ -425,12 +434,15 @@ static int snap_selected_to_location(bContext *C, const float snap_target_global invert_m3_m3(imat, originmat); mul_m3_v3(imat, cursor_parent); } - if ((ob->protectflag & OB_LOCK_LOCX) == 0) + if ((ob->protectflag & OB_LOCK_LOCX) == 0) { ob->loc[0] += cursor_parent[0]; - if ((ob->protectflag & OB_LOCK_LOCY) == 0) + } + if ((ob->protectflag & OB_LOCK_LOCY) == 0) { ob->loc[1] += cursor_parent[1]; - if ((ob->protectflag & OB_LOCK_LOCZ) == 0) + } + if ((ob->protectflag & OB_LOCK_LOCZ) == 0) { ob->loc[2] += cursor_parent[2]; + } /* auto-keyframing */ ED_autokeyframe_object(C, scene, ob, ks); @@ -561,8 +573,9 @@ static void bundle_midpoint(Scene *scene, Object *ob, float r_vec[3]) bool ok = false; float min[3], max[3], mat[4][4], pos[3], cammat[4][4]; - if (!clip) + if (!clip) { return; + } tracking = &clip->tracking; @@ -857,11 +870,13 @@ bool ED_view3d_minmax_verts(Object *obedit, float r_min[3], float r_max[3]) return changed; } - if (ED_transverts_check_obedit(obedit)) + if (ED_transverts_check_obedit(obedit)) { ED_transverts_create_from_obedit(&tvs, obedit, TM_ALL_JOINTS); + } - if (tvs.transverts_tot == 0) + if (tvs.transverts_tot == 0) { return false; + } copy_m3_m4(bmat, obedit->obmat); diff --git a/source/blender/editors/space_view3d/view3d_toolbar.c b/source/blender/editors/space_view3d/view3d_toolbar.c index 438cab21134..c96e524ec2b 100644 --- a/source/blender/editors/space_view3d/view3d_toolbar.c +++ b/source/blender/editors/space_view3d/view3d_toolbar.c @@ -46,8 +46,9 @@ static int view3d_toolshelf_toggle_exec(bContext *C, wmOperator *UNUSED(op)) ScrArea *sa = CTX_wm_area(C); ARegion *ar = view3d_has_tools_region(sa); - if (ar) + if (ar) { ED_region_toggle_hidden(C, ar); + } return OPERATOR_FINISHED; } diff --git a/source/blender/editors/space_view3d/view3d_utils.c b/source/blender/editors/space_view3d/view3d_utils.c index ab2d09e0862..0639bdaa71c 100644 --- a/source/blender/editors/space_view3d/view3d_utils.c +++ b/source/blender/editors/space_view3d/view3d_utils.c @@ -141,8 +141,12 @@ bool ED_view3d_clip_range_get( params.clip_end *= fac; } - if (r_clipsta) *r_clipsta = params.clip_start; - if (r_clipend) *r_clipend = params.clip_end; + if (r_clipsta) { + *r_clipsta = params.clip_start; + } + if (r_clipend) { + *r_clipend = params.clip_end; + } return params.is_ortho; } @@ -158,10 +162,18 @@ bool ED_view3d_viewplane_get( BKE_camera_params_from_view3d(¶ms, depsgraph, v3d, rv3d); BKE_camera_params_compute_viewplane(¶ms, winx, winy, 1.0f, 1.0f); - if (r_viewplane) *r_viewplane = params.viewplane; - if (r_clip_start) *r_clip_start = params.clip_start; - if (r_clip_end) *r_clip_end = params.clip_end; - if (r_pixsize) *r_pixsize = params.viewdx; + if (r_viewplane) { + *r_viewplane = params.viewplane; + } + if (r_clip_start) { + *r_clip_start = params.clip_start; + } + if (r_clip_end) { + *r_clip_end = params.clip_end; + } + if (r_pixsize) { + *r_pixsize = params.viewdx; + } return params.is_ortho; } @@ -327,15 +339,29 @@ static bool view3d_boundbox_clip_m4(const BoundBox *bb, float persmatob[4][4]) min = -vec[3]; fl = 0; - if (vec[0] < min) fl += 1; - if (vec[0] > max) fl += 2; - if (vec[1] < min) fl += 4; - if (vec[1] > max) fl += 8; - if (vec[2] < min) fl += 16; - if (vec[2] > max) fl += 32; + if (vec[0] < min) { + fl += 1; + } + if (vec[0] > max) { + fl += 2; + } + if (vec[1] < min) { + fl += 4; + } + if (vec[1] > max) { + fl += 8; + } + if (vec[2] < min) { + fl += 16; + } + if (vec[2] > max) { + fl += 32; + } flag &= fl; - if (flag == 0) return true; + if (flag == 0) { + return true; + } } return false; @@ -347,8 +373,12 @@ bool ED_view3d_boundbox_clip_ex(const RegionView3D *rv3d, const BoundBox *bb, fl float persmatob[4][4]; - if (bb == NULL) return true; - if (bb->flag & BOUNDBOX_DISABLED) return true; + if (bb == NULL) { + return true; + } + if (bb->flag & BOUNDBOX_DISABLED) { + return true; + } mul_m4_m4m4(persmatob, (float(*)[4])rv3d->persmat, obmat); @@ -357,8 +387,12 @@ bool ED_view3d_boundbox_clip_ex(const RegionView3D *rv3d, const BoundBox *bb, fl bool ED_view3d_boundbox_clip(RegionView3D *rv3d, const BoundBox *bb) { - if (bb == NULL) return true; - if (bb->flag & BOUNDBOX_DISABLED) return true; + if (bb == NULL) { + return true; + } + if (bb->flag & BOUNDBOX_DISABLED) { + return true; + } return view3d_boundbox_clip_m4(bb, rv3d->persmatob); } @@ -431,8 +465,9 @@ bool ED_view3d_persp_ensure(const Depsgraph *depsgraph, View3D *v3d, ARegion *ar BLI_assert((rv3d->viewlock & RV3D_LOCKED) == 0); - if (ED_view3d_camera_lock_check(v3d, rv3d)) + if (ED_view3d_camera_lock_check(v3d, rv3d)) { return false; + } if (rv3d->persp != RV3D_PERSP) { if (rv3d->persp == RV3D_CAMOB) { @@ -645,38 +680,56 @@ static void view3d_boxview_clip(ScrArea *sa) if (rv3d->viewlock & RV3D_BOXCLIP) { if (ELEM(rv3d->view, RV3D_VIEW_TOP, RV3D_VIEW_BOTTOM)) { - if (ar->winx > ar->winy) x1 = rv3d->dist; - else x1 = ar->winx * rv3d->dist / ar->winy; + if (ar->winx > ar->winy) { + x1 = rv3d->dist; + } + else { + x1 = ar->winx * rv3d->dist / ar->winy; + } - if (ar->winx > ar->winy) y1 = ar->winy * rv3d->dist / ar->winx; - else y1 = rv3d->dist; + if (ar->winx > ar->winy) { + y1 = ar->winy * rv3d->dist / ar->winx; + } + else { + y1 = rv3d->dist; + } copy_v2_v2(ofs, rv3d->ofs); } else if (ELEM(rv3d->view, RV3D_VIEW_FRONT, RV3D_VIEW_BACK)) { ofs[2] = rv3d->ofs[2]; - if (ar->winx > ar->winy) z1 = ar->winy * rv3d->dist / ar->winx; - else z1 = rv3d->dist; + if (ar->winx > ar->winy) { + z1 = ar->winy * rv3d->dist / ar->winx; + } + else { + z1 = rv3d->dist; + } } } } } for (val = 0; val < 8; val++) { - if (ELEM(val, 0, 3, 4, 7)) + if (ELEM(val, 0, 3, 4, 7)) { bb->vec[val][0] = -x1 - ofs[0]; - else + } + else { bb->vec[val][0] = x1 - ofs[0]; + } - if (ELEM(val, 0, 1, 4, 5)) + if (ELEM(val, 0, 1, 4, 5)) { bb->vec[val][1] = -y1 - ofs[1]; - else + } + else { bb->vec[val][1] = y1 - ofs[1]; + } - if (val > 3) + if (val > 3) { bb->vec[val][2] = -z1 - ofs[2]; - else + } + else { bb->vec[val][2] = z1 - ofs[2]; + } } /* normals for plane equations */ @@ -700,7 +753,9 @@ static void view3d_boxview_clip(ScrArea *sa) if (rv3d->viewlock & RV3D_BOXCLIP) { rv3d->rflag |= RV3D_CLIPPING; memcpy(rv3d->clip, clip, sizeof(clip)); - if (rv3d->clipbb) MEM_freeN(rv3d->clipbb); + if (rv3d->clipbb) { + MEM_freeN(rv3d->clipbb); + } rv3d->clipbb = MEM_dupallocN(bb); } } @@ -969,13 +1024,16 @@ bool ED_view3d_autodist_simple(ARegion *ar, const int mval[2], float mouse_world float depth; /* Get Z Depths, needed for perspective, nice for ortho */ - if (force_depth) + if (force_depth) { depth = *force_depth; - else + } + else { depth = view_autodist_depth_margin(ar, mval, margin); + } - if (depth == FLT_MAX) + if (depth == FLT_MAX) { return false; + } float centx = (float)mval[0] + 0.5f; float centy = (float)mval[1] + 0.5f; @@ -1299,8 +1357,9 @@ void ED_view3d_from_m4(const float mat[4][4], float ofs[3], float quat[4], float normalize_m3(nmat); /* Offset */ - if (ofs) + if (ofs) { negate_v3_v3(ofs, mat[3]); + } /* Quat */ if (quat) { @@ -1464,8 +1523,9 @@ bool ED_view3d_depth_unproject( void ED_view3d_depth_tag_update(RegionView3D *rv3d) { - if (rv3d->depths) + if (rv3d->depths) { rv3d->depths->damaged = true; + } } /** \} */ diff --git a/source/blender/editors/space_view3d/view3d_view.c b/source/blender/editors/space_view3d/view3d_view.c index 85fc5122016..21716f28b85 100644 --- a/source/blender/editors/space_view3d/view3d_view.c +++ b/source/blender/editors/space_view3d/view3d_view.c @@ -154,14 +154,18 @@ void ED_view3d_smooth_view_ex( } /* store the options we want to end with */ - if (sview->ofs) + if (sview->ofs) { copy_v3_v3(sms.dst.ofs, sview->ofs); - if (sview->quat) + } + if (sview->quat) { copy_qt_qt(sms.dst.quat, sview->quat); - if (sview->dist) + } + if (sview->dist) { sms.dst.dist = *sview->dist; - if (sview->lens) + } + if (sview->lens) { sms.dst.lens = *sview->lens; + } if (sview->dyn_ofs) { BLI_assert(sview->ofs == NULL); @@ -185,16 +189,21 @@ void ED_view3d_smooth_view_ex( if (smooth_viewtx && v3d->shading.type != OB_RENDER) { bool changed = false; /* zero means no difference */ - if (sview->camera_old != sview->camera) + if (sview->camera_old != sview->camera) { changed = true; - else if (sms.dst.dist != rv3d->dist) + } + else if (sms.dst.dist != rv3d->dist) { changed = true; - else if (sms.dst.lens != v3d->lens) + } + else if (sms.dst.lens != v3d->lens) { changed = true; - else if (!equals_v3v3(sms.dst.ofs, rv3d->ofs)) + } + else if (!equals_v3v3(sms.dst.ofs, rv3d->ofs)) { changed = true; - else if (!equals_v4v4(sms.dst.quat, rv3d->viewquat)) + } + else if (!equals_v4v4(sms.dst.quat, rv3d->viewquat)) { changed = true; + } /* The new view is different from the old one * so animate the view */ @@ -301,10 +310,12 @@ static void view3d_smoothview_apply(bContext *C, View3D *v3d, ARegion *ar, bool struct SmoothView3DStore *sms = rv3d->sms; float step, step_inv; - if (sms->time_allowed != 0.0) + if (sms->time_allowed != 0.0) { step = (float)((rv3d->smooth_timer->duration) / sms->time_allowed); - else + } + else { step = 1.0f; + } /* end timer */ if (step >= 1.0f) { @@ -779,11 +790,14 @@ void view3d_viewmatrix_set( /* should be moved to better initialize later on XXX */ - if (rv3d->viewlock & RV3D_LOCKED) + if (rv3d->viewlock & RV3D_LOCKED) { ED_view3d_lock(rv3d); + } quat_to_mat4(rv3d->viewmat, rv3d->viewquat); - if (rv3d->persp == RV3D_PERSP) rv3d->viewmat[3][2] -= rv3d->dist; + if (rv3d->persp == RV3D_PERSP) { + rv3d->viewmat[3][2] -= rv3d->dist; + } if (v3d->ob_centre) { Object *ob_eval = DEG_get_evaluated_object(depsgraph, v3d->ob_centre); float vec[3]; @@ -1094,14 +1108,17 @@ int view3d_opengl_select( GPU_depth_test(false); } - if (vc->rv3d->rflag & RV3D_CLIPPING) + if (vc->rv3d->rflag & RV3D_CLIPPING) { ED_view3d_clipping_disable(); + } DRW_opengl_context_disable(); finally: - if (hits < 0) printf("Too many objects in select buffer\n"); /* XXX make error message */ + if (hits < 0) { + printf("Too many objects in select buffer\n"); /* XXX make error message */ + } UI_Theme_Restore(&theme_state); @@ -1275,7 +1292,9 @@ static void view3d_localview_exit( { View3D *v3d = sa->spacedata.first; - if (v3d->localvd == NULL) return; + if (v3d->localvd == NULL) { + return; + } for (Base *base = FIRSTBASE(view_layer); base; base = base->next) { if (base->local_view_bits & v3d->local_view_uuid) { diff --git a/source/blender/editors/space_view3d/view3d_walk.c b/source/blender/editors/space_view3d/view3d_walk.c index 0caaf6eb113..a015b7f9945 100644 --- a/source/blender/editors/space_view3d/view3d_walk.c +++ b/source/blender/editors/space_view3d/view3d_walk.c @@ -166,8 +166,9 @@ void walk_modal_keymap(wmKeyConfig *keyconf) wmKeyMap *keymap = WM_modalkeymap_get(keyconf, "View3D Walk Modal"); /* this function is called for each spacetype, only needs to add map once */ - if (keymap && keymap->modal_items) + if (keymap && keymap->modal_items) { return; + } keymap = WM_modalkeymap_add(keyconf, "View3D Walk Modal", modal_items); @@ -498,10 +499,12 @@ static bool initWalkInfo(bContext *C, WalkInfo *walk, wmOperator *op) walk->teleport.duration = U.walk_navigation.teleport_time; walk->mouse_speed = U.walk_navigation.mouse_speed; - if ((U.walk_navigation.flag & USER_WALK_GRAVITY)) + if ((U.walk_navigation.flag & USER_WALK_GRAVITY)) { walk_navigation_mode_set(C, op, walk, WALK_MODE_GRAVITY); - else + } + else { walk_navigation_mode_set(C, op, walk, WALK_MODE_FREE); + } walk->view_height = U.walk_navigation.view_height; walk->jump_height = U.walk_navigation.jump_height; @@ -583,8 +586,9 @@ static int walkEnd(bContext *C, WalkInfo *walk) wmWindow *win; RegionView3D *rv3d; - if (walk->state == WALK_RUNNING) + if (walk->state == WALK_RUNNING) { return OPERATOR_RUNNING_MODAL; + } #ifdef NDOF_WALK_DEBUG puts("\n-- walk end --"); @@ -604,8 +608,9 @@ static int walkEnd(bContext *C, WalkInfo *walk) rv3d->rflag &= ~RV3D_NAVIGATING; #ifdef WITH_INPUT_NDOF - if (walk->ndof) + if (walk->ndof) { MEM_freeN(walk->ndof); + } #endif /* restore the cursor */ @@ -1019,11 +1024,12 @@ static int walkApply(bContext *C, wmOperator *op, WalkInfo *walk) /* it ranges from 90.0f to -90.0f */ angle = -asinf(rv3d->viewmat[2][2]); - if (angle > WALK_TOP_LIMIT && y > 0.0f) + if (angle > WALK_TOP_LIMIT && y > 0.0f) { y = 0.0f; - - else if (angle < WALK_BOTTOM_LIMIT && y < 0.0f) + } + else if (angle < WALK_BOTTOM_LIMIT && y < 0.0f) { y = 0.0f; + } copy_v3_fl3(upvec, 1.0f, 0.0f, 0.0f); mul_m3_v3(mat, upvec); @@ -1041,8 +1047,9 @@ static int walkApply(bContext *C, wmOperator *op, WalkInfo *walk) copy_v3_fl3(upvec, 0.0f, 1.0f, 0.0f); mul_m3_v3(mat, upvec); - if (upvec[2] < 0.0f) + if (upvec[2] < 0.0f) { moffset[0] = -moffset[0]; + } /* relative offset */ x = (float) moffset[0] / ar->winx; @@ -1073,11 +1080,13 @@ static int walkApply(bContext *C, wmOperator *op, WalkInfo *walk) direction = 0; - if ((walk->active_directions & WALK_BIT_FORWARD)) + if ((walk->active_directions & WALK_BIT_FORWARD)) { direction += 1; + } - if ((walk->active_directions & WALK_BIT_BACKWARD)) + if ((walk->active_directions & WALK_BIT_BACKWARD)) { direction -= 1; + } copy_v3_fl3(dvec_tmp, 0.0f, 0.0f, direction); mul_m3_v3(mat, dvec_tmp); @@ -1097,11 +1106,13 @@ static int walkApply(bContext *C, wmOperator *op, WalkInfo *walk) direction = 0; - if ((walk->active_directions & WALK_BIT_LEFT)) + if ((walk->active_directions & WALK_BIT_LEFT)) { direction += 1; + } - if ((walk->active_directions & WALK_BIT_RIGHT)) + if ((walk->active_directions & WALK_BIT_RIGHT)) { direction -= 1; + } dvec_tmp[0] = direction * rv3d->viewinv[0][0]; dvec_tmp[1] = direction * rv3d->viewinv[0][1]; @@ -1120,11 +1131,13 @@ static int walkApply(bContext *C, wmOperator *op, WalkInfo *walk) direction = 0; - if ((walk->active_directions & WALK_BIT_UP)) + if ((walk->active_directions & WALK_BIT_UP)) { direction -= 1; + } - if ((walk->active_directions & WALK_BIT_DOWN)) + if ((walk->active_directions & WALK_BIT_DOWN)) { direction = 1; + } copy_v3_fl3(dvec_tmp, 0.0f, 0.0f, direction); add_v3_v3(dvec, dvec_tmp); @@ -1162,8 +1175,9 @@ static int walkApply(bContext *C, wmOperator *op, WalkInfo *walk) dvec[2] -= difference; /* in case we switched from FREE to GRAVITY too close to the ground */ - if (walk->gravity_state == WALK_GRAVITY_STATE_START) + if (walk->gravity_state == WALK_GRAVITY_STATE_START) { walk->gravity_state = WALK_GRAVITY_STATE_OFF; + } } else { /* hijack the teleport variables */ @@ -1249,9 +1263,15 @@ static int walkApply(bContext *C, wmOperator *op, WalkInfo *walk) if (rv3d->persp == RV3D_CAMOB) { Object *lock_ob = ED_view3d_cameracontrol_object_get(walk->v3d_camera_control); - if (lock_ob->protectflag & OB_LOCK_LOCX) dvec[0] = 0.0f; - if (lock_ob->protectflag & OB_LOCK_LOCY) dvec[1] = 0.0f; - if (lock_ob->protectflag & OB_LOCK_LOCZ) dvec[2] = 0.0f; + if (lock_ob->protectflag & OB_LOCK_LOCX) { + dvec[0] = 0.0f; + } + if (lock_ob->protectflag & OB_LOCK_LOCY) { + dvec[1] = 0.0f; + } + if (lock_ob->protectflag & OB_LOCK_LOCZ) { + dvec[2] = 0.0f; + } } /* scale the movement to the scene size */ @@ -1310,8 +1330,9 @@ static int walk_invoke(bContext *C, wmOperator *op, const wmEvent *event) RegionView3D *rv3d = CTX_wm_region_view3d(C); WalkInfo *walk; - if (rv3d->viewlock & RV3D_LOCKED) + if (rv3d->viewlock & RV3D_LOCKED) { return OPERATOR_CANCELLED; + } walk = MEM_callocN(sizeof(WalkInfo), "NavigationWalkOperation"); @@ -1366,8 +1387,9 @@ static int walk_modal(bContext *C, wmOperator *op, const wmEvent *event) exit_code = walkEnd(C, walk); - if (exit_code != OPERATOR_RUNNING_MODAL) + if (exit_code != OPERATOR_RUNNING_MODAL) { do_draw = true; + } if (do_draw) { if (rv3d->persp == RV3D_CAMOB) { @@ -1379,8 +1401,9 @@ static int walk_modal(bContext *C, wmOperator *op, const wmEvent *event) ED_region_tag_redraw(CTX_wm_region(C)); } - if (ELEM(exit_code, OPERATOR_FINISHED, OPERATOR_CANCELLED)) + if (ELEM(exit_code, OPERATOR_FINISHED, OPERATOR_CANCELLED)) { ED_workspace_status_text(C, NULL); + } return exit_code; } -- cgit v1.2.3