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 --- .../editors/space_buttons/buttons_context.c | 149 +++++++--- source/blender/editors/space_buttons/buttons_ops.c | 13 +- .../editors/space_buttons/buttons_texture.c | 60 ++-- .../blender/editors/space_buttons/space_buttons.c | 33 ++- .../blender/editors/space_console/console_draw.c | 3 +- source/blender/editors/space_console/console_ops.c | 75 +++-- .../blender/editors/space_console/space_console.c | 9 +- source/blender/editors/space_image/image_buttons.c | 63 ++-- source/blender/editors/space_image/image_draw.c | 69 +++-- source/blender/editors/space_image/image_edit.c | 31 +- source/blender/editors/space_image/image_ops.c | 203 ++++++++----- source/blender/editors/space_image/space_image.c | 67 +++-- source/blender/editors/space_info/info_ops.c | 13 +- source/blender/editors/space_info/info_report.c | 3 +- source/blender/editors/space_info/info_stats.c | 53 +++- source/blender/editors/space_info/space_info.c | 15 +- source/blender/editors/space_info/textview.c | 12 +- source/blender/editors/space_node/drawnode.c | 199 ++++++++----- source/blender/editors/space_node/node_add.c | 28 +- source/blender/editors/space_node/node_buttons.c | 9 +- source/blender/editors/space_node/node_draw.c | 207 ++++++++----- source/blender/editors/space_node/node_edit.c | 322 +++++++++++++------- source/blender/editors/space_node/node_group.c | 96 ++++-- .../editors/space_node/node_relationships.c | 254 ++++++++++------ source/blender/editors/space_node/node_select.c | 114 +++++--- source/blender/editors/space_node/node_templates.c | 138 ++++++--- source/blender/editors/space_node/node_toolbar.c | 3 +- source/blender/editors/space_node/node_view.c | 3 +- source/blender/editors/space_node/space_node.c | 106 ++++--- .../editors/space_outliner/outliner_dragdrop.c | 69 +++-- .../blender/editors/space_outliner/outliner_draw.c | 62 ++-- .../blender/editors/space_outliner/outliner_edit.c | 151 +++++++--- .../editors/space_outliner/outliner_select.c | 38 ++- .../editors/space_outliner/outliner_tools.c | 105 ++++--- .../blender/editors/space_outliner/outliner_tree.c | 263 +++++++++++------ .../editors/space_outliner/outliner_utils.c | 19 +- .../editors/space_outliner/space_outliner.c | 21 +- .../editors/space_sequencer/sequencer_add.c | 60 ++-- .../editors/space_sequencer/sequencer_buttons.c | 3 +- .../editors/space_sequencer/sequencer_draw.c | 126 +++++--- .../editors/space_sequencer/sequencer_edit.c | 323 ++++++++++++++------- .../editors/space_sequencer/sequencer_modifier.c | 15 +- .../editors/space_sequencer/sequencer_scopes.c | 18 +- .../editors/space_sequencer/sequencer_select.c | 103 +++++-- .../editors/space_sequencer/sequencer_view.c | 3 +- .../editors/space_sequencer/space_sequencer.c | 99 +++++-- .../editors/space_statusbar/space_statusbar.c | 12 +- source/blender/editors/space_topbar/space_topbar.c | 24 +- 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 +++-- 66 files changed, 3357 insertions(+), 1557 deletions(-) (limited to 'source/blender/editors') diff --git a/source/blender/editors/space_buttons/buttons_context.c b/source/blender/editors/space_buttons/buttons_context.c index 152442f8671..0579e20bb5a 100644 --- a/source/blender/editors/space_buttons/buttons_context.c +++ b/source/blender/editors/space_buttons/buttons_context.c @@ -93,8 +93,9 @@ static PointerRNA *get_pointer_type(ButsContextPath *path, StructRNA *type) for (a = 0; a < path->len; a++) { ptr = &path->ptr[a]; - if (RNA_struct_is_a(ptr->type, type)) + if (RNA_struct_is_a(ptr->type, type)) { return ptr; + } } return NULL; @@ -221,16 +222,36 @@ static int buttons_context_path_data(ButsContextPath *path, int type) PointerRNA *ptr = &path->ptr[path->len - 1]; /* if we already have a data, we're done */ - if (RNA_struct_is_a(ptr->type, &RNA_Mesh) && (type == -1 || type == OB_MESH)) return 1; - else if (RNA_struct_is_a(ptr->type, &RNA_Curve) && (type == -1 || ELEM(type, OB_CURVE, OB_SURF, OB_FONT))) return 1; - else if (RNA_struct_is_a(ptr->type, &RNA_Armature) && (type == -1 || type == OB_ARMATURE)) return 1; - else if (RNA_struct_is_a(ptr->type, &RNA_MetaBall) && (type == -1 || type == OB_MBALL)) return 1; - else if (RNA_struct_is_a(ptr->type, &RNA_Lattice) && (type == -1 || type == OB_LATTICE)) return 1; - else if (RNA_struct_is_a(ptr->type, &RNA_Camera) && (type == -1 || type == OB_CAMERA)) return 1; - else if (RNA_struct_is_a(ptr->type, &RNA_Light) && (type == -1 || type == OB_LAMP)) return 1; - else if (RNA_struct_is_a(ptr->type, &RNA_Speaker) && (type == -1 || type == OB_SPEAKER)) return 1; - else if (RNA_struct_is_a(ptr->type, &RNA_LightProbe) && (type == -1 || type == OB_LIGHTPROBE)) return 1; - else if (RNA_struct_is_a(ptr->type, &RNA_GreasePencil) && (type == -1 || type == OB_GPENCIL)) return 1; + if (RNA_struct_is_a(ptr->type, &RNA_Mesh) && (type == -1 || type == OB_MESH)) { + return 1; + } + else if (RNA_struct_is_a(ptr->type, &RNA_Curve) && (type == -1 || ELEM(type, OB_CURVE, OB_SURF, OB_FONT))) { + return 1; + } + else if (RNA_struct_is_a(ptr->type, &RNA_Armature) && (type == -1 || type == OB_ARMATURE)) { + return 1; + } + else if (RNA_struct_is_a(ptr->type, &RNA_MetaBall) && (type == -1 || type == OB_MBALL)) { + return 1; + } + else if (RNA_struct_is_a(ptr->type, &RNA_Lattice) && (type == -1 || type == OB_LATTICE)) { + return 1; + } + else if (RNA_struct_is_a(ptr->type, &RNA_Camera) && (type == -1 || type == OB_CAMERA)) { + return 1; + } + else if (RNA_struct_is_a(ptr->type, &RNA_Light) && (type == -1 || type == OB_LAMP)) { + return 1; + } + else if (RNA_struct_is_a(ptr->type, &RNA_Speaker) && (type == -1 || type == OB_SPEAKER)) { + return 1; + } + else if (RNA_struct_is_a(ptr->type, &RNA_LightProbe) && (type == -1 || type == OB_LIGHTPROBE)) { + return 1; + } + else if (RNA_struct_is_a(ptr->type, &RNA_GreasePencil) && (type == -1 || type == OB_GPENCIL)) { + return 1; + } /* try to get an object in the path, no pinning supported here */ else if (buttons_context_path_object(path)) { ob = path->ptr[path->len - 1].data; @@ -254,8 +275,9 @@ static int buttons_context_path_modifier(ButsContextPath *path) if (buttons_context_path_object(path)) { ob = path->ptr[path->len - 1].data; - if (ob && ELEM(ob->type, OB_MESH, OB_CURVE, OB_FONT, OB_SURF, OB_LATTICE, OB_GPENCIL)) + if (ob && ELEM(ob->type, OB_MESH, OB_CURVE, OB_FONT, OB_SURF, OB_LATTICE, OB_GPENCIL)) { return 1; + } } return 0; @@ -268,8 +290,9 @@ static int buttons_context_path_shaderfx(ButsContextPath *path) if (buttons_context_path_object(path)) { ob = path->ptr[path->len - 1].data; - if (ob && ELEM(ob->type, OB_GPENCIL)) + if (ob && ELEM(ob->type, OB_GPENCIL)) { return 1; + } } return 0; @@ -429,27 +452,34 @@ static int buttons_context_path_texture(const bContext *C, ButsContextPath *path PointerRNA *ptr = &path->ptr[path->len - 1]; ID *id; - if (!ct) + if (!ct) { return 0; + } /* if we already have a (pinned) texture, we're done */ - if (RNA_struct_is_a(ptr->type, &RNA_Texture)) + if (RNA_struct_is_a(ptr->type, &RNA_Texture)) { return 1; + } - if (!ct->user) + if (!ct->user) { return 0; + } id = ct->user->id; if (id) { - if (GS(id->name) == ID_BR) + if (GS(id->name) == ID_BR) { buttons_context_path_brush(C, path); - else if (GS(id->name) == ID_PA) + } + else if (GS(id->name) == ID_PA) { buttons_context_path_particle(path); - else if (GS(id->name) == ID_OB) + } + else if (GS(id->name) == ID_OB) { buttons_context_path_object(path); - else if (GS(id->name) == ID_LS) + } + else if (GS(id->name) == ID_LS) { buttons_context_path_linestyle(path, CTX_wm_window(C)); + } } if (ct->texture) { @@ -568,8 +598,9 @@ static int buttons_context_path(const bContext *C, ButsContextPath *path, int ma break; case BCONTEXT_BONE: found = buttons_context_path_bone(path); - if (!found) + if (!found) { found = buttons_context_path_data(path, OB_ARMATURE); + } break; case BCONTEXT_BONE_CONSTRAINT: found = buttons_context_path_pose_bone(path); @@ -588,10 +619,12 @@ static int buttons_shading_context(const bContext *C, int mainb) ViewLayer *view_layer = WM_window_get_active_view_layer(window); Object *ob = OBACT(view_layer); - if (ELEM(mainb, BCONTEXT_MATERIAL, BCONTEXT_WORLD, BCONTEXT_TEXTURE)) + if (ELEM(mainb, BCONTEXT_MATERIAL, BCONTEXT_WORLD, BCONTEXT_TEXTURE)) { return 1; - if (mainb == BCONTEXT_DATA && ob && ELEM(ob->type, OB_LAMP, OB_CAMERA)) + } + if (mainb == BCONTEXT_DATA && ob && ELEM(ob->type, OB_LAMP, OB_CAMERA)) { return 1; + } return 0; } @@ -602,12 +635,15 @@ static int buttons_shading_new_context(const bContext *C, int flag) ViewLayer *view_layer = WM_window_get_active_view_layer(window); Object *ob = OBACT(view_layer); - if (flag & (1 << BCONTEXT_MATERIAL)) + if (flag & (1 << BCONTEXT_MATERIAL)) { return BCONTEXT_MATERIAL; - else if (ob && ELEM(ob->type, OB_LAMP, OB_CAMERA) && (flag & (1 << BCONTEXT_DATA))) + } + else if (ob && ELEM(ob->type, OB_LAMP, OB_CAMERA) && (flag & (1 << BCONTEXT_DATA))) { return BCONTEXT_DATA; - else if (flag & (1 << BCONTEXT_WORLD)) + } + else if (flag & (1 << BCONTEXT_WORLD)) { return BCONTEXT_WORLD; + } return BCONTEXT_RENDER; } @@ -618,8 +654,9 @@ void buttons_context_compute(const bContext *C, SpaceProperties *sbuts) PointerRNA *ptr; int a, pflag = 0, flag = 0; - if (!sbuts->path) + if (!sbuts->path) { sbuts->path = MEM_callocN(sizeof(ButsContextPath), "ButsContextPath"); + } path = sbuts->path; @@ -639,10 +676,12 @@ void buttons_context_compute(const bContext *C, SpaceProperties *sbuts) ptr = &path->ptr[path->len - 1]; if (ptr->type) { - if (RNA_struct_is_a(ptr->type, &RNA_Light)) + if (RNA_struct_is_a(ptr->type, &RNA_Light)) { sbuts->dataicon = ICON_OUTLINER_DATA_LIGHT; - else + } + else { sbuts->dataicon = RNA_struct_ui_icon(ptr->type); + } } else { sbuts->dataicon = ICON_EMPTY_DATA; @@ -678,16 +717,20 @@ void buttons_context_compute(const bContext *C, SpaceProperties *sbuts) buttons_context_path(C, path, sbuts->mainb, pflag); if (!(flag & (1 << sbuts->mainb))) { - if (flag & (1 << BCONTEXT_OBJECT)) + if (flag & (1 << BCONTEXT_OBJECT)) { sbuts->mainb = BCONTEXT_OBJECT; - else + } + else { sbuts->mainb = BCONTEXT_SCENE; + } } - if (buttons_shading_context(C, sbuts->mainb)) + if (buttons_shading_context(C, sbuts->mainb)) { sbuts->flag |= SB_SHADING_CONTEXT; - else + } + else { sbuts->flag &= ~SB_SHADING_CONTEXT; + } sbuts->pathflag = flag; } @@ -708,17 +751,20 @@ int buttons_context(const bContext *C, const char *member, bContextDataResult *r SpaceProperties *sbuts = CTX_wm_space_properties(C); ButsContextPath *path = sbuts ? sbuts->path : NULL; - if (!path) + if (!path) { return 0; + } /* here we handle context, getting data from precomputed path */ if (CTX_data_dir(member)) { /* in case of new shading system we skip texture_slot, complex python * UI script logic depends on checking if this is available */ - if (sbuts->texuser) + if (sbuts->texuser) { CTX_data_dir_set(result, buttons_context_dir + 1); - else + } + else { CTX_data_dir_set(result, buttons_context_dir); + } return 1; } else if (CTX_data_equals(member, "scene")) { @@ -792,7 +838,9 @@ int buttons_context(const bContext *C, const char *member, bContextDataResult *r if (ob && OB_TYPE_SUPPORT_MATERIAL(ob->type) && ob->totcol) { /* a valid actcol isn't ensured [#27526] */ int matnr = ob->actcol - 1; - if (matnr < 0) matnr = 0; + if (matnr < 0) { + matnr = 0; + } CTX_data_pointer_set(result, &ob->id, &RNA_MaterialSlot, &ob->mat[matnr]); } } @@ -802,8 +850,9 @@ int buttons_context(const bContext *C, const char *member, bContextDataResult *r else if (CTX_data_equals(member, "texture_user")) { ButsContextTexture *ct = sbuts->texuser; - if (!ct) + if (!ct) { return -1; + } if (ct->user && ct->user->ptr.data) { ButsTextureUser *user = ct->user; @@ -815,8 +864,9 @@ int buttons_context(const bContext *C, const char *member, bContextDataResult *r else if (CTX_data_equals(member, "texture_user_property")) { ButsContextTexture *ct = sbuts->texuser; - if (!ct) + if (!ct) { return -1; + } if (ct->user && ct->user->ptr.data) { ButsTextureUser *user = ct->user; @@ -845,8 +895,9 @@ int buttons_context(const bContext *C, const char *member, bContextDataResult *r if ((ptr = get_pointer_type(path, &RNA_ParticleSystem))) { ParticleSettings *part = ((ParticleSystem *)ptr->data)->part; - if (part) + if (part) { CTX_data_pointer_set(result, &part->id, &RNA_ParticleSettingsTextureSlot, part->mtex[(int)part->texact]); + } } else if (ct) { return 0; /* new shading system */ @@ -854,8 +905,9 @@ int buttons_context(const bContext *C, const char *member, bContextDataResult *r else if ((ptr = get_pointer_type(path, &RNA_FreestyleLineStyle))) { FreestyleLineStyle *ls = ptr->data; - if (ls) + if (ls) { CTX_data_pointer_set(result, &ls->id, &RNA_LineStyleTextureSlot, ls->mtex[(int)ls->texact]); + } } return 1; @@ -877,10 +929,12 @@ int buttons_context(const bContext *C, const char *member, bContextDataResult *r return 1; } else if (CTX_data_equals(member, "particle_system_editable")) { - if (PE_poll((bContext *)C)) + if (PE_poll((bContext *)C)) { set_pointer_type(path, result, &RNA_ParticleSystem); - else + } + else { CTX_data_pointer_set(result, NULL, &RNA_ParticleSystem, NULL); + } return 1; } else if (CTX_data_equals(member, "particle_settings")) { @@ -993,8 +1047,9 @@ static void pin_cb(bContext *C, void *UNUSED(arg1), void *UNUSED(arg2)) if (sbuts->flag & SB_PIN_CONTEXT) { sbuts->pinid = buttons_context_id_path(C); } - else + else { sbuts->pinid = NULL; + } ED_area_tag_redraw(CTX_wm_area(C)); } @@ -1011,8 +1066,9 @@ void buttons_context_draw(const bContext *C, uiLayout *layout) int a, icon; bool first = true; - if (!path) + if (!path) { return; + } row = uiLayoutRow(layout, true); uiLayoutSetAlignment(row, UI_LAYOUT_ALIGN_LEFT); @@ -1044,8 +1100,9 @@ void buttons_context_draw(const bContext *C, uiLayout *layout) if (name) { uiItemLDrag(row, ptr, name, icon); - if (name != namebuf) + if (name != namebuf) { MEM_freeN(name); + } } else { uiItemL(row, "", icon); diff --git a/source/blender/editors/space_buttons/buttons_ops.c b/source/blender/editors/space_buttons/buttons_ops.c index 7cec9c09767..3ae88f9cc78 100644 --- a/source/blender/editors/space_buttons/buttons_ops.c +++ b/source/blender/editors/space_buttons/buttons_ops.c @@ -99,8 +99,9 @@ static int file_browse_exec(bContext *C, wmOperator *op) char *str, path[FILE_MAX]; const char *path_prop = RNA_struct_find_property(op->ptr, "directory") ? "directory" : "filepath"; - if (RNA_struct_property_is_set(op->ptr, path_prop) == 0 || fbo == NULL) + if (RNA_struct_property_is_set(op->ptr, path_prop) == 0 || fbo == NULL) { return OPERATOR_CANCELLED; + } str = RNA_string_get_alloc(op->ptr, path_prop, NULL, 0); @@ -127,7 +128,9 @@ static int file_browse_exec(bContext *C, wmOperator *op) } else { char * const lslash = (char *)BLI_last_slash(str); - if (lslash) lslash[1] = '\0'; + if (lslash) { + lslash[1] = '\0'; + } } } @@ -176,8 +179,9 @@ static int file_browse_invoke(bContext *C, wmOperator *op, const wmEvent *event) UI_context_active_but_prop_get_filebrowser(C, &ptr, &prop, &is_undo); - if (!prop) + if (!prop) { return OPERATOR_CANCELLED; + } str = RNA_property_string_get_alloc(&ptr, prop, NULL, 0, NULL); @@ -189,8 +193,9 @@ static int file_browse_invoke(bContext *C, wmOperator *op, const wmEvent *event) if (event->alt) { char *lslash = (char *)BLI_last_slash(str); - if (lslash) + if (lslash) { *lslash = '\0'; + } } diff --git a/source/blender/editors/space_buttons/buttons_texture.c b/source/blender/editors/space_buttons/buttons_texture.c index 067e0f57433..7c1355b6b3c 100644 --- a/source/blender/editors/space_buttons/buttons_texture.c +++ b/source/blender/editors/space_buttons/buttons_texture.c @@ -172,14 +172,18 @@ static void buttons_texture_users_from_context(ListBase *users, const bContext * /* get data from context */ if (pinid) { - if (GS(pinid->name) == ID_SCE) + if (GS(pinid->name) == ID_SCE) { scene = (Scene *)pinid; - else if (GS(pinid->name) == ID_OB) + } + else if (GS(pinid->name) == ID_OB) { ob = (Object *)pinid; - else if (GS(pinid->name) == ID_BR) + } + else if (GS(pinid->name) == ID_BR) { brush = (Brush *)pinid; - else if (GS(pinid->name) == ID_LS) + } + else if (GS(pinid->name) == ID_LS) { linestyle = (FreestyleLineStyle *)pinid; + } } if (!scene) { @@ -201,8 +205,9 @@ static void buttons_texture_users_from_context(ListBase *users, const bContext * /* fill users */ BLI_listbase_clear(users); - if (linestyle && !limited_mode) + if (linestyle && !limited_mode) { buttons_texture_users_find_nodetree(users, &linestyle->id, linestyle->nodetree, N_("Line Style")); + } if (ob) { ParticleSystem *psys = psys_get_current(ob); @@ -290,8 +295,9 @@ void buttons_texture_context_compute(const bContext *C, SpaceProperties *sbuts) } else { /* set one user as active based on active index */ - if (ct->index >= BLI_listbase_count_at_most(&ct->users, ct->index + 1)) + if (ct->index >= BLI_listbase_count_at_most(&ct->users, ct->index + 1)) { ct->index = 0; + } ct->user = BLI_findlink(&ct->users, ct->index); ct->texture = NULL; @@ -335,8 +341,9 @@ static void template_texture_select(bContext *C, void *user_p, void *UNUSED(arg) PointerRNA texptr; Tex *tex; - if (!ct) + if (!ct) { return; + } /* set user as active */ if (user->node) { @@ -355,13 +362,16 @@ static void template_texture_select(bContext *C, void *user_p, void *UNUSED(arg) ParticleSettings *part = user->ptr.id.data; int a; - for (a = 0; a < MAX_MTEX; a++) - if (user->ptr.data == part->mtex[a]) + for (a = 0; a < MAX_MTEX; a++) { + if (user->ptr.data == part->mtex[a]) { part->texact = a; + } + } } - if (sbuts && tex) + if (sbuts && tex) { sbuts->preview = 1; + } } ct->user = user; @@ -393,13 +403,16 @@ static void template_texture_user_menu(bContext *C, uiLayout *layout, void *UNUS PointerRNA texptr = RNA_property_pointer_get(&user->ptr, user->prop); Tex *tex = texptr.data; - if (tex) + if (tex) { BLI_snprintf(name, UI_MAX_NAME_STR, " %s - %s", user->name, tex->id.name + 2); - else + } + else { BLI_snprintf(name, UI_MAX_NAME_STR, " %s", user->name); + } } - else + else { BLI_snprintf(name, UI_MAX_NAME_STR, " %s", user->name); + } but = uiDefIconTextBut(block, UI_BTYPE_BUT, 0, user->icon, name, 0, 0, UI_UNIT_X * 4, UI_UNIT_Y, NULL, 0.0, 0.0, 0.0, 0.0, ""); @@ -423,8 +436,9 @@ void uiTemplateTextureUser(uiLayout *layout, bContext *C) ButsTextureUser *user; char name[UI_MAX_NAME_STR]; - if (!ct) + if (!ct) { return; + } /* get current user */ user = ct->user; @@ -460,12 +474,15 @@ static void template_texture_show(bContext *C, void *data_p, void *prop_p) ButsContextTexture *ct = (sbuts) ? sbuts->texuser : NULL; ButsTextureUser *user; - if (!ct) + if (!ct) { return; + } - for (user = ct->users.first; user; user = user->next) - if (user->ptr.data == data_p && user->prop == prop_p) + for (user = ct->users.first; user; user = user->next) { + if (user->ptr.data == data_p && user->prop == prop_p) { break; + } + } if (user) { /* select texture */ @@ -489,13 +506,16 @@ void uiTemplateTextureShow(uiLayout *layout, bContext *C, PointerRNA *ptr, Prope ButsTextureUser *user; /* only show button in other tabs in properties editor */ - if (!ct || sbuts->mainb == BCONTEXT_TEXTURE) + if (!ct || sbuts->mainb == BCONTEXT_TEXTURE) { return; + } /* find corresponding texture user */ - for (user = ct->users.first; user; user = user->next) - if (user->ptr.data == ptr->data && user->prop == prop) + for (user = ct->users.first; user; user = user->next) { + if (user->ptr.data == ptr->data && user->prop == prop) { break; + } + } /* draw button */ if (user) { diff --git a/source/blender/editors/space_buttons/space_buttons.c b/source/blender/editors/space_buttons/space_buttons.c index 609ef86b003..3bf2d632a12 100644 --- a/source/blender/editors/space_buttons/space_buttons.c +++ b/source/blender/editors/space_buttons/space_buttons.c @@ -97,8 +97,9 @@ static void buttons_free(SpaceLink *sl) { SpaceProperties *sbuts = (SpaceProperties *) sl; - if (sbuts->path) + if (sbuts->path) { MEM_freeN(sbuts->path); + } if (sbuts->texuser) { ButsContextTexture *ct = sbuts->texuser; @@ -451,8 +452,9 @@ static void buttons_area_redraw(ScrArea *sa, short buttons) SpaceProperties *sbuts = sa->spacedata.first; /* if the area's current button set is equal to the one to redraw */ - if (sbuts->mainb == buttons) + if (sbuts->mainb == buttons) { ED_area_tag_redraw(sa); + } } /* reused! */ @@ -510,10 +512,12 @@ static void buttons_area_listener( buttons_area_redraw(sa, BCONTEXT_DATA); break; case ND_MODIFIER: - if (wmn->action == NA_RENAME) + if (wmn->action == NA_RENAME) { ED_area_tag_redraw(sa); - else + } + else { buttons_area_redraw(sa, BCONTEXT_MODIFIER); + } buttons_area_redraw(sa, BCONTEXT_PHYSICS); break; case ND_CONSTRAINT: @@ -521,8 +525,9 @@ static void buttons_area_listener( buttons_area_redraw(sa, BCONTEXT_BONE_CONSTRAINT); break; case ND_PARTICLE: - if (wmn->action == NA_EDITED) + if (wmn->action == NA_EDITED) { buttons_area_redraw(sa, BCONTEXT_PARTICLE); + } sbuts->preview = 1; break; case ND_DRAW: @@ -589,26 +594,30 @@ static void buttons_area_listener( } break; case NC_SPACE: - if (wmn->data == ND_SPACE_PROPERTIES) + if (wmn->data == ND_SPACE_PROPERTIES) { ED_area_tag_redraw(sa); + } break; case NC_ID: - if (wmn->action == NA_RENAME) + if (wmn->action == NA_RENAME) { ED_area_tag_redraw(sa); + } break; case NC_ANIMATION: switch (wmn->data) { case ND_KEYFRAME: - if (ELEM(wmn->action, NA_EDITED, NA_ADDED, NA_REMOVED)) + if (ELEM(wmn->action, NA_EDITED, NA_ADDED, NA_REMOVED)) { ED_area_tag_redraw(sa); + } break; } break; case NC_GPENCIL: switch (wmn->data) { case ND_DATA: - if (ELEM(wmn->action, NA_EDITED, NA_ADDED, NA_REMOVED)) + if (ELEM(wmn->action, NA_EDITED, NA_ADDED, NA_REMOVED)) { ED_area_tag_redraw(sa); + } break; } break; @@ -616,8 +625,9 @@ static void buttons_area_listener( if (wmn->action == NA_SELECTED) { ED_area_tag_redraw(sa); /* new active node, update texture preview */ - if (sbuts->mainb == BCONTEXT_TEXTURE) + if (sbuts->mainb == BCONTEXT_TEXTURE) { sbuts->preview = 1; + } } break; /* Listener for preview render, when doing an global undo. */ @@ -635,8 +645,9 @@ static void buttons_area_listener( #endif } - if (wmn->data == ND_KEYS) + if (wmn->data == ND_KEYS) { ED_area_tag_redraw(sa); + } } static void buttons_id_remap(ScrArea *UNUSED(sa), SpaceLink *slink, ID *old_id, ID *new_id) diff --git a/source/blender/editors/space_console/console_draw.c b/source/blender/editors/space_console/console_draw.c index b7e4133e073..042fb366224 100644 --- a/source/blender/editors/space_console/console_draw.c +++ b/source/blender/editors/space_console/console_draw.c @@ -132,8 +132,9 @@ static void console_cursor_wrap_offset(const char *str, int width, int *row, int *column = 0; } - if (end && str >= end) + if (end && str >= end) { break; + } *column += col; } diff --git a/source/blender/editors/space_console/console_ops.c b/source/blender/editors/space_console/console_ops.c index 46d22df2609..d4489337847 100644 --- a/source/blender/editors/space_console/console_ops.c +++ b/source/blender/editors/space_console/console_ops.c @@ -87,10 +87,13 @@ static void console_scrollback_limit(SpaceConsole *sc) { int tot; - if (U.scrollback < 32) U.scrollback = 256; // XXX - save in user defaults + if (U.scrollback < 32) { + U.scrollback = 256; // XXX - save in user defaults + } - for (tot = BLI_listbase_count(&sc->scrollback); tot > U.scrollback; tot--) + for (tot = BLI_listbase_count(&sc->scrollback); tot > U.scrollback; tot--) { console_scrollback_free(sc, sc->scrollback.first); + } } static ConsoleLine *console_history_find(SpaceConsole *sc, const char *str, ConsoleLine *cl_ignore) @@ -98,11 +101,13 @@ static ConsoleLine *console_history_find(SpaceConsole *sc, const char *str, Cons ConsoleLine *cl; for (cl = sc->history.last; cl; cl = cl->prev) { - if (cl == cl_ignore) + if (cl == cl_ignore) { continue; + } - if (STREQ(str, cl->line)) + if (STREQ(str, cl->line)) { return cl; + } } return NULL; @@ -113,9 +118,15 @@ static bool console_line_cursor_set(ConsoleLine *cl, int cursor) { int cursor_new; - if (cursor < 0) cursor_new = 0; - else if (cursor > cl->len) cursor_new = cl->len; - else cursor_new = cursor; + if (cursor < 0) { + cursor_new = 0; + } + else if (cursor > cl->len) { + cursor_new = cl->len; + } + else { + cursor_new = cursor; + } if (cursor_new == cl->cursor) { return false; @@ -184,8 +195,12 @@ static ConsoleLine *console_scrollback_add(const bContext *C, ConsoleLine *from) static ConsoleLine *console_lb_add_str__internal(ListBase *lb, char *str, bool own) { ConsoleLine *ci = MEM_callocN(sizeof(ConsoleLine), "ConsoleLine Add"); - if (own) ci->line = str; - else ci->line = BLI_strdup(str); + if (own) { + ci->line = str; + } + else { + ci->line = BLI_strdup(str); + } ci->len = ci->len_alloc = strlen(str); @@ -207,8 +222,9 @@ ConsoleLine *console_history_verify(const bContext *C) { SpaceConsole *sc = CTX_wm_space_console(C); ConsoleLine *ci = sc->history.last; - if (ci == NULL) + if (ci == NULL) { ci = console_history_add(sc, NULL); + } return ci; } @@ -242,8 +258,9 @@ static int console_line_insert(ConsoleLine *ci, char *str) len--; } - if (len == 0) + if (len == 0) { return 0; + } console_line_verify_length(ci, len + ci->len); @@ -480,8 +497,9 @@ static int console_indent_exec(bContext *C, wmOperator *UNUSED(op)) int len; for (spaces = 0; spaces < ci->len; spaces++) { - if (ci->line[spaces] != ' ') + if (ci->line[spaces] != ' ') { break; + } } len = TAB_LENGTH - spaces % TAB_LENGTH; @@ -524,16 +542,19 @@ static int console_unindent_exec(bContext *C, wmOperator *UNUSED(op)) int len; for (spaces = 0; spaces < ci->len; spaces++) { - if (ci->line[spaces] != ' ') + if (ci->line[spaces] != ' ') { break; + } } - if (spaces == 0) + if (spaces == 0) { return OPERATOR_CANCELLED; + } len = spaces % TAB_LENGTH; - if (len == 0) + if (len == 0) { len = TAB_LENGTH; + } console_line_verify_length(ci, ci->len - len); @@ -701,13 +722,15 @@ static int console_clear_exec(bContext *C, wmOperator *op) /*ConsoleLine *ci = */ console_history_verify(C); if (scrollback) { /* last item in mistory */ - while (sc->scrollback.first) + while (sc->scrollback.first) { console_scrollback_free(sc, sc->scrollback.first); + } } if (history) { - while (sc->history.first) + while (sc->history.first) { console_history_free(sc, sc->history.first); + } console_history_verify(C); } @@ -751,8 +774,9 @@ static int console_history_cycle_exec(bContext *C, wmOperator *op) if (ci->prev) { ConsoleLine *ci_prev = (ConsoleLine *)ci->prev; - if (STREQ(ci->line, ci_prev->line)) + if (STREQ(ci->line, ci_prev->line)) { console_history_free(sc, ci_prev); + } } if (reverse) { /* last item in history */ @@ -768,8 +792,9 @@ static int console_history_cycle_exec(bContext *C, wmOperator *op) { /* add a duplicate of the new arg and remove all other instances */ ConsoleLine *cl; - while ((cl = console_history_find(sc, ci->line, ci))) + while ((cl = console_history_find(sc, ci->line, ci))) { console_history_free(sc, cl); + } console_history_add(sc, (ConsoleLine *)sc->history.last); } @@ -818,8 +843,9 @@ static int console_history_append_exec(bContext *C, wmOperator *op) if (rem_dupes) { ConsoleLine *cl; - while ((cl = console_history_find(sc, ci->line, ci))) + while ((cl = console_history_find(sc, ci->line, ci))) { console_history_free(sc, cl); + } if (STREQ(str, ci->line)) { MEM_freeN(str); @@ -928,8 +954,9 @@ static int console_copy_exec(bContext *C, wmOperator *UNUSED(op)) ConsoleLine cl_dummy = {NULL}; - if (sc->sel_start == sc->sel_end) + if (sc->sel_start == sc->sel_end) { return OPERATOR_CANCELLED; + } console_scrollback_prompt_begin(sc, &cl_dummy); @@ -952,8 +979,9 @@ static int console_copy_exec(bContext *C, wmOperator *UNUSED(op)) int sta = max_ii(sel[0], 0); int end = min_ii(sel[1], cl->len); - if (BLI_dynstr_get_len(buf_dyn)) + if (BLI_dynstr_get_len(buf_dyn)) { BLI_dynstr_append(buf_dyn, "\n"); + } BLI_dynstr_nappend(buf_dyn, cl->line + sta, end - sta); } @@ -998,8 +1026,9 @@ static int console_paste_exec(bContext *C, wmOperator *UNUSED(op)) char *buf_str = WM_clipboard_text_get(false, &buf_len); char *buf_step, *buf_next; - if (buf_str == NULL) + if (buf_str == NULL) { return OPERATOR_CANCELLED; + } buf_step = buf_str; diff --git a/source/blender/editors/space_console/space_console.c b/source/blender/editors/space_console/space_console.c index 65f1fe36fec..5d4623e6fe6 100644 --- a/source/blender/editors/space_console/space_console.c +++ b/source/blender/editors/space_console/space_console.c @@ -88,11 +88,13 @@ static void console_free(SpaceLink *sl) { SpaceConsole *sc = (SpaceConsole *) sl; - while (sc->scrollback.first) + while (sc->scrollback.first) { console_scrollback_free(sc, sc->scrollback.first); + } - while (sc->history.first) + while (sc->history.first) { console_history_free(sc, sc->history.first); + } } @@ -208,8 +210,9 @@ static void console_main_region_draw(const bContext *C, ARegion *ar) View2D *v2d = &ar->v2d; View2DScrollers *scrollers; - if (BLI_listbase_is_empty(&sc->scrollback)) + if (BLI_listbase_is_empty(&sc->scrollback)) { WM_operator_name_call((bContext *)C, "CONSOLE_OT_banner", WM_OP_EXEC_DEFAULT, NULL); + } /* clear and setup matrix */ UI_ThemeClearColor(TH_BACK); diff --git a/source/blender/editors/space_image/image_buttons.c b/source/blender/editors/space_image/image_buttons.c index b77c08736dc..47b3f9995c5 100644 --- a/source/blender/editors/space_image/image_buttons.c +++ b/source/blender/editors/space_image/image_buttons.c @@ -69,8 +69,9 @@ static void image_info(Scene *scene, ImageUser *iuser, Image *ima, ImBuf *ibuf, size_t ofs = 0; str[0] = 0; - if (ima == NULL) + if (ima == NULL) { return; + } if (ibuf == NULL) { ofs += BLI_strncpy_rlen(str + ofs, IFACE_("Can't Load Image"), len - ofs); @@ -78,9 +79,10 @@ static void image_info(Scene *scene, ImageUser *iuser, Image *ima, ImBuf *ibuf, else { if (ima->source == IMA_SRC_MOVIE) { ofs += BLI_strncpy_rlen(str + ofs, IFACE_("Movie"), len - ofs); - if (BKE_image_has_anim(ima)) + if (BKE_image_has_anim(ima)) { ofs += BLI_snprintf(str + ofs, len - ofs, IFACE_(" %d frs"), IMB_anim_get_duration(((ImageAnim *)ima->anims.first)->anim, IMB_TC_RECORD_RUN)); + } } else { ofs += BLI_strncpy_rlen(str, IFACE_("Image"), len - ofs); @@ -92,26 +94,33 @@ static void image_info(Scene *scene, ImageUser *iuser, Image *ima, ImBuf *ibuf, if (ibuf->channels != 4) { ofs += BLI_snprintf(str + ofs, len - ofs, IFACE_("%d float channel(s)"), ibuf->channels); } - else if (ibuf->planes == R_IMF_PLANES_RGBA) + else if (ibuf->planes == R_IMF_PLANES_RGBA) { ofs += BLI_strncpy_rlen(str + ofs, IFACE_(" RGBA float"), len - ofs); - else + } + else { ofs += BLI_strncpy_rlen(str + ofs, IFACE_(" RGB float"), len - ofs); + } } else { - if (ibuf->planes == R_IMF_PLANES_RGBA) + if (ibuf->planes == R_IMF_PLANES_RGBA) { ofs += BLI_strncpy_rlen(str + ofs, IFACE_(" RGBA byte"), len - ofs); - else + } + else { ofs += BLI_strncpy_rlen(str + ofs, IFACE_(" RGB byte"), len - ofs); + } } - if (ibuf->zbuf || ibuf->zbuf_float) + if (ibuf->zbuf || ibuf->zbuf_float) { ofs += BLI_strncpy_rlen(str + ofs, IFACE_(" + Z"), len - ofs); + } if (ima->source == IMA_SRC_SEQUENCE) { const char *file = BLI_last_slash(ibuf->name); - if (file == NULL) + if (file == NULL) { file = ibuf->name; - else + } + else { file++; + } ofs += BLI_snprintf(str + ofs, len - ofs, ", %s", file); } } @@ -129,11 +138,15 @@ struct ImageUser *ntree_get_active_iuser(bNodeTree *ntree) { bNode *node; - if (ntree) - for (node = ntree->nodes.first; node; node = node->next) - if (ELEM(node->type, CMP_NODE_VIEWER, CMP_NODE_SPLITVIEWER)) - if (node->flag & NODE_DO_OUTPUT) + if (ntree) { + for (node = ntree->nodes.first; node; node = node->next) { + if (ELEM(node->type, CMP_NODE_VIEWER, CMP_NODE_SPLITVIEWER)) { + if (node->flag & NODE_DO_OUTPUT) { return node->storage; + } + } + } + } return NULL; } @@ -543,8 +556,9 @@ static bool ui_imageuser_layer_menu_step(bContext *C, int direction, void *rnd_p else if (direction == 1) { int tot = BLI_listbase_count(&rr->layers); - if (RE_HasCombinedLayer(rr)) + if (RE_HasCombinedLayer(rr)) { tot++; /* fake compo/sequencer layer */ + } if (iuser->layer < tot - 1) { iuser->layer++; @@ -835,8 +849,9 @@ void uiTemplateImage(uiLayout *layout, bContext *C, PointerRNA *ptr, const char void *lock; - if (!ptr->data) + if (!ptr->data) { return; + } prop = RNA_struct_find_property(ptr, propname); if (!prop) { @@ -921,10 +936,12 @@ void uiTemplateImage(uiLayout *layout, bContext *C, PointerRNA *ptr, const char if (ima->source != IMA_SRC_GENERATED) { row = uiLayoutRow(layout, true); - if (BKE_image_has_packedfile(ima)) + if (BKE_image_has_packedfile(ima)) { uiItemO(row, "", ICON_PACKAGE, "image.unpack"); - else + } + else { uiItemO(row, "", ICON_UGLYPACKAGE, "image.pack"); + } row = uiLayoutRow(row, true); uiLayoutSetEnabled(row, BKE_image_has_packedfile(ima) == false); @@ -1200,8 +1217,9 @@ void uiTemplateImageFormatViews(uiLayout *layout, PointerRNA *imfptr, PointerRNA { ImageFormatData *imf = imfptr->data; - if (ptr == NULL) + if (ptr == NULL) { return; + } uiItemR(layout, ptr, "use_multiview", 0, NULL, ICON_NONE); @@ -1247,8 +1265,9 @@ void uiTemplateImageInfo(uiLayout *layout, bContext *C, Image *ima, ImageUser *i char str[MAX_IMAGE_INFO_LEN]; void *lock; - if (!ima || !iuser) + if (!ima || !iuser) { return; + } ibuf = BKE_image_acquire_ibuf(ima, iuser, &lock); @@ -1297,8 +1316,9 @@ static int image_properties_toggle_exec(bContext *C, wmOperator *UNUSED(op)) ScrArea *sa = CTX_wm_area(C); ARegion *ar = image_has_buttons_region(sa); - if (ar) + if (ar) { ED_region_toggle_hidden(C, ar); + } return OPERATOR_FINISHED; } @@ -1321,8 +1341,9 @@ static int image_scopes_toggle_exec(bContext *C, wmOperator *UNUSED(op)) ScrArea *sa = CTX_wm_area(C); ARegion *ar = image_has_tools_region(sa); - if (ar) + if (ar) { ED_region_toggle_hidden(C, ar); + } return OPERATOR_FINISHED; } diff --git a/source/blender/editors/space_image/image_draw.c b/source/blender/editors/space_image/image_draw.c index e3fd36347fc..ca0f9bd013f 100644 --- a/source/blender/editors/space_image/image_draw.c +++ b/source/blender/editors/space_image/image_draw.c @@ -282,15 +282,19 @@ void ED_image_draw_info(Scene *scene, ARegion *ar, bool color_manage, bool use_d float rgba[4]; copy_v3_v3(rgba, linearcol); - if (channels == 3) + if (channels == 3) { rgba[3] = 1.0f; - else + } + else { rgba[3] = linearcol[3]; + } - if (use_default_view) + if (use_default_view) { IMB_colormanagement_pixel_to_display_space_v4(rgba, rgba, NULL, &scene->display_settings); - else + } + else { IMB_colormanagement_pixel_to_display_space_v4(rgba, rgba, &scene->view_settings, &scene->display_settings); + } SNPRINTF(str, " | CM R:%-.4f G:%-.4f B:%-.4f", rgba[0], rgba[1], rgba[2]); BLF_position(blf_mono_font, dx, dy, 0); @@ -325,10 +329,12 @@ void ED_image_draw_info(Scene *scene, ARegion *ar, bool color_manage, bool use_d } if (color_manage) { - if (use_default_view) + if (use_default_view) { IMB_colormanagement_pixel_to_display_space_v4(finalcol, col, NULL, &scene->display_settings); - else + } + else { IMB_colormanagement_pixel_to_display_space_v4(finalcol, col, &scene->view_settings, &scene->display_settings); + } } else { copy_v4_v4(finalcol, col); @@ -471,10 +477,12 @@ static void sima_draw_zbuffloat_pixels(Scene *scene, float x1, float y1, int rec rectf = MEM_mallocN(rectx * recty * sizeof(float), "temp"); for (a = rectx * recty - 1; a >= 0; a--) { - if (rect_float[a] > clip_end) + if (rect_float[a] > clip_end) { rectf[a] = 0.0f; - else if (rect_float[a] < bias) + } + else if (rect_float[a] < bias) { rectf[a] = 1.0f; + } else { rectf[a] = 1.0f - (rect_float[a] - bias) * scale; rectf[a] *= rectf[a]; @@ -498,12 +506,15 @@ static void draw_image_buffer(const bContext *C, SpaceImage *sima, ARegion *ar, /* this part is generic image display */ if (sima->flag & SI_SHOW_ZBUF && (ibuf->zbuf || ibuf->zbuf_float || (ibuf->channels == 1))) { - if (ibuf->zbuf) + if (ibuf->zbuf) { sima_draw_zbuf_pixels(x, y, ibuf->x, ibuf->y, ibuf->zbuf, zoomx, zoomy); - else if (ibuf->zbuf_float) + } + else if (ibuf->zbuf_float) { sima_draw_zbuffloat_pixels(scene, x, y, ibuf->x, ibuf->y, ibuf->zbuf_float, zoomx, zoomy); - else if (ibuf->channels == 1) + } + else if (ibuf->channels == 1) { sima_draw_zbuffloat_pixels(scene, x, y, ibuf->x, ibuf->y, ibuf->rect_float, zoomx, zoomy); + } } else { int clip_max_x, clip_max_y; @@ -531,14 +542,18 @@ static void draw_image_buffer(const bContext *C, SpaceImage *sima, ARegion *ar, ColorManagedViewSettings *view_settings; ColorManagedDisplaySettings *display_settings; - if (sima->flag & SI_SHOW_R) + if (sima->flag & SI_SHOW_R) { shuffle[0] = 1.0f; - else if (sima->flag & SI_SHOW_G) + } + else if (sima->flag & SI_SHOW_G) { shuffle[1] = 1.0f; - else if (sima->flag & SI_SHOW_B) + } + else if (sima->flag & SI_SHOW_B) { shuffle[2] = 1.0f; - else if (sima->flag & SI_SHOW_ALPHA) + } + else if (sima->flag & SI_SHOW_ALPHA) { shuffle[3] = 1.0f; + } IMMDrawPixelsTexState state = immDrawPixelsTexSetup(GPU_SHADER_2D_IMAGE_SHUFFLE_COLOR); GPU_shader_uniform_vector(state.shader, GPU_shader_get_uniform_ensure(state.shader, "shuffle"), 4, 1, shuffle); @@ -554,8 +569,9 @@ static void draw_image_buffer(const bContext *C, SpaceImage *sima, ARegion *ar, IMB_display_buffer_release(cache_handle); } - if (sima->flag & SI_USE_ALPHA) + if (sima->flag & SI_USE_ALPHA) { GPU_blend(false); + } } } @@ -573,8 +589,9 @@ static void draw_image_buffer_repeated(const bContext *C, SpaceImage *sima, AReg draw_image_buffer(C, sima, ar, scene, ibuf, x, y, zoomx, zoomy); /* only draw until running out of time */ - if ((PIL_check_seconds_timer() - time_current) > 0.25) + if ((PIL_check_seconds_timer() - time_current) > 0.25) { return; + } } } } @@ -715,11 +732,13 @@ void draw_image_main(const bContext *C, ARegion *ar) } if (show_stereo3d) { - if (show_multilayer) + if (show_multilayer) { /* update multiindex and pass for the current eye */ BKE_image_multilayer_index(ima->rr, &sima->iuser); - else + } + else { BKE_image_multiview_index(ima, &sima->iuser); + } } ibuf = ED_space_image_acquire_buffer(sima, &lock); @@ -729,10 +748,12 @@ void draw_image_main(const bContext *C, ARegion *ar) ED_region_grid_draw(ar, zoomx, zoomy); } else { - if (sima->flag & SI_DRAW_TILE) + if (sima->flag & SI_DRAW_TILE) { draw_image_buffer_repeated(C, sima, ar, scene, ibuf, zoomx, zoomy); - else + } + else { draw_image_buffer(C, sima, ar, scene, ibuf, 0.0f, 0.0f, zoomx, zoomy); + } if (sima->flag & SI_DRAW_METADATA) { int x, y; @@ -748,16 +769,18 @@ void draw_image_main(const bContext *C, ARegion *ar) ED_space_image_release_buffer(sima, ibuf, lock); /* paint helpers */ - if (show_paint) + if (show_paint) { draw_image_paint_helpers(C, ar, scene, zoomx, zoomy); + } if (show_viewer) { BLI_thread_unlock(LOCK_DRAW_IMAGE); } /* render info */ - if (ima && show_render) + if (ima && show_render) { draw_render_info(C, sima->iuser.scene, ima, ar, zoomx, zoomy); + } } bool ED_space_image_show_cache(SpaceImage *sima) diff --git a/source/blender/editors/space_image/image_edit.c b/source/blender/editors/space_image/image_edit.c index c8edccb0472..c838c6a87fe 100644 --- a/source/blender/editors/space_image/image_edit.c +++ b/source/blender/editors/space_image/image_edit.c @@ -74,13 +74,15 @@ void ED_space_image_set(Main *bmain, SpaceImage *sima, Object *obedit, Image *im } } - if (sima->image) + if (sima->image) { BKE_image_signal(bmain, sima->image, &sima->iuser, IMA_SIGNAL_USER_NEW_IMAGE); + } id_us_ensure_real((ID *)sima->image); - if (obedit) + if (obedit) { WM_main_add_notifier(NC_GEOM | ND_DATA, obedit->data); + } WM_main_add_notifier(NC_SPACE | ND_SPACE_IMAGE, NULL); } @@ -147,22 +149,25 @@ ImBuf *ED_space_image_acquire_buffer(SpaceImage *sima, void **r_lock) ibuf = BKE_image_acquire_ibuf(sima->image, &sima->iuser, r_lock); if (ibuf) { - if (ibuf->rect || ibuf->rect_float) + if (ibuf->rect || ibuf->rect_float) { return ibuf; + } BKE_image_release_ibuf(sima->image, ibuf, *r_lock); *r_lock = NULL; } } - else + else { *r_lock = NULL; + } return NULL; } void ED_space_image_release_buffer(SpaceImage *sima, ImBuf *ibuf, void *lock) { - if (sima && sima->image) + if (sima && sima->image) { BKE_image_release_ibuf(sima->image, ibuf, lock); + } } bool ED_space_image_has_buffer(SpaceImage *sima) @@ -335,7 +340,9 @@ bool ED_image_slot_cycle(struct Image *image, int direction) int num_slots = BLI_listbase_count(&image->renderslots); for (i = 1; i < num_slots; i++) { slot = (cur + ((direction == -1) ? -i : i)) % num_slots; - if (slot < 0) slot += num_slots; + if (slot < 0) { + slot += num_slots; + } RenderSlot *render_slot = BKE_image_get_renderslot(image, slot); if ((render_slot && render_slot->render) || slot == image->last_render_slot) { @@ -357,10 +364,12 @@ void ED_space_image_scopes_update(const struct bContext *C, struct SpaceImage *s Object *ob = CTX_data_active_object(C); /* scope update can be expensive, don't update during paint modes */ - if (sima->mode == SI_MODE_PAINT) + if (sima->mode == SI_MODE_PAINT) { return; - if (ob && ((ob->mode & (OB_MODE_TEXTURE_PAINT | OB_MODE_EDIT)) != 0)) + } + if (ob && ((ob->mode & (OB_MODE_TEXTURE_PAINT | OB_MODE_EDIT)) != 0)) { return; + } /* We also don't update scopes of render result during render. */ if (G.is_rendering) { @@ -382,8 +391,9 @@ bool ED_space_image_show_render(SpaceImage *sima) bool ED_space_image_show_paint(SpaceImage *sima) { - if (ED_space_image_show_render(sima)) + if (ED_space_image_show_render(sima)) { return false; + } return (sima->mode == SI_MODE_PAINT); } @@ -442,8 +452,9 @@ bool ED_space_image_paint_curve(const bContext *C) if (sima && sima->mode == SI_MODE_PAINT) { Brush *br = CTX_data_tool_settings(C)->imapaint.paint.brush; - if (br && (br->flag & BRUSH_CURVE)) + if (br && (br->flag & BRUSH_CURVE)) { return true; + } } return false; diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c index 9cbb4263e23..831be935fa4 100644 --- a/source/blender/editors/space_image/image_ops.c +++ b/source/blender/editors/space_image/image_ops.c @@ -117,12 +117,15 @@ static void sima_zoom_set(SpaceImage *sima, ARegion *ar, float zoom, const float width *= sima->zoom; height *= sima->zoom; - if ((width < 4) && (height < 4) && sima->zoom < oldzoom) + if ((width < 4) && (height < 4) && sima->zoom < oldzoom) { sima->zoom = oldzoom; - else if (BLI_rcti_size_x(&ar->winrct) <= sima->zoom) + } + else if (BLI_rcti_size_x(&ar->winrct) <= sima->zoom) { sima->zoom = oldzoom; - else if (BLI_rcti_size_y(&ar->winrct) <= sima->zoom) + } + else if (BLI_rcti_size_y(&ar->winrct) <= sima->zoom) { sima->zoom = oldzoom; + } } if ((U.uiflag & USER_ZOOM_TO_MOUSEPOS) && location) { @@ -489,8 +492,9 @@ static void image_view_zoom_exit(bContext *C, wmOperator *op, bool cancel) ED_region_tag_redraw(CTX_wm_region(C)); } - if (vpd->timer) + if (vpd->timer) { WM_event_remove_timer(CTX_wm_manager(C), vpd->timer->win, vpd->timer); + } WM_cursor_modal_restore(CTX_wm_window(C)); MEM_freeN(op->customdata); @@ -534,8 +538,9 @@ static int image_view_zoom_invoke(bContext *C, wmOperator *op, const wmEvent *ev delta = event->prevx - event->x + event->prevy - event->y; - if (U.uiflag & USER_ZOOM_INVERT) + if (U.uiflag & USER_ZOOM_INVERT) { delta *= -1; + } factor = 1.0f + delta / 300.0f; RNA_float_set(op->ptr, "factor", factor); @@ -582,8 +587,9 @@ static void image_zoom_apply(ViewZoomData *vpd, wmOperator *op, const int x, con /* for now do the same things for scale and dolly */ float delta = x - vpd->origx + y - vpd->origy; - if (zoom_invert) + if (zoom_invert) { delta *= -1.0f; + } factor = 1.0f + delta / 300.0f; } @@ -662,8 +668,9 @@ void IMAGE_OT_view_zoom(wmOperatorType *ot) static int image_view_ndof_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent *event) { - if (event->type != NDOF_MOTION) + if (event->type != NDOF_MOTION) { return OPERATOR_CANCELLED; + } else { SpaceImage *sima = CTX_wm_space_image(C); ARegion *ar = CTX_wm_region(C); @@ -747,8 +754,9 @@ static int image_view_all_exec(bContext *C, wmOperator *op) /* find the zoom value that will fit the image in the image space */ sima_zoom_set(sima, ar, 1.0f / power_of_2(1.0f / min_ff(zoomx, zoomy)), NULL); } - else + else { sima_zoom_set(sima, ar, 1.0f, NULL); + } } sima->xof = sima->yof = 0.0f; @@ -1138,8 +1146,12 @@ static int image_cmp_frame(const void *a, const void *b) const ImageFrame *frame_a = a; const ImageFrame *frame_b = b; - if (frame_a->framenr < frame_b->framenr) return -1; - if (frame_a->framenr > frame_b->framenr) return 1; + if (frame_a->framenr < frame_b->framenr) { + return -1; + } + if (frame_a->framenr > frame_b->framenr) { + return 1; + } return 0; } @@ -1181,7 +1193,9 @@ static Image *image_open_single( ima = BKE_image_load_exists_ex(bmain, filepath, &exists); if (!ima) { - if (op->customdata) MEM_freeN(op->customdata); + if (op->customdata) { + MEM_freeN(op->customdata); + } BKE_reportf(op->reports, RPT_ERROR, "Cannot read '%s': %s", filepath, errno ? strerror(errno) : TIP_("unsupported image format")); return NULL; @@ -1232,8 +1246,9 @@ static int image_open_exec(bContext *C, wmOperator *op) const bool is_relative_path = RNA_boolean_get(op->ptr, "relative_path"); const bool use_multiview = RNA_boolean_get(op->ptr, "use_multiview"); - if (!op->customdata) + if (!op->customdata) { image_open_init(C, op); + } RNA_string_get(op->ptr, "filepath", filepath); @@ -1361,8 +1376,9 @@ static int image_open_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED( if (ima == NULL) { Tex *tex = CTX_data_pointer_get_type(C, "texture", &RNA_Texture).data; - if (tex && tex->type == TEX_IMAGE) + if (tex && tex->type == TEX_IMAGE) { ima = tex->ima; + } } if (ima == NULL) { @@ -1385,11 +1401,13 @@ static int image_open_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED( } } - if (ima) + if (ima) { path = ima->name; + } - if (RNA_struct_property_is_set(op->ptr, "filepath")) + if (RNA_struct_property_is_set(op->ptr, "filepath")) { return image_open_exec(C, op); + } image_open_init(C, op); @@ -1428,8 +1446,9 @@ static void image_open_draw(bContext *UNUSED(C), wmOperator *op) RNA_pointer_create(NULL, &RNA_ImageFormatSettings, imf, &imf_ptr); /* multiview template */ - if (RNA_boolean_get(op->ptr, "show_multiview")) + if (RNA_boolean_get(op->ptr, "show_multiview")) { uiTemplateImageFormatViews(layout, &imf_ptr, op->ptr); + } } /* called by other space types too */ @@ -1481,12 +1500,14 @@ static int image_match_len_exec(bContext *C, wmOperator *UNUSED(op)) } - if (!ima || !iuser || !BKE_image_has_anim(ima)) + if (!ima || !iuser || !BKE_image_has_anim(ima)) { return OPERATOR_CANCELLED; + } struct anim *anim = ((ImageAnim *)ima->anims.first)->anim; - if (!anim) + if (!anim) { return OPERATOR_CANCELLED; + } iuser->frames = IMB_anim_get_duration(anim, IMB_TC_RECORD_RUN); BKE_image_user_frame_calc(iuser, scene->r.cfra); @@ -1517,8 +1538,9 @@ static int image_replace_exec(bContext *C, wmOperator *op) SpaceImage *sima = CTX_wm_space_image(C); char str[FILE_MAX]; - if (!sima->image) + if (!sima->image) { return OPERATOR_CANCELLED; + } RNA_string_get(op->ptr, "filepath", str); @@ -1530,10 +1552,12 @@ static int image_replace_exec(bContext *C, wmOperator *op) BKE_image_signal(bmain, sima->image, &sima->iuser, IMA_SIGNAL_SRC_CHANGE); } - if (BLI_path_extension_check_array(str, imb_ext_movie)) + if (BLI_path_extension_check_array(str, imb_ext_movie)) { sima->image->source = IMA_SRC_MOVIE; - else + } + else { sima->image->source = IMA_SRC_FILE; + } /* XXX unpackImage frees image buffers */ ED_preview_kill_jobs(CTX_wm_manager(C), CTX_data_main(C)); @@ -1549,14 +1573,17 @@ static int image_replace_invoke(bContext *C, wmOperator *op, const wmEvent *UNUS { SpaceImage *sima = CTX_wm_space_image(C); - if (!sima->image) + if (!sima->image) { return OPERATOR_CANCELLED; + } - if (RNA_struct_property_is_set(op->ptr, "filepath")) + if (RNA_struct_property_is_set(op->ptr, "filepath")) { return image_replace_exec(C, op); + } - if (!RNA_struct_property_is_set(op->ptr, "relative_path")) + if (!RNA_struct_property_is_set(op->ptr, "relative_path")) { RNA_boolean_set(op->ptr, "relative_path", BLI_path_is_rel(sima->image->name)); + } image_filesel(C, op, sima->image->name); @@ -1604,18 +1631,18 @@ static char imtype_best_depth(ImBuf *ibuf, const char imtype) const char depth_ok = BKE_imtype_valid_depths(imtype); if (ibuf->rect_float) { - if (depth_ok & R_IMF_CHAN_DEPTH_32) return R_IMF_CHAN_DEPTH_32; - if (depth_ok & R_IMF_CHAN_DEPTH_24) return R_IMF_CHAN_DEPTH_24; - if (depth_ok & R_IMF_CHAN_DEPTH_16) return R_IMF_CHAN_DEPTH_16; - if (depth_ok & R_IMF_CHAN_DEPTH_12) return R_IMF_CHAN_DEPTH_12; + if (depth_ok & R_IMF_CHAN_DEPTH_32) { return R_IMF_CHAN_DEPTH_32; } + if (depth_ok & R_IMF_CHAN_DEPTH_24) { return R_IMF_CHAN_DEPTH_24; } + if (depth_ok & R_IMF_CHAN_DEPTH_16) { return R_IMF_CHAN_DEPTH_16; } + if (depth_ok & R_IMF_CHAN_DEPTH_12) { return R_IMF_CHAN_DEPTH_12; } return R_IMF_CHAN_DEPTH_8; } else { - if (depth_ok & R_IMF_CHAN_DEPTH_8) return R_IMF_CHAN_DEPTH_8; - if (depth_ok & R_IMF_CHAN_DEPTH_12) return R_IMF_CHAN_DEPTH_12; - if (depth_ok & R_IMF_CHAN_DEPTH_16) return R_IMF_CHAN_DEPTH_16; - if (depth_ok & R_IMF_CHAN_DEPTH_24) return R_IMF_CHAN_DEPTH_24; - if (depth_ok & R_IMF_CHAN_DEPTH_32) return R_IMF_CHAN_DEPTH_32; + if (depth_ok & R_IMF_CHAN_DEPTH_8) { return R_IMF_CHAN_DEPTH_8; } + if (depth_ok & R_IMF_CHAN_DEPTH_12) { return R_IMF_CHAN_DEPTH_12; } + if (depth_ok & R_IMF_CHAN_DEPTH_16) { return R_IMF_CHAN_DEPTH_16; } + if (depth_ok & R_IMF_CHAN_DEPTH_24) { return R_IMF_CHAN_DEPTH_24; } + if (depth_ok & R_IMF_CHAN_DEPTH_32) { return R_IMF_CHAN_DEPTH_32; } return R_IMF_CHAN_DEPTH_8; /* fallback, should not get here */ } } @@ -1753,14 +1780,18 @@ static void save_image_post( /* workaround to ensure the render result buffer is no longer used * by this image, otherwise can crash when a new render result is * created. */ - if (ibuf->rect && !(ibuf->mall & IB_rect)) + if (ibuf->rect && !(ibuf->mall & IB_rect)) { imb_freerectImBuf(ibuf); - if (ibuf->rect_float && !(ibuf->mall & IB_rectfloat)) + } + if (ibuf->rect_float && !(ibuf->mall & IB_rectfloat)) { imb_freerectfloatImBuf(ibuf); - if (ibuf->zbuf && !(ibuf->mall & IB_zbuf)) + } + if (ibuf->zbuf && !(ibuf->mall & IB_zbuf)) { IMB_freezbufImBuf(ibuf); - if (ibuf->zbuf_float && !(ibuf->mall & IB_zbuffloat)) + } + if (ibuf->zbuf_float && !(ibuf->mall & IB_zbuffloat)) { IMB_freezbuffloatImBuf(ibuf); + } } if (ELEM(ima->source, IMA_SRC_GENERATED, IMA_SRC_VIEWER)) { ima->source = IMA_SRC_FILE; @@ -1932,10 +1963,12 @@ static bool save_image_doit(bContext *C, SpaceImage *sima, wmOperator *op, SaveI iuser.view = i; iuser.flag &= ~IMA_SHOW_STEREO; - if (rr) + if (rr) { BKE_image_multilayer_index(rr, &iuser); - else + } + else { BKE_image_multiview_index(ima, &iuser); + } ibuf = BKE_image_acquire_ibuf(sima->image, &iuser, &lock); ibuf->planes = planes; @@ -2087,13 +2120,15 @@ static int image_save_as_invoke(bContext *C, wmOperator *op, const wmEvent *UNUS PropertyRNA *prop; const bool save_as_render = ((ima->source == IMA_SRC_VIEWER) || (ima->flag & IMA_VIEW_AS_RENDER)); - if (RNA_struct_property_is_set(op->ptr, "filepath")) + if (RNA_struct_property_is_set(op->ptr, "filepath")) { return image_save_as_exec(C, op); + } save_image_options_defaults(&simopts); - if (save_image_options_init(bmain, &simopts, sima, scene, true, save_as_render) == 0) + if (save_image_options_init(bmain, &simopts, sima, scene, true, save_as_render) == 0) { return OPERATOR_CANCELLED; + } save_image_options_to_op(&simopts, op); /* enable save_copy by default for render results */ @@ -2150,8 +2185,9 @@ static void image_save_as_draw(bContext *UNUSED(C), wmOperator *op) uiDefAutoButsRNA(layout, &ptr, image_save_as_draw_check_prop, NULL, NULL, UI_BUT_LABEL_ALIGN_NONE, false); /* multiview template */ - if (is_multiview) + if (is_multiview) { uiTemplateImageFormatViews(layout, &imf_ptr, op->ptr); + } } static bool image_save_as_poll(bContext *C) @@ -2209,8 +2245,9 @@ static int image_save_exec(bContext *C, wmOperator *op) SaveImageOptions simopts; save_image_options_defaults(&simopts); - if (save_image_options_init(bmain, &simopts, sima, scene, false, false) == 0) + if (save_image_options_init(bmain, &simopts, sima, scene, false, false) == 0) { return OPERATOR_CANCELLED; + } save_image_options_from_op(bmain, &simopts, op); if (BLI_exists(simopts.filepath) && BLI_file_is_writable(simopts.filepath)) { @@ -2253,8 +2290,9 @@ static int image_save_sequence_exec(bContext *C, wmOperator *op) char di[FILE_MAX]; struct MovieCacheIter *iter; - if (sima->image == NULL) + if (sima->image == NULL) { return OPERATOR_CANCELLED; + } if (sima->image->source != IMA_SRC_SEQUENCE) { BKE_report(op->reports, RPT_ERROR, "Can only save sequence on image sequences"); @@ -2341,8 +2379,9 @@ static int image_reload_exec(bContext *C, wmOperator *UNUSED(op)) Image *ima = CTX_data_edit_image(C); SpaceImage *sima = CTX_wm_space_image(C); - if (!ima) + if (!ima) { return OPERATOR_CANCELLED; + } /* XXX unpackImage frees image buffers */ ED_preview_kill_jobs(CTX_wm_manager(C), CTX_data_main(C)); @@ -2437,8 +2476,9 @@ static int image_new_exec(bContext *C, wmOperator *op) alpha = RNA_boolean_get(op->ptr, "alpha"); stereo3d = RNA_boolean_get(op->ptr, "use_stereo_3d"); - if (!alpha) + if (!alpha) { color[3] = 1.0f; + } ima = BKE_image_add_generated(bmain, width, height, name, alpha ? 32 : 24, floatbuf, gen_type, color, stereo3d); @@ -2619,10 +2659,10 @@ static int image_invert_exec(bContext *C, wmOperator *op) float *fp = (float *) ibuf->rect_float; for (i = ((size_t)ibuf->x) * ibuf->y; i > 0; i--, fp += 4) { - if (r) fp[0] = 1.0f - fp[0]; - if (g) fp[1] = 1.0f - fp[1]; - if (b) fp[2] = 1.0f - fp[2]; - if (a) fp[3] = 1.0f - fp[3]; + if (r) { fp[0] = 1.0f - fp[0]; } + if (g) { fp[1] = 1.0f - fp[1]; } + if (b) { fp[2] = 1.0f - fp[2]; } + if (a) { fp[3] = 1.0f - fp[3]; } } if (ibuf->rect) { @@ -2633,10 +2673,10 @@ static int image_invert_exec(bContext *C, wmOperator *op) char *cp = (char *) ibuf->rect; for (i = ((size_t)ibuf->x) * ibuf->y; i > 0; i--, cp += 4) { - if (r) cp[0] = 255 - cp[0]; - if (g) cp[1] = 255 - cp[1]; - if (b) cp[2] = 255 - cp[2]; - if (a) cp[3] = 255 - cp[3]; + if (r) { cp[0] = 255 - cp[0]; } + if (g) { cp[1] = 255 - cp[1]; } + if (b) { cp[2] = 255 - cp[2]; } + if (a) { cp[3] = 255 - cp[3]; } } } else { @@ -2646,8 +2686,9 @@ static int image_invert_exec(bContext *C, wmOperator *op) ibuf->userflags |= IB_BITMAPDIRTY | IB_DISPLAY_BUFFER_INVALID; - if (ibuf->mipmap[0]) + if (ibuf->mipmap[0]) { ibuf->userflags |= IB_MIPMAP_INVALID; + } if (support_undo) { ED_image_undo_push_end(); @@ -2697,10 +2738,12 @@ static bool image_pack_test(bContext *C, wmOperator *op) Image *ima = CTX_data_edit_image(C); const bool as_png = RNA_boolean_get(op->ptr, "as_png"); - if (!ima) + if (!ima) { return 0; - if (!as_png && BKE_image_has_packedfile(ima)) + } + if (!as_png && BKE_image_has_packedfile(ima)) { return 0; + } if (ima->source == IMA_SRC_SEQUENCE || ima->source == IMA_SRC_MOVIE) { BKE_report(op->reports, RPT_ERROR, "Packing movies or image sequences not supported"); @@ -2717,18 +2760,21 @@ static int image_pack_exec(bContext *C, wmOperator *op) ImBuf *ibuf = BKE_image_acquire_ibuf(ima, NULL, NULL); const bool as_png = RNA_boolean_get(op->ptr, "as_png"); - if (!image_pack_test(C, op)) + if (!image_pack_test(C, op)) { return OPERATOR_CANCELLED; + } if (!as_png && (ibuf && (ibuf->userflags & IB_BITMAPDIRTY))) { BKE_report(op->reports, RPT_ERROR, "Cannot pack edited image from disk, only as internal PNG"); return OPERATOR_CANCELLED; } - if (as_png) + if (as_png) { BKE_image_memorypack(ima); - else + } + else { BKE_image_packfiles(op->reports, ima, ID_BLEND_PATH(bmain, &ima->id)); + } WM_event_add_notifier(C, NC_IMAGE | NA_EDITED, ima); @@ -2745,8 +2791,9 @@ static int image_pack_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED( uiLayout *layout; const bool as_png = RNA_boolean_get(op->ptr, "as_png"); - if (!image_pack_test(C, op)) + if (!image_pack_test(C, op)) { return OPERATOR_CANCELLED; + } ibuf = BKE_image_acquire_ibuf(ima, NULL, NULL); @@ -2797,19 +2844,23 @@ static int image_unpack_exec(bContext *C, wmOperator *op) char imaname[MAX_ID_NAME - 2]; RNA_string_get(op->ptr, "id", imaname); ima = BLI_findstring(&CTX_data_main(C)->images, imaname, offsetof(ID, name) + 2); - if (!ima) ima = CTX_data_edit_image(C); + if (!ima) { + ima = CTX_data_edit_image(C); + } } - if (!ima || !BKE_image_has_packedfile(ima)) + if (!ima || !BKE_image_has_packedfile(ima)) { return OPERATOR_CANCELLED; + } if (ima->source == IMA_SRC_SEQUENCE || ima->source == IMA_SRC_MOVIE) { BKE_report(op->reports, RPT_ERROR, "Unpacking movies or image sequences not supported"); return OPERATOR_CANCELLED; } - if (G.fileflags & G_FILE_AUTOPACK) + if (G.fileflags & G_FILE_AUTOPACK) { BKE_report(op->reports, RPT_WARNING, "AutoPack is enabled, so image will be packed again on file save"); + } /* XXX unpackImage frees image buffers */ ED_preview_kill_jobs(CTX_wm_manager(C), CTX_data_main(C)); @@ -2825,19 +2876,22 @@ static int image_unpack_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSE { Image *ima = CTX_data_edit_image(C); - if (RNA_struct_property_is_set(op->ptr, "id")) + if (RNA_struct_property_is_set(op->ptr, "id")) { return image_unpack_exec(C, op); + } - if (!ima || !BKE_image_has_packedfile(ima)) + if (!ima || !BKE_image_has_packedfile(ima)) { return OPERATOR_CANCELLED; + } if (ima->source == IMA_SRC_SEQUENCE || ima->source == IMA_SRC_MOVIE) { BKE_report(op->reports, RPT_ERROR, "Unpacking movies or image sequences not supported"); return OPERATOR_CANCELLED; } - if (G.fileflags & G_FILE_AUTOPACK) + if (G.fileflags & G_FILE_AUTOPACK) { BKE_report(op->reports, RPT_WARNING, "AutoPack is enabled, so image will be packed again on file save"); + } unpack_menu(C, "IMAGE_OT_unpack", ima->id.name + 2, ima->name, "textures", BKE_image_has_packedfile(ima) ? ((ImagePackedFile *)ima->packedfiles.first)->packedfile : NULL); @@ -3209,8 +3263,9 @@ static int image_sample_invoke(bContext *C, wmOperator *op, const wmEvent *event } } - if (!ED_space_image_has_buffer(sima)) + if (!ED_space_image_has_buffer(sima)) { return OPERATOR_CANCELLED; + } info = MEM_callocN(sizeof(ImageSampleInfo), "ImageSampleInfo"); @@ -3329,8 +3384,9 @@ static int image_sample_line_invoke(bContext *C, wmOperator *op, const wmEvent * Histogram *hist = &sima->sample_line_hist; hist->flag &= ~HISTO_FLAG_SAMPLELINE; - if (!ED_space_image_has_buffer(sima)) + if (!ED_space_image_has_buffer(sima)) { return OPERATOR_CANCELLED; + } return WM_gesture_straightline_invoke(C, op, event); } @@ -3559,8 +3615,9 @@ static int image_cycle_render_slot_exec(bContext *C, wmOperator *op) /* no undo push for browsing existing */ RenderSlot *slot = BKE_image_get_renderslot(ima, ima->render_slot); - if ((slot && slot->render) || ima->render_slot == ima->last_render_slot) + if ((slot && slot->render) || ima->render_slot == ima->last_render_slot) { return OPERATOR_CANCELLED; + } return OPERATOR_FINISHED; } @@ -3678,8 +3735,9 @@ void IMAGE_OT_remove_render_slot(wmOperatorType *ot) static bool change_frame_poll(bContext *C) { /* prevent changes during render */ - if (G.is_rendering) + if (G.is_rendering) { return 0; + } return space_image_main_region_poll(C); } @@ -3761,8 +3819,9 @@ static int change_frame_modal(bContext *C, wmOperator *op, const wmEvent *event) case LEFTMOUSE: case RIGHTMOUSE: - if (event->val == KM_RELEASE) + if (event->val == KM_RELEASE) { return OPERATOR_FINISHED; + } break; } diff --git a/source/blender/editors/space_image/space_image.c b/source/blender/editors/space_image/space_image.c index 7aa3ea57956..d5eb0b485a1 100644 --- a/source/blender/editors/space_image/space_image.c +++ b/source/blender/editors/space_image/space_image.c @@ -91,8 +91,9 @@ static void image_scopes_tag_refresh(ScrArea *sa) /* only while histogram is visible */ for (ar = sa->regionbase.first; ar; ar = ar->next) { - if (ar->regiontype == RGN_TYPE_TOOL_PROPS && ar->flag & RGN_FLAG_HIDDEN) + if (ar->regiontype == RGN_TYPE_TOOL_PROPS && ar->flag & RGN_FLAG_HIDDEN) { return; + } } sima->scopes.ok = 0; @@ -122,13 +123,17 @@ ARegion *image_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 image"); @@ -146,13 +151,17 @@ ARegion *image_has_tools_region(ScrArea *sa) ARegion *ar, *arnew; ar = BKE_area_find_region_type(sa, RGN_TYPE_TOOLS); - if (ar) return ar; + if (ar) { + return ar; + } /* add subdiv level; after buttons */ ar = BKE_area_find_region_type(sa, RGN_TYPE_UI); /* is error! */ - if (ar == NULL) return NULL; + if (ar == NULL) { + return NULL; + } arnew = MEM_callocN(sizeof(ARegion), "scopes for image"); @@ -371,15 +380,17 @@ static void image_listener(wmWindow *win, ScrArea *sa, wmNotifier *wmn, Scene *U ED_area_tag_redraw(sa); break; case ND_MODE: - if (wmn->subtype == NS_EDITMODE_MESH) + if (wmn->subtype == NS_EDITMODE_MESH) { ED_area_tag_refresh(sa); + } ED_area_tag_redraw(sa); break; case ND_RENDER_RESULT: case ND_RENDER_OPTIONS: case ND_COMPO_RESULT: - if (ED_space_image_show_render(sima)) + if (ED_space_image_show_render(sima)) { image_scopes_tag_refresh(sa); + } ED_area_tag_redraw(sa); break; } @@ -532,8 +543,9 @@ static void image_main_region_set_view2d(SpaceImage *sima, ARegion *ar) float w = width; float h = height; - if (ima) + if (ima) { h *= ima->aspy / ima->aspx; + } int winx = BLI_rcti_size_x(&ar->winrct) + 1; int winy = BLI_rcti_size_y(&ar->winrct) + 1; @@ -703,8 +715,9 @@ static void image_main_region_draw(const bContext *C, ARegion *ar) ED_space_image_get_size(sima, &width, &height); ED_space_image_get_aspect(sima, &aspx, &aspy); - if (show_viewer) + if (show_viewer) { BLI_thread_unlock(LOCK_DRAW_IMAGE); + } ED_mask_draw_region(mask, ar, sima->mask_info.draw_flag, @@ -744,26 +757,31 @@ static void image_main_region_listener( /* context changes */ switch (wmn->category) { case NC_GEOM: - if (ELEM(wmn->data, ND_DATA, ND_SELECT)) + if (ELEM(wmn->data, ND_DATA, ND_SELECT)) { WM_gizmomap_tag_refresh(ar->gizmo_map); + } break; case NC_GPENCIL: - if (ELEM(wmn->action, NA_EDITED, NA_SELECTED)) + if (ELEM(wmn->action, NA_EDITED, NA_SELECTED)) { ED_region_tag_redraw(ar); - else if (wmn->data & ND_GPENCIL_EDITMODE) + } + else if (wmn->data & ND_GPENCIL_EDITMODE) { ED_region_tag_redraw(ar); + } break; case NC_IMAGE: - if (wmn->action == NA_PAINTING) + if (wmn->action == NA_PAINTING) { ED_region_tag_redraw(ar); + } WM_gizmomap_tag_refresh(ar->gizmo_map); break; case NC_MATERIAL: if (wmn->data == ND_SHADING_LINKS) { SpaceImage *sima = sa->spacedata.first; - if (sima->iuser.scene && (sima->iuser.scene->toolsettings->uv_flag & UV_SHOW_SAME_IMAGE)) + if (sima->iuser.scene && (sima->iuser.scene->toolsettings->uv_flag & UV_SHOW_SAME_IMAGE)) { ED_region_tag_redraw(ar); + } } break; case NC_SCREEN: @@ -803,10 +821,12 @@ static void image_buttons_region_draw(const bContext *C, ARegion *ar) if (!sima->scopes.ok) { BKE_histogram_update_sample_line(&sima->sample_line_hist, ibuf, &scene->view_settings, &scene->display_settings); } - if (sima->image->flag & IMA_VIEW_AS_RENDER) + if (sima->image->flag & IMA_VIEW_AS_RENDER) { ED_space_image_scopes_update(C, sima, ibuf, true); - else + } + else { ED_space_image_scopes_update(C, sima, ibuf, false); + } } } ED_space_image_release_buffer(sima, ibuf, lock); @@ -836,15 +856,17 @@ static void image_buttons_region_listener( } break; case NC_IMAGE: - if (wmn->action != NA_PAINTING) + if (wmn->action != NA_PAINTING) { ED_region_tag_redraw(ar); + } break; case NC_NODE: ED_region_tag_redraw(ar); break; case NC_GPENCIL: - if (ELEM(wmn->action, NA_EDITED, NA_SELECTED)) + if (ELEM(wmn->action, NA_EDITED, NA_SELECTED)) { ED_region_tag_redraw(ar); + } break; } } @@ -875,13 +897,15 @@ static void image_tools_region_listener( /* context changes */ switch (wmn->category) { case NC_GPENCIL: - if (wmn->data == ND_DATA || ELEM(wmn->action, NA_EDITED, NA_SELECTED)) + if (wmn->data == ND_DATA || ELEM(wmn->action, NA_EDITED, NA_SELECTED)) { ED_region_tag_redraw(ar); + } 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_SCENE: switch (wmn->data) { @@ -893,8 +917,9 @@ static void image_tools_region_listener( } break; case NC_IMAGE: - if (wmn->action != NA_PAINTING) + if (wmn->action != NA_PAINTING) { ED_region_tag_redraw(ar); + } break; case NC_NODE: ED_region_tag_redraw(ar); diff --git a/source/blender/editors/space_info/info_ops.c b/source/blender/editors/space_info/info_ops.c index 538c41f730a..4f7e0f70ad9 100644 --- a/source/blender/editors/space_info/info_ops.c +++ b/source/blender/editors/space_info/info_ops.c @@ -219,7 +219,9 @@ static int unpack_all_exec(bContext *C, wmOperator *op) Main *bmain = CTX_data_main(C); int method = RNA_enum_get(op->ptr, "method"); - if (method != PF_KEEP) unpackAll(bmain, op->reports, method); /* XXX PF_ASK can't work here */ + if (method != PF_KEEP) { + unpackAll(bmain, op->reports, method); /* XXX PF_ASK can't work here */ + } G.fileflags &= ~G_FILE_AUTOPACK; return OPERATOR_FINISHED; @@ -241,10 +243,12 @@ static int unpack_all_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED( return OPERATOR_CANCELLED; } - if (count == 1) + if (count == 1) { BLI_strncpy(title, IFACE_("Unpack 1 File"), sizeof(title)); - else + } + else { BLI_snprintf(title, sizeof(title), IFACE_("Unpack %d Files"), count); + } pup = UI_popup_menu_begin(C, title, ICON_NONE); layout = UI_popup_menu_layout(pup); @@ -303,8 +307,9 @@ static int unpack_item_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } - if (method != PF_KEEP) + if (method != PF_KEEP) { BKE_unpack_id(bmain, id, op->reports, method); /* XXX PF_ASK can't work here */ + } G.fileflags &= ~G_FILE_AUTOPACK; diff --git a/source/blender/editors/space_info/info_report.c b/source/blender/editors/space_info/info_report.c index 73c36f64cb5..a8f5d9b9b76 100644 --- a/source/blender/editors/space_info/info_report.c +++ b/source/blender/editors/space_info/info_report.c @@ -111,8 +111,9 @@ static int select_report_pick_exec(bContext *C, wmOperator *op) int report_index = RNA_int_get(op->ptr, "report_index"); Report *report = BLI_findlink(&CTX_wm_reports(C)->list, report_index); - if (!report) + if (!report) { return OPERATOR_CANCELLED; + } report->flag ^= SELECT; /* toggle */ diff --git a/source/blender/editors/space_info/info_stats.c b/source/blender/editors/space_info/info_stats.c index fdcc915737d..054e9cd0026 100644 --- a/source/blender/editors/space_info/info_stats.c +++ b/source/blender/editors/space_info/info_stats.c @@ -128,7 +128,9 @@ static void stats_object(Object *ob, SceneStats *stats) const bool is_selected = (ob->base_flag & BASE_SELECTED) != 0; stats->totobj++; - if (is_selected) stats->totobjsel++; + if (is_selected) { + stats->totobjsel++; + } switch (ob->type) { case OB_MESH: @@ -158,8 +160,9 @@ static void stats_object(Object *ob, SceneStats *stats) { int totv = 0, totf = 0, tottri = 0; - if (ob->runtime.curve_cache && ob->runtime.curve_cache->disp.first) + if (ob->runtime.curve_cache && ob->runtime.curve_cache->disp.first) { BKE_displist_count(&ob->runtime.curve_cache->disp, &totv, &totf, &tottri); + } stats->totvert += totv; stats->totface += totf; @@ -214,15 +217,20 @@ static void stats_object_edit(Object *obedit, SceneStats *stats) for (ebo = arm->edbo->first; ebo; ebo = ebo->next) { stats->totbone++; - if ((ebo->flag & BONE_CONNECTED) && ebo->parent) + if ((ebo->flag & BONE_CONNECTED) && ebo->parent) { stats->totvert--; + } - if (ebo->flag & BONE_TIPSEL) + if (ebo->flag & BONE_TIPSEL) { stats->totvertsel++; - if (ebo->flag & BONE_ROOTSEL) + } + if (ebo->flag & BONE_ROOTSEL) { stats->totvertsel++; + } - if (ebo->flag & BONE_SELECTED) stats->totbonesel++; + if (ebo->flag & BONE_SELECTED) { + stats->totbonesel++; + } /* if this is a connected child and it's parent is being moved, remove our root */ if ((ebo->flag & BONE_CONNECTED) && (ebo->flag & BONE_ROOTSEL) && @@ -249,9 +257,15 @@ static void stats_object_edit(Object *obedit, SceneStats *stats) a = nu->pntsu; while (a--) { stats->totvert += 3; - if (bezt->f1 & SELECT) stats->totvertsel++; - if (bezt->f2 & SELECT) stats->totvertsel++; - if (bezt->f3 & SELECT) stats->totvertsel++; + if (bezt->f1 & SELECT) { + stats->totvertsel++; + } + if (bezt->f2 & SELECT) { + stats->totvertsel++; + } + if (bezt->f3 & SELECT) { + stats->totvertsel++; + } bezt++; } } @@ -260,7 +274,9 @@ static void stats_object_edit(Object *obedit, SceneStats *stats) a = nu->pntsu * nu->pntsv; while (a--) { stats->totvert++; - if (bp->f1 & SELECT) stats->totvertsel++; + if (bp->f1 & SELECT) { + stats->totvertsel++; + } bp++; } } @@ -273,7 +289,9 @@ static void stats_object_edit(Object *obedit, SceneStats *stats) for (ml = mball->editelems->first; ml; ml = ml->next) { stats->totvert++; - if (ml->flag & SELECT) stats->totvertsel++; + if (ml->flag & SELECT) { + stats->totvertsel++; + } } } else if (obedit->type == OB_LATTICE) { @@ -288,7 +306,9 @@ static void stats_object_edit(Object *obedit, SceneStats *stats) a = editlatt->pntsu * editlatt->pntsv * editlatt->pntsw; while (a--) { stats->totvert++; - if (bp->f1 & SELECT) stats->totvertsel++; + if (bp->f1 & SELECT) { + stats->totvertsel++; + } bp++; } } @@ -302,9 +322,11 @@ static void stats_object_pose(Object *ob, SceneStats *stats) for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) { stats->totbone++; - if (pchan->bone && (pchan->bone->flag & BONE_SELECTED)) - if (pchan->bone->layer & arm->layer) + if (pchan->bone && (pchan->bone->flag & BONE_SELECTED)) { + if (pchan->bone->layer & arm->layer) { stats->totbonesel++; + } + } } } } @@ -448,8 +470,9 @@ static void stats_string(ViewLayer *view_layer) } if (obedit) { - if (BKE_keyblock_from_object(obedit)) + if (BKE_keyblock_from_object(obedit)) { ofs += BLI_strncpy_rlen(s + ofs, IFACE_("(Key) "), MAX_INFO_LEN - ofs); + } if (obedit->type == OB_MESH) { ofs += BLI_snprintf(s + ofs, MAX_INFO_LEN - ofs, diff --git a/source/blender/editors/space_info/space_info.c b/source/blender/editors/space_info/space_info.c index 754941a12c0..997a40839ac 100644 --- a/source/blender/editors/space_info/space_info.c +++ b/source/blender/editors/space_info/space_info.c @@ -151,8 +151,9 @@ static void info_main_region_draw(const bContext *C, ARegion *ar) GPU_clear(GPU_COLOR_BIT); /* quick way to avoid drawing if not bug enough */ - if (ar->winy < 16) + if (ar->winy < 16) { return; + } info_textview_update_rect(C, ar); @@ -241,20 +242,24 @@ static void info_header_listener( } break; case NC_WM: - if (wmn->data == ND_JOB) + if (wmn->data == ND_JOB) { ED_region_tag_redraw(ar); + } break; case NC_SCENE: - if (wmn->data == ND_RENDER_RESULT) + if (wmn->data == ND_RENDER_RESULT) { ED_region_tag_redraw(ar); + } break; case NC_SPACE: - if (wmn->data == ND_SPACE_INFO) + if (wmn->data == ND_SPACE_INFO) { 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; } diff --git a/source/blender/editors/space_info/textview.c b/source/blender/editors/space_info/textview.c index a335d6d0bfb..7585cda5e19 100644 --- a/source/blender/editors/space_info/textview.c +++ b/source/blender/editors/space_info/textview.c @@ -291,11 +291,13 @@ int textview_draw(TextViewContext *tvc, const int draw, int mval[2], void **mous xy[0] = x_orig; xy[1] = y_orig; - if (mval[1] != INT_MAX) + if (mval[1] != INT_MAX) { mval[1] += (tvc->ymin + CONSOLE_DRAW_MARGIN); + } - if (pos_pick) + if (pos_pick) { *pos_pick = 0; + } /* constants for the sequencer context */ cdc.font_id = font_id; @@ -306,8 +308,9 @@ int textview_draw(TextViewContext *tvc, const int draw, int mval[2], void **mous /* note, scroll bar must be already subtracted () */ cdc.console_width = (tvc->winx - (CONSOLE_DRAW_MARGIN * 2)) / cdc.cwidth; /* avoid divide by zero on small windows */ - if (cdc.console_width < 1) + if (cdc.console_width < 1) { cdc.console_width = 1; + } cdc.winx = tvc->winx - CONSOLE_DRAW_MARGIN; cdc.ymin = tvc->ymin; cdc.ymax = tvc->ymax; @@ -341,8 +344,9 @@ int textview_draw(TextViewContext *tvc, const int draw, int mval[2], void **mous y_prev = xy[1]; - if (draw) + if (draw) { color_flag = tvc->line_color(tvc, fg, bg); + } tvc->line_get(tvc, &ext_line, &ext_len); diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c index 60dcdaebb08..be26f67b936 100644 --- a/source/blender/editors/space_node/drawnode.c +++ b/source/blender/editors/space_node/drawnode.c @@ -115,8 +115,9 @@ static void node_buts_mix_rgb(uiLayout *layout, bContext *UNUSED(C), PointerRNA col = uiLayoutColumn(layout, false); row = uiLayoutRow(col, true); uiItemR(row, ptr, "blend_type", 0, "", ICON_NONE); - if (ELEM(ntree->type, NTREE_COMPOSIT, NTREE_TEXTURE)) + if (ELEM(ntree->type, NTREE_COMPOSIT, NTREE_TEXTURE)) { uiItemR(row, ptr, "use_alpha", 0, "", ICON_IMAGE_RGB_ALPHA); + } uiItemR(col, ptr, "use_clamp", 0, NULL, ICON_NONE); } @@ -257,20 +258,24 @@ static int node_resize_area_default(bNode *node, int x, int y) rctf totr = node->totr; /* right part of node */ totr.xmin = node->totr.xmax - 20.0f; - if (BLI_rctf_isect_pt(&totr, x, y)) + if (BLI_rctf_isect_pt(&totr, x, y)) { return NODE_RESIZE_RIGHT; - else + } + else { return 0; + } } else { const float size = NODE_RESIZE_MARGIN; rctf totr = node->totr; int dir = 0; - if (x >= totr.xmax - size && x < totr.xmax && y >= totr.ymin && y < totr.ymax) + if (x >= totr.xmax - size && x < totr.xmax && y >= totr.ymin && y < totr.ymax) { dir |= NODE_RESIZE_RIGHT; - if (x >= totr.xmin && x < totr.xmin + size && y >= totr.ymin && y < totr.ymax) + } + if (x >= totr.xmin && x < totr.xmin + size && y >= totr.ymin && y < totr.ymax) { dir |= NODE_RESIZE_LEFT; + } return dir; } } @@ -306,8 +311,9 @@ static void node_draw_frame_prepare(const bContext *UNUSED(C), bNodeTree *ntree, bbinit = (data->flag & NODE_FRAME_SHRINK); /* fit bounding box to all children */ for (tnode = ntree->nodes.first; tnode; tnode = tnode->next) { - if (tnode->parent != node) + if (tnode->parent != node) { continue; + } /* add margin to node rect */ noderect = tnode->totr; @@ -322,8 +328,9 @@ static void node_draw_frame_prepare(const bContext *UNUSED(C), bNodeTree *ntree, rect = noderect; data->flag &= ~NODE_FRAME_RESIZEABLE; } - else + else { BLI_rctf_union(&rect, &noderect); + } } /* now adjust the frame size from view-space bounding box */ @@ -445,18 +452,21 @@ static void node_draw_frame(const bContext *C, ARegion *ar, SpaceNode *snode, if (node->flag & NODE_CUSTOM_COLOR) { rgba_float_args_set(color, node->color[0], node->color[1], node->color[2], alpha); } - else + else { UI_GetThemeColor4fv(TH_NODE_FRAME, color); + } UI_draw_roundbox_corner_set(UI_CNR_ALL); UI_draw_roundbox_aa(true, rct->xmin, rct->ymin, rct->xmax, rct->ymax, BASIS_RAD, color); /* outline active and selected emphasis */ if (node->flag & SELECT) { - if (node->flag & NODE_ACTIVE) + if (node->flag & NODE_ACTIVE) { UI_GetThemeColorShadeAlpha4fv(TH_ACTIVE, 0, -40, color); - else + } + else { UI_GetThemeColorShadeAlpha4fv(TH_SELECT, 0, -40, color); + } UI_draw_roundbox_aa(false, rct->xmin, rct->ymin, rct->xmax, rct->ymax, BASIS_RAD, color); } @@ -479,17 +489,22 @@ static int node_resize_area_frame(bNode *node, int x, int y) int dir = 0; /* shrinking frame size is determined by child nodes */ - if (!(data->flag & NODE_FRAME_RESIZEABLE)) + if (!(data->flag & NODE_FRAME_RESIZEABLE)) { return 0; + } - if (x >= totr.xmax - size && x < totr.xmax && y >= totr.ymin && y < totr.ymax) + if (x >= totr.xmax - size && x < totr.xmax && y >= totr.ymin && y < totr.ymax) { dir |= NODE_RESIZE_RIGHT; - if (x >= totr.xmin && x < totr.xmin + size && y >= totr.ymin && y < totr.ymax) + } + if (x >= totr.xmin && x < totr.xmin + size && y >= totr.ymin && y < totr.ymax) { dir |= NODE_RESIZE_LEFT; - if (x >= totr.xmin && x < totr.xmax && y >= totr.ymax - size && y < totr.ymax) + } + if (x >= totr.xmin && x < totr.xmax && y >= totr.ymax - size && y < totr.ymax) { dir |= NODE_RESIZE_TOP; - if (x >= totr.xmin && x < totr.xmax && y >= totr.ymin && y < totr.ymin + size) + } + if (x >= totr.xmin && x < totr.xmax && y >= totr.ymin && y < totr.ymin + size) { dir |= NODE_RESIZE_BOTTOM; + } return dir; } @@ -636,8 +651,9 @@ static void node_buts_image_user(uiLayout *layout, bContext *C, PointerRNA *ptr, uiLayout *col; int source; - if (!imaptr->data) + if (!imaptr->data) { return; + } col = uiLayoutColumn(layout, false); @@ -790,8 +806,9 @@ static void node_shader_buts_tex_environment_ex(uiLayout *layout, bContext *C, P layout, C, ptr, "image", "IMAGE_OT_new", "IMAGE_OT_open", NULL, UI_TEMPLATE_ID_FILTER_ALL, false); - if (!ima) + if (!ima) { return; + } uiItemR(layout, &imaptr, "source", 0, IFACE_("Source"), ICON_NONE); @@ -799,10 +816,12 @@ static void node_shader_buts_tex_environment_ex(uiLayout *layout, bContext *C, P uiLayout *row = uiLayoutRow(layout, true); const bool is_packed = BKE_image_has_packedfile(ima); - if (is_packed) + if (is_packed) { uiItemO(row, "", ICON_PACKAGE, "image.unpack"); - else + } + else { uiItemO(row, "", ICON_UGLYPACKAGE, "image.pack"); + } row = uiLayoutRow(row, true); uiLayoutSetEnabled(row, !is_packed); @@ -829,8 +848,9 @@ static void node_shader_buts_tex_sky(uiLayout *layout, bContext *UNUSED(C), Poin uiItemR(layout, ptr, "sun_direction", 0, "", ICON_NONE); uiItemR(layout, ptr, "turbidity", 0, NULL, ICON_NONE); - if (RNA_enum_get(ptr, "sky_type") == SHD_SKY_NEW) + if (RNA_enum_get(ptr, "sky_type") == SHD_SKY_NEW) { uiItemR(layout, ptr, "ground_albedo", 0, NULL, ICON_NONE); + } } static void node_shader_buts_tex_gradient(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) @@ -903,12 +923,14 @@ static void node_shader_buts_tex_pointdensity(uiLayout *layout, bContext *UNUSED else { uiItemR(layout, ptr, "vertex_color_source", 0, NULL, ICON_NONE); if (shader_point_density->ob_color_source == SHD_POINTDENSITY_COLOR_VERTWEIGHT) { - if (ob_ptr.data) + if (ob_ptr.data) { uiItemPointerR(layout, ptr, "vertex_attribute_name", &ob_ptr, "vertex_groups", "", ICON_NONE); + } } if (shader_point_density->ob_color_source == SHD_POINTDENSITY_COLOR_VERTCOL) { - if (obdata_ptr.data) + if (obdata_ptr.data) { uiItemPointerR(layout, ptr, "vertex_attribute_name", &obdata_ptr, "vertex_colors", "", ICON_NONE); + } } } } @@ -954,8 +976,9 @@ static void node_shader_buts_normal_map(uiLayout *layout, bContext *C, PointerRN PointerRNA dataptr = RNA_pointer_get(&obptr, "data"); uiItemPointerR(layout, ptr, "uv_map", &dataptr, "uv_layers", "", ICON_NONE); } - else + else { uiItemR(layout, ptr, "uv_map", 0, "", 0); + } } } @@ -981,11 +1004,13 @@ static void node_shader_buts_tangent(uiLayout *layout, bContext *C, PointerRNA * PointerRNA dataptr = RNA_pointer_get(&obptr, "data"); uiItemPointerR(row, ptr, "uv_map", &dataptr, "uv_layers", "", ICON_NONE); } - else + else { uiItemR(row, ptr, "uv_map", 0, "", 0); + } } - else + else { uiItemR(row, ptr, "axis", UI_ITEM_R_EXPAND, NULL, 0); + } } static void node_shader_buts_glossy(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) @@ -1034,10 +1059,12 @@ static void node_shader_buts_ies(uiLayout *layout, bContext *UNUSED(C), PointerR row = uiLayoutRow(layout, true); - if (RNA_enum_get(ptr, "mode") == NODE_IES_INTERNAL) + if (RNA_enum_get(ptr, "mode") == NODE_IES_INTERNAL) { uiItemR(row, ptr, "ies", 0, "", ICON_NONE); - else + } + else { uiItemR(row, ptr, "filepath", 0, "", ICON_NONE); + } } static void node_shader_buts_script(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) @@ -1049,10 +1076,12 @@ static void node_shader_buts_script(uiLayout *layout, bContext *UNUSED(C), Point row = uiLayoutRow(layout, true); - if (RNA_enum_get(ptr, "mode") == NODE_SCRIPT_INTERNAL) + if (RNA_enum_get(ptr, "mode") == NODE_SCRIPT_INTERNAL) { uiItemR(row, ptr, "script", 0, "", ICON_NONE); - else + } + else { uiItemR(row, ptr, "filepath", 0, "", ICON_NONE); + } uiItemO(row, "", ICON_FILE_REFRESH, "node.shader_script_update"); } @@ -1247,16 +1276,19 @@ static void node_buts_image_views(uiLayout *layout, bContext *UNUSED(C), Pointer { uiLayout *col; - if (!imaptr->data) + if (!imaptr->data) { return; + } col = uiLayoutColumn(layout, false); if (RNA_boolean_get(ptr, "has_views")) { - if (RNA_enum_get(ptr, "view") == 0) + if (RNA_enum_get(ptr, "view") == 0) { uiItemR(col, ptr, "view", 0, NULL, ICON_CAMERA_STEREO); - else + } + else { uiItemR(col, ptr, "view", 0, NULL, ICON_SCENE); + } } } @@ -1270,7 +1302,9 @@ static void node_composit_buts_image(uiLayout *layout, bContext *C, PointerRNA * uiTemplateID( layout, C, ptr, "image", "IMAGE_OT_new", "IMAGE_OT_open", NULL, UI_TEMPLATE_ID_FILTER_ALL, false); - if (!node->id) return; + if (!node->id) { + return; + } imaptr = RNA_pointer_get(ptr, "image"); @@ -1301,15 +1335,18 @@ static void node_composit_buts_viewlayers(uiLayout *layout, bContext *C, Pointer uiTemplateID(layout, C, ptr, "scene", NULL, NULL, NULL, UI_TEMPLATE_ID_FILTER_ALL, false); - if (!node->id) return; + if (!node->id) { + return; + } col = uiLayoutColumn(layout, false); row = uiLayoutRow(col, true); uiItemR(row, ptr, "layer", 0, "", ICON_NONE); prop = RNA_struct_find_property(ptr, "layer"); - if (!(RNA_property_enum_identifier(C, ptr, prop, RNA_property_enum_get(ptr, prop), &layer_name))) + if (!(RNA_property_enum_identifier(C, ptr, prop, RNA_property_enum_get(ptr, prop), &layer_name))) { return; + } scn_ptr = RNA_pointer_get(ptr, "scene"); RNA_string_get(&scn_ptr, "name", scene_name); @@ -1431,8 +1468,9 @@ static void node_composit_buts_glare(uiLayout *layout, bContext *UNUSED(C), Poin if (RNA_enum_get(ptr, "glare_type") != 1) { uiItemR(layout, ptr, "iterations", 0, NULL, ICON_NONE); - if (RNA_enum_get(ptr, "glare_type") != 0) + if (RNA_enum_get(ptr, "glare_type") != 0) { uiItemR(layout, ptr, "color_modulation", UI_ITEM_R_SLIDER, NULL, ICON_NONE); + } } uiItemR(layout, ptr, "mix", 0, NULL, ICON_NONE); @@ -1445,8 +1483,9 @@ static void node_composit_buts_glare(uiLayout *layout, bContext *UNUSED(C), Poin if (RNA_enum_get(ptr, "glare_type") == 0 || RNA_enum_get(ptr, "glare_type") == 2) { uiItemR(layout, ptr, "fade", UI_ITEM_R_SLIDER, NULL, ICON_NONE); - if (RNA_enum_get(ptr, "glare_type") == 0) + if (RNA_enum_get(ptr, "glare_type") == 0) { uiItemR(layout, ptr, "use_rotate_45", 0, NULL, ICON_NONE); + } } if (RNA_enum_get(ptr, "glare_type") == 1) { uiItemR(layout, ptr, "size", 0, NULL, ICON_NONE); @@ -1754,10 +1793,12 @@ static void node_composit_buts_file_output(uiLayout *layout, bContext *UNUSED(C) PointerRNA imfptr = RNA_pointer_get(ptr, "format"); const bool multilayer = RNA_enum_get(&imfptr, "file_format") == R_IMF_IMTYPE_MULTILAYER; - if (multilayer) + if (multilayer) { uiItemL(layout, IFACE_("Path:"), ICON_NONE); - else + } + else { uiItemL(layout, IFACE_("Base Path:"), ICON_NONE); + } uiItemR(layout, ptr, "base_path", 0, "", ICON_NONE); } static void node_composit_buts_file_output_ex(uiLayout *layout, bContext *C, PointerRNA *ptr) @@ -1776,8 +1817,9 @@ static void node_composit_buts_file_output_ex(uiLayout *layout, bContext *C, Poi /* disable stereo output for multilayer, too much work for something that no one will use */ /* if someone asks for that we can implement it */ - if (is_multiview) + if (is_multiview) { uiTemplateImageFormatViews(layout, &imfptr, NULL); + } uiItemS(layout); @@ -1841,8 +1883,9 @@ static void node_composit_buts_file_output_ex(uiLayout *layout, bContext *C, Poi uiLayoutSetActive(col, RNA_boolean_get(&active_input_ptr, "use_node_format") == false); uiTemplateImageSettings(col, &imfptr, false); - if (is_multiview) + if (is_multiview) { uiTemplateImageFormatViews(layout, &imfptr, NULL); + } } } } @@ -1991,8 +2034,9 @@ static void node_composit_buts_movieclip_ex(uiLayout *layout, bContext *C, Point uiTemplateID(layout, C, ptr, "clip", NULL, "CLIP_OT_open", NULL, UI_TEMPLATE_ID_FILTER_ALL, false); - if (!node->id) + if (!node->id) { return; + } clipptr = RNA_pointer_get(ptr, "clip"); @@ -2005,8 +2049,9 @@ static void node_composit_buts_stabilize2d(uiLayout *layout, bContext *C, Pointe uiTemplateID(layout, C, ptr, "clip", NULL, "CLIP_OT_open", NULL, UI_TEMPLATE_ID_FILTER_ALL, false); - if (!node->id) + if (!node->id) { return; + } uiItemR(layout, ptr, "filter_type", 0, "", ICON_NONE); uiItemR(layout, ptr, "invert", 0, NULL, ICON_NONE); @@ -2029,8 +2074,9 @@ static void node_composit_buts_moviedistortion(uiLayout *layout, bContext *C, Po uiTemplateID(layout, C, ptr, "clip", NULL, "CLIP_OT_open", NULL, UI_TEMPLATE_ID_FILTER_ALL, false); - if (!node->id) + if (!node->id) { return; + } uiItemR(layout, ptr, "distortion_type", 0, "", ICON_NONE); } @@ -2913,8 +2959,9 @@ static void node_socket_template_properties_update(bNodeType *ntype, bNodeSocket StructRNA *srna = ntype->ext.srna; PropertyRNA *prop = RNA_struct_type_find_property(srna, stemp->identifier); - if (prop) + if (prop) { RNA_def_property_update_runtime(prop, node_property_update_default); + } } static void node_template_properties_update(bNodeType *ntype) @@ -2922,12 +2969,14 @@ static void node_template_properties_update(bNodeType *ntype) bNodeSocketTemplate *stemp; if (ntype->inputs) { - for (stemp = ntype->inputs; stemp->type >= 0; ++stemp) + for (stemp = ntype->inputs; stemp->type >= 0; ++stemp) { node_socket_template_properties_update(ntype, stemp); + } } if (ntype->outputs) { - for (stemp = ntype->outputs; stemp->type >= 0; ++stemp) + for (stemp = ntype->outputs; stemp->type >= 0; ++stemp) { node_socket_template_properties_update(ntype, stemp); + } } } @@ -3077,8 +3126,9 @@ static void node_file_output_socket_draw(bContext *C, uiLayout *layout, PointerR uiItemL(row, input->path, ICON_NONE); - if (!RNA_boolean_get(&inputptr, "use_node_format")) + if (!RNA_boolean_get(&inputptr, "use_node_format")) { imfptr = RNA_pointer_get(&inputptr, "format"); + } imtype_prop = RNA_struct_find_property(&imfptr, "file_format"); RNA_property_enum_name((bContext *)C, &imfptr, imtype_prop, @@ -3206,11 +3256,13 @@ void draw_nodespace_back_pix(const bContext *C, ARegion *ar, SpaceNode *snode, b void *lock; ImBuf *ibuf; - if (!(snode->flag & SNODE_BACKDRAW) || !ED_node_is_compositor(snode)) + if (!(snode->flag & SNODE_BACKDRAW) || !ED_node_is_compositor(snode)) { return; + } - if (parent_key.value != active_viewer_key.value) + if (parent_key.value != active_viewer_key.value) { return; + } ima = BKE_image_verify_viewer(bmain, IMA_TYPE_COMPOSITE, "Viewer Node"); ibuf = BKE_image_acquire_ibuf(ima, NULL, &lock); @@ -3234,14 +3286,18 @@ void draw_nodespace_back_pix(const bContext *C, ARegion *ar, SpaceNode *snode, b display_buffer = IMB_display_buffer_acquire_ctx(C, ibuf, &cache_handle); - if (snode->flag & SNODE_SHOW_R) + if (snode->flag & SNODE_SHOW_R) { shuffle[0] = 1.0f; - else if (snode->flag & SNODE_SHOW_G) + } + else if (snode->flag & SNODE_SHOW_G) { shuffle[1] = 1.0f; - else if (snode->flag & SNODE_SHOW_B) + } + else if (snode->flag & SNODE_SHOW_B) { shuffle[2] = 1.0f; - else + } + else { shuffle[3] = 1.0f; + } IMMDrawPixelsTexState state = immDrawPixelsTexSetup(GPU_SHADER_2D_IMAGE_SHUFFLE_COLOR); GPU_shader_uniform_vector(state.shader, GPU_shader_get_uniform_ensure(state.shader, "shuffle"), 4, 1, shuffle); @@ -3263,8 +3319,9 @@ void draw_nodespace_back_pix(const bContext *C, ARegion *ar, SpaceNode *snode, b glaDrawImBuf_glsl_ctx(C, ibuf, x, y, GL_NEAREST, snode->zoom, snode->zoom); } - if (cache_handle) + if (cache_handle) { IMB_display_buffer_release(cache_handle); + } } /** \note draw selected info on backdrop */ @@ -3330,7 +3387,9 @@ static bool node_link_bezier_handles(View2D *v2d, SpaceNode *snode, bNodeLink *l fromreroute = (link->fromnode && link->fromnode->type == NODE_REROUTE); } else { - if (snode == NULL) return 0; + if (snode == NULL) { + return 0; + } copy_v2_v2(vec[0], cursor); fromreroute = 0; } @@ -3340,7 +3399,9 @@ static bool node_link_bezier_handles(View2D *v2d, SpaceNode *snode, bNodeLink *l toreroute = (link->tonode && link->tonode->type == NODE_REROUTE); } else { - if (snode == NULL) return 0; + if (snode == NULL) { + return 0; + } copy_v2_v2(vec[3], cursor); toreroute = 0; } @@ -3477,8 +3538,9 @@ static void nodelink_batch_init(void) float exp[2] = {0.0f, 1.0f}; /* restart */ - if (k == 1) + if (k == 1) { set_nodelink_vertex(vbo, uv_id, pos_id, expand_id, v++, uv, pos, exp); + } /* curve strip */ for (int i = 0; i < LINK_RESOL; ++i) { @@ -3508,8 +3570,9 @@ static void nodelink_batch_init(void) } /* restart */ - if (k == 0) + if (k == 0) { set_nodelink_vertex(vbo, uv_id, pos_id, expand_id, v++, uv, pos, exp); + } } g_batch_link.batch = GPU_batch_create_ex(GPU_PRIM_TRI_STRIP, vbo, NULL, GPU_BATCH_OWNS_VBO); @@ -3548,8 +3611,9 @@ static char nodelink_get_color_id(int th_col) static void nodelink_batch_draw(SpaceNode *snode) { - if (g_batch_link.count == 0) + if (g_batch_link.count == 0) { return; + } GPU_blend(true); @@ -3655,8 +3719,9 @@ void node_draw_link(View2D *v2d, SpaceNode *snode, bNodeLink *link) { int th_col1 = TH_WIRE_INNER, th_col2 = TH_WIRE_INNER, th_col3 = TH_WIRE; - if (link->fromsock == NULL && link->tosock == NULL) + if (link->fromsock == NULL && link->tosock == NULL) { return; + } /* new connection */ if (!link->fromsock || !link->tosock) { @@ -3664,10 +3729,12 @@ void node_draw_link(View2D *v2d, SpaceNode *snode, bNodeLink *link) } else { /* going to give issues once... */ - if (link->tosock->flag & SOCK_UNAVAIL) + if (link->tosock->flag & SOCK_UNAVAIL) { return; - if (link->fromsock->flag & SOCK_UNAVAIL) + } + if (link->fromsock->flag & SOCK_UNAVAIL) { return; + } if (link->flag & NODE_LINK_VALID) { /* special indicated link, on drop-node */ @@ -3676,10 +3743,12 @@ void node_draw_link(View2D *v2d, SpaceNode *snode, bNodeLink *link) } else { /* regular link */ - if (link->fromnode && link->fromnode->flag & SELECT) + if (link->fromnode && link->fromnode->flag & SELECT) { th_col1 = TH_EDGE_SELECT; - if (link->tonode && link->tonode->flag & SELECT) + } + if (link->tonode && link->tonode->flag & SELECT) { th_col2 = TH_EDGE_SELECT; + } } } else { diff --git a/source/blender/editors/space_node/node_add.c b/source/blender/editors/space_node/node_add.c index 6cb45f8d318..814496cf59e 100644 --- a/source/blender/editors/space_node/node_add.c +++ b/source/blender/editors/space_node/node_add.c @@ -65,10 +65,12 @@ bNode *node_add_node(const bContext *C, const char *idname, int type, float locx node_deselect_all(snode); - if (idname) + if (idname) { node = nodeAddNode(C, snode->edittree, idname); - else + } + else { node = nodeAddStaticNode(C, snode->edittree, type); + } BLI_assert(node && node->typeinfo); /* Position mouse in node header. */ @@ -128,8 +130,9 @@ static bNodeSocketLink *add_reroute_insert_socket_link(ListBase *lb, bNodeSocket copy_v2_v2(socklink->point, point); for (prev = lb->last; prev; prev = prev->prev) { - if (prev->sock == sock) + if (prev->sock == sock) { break; + } } BLI_insertlinkafter(lb, prev, socklink); return socklink; @@ -208,7 +211,9 @@ static int add_reroute_exec(bContext *C, wmOperator *op) UI_view2d_region_to_view(&ar->v2d, (short)loc[0], (short)loc[1], &mcoords[i][0], &mcoords[i][1]); i++; - if (i >= 256) break; + if (i >= 256) { + break; + } } RNA_END; @@ -228,8 +233,9 @@ static int add_reroute_exec(bContext *C, wmOperator *op) BLI_listbase_clear(&input_links); for (link = ntree->links.first; link; link = link->next) { - if (nodeLinkIsHidden(link)) + if (nodeLinkIsHidden(link)) { continue; + } if (add_reroute_intersect_check(link, mcoords, i, insert_point)) { add_reroute_insert_socket_link(&output_links, link->fromsock, link, insert_point); add_reroute_insert_socket_link(&input_links, link->tosock, link, insert_point); @@ -356,10 +362,12 @@ static int node_add_file_invoke(bContext *C, wmOperator *op, const wmEvent *even snode->cursor[0] /= UI_DPI_FAC; snode->cursor[1] /= UI_DPI_FAC; - if (RNA_struct_property_is_set(op->ptr, "filepath") || RNA_struct_property_is_set(op->ptr, "name")) + if (RNA_struct_property_is_set(op->ptr, "filepath") || RNA_struct_property_is_set(op->ptr, "name")) { return node_add_file_exec(C, op); - else + } + else { return WM_operator_filesel(C, op, event); + } } void NODE_OT_add_file(wmOperatorType *ot) @@ -460,10 +468,12 @@ static int new_node_tree_exec(bContext *C, wmOperator *op) prop = RNA_struct_find_property(op->ptr, "type"); RNA_property_enum_identifier(C, op->ptr, prop, RNA_property_enum_get(op->ptr, prop), &idname); } - else if (snode) + else if (snode) { idname = snode->tree_idname; - else + } + else { return OPERATOR_CANCELLED; + } if (RNA_struct_property_is_set(op->ptr, "name")) { RNA_string_get(op->ptr, "name", treename_buf); diff --git a/source/blender/editors/space_node/node_buttons.c b/source/blender/editors/space_node/node_buttons.c index da0be280f2c..13f8eb0729e 100644 --- a/source/blender/editors/space_node/node_buttons.c +++ b/source/blender/editors/space_node/node_buttons.c @@ -76,8 +76,9 @@ static void node_sockets_panel(const bContext *C, Panel *pa) uiLayout *layout = pa->layout, *split; char name[UI_MAX_NAME_STR]; - if (ELEM(NULL, ntree, node)) + if (ELEM(NULL, ntree, node)) { return; + } for (sock = node->inputs.first; sock; sock = sock->next) { BLI_snprintf(name, sizeof(name), "%s:", sock->name); @@ -128,8 +129,9 @@ static void node_tree_interface_panel(const bContext *C, Panel *pa) PointerRNA ptr, sockptr, opptr; wmOperatorType *ot; - if (!ntree) + if (!ntree) { return; + } RNA_id_pointer_create((ID *)ntree, &ptr); @@ -204,8 +206,9 @@ static int node_properties_toggle_exec(bContext *C, wmOperator *UNUSED(op)) ScrArea *sa = CTX_wm_area(C); ARegion *ar = node_has_buttons_region(sa); - if (ar) + if (ar) { ED_region_toggle_hidden(C, ar); + } return OPERATOR_FINISHED; } diff --git a/source/blender/editors/space_node/node_draw.c b/source/blender/editors/space_node/node_draw.c index afef027f7e1..2d25c067d69 100644 --- a/source/blender/editors/space_node/node_draw.c +++ b/source/blender/editors/space_node/node_draw.c @@ -120,8 +120,9 @@ static bNodeTree *node_tree_from_ID(ID *id) void ED_node_tag_update_id(ID *id) { bNodeTree *ntree = node_tree_from_ID(id); - if (id == NULL || ntree == NULL) + if (id == NULL || ntree == NULL) { return; + } /* TODO(sergey): With the new dependency graph it * should be just enough to only tag ntree itself, @@ -133,12 +134,15 @@ void ED_node_tag_update_id(ID *id) if (ntree->type == NTREE_SHADER) { DEG_id_tag_update(id, 0); - if (GS(id->name) == ID_MA) + if (GS(id->name) == ID_MA) { WM_main_add_notifier(NC_MATERIAL | ND_SHADING, id); - else if (GS(id->name) == ID_LA) + } + else if (GS(id->name) == ID_LA) { WM_main_add_notifier(NC_LAMP | ND_LIGHTING, id); - else if (GS(id->name) == ID_WO) + } + else if (GS(id->name) == ID_WO) { WM_main_add_notifier(NC_WORLD | ND_WORLD, id); + } } else if (ntree->type == NTREE_COMPOSIT) { WM_main_add_notifier(NC_SCENE | ND_NODES, id); @@ -155,8 +159,9 @@ void ED_node_tag_update_id(ID *id) void ED_node_tag_update_nodetree(Main *bmain, bNodeTree *ntree, bNode *node) { - if (!ntree) + if (!ntree) { return; + } bool do_tag_update = true; if (node != NULL) { @@ -169,13 +174,15 @@ void ED_node_tag_update_nodetree(Main *bmain, bNodeTree *ntree, bNode *node) if (do_tag_update) { FOREACH_NODETREE_BEGIN(bmain, tntree, id) { /* check if nodetree uses the group */ - if (ntreeHasTree(tntree, ntree)) + if (ntreeHasTree(tntree, ntree)) { ED_node_tag_update_id(id); + } } FOREACH_NODETREE_END; } - if (ntree->type == NTREE_TEXTURE) + if (ntree->type == NTREE_TEXTURE) { ntreeTexCheckCyclics(ntree); + } } static bool compare_nodes(const bNode *a, const bNode *b) @@ -192,36 +199,46 @@ static bool compare_nodes(const bNode *a, const bNode *b) * this is O(n^2) worst case */ for (parent = a->parent; parent; parent = parent->parent) { /* if b is an ancestor, it is always behind a */ - if (parent == b) + if (parent == b) { return 1; + } /* any selected ancestor moves the node forward */ - if (parent->flag & NODE_ACTIVE) + if (parent->flag & NODE_ACTIVE) { a_active = 1; - if (parent->flag & NODE_SELECT) + } + if (parent->flag & NODE_SELECT) { a_select = 1; + } } for (parent = b->parent; parent; parent = parent->parent) { /* if a is an ancestor, it is always behind b */ - if (parent == a) + if (parent == a) { return 0; + } /* any selected ancestor moves the node forward */ - if (parent->flag & NODE_ACTIVE) + if (parent->flag & NODE_ACTIVE) { b_active = 1; - if (parent->flag & NODE_SELECT) + } + if (parent->flag & NODE_SELECT) { b_select = 1; + } } /* if one of the nodes is in the background and the other not */ - if ((a->flag & NODE_BACKGROUND) && !(b->flag & NODE_BACKGROUND)) + if ((a->flag & NODE_BACKGROUND) && !(b->flag & NODE_BACKGROUND)) { return 0; - else if (!(a->flag & NODE_BACKGROUND) && (b->flag & NODE_BACKGROUND)) + } + else if (!(a->flag & NODE_BACKGROUND) && (b->flag & NODE_BACKGROUND)) { return 1; + } /* if one has a higher selection state (active > selected > nothing) */ - if (!b_active && a_active) + if (!b_active && a_active) { return 1; - else if (!b_select && (a_active || a_select)) + } + else if (!b_select && (a_active || a_select)) { return 1; + } return 0; } @@ -246,8 +263,9 @@ void ED_node_sort(bNodeTree *ntree) first_b = first_b->next; } /* all batches merged? */ - if (first_b == NULL) + if (first_b == NULL) { break; + } /* merge batches */ node_a = first_a; @@ -271,8 +289,9 @@ void ED_node_sort(bNodeTree *ntree) first_b = node_b; for (; b < k; ++b) { /* all nodes sorted? */ - if (first_b == NULL) + if (first_b == NULL) { break; + } first_b = first_b->next; } first_a = first_b; @@ -287,8 +306,9 @@ static void do_node_internal_buttons(bContext *C, void *UNUSED(node_v), int even { if (event == B_NODE_EXEC) { SpaceNode *snode = CTX_wm_space_node(C); - if (snode && snode->id) + if (snode && snode->id) { ED_node_tag_update_id(snode->id); + } } } @@ -351,15 +371,17 @@ static void node_update_basis(const bContext *C, bNodeTree *ntree, bNode *node) dy -= NODE_DY; /* little bit space in top */ - if (node->outputs.first) + if (node->outputs.first) { dy -= NODE_DYS / 2; + } /* output sockets */ bool add_output_space = false; for (nsock = node->outputs.first; nsock; nsock = nsock->next) { - if (nodeSocketIsHidden(nsock)) + if (nodeSocketIsHidden(nsock)) { continue; + } RNA_pointer_create(&ntree->id, &RNA_NodeSocket, nsock, &sockptr); @@ -387,8 +409,9 @@ static void node_update_basis(const bContext *C, bNodeTree *ntree, bNode *node) nsock->locy = 0.5f * (dy + buty); dy = buty; - if (nsock->next) + if (nsock->next) { dy -= NODE_SOCKDY; + } add_output_space = true; } @@ -404,14 +427,16 @@ static void node_update_basis(const bContext *C, bNodeTree *ntree, bNode *node) if (node->flag & NODE_PREVIEW) { float aspect = 1.0f; - if (node->preview_xsize && node->preview_ysize) + if (node->preview_xsize && node->preview_ysize) { aspect = (float)node->preview_ysize / (float)node->preview_xsize; + } dy -= NODE_DYS / 2; node->prvr.ymax = dy; - if (aspect <= 1.0f) + if (aspect <= 1.0f) { node->prvr.ymin = dy - aspect * (NODE_WIDTH(node) - NODE_DY); + } else { /* width correction of image */ /* XXX huh? (ton) */ @@ -426,8 +451,12 @@ static void node_update_basis(const bContext *C, bNodeTree *ntree, bNode *node) dy = node->prvr.ymin - NODE_DYS / 2; /* make sure that maximums are bigger or equal to minimums */ - if (node->prvr.xmax < node->prvr.xmin) SWAP(float, node->prvr.xmax, node->prvr.xmin); - if (node->prvr.ymax < node->prvr.ymin) SWAP(float, node->prvr.ymax, node->prvr.ymin); + if (node->prvr.xmax < node->prvr.xmin) { + SWAP(float, node->prvr.xmax, node->prvr.xmin); + } + if (node->prvr.ymax < node->prvr.ymin) { + SWAP(float, node->prvr.ymax, node->prvr.ymin); + } } /* buttons rect? */ @@ -456,8 +485,9 @@ static void node_update_basis(const bContext *C, bNodeTree *ntree, bNode *node) /* input sockets */ for (nsock = node->inputs.first; nsock; nsock = nsock->next) { - if (nodeSocketIsHidden(nsock)) + if (nodeSocketIsHidden(nsock)) { continue; + } RNA_pointer_create(&ntree->id, &RNA_NodeSocket, nsock, &sockptr); @@ -483,13 +513,15 @@ static void node_update_basis(const bContext *C, bNodeTree *ntree, bNode *node) nsock->locy = 0.5f * (dy + buty); dy = buty; - if (nsock->next) + if (nsock->next) { dy -= NODE_SOCKDY; + } } /* little bit space in end */ - if (node->inputs.first || (node->flag & (NODE_OPTIONS | NODE_PREVIEW)) == 0) + if (node->inputs.first || (node->flag & (NODE_OPTIONS | NODE_PREVIEW)) == 0) { dy -= NODE_DYS / 2; + } node->totr.xmin = locx; node->totr.xmax = locx + NODE_WIDTH(node); @@ -519,12 +551,16 @@ static void node_update_hidden(bNode *node) node_to_view(node, 0.0f, 0.0f, &locx, &locy); /* calculate minimal radius */ - for (nsock = node->inputs.first; nsock; nsock = nsock->next) - if (!nodeSocketIsHidden(nsock)) + for (nsock = node->inputs.first; nsock; nsock = nsock->next) { + if (!nodeSocketIsHidden(nsock)) { totin++; - for (nsock = node->outputs.first; nsock; nsock = nsock->next) - if (!nodeSocketIsHidden(nsock)) + } + } + for (nsock = node->outputs.first; nsock; nsock = nsock->next) { + if (!nodeSocketIsHidden(nsock)) { totout++; + } + } tot = MAX2(totin, totout); if (tot > 4) { @@ -571,10 +607,12 @@ static void node_update_hidden(bNode *node) void node_update_default(const bContext *C, bNodeTree *ntree, bNode *node) { - if (node->flag & NODE_HIDDEN) + if (node->flag & NODE_HIDDEN) { node_update_hidden(node); - else + } + else { node_update_basis(C, ntree, node); + } } int node_select_area_default(bNode *node, int x, int y) @@ -618,8 +656,9 @@ static void node_draw_mute_line(View2D *v2d, SpaceNode *snode, bNode *node) GPU_blend(true); - for (link = node->internal_links.first; link; link = link->next) + for (link = node->internal_links.first; link; link = link->next) { node_draw_link_bezier(v2d, snode, link, TH_REDALERT, TH_REDALERT, -1); + } GPU_blend(false); } @@ -656,10 +695,12 @@ static void node_draw_preview_background(float tile, rctf *rect) for (x = rect->xmin; x < rect->xmax; x += tile * 2) { float tilex = tile, tiley = tile; - if (x + tile > rect->xmax) + if (x + tile > rect->xmax) { tilex = rect->xmax - x; - if (y + tile > rect->ymax) + } + if (y + tile > rect->ymax) { tiley = rect->ymax - y; + } immRectf(pos, x, y, x + tilex, y + tiley); } @@ -668,10 +709,12 @@ static void node_draw_preview_background(float tile, rctf *rect) for (x = rect->xmin + tile; x < rect->xmax; x += tile * 2) { float tilex = tile, tiley = tile; - if (x + tile > rect->xmax) + if (x + tile > rect->xmax) { tilex = rect->xmax - x; - if (y + tile > rect->ymax) + } + if (y + tile > rect->ymax) { tiley = rect->ymax - y; + } immRectf(pos, x, y, x + tilex, y + tiley); } @@ -740,8 +783,9 @@ void node_draw_shadow(SpaceNode *snode, bNode *node, float radius, float alpha) rctf *rct = &node->totr; UI_draw_roundbox_corner_set(UI_CNR_ALL); - if (node->parent == NULL) + if (node->parent == NULL) { ui_draw_dropshadow(rct, radius, snode->aspect, alpha, node->flag & SELECT); + } else { const float margin = 3.0f; @@ -790,8 +834,9 @@ void node_draw_sockets(View2D *v2d, const bContext *C, bNodeTree *ntree, bNode * short selected_input_len = 0; bNodeSocket *sock; for (sock = node->inputs.first; sock; sock = sock->next) { - if (nodeSocketIsHidden(sock)) + if (nodeSocketIsHidden(sock)) { continue; + } if (select_all || (sock->flag & SELECT)) { ++selected_input_len; continue; @@ -804,8 +849,9 @@ void node_draw_sockets(View2D *v2d, const bContext *C, bNodeTree *ntree, bNode * short selected_output_len = 0; if (draw_outputs) { for (sock = node->outputs.first; sock; sock = sock->next) { - if (nodeSocketIsHidden(sock)) + if (nodeSocketIsHidden(sock)) { continue; + } if (select_all || (sock->flag & SELECT)) { ++selected_output_len; continue; @@ -832,12 +878,14 @@ void node_draw_sockets(View2D *v2d, const bContext *C, bNodeTree *ntree, bNode * if (selected_input_len) { /* socket inputs */ for (sock = node->inputs.first; sock; sock = sock->next) { - if (nodeSocketIsHidden(sock)) + if (nodeSocketIsHidden(sock)) { continue; + } if (select_all || (sock->flag & SELECT)) { node_socket_circle_draw(C, ntree, node_ptr, sock, pos, col); - if (--selected_input_len == 0) + if (--selected_input_len == 0) { break; /* stop as soon as last one is drawn */ + } } } } @@ -845,12 +893,14 @@ void node_draw_sockets(View2D *v2d, const bContext *C, bNodeTree *ntree, bNode * if (selected_output_len) { /* socket outputs */ for (sock = node->outputs.first; sock; sock = sock->next) { - if (nodeSocketIsHidden(sock)) + if (nodeSocketIsHidden(sock)) { continue; + } if (select_all || (sock->flag & SELECT)) { node_socket_circle_draw(C, ntree, node_ptr, sock, pos, col); - if (--selected_output_len == 0) + if (--selected_output_len == 0) { break; /* stop as soon as last one is drawn */ + } } } } @@ -979,8 +1029,9 @@ static void node_draw_basis(const bContext *C, ARegion *ar, SpaceNode *snode, bN else if (node->flag & NODE_CUSTOM_COLOR) { rgba_float_args_set(color, node->color[0], node->color[1], node->color[2], 1.0f); } - else + else { UI_GetThemeColor4fv(TH_NODE, color); + } UI_draw_roundbox_corner_set(UI_CNR_BOTTOM_LEFT | UI_CNR_BOTTOM_RIGHT); UI_draw_roundbox_aa(true, rct->xmin, rct->ymin, rct->xmax, rct->ymax - NODE_DY, BASIS_RAD, color); @@ -994,8 +1045,9 @@ static void node_draw_basis(const bContext *C, ARegion *ar, SpaceNode *snode, bN } /* disable lines */ - if (node->flag & NODE_MUTED) + if (node->flag & NODE_MUTED) { node_draw_mute_line(v2d, snode, node); + } node_draw_sockets(v2d, C, ntree, node, true, false); @@ -1033,10 +1085,12 @@ static void node_draw_hidden(const bContext *C, ARegion *ar, SpaceNode *snode, b node_draw_shadow(snode, node, hiddenrad, 1.0f); /* body */ - if (node->flag & NODE_MUTED) + if (node->flag & NODE_MUTED) { UI_GetThemeColorBlendShade4fv(color_id, TH_REDALERT, 0.5f, 0, color); - else + } + else { UI_GetThemeColor4fv(color_id, color); + } UI_draw_roundbox_aa(true, rct->xmin, rct->ymin, rct->xmax, rct->ymax, hiddenrad, color); @@ -1084,8 +1138,9 @@ static void node_draw_hidden(const bContext *C, ARegion *ar, SpaceNode *snode, b } /* disable lines */ - if (node->flag & NODE_MUTED) + if (node->flag & NODE_MUTED) { node_draw_mute_line(&ar->v2d, snode, node); + } if (node->miniwidth > 0.0f) { nodeLabel(ntree, node, showname, sizeof(showname)); @@ -1137,14 +1192,18 @@ static void node_draw_hidden(const bContext *C, ARegion *ar, SpaceNode *snode, b int node_get_resize_cursor(int directions) { - if (directions == 0) + if (directions == 0) { return CURSOR_STD; - else if ((directions & ~(NODE_RESIZE_TOP | NODE_RESIZE_BOTTOM)) == 0) + } + else if ((directions & ~(NODE_RESIZE_TOP | NODE_RESIZE_BOTTOM)) == 0) { return CURSOR_Y_MOVE; - else if ((directions & ~(NODE_RESIZE_RIGHT | NODE_RESIZE_LEFT)) == 0) + } + else if ((directions & ~(NODE_RESIZE_RIGHT | NODE_RESIZE_LEFT)) == 0) { return CURSOR_X_MOVE; - else + } + else { return CURSOR_EDIT; + } } void node_set_cursor(wmWindow *win, SpaceNode *snode, float cursor[2]) @@ -1161,8 +1220,9 @@ void node_set_cursor(wmWindow *win, SpaceNode *snode, float cursor[2]) else { /* check nodes front to back */ for (node = ntree->nodes.last; node; node = node->prev) { - if (BLI_rctf_isect_pt(&node->totr, cursor[0], cursor[1])) + if (BLI_rctf_isect_pt(&node->totr, cursor[0], cursor[1])) { break; /* first hit on node stops */ + } } if (node) { int dir = node->typeinfo->resize_area_func(node, cursor[0], cursor[1]); @@ -1176,16 +1236,19 @@ void node_set_cursor(wmWindow *win, SpaceNode *snode, float cursor[2]) void node_draw_default(const bContext *C, ARegion *ar, SpaceNode *snode, bNodeTree *ntree, bNode *node, bNodeInstanceKey key) { - if (node->flag & NODE_HIDDEN) + if (node->flag & NODE_HIDDEN) { node_draw_hidden(C, ar, snode, ntree, node, key); - else + } + else { node_draw_basis(C, ar, snode, ntree, node, key); + } } static void node_update(const bContext *C, bNodeTree *ntree, bNode *node) { - if (node->typeinfo->draw_nodetype_prepare) + if (node->typeinfo->draw_nodetype_prepare) { node->typeinfo->draw_nodetype_prepare(C, ntree, node); + } } void node_update_nodetree(const bContext *C, bNodeTree *ntree) @@ -1203,8 +1266,9 @@ void node_update_nodetree(const bContext *C, bNodeTree *ntree) static void node_draw(const bContext *C, ARegion *ar, SpaceNode *snode, bNodeTree *ntree, bNode *node, bNodeInstanceKey key) { - if (node->typeinfo->draw_nodetype) + if (node->typeinfo->draw_nodetype) { node->typeinfo->draw_nodetype(C, ar, snode, ntree, node, key); + } } #define USE_DRAW_TOT_UPDATE @@ -1215,7 +1279,9 @@ void node_draw_nodetree(const bContext *C, ARegion *ar, SpaceNode *snode, bNodeT bNodeLink *link; int a; - if (ntree == NULL) return; /* groups... */ + if (ntree == NULL) { + return; /* groups... */ + } #ifdef USE_DRAW_TOT_UPDATE if (ntree->nodes.first) { @@ -1233,8 +1299,9 @@ void node_draw_nodetree(const bContext *C, ARegion *ar, SpaceNode *snode, bNodeT BLI_rctf_union(&ar->v2d.tot, &node->totr); #endif - if (!(node->flag & NODE_BACKGROUND)) + if (!(node->flag & NODE_BACKGROUND)) { continue; + } key = BKE_node_instance_key(parent_key, ntree, node); node->nr = a; /* index of node in list, used for exec event code */ @@ -1245,8 +1312,9 @@ void node_draw_nodetree(const bContext *C, ARegion *ar, SpaceNode *snode, bNodeT GPU_blend(true); nodelink_batch_start(snode); for (link = ntree->links.first; link; link = link->next) { - if (!nodeLinkIsHidden(link)) + if (!nodeLinkIsHidden(link)) { node_draw_link(&ar->v2d, snode, link); + } } nodelink_batch_end(snode); GPU_blend(false); @@ -1254,8 +1322,9 @@ void node_draw_nodetree(const bContext *C, ARegion *ar, SpaceNode *snode, bNodeT /* draw foreground nodes, last nodes in front */ for (a = 0, node = ntree->nodes.first; node; node = node->next, a++) { bNodeInstanceKey key; - if (node->flag & NODE_BACKGROUND) + if (node->flag & NODE_BACKGROUND) { continue; + } key = BKE_node_instance_key(parent_key, ntree, node); node->nr = a; /* index of node in list, used for exec event code */ @@ -1370,8 +1439,9 @@ void drawnodespace(const bContext *C, ARegion *ar) /* store new view center in path and current edittree */ copy_v2_v2(path->view_center, center); - if (snode->edittree) + if (snode->edittree) { copy_v2_v2(snode->edittree->view_center, center); + } depth = 0; while (path->prev && depth < max_depth) { @@ -1424,8 +1494,9 @@ void drawnodespace(const bContext *C, ARegion *ar) GPU_blend(true); GPU_line_smooth(true); for (nldrag = snode->linkdrag.first; nldrag; nldrag = nldrag->next) { - for (linkdata = nldrag->links.first; linkdata; linkdata = linkdata->next) + for (linkdata = nldrag->links.first; linkdata; linkdata = linkdata->next) { node_draw_link(v2d, snode, (bNodeLink *)linkdata->data); + } } GPU_line_smooth(false); GPU_blend(false); diff --git a/source/blender/editors/space_node/node_edit.c b/source/blender/editors/space_node/node_edit.c index eb20f4e7175..0c7b3daf611 100644 --- a/source/blender/editors/space_node/node_edit.c +++ b/source/blender/editors/space_node/node_edit.c @@ -97,16 +97,19 @@ static void compo_tag_output_nodes(bNodeTree *nodetree, int recalc_flags) for (node = nodetree->nodes.first; node; node = node->next) { if (node->type == CMP_NODE_COMPOSITE) { - if (recalc_flags & COM_RECALC_COMPOSITE) + if (recalc_flags & COM_RECALC_COMPOSITE) { node->flag |= NODE_DO_OUTPUT_RECALC; + } } else if (node->type == CMP_NODE_VIEWER || node->type == CMP_NODE_SPLITVIEWER) { - if (recalc_flags & COM_RECALC_VIEWER) + if (recalc_flags & COM_RECALC_VIEWER) { node->flag |= NODE_DO_OUTPUT_RECALC; + } } else if (node->type == NODE_GROUP) { - if (node->id) + if (node->id) { compo_tag_output_nodes((bNodeTree *)node->id, recalc_flags); + } } } } @@ -125,16 +128,19 @@ static int compo_get_recalc_flags(const bContext *C) if (sa->spacetype == SPACE_IMAGE) { SpaceImage *sima = sa->spacedata.first; if (sima->image) { - if (sima->image->type == IMA_TYPE_R_RESULT) + if (sima->image->type == IMA_TYPE_R_RESULT) { recalc_flags |= COM_RECALC_COMPOSITE; - else if (sima->image->type == IMA_TYPE_COMPOSITE) + } + else if (sima->image->type == IMA_TYPE_COMPOSITE) { recalc_flags |= COM_RECALC_VIEWER; + } } } else if (sa->spacetype == SPACE_NODE) { SpaceNode *snode = sa->spacedata.first; - if (snode->flag & SNODE_BACKDRAW) + if (snode->flag & SNODE_BACKDRAW) { recalc_flags |= COM_RECALC_VIEWER; + } } } } @@ -190,8 +196,9 @@ static void compo_initjob(void *cjv) cj->localtree = ntreeLocalize(cj->ntree); - if (cj->recalc_flags) + if (cj->recalc_flags) { compo_tag_output_nodes(cj->localtree, cj->recalc_flags); + } } /* called before redraw notifiers, it moves finished previews over */ @@ -215,8 +222,9 @@ static void compo_startjob(void *cjv, short *stop, short *do_update, float *prog Scene *scene = cj->scene; SceneRenderView *srv; - if (scene->use_nodes == false) + if (scene->use_nodes == false) { return; + } cj->stop = stop; cj->do_update = do_update; @@ -239,7 +247,9 @@ static void compo_startjob(void *cjv, short *stop, short *do_update, float *prog } else { for (srv = scene->r.views.first; srv; srv = srv->next) { - if (BKE_scene_multiview_is_render_view_active(&scene->r, srv) == false) continue; + if (BKE_scene_multiview_is_render_view_active(&scene->r, srv) == false) { + continue; + } ntreeCompositExecTree(cj->scene, ntree, &cj->scene->r, false, true, &scene->view_settings, &scene->display_settings, srv->name); } } @@ -300,8 +310,9 @@ bool composite_node_active(bContext *C) { if (ED_operator_node_active(C)) { SpaceNode *snode = CTX_wm_space_node(C); - if (ED_node_is_compositor(snode)) + if (ED_node_is_compositor(snode)) { return 1; + } } return 0; } @@ -311,8 +322,9 @@ bool composite_node_editable(bContext *C) { if (ED_operator_node_editable(C)) { SpaceNode *snode = CTX_wm_space_node(C); - if (ED_node_is_compositor(snode)) + if (ED_node_is_compositor(snode)) { return 1; + } } return 0; } @@ -324,8 +336,9 @@ void snode_dag_update(bContext *C, SpaceNode *snode) /* for groups, update all ID's using this */ if (snode->edittree != snode->nodetree) { FOREACH_NODETREE_BEGIN(bmain, tntree, id) { - if (ntreeHasTree(tntree, snode->edittree)) + if (ntreeHasTree(tntree, snode->edittree)) { DEG_id_tag_update(id, 0); + } } FOREACH_NODETREE_END; } @@ -339,25 +352,32 @@ void snode_notify(bContext *C, SpaceNode *snode) WM_event_add_notifier(C, NC_NODE | NA_EDITED, NULL); if (ED_node_is_shader(snode)) { - if (GS(id->name) == ID_MA) + if (GS(id->name) == ID_MA) { WM_main_add_notifier(NC_MATERIAL | ND_SHADING, id); - else if (GS(id->name) == ID_LA) + } + else if (GS(id->name) == ID_LA) { WM_main_add_notifier(NC_LAMP | ND_LIGHTING, id); - else if (GS(id->name) == ID_WO) + } + else if (GS(id->name) == ID_WO) { WM_main_add_notifier(NC_WORLD | ND_WORLD, id); + } } - else if (ED_node_is_compositor(snode)) + else if (ED_node_is_compositor(snode)) { WM_event_add_notifier(C, NC_SCENE | ND_NODES, id); - else if (ED_node_is_texture(snode)) + } + else if (ED_node_is_texture(snode)) { WM_event_add_notifier(C, NC_TEXTURE | ND_NODES, id); + } } void ED_node_set_tree_type(SpaceNode *snode, bNodeTreeType *typeinfo) { - if (typeinfo) + if (typeinfo) { BLI_strncpy(snode->tree_idname, typeinfo->idname, sizeof(snode->tree_idname)); - else + } + else { snode->tree_idname[0] = '\0'; + } } bool ED_node_is_compositor(struct SpaceNode *snode) @@ -421,10 +441,12 @@ void ED_node_shader_default(const bContext *C, ID *id) shader_type = SH_NODE_EMISSION; copy_v3_v3(color, &la->r); - if (la->type == LA_LOCAL || la->type == LA_SPOT || la->type == LA_AREA) + if (la->type == LA_LOCAL || la->type == LA_SPOT || la->type == LA_AREA) { strength = 100.0f; - else + } + else { strength = 1.0f; + } break; } default: @@ -469,8 +491,9 @@ void ED_node_composit_default(const bContext *C, struct Scene *sce) /* but lets check it anyway */ if (sce->nodetree) { - if (G.debug & G_DEBUG) + if (G.debug & G_DEBUG) { printf("error in composite initialize\n"); + } return; } @@ -504,8 +527,9 @@ void ED_node_texture_default(const bContext *C, Tex *tx) /* but lets check it anyway */ if (tx->nodetree) { - if (G.debug & G_DEBUG) + if (G.debug & G_DEBUG) { printf("error in texture initialize\n"); + } return; } @@ -588,8 +612,9 @@ void snode_update(SpaceNode *snode, bNode *node) } } - if (node) + if (node) { nodeUpdate(snode->edittree, node); + } } void ED_node_set_active(Main *bmain, bNodeTree *ntree, bNode *node) @@ -605,49 +630,61 @@ void ED_node_set_active(Main *bmain, bNodeTree *ntree, bNode *node) /* generic node group output: set node as active output */ if (node->type == NODE_GROUP_OUTPUT) { bNode *tnode; - for (tnode = ntree->nodes.first; tnode; tnode = tnode->next) - if (tnode->type == NODE_GROUP_OUTPUT) + for (tnode = ntree->nodes.first; tnode; tnode = tnode->next) { + if (tnode->type == NODE_GROUP_OUTPUT) { tnode->flag &= ~NODE_DO_OUTPUT; + } + } node->flag |= NODE_DO_OUTPUT; - if (!was_output) + if (!was_output) { do_update = 1; + } } /* tree specific activate calls */ if (ntree->type == NTREE_SHADER) { /* when we select a material, active texture is cleared, for buttons */ - if (node->id && ELEM(GS(node->id->name), ID_MA, ID_LA, ID_WO)) + if (node->id && ELEM(GS(node->id->name), ID_MA, ID_LA, ID_WO)) { nodeClearActiveID(ntree, ID_TE); + } if (ELEM(node->type, SH_NODE_OUTPUT_MATERIAL, SH_NODE_OUTPUT_WORLD, SH_NODE_OUTPUT_LIGHT, SH_NODE_OUTPUT_LINESTYLE)) { bNode *tnode; - for (tnode = ntree->nodes.first; tnode; tnode = tnode->next) - if (tnode->type == node->type) + for (tnode = ntree->nodes.first; tnode; tnode = tnode->next) { + if (tnode->type == node->type) { tnode->flag &= ~NODE_DO_OUTPUT; + } + } node->flag |= NODE_DO_OUTPUT; - if (was_output == 0) + if (was_output == 0) { ED_node_tag_update_nodetree(bmain, ntree, node); + } } - else if (do_update) + else if (do_update) { ED_node_tag_update_nodetree(bmain, ntree, node); + } /* if active texture changed, free glsl materials */ if ((node->flag & NODE_ACTIVE_TEXTURE) && !was_active_texture) { Material *ma; World *wo; - for (ma = bmain->materials.first; ma; ma = ma->id.next) - if (ma->nodetree && ma->use_nodes && ntreeHasTree(ma->nodetree, ntree)) + for (ma = bmain->materials.first; ma; ma = ma->id.next) { + if (ma->nodetree && ma->use_nodes && ntreeHasTree(ma->nodetree, ntree)) { GPU_material_free(&ma->gpumaterial); + } + } - for (wo = bmain->worlds.first; wo; wo = wo->id.next) - if (wo->nodetree && wo->use_nodes && ntreeHasTree(wo->nodetree, ntree)) + for (wo = bmain->worlds.first; wo; wo = wo->id.next) { + if (wo->nodetree && wo->use_nodes && ntreeHasTree(wo->nodetree, ntree)) { GPU_material_free(&wo->gpumaterial); + } + } ED_node_tag_update_nodetree(bmain, ntree, node); WM_main_add_notifier(NC_IMAGE, NULL); @@ -661,13 +698,16 @@ void ED_node_set_active(Main *bmain, bNodeTree *ntree, bNode *node) bNode *tnode; - for (tnode = ntree->nodes.first; tnode; tnode = tnode->next) - if (ELEM(tnode->type, CMP_NODE_VIEWER, CMP_NODE_SPLITVIEWER)) + for (tnode = ntree->nodes.first; tnode; tnode = tnode->next) { + if (ELEM(tnode->type, CMP_NODE_VIEWER, CMP_NODE_SPLITVIEWER)) { tnode->flag &= ~NODE_DO_OUTPUT; + } + } node->flag |= NODE_DO_OUTPUT; - if (was_output == 0) + if (was_output == 0) { ED_node_tag_update_nodetree(bmain, ntree, node); + } /* addnode() doesn't link this yet... */ node->id = (ID *)BKE_image_verify_viewer(bmain, IMA_TYPE_COMPOSITE, "Viewer Node"); @@ -676,16 +716,19 @@ void ED_node_set_active(Main *bmain, bNodeTree *ntree, bNode *node) if (was_output == 0) { bNode *tnode; - for (tnode = ntree->nodes.first; tnode; tnode = tnode->next) - if (tnode->type == CMP_NODE_COMPOSITE) + for (tnode = ntree->nodes.first; tnode; tnode = tnode->next) { + if (tnode->type == CMP_NODE_COMPOSITE) { tnode->flag &= ~NODE_DO_OUTPUT; + } + } node->flag |= NODE_DO_OUTPUT; ED_node_tag_update_nodetree(bmain, ntree, node); } } - else if (do_update) + else if (do_update) { ED_node_tag_update_nodetree(bmain, ntree, node); + } } else if (ntree->type == NTREE_TEXTURE) { // XXX @@ -780,8 +823,9 @@ static bNode *visible_node(SpaceNode *snode, const rctf *rct) bNode *node; for (node = snode->edittree->nodes.last; node; node = node->prev) { - if (BLI_rctf_isect(&node->totr, rct, NULL)) + if (BLI_rctf_isect(&node->totr, rct, NULL)) { break; + } } return node; } @@ -986,12 +1030,16 @@ int node_has_hidden_sockets(bNode *node) { bNodeSocket *sock; - for (sock = node->inputs.first; sock; sock = sock->next) - if (sock->flag & SOCK_HIDDEN) + for (sock = node->inputs.first; sock; sock = sock->next) { + if (sock->flag & SOCK_HIDDEN) { return 1; - for (sock = node->outputs.first; sock; sock = sock->next) - if (sock->flag & SOCK_HIDDEN) + } + } + for (sock = node->outputs.first; sock; sock = sock->next) { + if (sock->flag & SOCK_HIDDEN) { return 1; + } + } return 0; } @@ -1000,20 +1048,24 @@ void node_set_hidden_sockets(SpaceNode *snode, bNode *node, int set) bNodeSocket *sock; if (set == 0) { - for (sock = node->inputs.first; sock; sock = sock->next) + for (sock = node->inputs.first; sock; sock = sock->next) { sock->flag &= ~SOCK_HIDDEN; - for (sock = node->outputs.first; sock; sock = sock->next) + } + for (sock = node->outputs.first; sock; sock = sock->next) { sock->flag &= ~SOCK_HIDDEN; + } } else { /* hide unused sockets */ for (sock = node->inputs.first; sock; sock = sock->next) { - if (sock->link == NULL) + if (sock->link == NULL) { sock->flag |= SOCK_HIDDEN; + } } for (sock = node->outputs.first; sock; sock = sock->next) { - if (nodeCountSocketLinks(snode->edittree, sock) == 0) + if (nodeCountSocketLinks(snode->edittree, sock) == 0) { sock->flag |= SOCK_HIDDEN; + } } } } @@ -1089,8 +1141,9 @@ static void node_duplicate_reparent_recursive(bNode *node) /* find first selected parent */ for (parent = node->parent; parent; parent = parent->parent) { if (parent->flag & SELECT) { - if (!(parent->flag & NODE_TEST)) + if (!(parent->flag & NODE_TEST)) { node_duplicate_reparent_recursive(parent); + } break; } } @@ -1123,8 +1176,9 @@ static int node_duplicate_exec(bContext *C, wmOperator *op) } /* make sure we don't copy new nodes again! */ - if (node == lastnode) + if (node == lastnode) { break; + } } /* copy links between selected nodes @@ -1156,21 +1210,25 @@ static int node_duplicate_exec(bContext *C, wmOperator *op) } /* make sure we don't copy new links again! */ - if (link == lastlink) + if (link == lastlink) { break; + } } /* clear flags for recursive depth-first iteration */ - for (node = ntree->nodes.first; node; node = node->next) + for (node = ntree->nodes.first; node; node = node->next) { node->flag &= ~NODE_TEST; + } /* reparent copied nodes */ for (node = ntree->nodes.first; node; node = node->next) { - if ((node->flag & SELECT) && !(node->flag & NODE_TEST)) + if ((node->flag & SELECT) && !(node->flag & NODE_TEST)) { node_duplicate_reparent_recursive(node); + } /* only has to check old nodes */ - if (node == lastnode) + if (node == lastnode) { break; + } } /* deselect old nodes, select the copies instead */ @@ -1187,8 +1245,9 @@ static int node_duplicate_exec(bContext *C, wmOperator *op) } /* make sure we don't copy new nodes again! */ - if (node == lastnode) + if (node == lastnode) { break; + } } ntreeUpdateTree(CTX_data_main(C), snode->edittree); @@ -1232,10 +1291,12 @@ bool ED_node_select_check(ListBase *lb) void ED_node_select_all(ListBase *lb, int action) { if (action == SEL_TOGGLE) { - if (ED_node_select_check(lb)) + if (ED_node_select_check(lb)) { action = SEL_DESELECT; - else + } + else { action = SEL_SELECT; + } } for (bNode *node = lb->first; node; node = node->next) { @@ -1268,8 +1329,9 @@ static int node_read_viewlayers_exec(bContext *C, wmOperator *UNUSED(op)) ED_preview_kill_jobs(CTX_wm_manager(C), bmain); /* first tag scenes unread */ - for (scene = bmain->scenes.first; scene; scene = scene->id.next) + for (scene = bmain->scenes.first; scene; scene = scene->id.next) { scene->id.tag |= LIB_TAG_DOIT; + } for (node = snode->edittree->nodes.first; node; node = node->next) { if (node->type == CMP_NODE_R_LAYERS) { @@ -1365,29 +1427,37 @@ static void node_flag_toggle_exec(SpaceNode *snode, int toggle_flag) for (node = snode->edittree->nodes.first; node; node = node->next) { if (node->flag & SELECT) { - if (toggle_flag == NODE_PREVIEW && (node->typeinfo->flag & NODE_PREVIEW) == 0) + if (toggle_flag == NODE_PREVIEW && (node->typeinfo->flag & NODE_PREVIEW) == 0) { continue; - if (toggle_flag == NODE_OPTIONS && !(node->typeinfo->draw_buttons || node->typeinfo->draw_buttons_ex)) + } + if (toggle_flag == NODE_OPTIONS && !(node->typeinfo->draw_buttons || node->typeinfo->draw_buttons_ex)) { continue; + } - if (node->flag & toggle_flag) + if (node->flag & toggle_flag) { tot_eq++; - else + } + else { tot_neq++; + } } } for (node = snode->edittree->nodes.first; node; node = node->next) { if (node->flag & SELECT) { - if (toggle_flag == NODE_PREVIEW && (node->typeinfo->flag & NODE_PREVIEW) == 0) + if (toggle_flag == NODE_PREVIEW && (node->typeinfo->flag & NODE_PREVIEW) == 0) { continue; - if (toggle_flag == NODE_OPTIONS && !(node->typeinfo->draw_buttons || node->typeinfo->draw_buttons_ex)) + } + if (toggle_flag == NODE_OPTIONS && !(node->typeinfo->draw_buttons || node->typeinfo->draw_buttons_ex)) { continue; + } - if ((tot_eq && tot_neq) || tot_eq == 0) + if ((tot_eq && tot_neq) || tot_eq == 0) { node->flag |= toggle_flag; - else + } + else { node->flag &= ~toggle_flag; + } } } } @@ -1397,8 +1467,9 @@ static int node_hide_toggle_exec(bContext *C, wmOperator *UNUSED(op)) SpaceNode *snode = CTX_wm_space_node(C); /* sanity checking (poll callback checks this already) */ - if ((snode == NULL) || (snode->edittree == NULL)) + if ((snode == NULL) || (snode->edittree == NULL)) { return OPERATOR_CANCELLED; + } node_flag_toggle_exec(snode, NODE_HIDDEN); @@ -1427,8 +1498,9 @@ static int node_preview_toggle_exec(bContext *C, wmOperator *UNUSED(op)) SpaceNode *snode = CTX_wm_space_node(C); /* sanity checking (poll callback checks this already) */ - if ((snode == NULL) || (snode->edittree == NULL)) + if ((snode == NULL) || (snode->edittree == NULL)) { return OPERATOR_CANCELLED; + } ED_preview_kill_jobs(CTX_wm_manager(C), CTX_data_main(C)); @@ -1459,8 +1531,9 @@ static int node_options_toggle_exec(bContext *C, wmOperator *UNUSED(op)) SpaceNode *snode = CTX_wm_space_node(C); /* sanity checking (poll callback checks this already) */ - if ((snode == NULL) || (snode->edittree == NULL)) + if ((snode == NULL) || (snode->edittree == NULL)) { return OPERATOR_CANCELLED; + } node_flag_toggle_exec(snode, NODE_OPTIONS); @@ -1491,8 +1564,9 @@ static int node_socket_toggle_exec(bContext *C, wmOperator *UNUSED(op)) int hidden; /* sanity checking (poll callback checks this already) */ - if ((snode == NULL) || (snode->edittree == NULL)) + if ((snode == NULL) || (snode->edittree == NULL)) { return OPERATOR_CANCELLED; + } ED_preview_kill_jobs(CTX_wm_manager(C), CTX_data_main(C)); @@ -1628,8 +1702,9 @@ static bool node_switch_view_poll(bContext *C) { SpaceNode *snode = CTX_wm_space_node(C); - if (snode && snode->edittree) + if (snode && snode->edittree) { return true; + } return false; } @@ -1731,8 +1806,9 @@ static int node_output_file_add_socket_exec(bContext *C, wmOperator *op) node = nodeGetActive(snode->edittree); } - if (!node || node->type != CMP_NODE_OUTPUT_FILE) + if (!node || node->type != CMP_NODE_OUTPUT_FILE) { return OPERATOR_CANCELLED; + } RNA_string_get(op->ptr, "file_path", file_path); ntreeCompositOutputFileAddSocket(ntree, node, file_path, &scene->r.im_format); @@ -1777,11 +1853,13 @@ static int node_output_file_remove_active_socket_exec(bContext *C, wmOperator *U node = nodeGetActive(snode->edittree); } - if (!node || node->type != CMP_NODE_OUTPUT_FILE) + if (!node || node->type != CMP_NODE_OUTPUT_FILE) { return OPERATOR_CANCELLED; + } - if (!ntreeCompositOutputFileRemoveActiveSocket(ntree, node)) + if (!ntreeCompositOutputFileRemoveActiveSocket(ntree, node)) { return OPERATOR_CANCELLED; + } snode_notify(C, snode); @@ -1814,34 +1892,40 @@ static int node_output_file_move_active_socket_exec(bContext *C, wmOperator *op) bNodeSocket *sock; int direction; - if (ptr.data) + if (ptr.data) { node = ptr.data; - else if (snode && snode->edittree) + } + else if (snode && snode->edittree) { node = nodeGetActive(snode->edittree); + } - if (!node || node->type != CMP_NODE_OUTPUT_FILE) + if (!node || node->type != CMP_NODE_OUTPUT_FILE) { return OPERATOR_CANCELLED; + } nimf = node->storage; sock = BLI_findlink(&node->inputs, nimf->active_input); - if (!sock) + if (!sock) { return OPERATOR_CANCELLED; + } direction = RNA_enum_get(op->ptr, "direction"); if (direction == 1) { bNodeSocket *before = sock->prev; - if (!before) + if (!before) { return OPERATOR_CANCELLED; + } BLI_remlink(&node->inputs, sock); BLI_insertlinkbefore(&node->inputs, before, sock); nimf->active_input--; } else { bNodeSocket *after = sock->next; - if (!after) + if (!after) { return OPERATOR_CANCELLED; + } BLI_remlink(&node->inputs, sock); BLI_insertlinkafter(&node->inputs, after, sock); nimf->active_input++; @@ -1883,11 +1967,13 @@ static int node_copy_color_exec(bContext *C, wmOperator *UNUSED(op)) bNodeTree *ntree = snode->edittree; bNode *node, *tnode; - if (!ntree) + if (!ntree) { return OPERATOR_CANCELLED; + } node = nodeGetActive(ntree); - if (!node) + if (!node) { return OPERATOR_CANCELLED; + } for (tnode = ntree->nodes.first; tnode; tnode = tnode->next) { if (tnode->flag & NODE_SELECT && tnode != node) { @@ -1895,8 +1981,9 @@ static int node_copy_color_exec(bContext *C, wmOperator *UNUSED(op)) tnode->flag |= NODE_CUSTOM_COLOR; copy_v3_v3(tnode->color, node->color); } - else + else { tnode->flag &= ~NODE_CUSTOM_COLOR; + } } } @@ -2041,8 +2128,9 @@ static int node_clipboard_paste_exec(bContext *C, wmOperator *op) BKE_reportf(op->reports, RPT_ERROR, "Cannot add node %s into node tree %s", node->name, ntree->id.name + 2); } } - if (!all_nodes_valid) + if (!all_nodes_valid) { return OPERATOR_CANCELLED; + } ED_preview_kill_jobs(CTX_wm_manager(C), CTX_data_main(C)); @@ -2068,8 +2156,9 @@ static int node_clipboard_paste_exec(bContext *C, wmOperator *op) /* reparent copied nodes */ for (node = clipboard_nodes_lb->first; node; node = node->next) { bNode *new_node = node->new_node; - if (new_node->parent) + if (new_node->parent) { new_node->parent = new_node->parent->new_node; + } } for (link = clipboard_links_lb->first; link; link = link->next) { @@ -2105,9 +2194,11 @@ void NODE_OT_clipboard_paste(wmOperatorType *ot) static bNodeSocket *ntree_get_active_interface_socket(ListBase *lb) { bNodeSocket *sock; - for (sock = lb->first; sock; sock = sock->next) - if (sock->flag & SELECT) + for (sock = lb->first; sock; sock = sock->next) { + if (sock->flag & SELECT) { return sock; + } + } return NULL; } @@ -2143,10 +2234,12 @@ static int ntree_socket_add_exec(bContext *C, wmOperator *op) } /* deactivate sockets (has to check both lists) */ - for (tsock = ntree->inputs.first; tsock; tsock = tsock->next) + for (tsock = ntree->inputs.first; tsock; tsock = tsock->next) { tsock->flag &= ~SELECT; - for (tsock = ntree->outputs.first; tsock; tsock = tsock->next) + } + for (tsock = ntree->outputs.first; tsock; tsock = tsock->next) { tsock->flag &= ~SELECT; + } /* make the new socket active */ sock->flag |= SELECT; @@ -2183,18 +2276,21 @@ static int ntree_socket_remove_exec(bContext *C, wmOperator *UNUSED(op)) bNodeSocket *iosock, *active_sock; iosock = ntree_get_active_interface_socket(&ntree->inputs); - if (!iosock) + if (!iosock) { iosock = ntree_get_active_interface_socket(&ntree->outputs); - if (!iosock) + } + if (!iosock) { return OPERATOR_CANCELLED; + } /* preferably next socket becomes active, otherwise try previous socket */ active_sock = (iosock->next ? iosock->next : iosock->prev); ntreeRemoveSocketInterface(ntree, iosock); /* set active socket */ - if (active_sock) + if (active_sock) { active_sock->flag |= SELECT; + } ntreeUpdateTree(CTX_data_main(C), ntree); @@ -2240,28 +2336,33 @@ static int ntree_socket_move_exec(bContext *C, wmOperator *op) lb = &ntree->outputs; iosock = ntree_get_active_interface_socket(lb); } - if (!iosock) + if (!iosock) { return OPERATOR_CANCELLED; + } switch (direction) { case 1: { /* up */ bNodeSocket *before = iosock->prev; BLI_remlink(lb, iosock); - if (before) + if (before) { BLI_insertlinkbefore(lb, before, iosock); - else + } + else { BLI_addhead(lb, iosock); + } break; } case 2: { /* down */ bNodeSocket *after = iosock->next; BLI_remlink(lb, iosock); - if (after) + if (after) { BLI_insertlinkafter(lb, after, iosock); - else + } + else { BLI_addtail(lb, iosock); + } break; } } @@ -2301,14 +2402,16 @@ static bool node_shader_script_update_poll(bContext *C) Text *text; /* test if we have a render engine that supports shaders scripts */ - if (!(type && type->update_script_node)) + if (!(type && type->update_script_node)) { return 0; + } /* see if we have a shader script node in context */ node = CTX_data_pointer_get_type(C, "node", &RNA_ShaderNodeScript).data; - if (!node && snode && snode->edittree) + if (!node && snode && snode->edittree) { node = nodeGetActive(snode->edittree); + } if (node && node->type == SH_NODE_SCRIPT) { NodeShaderScript *nss = node->storage; @@ -2320,8 +2423,9 @@ static bool node_shader_script_update_poll(bContext *C) /* see if we have a text datablock in context */ text = CTX_data_pointer_get_type(C, "edit_text", &RNA_Text).data; - if (text) + if (text) { return 1; + } /* we don't check if text datablock is actually in use, too slow for poll */ @@ -2340,8 +2444,9 @@ static bool node_shader_script_update_text_recursive(RenderEngine *engine, Rende for (node = ntree->nodes.first; node; node = node->next) { if (node->type == NODE_GROUP) { bNodeTree *ngroup = (bNodeTree *)node->id; - if (ngroup && !ngroup->done) + if (ngroup && !ngroup->done) { found |= node_shader_script_update_text_recursive(engine, type, ngroup, text); + } } else if (node->type == SH_NODE_SCRIPT && node->id == &text->id) { type->update_script_node(engine, ntree, node); @@ -2392,19 +2497,22 @@ static int node_shader_script_update_exec(bContext *C, wmOperator *op) if (text) { /* clear flags for recursion check */ FOREACH_NODETREE_BEGIN(bmain, ntree, id) { - if (ntree->type == NTREE_SHADER) + if (ntree->type == NTREE_SHADER) { ntree->done = false; + } } FOREACH_NODETREE_END; FOREACH_NODETREE_BEGIN(bmain, ntree, id) { if (ntree->type == NTREE_SHADER) { - if (!ntree->done) + if (!ntree->done) { found |= node_shader_script_update_text_recursive(engine, type, ntree, text); + } } } FOREACH_NODETREE_END; - if (!found) + if (!found) { BKE_report(op->reports, RPT_INFO, "Text not used by any node, no update done"); + } } } diff --git a/source/blender/editors/space_node/node_group.c b/source/blender/editors/space_node/node_group.c index 808d9375d22..3de389dca7c 100644 --- a/source/blender/editors/space_node/node_group.c +++ b/source/blender/editors/space_node/node_group.c @@ -106,12 +106,15 @@ static const char *group_node_idname(bContext *C) { SpaceNode *snode = CTX_wm_space_node(C); - if (ED_node_is_shader(snode)) + if (ED_node_is_shader(snode)) { return "ShaderNodeGroup"; - else if (ED_node_is_compositor(snode)) + } + else if (ED_node_is_compositor(snode)) { return "CompositorNodeGroup"; - else if (ED_node_is_texture(snode)) + } + else if (ED_node_is_texture(snode)) { return "TextureNodeGroup"; + } return ""; } @@ -121,10 +124,12 @@ static bNode *node_group_get_active(bContext *C, const char *node_idname) SpaceNode *snode = CTX_wm_space_node(C); bNode *node = nodeGetActive(snode->edittree); - if (node && STREQ(node->idname, node_idname)) + if (node && STREQ(node->idname, node_idname)) { return node; - else + } + else { return NULL; + } } /* ***************** Edit Group operator ************* */ @@ -143,11 +148,13 @@ static int node_group_edit_exec(bContext *C, wmOperator *op) if (gnode && !exit) { bNodeTree *ngroup = (bNodeTree *)gnode->id; - if (ngroup) + if (ngroup) { ED_node_tree_push(snode, ngroup, gnode); + } } - else + else { ED_node_tree_pop(snode); + } WM_event_add_notifier(C, NC_SCENE | ND_NODES, NULL); @@ -185,8 +192,9 @@ static int node_group_ungroup(Main *bmain, bNodeTree *ntree, bNode *gnode) ngroup = (bNodeTree *)gnode->id; /* clear new pointers, set in copytree */ - for (node = ntree->nodes.first; node; node = node->next) + for (node = ntree->nodes.first; node; node = node->next) { node->new_node = NULL; + } /* wgroup is a temporary copy of the NodeTree we're merging in * - all of wgroup's nodes are transferred across to their new home @@ -217,8 +225,9 @@ static int node_group_ungroup(Main *bmain, bNodeTree *ntree, bNode *gnode) RNA_pointer_create(&wgroup->id, &RNA_Node, node, &ptr); path = RNA_path_from_ID_to_struct(&ptr); - if (path) + if (path) { BLI_addtail(&anim_basepaths, BLI_genericNodeN(path)); + } } /* migrate node */ @@ -359,8 +368,9 @@ static int node_group_ungroup_exec(bContext *C, wmOperator *op) ED_preview_kill_jobs(CTX_wm_manager(C), bmain); gnode = node_group_get_active(C, node_idname); - if (!gnode) + if (!gnode) { return OPERATOR_CANCELLED; + } if (gnode->id && node_group_ungroup(bmain, snode->edittree, gnode)) { ntreeUpdateTree(bmain, snode->nodetree); @@ -402,18 +412,21 @@ static int node_group_separate_selected( ListBase anim_basepaths = {NULL, NULL}; /* deselect all nodes in the target tree */ - for (node = ntree->nodes.first; node; node = node->next) + for (node = ntree->nodes.first; node; node = node->next) { nodeSetSelected(node, false); + } /* clear new pointers, set in BKE_node_copy_ex(). */ - for (node = ngroup->nodes.first; node; node = node->next) + for (node = ngroup->nodes.first; node; node = node->next) { node->new_node = NULL; + } /* add selected nodes into the ntree */ for (node = ngroup->nodes.first; node; node = node_next) { node_next = node->next; - if (!(node->flag & NODE_SELECT)) + if (!(node->flag & NODE_SELECT)) { continue; + } /* ignore interface nodes */ if (ELEM(node->type, NODE_GROUP_INPUT, NODE_GROUP_OUTPUT)) { @@ -440,13 +453,15 @@ static int node_group_separate_selected( RNA_pointer_create(&ngroup->id, &RNA_Node, newnode, &ptr); path = RNA_path_from_ID_to_struct(&ptr); - if (path) + if (path) { BLI_addtail(&anim_basepaths, BLI_genericNodeN(path)); + } } /* ensure valid parent pointers, detach if parent stays inside the group */ - if (newnode->parent && !(newnode->parent->flag & NODE_SELECT)) + if (newnode->parent && !(newnode->parent->flag & NODE_SELECT)) { nodeDetachNode(newnode); + } /* migrate node */ BLI_remlink(&ngroup->nodes, newnode); @@ -469,8 +484,9 @@ static int node_group_separate_selected( if (make_copy) { /* make a copy of internal links */ - if (fromselect && toselect) + if (fromselect && toselect) { nodeAddLink(ntree, link->fromnode->new_node, link->fromsock->new_sock, link->tonode->new_node, link->tosock->new_sock); + } } else { /* move valid links over, delete broken links */ @@ -502,8 +518,9 @@ static int node_group_separate_selected( } ntree->update |= NTREE_UPDATE_NODES | NTREE_UPDATE_LINKS; - if (!make_copy) + if (!make_copy) { ngroup->update |= NTREE_UPDATE_NODES | NTREE_UPDATE_LINKS; + } return 1; } @@ -633,16 +650,19 @@ static bool node_group_make_test_selected(bNodeTree *ntree, bNode *gnode, const /* free local pseudo node tree again */ ntreeFreeTree(ngroup); MEM_freeN(ngroup); - if (!ok) + if (!ok) { return false; + } /* check if all connections are OK, no unselected node has both * inputs and outputs to a selection */ for (link = ntree->links.first; link; link = link->next) { - if (node_group_make_use_node(link->fromnode, gnode)) + if (node_group_make_use_node(link->fromnode, gnode)) { link->tonode->done |= 1; - if (node_group_make_use_node(link->tonode, gnode)) + } + if (node_group_make_use_node(link->tonode, gnode)) { link->fromnode->done |= 2; + } } for (node = ntree->nodes.first; node; node = node->next) { if (!(node->flag & NODE_SELECT) && @@ -696,16 +716,18 @@ static void node_group_make_insert_selected(const bContext *C, bNodeTree *ntree, static const float offsety = 0.0f; /* deselect all nodes in the target tree */ - for (node = ngroup->nodes.first; node; node = node->next) + for (node = ngroup->nodes.first; node; node = node->next) { nodeSetSelected(node, false); + } totselect = node_get_selected_minmax(ntree, gnode, min, max); add_v2_v2v2(center, min, max); mul_v2_fl(center, 0.5f); /* auto-add interface for "solo" nodes */ - if (totselect == 1) + if (totselect == 1) { expose_all = true; + } /* move nodes over */ for (node = ntree->nodes.first; node; node = nextn) { @@ -721,13 +743,15 @@ static void node_group_make_insert_selected(const bContext *C, bNodeTree *ntree, RNA_pointer_create(&ntree->id, &RNA_Node, node, &ptr); path = RNA_path_from_ID_to_struct(&ptr); - if (path) + if (path) { BLI_addtail(&anim_basepaths, BLI_genericNodeN(path)); + } } /* ensure valid parent pointers, detach if parent stays outside the group */ - if (node->parent && !(node->parent->flag & NODE_SELECT)) + if (node->parent && !(node->parent->flag & NODE_SELECT)) { nodeDetachNode(node); + } /* change node-collection membership */ BLI_remlink(&ntree->nodes, node); @@ -857,8 +881,9 @@ static void node_group_make_insert_selected(const bContext *C, bNodeTree *ntree, break; } } - if (skip) + if (skip) { continue; + } iosock = ntreeAddSocketInterfaceFromSocket(ngroup, node, sock); @@ -872,11 +897,14 @@ static void node_group_make_insert_selected(const bContext *C, bNodeTree *ntree, for (sock = node->outputs.first; sock; sock = sock->next) { bNodeSocket *iosock, *output_sock; bool skip = false; - for (link = ngroup->links.first; link; link = link->next) - if (link->fromsock == sock) + for (link = ngroup->links.first; link; link = link->next) { + if (link->fromsock == sock) { skip = true; - if (skip) + } + } + if (skip) { continue; + } iosock = ntreeAddSocketInterfaceFromSocket(ngroup, node, sock); @@ -906,8 +934,9 @@ static bNode *node_group_make_from_selected(const bContext *C, bNodeTree *ntree, totselect = node_get_selected_minmax(ntree, NULL, min, max); /* don't make empty group */ - if (totselect == 0) + if (totselect == 0) { return NULL; + } /* new nodetree */ ngroup = ntreeAddTree(bmain, "NodeGroup", ntreetype); @@ -939,8 +968,9 @@ static int node_group_make_exec(bContext *C, wmOperator *op) ED_preview_kill_jobs(CTX_wm_manager(C), CTX_data_main(C)); - if (!node_group_make_test_selected(ntree, NULL, ntree_idname, op->reports)) + if (!node_group_make_test_selected(ntree, NULL, ntree_idname, op->reports)) { return OPERATOR_CANCELLED; + } gnode = node_group_make_from_selected(C, ntree, node_idname, ntree_idname); @@ -995,12 +1025,14 @@ static int node_group_insert_exec(bContext *C, wmOperator *op) gnode = node_group_get_active(C, node_idname); - if (!gnode || !gnode->id) + if (!gnode || !gnode->id) { return OPERATOR_CANCELLED; + } ngroup = (bNodeTree *)gnode->id; - if (!node_group_make_test_selected(ntree, gnode, ngroup->idname, op->reports)) + if (!node_group_make_test_selected(ntree, gnode, ngroup->idname, op->reports)) { return OPERATOR_CANCELLED; + } node_group_make_insert_selected(C, ntree, gnode); diff --git a/source/blender/editors/space_node/node_relationships.c b/source/blender/editors/space_node/node_relationships.c index 1aaf0baae6d..55a3da6f77c 100644 --- a/source/blender/editors/space_node/node_relationships.c +++ b/source/blender/editors/space_node/node_relationships.c @@ -200,19 +200,23 @@ static int sort_nodes_locx(const void *a, const void *b) const bNode *node1 = nli1->node; const bNode *node2 = nli2->node; - if (node1->locx > node2->locx) + if (node1->locx > node2->locx) { return 1; - else + } + else { return 0; + } } static bool socket_is_available(bNodeTree *UNUSED(ntree), bNodeSocket *sock, const bool allow_used) { - if (nodeSocketIsHidden(sock)) + if (nodeSocketIsHidden(sock)) { return 0; + } - if (!allow_used && (sock->flag & SOCK_IN_USE)) + if (!allow_used && (sock->flag & SOCK_IN_USE)) { return 0; + } return 1; } @@ -223,30 +227,35 @@ static bNodeSocket *best_socket_output(bNodeTree *ntree, bNode *node, bNodeSocke /* first look for selected output */ for (sock = node->outputs.first; sock; sock = sock->next) { - if (!socket_is_available(ntree, sock, allow_multiple)) + if (!socket_is_available(ntree, sock, allow_multiple)) { continue; + } - if (sock->flag & SELECT) + if (sock->flag & SELECT) { return sock; + } } /* try to find a socket with a matching name */ for (sock = node->outputs.first; sock; sock = sock->next) { - if (!socket_is_available(ntree, sock, allow_multiple)) + if (!socket_is_available(ntree, sock, allow_multiple)) { continue; + } /* check for same types */ if (sock->type == sock_target->type) { - if (STREQ(sock->name, sock_target->name)) + if (STREQ(sock->name, sock_target->name)) { return sock; + } } } /* otherwise settle for the first available socket of the right type */ for (sock = node->outputs.first; sock; sock = sock->next) { - if (!socket_is_available(ntree, sock, allow_multiple)) + if (!socket_is_available(ntree, sock, allow_multiple)) { continue; + } /* check for same types */ if (sock->type == sock_target->type) { @@ -282,8 +291,9 @@ static bNodeSocket *best_socket_input(bNodeTree *ntree, bNode *node, int num, in /* increment to make sure we don't keep finding * the same socket on every attempt running this function */ a++; - if (a > num) + if (a > num) { return sock; + } } } } @@ -296,8 +306,9 @@ static bool snode_autoconnect_input(SpaceNode *snode, bNode *node_fr, bNodeSocke bNodeTree *ntree = snode->edittree; /* then we can connect */ - if (replace) + if (replace) { nodeRemSocketLinks(ntree, sock_to); + } nodeAddLink(ntree, node_fr, sock_fr, node_to, sock_to); return true; @@ -327,7 +338,9 @@ static void snode_autoconnect(Main *bmain, SpaceNode *snode, const bool allow_mu bNodeSocket *sock_fr, *sock_to; bool has_selected_inputs = false; - if (nli->next == NULL) break; + if (nli->next == NULL) { + break; + } node_fr = nli->node; node_to = nli->next->node; @@ -341,13 +354,15 @@ static void snode_autoconnect(Main *bmain, SpaceNode *snode, const bool allow_mu if (sock_to->flag & SELECT) { has_selected_inputs = 1; - if (!socket_is_available(ntree, sock_to, replace)) + if (!socket_is_available(ntree, sock_to, replace)) { continue; + } /* check for an appropriate output socket to connect from */ sock_fr = best_socket_output(ntree, node_fr, sock_to, allow_multiple); - if (!sock_fr) + if (!sock_fr) { continue; + } if (snode_autoconnect_input(snode, node_fr, sock_fr, node_to, sock_to, replace)) { numlinks++; @@ -363,13 +378,15 @@ static void snode_autoconnect(Main *bmain, SpaceNode *snode, const bool allow_mu /* find the best guess input socket */ sock_to = best_socket_input(ntree, node_to, i, replace); - if (!sock_to) + if (!sock_to) { continue; + } /* check for an appropriate output socket to connect from */ sock_fr = best_socket_output(ntree, node_fr, sock_to, allow_multiple); - if (!sock_fr) + if (!sock_fr) { continue; + } if (snode_autoconnect_input(snode, node_fr, sock_fr, node_to, sock_to, replace)) { numlinks++; @@ -397,16 +414,21 @@ static int node_link_viewer(const bContext *C, bNode *tonode) bNodeSocket *sock; /* context check */ - if (tonode == NULL || BLI_listbase_is_empty(&tonode->outputs)) + if (tonode == NULL || BLI_listbase_is_empty(&tonode->outputs)) { return OPERATOR_CANCELLED; - if (ELEM(tonode->type, CMP_NODE_VIEWER, CMP_NODE_SPLITVIEWER)) + } + if (ELEM(tonode->type, CMP_NODE_VIEWER, CMP_NODE_SPLITVIEWER)) { return OPERATOR_CANCELLED; + } /* get viewer */ - for (node = snode->edittree->nodes.first; node; node = node->next) - if (ELEM(node->type, CMP_NODE_VIEWER, CMP_NODE_SPLITVIEWER)) - if (node->flag & NODE_DO_OUTPUT) + for (node = snode->edittree->nodes.first; node; node = node->next) { + if (ELEM(node->type, CMP_NODE_VIEWER, CMP_NODE_SPLITVIEWER)) { + if (node->flag & NODE_DO_OUTPUT) { break; + } + } + } /* no viewer, we make one active */ if (node == NULL) { for (node = snode->edittree->nodes.first; node; node = node->next) { @@ -422,19 +444,24 @@ static int node_link_viewer(const bContext *C, bNode *tonode) /* try to find an already connected socket to cycle to the next */ if (node) { link = NULL; - for (link = snode->edittree->links.first; link; link = link->next) - if (link->tonode == node && link->fromnode == tonode) - if (link->tosock == node->inputs.first) + for (link = snode->edittree->links.first; link; link = link->next) { + if (link->tonode == node && link->fromnode == tonode) { + if (link->tosock == node->inputs.first) { break; + } + } + } if (link) { /* unlink existing connection */ sock = link->fromsock; nodeRemLink(snode->edittree, link); /* find a socket after the previously connected socket */ - for (sock = sock->next; sock; sock = sock->next) - if (!nodeSocketIsHidden(sock)) + for (sock = sock->next; sock; sock = sock->next) { + if (!nodeSocketIsHidden(sock)) { break; + } + } } } @@ -451,9 +478,11 @@ static int node_link_viewer(const bContext *C, bNode *tonode) /* find a socket starting from the first socket */ if (!sock) { - for (sock = tonode->outputs.first; sock; sock = sock->next) - if (!nodeSocketIsHidden(sock)) + for (sock = tonode->outputs.first; sock; sock = sock->next) { + if (!nodeSocketIsHidden(sock)) { break; + } + } } if (sock) { @@ -461,16 +490,19 @@ static int node_link_viewer(const bContext *C, bNode *tonode) if (!node) { /* XXX location is a quick hack, just place it next to the linked socket */ node = node_add_node(C, NULL, CMP_NODE_VIEWER, sock->locx + 100, sock->locy); - if (!node) + if (!node) { return OPERATOR_CANCELLED; + } link = NULL; } else { /* get link to viewer */ - for (link = snode->edittree->links.first; link; link = link->next) - if (link->tonode == node && link->tosock == node->inputs.first) + for (link = snode->edittree->links.first; link; link = link->next) { + if (link->tonode == node && link->tosock == node->inputs.first) { break; + } + } } if (link == NULL) { @@ -497,13 +529,15 @@ static int node_active_link_viewer_exec(bContext *C, wmOperator *UNUSED(op)) node = nodeGetActive(snode->edittree); - if (!node) + if (!node) { return OPERATOR_CANCELLED; + } ED_preview_kill_jobs(CTX_wm_manager(C), CTX_data_main(C)); - if (node_link_viewer(C, node) == OPERATOR_CANCELLED) + if (node_link_viewer(C, node) == OPERATOR_CANCELLED) { return OPERATOR_CANCELLED; + } snode_notify(C, snode); @@ -542,10 +576,12 @@ static int node_count_links(bNodeTree *ntree, bNodeSocket *sock) bNodeLink *link; int count = 0; for (link = ntree->links.first; link; link = link->next) { - if (link->fromsock == sock) + if (link->fromsock == sock) { ++count; - if (link->tosock == sock) + } + if (link->tosock == sock) { ++count; + } } return count; } @@ -560,8 +596,9 @@ static void node_remove_extra_links(SpaceNode *snode, bNodeLink *link) for (tlink = ntree->links.first; tlink; tlink = tlink_next) { tlink_next = tlink->next; - if (tlink == link) + if (tlink == link) { continue; + } if (tlink && tlink->fromsock == from) { if (from_count > from->limit) { @@ -605,10 +642,12 @@ static void node_link_exit(bContext *C, wmOperator *op, bool apply_links) /* before actually adding the link, * let nodes perform special link insertion handling */ - if (link->fromnode->typeinfo->insert_link) + if (link->fromnode->typeinfo->insert_link) { link->fromnode->typeinfo->insert_link(ntree, link->fromnode, link); - if (link->tonode->typeinfo->insert_link) + } + if (link->tonode->typeinfo->insert_link) { link->tonode->typeinfo->insert_link(ntree, link->tonode, link); + } /* add link to the node tree */ BLI_addtail(&ntree->links, link); @@ -657,11 +696,13 @@ static void node_link_find_socket(bContext *C, wmOperator *op, float cursor[2]) bNodeLink *link = linkdata->data; /* skip if this is already the target socket */ - if (link->tosock == tsock) + if (link->tosock == tsock) { continue; + } /* skip if socket is on the same node as the fromsock */ - if (tnode && link->fromnode == tnode) + if (tnode && link->fromnode == tnode) { continue; + } /* attach links to the socket */ link->tonode = tnode; @@ -683,11 +724,13 @@ static void node_link_find_socket(bContext *C, wmOperator *op, float cursor[2]) bNodeLink *link = linkdata->data; /* skip if this is already the target socket */ - if (link->fromsock == tsock) + if (link->fromsock == tsock) { continue; + } /* skip if socket is on the same node as the fromsock */ - if (tnode && link->tonode == tnode) + if (tnode && link->tonode == tnode) { continue; + } /* attach links to the socket */ link->fromnode = tnode; @@ -829,8 +872,9 @@ static bNodeLinkDrag *node_link_init(Main *bmain, SpaceNode *snode, float cursor nodeRemLink(snode->edittree, link); /* send changed event to original link->tonode */ - if (node) + if (node) { snode_update(snode, node); + } } } } @@ -881,8 +925,9 @@ static int node_link_invoke(bContext *C, wmOperator *op, const wmEvent *event) return OPERATOR_RUNNING_MODAL; } - else + else { return OPERATOR_CANCELLED | OPERATOR_PASS_THROUGH; + } } static void node_link_cancel(bContext *C, wmOperator *op) @@ -965,10 +1010,13 @@ static bool cut_links_intersect(bNodeLink *link, float mcoords[][2], int tot) if (node_link_bezier_points(NULL, NULL, link, coord_array, NODE_LINK_RESOL)) { - for (i = 0; i < tot - 1; i++) - for (b = 0; b < NODE_LINK_RESOL; b++) - if (isect_seg_seg_v2(mcoords[i], mcoords[i + 1], coord_array[b], coord_array[b + 1]) > 0) + for (i = 0; i < tot - 1; i++) { + for (b = 0; b < NODE_LINK_RESOL; b++) { + if (isect_seg_seg_v2(mcoords[i], mcoords[i + 1], coord_array[b], coord_array[b + 1]) > 0) { return 1; + } + } + } } return 0; } @@ -990,7 +1038,9 @@ static int cut_links_exec(bContext *C, wmOperator *op) UI_view2d_region_to_view(&ar->v2d, (int)loc[0], (int)loc[1], &mcoords[i][0], &mcoords[i][1]); i++; - if (i >= 256) break; + if (i >= 256) { + break; + } } RNA_END; @@ -1002,8 +1052,9 @@ static int cut_links_exec(bContext *C, wmOperator *op) for (link = snode->edittree->links.first; link; link = next) { next = link->next; - if (nodeLinkIsHidden(link)) + if (nodeLinkIsHidden(link)) { continue; + } if (cut_links_intersect(link, mcoords, i)) { @@ -1108,12 +1159,14 @@ static int node_parent_set_exec(bContext *C, wmOperator *UNUSED(op)) SpaceNode *snode = CTX_wm_space_node(C); bNodeTree *ntree = snode->edittree; bNode *frame = nodeGetActive(ntree), *node; - if (!frame || frame->type != NODE_FRAME) + if (!frame || frame->type != NODE_FRAME) { return OPERATOR_CANCELLED; + } for (node = ntree->nodes.first; node; node = node->next) { - if (node == frame) + if (node == frame) { continue; + } if (node->flag & NODE_SELECT) { nodeDetachNode(node); nodeAttachNode(node, frame); @@ -1156,12 +1209,14 @@ static void node_join_attach_recursive(bNode *node, bNode *frame) } else if (node->parent) { /* call recursively */ - if (!(node->parent->done & NODE_JOIN_DONE)) + if (!(node->parent->done & NODE_JOIN_DONE)) { node_join_attach_recursive(node->parent, frame); + } /* in any case: if the parent is a descendant, so is the child */ - if (node->parent->done & NODE_JOIN_IS_DESCENDANT) + if (node->parent->done & NODE_JOIN_IS_DESCENDANT) { node->done |= NODE_JOIN_IS_DESCENDANT; + } else if (node->flag & NODE_TEST) { /* if parent is not an descendant of the frame, reattach the node */ nodeDetachNode(node); @@ -1184,27 +1239,32 @@ static int node_join_exec(bContext *C, wmOperator *UNUSED(op)) /* XXX save selection: node_add_node call below sets the new frame as single * active+selected node */ for (node = ntree->nodes.first; node; node = node->next) { - if (node->flag & NODE_SELECT) + if (node->flag & NODE_SELECT) { node->flag |= NODE_TEST; - else + } + else { node->flag &= ~NODE_TEST; + } } frame = node_add_node(C, NULL, NODE_FRAME, 0.0f, 0.0f); /* reset tags */ - for (node = ntree->nodes.first; node; node = node->next) + for (node = ntree->nodes.first; node; node = node->next) { node->done = 0; + } for (node = ntree->nodes.first; node; node = node->next) { - if (!(node->done & NODE_JOIN_DONE)) + if (!(node->done & NODE_JOIN_DONE)) { node_join_attach_recursive(node, frame); + } } /* restore selection */ for (node = ntree->nodes.first; node; node = node->next) { - if (node->flag & NODE_TEST) + if (node->flag & NODE_TEST) { node->flag |= NODE_SELECT; + } } ED_node_sort(ntree); @@ -1241,10 +1301,12 @@ static bNode *node_find_frame_to_attach(ARegion *ar, const bNodeTree *ntree, con /* check nodes front to back */ for (frame = ntree->nodes.last; frame; frame = frame->prev) { /* skip selected, those are the nodes we want to attach */ - if ((frame->type != NODE_FRAME) || (frame->flag & NODE_SELECT)) + if ((frame->type != NODE_FRAME) || (frame->flag & NODE_SELECT)) { continue; - if (BLI_rctf_isect_pt_v(&frame->totr, cursor)) + } + if (BLI_rctf_isect_pt_v(&frame->totr, cursor)) { return frame; + } } return NULL; @@ -1323,12 +1385,14 @@ static void node_detach_recursive(bNode *node) if (node->parent) { /* call recursively */ - if (!(node->parent->done & NODE_DETACH_DONE)) + if (!(node->parent->done & NODE_DETACH_DONE)) { node_detach_recursive(node->parent); + } /* in any case: if the parent is a descendant, so is the child */ - if (node->parent->done & NODE_DETACH_IS_DESCENDANT) + if (node->parent->done & NODE_DETACH_IS_DESCENDANT) { node->done |= NODE_DETACH_IS_DESCENDANT; + } else if (node->flag & NODE_SELECT) { /* if parent is not a descendant of a selected node, detach */ nodeDetachNode(node); @@ -1349,14 +1413,16 @@ static int node_detach_exec(bContext *C, wmOperator *UNUSED(op)) bNode *node; /* reset tags */ - for (node = ntree->nodes.first; node; node = node->next) + for (node = ntree->nodes.first; node; node = node->next) { node->done = 0; + } /* detach nodes recursively * relative order is preserved here! */ for (node = ntree->nodes.first; node; node = node->next) { - if (!(node->done & NODE_DETACH_DONE)) + if (!(node->done & NODE_DETACH_DONE)) { node_detach_recursive(node); + } } ED_node_sort(ntree); @@ -1394,8 +1460,9 @@ static bool ed_node_link_conditions(ScrArea *sa, bool test, SpaceNode **r_snode, *r_select = NULL; /* no unlucky accidents */ - if (sa == NULL || sa->spacetype != SPACE_NODE) + if (sa == NULL || sa->spacetype != SPACE_NODE) { return false; + } if (!test) { /* no need to look for a node */ @@ -1404,27 +1471,33 @@ static bool ed_node_link_conditions(ScrArea *sa, bool test, SpaceNode **r_snode, for (node = snode->edittree->nodes.first; node; node = node->next) { if (node->flag & SELECT) { - if (select) + if (select) { break; - else + } + else { select = node; + } } } /* only one selected */ - if (node || select == NULL) + if (node || select == NULL) { return false; + } /* correct node */ - if (BLI_listbase_is_empty(&select->inputs) || BLI_listbase_is_empty(&select->outputs)) + if (BLI_listbase_is_empty(&select->inputs) || BLI_listbase_is_empty(&select->outputs)) { return false; + } /* test node for links */ for (link = snode->edittree->links.first; link; link = link->next) { - if (nodeLinkIsHidden(link)) + if (nodeLinkIsHidden(link)) { continue; + } - if (link->tonode == select || link->fromnode == select) + if (link->tonode == select || link->fromnode == select) { return false; + } } *r_select = select; @@ -1439,20 +1512,26 @@ void ED_node_link_intersect_test(ScrArea *sa, int test) bNodeLink *link, *selink = NULL; float dist_best = FLT_MAX; - if (!ed_node_link_conditions(sa, test, &snode, &select)) return; + if (!ed_node_link_conditions(sa, test, &snode, &select)) { + return; + } /* clear flags */ - for (link = snode->edittree->links.first; link; link = link->next) + for (link = snode->edittree->links.first; link; link = link->next) { link->flag &= ~NODE_LINKFLAG_HILITE; + } - if (test == 0) return; + if (test == 0) { + return; + } /* find link to select/highlight */ for (link = snode->edittree->links.first; link; link = link->next) { float coord_array[NODE_LINK_RESOL + 1][2]; - if (nodeLinkIsHidden(link)) + if (nodeLinkIsHidden(link)) { continue; + } if (node_link_bezier_points(NULL, NULL, link, coord_array, NODE_LINK_RESOL)) { float dist = FLT_MAX; @@ -1482,8 +1561,9 @@ void ED_node_link_intersect_test(ScrArea *sa, int test) } } - if (selink) + if (selink) { selink->flag |= NODE_LINKFLAG_HILITE; + } } /* assumes sockets in list */ @@ -1493,8 +1573,9 @@ static bNodeSocket *socket_best_match(ListBase *sockets) int type, maxtype = 0; /* find type range */ - for (sock = sockets->first; sock; sock = sock->next) + for (sock = sockets->first; sock; sock = sock->next) { maxtype = max_ii(sock->type, maxtype); + } /* try all types, starting from 'highest' (i.e. colors, vectors, values) */ for (type = maxtype; type >= 0; --type) { @@ -1670,8 +1751,9 @@ static void node_link_insert_offset_ntree( /* check nodes front to back */ for (frame = ntree->nodes.last; frame; frame = frame->prev) { /* skip selected, those are the nodes we want to attach */ - if ((frame->type != NODE_FRAME) || (frame->flag & NODE_SELECT)) + if ((frame->type != NODE_FRAME) || (frame->flag & NODE_SELECT)) { continue; + } /* for some reason frame y coords aren't correct yet */ node_to_updated_rect(frame, &totr_frame); @@ -1757,8 +1839,9 @@ static int node_insert_offset_modal(bContext *C, wmOperator *UNUSED(op), const w float duration; bool redraw = false; - if (!snode || event->type != TIMER || iofsd == NULL || iofsd->anim_timer != event->customdata) + if (!snode || event->type != TIMER || iofsd == NULL || iofsd->anim_timer != event->customdata) { return OPERATOR_PASS_THROUGH; + } duration = (float)iofsd->anim_timer->duration; @@ -1808,8 +1891,9 @@ static int node_insert_offset_invoke(bContext *C, wmOperator *op, const wmEvent const SpaceNode *snode = CTX_wm_space_node(C); NodeInsertOfsData *iofsd = snode->iofsd; - if (!iofsd || !iofsd->insert) + if (!iofsd || !iofsd->insert) { return OPERATOR_CANCELLED; + } BLI_assert((snode->flag & SNODE_SKIP_INSOFFSET) == 0); @@ -1850,12 +1934,16 @@ void ED_node_link_insert(Main *bmain, ScrArea *sa) bNodeLink *link; bNodeSocket *sockto; - if (!ed_node_link_conditions(sa, true, &snode, &select)) return; + if (!ed_node_link_conditions(sa, true, &snode, &select)) { + return; + } /* get the link */ - for (link = snode->edittree->links.first; link; link = link->next) - if (link->flag & NODE_LINKFLAG_HILITE) + for (link = snode->edittree->links.first; link; link = link->next) { + if (link->flag & NODE_LINKFLAG_HILITE) { break; + } + } if (link) { bNodeSocket *best_input = socket_best_match(&select->inputs); diff --git a/source/blender/editors/space_node/node_select.c b/source/blender/editors/space_node/node_select.c index a329958db5e..a027481ff27 100644 --- a/source/blender/editors/space_node/node_select.c +++ b/source/blender/editors/space_node/node_select.c @@ -64,8 +64,9 @@ static bNode *node_under_mouse_select(bNodeTree *ntree, int mx, int my) for (node = ntree->nodes.last; node; node = node->prev) { if (node->typeinfo->select_area_func) { - if (node->typeinfo->select_area_func(node, mx, my)) + if (node->typeinfo->select_area_func(node, mx, my)) { return node; + } } } return NULL; @@ -77,8 +78,9 @@ static bNode *node_under_mouse_tweak(bNodeTree *ntree, int mx, int my) for (node = ntree->nodes.last; node; node = node->prev) { if (node->typeinfo->tweak_area_func) { - if (node->typeinfo->tweak_area_func(node, mx, my)) + if (node->typeinfo->tweak_area_func(node, mx, my)) { return node; + } } } return NULL; @@ -118,8 +120,9 @@ void node_socket_select(bNode *node, bNodeSocket *sock) sock->flag |= SELECT; /* select node too */ - if (node) + if (node) { node->flag |= SELECT; + } } void node_socket_deselect(bNode *node, bNodeSocket *sock, const bool deselect_node) @@ -143,17 +146,20 @@ void node_socket_deselect(bNode *node, bNodeSocket *sock, const bool deselect_no } } - if (!sel) + if (!sel) { node->flag &= ~SELECT; + } } } static void node_socket_toggle(bNode *node, bNodeSocket *sock, int deselect_node) { - if (sock->flag & SELECT) + if (sock->flag & SELECT) { node_socket_deselect(node, sock, deselect_node); - else + } + else { node_socket_select(node, sock); + } } /* no undo here! */ @@ -161,8 +167,9 @@ void node_deselect_all(SpaceNode *snode) { bNode *node; - for (node = snode->edittree->nodes.first; node; node = node->next) + for (node = snode->edittree->nodes.first; node; node = node->next) { nodeSetSelected(node, false); + } } void node_deselect_all_input_sockets(SpaceNode *snode, const bool deselect_nodes) @@ -178,8 +185,9 @@ void node_deselect_all_input_sockets(SpaceNode *snode, const bool deselect_nodes for (node = snode->edittree->nodes.first; node; node = node->next) { int sel = 0; - for (sock = node->inputs.first; sock; sock = sock->next) + for (sock = node->inputs.first; sock; sock = sock->next) { sock->flag &= ~SELECT; + } /* if no selected sockets remain, also deselect the node */ if (deselect_nodes) { @@ -190,8 +198,9 @@ void node_deselect_all_input_sockets(SpaceNode *snode, const bool deselect_nodes } } - if (!sel) + if (!sel) { node->flag &= ~SELECT; + } } } } @@ -209,8 +218,9 @@ void node_deselect_all_output_sockets(SpaceNode *snode, const bool deselect_node for (node = snode->edittree->nodes.first; node; node = node->next) { bool sel = false; - for (sock = node->outputs.first; sock; sock = sock->next) + for (sock = node->outputs.first; sock; sock = sock->next) { sock->flag &= ~SELECT; + } /* if no selected sockets remain, also deselect the node */ if (deselect_nodes) { @@ -221,8 +231,9 @@ void node_deselect_all_output_sockets(SpaceNode *snode, const bool deselect_node } } - if (!sel) + if (!sel) { node->flag &= ~SELECT; + } } } } @@ -397,9 +408,11 @@ void node_select_single(bContext *C, bNode *node) SpaceNode *snode = CTX_wm_space_node(C); bNode *tnode; - for (tnode = snode->edittree->nodes.first; tnode; tnode = tnode->next) - if (tnode != node) + for (tnode = snode->edittree->nodes.first; tnode; tnode = tnode->next) { + if (tnode != node) { nodeSetSelected(tnode, false); + } + } nodeSetSelected(node, true); ED_node_set_active(bmain, snode->edittree, node); @@ -440,8 +453,9 @@ static int node_mouse_select(Main *bmain, SpaceNode *snode, ARegion *ar, const i /* only allow one selected output per node, for sensible linking. * allows selecting outputs from different nodes though. */ if (node) { - for (tsock = node->outputs.first; tsock; tsock = tsock->next) + for (tsock = node->outputs.first; tsock; tsock = tsock->next) { node_socket_deselect(node, tsock, 1); + } } if (extend) { /* only allow one selected output per node, for sensible linking. @@ -857,19 +871,23 @@ static int node_select_linked_to_exec(bContext *C, wmOperator *UNUSED(op)) bNodeLink *link; bNode *node; - for (node = snode->edittree->nodes.first; node; node = node->next) + for (node = snode->edittree->nodes.first; node; node = node->next) { node->flag &= ~NODE_TEST; + } for (link = snode->edittree->links.first; link; link = link->next) { - if (nodeLinkIsHidden(link)) + if (nodeLinkIsHidden(link)) { continue; - if (link->fromnode && link->tonode && (link->fromnode->flag & NODE_SELECT)) + } + if (link->fromnode && link->tonode && (link->fromnode->flag & NODE_SELECT)) { link->tonode->flag |= NODE_TEST; + } } for (node = snode->edittree->nodes.first; node; node = node->next) { - if (node->flag & NODE_TEST) + if (node->flag & NODE_TEST) { nodeSetSelected(node, true); + } } ED_node_sort(snode->edittree); @@ -905,19 +923,23 @@ static int node_select_linked_from_exec(bContext *C, wmOperator *UNUSED(op)) bNodeLink *link; bNode *node; - for (node = snode->edittree->nodes.first; node; node = node->next) + for (node = snode->edittree->nodes.first; node; node = node->next) { node->flag &= ~NODE_TEST; + } for (link = snode->edittree->links.first; link; link = link->next) { - if (nodeLinkIsHidden(link)) + if (nodeLinkIsHidden(link)) { continue; - if (link->fromnode && link->tonode && (link->tonode->flag & NODE_SELECT)) + } + if (link->fromnode && link->tonode && (link->tonode->flag & NODE_SELECT)) { link->fromnode->flag |= NODE_TEST; + } } for (node = snode->edittree->nodes.first; node; node = node->next) { - if (node->flag & NODE_TEST) + if (node->flag & NODE_TEST) { nodeSetSelected(node, true); + } } ED_node_sort(snode->edittree); @@ -963,41 +985,55 @@ static int node_select_same_type_step_exec(bContext *C, wmOperator *op) int a; for (a = 0; a < totnodes; a++) { - if (node_array[a] == active) + if (node_array[a] == active) { break; + } } if (same_type) { bNode *node = NULL; while (node == NULL) { - if (revert) a--; - else a++; + if (revert) { + a--; + } + else { + a++; + } - if (a < 0 || a >= totnodes) + if (a < 0 || a >= totnodes) { break; + } node = node_array[a]; - if (node->type == active->type) + if (node->type == active->type) { break; - else node = NULL; + } + else { + node = NULL; + } } - if (node) + if (node) { active = node; + } } else { if (revert) { - if (a == 0) + if (a == 0) { active = node_array[totnodes - 1]; - else + } + else { active = node_array[a - 1]; + } } else { - if (a == totnodes - 1) + if (a == totnodes - 1) { active = node_array[0]; - else + } + else { active = node_array[a + 1]; + } } } @@ -1012,8 +1048,9 @@ static int node_select_same_type_step_exec(bContext *C, wmOperator *op) } } - if (node_array) + if (node_array) { MEM_freeN(node_array); + } return OPERATOR_FINISHED; } @@ -1053,12 +1090,15 @@ static void node_find_cb(const struct bContext *C, void *UNUSED(arg), const char if (BLI_strcasestr(node->name, str) || BLI_strcasestr(node->label, str)) { char name[256]; - if (node->label[0]) + if (node->label[0]) { BLI_snprintf(name, 256, "%s (%s)", node->name, node->label); - else + } + else { BLI_strncpy(name, node->name, 256); - if (false == UI_search_item_add(items, name, node, 0)) + } + if (false == UI_search_item_add(items, name, node, 0)) { break; + } } } } diff --git a/source/blender/editors/space_node/node_templates.c b/source/blender/editors/space_node/node_templates.c index 10cb3ba8d99..aa6fb770c56 100644 --- a/source/blender/editors/space_node/node_templates.c +++ b/source/blender/editors/space_node/node_templates.c @@ -71,8 +71,9 @@ static bool node_link_item_compare(bNode *node, NodeLinkItem *item) if (ELEM(node->type, NODE_GROUP, NODE_CUSTOM_GROUP)) { return (node->id == (ID *)item->ngroup); } - else + else { return true; + } } static void node_link_item_apply(Main *bmain, bNode *node, NodeLinkItem *item) @@ -85,36 +86,43 @@ static void node_link_item_apply(Main *bmain, bNode *node, NodeLinkItem *item) /* nothing to do for now */ } - if (node->id) + if (node->id) { id_us_plus(node->id); + } } static void node_tag_recursive(bNode *node) { bNodeSocket *input; - if (!node || (node->flag & NODE_TEST)) + if (!node || (node->flag & NODE_TEST)) { return; /* in case of cycles */ + } node->flag |= NODE_TEST; - for (input = node->inputs.first; input; input = input->next) - if (input->link) + for (input = node->inputs.first; input; input = input->next) { + if (input->link) { node_tag_recursive(input->link->fromnode); + } + } } static void node_clear_recursive(bNode *node) { bNodeSocket *input; - if (!node || !(node->flag & NODE_TEST)) + if (!node || !(node->flag & NODE_TEST)) { return; /* in case of cycles */ + } node->flag &= ~NODE_TEST; - for (input = node->inputs.first; input; input = input->next) - if (input->link) + for (input = node->inputs.first; input; input = input->next) { + if (input->link) { node_clear_recursive(input->link->fromnode); + } + } } static void node_remove_linked(Main *bmain, bNodeTree *ntree, bNode *rem_node) @@ -122,21 +130,27 @@ static void node_remove_linked(Main *bmain, bNodeTree *ntree, bNode *rem_node) bNode *node, *next; bNodeSocket *sock; - if (!rem_node) + if (!rem_node) { return; + } /* tag linked nodes to be removed */ - for (node = ntree->nodes.first; node; node = node->next) + for (node = ntree->nodes.first; node; node = node->next) { node->flag &= ~NODE_TEST; + } node_tag_recursive(rem_node); /* clear tags on nodes that are still used by other nodes */ - for (node = ntree->nodes.first; node; node = node->next) - if (!(node->flag & NODE_TEST)) - for (sock = node->inputs.first; sock; sock = sock->next) - if (sock->link && sock->link->fromnode != rem_node) + for (node = ntree->nodes.first; node; node = node->next) { + if (!(node->flag & NODE_TEST)) { + for (sock = node->inputs.first; sock; sock = sock->next) { + if (sock->link && sock->link->fromnode != rem_node) { node_clear_recursive(sock->link->fromnode); + } + } + } + } /* remove nodes */ for (node = ntree->nodes.first; node; node = next) { @@ -151,8 +165,9 @@ static void node_remove_linked(Main *bmain, bNodeTree *ntree, bNode *rem_node) /* disconnect socket from the node it is connected to */ static void node_socket_disconnect(Main *bmain, bNodeTree *ntree, bNode *node_to, bNodeSocket *sock_to) { - if (!sock_to->link) + if (!sock_to->link) { return; + } nodeRemLink(ntree, sock_to->link); sock_to->flag |= SOCK_COLLAPSED; @@ -166,8 +181,9 @@ static void node_socket_disconnect(Main *bmain, bNodeTree *ntree, bNode *node_to /* remove all nodes connected to this socket, if they aren't connected to other nodes */ static void node_socket_remove(Main *bmain, bNodeTree *ntree, bNode *node_to, bNodeSocket *sock_to) { - if (!sock_to->link) + if (!sock_to->link) { return; + } node_remove_linked(bmain, ntree, sock_to->link->fromnode); sock_to->flag |= SOCK_COLLAPSED; @@ -194,13 +210,17 @@ static void node_socket_add_replace(const bContext *C, bNodeTree *ntree, bNode * } /* find existing node that we can use */ - for (node_from = ntree->nodes.first; node_from; node_from = node_from->next) - if (node_from->type == type) + for (node_from = ntree->nodes.first; node_from; node_from = node_from->next) { + if (node_from->type == type) { break; + } + } - if (node_from) - if (node_from->inputs.first || node_from->typeinfo->draw_buttons || node_from->typeinfo->draw_buttons_ex) + if (node_from) { + if (node_from->inputs.first || node_from->typeinfo->draw_buttons || node_from->typeinfo->draw_buttons_ex) { node_from = NULL; + } + } if (node_prev && node_prev->type == type && node_link_item_compare(node_prev, item)) { /* keep the previous node if it's the same type */ @@ -236,8 +256,9 @@ static void node_socket_add_replace(const bContext *C, bNodeTree *ntree, bNode * for (sock_prev = node_prev->inputs.first; sock_prev; sock_prev = sock_prev->next) { for (sock_from = node_from->inputs.first; sock_from; sock_from = sock_from->next) { - if (nodeCountSocketLinks(ntree, sock_from) >= sock_from->limit) + if (nodeCountSocketLinks(ntree, sock_from) >= sock_from->limit) { continue; + } if (STREQ(sock_prev->name, sock_from->name) && sock_prev->type == sock_from->type) { bNodeLink *link = sock_prev->link; @@ -332,8 +353,9 @@ static void ui_node_link_items(NodeLinkArg *arg, int in_out, NodeLinkItem **r_it bNodeSocketTemplate *stemp; int i; - for (stemp = socket_templates; stemp && stemp->type != -1; ++stemp) + for (stemp = socket_templates; stemp && stemp->type != -1; ++stemp) { ++totitems; + } if (totitems > 0) { items = MEM_callocN(sizeof(NodeLinkItem) * totitems, "ui node link items"); @@ -363,12 +385,15 @@ static void ui_node_link(bContext *C, void *arg_p, void *event_p) bNodeTree *ntree = arg->ntree; int event = POINTER_AS_INT(event_p); - if (event == UI_NODE_LINK_DISCONNECT) + if (event == UI_NODE_LINK_DISCONNECT) { node_socket_disconnect(bmain, ntree, node_to, sock_to); - else if (event == UI_NODE_LINK_REMOVE) + } + else if (event == UI_NODE_LINK_REMOVE) { node_socket_remove(bmain, ntree, node_to, sock_to); - else + } + else { node_socket_add_replace(C, ntree, node_to, sock_to, arg->node_type->type, &arg->item); + } ED_undo_push(C, "Node input modify"); } @@ -390,10 +415,12 @@ static void ui_node_sock_name(bNodeTree *ntree, bNodeSocket *sock, char name[UI_ BLI_strncpy(name, IFACE_(node_name), UI_MAX_NAME_STR); } } - else if (sock->type == SOCK_SHADER) + else if (sock->type == SOCK_SHADER) { BLI_strncpy(name, IFACE_("None"), UI_MAX_NAME_STR); - else + } + else { BLI_strncpy(name, IFACE_("Default"), UI_MAX_NAME_STR); + } } static int ui_compatible_sockets(int typeA, int typeB) @@ -469,13 +496,16 @@ static void ui_node_menu_column(NodeLinkArg *arg, int nclass, const char *cname) ui_node_link_items(arg, SOCK_OUT, &items, &totitems); - for (i = 0; i < totitems; ++i) - if (ui_compatible_sockets(items[i].socket_type, sock->type)) + for (i = 0; i < totitems; ++i) { + if (ui_compatible_sockets(items[i].socket_type, sock->type)) { num++; + } + } for (i = 0; i < totitems; ++i) { - if (!ui_compatible_sockets(items[i].socket_type, sock->type)) + if (!ui_compatible_sockets(items[i].socket_type, sock->type)) { continue; + } if (first) { column = uiLayoutColumn(layout, 0); @@ -512,8 +542,9 @@ static void ui_node_menu_column(NodeLinkArg *arg, int nclass, const char *cname) UI_but_funcN_set(but, ui_node_link, argN, NULL); } - if (items) + if (items) { MEM_freeN(items); + } } BLI_array_free(sorted_ntypes); @@ -523,8 +554,9 @@ static void node_menu_column_foreach_cb(void *calldata, int nclass, const char * { NodeLinkArg *arg = (NodeLinkArg *)calldata; - if (!ELEM(nclass, NODE_CLASS_GROUP, NODE_CLASS_LAYOUT)) + if (!ELEM(nclass, NODE_CLASS_GROUP, NODE_CLASS_LAYOUT)) { ui_node_menu_column(arg, nclass, name); + } } static void ui_template_node_link_menu(bContext *C, uiLayout *layout, void *but_p) @@ -546,8 +578,9 @@ static void ui_template_node_link_menu(bContext *C, uiLayout *layout, void *but_ arg->scene = scene; arg->layout = split; - if (ntreetype && ntreetype->foreach_nodeclass) + if (ntreetype && ntreetype->foreach_nodeclass) { ntreetype->foreach_nodeclass(scene, arg, node_menu_column_foreach_cb); + } column = uiLayoutColumn(split, false); UI_block_layout_set_current(block, column); @@ -587,8 +620,9 @@ void uiTemplateNodeLink(uiLayout *layout, bNodeTree *ntree, bNode *node, bNodeSo ui_node_sock_name(ntree, sock, name); but = uiDefMenuBut(block, ui_template_node_link_menu, NULL, name, 0, 0, UI_UNIT_X * 4, UI_UNIT_Y, ""); } - else + else { but = uiDefIconMenuBut(block, ui_template_node_link_menu, NULL, ICON_NONE, 0, 0, UI_UNIT_X, UI_UNIT_Y, ""); + } UI_but_type_set_menu_from_pulldown(but); @@ -596,9 +630,11 @@ void uiTemplateNodeLink(uiLayout *layout, bNodeTree *ntree, bNode *node, bNodeSo but->poin = (char *)but; but->func_argN = arg; - if (sock->link && sock->link->fromnode) - if (sock->link->fromnode->flag & NODE_ACTIVE_TEXTURE) + if (sock->link && sock->link->fromnode) { + if (sock->link->fromnode->flag & NODE_ACTIVE_TEXTURE) { but->flag |= UI_BUT_NODE_ACTIVE; + } + } } /**************************** Node Tree Layout *******************************/ @@ -624,8 +660,9 @@ static void ui_node_draw_node(uiLayout *layout, bContext *C, bNodeTree *ntree, b } } - for (input = node->inputs.first; input; input = input->next) + for (input = node->inputs.first; input; input = input->next) { ui_node_draw_input(layout, C, ntree, node, input, depth + 1); + } } static void ui_node_draw_input(uiLayout *layout, bContext *C, bNodeTree *ntree, bNode *node, bNodeSocket *input, int depth) @@ -639,16 +676,18 @@ static void ui_node_draw_input(uiLayout *layout, bContext *C, bNodeTree *ntree, int i, indent = (depth > 1) ? 2 * (depth - 1) : 0; int dependency_loop; - if (input->flag & SOCK_UNAVAIL) + if (input->flag & SOCK_UNAVAIL) { return; + } /* to avoid eternal loops on cyclic dependencies */ node->flag |= NODE_TEST; lnode = (input->link) ? input->link->fromnode : NULL; dependency_loop = (lnode && (lnode->flag & NODE_TEST)); - if (dependency_loop) + if (dependency_loop) { lnode = NULL; + } /* socket RNA pointer */ RNA_pointer_create(&ntree->id, &RNA_NodeSocket, input, &inputptr); @@ -673,8 +712,9 @@ static void ui_node_draw_input(uiLayout *layout, bContext *C, bNodeTree *ntree, int icon = (input->flag & SOCK_COLLAPSED) ? ICON_DISCLOSURE_TRI_RIGHT : ICON_DISCLOSURE_TRI_DOWN; uiItemR(row, &inputptr, "show_expanded", UI_ITEM_R_ICON_ONLY, "", icon); } - else + else { uiItemL(row, "", ICON_BLANK1); + } bt = block->buttons.last; bt->rect.xmax = UI_UNIT_X / 2; @@ -695,8 +735,9 @@ static void ui_node_draw_input(uiLayout *layout, bContext *C, bNodeTree *ntree, uiTemplateNodeLink(split, ntree, node, input); if (depth == 0 || !(input->flag & SOCK_COLLAPSED)) { - if (depth == 0) + if (depth == 0) { uiItemS(layout); + } ui_node_draw_node(layout, C, ntree, lnode, depth); } @@ -724,8 +765,9 @@ static void ui_node_draw_input(uiLayout *layout, bContext *C, bNodeTree *ntree, break; } } - else + else { row = uiLayoutRow(split, false); + } uiTemplateNodeLink(row, ntree, node, input); } @@ -738,15 +780,19 @@ void uiTemplateNodeView(uiLayout *layout, bContext *C, bNodeTree *ntree, bNode * { bNode *tnode; - if (!ntree) + if (!ntree) { return; + } /* clear for cycle check */ - for (tnode = ntree->nodes.first; tnode; tnode = tnode->next) + for (tnode = ntree->nodes.first; tnode; tnode = tnode->next) { tnode->flag &= ~NODE_TEST; + } - if (input) + if (input) { ui_node_draw_input(layout, C, ntree, node, input, 0); - else + } + else { ui_node_draw_node(layout, C, ntree, node, 0); + } } diff --git a/source/blender/editors/space_node/node_toolbar.c b/source/blender/editors/space_node/node_toolbar.c index e2effc84870..dae8024611a 100644 --- a/source/blender/editors/space_node/node_toolbar.c +++ b/source/blender/editors/space_node/node_toolbar.c @@ -49,8 +49,9 @@ static int node_toolbar_toggle_exec(bContext *C, wmOperator *UNUSED(op)) ScrArea *sa = CTX_wm_area(C); ARegion *ar = node_has_tools_region(sa); - if (ar) + if (ar) { ED_region_toggle_hidden(C, ar); + } return OPERATOR_FINISHED; } diff --git a/source/blender/editors/space_node/node_view.c b/source/blender/editors/space_node/node_view.c index d0e6c45bb07..9d4b9d18c2a 100644 --- a/source/blender/editors/space_node/node_view.c +++ b/source/blender/editors/space_node/node_view.c @@ -581,8 +581,9 @@ static int sample_invoke(bContext *C, wmOperator *op, const wmEvent *event) ARegion *ar = CTX_wm_region(C); ImageSampleInfo *info; - if (!ED_node_is_compositor(snode) || !(snode->flag & SNODE_BACKDRAW)) + if (!ED_node_is_compositor(snode) || !(snode->flag & SNODE_BACKDRAW)) { return OPERATOR_CANCELLED; + } info = MEM_callocN(sizeof(ImageSampleInfo), "ImageSampleInfo"); info->art = ar->type; diff --git a/source/blender/editors/space_node/space_node.c b/source/blender/editors/space_node/space_node.c index 1271bf51c5f..22564061aed 100644 --- a/source/blender/editors/space_node/space_node.c +++ b/source/blender/editors/space_node/space_node.c @@ -75,8 +75,9 @@ void ED_node_tree_start(SpaceNode *snode, bNodeTree *ntree, ID *id, ID *from) /* copy initial offset from bNodeTree */ copy_v2_v2(path->view_center, ntree->view_center); - if (id) + if (id) { BLI_strncpy(path->node_name, id->name + 2, sizeof(path->node_name)); + } BLI_addtail(&snode->treepath, path); @@ -99,15 +100,18 @@ void ED_node_tree_push(SpaceNode *snode, bNodeTree *ntree, bNode *gnode) bNodeTreePath *prev_path = snode->treepath.last; path->nodetree = ntree; if (gnode) { - if (prev_path) + if (prev_path) { path->parent_key = BKE_node_instance_key(prev_path->parent_key, prev_path->nodetree, gnode); - else + } + else { path->parent_key = NODE_INSTANCE_KEY_BASE; + } BLI_strncpy(path->node_name, gnode->name, sizeof(path->node_name)); } - else + else { path->parent_key = NODE_INSTANCE_KEY_BASE; + } /* copy initial offset from bNodeTree */ copy_v2_v2(path->view_center, ntree->view_center); @@ -129,8 +133,9 @@ void ED_node_tree_pop(SpaceNode *snode) bNodeTreePath *path = snode->treepath.last; /* don't remove root */ - if (path == snode->treepath.first) + if (path == snode->treepath.first) { return; + } BLI_remlink(&snode->treepath, path); MEM_freeN(path); @@ -155,8 +160,9 @@ bNodeTree *ED_node_tree_get(SpaceNode *snode, int level) bNodeTreePath *path; int i; for (path = snode->treepath.last, i = 0; path; path = path->prev, ++i) { - if (i == level) + if (i == level) { return path->nodetree; + } } return NULL; } @@ -168,8 +174,9 @@ int ED_node_tree_path_length(SpaceNode *snode) int i; for (path = snode->treepath.first, i = 0; path; path = path->next, ++i) { length += strlen(path->node_name); - if (i > 0) + if (i > 0) { length += 1; /* for separator char */ + } } return length; } @@ -206,8 +213,9 @@ void ED_node_tree_path_get_fixedbuf(SpaceNode *snode, char *value, int max_lengt size = BLI_snprintf_rlen(value, max_length, "/%s", path->node_name); } max_length -= size; - if (max_length <= 0) + if (max_length <= 0) { break; + } value += size; } } @@ -230,8 +238,9 @@ void snode_group_offset(SpaceNode *snode, float *x, float *y) *x = dcenter[0]; *y = dcenter[1]; } - else + else { *x = *y = 0.0f; + } } /* ******************** manage regions ********************* */ @@ -241,13 +250,17 @@ ARegion *node_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 node"); @@ -265,13 +278,17 @@ ARegion *node_has_tools_region(ScrArea *sa) ARegion *ar, *arnew; ar = BKE_area_find_region_type(sa, RGN_TYPE_TOOLS); - 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), "node tools"); @@ -393,8 +410,9 @@ static void node_area_listener(wmWindow *UNUSED(win), ScrArea *sa, wmNotifier *w ARegion *ar = BKE_area_find_region_type(sa, RGN_TYPE_WINDOW); bNodeTreePath *path = snode->treepath.last; /* shift view to node tree center */ - if (ar && path) + if (ar && path) { UI_view2d_center_set(&ar->v2d, path->view_center[0], path->view_center[1]); + } ED_area_tag_refresh(sa); break; @@ -422,21 +440,26 @@ static void node_area_listener(wmWindow *UNUSED(win), ScrArea *sa, wmNotifier *w /* future: add ID checks? */ case NC_MATERIAL: if (ED_node_is_shader(snode)) { - if (wmn->data == ND_SHADING) + if (wmn->data == ND_SHADING) { ED_area_tag_refresh(sa); - else if (wmn->data == ND_SHADING_DRAW) + } + else if (wmn->data == ND_SHADING_DRAW) { ED_area_tag_refresh(sa); - else if (wmn->data == ND_SHADING_LINKS) + } + else if (wmn->data == ND_SHADING_LINKS) { ED_area_tag_refresh(sa); - else if (wmn->action == NA_ADDED && snode->edittree) + } + else if (wmn->action == NA_ADDED && snode->edittree) { nodeSetActiveID(snode->edittree, ID_MA, wmn->reference); + } } break; case NC_TEXTURE: if (ED_node_is_shader(snode) || ED_node_is_texture(snode)) { - if (wmn->data == ND_NODES) + if (wmn->data == ND_NODES) { ED_area_tag_refresh(sa); + } } break; case NC_WORLD: @@ -446,21 +469,26 @@ static void node_area_listener(wmWindow *UNUSED(win), ScrArea *sa, wmNotifier *w break; case NC_OBJECT: if (ED_node_is_shader(snode)) { - if (wmn->data == ND_OB_SHADING) + if (wmn->data == ND_OB_SHADING) { ED_area_tag_refresh(sa); + } } break; case NC_SPACE: - if (wmn->data == ND_SPACE_NODE) + if (wmn->data == ND_SPACE_NODE) { ED_area_tag_refresh(sa); - else if (wmn->data == ND_SPACE_NODE_VIEW) + } + else if (wmn->data == ND_SPACE_NODE_VIEW) { ED_area_tag_redraw(sa); + } break; case NC_NODE: - if (wmn->action == NA_EDITED) + if (wmn->action == NA_EDITED) { ED_area_tag_refresh(sa); - else if (wmn->action == NA_SELECTED) + } + else if (wmn->action == NA_SELECTED) { ED_area_tag_redraw(sa); + } break; case NC_SCREEN: switch (wmn->data) { @@ -483,8 +511,9 @@ static void node_area_listener(wmWindow *UNUSED(win), ScrArea *sa, wmNotifier *w /* note that nodeUpdateID is already called by BKE_image_signal() on all * scenes so really this is just to know if the images is used in the compo else * painting on images could become very slow when the compositor is open. */ - if (nodeUpdateID(snode->nodetree, wmn->reference)) + if (nodeUpdateID(snode->nodetree, wmn->reference)) { ED_area_tag_refresh(sa); + } } } break; @@ -492,8 +521,9 @@ static void node_area_listener(wmWindow *UNUSED(win), ScrArea *sa, wmNotifier *w case NC_MOVIECLIP: if (wmn->action == NA_EDITED) { if (ED_node_is_compositor(snode)) { - if (nodeUpdateID(snode->nodetree, wmn->reference)) + if (nodeUpdateID(snode->nodetree, wmn->reference)) { ED_area_tag_refresh(sa); + } } } break; @@ -527,18 +557,21 @@ static void node_area_refresh(const struct bContext *C, ScrArea *sa) if (snode->nodetree->type == NTREE_SHADER) { if (GS(snode->id->name) == ID_MA) { Material *ma = (Material *)snode->id; - if (ma->use_nodes) + if (ma->use_nodes) { ED_preview_shader_job(C, sa, snode->id, NULL, NULL, 100, 100, PR_NODE_RENDER); + } } else if (GS(snode->id->name) == ID_LA) { Light *la = (Light *)snode->id; - if (la->use_nodes) + if (la->use_nodes) { ED_preview_shader_job(C, sa, snode->id, NULL, NULL, 100, 100, PR_NODE_RENDER); + } } else if (GS(snode->id->name) == ID_WO) { World *wo = (World *)snode->id; - if (wo->use_nodes) + if (wo->use_nodes) { ED_preview_shader_job(C, sa, snode->id, NULL, NULL, 100, 100, PR_NODE_RENDER); + } } } else if (snode->nodetree->type == NTREE_COMPOSIT) { @@ -755,8 +788,9 @@ static void node_region_listener( } break; case NC_WM: - if (wmn->data == ND_JOB) + if (wmn->data == ND_JOB) { ED_region_tag_redraw(ar); + } break; case NC_SCENE: ED_region_tag_redraw(ar); @@ -777,18 +811,22 @@ static void node_region_listener( ED_region_tag_redraw(ar); break; case NC_OBJECT: - if (wmn->data == ND_OB_SHADING) + if (wmn->data == ND_OB_SHADING) { 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->action == NA_EDITED) + if (wmn->action == NA_EDITED) { ED_region_tag_redraw(ar); - else if (wmn->data & ND_GPENCIL_EDITMODE) + } + else if (wmn->data & ND_GPENCIL_EDITMODE) { ED_region_tag_redraw(ar); + } break; } } diff --git a/source/blender/editors/space_outliner/outliner_dragdrop.c b/source/blender/editors/space_outliner/outliner_dragdrop.c index d9dc0d182c7..77821ec0990 100644 --- a/source/blender/editors/space_outliner/outliner_dragdrop.c +++ b/source/blender/editors/space_outliner/outliner_dragdrop.c @@ -73,15 +73,17 @@ static TreeElement *outliner_dropzone_element(TreeElement *te, const float fmval { if ((fmval[1] > te->ys) && (fmval[1] < (te->ys + UI_UNIT_Y))) { /* name and first icon */ - if ((fmval[0] > te->xs + UI_UNIT_X) && (fmval[0] < te->xend)) + if ((fmval[0] > te->xs + UI_UNIT_X) && (fmval[0] < te->xend)) { return te; + } } /* Not it. Let's look at its children. */ if (children && (TREESTORE(te)->flag & TSE_CLOSED) == 0 && (te->subtree.first)) { for (te = te->subtree.first; te; te = te->next) { TreeElement *te_valid = outliner_dropzone_element(te, fmval, children); - if (te_valid) + if (te_valid) { return te_valid; + } } } return NULL; @@ -94,8 +96,9 @@ static TreeElement *outliner_dropzone_find(const SpaceOutliner *soops, const flo for (te = soops->tree.first; te; te = te->next) { TreeElement *te_valid = outliner_dropzone_element(te, fmval, children); - if (te_valid) + if (te_valid) { return te_valid; + } } return NULL; } @@ -204,11 +207,15 @@ static TreeElement *outliner_drop_insert_collection_find( TreeElementInsertType *r_insert_type) { TreeElement *te = outliner_drop_insert_find(C, event, r_insert_type); - if (!te) return NULL; + if (!te) { + return NULL; + } TreeElement *collection_te; Collection *collection = outliner_collection_from_tree_element_and_parents(te, &collection_te); - if (!collection) return NULL; + if (!collection) { + return NULL; + } if (collection_te != te) { *r_insert_type = TE_INSERT_INTO; @@ -233,9 +240,15 @@ static bool parent_drop_allowed(SpaceOutliner *soops, TreeElement *te, Object *p Object *potential_parent = (Object *)tselem->id; - if (potential_parent == potential_child) return false; - if (BKE_object_is_child_recursive(potential_child, potential_parent)) return false; - if (potential_parent == potential_child->parent) return false; + if (potential_parent == potential_child) { + return false; + } + if (BKE_object_is_child_recursive(potential_child, potential_parent)) { + return false; + } + if (potential_parent == potential_child->parent) { + return false; + } /* check that parent/child are both in the same scene */ Scene *scene = (Scene *)outliner_search_back(soops, te, ID_SCE); @@ -276,17 +289,25 @@ static bool parent_drop_poll(bContext *C, wmDrag *drag, const wmEvent *event, co SpaceOutliner *soops = CTX_wm_space_outliner(C); bool changed = outliner_flag_set(&soops->tree, TSE_DRAG_ANY, false); - if (changed) ED_region_tag_redraw_no_rebuild(CTX_wm_region(C)); + if (changed) { + ED_region_tag_redraw_no_rebuild(CTX_wm_region(C)); + } Object *potential_child = (Object *)WM_drag_ID(drag, ID_OB); - if (!potential_child) return false; + if (!potential_child) { + return false; + } if (!allow_parenting_without_modifier_key(soops)) { - if (!event->shift) return false; + if (!event->shift) { + return false; + } } TreeElement *te = outliner_drop_find(C, event); - if (!te) return false; + if (!te) { + return false; + } if (parent_drop_allowed(soops, te, potential_child)) { TREESTORE(te)->flag |= TSE_DRAG_INTO; @@ -476,18 +497,26 @@ static bool parent_clear_poll(bContext *C, wmDrag *drag, const wmEvent *event, c SpaceOutliner *soops = CTX_wm_space_outliner(C); if (!allow_parenting_without_modifier_key(soops)) { - if (!event->shift) return false; + if (!event->shift) { + return false; + } } Object *ob = (Object *)WM_drag_ID(drag, ID_OB); - if (!ob) return false; - if (!ob->parent) return false; + if (!ob) { + return false; + } + if (!ob->parent) { + return false; + } TreeElement *te = outliner_drop_find(C, event); if (te) { TreeStoreElem *tselem = TREESTORE(te); ID *id = tselem->id; - if (!id) return true; + if (!id) { + return true; + } switch (GS(id->name)) { case ID_OB: @@ -772,11 +801,15 @@ static bool collection_drop_poll(bContext *C, wmDrag *drag, const wmEvent *event break; } } - if (changed) ED_region_tag_redraw_no_rebuild(ar); + if (changed) { + ED_region_tag_redraw_no_rebuild(ar); + } return true; } else { - if (changed) ED_region_tag_redraw_no_rebuild(ar); + if (changed) { + ED_region_tag_redraw_no_rebuild(ar); + } return false; } } diff --git a/source/blender/editors/space_outliner/outliner_draw.c b/source/blender/editors/space_outliner/outliner_draw.c index 929c179a62f..99d4c587401 100644 --- a/source/blender/editors/space_outliner/outliner_draw.c +++ b/source/blender/editors/space_outliner/outliner_draw.c @@ -125,8 +125,9 @@ static void outliner_rna_width(SpaceOutliner *soops, ListBase *lb, int *w, int s *w = te->xend; } #endif - if (startx + 100 > *w) + if (startx + 100 > *w) { *w = startx + 100; + } if (TSELEM_OPEN(tselem, soops)) { outliner_rna_width(soops, &te->subtree, w, startx + UI_UNIT_X); @@ -194,8 +195,9 @@ static void restrictbutton_r_lay_cb(bContext *C, void *poin, void *UNUSED(poin2) static void restrictbutton_bone_visibility_cb(bContext *C, void *UNUSED(poin), void *poin2) { Bone *bone = (Bone *)poin2; - if (bone->flag & BONE_HIDDEN_P) + if (bone->flag & BONE_HIDDEN_P) { bone->flag &= ~(BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL); + } if (CTX_wm_window(C)->eventstate->ctrl) { restrictbutton_recursive_bone(bone, BONE_HIDDEN_P, (bone->flag & BONE_HIDDEN_P) != 0); @@ -207,8 +209,9 @@ static void restrictbutton_bone_visibility_cb(bContext *C, void *UNUSED(poin), v static void restrictbutton_bone_select_cb(bContext *C, void *UNUSED(poin), void *poin2) { Bone *bone = (Bone *)poin2; - if (bone->flag & BONE_UNSELECTABLE) + if (bone->flag & BONE_UNSELECTABLE) { bone->flag &= ~(BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL); + } if (CTX_wm_window(C)->eventstate->ctrl) { restrictbutton_recursive_bone(bone, BONE_UNSELECTABLE, (bone->flag & BONE_UNSELECTABLE) != 0); @@ -800,8 +803,9 @@ static void outliner_draw_userbuts(uiBlock *block, ARegion *ar, SpaceOutliner *s char buf[16] = ""; int but_flag = UI_BUT_DRAG_LOCK; - if (ID_IS_LINKED(id)) + if (ID_IS_LINKED(id)) { but_flag |= UI_BUT_DISABLED; + } if (id->flag & LIB_FAKEUSER) { icon = ICON_FILE_TICK; @@ -850,7 +854,9 @@ static void outliner_draw_rnacols(ARegion *ar, int sizex) View2D *v2d = &ar->v2d; float miny = v2d->cur.ymin; - if (miny < v2d->tot.ymin) miny = v2d->tot.ymin; + if (miny < v2d->tot.ymin) { + miny = v2d->tot.ymin; + } GPU_line_width(1.0f); @@ -931,10 +937,18 @@ static void outliner_buttons(const bContext *C, uiBlock *block, ARegion *ar, Tre * need change this. */ - if (tselem->type == TSE_EBONE) len = sizeof(((EditBone *) 0)->name); - else if (tselem->type == TSE_MODIFIER) len = sizeof(((ModifierData *) 0)->name); - else if (tselem->id && GS(tselem->id->name) == ID_LI) len = sizeof(((Library *) 0)->name); - else len = MAX_ID_NAME - 2; + if (tselem->type == TSE_EBONE) { + len = sizeof(((EditBone *) 0)->name); + } + else if (tselem->type == TSE_MODIFIER) { + len = sizeof(((ModifierData *) 0)->name); + } + else if (tselem->id && GS(tselem->id->name) == ID_LI) { + len = sizeof(((Library *) 0)->name); + } + else { + len = MAX_ID_NAME - 2; + } spx = te->xs + 1.8f * UI_UNIT_X; dx = ar->v2d.cur.xmax - (spx + 3.2f * UI_UNIT_X); @@ -1240,18 +1254,24 @@ TreeElementIcon tree_element_get_icon(TreeStoreElem *tselem, TreeElement *te) data.icon = ICON_GROUP_BONE; break; case TSE_SEQUENCE: - if (te->idcode == SEQ_TYPE_MOVIE) + if (te->idcode == SEQ_TYPE_MOVIE) { data.icon = ICON_SEQUENCE; - else if (te->idcode == SEQ_TYPE_META) + } + else if (te->idcode == SEQ_TYPE_META) { data.icon = ICON_DOT; - else if (te->idcode == SEQ_TYPE_SCENE) + } + else if (te->idcode == SEQ_TYPE_SCENE) { data.icon = ICON_SCENE; - else if (te->idcode == SEQ_TYPE_SOUND_RAM) + } + else if (te->idcode == SEQ_TYPE_SOUND_RAM) { data.icon = ICON_SOUND; - else if (te->idcode == SEQ_TYPE_IMAGE) + } + else if (te->idcode == SEQ_TYPE_IMAGE) { data.icon = ICON_IMAGE; - else + } + else { data.icon = ICON_PARTICLES; + } break; case TSE_SEQ_STRIP: data.icon = ICON_LIBRARY_DATA_DIRECT; @@ -1601,8 +1621,9 @@ static void outliner_draw_iconrow( for (TreeElement *te = lb->first; te; te = te->next) { /* exit drawing early */ - if ((*offsx) - UI_UNIT_X > xmax) + if ((*offsx) - UI_UNIT_X > xmax) { break; + } TreeStoreElem *tselem = TREESTORE(te); @@ -1710,8 +1731,9 @@ static void outliner_draw_tree_element( } /* icons can be ui buts, we don't want it to overlap with restrict */ - if ((soops->flag & SO_HIDE_RESTRICTCOLS) == 0) + if ((soops->flag & SO_HIDE_RESTRICTCOLS) == 0) { xmax -= OL_TOGW + UI_UNIT_X; + } GPU_blend(true); @@ -1808,8 +1830,9 @@ static void outliner_draw_tree_element( tselem_draw_icon(block, xmax, (float)startx + offsx, (float)*starty, tselem, te, alpha_fac, true); offsx += UI_UNIT_X + 4 * ufac; } - else + else { offsx += 2 * ufac; + } if (ELEM(tselem->type, 0, TSE_LAYER_COLLECTION) && ID_IS_LINKED(tselem->id)) { if (tselem->id->tag & LIB_TAG_MISSING) { @@ -1965,10 +1988,11 @@ static void outliner_draw_hierarchy_lines_recursive( *starty -= UI_UNIT_Y; - if (TSELEM_OPEN(tselem, soops)) + if (TSELEM_OPEN(tselem, soops)) { outliner_draw_hierarchy_lines_recursive( pos, soops, &te->subtree, startx + UI_UNIT_X, col, draw_childs_grayed_out, starty); + } } if (draw_grayed_out) { diff --git a/source/blender/editors/space_outliner/outliner_edit.c b/source/blender/editors/space_outliner/outliner_edit.c index 0cadda235f4..aa9c462d74e 100644 --- a/source/blender/editors/space_outliner/outliner_edit.c +++ b/source/blender/editors/space_outliner/outliner_edit.c @@ -141,16 +141,21 @@ static int do_outliner_item_openclose(bContext *C, SpaceOutliner *soops, TreeEle outliner_flag_set(&te->subtree, TSE_CLOSED, !outliner_flag_is_any_test(&te->subtree, TSE_CLOSED, 1)); } else { - if (tselem->flag & TSE_CLOSED) tselem->flag &= ~TSE_CLOSED; - else tselem->flag |= TSE_CLOSED; + if (tselem->flag & TSE_CLOSED) { + tselem->flag &= ~TSE_CLOSED; + } + else { + tselem->flag |= TSE_CLOSED; + } } return 1; } for (te = te->subtree.first; te; te = te->next) { - if (do_outliner_item_openclose(C, soops, te, all, mval)) + if (do_outliner_item_openclose(C, soops, te, all, mval)) { return 1; + } } return 0; @@ -168,8 +173,9 @@ static int outliner_item_openclose(bContext *C, wmOperator *op, const wmEvent *e UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], &fmval[0], &fmval[1]); for (te = soops->tree.first; te; te = te->next) { - if (do_outliner_item_openclose(C, soops, te, all, fmval)) + if (do_outliner_item_openclose(C, soops, te, all, fmval)) { break; + } } ED_region_tag_redraw(ar); @@ -308,7 +314,9 @@ static int do_outliner_item_rename(ReportList *reports, ARegion *ar, TreeElement } for (te = te->subtree.first; te; te = te->next) { - if (do_outliner_item_rename(reports, ar, te, mval)) return 1; + if (do_outliner_item_rename(reports, ar, te, mval)) { + return 1; + } } return 0; } @@ -865,7 +873,9 @@ static int outliner_count_levels(ListBase *lb, const int curlevel) for (te = lb->first; te; te = te->next) { lev = outliner_count_levels(&te->subtree, curlevel + 1); - if (lev > level) level = lev; + if (lev > level) { + level = lev; + } } return level; } @@ -878,10 +888,14 @@ int outliner_flag_is_any_test(ListBase *lb, short flag, const int curlevel) for (te = lb->first; te; te = te->next) { tselem = TREESTORE(te); - if (tselem->flag & flag) return curlevel; + if (tselem->flag & flag) { + return curlevel; + } level = outliner_flag_is_any_test(&te->subtree, flag, curlevel + 1); - if (level) return level; + if (level) { + return level; + } } return 0; } @@ -944,11 +958,13 @@ int common_restrict_check(bContext *C, Object *ob) Object *obedit = CTX_data_edit_object(C); if (obedit && obedit == ob) { /* found object is hidden, reset */ - if (ob->restrictflag & OB_RESTRICT_VIEW) + if (ob->restrictflag & OB_RESTRICT_VIEW) { ob->restrictflag &= ~OB_RESTRICT_VIEW; + } /* found object is unselectable, reset */ - if (ob->restrictflag & OB_RESTRICT_SELECT) + if (ob->restrictflag & OB_RESTRICT_SELECT) { ob->restrictflag &= ~OB_RESTRICT_SELECT; + } return 0; } @@ -965,10 +981,12 @@ static int outliner_toggle_expanded_exec(bContext *C, wmOperator *UNUSED(op)) SpaceOutliner *soops = CTX_wm_space_outliner(C); ARegion *ar = CTX_wm_region(C); - if (outliner_flag_is_any_test(&soops->tree, TSE_CLOSED, 1)) + if (outliner_flag_is_any_test(&soops->tree, TSE_CLOSED, 1)) { outliner_flag_set(&soops->tree, TSE_CLOSED, 0); - else + } + else { outliner_flag_set(&soops->tree, TSE_CLOSED, 1); + } ED_region_tag_redraw(ar); @@ -1098,8 +1116,9 @@ static int outliner_show_active_exec(bContext *C, wmOperator *UNUSED(op)) Object *obact = OBACT(view_layer); - if (!obact) + if (!obact) { return OPERATOR_CANCELLED; + } te = outliner_find_id(so, &so->tree, &obact->id); @@ -1130,7 +1149,9 @@ static int outliner_show_active_exec(bContext *C, wmOperator *UNUSED(op)) /* make te->ys center of view */ ytop = te->ys + BLI_rcti_size_y(&v2d->mask) / 2; - if (ytop > 0) ytop = 0; + if (ytop > 0) { + ytop = 0; + } v2d->cur.ymax = (float)ytop; v2d->cur.ymin = (float)(ytop - BLI_rcti_size_y(&v2d->mask)); @@ -1166,10 +1187,13 @@ static int outliner_scroll_page_exec(bContext *C, wmOperator *op) int dy = BLI_rcti_size_y(&ar->v2d.mask); int up = 0; - if (RNA_boolean_get(op->ptr, "up")) + if (RNA_boolean_get(op->ptr, "up")) { up = 1; + } - if (up == 0) dy = -dy; + if (up == 0) { + dy = -dy; + } ar->v2d.cur.ymin += dy; ar->v2d.cur.ymax += dy; @@ -1319,10 +1343,14 @@ static void outliner_openclose_level(ListBase *lb, int curlevel, int level, int tselem = TREESTORE(te); if (open) { - if (curlevel <= level) tselem->flag &= ~TSE_CLOSED; + if (curlevel <= level) { + tselem->flag &= ~TSE_CLOSED; + } } else { - if (curlevel >= level) tselem->flag |= TSE_CLOSED; + if (curlevel >= level) { + tselem->flag |= TSE_CLOSED; + } } outliner_openclose_level(&te->subtree, curlevel + 1, level, open); @@ -1338,11 +1366,17 @@ static int outliner_one_level_exec(bContext *C, wmOperator *op) level = outliner_flag_is_any_test(&soops->tree, TSE_CLOSED, 1); if (add == 1) { - if (level) outliner_openclose_level(&soops->tree, 1, level, 1); + if (level) { + outliner_openclose_level(&soops->tree, 1, level, 1); + } } else { - if (level == 0) level = outliner_count_levels(&soops->tree, 0); - if (level) outliner_openclose_level(&soops->tree, 1, level - 1, 0); + if (level == 0) { + level = outliner_count_levels(&soops->tree, 0); + } + if (level) { + outliner_openclose_level(&soops->tree, 1, level - 1, 0); + } } ED_region_tag_redraw(ar); @@ -1380,8 +1414,12 @@ static int subtree_has_objects(ListBase *lb) for (te = lb->first; te; te = te->next) { tselem = TREESTORE(te); - if (tselem->type == 0 && te->idcode == ID_OB) return 1; - if (subtree_has_objects(&te->subtree)) return 1; + if (tselem->type == 0 && te->idcode == ID_OB) { + return 1; + } + if (subtree_has_objects(&te->subtree)) { + return 1; + } } return 0; } @@ -1398,12 +1436,20 @@ static void tree_element_show_hierarchy(Scene *scene, SpaceOutliner *soops, List if (tselem->type == 0) { if (te->idcode == ID_SCE) { - if (tselem->id != (ID *)scene) tselem->flag |= TSE_CLOSED; - else tselem->flag &= ~TSE_CLOSED; + if (tselem->id != (ID *)scene) { + tselem->flag |= TSE_CLOSED; + } + else { + tselem->flag &= ~TSE_CLOSED; + } } else if (te->idcode == ID_OB) { - if (subtree_has_objects(&te->subtree)) tselem->flag &= ~TSE_CLOSED; - else tselem->flag |= TSE_CLOSED; + if (subtree_has_objects(&te->subtree)) { + tselem->flag &= ~TSE_CLOSED; + } + else { + tselem->flag |= TSE_CLOSED; + } } } else { @@ -1479,8 +1525,9 @@ static void tree_element_to_path(TreeElement *te, TreeStoreElem *tselem, /* optimize tricks: * - Don't do anything if the selected item is a 'struct', but arrays are allowed */ - if (tselem->type == TSE_RNA_STRUCT) + if (tselem->type == TSE_RNA_STRUCT) { return; + } /* Overview of Algorithm: * 1. Go up the chain of parents until we find the 'root', taking note of the @@ -1530,17 +1577,19 @@ static void tree_element_to_path(TreeElement *te, TreeStoreElem *tselem, /* if possible, use name as a key in the path */ newpath = RNA_path_append(*path, NULL, prop, 0, name); - if (name != buf) + if (name != buf) { MEM_freeN(name); + } } else { /* otherwise use index */ int index = 0; - for (temsub = tem->subtree.first; temsub; temsub = temsub->next, index++) - if (temsub == temnext) + for (temsub = tem->subtree.first; temsub; temsub = temsub->next, index++) { + if (temsub == temnext) { break; - + } + } newpath = RNA_path_append(*path, NULL, prop, index, NULL); } @@ -1549,7 +1598,9 @@ static void tree_element_to_path(TreeElement *te, TreeStoreElem *tselem, } if (newpath) { - if (*path) MEM_freeN(*path); + if (*path) { + MEM_freeN(*path); + } *path = newpath; newpath = NULL; } @@ -1590,7 +1641,9 @@ static void tree_element_to_path(TreeElement *te, TreeStoreElem *tselem, /* path */ newpath = RNA_path_append(*path, NULL, prop, 0, NULL); - if (*path) MEM_freeN(*path); + if (*path) { + MEM_freeN(*path); + } *path = newpath; } @@ -1647,12 +1700,14 @@ static void do_outliner_drivers_editop(SpaceOutliner *soops, ListBase *tree, Rep /* entire array was selected, so add drivers for all */ arraylen = RNA_property_array_length(&te->rnaptr, te->directdata); } - else + else { arraylen = array_index; + } /* we should do at least one step */ - if (arraylen == array_index) + if (arraylen == array_index) { arraylen++; + } /* for each array element we should affect, add driver */ for (; array_index < arraylen; array_index++) { @@ -1681,8 +1736,9 @@ static void do_outliner_drivers_editop(SpaceOutliner *soops, ListBase *tree, Rep } /* go over sub-tree */ - if (TSELEM_OPEN(tselem, soops)) + if (TSELEM_OPEN(tselem, soops)) { do_outliner_drivers_editop(soops, &te->subtree, reports, mode); + } } } @@ -1693,8 +1749,9 @@ static int outliner_drivers_addsel_exec(bContext *C, wmOperator *op) SpaceOutliner *soutliner = CTX_wm_space_outliner(C); /* check for invalid states */ - if (soutliner == NULL) + if (soutliner == NULL) { return OPERATOR_CANCELLED; + } /* recursively go into tree, adding selected items */ do_outliner_drivers_editop(soutliner, &soutliner->tree, op->reports, DRIVERS_EDITMODE_ADD); @@ -1728,8 +1785,9 @@ static int outliner_drivers_deletesel_exec(bContext *C, wmOperator *op) SpaceOutliner *soutliner = CTX_wm_space_outliner(C); /* check for invalid states */ - if (soutliner == NULL) + if (soutliner == NULL) { return OPERATOR_CANCELLED; + } /* recursively go into tree, adding selected items */ do_outliner_drivers_editop(soutliner, &soutliner->tree, op->reports, DRIVERS_EDITMODE_REMOVE); @@ -1775,12 +1833,14 @@ static KeyingSet *verify_active_keyingset(Scene *scene, short add) KeyingSet *ks = NULL; /* sanity check */ - if (scene == NULL) + if (scene == NULL) { return NULL; + } /* try to find one from scene */ - if (scene->active_keyingset > 0) + if (scene->active_keyingset > 0) { ks = BLI_findlink(&scene->keyingsets, scene->active_keyingset - 1); + } /* add if none found */ // XXX the default settings have yet to evolve @@ -1852,8 +1912,9 @@ static void do_outliner_keyingset_editop(SpaceOutliner *soops, KeyingSet *ks, Li } /* go over sub-tree */ - if (TSELEM_OPEN(tselem, soops)) + if (TSELEM_OPEN(tselem, soops)) { do_outliner_keyingset_editop(soops, ks, &te->subtree, mode); + } } } @@ -1870,8 +1931,9 @@ static int outliner_keyingset_additems_exec(bContext *C, wmOperator *op) BKE_report(op->reports, RPT_ERROR, "Operation requires an active keying set"); return OPERATOR_CANCELLED; } - if (soutliner == NULL) + if (soutliner == NULL) { return OPERATOR_CANCELLED; + } /* recursively go into tree, adding selected items */ do_outliner_keyingset_editop(soutliner, ks, &soutliner->tree, KEYINGSET_EDITMODE_ADD); @@ -1907,8 +1969,9 @@ static int outliner_keyingset_removeitems_exec(bContext *C, wmOperator *UNUSED(o KeyingSet *ks = verify_active_keyingset(scene, 1); /* check for invalid states */ - if (soutliner == NULL) + if (soutliner == NULL) { return OPERATOR_CANCELLED; + } /* recursively go into tree, adding selected items */ do_outliner_keyingset_editop(soutliner, ks, &soutliner->tree, KEYINGSET_EDITMODE_REMOVE); diff --git a/source/blender/editors/space_outliner/outliner_select.c b/source/blender/editors/space_outliner/outliner_select.c index a1afe8b46ea..5ace2c291e0 100644 --- a/source/blender/editors/space_outliner/outliner_select.c +++ b/source/blender/editors/space_outliner/outliner_select.c @@ -227,8 +227,9 @@ static eOLDrawState active_viewlayer( bContext *C, Scene *UNUSED(scene), ViewLayer *UNUSED(sl), TreeElement *te, const eOLSetState set) { /* paranoia check */ - if (te->idcode != ID_SCE) + if (te->idcode != ID_SCE) { return OL_DRAWSEL_NONE; + } ViewLayer *view_layer = te->directdata; @@ -268,10 +269,12 @@ static void do_outliner_bone_select_recursive(bArmature *arm, Bone *bone_parent, { Bone *bone; for (bone = bone_parent->childbase.first; bone; bone = bone->next) { - if (select && PBONE_SELECTABLE(arm, bone)) + if (select && PBONE_SELECTABLE(arm, bone)) { bone->flag |= BONE_SELECTED; - else + } + else { bone->flag &= ~(BONE_TIPSEL | BONE_SELECTED | BONE_ROOTSEL); + } do_outliner_bone_select_recursive(arm, bone, select); } } @@ -281,10 +284,12 @@ static void do_outliner_ebone_select_recursive(bArmature *arm, EditBone *ebone_p EditBone *ebone; for (ebone = ebone_parent->next; ebone; ebone = ebone->next) { if (ED_armature_ebone_is_child_recursive(ebone_parent, ebone)) { - if (select && EBONE_SELECTABLE(arm, ebone)) + if (select && EBONE_SELECTABLE(arm, ebone)) { ebone->flag |= BONE_TIPSEL | BONE_SELECTED | BONE_ROOTSEL; - else + } + else { ebone->flag &= ~(BONE_TIPSEL | BONE_SELECTED | BONE_ROOTSEL); + } } } } @@ -341,10 +346,12 @@ static eOLDrawState tree_element_set_active_object( if (base) { if (set == OL_SETSEL_EXTEND) { /* swap select */ - if (base->flag & BASE_SELECTED) + if (base->flag & BASE_SELECTED) { ED_object_base_select(base, BA_DESELECT); - else + } + else { ED_object_base_select(base, BA_SELECT); + } } else { /* deleselect all */ @@ -477,8 +484,9 @@ static eOLDrawState tree_element_active_world( tep = te->parent; if (tep) { tselem = TREESTORE(tep); - if (tselem->type == 0) + if (tselem->type == 0) { sce = (Scene *)tselem->id; + } } if (set != OL_SETSEL_NONE) { @@ -578,8 +586,9 @@ static eOLDrawState tree_element_active_posechannel( if (set != OL_SETSEL_EXTEND) { bPoseChannel *pchannel; /* single select forces all other bones to get unselected */ - for (pchannel = ob->pose->chanbase.first; pchannel; pchannel = pchannel->next) + for (pchannel = ob->pose->chanbase.first; pchannel; pchannel = pchannel->next) { pchannel->bone->flag &= ~(BONE_TIPSEL | BONE_SELECTED | BONE_ROOTSEL); + } } if ((set == OL_SETSEL_EXTEND) && (pchan->bone->flag & BONE_SELECTED)) { @@ -665,12 +674,16 @@ static void tree_element_active_ebone__sel(bContext *C, Object *obedit, bArmatur ebone->flag |= BONE_SELECTED | BONE_ROOTSEL | BONE_TIPSEL; arm->act_edbone = ebone; // flush to parent? - if (ebone->parent && (ebone->flag & BONE_CONNECTED)) ebone->parent->flag |= BONE_TIPSEL; + if (ebone->parent && (ebone->flag & BONE_CONNECTED)) { + ebone->parent->flag |= BONE_TIPSEL; + } } else { ebone->flag &= ~(BONE_SELECTED | BONE_ROOTSEL | BONE_TIPSEL); // flush to parent? - if (ebone->parent && (ebone->flag & BONE_CONNECTED)) ebone->parent->flag &= ~BONE_TIPSEL; + if (ebone->parent && (ebone->flag & BONE_CONNECTED)) { + ebone->parent->flag &= ~BONE_TIPSEL; + } } WM_event_add_notifier(C, NC_OBJECT | ND_BONE_ACTIVE, obedit); @@ -830,8 +843,9 @@ static eOLDrawState tree_element_active_sequence_dup( seq = (Sequence *)te->directdata; if (set == OL_SETSEL_NONE) { - if (seq->flag & SELECT) + if (seq->flag & SELECT) { return OL_DRAWSEL_NORMAL; + } return OL_DRAWSEL_NONE; } diff --git a/source/blender/editors/space_outliner/outliner_tools.c b/source/blender/editors/space_outliner/outliner_tools.c index 400a69cef51..15d2d007ecf 100644 --- a/source/blender/editors/space_outliner/outliner_tools.c +++ b/source/blender/editors/space_outliner/outliner_tools.c @@ -101,10 +101,12 @@ static void set_operation_types(SpaceOutliner *soops, ListBase *lb, if (tselem->flag & TSE_SELECTED) { /* Layer collection points to collection ID. */ if (!ELEM(tselem->type, 0, TSE_LAYER_COLLECTION)) { - if (*datalevel == 0) + if (*datalevel == 0) { *datalevel = tselem->type; - else if (*datalevel != tselem->type) + } + else if (*datalevel != tselem->type) { *datalevel = -1; + } } else { int idcode = GS(tselem->id->name); @@ -122,8 +124,12 @@ static void set_operation_types(SpaceOutliner *soops, ListBase *lb, case ID_SO: case ID_KE: case ID_WO: case ID_AC: case ID_NLA: case ID_TXT: case ID_GR: case ID_LS: case ID_LI: - if (*idlevel == 0) *idlevel = idcode; - else if (*idlevel != idcode) *idlevel = -1; + if (*idlevel == 0) { + *idlevel = idcode; + } + else if (*idlevel != idcode) { + *idlevel = -1; + } if (ELEM(*datalevel, TSE_VIEW_COLLECTION_BASE, TSE_SCENE_COLLECTION_BASE)) { *datalevel = 0; } @@ -626,8 +632,9 @@ static void refreshdrivers_animdata_cb(int UNUSED(event), TreeElement *UNUSED(te for (fcu = iat->adt->drivers.first; fcu; fcu = fcu->next) { fcu->flag &= ~FCURVE_DISABLED; - if (fcu->driver) + if (fcu->driver) { fcu->driver->flag &= ~DRIVER_FLAG_INVALID; + } } } @@ -657,48 +664,57 @@ static void pchan_cb(int event, TreeElement *te, TreeStoreElem *UNUSED(tselem), { bPoseChannel *pchan = (bPoseChannel *)te->directdata; - if (event == OL_DOP_SELECT) + if (event == OL_DOP_SELECT) { pchan->bone->flag |= BONE_SELECTED; - else if (event == OL_DOP_DESELECT) + } + else if (event == OL_DOP_DESELECT) { pchan->bone->flag &= ~BONE_SELECTED; + } else if (event == OL_DOP_HIDE) { pchan->bone->flag |= BONE_HIDDEN_P; pchan->bone->flag &= ~BONE_SELECTED; } - else if (event == OL_DOP_UNHIDE) + else if (event == OL_DOP_UNHIDE) { pchan->bone->flag &= ~BONE_HIDDEN_P; + } } static void bone_cb(int event, TreeElement *te, TreeStoreElem *UNUSED(tselem), void *UNUSED(arg)) { Bone *bone = (Bone *)te->directdata; - if (event == OL_DOP_SELECT) + if (event == OL_DOP_SELECT) { bone->flag |= BONE_SELECTED; - else if (event == OL_DOP_DESELECT) + } + else if (event == OL_DOP_DESELECT) { bone->flag &= ~BONE_SELECTED; + } else if (event == OL_DOP_HIDE) { bone->flag |= BONE_HIDDEN_P; bone->flag &= ~BONE_SELECTED; } - else if (event == OL_DOP_UNHIDE) + else if (event == OL_DOP_UNHIDE) { bone->flag &= ~BONE_HIDDEN_P; + } } static void ebone_cb(int event, TreeElement *te, TreeStoreElem *UNUSED(tselem), void *UNUSED(arg)) { EditBone *ebone = (EditBone *)te->directdata; - if (event == OL_DOP_SELECT) + if (event == OL_DOP_SELECT) { ebone->flag |= BONE_SELECTED; - else if (event == OL_DOP_DESELECT) + } + else if (event == OL_DOP_DESELECT) { ebone->flag &= ~BONE_SELECTED; + } else if (event == OL_DOP_HIDE) { ebone->flag |= BONE_HIDDEN_A; ebone->flag &= ~BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL; } - else if (event == OL_DOP_UNHIDE) + else if (event == OL_DOP_UNHIDE) { ebone->flag &= ~BONE_HIDDEN_A; + } } static void sequence_cb(int event, TreeElement *te, TreeStoreElem *tselem, void *scene_ptr) @@ -719,14 +735,18 @@ static void gp_layer_cb(int event, TreeElement *te, TreeStoreElem *UNUSED(tselem { bGPDlayer *gpl = (bGPDlayer *)te->directdata; - if (event == OL_DOP_SELECT) + if (event == OL_DOP_SELECT) { gpl->flag |= GP_LAYER_SELECT; - else if (event == OL_DOP_DESELECT) + } + else if (event == OL_DOP_DESELECT) { gpl->flag &= ~GP_LAYER_SELECT; - else if (event == OL_DOP_HIDE) + } + else if (event == OL_DOP_HIDE) { gpl->flag |= GP_LAYER_HIDE; - else if (event == OL_DOP_UNHIDE) + } + else if (event == OL_DOP_UNHIDE) { gpl->flag &= ~GP_LAYER_HIDE; + } } static void data_select_linked_cb(int event, TreeElement *te, TreeStoreElem *UNUSED(tselem), void *C_v) @@ -839,7 +859,9 @@ static Base *outline_delete_hierarchy(bContext *C, ReportList *reports, Scene *s for (child_base = view_layer->object_bases.first; child_base; child_base = base_next) { base_next = child_base->next; - for (parent = child_base->object->parent; parent && (parent != base->object); parent = parent->parent); + for (parent = child_base->object->parent; parent && (parent != base->object); parent = parent->parent) { + /* pass */ + } if (parent) { base_next = outline_delete_hierarchy(C, reports, scene, child_base); } @@ -877,7 +899,9 @@ static void object_delete_hierarchy_cb( } if (base) { /* Check also library later. */ - for (; obedit && (obedit != base->object); obedit = obedit->parent); + for (; obedit && (obedit != base->object); obedit = obedit->parent) { + /* pass */ + } if (obedit == base->object) { ED_object_editmode_exit(C, EM_FREEDATA); } @@ -907,7 +931,9 @@ static Base *outline_batch_delete_hierarchy( object = base->object; for (child_base = view_layer->object_bases.first; child_base; child_base = base_next) { base_next = child_base->next; - for (parent = child_base->object->parent; parent && (parent != object); parent = parent->parent); + for (parent = child_base->object->parent; parent && (parent != object); parent = parent->parent) { + /* pass */ + } if (parent) { base_next = outline_batch_delete_hierarchy(reports, bmain, view_layer, scene, child_base); } @@ -951,7 +977,9 @@ static void object_batch_delete_hierarchy_cb( } if (base) { /* Check also library later. */ - for (; obedit && (obedit != base->object); obedit = obedit->parent); + for (; obedit && (obedit != base->object); obedit = obedit->parent) { + /* pass */ + } if (obedit == base->object) { ED_object_editmode_exit(C, EM_FREEDATA); } @@ -1008,8 +1036,9 @@ static int outliner_object_operation_exec(bContext *C, wmOperator *op) const char *str = NULL; /* check for invalid states */ - if (soops == NULL) + if (soops == NULL) { return OPERATOR_CANCELLED; + } event = RNA_enum_get(op->ptr, "type"); @@ -1215,8 +1244,9 @@ static int outliner_id_operation_exec(bContext *C, wmOperator *op) eOutlinerIdOpTypes event; /* check for invalid states */ - if (soops == NULL) + if (soops == NULL) { return OPERATOR_CANCELLED; + } set_operation_types(soops, &soops->tree, &scenelevel, &objectlevel, &idlevel, &datalevel); @@ -1429,8 +1459,9 @@ static int outliner_lib_operation_exec(bContext *C, wmOperator *op) eOutlinerLibOpTypes event; /* check for invalid states */ - if (soops == NULL) + if (soops == NULL) { return OPERATOR_CANCELLED; + } set_operation_types(soops, &soops->tree, &scenelevel, &objectlevel, &idlevel, &datalevel); @@ -1544,8 +1575,9 @@ static int outliner_action_set_exec(bContext *C, wmOperator *op) bAction *act; /* check for invalid states */ - if (soops == NULL) + if (soops == NULL) { return OPERATOR_CANCELLED; + } set_operation_types(soops, &soops->tree, &scenelevel, &objectlevel, &idlevel, &datalevel); /* get action to use */ @@ -1565,12 +1597,15 @@ static int outliner_action_set_exec(bContext *C, wmOperator *op) } /* perform action if valid channel */ - if (datalevel == TSE_ANIM_DATA) + if (datalevel == TSE_ANIM_DATA) { outliner_do_id_set_operation(soops, datalevel, &soops->tree, (ID *)act, actionset_id_cb); - else if (idlevel == ID_AC) + } + else if (idlevel == ID_AC) { outliner_do_id_set_operation(soops, idlevel, &soops->tree, (ID *)act, actionset_id_cb); - else + } + else { return OPERATOR_CANCELLED; + } /* set notifier that things have changed */ WM_event_add_notifier(C, NC_ANIMATION | ND_NLA_ACTCHANGE, NULL); @@ -1641,14 +1676,16 @@ static int outliner_animdata_operation_exec(bContext *C, wmOperator *op) short updateDeps = 0; /* check for invalid states */ - if (soops == NULL) + if (soops == NULL) { return OPERATOR_CANCELLED; + } event = RNA_enum_get(op->ptr, "type"); set_operation_types(soops, &soops->tree, &scenelevel, &objectlevel, &idlevel, &datalevel); - if (datalevel != TSE_ANIM_DATA) + if (datalevel != TSE_ANIM_DATA) { return OPERATOR_CANCELLED; + } /* perform the core operation */ switch (event) { @@ -1828,8 +1865,9 @@ static int outliner_data_operation_exec(bContext *C, wmOperator *op) eOutliner_PropDataOps event; /* check for invalid states */ - if (soops == NULL) + if (soops == NULL) { return OPERATOR_CANCELLED; + } event = RNA_enum_get(op->ptr, "type"); set_operation_types(soops, &soops->tree, &scenelevel, &objectlevel, &idlevel, &datalevel); @@ -1942,8 +1980,9 @@ static int do_outliner_operation_event(bContext *C, ARegion *ar, SpaceOutliner * /* select object that's clicked on and popup context menu */ if (!(tselem->flag & TSE_SELECTED)) { - if (outliner_flag_is_any_test(&soops->tree, TSE_SELECTED, 1)) + if (outliner_flag_is_any_test(&soops->tree, TSE_SELECTED, 1)) { outliner_flag_set(&soops->tree, TSE_SELECTED, 0); + } tselem->flag |= TSE_SELECTED; diff --git a/source/blender/editors/space_outliner/outliner_tree.c b/source/blender/editors/space_outliner/outliner_tree.c index 7d700be0ec7..72e9236636e 100644 --- a/source/blender/editors/space_outliner/outliner_tree.c +++ b/source/blender/editors/space_outliner/outliner_tree.c @@ -113,7 +113,9 @@ static void outliner_storage_cleanup(SpaceOutliner *soops) BLI_mempool_iternew(ts, &iter); while ((tselem = BLI_mempool_iterstep(&iter))) { - if (tselem->id == NULL) unused++; + if (tselem->id == NULL) { + unused++; + } } if (unused) { @@ -246,8 +248,9 @@ static void outliner_add_bone(SpaceOutliner *soops, ListBase *lb, ID *id, Bone * static bool outliner_animdata_test(AnimData *adt) { - if (adt) + if (adt) { return (adt->action || adt->drivers.first || adt->nla_tracks.first); + } return false; } @@ -269,8 +272,9 @@ static void outliner_add_line_styles(SpaceOutliner *soops, ListBase *lb, Scene * for (lineset = view_layer->freestyle_config.linesets.first; lineset; lineset = lineset->next) { FreestyleLineStyle *linestyle = lineset->linestyle; if (linestyle) { - if (!(linestyle->id.tag & LIB_TAG_DOIT)) + if (!(linestyle->id.tag & LIB_TAG_DOIT)) { continue; + } linestyle->id.tag &= ~LIB_TAG_DOIT; outliner_add_element(soops, lb, linestyle, te, 0, 0); } @@ -308,21 +312,24 @@ static void outliner_add_scene_contents(SpaceOutliner *soops, ListBase *lb, Scen outliner_make_object_parent_hierarchy(&ten->subtree); /* Animation Data */ - if (outliner_animdata_test(sce->adt)) + if (outliner_animdata_test(sce->adt)) { outliner_add_element(soops, lb, sce, te, TSE_ANIM_DATA, 0); + } } // can be inlined if necessary static void outliner_add_object_contents(SpaceOutliner *soops, TreeElement *te, TreeStoreElem *tselem, Object *ob) { - if (outliner_animdata_test(ob->adt)) + if (outliner_animdata_test(ob->adt)) { outliner_add_element(soops, &te->subtree, ob, te, TSE_ANIM_DATA, 0); + } outliner_add_element(soops, &te->subtree, ob->poselib, te, 0, 0); // XXX FIXME.. add a special type for this - if (ob->proxy && !ID_IS_LINKED(ob)) + if (ob->proxy && !ID_IS_LINKED(ob)) { outliner_add_element(soops, &te->subtree, ob->proxy, te, TSE_PROXY, 0); + } outliner_add_element(soops, &te->subtree, ob->gpd, te, 0, 0); @@ -479,8 +486,9 @@ static void outliner_add_object_contents(SpaceOutliner *soops, TreeElement *te, } /* duplicated group */ - if (ob->instance_collection) + if (ob->instance_collection) { outliner_add_element(soops, &te->subtree, ob->instance_collection, te, 0, 0); + } } @@ -488,7 +496,9 @@ static void outliner_add_object_contents(SpaceOutliner *soops, TreeElement *te, static void outliner_add_id_contents(SpaceOutliner *soops, TreeElement *te, TreeStoreElem *tselem, ID *id) { /* tuck pointer back in object, to construct hierarchy */ - if (GS(id->name) == ID_OB) id->newid = (ID *)te; + if (GS(id->name) == ID_OB) { + id->newid = (ID *)te; + } /* expand specific data always */ switch (GS(id->name)) { @@ -512,12 +522,14 @@ static void outliner_add_id_contents(SpaceOutliner *soops, TreeElement *te, Tree Mesh *me = (Mesh *)id; int a; - if (outliner_animdata_test(me->adt)) + if (outliner_animdata_test(me->adt)) { outliner_add_element(soops, &te->subtree, me, te, TSE_ANIM_DATA, 0); + } outliner_add_element(soops, &te->subtree, me->key, te, 0, 0); - for (a = 0; a < me->totcol; a++) + for (a = 0; a < me->totcol; a++) { outliner_add_element(soops, &te->subtree, me->mat[a], te, 0, a); + } /* could do tfaces with image links, but the images are not grouped nicely. * would require going over all tfaces, sort images in use. etc... */ break; @@ -527,11 +539,13 @@ static void outliner_add_id_contents(SpaceOutliner *soops, TreeElement *te, Tree Curve *cu = (Curve *)id; int a; - if (outliner_animdata_test(cu->adt)) + if (outliner_animdata_test(cu->adt)) { outliner_add_element(soops, &te->subtree, cu, te, TSE_ANIM_DATA, 0); + } - for (a = 0; a < cu->totcol; a++) + for (a = 0; a < cu->totcol; a++) { outliner_add_element(soops, &te->subtree, cu->mat[a], te, 0, a); + } break; } case ID_MB: @@ -539,28 +553,31 @@ static void outliner_add_id_contents(SpaceOutliner *soops, TreeElement *te, Tree MetaBall *mb = (MetaBall *)id; int a; - if (outliner_animdata_test(mb->adt)) + if (outliner_animdata_test(mb->adt)) { outliner_add_element(soops, &te->subtree, mb, te, TSE_ANIM_DATA, 0); + } - for (a = 0; a < mb->totcol; a++) + for (a = 0; a < mb->totcol; a++) { outliner_add_element(soops, &te->subtree, mb->mat[a], te, 0, a); + } break; } case ID_MA: { Material *ma = (Material *)id; - if (outliner_animdata_test(ma->adt)) + if (outliner_animdata_test(ma->adt)) { outliner_add_element(soops, &te->subtree, ma, te, TSE_ANIM_DATA, 0); + } break; } case ID_TE: { Tex *tex = (Tex *)id; - if (outliner_animdata_test(tex->adt)) + if (outliner_animdata_test(tex->adt)) { outliner_add_element(soops, &te->subtree, tex, te, TSE_ANIM_DATA, 0); - + } outliner_add_element(soops, &te->subtree, tex->ima, te, 0, 0); break; } @@ -568,8 +585,9 @@ static void outliner_add_id_contents(SpaceOutliner *soops, TreeElement *te, Tree { Camera *ca = (Camera *)id; - if (outliner_animdata_test(ca->adt)) + if (outliner_animdata_test(ca->adt)) { outliner_add_element(soops, &te->subtree, ca, te, TSE_ANIM_DATA, 0); + } break; } case ID_CF: @@ -586,40 +604,45 @@ static void outliner_add_id_contents(SpaceOutliner *soops, TreeElement *te, Tree { Light *la = (Light *)id; - if (outliner_animdata_test(la->adt)) + if (outliner_animdata_test(la->adt)) { outliner_add_element(soops, &te->subtree, la, te, TSE_ANIM_DATA, 0); + } break; } case ID_SPK: { Speaker *spk = (Speaker *)id; - if (outliner_animdata_test(spk->adt)) + if (outliner_animdata_test(spk->adt)) { outliner_add_element(soops, &te->subtree, spk, te, TSE_ANIM_DATA, 0); + } break; } case ID_LP: { LightProbe *prb = (LightProbe *)id; - if (outliner_animdata_test(prb->adt)) + if (outliner_animdata_test(prb->adt)) { outliner_add_element(soops, &te->subtree, prb, te, TSE_ANIM_DATA, 0); + } break; } case ID_WO: { World *wrld = (World *)id; - if (outliner_animdata_test(wrld->adt)) + if (outliner_animdata_test(wrld->adt)) { outliner_add_element(soops, &te->subtree, wrld, te, TSE_ANIM_DATA, 0); + } break; } case ID_KE: { Key *key = (Key *)id; - if (outliner_animdata_test(key->adt)) + if (outliner_animdata_test(key->adt)) { outliner_add_element(soops, &te->subtree, key, te, TSE_ANIM_DATA, 0); + } break; } case ID_AC: @@ -633,8 +656,9 @@ static void outliner_add_id_contents(SpaceOutliner *soops, TreeElement *te, Tree bArmature *arm = (bArmature *)id; int a = 0; - if (outliner_animdata_test(arm->adt)) + if (outliner_animdata_test(arm->adt)) { outliner_add_element(soops, &te->subtree, arm, te, TSE_ANIM_DATA, 0); + } if (arm->edbo) { EditBone *ebone; @@ -680,12 +704,14 @@ static void outliner_add_id_contents(SpaceOutliner *soops, TreeElement *te, Tree FreestyleLineStyle *linestyle = (FreestyleLineStyle *)id; int a; - if (outliner_animdata_test(linestyle->adt)) + if (outliner_animdata_test(linestyle->adt)) { outliner_add_element(soops, &te->subtree, linestyle, te, TSE_ANIM_DATA, 0); + } for (a = 0; a < MAX_MTEX; a++) { - if (linestyle->mtex[a]) + if (linestyle->mtex[a]) { outliner_add_element(soops, &te->subtree, linestyle->mtex[a]->tex, te, 0, a); + } } break; } @@ -695,8 +721,9 @@ static void outliner_add_id_contents(SpaceOutliner *soops, TreeElement *te, Tree bGPDlayer *gpl; int a = 0; - if (outliner_animdata_test(gpd->adt)) + if (outliner_animdata_test(gpd->adt)) { outliner_add_element(soops, &te->subtree, gpd, te, TSE_ANIM_DATA, 0); + } // TODO: base element for layers? for (gpl = gpd->layers.last; gpl; gpl = gpl->prev) { @@ -729,7 +756,9 @@ static TreeElement *outliner_add_element(SpaceOutliner *soops, ListBase *lb, voi if (ELEM(type, TSE_RNA_STRUCT, TSE_RNA_PROPERTY, TSE_RNA_ARRAY_ELEM)) { id = ((PointerRNA *)idv)->id.data; - if (!id) id = ((PointerRNA *)idv)->data; + if (!id) { + id = ((PointerRNA *)idv)->data; + } } else if (type == TSE_GP_LAYER) { /* idv is the layer its self */ @@ -757,8 +786,9 @@ static TreeElement *outliner_add_element(SpaceOutliner *soops, ListBase *lb, voi tselem = TREESTORE(te); /* if we are searching for something expand to see child elements */ - if (SEARCHING_OUTLINER(soops)) + if (SEARCHING_OUTLINER(soops)) { tselem->flag |= TSE_CHILDSEARCH; + } te->parent = parent; te->index = index; // for data arrays @@ -782,10 +812,12 @@ static TreeElement *outliner_add_element(SpaceOutliner *soops, ListBase *lb, voi } else { /* do here too, for blend file viewer, own ID_LI then shows file name */ - if (GS(id->name) == ID_LI) + if (GS(id->name) == ID_LI) { te->name = ((Library *)id)->name; - else + } + else { te->name = id->name + 2; // default, can be overridden by Library or non-ID data + } te->idcode = GS(id->name); } @@ -855,7 +887,9 @@ static TreeElement *outliner_add_element(SpaceOutliner *soops, ListBase *lb, voi for (strip = nlt->strips.first; strip; strip = strip->next, b++) { ten = outliner_add_element(soops, &tenlt->subtree, strip->act, tenlt, TSE_NLA_ACTION, b); - if (ten) ten->directdata = strip; + if (ten) { + ten->directdata = strip; + } } } } @@ -893,17 +927,20 @@ static TreeElement *outliner_add_element(SpaceOutliner *soops, ListBase *lb, voi p = p->next; } } - else + else { outliner_add_element(soops, &te->subtree, (void *)seq->strip, te, TSE_SEQ_STRIP, index); + } } } else if (type == TSE_SEQ_STRIP) { Strip *strip = (Strip *)idv; - if (strip->dir[0] != '\0') + if (strip->dir[0] != '\0') { te->name = strip->dir; - else + } + else { te->name = IFACE_("Strip None"); + } te->directdata = strip; } else if (type == TSE_SEQUENCE_DUP) { @@ -934,22 +971,28 @@ static TreeElement *outliner_add_element(SpaceOutliner *soops, ListBase *lb, voi /* struct */ te->name = RNA_struct_name_get_alloc(ptr, NULL, 0, NULL); - if (te->name) + if (te->name) { te->flag |= TE_FREE_NAME; - else + } + else { te->name = RNA_struct_ui_name(ptr->type); + } /* If searching don't expand RNA entries */ - if (SEARCHING_OUTLINER(soops) && BLI_strcasecmp("RNA", te->name) == 0) tselem->flag &= ~TSE_CHILDSEARCH; + if (SEARCHING_OUTLINER(soops) && BLI_strcasecmp("RNA", te->name) == 0) { + tselem->flag &= ~TSE_CHILDSEARCH; + } iterprop = RNA_struct_iterator_property(ptr->type); tot = RNA_property_collection_length(ptr, iterprop); CLAMP_MAX(tot, tot_limit); /* auto open these cases */ - if (!parent || (RNA_property_type(parent->directdata)) == PROP_POINTER) - if (!tselem->used) + if (!parent || (RNA_property_type(parent->directdata)) == PROP_POINTER) { + if (!tselem->used) { tselem->flag &= ~TSE_CLOSED; + } + } if (TSELEM_OPEN(tselem, soops)) { for (a = 0; a < tot; a++) { @@ -959,8 +1002,9 @@ static TreeElement *outliner_add_element(SpaceOutliner *soops, ListBase *lb, voi } } } - else if (tot) + else if (tot) { te->flag |= TE_LAZY_CLOSED; + } te->rnaptr = *ptr; } @@ -977,16 +1021,20 @@ static TreeElement *outliner_add_element(SpaceOutliner *soops, ListBase *lb, voi te->rnaptr = *ptr; /* If searching don't expand RNA entries */ - if (SEARCHING_OUTLINER(soops) && BLI_strcasecmp("RNA", te->name) == 0) tselem->flag &= ~TSE_CHILDSEARCH; + if (SEARCHING_OUTLINER(soops) && BLI_strcasecmp("RNA", te->name) == 0) { + tselem->flag &= ~TSE_CHILDSEARCH; + } if (proptype == PROP_POINTER) { pptr = RNA_property_pointer_get(ptr, prop); if (pptr.data) { - if (TSELEM_OPEN(tselem, soops)) + if (TSELEM_OPEN(tselem, soops)) { outliner_add_element(soops, &te->subtree, (void *)&pptr, te, TSE_RNA_STRUCT, -1); - else + } + else { te->flag |= TE_LAZY_CLOSED; + } } } else if (proptype == PROP_COLLECTION) { @@ -999,19 +1047,22 @@ static TreeElement *outliner_add_element(SpaceOutliner *soops, ListBase *lb, voi outliner_add_element(soops, &te->subtree, (void *)&pptr, te, TSE_RNA_STRUCT, a); } } - else if (tot) + else if (tot) { te->flag |= TE_LAZY_CLOSED; + } } else if (ELEM(proptype, PROP_BOOLEAN, PROP_INT, PROP_FLOAT)) { tot = RNA_property_array_length(ptr, prop); CLAMP_MAX(tot, tot_limit); if (TSELEM_OPEN(tselem, soops)) { - for (a = 0; a < tot; a++) + for (a = 0; a < tot; a++) { outliner_add_element(soops, &te->subtree, (void *)ptr, te, TSE_RNA_ARRAY_ELEM, a); + } } - else if (tot) + else if (tot) { te->flag |= TE_LAZY_CLOSED; + } } } else if (type == TSE_RNA_ARRAY_ELEM) { @@ -1026,8 +1077,12 @@ static TreeElement *outliner_add_element(SpaceOutliner *soops, ListBase *lb, voi c = RNA_property_array_item_char(prop, index); te->name = MEM_callocN(sizeof(char) * 20, "OutlinerRNAArrayName"); - if (c) sprintf((char *)te->name, " %c", c); - else sprintf((char *)te->name, " %d", index + 1); + if (c) { + sprintf((char *)te->name, " %c", c); + } + else { + sprintf((char *)te->name, " %d", index + 1); + } te->flag |= TE_FREE_NAME; } } @@ -1072,8 +1127,9 @@ static TreeElement *outliner_add_element(SpaceOutliner *soops, ListBase *lb, voi } } } - else + else { te->flag |= TE_LAZY_CLOSED; + } } return te; @@ -1087,8 +1143,9 @@ static int need_add_seq_dup(Sequence *seq) { Sequence *p; - if ((!seq->strip) || (!seq->strip->stripdata)) - return(1); + if ((!seq->strip) || (!seq->strip->stripdata)) { + return 1; + } /* * First check backward, if we found a duplicate @@ -1101,8 +1158,9 @@ static int need_add_seq_dup(Sequence *seq) continue; } - if (STREQ(p->strip->stripdata->name, seq->strip->stripdata->name)) - return(2); + if (STREQ(p->strip->stripdata->name, seq->strip->stripdata->name)) { + return 2; + } p = p->prev; } @@ -1113,8 +1171,9 @@ static int need_add_seq_dup(Sequence *seq) continue; } - if (STREQ(p->strip->stripdata->name, seq->strip->stripdata->name)) - return(0); + if (STREQ(p->strip->stripdata->name, seq->strip->stripdata->name)) { + return 0; + } p = p->next; } return(1); @@ -1132,8 +1191,9 @@ static void outliner_add_seq_dup(SpaceOutliner *soops, Sequence *seq, TreeElemen continue; } - if (STREQ(p->strip->stripdata->name, seq->strip->stripdata->name)) + if (STREQ(p->strip->stripdata->name, seq->strip->stripdata->name)) { /* ch = */ /* UNUSED */ outliner_add_element(soops, &te->subtree, (void *)p, te, TSE_SEQUENCE, index); + } p = p->next; } } @@ -1194,9 +1254,11 @@ static TreeElement *outliner_add_library_contents(Main *mainvar, SpaceOutliner * ID *id = lbarray[a]->first; /* check if there's data in current lib */ - for (; id; id = id->next) - if (id->lib == lib) + for (; id; id = id->next) { + if (id->lib == lib) { break; + } + } if (id) { if (!tenlib) { @@ -1253,8 +1315,9 @@ static void outliner_add_orphaned_datablocks(Main *mainvar, SpaceOutliner *soops /* check if there are any datablocks of this type which are orphans */ for (; id; id = id->next) { - if (ID_REAL_USERS(id) <= 0) + if (ID_REAL_USERS(id) <= 0) { break; + } } if (id) { @@ -1270,8 +1333,9 @@ static void outliner_add_orphaned_datablocks(Main *mainvar, SpaceOutliner *soops /* add the orphaned datablocks - these will not be added with any subtrees attached */ for (id = lbarray[a]->first; id; id = id->next) { - if (ID_REAL_USERS(id) <= 0) + if (ID_REAL_USERS(id) <= 0) { outliner_add_element(soops, (ten) ? &ten->subtree : &soops->tree, id, ten, 0, 0); + } } } } @@ -1395,7 +1459,9 @@ static void outliner_make_object_parent_hierarchy(ListBase *lb) tep = (TreeElement *)ob->parent->id.newid; BLI_addtail(&tep->subtree, te); // set correct parent pointers - for (te = tep->subtree.first; te; te = te->next) te->parent = tep; + for (te = tep->subtree.first; te; te = te->next) { + te->parent = tep; + } } } te = ten; @@ -1419,15 +1485,25 @@ static int treesort_alpha_ob(const void *v1, const void *v2) /* first put objects last (hierarchy) */ comp = (x1->idcode == ID_OB); - if (x2->idcode == ID_OB) comp += 2; + if (x2->idcode == ID_OB) { + comp += 2; + } - if (comp == 1) return 1; - else if (comp == 2) return -1; + if (comp == 1) { + return 1; + } + else if (comp == 2) { + return -1; + } else if (comp == 3) { comp = strcmp(x1->name, x2->name); - if (comp > 0) return 1; - else if (comp < 0) return -1; + if (comp > 0) { + return 1; + } + else if (comp < 0) { + return -1; + } return 0; } return 0; @@ -1441,8 +1517,12 @@ static int treesort_alpha(const void *v1, const void *v2) comp = strcmp(x1->name, x2->name); - if (comp > 0) return 1; - else if (comp < 0) return -1; + if (comp > 0) { + return 1; + } + else if (comp < 0) { + return -1; + } return 0; } @@ -1485,7 +1565,9 @@ static void outliner_sort(ListBase *lb) TreeStoreElem *tselem; te = lb->last; - if (te == NULL) return; + if (te == NULL) { + return; + } tselem = TREESTORE(te); /* sorting rules; only object lists, ID lists, or deformgroups */ @@ -1503,10 +1585,12 @@ static void outliner_sort(ListBase *lb) tp->name = te->name; tp->idcode = te->idcode; - if (tselem->type && tselem->type != TSE_DEFGROUP) + if (tselem->type && tselem->type != TSE_DEFGROUP) { tp->idcode = 0; // don't sort this - if (tselem->type == TSE_ID_BASE) + } + if (tselem->type == TSE_ID_BASE) { tp->idcode = 1; // do sort this + } tp->id = tselem->id; } @@ -1517,11 +1601,15 @@ static void outliner_sort(ListBase *lb) } else { /* keep beginning of list */ - for (tp = tear, skip = 0; skip < totelem; skip++, tp++) - if (tp->idcode) break; + for (tp = tear, skip = 0; skip < totelem; skip++, tp++) { + if (tp->idcode) { + break; + } + } - if (skip < totelem) + if (skip < totelem) { qsort(tear + skip, totelem - skip, sizeof(tTreeSort), treesort_alpha_ob); + } } BLI_listbase_clear(lb); @@ -1567,7 +1655,9 @@ static void outliner_restore_scrolling_position(SpaceOutliner *soops, ARegion *a ys_old = focus->ys; ytop = v2d->cur.ymax + (ys_new - ys_old) -1; - if (ytop > 0) ytop = 0; + if (ytop > 0) { + ytop = 0; + } v2d->cur.ymax = (float)ytop; v2d->cur.ymin = (float)(ytop - BLI_rcti_size_y(&v2d->mask)); @@ -1836,8 +1926,9 @@ static bool outliner_filter_has_name(TreeElement *te, const char *name, int flag { int fn_flag = 0; - if ((flags & SO_FIND_CASE_SENSITIVE) == 0) + if ((flags & SO_FIND_CASE_SENSITIVE) == 0) { fn_flag |= FNM_CASEFOLD; + } return fnmatch(name, te->name, fn_flag) == 0; } @@ -1932,10 +2023,12 @@ void outliner_build_tree(Main *mainvar, Scene *scene, ViewLayer *view_layer, Spa /* Are we looking for something - we want to tag parents to filter child matches * - NOT in datablocks view - searching all datablocks takes way too long to be useful * - this variable is only set once per tree build */ - if (soops->search_string[0] != 0 && soops->outlinevis != SO_DATA_API) + if (soops->search_string[0] != 0 && soops->outlinevis != SO_DATA_API) { soops->search_flags |= SO_SEARCH_RECURSIVE; - else + } + else { soops->search_flags &= ~SO_SEARCH_RECURSIVE; + } if (soops->treehash && (soops->storeflag & SO_TREESTORE_REBUILD) && soops->treestore) { soops->storeflag &= ~SO_TREESTORE_REBUILD; @@ -1960,8 +2053,9 @@ void outliner_build_tree(Main *mainvar, Scene *scene, ViewLayer *view_layer, Spa ten = outliner_add_library_contents(mainvar, soops, &soops->tree, NULL); if (ten) { tselem = TREESTORE(ten); - if (!tselem->used) + if (!tselem->used) { tselem->flag &= ~TSE_CLOSED; + } } for (lib = mainvar->libraries.first; lib; lib = lib->id.next) { @@ -1999,8 +2093,9 @@ void outliner_build_tree(Main *mainvar, Scene *scene, ViewLayer *view_layer, Spa } } /* restore newid pointers */ - for (lib = mainvar->libraries.first; lib; lib = lib->id.next) + for (lib = mainvar->libraries.first; lib; lib = lib->id.next) { lib->id.newid = NULL; + } } else if (soops->outlinevis == SO_SCENES) { @@ -2021,12 +2116,14 @@ void outliner_build_tree(Main *mainvar, Scene *scene, ViewLayer *view_layer, Spa Editing *ed = BKE_sequencer_editing_get(scene, false); int op; - if (ed == NULL) + if (ed == NULL) { return; + } seq = ed->seqbasep->first; - if (!seq) + if (!seq) { return; + } while (seq) { op = need_add_seq_dup(seq); diff --git a/source/blender/editors/space_outliner/outliner_utils.c b/source/blender/editors/space_outliner/outliner_utils.c index 3afb4f4d75a..a44a6e605de 100644 --- a/source/blender/editors/space_outliner/outliner_utils.c +++ b/source/blender/editors/space_outliner/outliner_utils.c @@ -91,9 +91,13 @@ TreeElement *outliner_find_tree_element(ListBase *lb, const TreeStoreElem *store { TreeElement *te, *tes; for (te = lb->first; te; te = te->next) { - if (te->store_elem == store_elem) return te; + if (te->store_elem == store_elem) { + return te; + } tes = outliner_find_tree_element(&te->subtree, store_elem); - if (tes) return tes; + if (tes) { + return tes; + } } return NULL; } @@ -120,12 +124,15 @@ TreeElement *outliner_find_tse(SpaceOutliner *soops, const TreeStoreElem *tse) { TreeStoreElem *tselem; - if (tse->id == NULL) return NULL; + if (tse->id == NULL) { + return NULL; + } /* check if 'tse' is in treestore */ tselem = BKE_outliner_treehash_lookup_any(soops->treehash, tse->type, tse->nr, tse->id); - if (tselem) + if (tselem) { return outliner_find_tree_element(&soops->tree, tselem); + } return NULL; } @@ -192,7 +199,9 @@ ID *outliner_search_back(SpaceOutliner *UNUSED(soops), TreeElement *te, short id while (te) { tselem = TREESTORE(te); - if (tselem->type == 0 && te->idcode == idcode) return tselem->id; + if (tselem->type == 0 && te->idcode == idcode) { + return tselem->id; + } te = te->parent; } return NULL; diff --git a/source/blender/editors/space_outliner/space_outliner.c b/source/blender/editors/space_outliner/space_outliner.c index 822f9ec61ac..dc51d501b99 100644 --- a/source/blender/editors/space_outliner/space_outliner.c +++ b/source/blender/editors/space_outliner/space_outliner.c @@ -172,16 +172,19 @@ static void outliner_main_region_listener( break; case NC_LAMP: /* For updating light icons, when changing light type */ - if (wmn->data == ND_LIGHTING_DRAW) + if (wmn->data == ND_LIGHTING_DRAW) { ED_region_tag_redraw(ar); + } break; case NC_SPACE: - if (wmn->data == ND_SPACE_OUTLINER) + if (wmn->data == ND_SPACE_OUTLINER) { 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_MATERIAL: switch (wmn->data) { @@ -205,14 +208,16 @@ static void outliner_main_region_listener( ED_region_tag_redraw(ar); break; case ND_ANIMCHAN: - if (wmn->action == NA_SELECTED) + if (wmn->action == NA_SELECTED) { ED_region_tag_redraw(ar); + } break; } break; case NC_GPENCIL: - if (ELEM(wmn->action, NA_EDITED, NA_SELECTED)) + if (ELEM(wmn->action, NA_EDITED, NA_SELECTED)) { ED_region_tag_redraw(ar); + } break; case NC_SCREEN: if (ELEM(wmn->data, ND_LAYER)) { @@ -276,12 +281,14 @@ static void outliner_header_region_listener( /* context changes */ switch (wmn->category) { case NC_SCENE: - if (wmn->data == ND_KEYINGSET) + if (wmn->data == ND_KEYINGSET) { ED_region_tag_redraw(ar); + } break; case NC_SPACE: - if (wmn->data == ND_SPACE_OUTLINER) + if (wmn->data == ND_SPACE_OUTLINER) { ED_region_tag_redraw(ar); + } break; } } diff --git a/source/blender/editors/space_sequencer/sequencer_add.c b/source/blender/editors/space_sequencer/sequencer_add.c index c21d1f6f57e..5e36ad9e8bc 100644 --- a/source/blender/editors/space_sequencer/sequencer_add.c +++ b/source/blender/editors/space_sequencer/sequencer_add.c @@ -166,8 +166,9 @@ static void sequencer_generic_invoke_xy__internal(bContext *C, wmOperator *op, i RNA_int_set(op->ptr, "frame_start", cfra); - if ((flag & SEQPROP_ENDFRAME) && RNA_struct_property_is_set(op->ptr, "frame_end") == 0) + if ((flag & SEQPROP_ENDFRAME) && RNA_struct_property_is_set(op->ptr, "frame_end") == 0) { RNA_int_set(op->ptr, "frame_end", cfra + 25); // XXX arbitrary but ok for now. + } if (!(flag & SEQPROP_NOPATHS)) { sequencer_generic_invoke_path__internal(C, op, "filepath"); @@ -201,28 +202,34 @@ static void seq_load_operator_info(SeqLoadInfo *seq_load, bContext *C, wmOperato is_file = 0; } - if ((is_file != -1) && relative) + if ((is_file != -1) && relative) { BLI_path_rel(seq_load->path, BKE_main_blendfile_path(bmain)); + } if ((prop = RNA_struct_find_property(op->ptr, "frame_end"))) { seq_load->end_frame = RNA_property_int_get(op->ptr, prop); } - if ((prop = RNA_struct_find_property(op->ptr, "replace_sel")) && RNA_property_boolean_get(op->ptr, prop)) + if ((prop = RNA_struct_find_property(op->ptr, "replace_sel")) && RNA_property_boolean_get(op->ptr, prop)) { seq_load->flag |= SEQ_LOAD_REPLACE_SEL; + } - if ((prop = RNA_struct_find_property(op->ptr, "cache")) && RNA_property_boolean_get(op->ptr, prop)) + if ((prop = RNA_struct_find_property(op->ptr, "cache")) && RNA_property_boolean_get(op->ptr, prop)) { seq_load->flag |= SEQ_LOAD_SOUND_CACHE; + } - if ((prop = RNA_struct_find_property(op->ptr, "mono")) && RNA_property_boolean_get(op->ptr, prop)) + if ((prop = RNA_struct_find_property(op->ptr, "mono")) && RNA_property_boolean_get(op->ptr, prop)) { seq_load->flag |= SEQ_LOAD_SOUND_MONO; + } - if ((prop = RNA_struct_find_property(op->ptr, "sound")) && RNA_property_boolean_get(op->ptr, prop)) + if ((prop = RNA_struct_find_property(op->ptr, "sound")) && RNA_property_boolean_get(op->ptr, prop)) { seq_load->flag |= SEQ_LOAD_MOVIE_SOUND; + } - if ((prop = RNA_struct_find_property(op->ptr, "use_framerate")) && RNA_property_boolean_get(op->ptr, prop)) + if ((prop = RNA_struct_find_property(op->ptr, "use_framerate")) && RNA_property_boolean_get(op->ptr, prop)) { seq_load->flag |= SEQ_LOAD_SYNC_FPS; + } /* always use this for ops */ seq_load->flag |= SEQ_LOAD_FRAME_ADVANCE; @@ -338,8 +345,9 @@ static int sequencer_add_scene_strip_exec(bContext *C, wmOperator *op) static int sequencer_add_scene_strip_invoke(bContext *C, wmOperator *op, const wmEvent *event) { - if (!RNA_struct_property_is_set(op->ptr, "scene")) + if (!RNA_struct_property_is_set(op->ptr, "scene")) { return WM_enum_search_invoke(C, op, event); + } sequencer_generic_invoke_xy__internal(C, op, 0, SEQ_TYPE_SCENE); return sequencer_add_scene_strip_exec(C, op); @@ -424,8 +432,9 @@ static int sequencer_add_movieclip_strip_exec(bContext *C, wmOperator *op) static int sequencer_add_movieclip_strip_invoke(bContext *C, wmOperator *op, const wmEvent *event) { - if (!RNA_struct_property_is_set(op->ptr, "clip")) + if (!RNA_struct_property_is_set(op->ptr, "clip")) { return WM_enum_search_invoke(C, op, event); + } sequencer_generic_invoke_xy__internal(C, op, 0, SEQ_TYPE_MOVIECLIP); return sequencer_add_movieclip_strip_exec(C, op); @@ -509,8 +518,9 @@ static int sequencer_add_mask_strip_exec(bContext *C, wmOperator *op) static int sequencer_add_mask_strip_invoke(bContext *C, wmOperator *op, const wmEvent *event) { - if (!RNA_struct_property_is_set(op->ptr, "mask")) + if (!RNA_struct_property_is_set(op->ptr, "mask")) { return WM_enum_search_invoke(C, op, event); + } sequencer_generic_invoke_xy__internal(C, op, 0, SEQ_TYPE_MASK); return sequencer_add_mask_strip_exec(C, op); @@ -554,13 +564,16 @@ static int sequencer_add_generic_strip_exec(bContext *C, wmOperator *op, SeqLoad seq_load_operator_info(&seq_load, C, op); - if (seq_load.flag & SEQ_LOAD_REPLACE_SEL) + if (seq_load.flag & SEQ_LOAD_REPLACE_SEL) { ED_sequencer_deselect_all(scene); + } - if (RNA_struct_property_is_set(op->ptr, "files")) + if (RNA_struct_property_is_set(op->ptr, "files")) { tot_files = RNA_property_collection_length(op->ptr, RNA_struct_find_property(op->ptr, "files")); - else + } + else { tot_files = 0; + } if (tot_files) { /* multiple files */ @@ -607,8 +620,9 @@ static int sequencer_add_generic_strip_exec(bContext *C, wmOperator *op, SeqLoad return OPERATOR_CANCELLED; } - if (op->customdata) + if (op->customdata) { MEM_freeN(op->customdata); + } BKE_sequencer_sort(scene); BKE_sequencer_update_muting(ed); @@ -626,8 +640,9 @@ static void sequencer_add_init(bContext *UNUSED(C), wmOperator *op) static void sequencer_add_cancel(bContext *UNUSED(C), wmOperator *op) { - if (op->customdata) + if (op->customdata) { MEM_freeN(op->customdata); + } op->customdata = NULL; } @@ -703,8 +718,9 @@ static void sequencer_add_draw(bContext *UNUSED(C), wmOperator *op) RNA_pointer_create(NULL, &RNA_ImageFormatSettings, imf, &imf_ptr); /* multiview template */ - if (RNA_boolean_get(op->ptr, "show_multiview")) + if (RNA_boolean_get(op->ptr, "show_multiview")) { uiTemplateImageFormatViews(layout, &imf_ptr, op->ptr); + } } void SEQUENCER_OT_movie_strip_add(struct wmOperatorType *ot) @@ -872,11 +888,13 @@ static int sequencer_add_image_strip_exec(bContext *C, wmOperator *op) seq_load.len = RNA_property_collection_length(op->ptr, RNA_struct_find_property(op->ptr, "files")); } - if (seq_load.len == 0) + if (seq_load.len == 0) { return OPERATOR_CANCELLED; + } - if (seq_load.flag & SEQ_LOAD_REPLACE_SEL) + if (seq_load.flag & SEQ_LOAD_REPLACE_SEL) { ED_sequencer_deselect_all(scene); + } /* main adding function */ seq = BKE_sequencer_add_image_strip(C, ed->seqbasep, &seq_load); @@ -916,8 +934,9 @@ static int sequencer_add_image_strip_exec(bContext *C, wmOperator *op) sequencer_add_apply_overlap(C, op, seq); - if (op->customdata) + if (op->customdata) { MEM_freeN(op->customdata); + } WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene); @@ -1057,8 +1076,9 @@ static int sequencer_add_effect_strip_exec(bContext *C, wmOperator *op) int chan = max_iii(seq->seq1 ? seq->seq1->machine : 0, seq->seq2 ? seq->seq2->machine : 0, seq->seq3 ? seq->seq3->machine : 0); - if (chan < MAXSEQ) + if (chan < MAXSEQ) { seq->machine = chan; + } } } diff --git a/source/blender/editors/space_sequencer/sequencer_buttons.c b/source/blender/editors/space_sequencer/sequencer_buttons.c index c1b70a7f14a..7b7f6599404 100644 --- a/source/blender/editors/space_sequencer/sequencer_buttons.c +++ b/source/blender/editors/space_sequencer/sequencer_buttons.c @@ -132,8 +132,9 @@ static int sequencer_properties_toggle_exec(bContext *C, wmOperator *UNUSED(op)) ScrArea *sa = CTX_wm_area(C); ARegion *ar = sequencer_has_buttons_region(sa); - if (ar) + if (ar) { ED_region_toggle_hidden(C, ar); + } return OPERATOR_FINISHED; } diff --git a/source/blender/editors/space_sequencer/sequencer_draw.c b/source/blender/editors/space_sequencer/sequencer_draw.c index 2b2935157be..ea6d4cf69be 100644 --- a/source/blender/editors/space_sequencer/sequencer_draw.c +++ b/source/blender/editors/space_sequencer/sequencer_draw.c @@ -134,9 +134,9 @@ void color3ubv_from_seq(Scene *curscene, Sequence *seq, unsigned char col[3]) UI_GetThemeColor3ubv(TH_SEQ_TRANSITION, col); /* slightly offset hue to distinguish different effects */ - if (seq->type == SEQ_TYPE_CROSS) rgb_byte_set_hue_float_offset(col, 0.04); - if (seq->type == SEQ_TYPE_GAMCROSS) rgb_byte_set_hue_float_offset(col, 0.08); - if (seq->type == SEQ_TYPE_WIPE) rgb_byte_set_hue_float_offset(col, 0.12); + if (seq->type == SEQ_TYPE_CROSS) { rgb_byte_set_hue_float_offset(col, 0.04); } + if (seq->type == SEQ_TYPE_GAMCROSS) { rgb_byte_set_hue_float_offset(col, 0.08); } + if (seq->type == SEQ_TYPE_WIPE) { rgb_byte_set_hue_float_offset(col, 0.12); } break; /* effects */ @@ -156,18 +156,18 @@ void color3ubv_from_seq(Scene *curscene, Sequence *seq, unsigned char col[3]) UI_GetThemeColor3ubv(TH_SEQ_EFFECT, col); /* slightly offset hue to distinguish different effects */ - if (seq->type == SEQ_TYPE_ADD) rgb_byte_set_hue_float_offset(col, 0.04); - else if (seq->type == SEQ_TYPE_SUB) rgb_byte_set_hue_float_offset(col, 0.08); - else if (seq->type == SEQ_TYPE_MUL) rgb_byte_set_hue_float_offset(col, 0.12); - else if (seq->type == SEQ_TYPE_ALPHAOVER) rgb_byte_set_hue_float_offset(col, 0.16); - else if (seq->type == SEQ_TYPE_ALPHAUNDER) rgb_byte_set_hue_float_offset(col, 0.20); - else if (seq->type == SEQ_TYPE_OVERDROP) rgb_byte_set_hue_float_offset(col, 0.24); - else if (seq->type == SEQ_TYPE_GLOW) rgb_byte_set_hue_float_offset(col, 0.28); - else if (seq->type == SEQ_TYPE_TRANSFORM) rgb_byte_set_hue_float_offset(col, 0.36); - else if (seq->type == SEQ_TYPE_MULTICAM) rgb_byte_set_hue_float_offset(col, 0.32); - else if (seq->type == SEQ_TYPE_ADJUSTMENT) rgb_byte_set_hue_float_offset(col, 0.40); - else if (seq->type == SEQ_TYPE_GAUSSIAN_BLUR) rgb_byte_set_hue_float_offset(col, 0.42); - else if (seq->type == SEQ_TYPE_COLORMIX) rgb_byte_set_hue_float_offset(col, 0.46); + if (seq->type == SEQ_TYPE_ADD) { rgb_byte_set_hue_float_offset(col, 0.04); } + else if (seq->type == SEQ_TYPE_SUB) { rgb_byte_set_hue_float_offset(col, 0.08); } + else if (seq->type == SEQ_TYPE_MUL) { rgb_byte_set_hue_float_offset(col, 0.12); } + else if (seq->type == SEQ_TYPE_ALPHAOVER) { rgb_byte_set_hue_float_offset(col, 0.16); } + else if (seq->type == SEQ_TYPE_ALPHAUNDER) { rgb_byte_set_hue_float_offset(col, 0.20); } + else if (seq->type == SEQ_TYPE_OVERDROP) { rgb_byte_set_hue_float_offset(col, 0.24); } + else if (seq->type == SEQ_TYPE_GLOW) { rgb_byte_set_hue_float_offset(col, 0.28); } + else if (seq->type == SEQ_TYPE_TRANSFORM) { rgb_byte_set_hue_float_offset(col, 0.36); } + else if (seq->type == SEQ_TYPE_MULTICAM) { rgb_byte_set_hue_float_offset(col, 0.32); } + else if (seq->type == SEQ_TYPE_ADJUSTMENT) { rgb_byte_set_hue_float_offset(col, 0.40); } + else if (seq->type == SEQ_TYPE_GAUSSIAN_BLUR) { rgb_byte_set_hue_float_offset(col, 0.42); } + else if (seq->type == SEQ_TYPE_COLORMIX) { rgb_byte_set_hue_float_offset(col, 0.46); } break; case SEQ_TYPE_COLOR: @@ -177,7 +177,9 @@ void color3ubv_from_seq(Scene *curscene, Sequence *seq, unsigned char col[3]) case SEQ_TYPE_SOUND_RAM: UI_GetThemeColor3ubv(TH_SEQ_AUDIO, col); blendcol[0] = blendcol[1] = blendcol[2] = 128; - if (seq->flag & SEQ_MUTE) UI_GetColorPtrBlendShade3ubv(col, blendcol, col, 0.5, 20); + if (seq->flag & SEQ_MUTE) { + UI_GetColorPtrBlendShade3ubv(col, blendcol, col, 0.5, 20); + } break; case SEQ_TYPE_TEXT: @@ -273,11 +275,13 @@ static void drawseqwave(View2D *v2d, const bContext *C, SpaceSeq *sseq, Scene *s if (samplestep > 1.0f) { for (j = p + 1; (j < waveform->length) && (j < p + samplestep); j++) { - if (value1 > waveform->data[j * 3]) + if (value1 > waveform->data[j * 3]) { value1 = waveform->data[j * 3]; + } - if (value2 < waveform->data[j * 3 + 1]) + if (value2 < waveform->data[j * 3 + 1]) { value2 = waveform->data[j * 3 + 1]; + } } } else if (p + 1 < waveform->length) { @@ -377,8 +381,12 @@ static void drawmeta_contents(Scene *scene, Sequence *seqm, float x1, float y1, immUniformColor4ubv(col); /* clamp within parent sequence strip bounds */ - if (x1_chan < x1) x1_chan = x1; - if (x2_chan > x2) x2_chan = x2; + if (x1_chan < x1) { + x1_chan = x1; + } + if (x2_chan > x2) { + x2_chan = x2; + } y1_chan = y1 + y_chan + (draw_height * SEQ_STRIP_OFSBOTTOM); y2_chan = y1 + y_chan + (draw_height * SEQ_STRIP_OFSTOP); @@ -508,8 +516,9 @@ static void draw_seq_text( char col[4]; /* note, all strings should include 'name' */ - if (name[0] == '\0') + if (name[0] == '\0') { name = BKE_sequence_give_name(seq); + } if (seq->type == SEQ_TYPE_META || seq->type == SEQ_TYPE_ADJUSTMENT) { str_len = BLI_snprintf(str, sizeof(str), "%s | %d", name, seq->len); @@ -628,7 +637,9 @@ static void draw_sequence_extensions(Scene *scene, ARegion *ar, Sequence *seq, u pixely = BLI_rctf_size_y(&v2d->cur) / BLI_rcti_size_y(&v2d->mask); - if (pixely <= 0) return; /* can happen when the view is split/resized */ + if (pixely <= 0) { + return; /* can happen when the view is split/resized */ + } blendcol[0] = blendcol[1] = blendcol[2] = 120; @@ -839,11 +850,13 @@ static void draw_seq_strip( if (seq->flag & SEQ_OVERLAP) { col[0] = 255; col[1] = col[2] = 40; } - else + else { UI_GetColorPtrShade3ubv(col, col, 120 + outline_tint); + } } - else + else { UI_GetColorPtrShade3ubv(col, col, outline_tint); + } if ((seq->type == SEQ_TYPE_META) || ((seq->type == SEQ_TYPE_SCENE) && (seq->flag & SEQ_SCENE_STRIPS))) @@ -879,10 +892,18 @@ static void draw_seq_strip( float scroller_vert_xoffs = (V2D_SCROLL_WIDTH_TEXT + SEQ_SCROLLER_TEXT_OFFSET) * pixelx; /* info text on the strip */ - if (x1 < v2d->cur.xmin + scroller_vert_xoffs) x1 = v2d->cur.xmin + scroller_vert_xoffs; - else if (x1 > v2d->cur.xmax) x1 = v2d->cur.xmax; - if (x2 < v2d->cur.xmin) x2 = v2d->cur.xmin; - else if (x2 > v2d->cur.xmax) x2 = v2d->cur.xmax; + if (x1 < v2d->cur.xmin + scroller_vert_xoffs) { + x1 = v2d->cur.xmin + scroller_vert_xoffs; + } + else if (x1 > v2d->cur.xmax) { + x1 = v2d->cur.xmax; + } + if (x2 < v2d->cur.xmin) { + x2 = v2d->cur.xmin; + } + else if (x2 > v2d->cur.xmax) { + x2 = v2d->cur.xmax; + } /* nice text here would require changing the view matrix for texture text */ if ((x2 - x1) / pixelx > 32) { @@ -956,12 +977,15 @@ ImBuf *sequencer_ibuf_get( GPUFrameBuffer *fb = GPU_framebuffer_active_get(); GPU_framebuffer_restore(); - if (special_seq_update) + if (special_seq_update) { ibuf = BKE_sequencer_give_ibuf_direct(&context, cfra + frame_ofs, special_seq_update); - else if (!U.prefetchframes) // XXX || (G.f & G_PLAYANIM) == 0) { + } + else if (!U.prefetchframes) { // XXX || (G.f & G_PLAYANIM) == 0) { ibuf = BKE_sequencer_give_ibuf(&context, cfra + frame_ofs, sseq->chanshown); - else + } + else { ibuf = BKE_sequencer_give_ibuf_threaded(&context, cfra + frame_ofs, sseq->chanshown); + } GPU_framebuffer_bind(fb); @@ -1176,8 +1200,9 @@ static void *sequencer_OCIO_transform_ibuf(const bContext *C, ImBuf *ibuf, bool *format = GL_RGBA; *type = GL_UNSIGNED_BYTE; } - if (cache_handle) + if (cache_handle) { IMB_display_buffer_release(cache_handle); + } return display_buffer; } @@ -1373,24 +1398,28 @@ static ImBuf *sequencer_get_scope(Scene *scene, SpaceSeq *sseq, ImBuf *ibuf, boo break; case SEQ_DRAW_IMG_WAVEFORM: if ((sseq->flag & SEQ_DRAW_COLOR_SEPARATED) != 0) { - if (!scopes->sep_waveform_ibuf) + if (!scopes->sep_waveform_ibuf) { scopes->sep_waveform_ibuf = sequencer_make_scope(scene, ibuf, make_sep_waveform_view_from_ibuf); + } scope = scopes->sep_waveform_ibuf; } else { - if (!scopes->waveform_ibuf) + if (!scopes->waveform_ibuf) { scopes->waveform_ibuf = sequencer_make_scope(scene, ibuf, make_waveform_view_from_ibuf); + } scope = scopes->waveform_ibuf; } break; case SEQ_DRAW_IMG_VECTORSCOPE: - if (!scopes->vector_ibuf) + if (!scopes->vector_ibuf) { scopes->vector_ibuf = sequencer_make_scope(scene, ibuf, make_vectorscope_view_from_ibuf); + } scope = scopes->vector_ibuf; break; case SEQ_DRAW_IMG_HISTOGRAM: - if (!scopes->histogram_ibuf) + if (!scopes->histogram_ibuf) { scopes->histogram_ibuf = sequencer_make_scope(scene, ibuf, make_histogram_view_from_ibuf); + } scope = scopes->histogram_ibuf; break; } @@ -1564,12 +1593,12 @@ static void draw_seq_strips(const bContext *C, Editing *ed, ARegion *ar) /* loop through strips, checking for those that are visible */ for (seq = ed->seqbasep->first; seq; seq = seq->next) { /* boundbox and selection tests for NOT drawing the strip... */ - if ((seq->flag & SELECT) != sel) continue; - else if (seq == last_seq) continue; - else if (min_ii(seq->startdisp, seq->start) > v2d->cur.xmax) continue; - else if (max_ii(seq->enddisp, seq->start + seq->len) < v2d->cur.xmin) continue; - else if (seq->machine + 1.0f < v2d->cur.ymin) continue; - else if (seq->machine > v2d->cur.ymax) continue; + if ((seq->flag & SELECT) != sel) { continue; } + else if (seq == last_seq) { continue; } + else if (min_ii(seq->startdisp, seq->start) > v2d->cur.xmax) { continue; } + else if (max_ii(seq->enddisp, seq->start + seq->len) < v2d->cur.xmin) { continue; } + else if (seq->machine + 1.0f < v2d->cur.ymin) { continue; } + else if (seq->machine > v2d->cur.ymax) { continue; } /* strip passed all tests unscathed... so draw it now */ draw_seq_strip(C, sseq, scene, ar, seq, outline_tint, pixelx); @@ -1581,8 +1610,9 @@ static void draw_seq_strips(const bContext *C, Editing *ed, ARegion *ar) /* draw the last selected last (i.e. 'active' in other parts of Blender), * removes some overlapping error */ - if (last_seq) + if (last_seq) { draw_seq_strip(C, sseq, scene, ar, last_seq, 120, pixelx); + } /* draw highlight when previewing a single strip */ if (special_seq_update) { @@ -1674,10 +1704,12 @@ void draw_timeline_seq(const bContext *C, ARegion *ar) /* clear and setup matrix */ UI_GetThemeColor3fv(TH_BACK, col); - if (ed && ed->metastack.first) + if (ed && ed->metastack.first) { GPU_clear_color(col[0], col[1], col[2] - 0.1f, 0.0f); - else + } + else { GPU_clear_color(col[0], col[1], col[2], 0.0f); + } GPU_clear(GPU_COLOR_BIT); UI_view2d_view_ortho(v2d); @@ -1716,7 +1748,9 @@ void draw_timeline_seq(const bContext *C, ARegion *ar) /* current frame */ UI_view2d_view_ortho(v2d); - if ((sseq->flag & SEQ_DRAWFRAMES) == 0) cfra_flag |= DRAWCFRA_UNIT_SECONDS; + if ((sseq->flag & SEQ_DRAWFRAMES) == 0) { + cfra_flag |= DRAWCFRA_UNIT_SECONDS; + } ANIM_draw_cfra(C, v2d, cfra_flag); /* markers */ diff --git a/source/blender/editors/space_sequencer/sequencer_edit.c b/source/blender/editors/space_sequencer/sequencer_edit.c index 6e4ffd39edc..b7d3bec326a 100644 --- a/source/blender/editors/space_sequencer/sequencer_edit.c +++ b/source/blender/editors/space_sequencer/sequencer_edit.c @@ -229,11 +229,20 @@ static void seq_proxy_build_job(const bContext *C) void seq_rectf(Sequence *seq, rctf *rectf) { - if (seq->startstill) rectf->xmin = seq->start; - else rectf->xmin = seq->startdisp; + if (seq->startstill) { + rectf->xmin = seq->start; + } + else { + rectf->xmin = seq->startdisp; + } + rectf->ymin = seq->machine + SEQ_STRIP_OFSBOTTOM; - if (seq->endstill) rectf->xmax = seq->start + seq->len; - else rectf->xmax = seq->enddisp; + if (seq->endstill) { + rectf->xmax = seq->start + seq->len; + } + else { + rectf->xmax = seq->enddisp; + } rectf->ymax = seq->machine + SEQ_STRIP_OFSTOP; } @@ -244,7 +253,9 @@ void boundbox_seq(Scene *scene, rctf *rect) float min[2], max[2]; - if (ed == NULL) return; + if (ed == NULL) { + return; + } min[0] = 0.0; max[0] = EFRA + 1; @@ -254,9 +265,15 @@ void boundbox_seq(Scene *scene, rctf *rect) seq = ed->seqbasep->first; while (seq) { - if (min[0] > seq->startdisp - 1) min[0] = seq->startdisp - 1; - if (max[0] < seq->enddisp + 1) max[0] = seq->enddisp + 1; - if (max[1] < seq->machine + 2) max[1] = seq->machine + 2; + if (min[0] > seq->startdisp - 1) { + min[0] = seq->startdisp - 1; + } + if (max[0] < seq->enddisp + 1) { + max[0] = seq->enddisp + 1; + } + if (max[1] < seq->machine + 2) { + max[1] = seq->machine + 2; + } seq = seq->next; } @@ -289,9 +306,13 @@ Sequence *find_neighboring_sequence(Scene *scene, Sequence *test, int lr, int se Sequence *seq; Editing *ed = BKE_sequencer_editing_get(scene, false); - if (ed == NULL) return NULL; + if (ed == NULL) { + return NULL; + } - if (sel > 0) sel = SELECT; + if (sel > 0) { + sel = SELECT; + } for (seq = ed->seqbasep->first; seq; seq = seq->next) { if ((seq != test) && @@ -325,7 +346,9 @@ static Sequence *find_next_prev_sequence(Scene *scene, Sequence *test, int lr, i best_dist = MAXFRAME * 2; - if (ed == NULL) return NULL; + if (ed == NULL) { + return NULL; + } seq = ed->seqbasep->first; while (seq) { @@ -375,7 +398,9 @@ Sequence *find_nearest_seq(Scene *scene, View2D *v2d, int *hand, const int mval[ *hand = SEQ_SIDE_NONE; - if (ed == NULL) return NULL; + if (ed == NULL) { + return NULL; + } pixelx = BLI_rctf_size_x(&v2d->cur) / BLI_rcti_size_x(&v2d->mask); @@ -409,10 +434,12 @@ Sequence *find_nearest_seq(Scene *scene, View2D *v2d, int *hand, const int mval[ CLAMP(handsize, 7 * pixelx, 30 * pixelx); } - if (handsize + seq->startdisp >= x) + if (handsize + seq->startdisp >= x) { *hand = SEQ_SIDE_LEFT; - else if (-handsize + seq->enddisp <= x) + } + else if (-handsize + seq->enddisp <= x) { *hand = SEQ_SIDE_RIGHT; + } } } return seq; @@ -431,12 +458,12 @@ static bool seq_is_parent(Sequence *par, Sequence *seq) static bool seq_is_predecessor(Sequence *pred, Sequence *seq) { - if (!pred) return 0; - if (pred == seq) return 0; - else if (seq_is_parent(pred, seq)) return 1; - else if (pred->seq1 && seq_is_predecessor(pred->seq1, seq)) return 1; - else if (pred->seq2 && seq_is_predecessor(pred->seq2, seq)) return 1; - else if (pred->seq3 && seq_is_predecessor(pred->seq3, seq)) return 1; + if (!pred) { return 0; } + if (pred == seq) { return 0; } + else if (seq_is_parent(pred, seq)) { return 1; } + else if (pred->seq1 && seq_is_predecessor(pred->seq1, seq)) { return 1; } + else if (pred->seq2 && seq_is_predecessor(pred->seq2, seq)) { return 1; } + else if (pred->seq3 && seq_is_predecessor(pred->seq3, seq)) { return 1; } return 0; } @@ -447,7 +474,9 @@ void ED_sequencer_deselect_all(Scene *scene) Editing *ed = BKE_sequencer_editing_get(scene, false); - if (ed == NULL) return; + if (ed == NULL) { + return; + } SEQP_BEGIN (ed, seq) { @@ -463,11 +492,19 @@ void recurs_sel_seq(Sequence *seqm) seq = seqm->seqbase.first; while (seq) { - if (seqm->flag & (SEQ_LEFTSEL + SEQ_RIGHTSEL)) seq->flag &= ~SEQ_ALLSEL; - else if (seqm->flag & SELECT) seq->flag |= SELECT; - else seq->flag &= ~SEQ_ALLSEL; + if (seqm->flag & (SEQ_LEFTSEL + SEQ_RIGHTSEL)) { + seq->flag &= ~SEQ_ALLSEL; + } + else if (seqm->flag & SELECT) { + seq->flag |= SELECT; + } + else { + seq->flag &= ~SEQ_ALLSEL; + } - if (seq->seqbase.first) recurs_sel_seq(seq); + if (seq->seqbase.first) { + recurs_sel_seq(seq); + } seq = seq->next; } @@ -521,8 +558,9 @@ int seq_effect_find_selected(Scene *scene, Sequence *activeseq, int type, Sequen *error_str = NULL; - if (!activeseq) + if (!activeseq) { seq2 = BKE_sequencer_active_get(scene); + } for (seq = ed->seqbasep->first; seq; seq = seq->next) { if (seq->flag & SELECT) { @@ -531,9 +569,15 @@ int seq_effect_find_selected(Scene *scene, Sequence *activeseq, int type, Sequen return 0; } if ((seq != activeseq) && (seq != seq2)) { - if (seq2 == NULL) seq2 = seq; - else if (seq1 == NULL) seq1 = seq; - else if (seq3 == NULL) seq3 = seq; + if (seq2 == NULL) { + seq2 = seq; + } + else if (seq1 == NULL) { + seq1 = seq; + } + else if (seq3 == NULL) { + seq3 = seq; + } else { *error_str = N_("Cannot apply effect to more than 3 sequence strips"); return 0; @@ -560,15 +604,21 @@ int seq_effect_find_selected(Scene *scene, Sequence *activeseq, int type, Sequen *error_str = N_("At least one selected sequence strip is needed"); return 0; } - if (seq1 == NULL) seq1 = seq2; - if (seq3 == NULL) seq3 = seq2; + if (seq1 == NULL) { + seq1 = seq2; + } + if (seq3 == NULL) { + seq3 = seq2; + } ATTR_FALLTHROUGH; case 2: if (seq1 == NULL || seq2 == NULL) { *error_str = N_("2 selected sequence strips are needed"); return 0; } - if (seq3 == NULL) seq3 = seq2; + if (seq3 == NULL) { + seq3 = seq2; + } break; } @@ -591,10 +641,12 @@ static Sequence *del_seq_find_replace_recurs(Scene *scene, Sequence *seq) /* try to find a replacement input sequence, and flag for later deletion if * no replacement can be found */ - if (!seq) + if (!seq) { return NULL; - else if (!(seq->type & SEQ_TYPE_EFFECT)) + } + else if (!(seq->type & SEQ_TYPE_EFFECT)) { return ((seq->flag & SELECT) ? NULL : seq); + } else if (!(seq->flag & SELECT)) { /* try to find replacement for effect inputs */ seq1 = del_seq_find_replace_recurs(scene, seq->seq1); @@ -611,18 +663,22 @@ static Sequence *del_seq_find_replace_recurs(Scene *scene, Sequence *seq) BKE_sequencer_update_changed_seq_and_deps(scene, seq, 1, 1); } - else + else { seq->flag |= SELECT; /* mark for delete */ + } } if (seq->flag & SELECT) { - if ((seq1 = del_seq_find_replace_recurs(scene, seq->seq1))) return seq1; - if ((seq2 = del_seq_find_replace_recurs(scene, seq->seq2))) return seq2; - if ((seq3 = del_seq_find_replace_recurs(scene, seq->seq3))) return seq3; - else return NULL; + if ((seq1 = del_seq_find_replace_recurs(scene, seq->seq1))) { return seq1; } + if ((seq2 = del_seq_find_replace_recurs(scene, seq->seq2))) { return seq2; } + if ((seq3 = del_seq_find_replace_recurs(scene, seq->seq3))) { return seq3; } + else { + return NULL; + } } - else + else { return seq; + } } static void del_seq_clear_modifiers_recurs(Scene *scene, Sequence *deleting_sequence) @@ -654,8 +710,12 @@ static void recurs_del_seq_flag(Scene *scene, ListBase *lb, short flag, short de seqn = seq->next; if ((seq->flag & flag) || deleteall) { BLI_remlink(lb, seq); - if (seq == last_seq) BKE_sequencer_active_set(scene, NULL); - if (seq->type == SEQ_TYPE_META) recurs_del_seq_flag(scene, &seq->seqbase, flag, 1); + if (seq == last_seq) { + BKE_sequencer_active_set(scene, NULL); + } + if (seq->type == SEQ_TYPE_META) { + recurs_del_seq_flag(scene, &seq->seqbase, flag, 1); + } BKE_sequence_free(scene, seq); } seq = seqn; @@ -945,7 +1005,9 @@ static bool sequence_offset_after_frame(Scene *scene, const int delta, const int /* all strips >= cfra are shifted */ - if (ed == NULL) return 0; + if (ed == NULL) { + return 0; + } for (seq = ed->seqbasep->first; seq; seq = seq->next) { if (seq->startdisp >= cfra) { @@ -998,8 +1060,9 @@ static void UNUSED_FUNCTION(seq_remap_paths) (Scene *scene) char from[FILE_MAX], to[FILE_MAX], stripped[FILE_MAX]; - if (last_seq == NULL) + if (last_seq == NULL) { return; + } BLI_strncpy(from, last_seq->strip->dir, sizeof(from)); // XXX if (0 == sbutton(from, 0, sizeof(from) - 1, "From: ")) @@ -1009,8 +1072,9 @@ static void UNUSED_FUNCTION(seq_remap_paths) (Scene *scene) // XXX if (0 == sbutton(to, 0, sizeof(to) - 1, "To: ")) // return; - if (STREQ(to, from)) + if (STREQ(to, from)) { return; + } SEQP_BEGIN (ed, seq) { @@ -1056,15 +1120,21 @@ static int sequencer_gap_remove_exec(bContext *C, wmOperator *op) for ( ; cfra < efra; cfra++) { /* first == 0 means there's still no strip to remove a gap for */ if (first == false) { - if (BKE_sequencer_evaluate_frame(scene, cfra) ) first = true; + if (BKE_sequencer_evaluate_frame(scene, cfra) ) { + first = true; + } } else if (BKE_sequencer_evaluate_frame(scene, cfra) == 0) { done = true; while (BKE_sequencer_evaluate_frame(scene, cfra) == 0) { done = sequence_offset_after_frame(scene, -1, cfra); - if (done == false) break; + if (done == false) { + break; + } + } + if (done == false || do_all == false) { + break; } - if (done == false || do_all == false) break; } } @@ -1166,8 +1236,9 @@ bool sequencer_view_preview_poll(bContext *C) { SpaceSeq *sseq = CTX_wm_space_seq(C); Editing *ed = BKE_sequencer_editing_get(CTX_data_scene(C), false); - if (ed && sseq && (sseq->mainb == SEQ_DRAW_IMG_IMBUF)) + if (ed && sseq && (sseq->mainb == SEQ_DRAW_IMG_IMBUF)) { return 1; + } return 0; } @@ -1175,8 +1246,9 @@ bool sequencer_view_preview_poll(bContext *C) bool sequencer_view_strips_poll(bContext *C) { SpaceSeq *sseq = CTX_wm_space_seq(C); - if (sseq && ED_space_sequencer_check_show_strip(sseq)) + if (sseq && ED_space_sequencer_check_show_strip(sseq)) { return 1; + } return 0; } @@ -1227,12 +1299,15 @@ static int sequencer_snap_exec(bContext *C, wmOperator *op) } } else if (seq->type & SEQ_TYPE_EFFECT) { - if (seq->seq1 && (seq->seq1->flag & SELECT)) + if (seq->seq1 && (seq->seq1->flag & SELECT)) { BKE_sequence_calc(scene, seq); - else if (seq->seq2 && (seq->seq2->flag & SELECT)) + } + else if (seq->seq2 && (seq->seq2->flag & SELECT)) { BKE_sequence_calc(scene, seq); - else if (seq->seq3 && (seq->seq3->flag & SELECT)) + } + else if (seq->seq3 && (seq->seq3->flag & SELECT)) { BKE_sequence_calc(scene, seq); + } } } @@ -1372,8 +1447,9 @@ static int sequencer_slip_invoke(bContext *C, wmOperator *op, const wmEvent *eve /* first recursively count the trimmed elements */ num_seq = slip_count_sequences_rec(ed->seqbasep, true); - if (num_seq == 0) + if (num_seq == 0) { return OPERATOR_CANCELLED; + } data = op->customdata = MEM_mallocN(sizeof(SlipData), "trimdata"); data->ts = MEM_mallocN(num_seq * sizeof(TransSeq), "trimdata_transform"); @@ -1457,8 +1533,9 @@ static bool sequencer_slip_recursively(Scene *scene, SlipData *data, int offset) /* effects are only added if we they are in a metastrip. In this case, dependent strips will just be transformed and we can skip calculating for effects * This way we can avoid an extra loop just for effects*/ - if (!(seq->type & SEQ_TYPE_EFFECT)) + if (!(seq->type & SEQ_TYPE_EFFECT)) { BKE_sequence_calc(scene, seq); + } } BKE_sequencer_free_imbuf(scene, &ed->seqbase, false); @@ -1480,8 +1557,9 @@ static int sequencer_slip_exec(bContext *C, wmOperator *op) /* first recursively count the trimmed elements */ num_seq = slip_count_sequences_rec(ed->seqbasep, true); - if (num_seq == 0) + if (num_seq == 0) { return OPERATOR_CANCELLED; + } data = op->customdata = MEM_mallocN(sizeof(SlipData), "trimdata"); data->ts = MEM_mallocN(num_seq * sizeof(TransSeq), "trimdata_transform"); @@ -1874,8 +1952,9 @@ static int sequencer_reload_exec(bContext *C, wmOperator *op) BKE_sequence_reload_new_file(scene, seq, !adjust_length); if (adjust_length) { - if (BKE_sequence_test_overlap(ed->seqbasep, seq)) + if (BKE_sequence_test_overlap(ed->seqbasep, seq)) { BKE_sequence_base_shuffle(ed->seqbasep, seq, scene); + } } } } @@ -2171,8 +2250,9 @@ static int sequencer_add_duplicate_exec(bContext *C, wmOperator *UNUSED(op)) ListBase nseqbase = {NULL, NULL}; - if (ed == NULL) + if (ed == NULL) { return OPERATOR_CANCELLED; + } BKE_sequence_base_dupli_recursive(scene, scene, &nseqbase, ed->seqbasep, SEQ_DUPE_CONTEXT, 0); @@ -2181,8 +2261,9 @@ static int sequencer_add_duplicate_exec(bContext *C, wmOperator *UNUSED(op)) /* rely on the nseqbase list being added at the end */ BLI_movelisttolist(ed->seqbasep, &nseqbase); - for (; seq; seq = seq->next) + for (; seq; seq = seq->next) { BKE_sequencer_recursive_apply(seq, apply_unique_name_cb, scene); + } WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene); return OPERATOR_FINISHED; @@ -2277,8 +2358,9 @@ static int sequencer_delete_invoke(bContext *C, wmOperator *op, const wmEvent *e /* bounding box of 30 pixels is used for markers shortcuts, * prevent conflict with markers shortcuts here */ - if (event->mval[1] <= 30) + if (event->mval[1] <= 30) { return OPERATOR_PASS_THROUGH; + } } return WM_operator_confirm(C, op, event); @@ -2483,8 +2565,9 @@ static int sequencer_meta_toggle_exec(bContext *C, wmOperator *UNUSED(op)) Sequence *seq; - if (BLI_listbase_is_empty(&ed->metastack)) + if (BLI_listbase_is_empty(&ed->metastack)) { return OPERATOR_CANCELLED; + } ms = ed->metastack.last; BLI_remlink(&ed->metastack, ms); @@ -2497,8 +2580,9 @@ static int sequencer_meta_toggle_exec(bContext *C, wmOperator *UNUSED(op)) } /* recalc all: the meta can have effects connected to it */ - for (seq = ed->seqbasep->first; seq; seq = seq->next) + for (seq = ed->seqbasep->first; seq; seq = seq->next) { BKE_sequence_calc(scene, seq); + } /* 2.73+, keeping endpoings is important! * moving them around means you can't usefully use metas in a complex edit */ @@ -2508,8 +2592,9 @@ static int sequencer_meta_toggle_exec(bContext *C, wmOperator *UNUSED(op)) BKE_sequence_single_fix(ms->parseq); BKE_sequence_calc(scene, ms->parseq); #else - if (BKE_sequence_test_overlap(ed->seqbasep, ms->parseq)) + if (BKE_sequence_test_overlap(ed->seqbasep, ms->parseq)) { BKE_sequence_base_shuffle(ed->seqbasep, ms->parseq, scene); + } #endif BKE_sequencer_active_set(scene, ms->parseq); @@ -2583,7 +2668,9 @@ static int sequencer_meta_make_exec(bContext *C, wmOperator *op) BKE_sequencer_active_set(scene, seqm); - if (BKE_sequence_test_overlap(ed->seqbasep, seqm) ) BKE_sequence_base_shuffle(ed->seqbasep, seqm, scene); + if (BKE_sequence_test_overlap(ed->seqbasep, seqm)) { + BKE_sequence_base_shuffle(ed->seqbasep, seqm, scene); + } BKE_sequencer_update_muting(ed); @@ -2612,11 +2699,21 @@ void SEQUENCER_OT_meta_make(wmOperatorType *ot) static int seq_depends_on_meta(Sequence *seq, Sequence *seqm) { - if (seq == seqm) return 1; - else if (seq->seq1 && seq_depends_on_meta(seq->seq1, seqm)) return 1; - else if (seq->seq2 && seq_depends_on_meta(seq->seq2, seqm)) return 1; - else if (seq->seq3 && seq_depends_on_meta(seq->seq3, seqm)) return 1; - else return 0; + if (seq == seqm) { + return 1; + } + else if (seq->seq1 && seq_depends_on_meta(seq->seq1, seqm)) { + return 1; + } + else if (seq->seq2 && seq_depends_on_meta(seq->seq2, seqm)) { + return 1; + } + else if (seq->seq3 && seq_depends_on_meta(seq->seq3, seqm)) { + return 1; + } + else { + return 0; + } } /* separate_meta_make operator */ @@ -2627,8 +2724,9 @@ static int sequencer_meta_separate_exec(bContext *C, wmOperator *UNUSED(op)) Sequence *seq, *last_seq = BKE_sequencer_active_get(scene); /* last_seq checks (ed == NULL) */ - if (last_seq == NULL || last_seq->type != SEQ_TYPE_META) + if (last_seq == NULL || last_seq->type != SEQ_TYPE_META) { return OPERATOR_CANCELLED; + } for (seq = last_seq->seqbase.first; seq != NULL; seq = seq->next) { BKE_sequence_invalidate_cache(scene, seq); @@ -2642,9 +2740,11 @@ static int sequencer_meta_separate_exec(bContext *C, wmOperator *UNUSED(op)) BKE_sequence_free(scene, last_seq); /* empty meta strip, delete all effects depending on it */ - for (seq = ed->seqbasep->first; seq; seq = seq->next) - if ((seq->type & SEQ_TYPE_EFFECT) && seq_depends_on_meta(seq, last_seq)) + for (seq = ed->seqbasep->first; seq; seq = seq->next) { + if ((seq->type & SEQ_TYPE_EFFECT) && seq_depends_on_meta(seq, last_seq)) { seq->flag |= SEQ_FLAG_DELETE; + } + } recurs_del_seq_flag(scene, ed->seqbasep, SEQ_FLAG_DELETE, 0); @@ -2850,7 +2950,9 @@ static int sequencer_view_toggle_exec(bContext *C, wmOperator *UNUSED(op)) SpaceSeq *sseq = (SpaceSeq *)CTX_wm_space_data(C); sseq->view++; - if (sseq->view > SEQ_VIEW_SEQUENCE_PREVIEW) sseq->view = SEQ_VIEW_SEQUENCE; + if (sseq->view > SEQ_VIEW_SEQUENCE_PREVIEW) { + sseq->view = SEQ_VIEW_SEQUENCE; + } ED_area_tag_refresh(CTX_wm_area(C)); @@ -2893,8 +2995,9 @@ static int sequencer_view_selected_exec(bContext *C, wmOperator *op) int ymargin = 1; int xmargin = FPS; - if (ed == NULL) + if (ed == NULL) { return OPERATOR_CANCELLED; + } for (seq = ed->seqbasep->first; seq; seq = seq->next) { if ((seq->flag & SELECT) || (seq == last_seq)) { @@ -2974,8 +3077,9 @@ static bool strip_jump_internal(Scene *scene, static bool sequencer_strip_jump_poll(bContext *C) { /* prevent changes during render */ - if (G.is_rendering) + if (G.is_rendering) { return 0; + } return sequencer_edit_poll(C); } @@ -3059,17 +3163,21 @@ static int sequencer_swap_exec(bContext *C, wmOperator *op) Sequence *seq, *iseq; int side = RNA_enum_get(op->ptr, "side"); - if (active_seq == NULL) return OPERATOR_CANCELLED; + if (active_seq == NULL) { + return OPERATOR_CANCELLED; + } seq = find_next_prev_sequence(scene, active_seq, side, -1); if (seq) { /* disallow effect strips */ - if (BKE_sequence_effect_get_num_inputs(seq->type) >= 1 && (seq->effectdata || seq->seq1 || seq->seq2 || seq->seq3)) + if (BKE_sequence_effect_get_num_inputs(seq->type) >= 1 && (seq->effectdata || seq->seq1 || seq->seq2 || seq->seq3)) { return OPERATOR_CANCELLED; - if ((BKE_sequence_effect_get_num_inputs(active_seq->type) >= 1) && (active_seq->effectdata || active_seq->seq1 || active_seq->seq2 || active_seq->seq3)) + } + if ((BKE_sequence_effect_get_num_inputs(active_seq->type) >= 1) && (active_seq->effectdata || active_seq->seq1 || active_seq->seq2 || active_seq->seq3)) { return OPERATOR_CANCELLED; + } switch (side) { case SEQ_SIDE_LEFT: @@ -3134,8 +3242,9 @@ static int sequencer_rendersize_exec(bContext *C, wmOperator *UNUSED(op)) Sequence *active_seq = BKE_sequencer_active_get(scene); StripElem *se = NULL; - if (active_seq == NULL) + if (active_seq == NULL) { return OPERATOR_CANCELLED; + } if (active_seq->strip) { @@ -3223,8 +3332,9 @@ static int sequencer_copy_exec(bContext *C, wmOperator *op) Sequence *seq, *first_seq = nseqbase.first; BLI_movelisttolist(ed->seqbasep, &nseqbase); - for (seq = first_seq; seq; seq = seq->next) + for (seq = first_seq; seq; seq = seq->next) { BKE_sequencer_recursive_apply(seq, apply_unique_name_cb, scene); + } seqbase_clipboard.first = first_seq; seqbase_clipboard.last = ed->seqbasep->last; @@ -3350,11 +3460,13 @@ static int sequencer_swap_data_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } - if (seq_act->scene_sound) + if (seq_act->scene_sound) { BKE_sound_remove_scene_sound(scene, seq_act->scene_sound); + } - if (seq_other->scene_sound) + if (seq_other->scene_sound) { BKE_sound_remove_scene_sound(scene, seq_other->scene_sound); + } seq_act->scene_sound = NULL; seq_other->scene_sound = NULL; @@ -3362,8 +3474,12 @@ static int sequencer_swap_data_exec(bContext *C, wmOperator *op) BKE_sequence_calc(scene, seq_act); BKE_sequence_calc(scene, seq_other); - if (seq_act->sound) BKE_sound_add_scene_sound_defaults(scene, seq_act); - if (seq_other->sound) BKE_sound_add_scene_sound_defaults(scene, seq_other); + if (seq_act->sound) { + BKE_sound_add_scene_sound_defaults(scene, seq_act); + } + if (seq_other->sound) { + BKE_sound_add_scene_sound_defaults(scene, seq_other); + } BKE_sequence_invalidate_cache(scene, seq_act); BKE_sequence_invalidate_cache(scene, seq_other); @@ -3541,30 +3657,40 @@ static int sequencer_enable_proxies_exec(bContext *C, wmOperator *op) continue; } - if (proxy_25) + if (proxy_25) { seq->strip->proxy->build_size_flags |= SEQ_PROXY_IMAGE_SIZE_25; - else + } + else { seq->strip->proxy->build_size_flags &= ~SEQ_PROXY_IMAGE_SIZE_25; + } - if (proxy_50) + if (proxy_50) { seq->strip->proxy->build_size_flags |= SEQ_PROXY_IMAGE_SIZE_50; - else + } + else { seq->strip->proxy->build_size_flags &= ~SEQ_PROXY_IMAGE_SIZE_50; + } - if (proxy_75) + if (proxy_75) { seq->strip->proxy->build_size_flags |= SEQ_PROXY_IMAGE_SIZE_75; - else + } + else { seq->strip->proxy->build_size_flags &= ~SEQ_PROXY_IMAGE_SIZE_75; + } - if (proxy_100) + if (proxy_100) { seq->strip->proxy->build_size_flags |= SEQ_PROXY_IMAGE_SIZE_100; - else + } + else { seq->strip->proxy->build_size_flags &= ~SEQ_PROXY_IMAGE_SIZE_100; + } - if (!overwrite) + if (!overwrite) { seq->strip->proxy->build_flags |= SEQ_PROXY_SKIP_EXISTING; - else + } + else { seq->strip->proxy->build_flags &= ~SEQ_PROXY_SKIP_EXISTING; + } } } } SEQ_END; @@ -3742,8 +3868,9 @@ static int sequencer_change_path_exec(bContext *C, wmOperator *op) else { len = RNA_property_collection_length(op->ptr, RNA_struct_find_property(op->ptr, "files")); } - if (len == 0) + if (len == 0) { return OPERATOR_CANCELLED; + } RNA_string_get(op->ptr, "directory", directory); if (is_relative_path) { @@ -3865,10 +3992,12 @@ static int sequencer_export_subtitles_invoke(bContext *C, wmOperator *op, const if (!RNA_struct_property_is_set(op->ptr, "filepath")) { char filepath[FILE_MAX]; - if (BKE_main_blendfile_path(bmain)[0] == '\0') + if (BKE_main_blendfile_path(bmain)[0] == '\0') { BLI_strncpy(filepath, "untitled", sizeof(filepath)); - else + } + else { BLI_strncpy(filepath, BKE_main_blendfile_path(bmain), sizeof(filepath)); + } BLI_path_extension_replace(filepath, sizeof(filepath), ".srt"); RNA_string_set(op->ptr, "filepath", filepath); diff --git a/source/blender/editors/space_sequencer/sequencer_modifier.c b/source/blender/editors/space_sequencer/sequencer_modifier.c index c3df5a0c5ee..41ca52e0431 100644 --- a/source/blender/editors/space_sequencer/sequencer_modifier.c +++ b/source/blender/editors/space_sequencer/sequencer_modifier.c @@ -51,8 +51,9 @@ static bool strip_modifier_active_poll(bContext *C) if (ed) { Sequence *seq = BKE_sequencer_active_get(scene); - if (seq) + if (seq) { return BKE_sequence_supports_modifiers(seq); + } } return false; @@ -105,8 +106,9 @@ static int strip_modifier_remove_exec(bContext *C, wmOperator *op) RNA_string_get(op->ptr, "name", name); smd = BKE_sequence_modifier_find_by_name(seq, name); - if (!smd) + if (!smd) { return OPERATOR_CANCELLED; + } BLI_remlink(&seq->modifiers, smd); BKE_sequence_modifier_free(smd); @@ -154,8 +156,9 @@ static int strip_modifier_move_exec(bContext *C, wmOperator *op) direction = RNA_enum_get(op->ptr, "direction"); smd = BKE_sequence_modifier_find_by_name(seq, name); - if (!smd) + if (!smd) { return OPERATOR_CANCELLED; + } if (direction == SEQ_MODIFIER_MOVE_UP) { if (smd->prev) { @@ -216,14 +219,16 @@ static int strip_modifier_copy_exec(bContext *C, wmOperator *op) Sequence *seq_iter; const int type = RNA_enum_get(op->ptr, "type"); - if (!seq || !seq->modifiers.first) + if (!seq || !seq->modifiers.first) { return OPERATOR_CANCELLED; + } SEQP_BEGIN(ed, seq_iter) { if (seq_iter->flag & SELECT) { - if (seq_iter == seq) + if (seq_iter == seq) { continue; + } if (type == SEQ_MODIFIER_COPY_REPLACE) { if (seq_iter->modifiers.first) { diff --git a/source/blender/editors/space_sequencer/sequencer_scopes.c b/source/blender/editors/space_sequencer/sequencer_scopes.c index f93eaa5bce5..5ccd9e86e12 100644 --- a/source/blender/editors/space_sequencer/sequencer_scopes.c +++ b/source/blender/editors/space_sequencer/sequencer_scopes.c @@ -513,12 +513,15 @@ static ImBuf *make_histogram_view_from_ibuf_byte(ImBuf *ibuf) nr = nb = ng = 0; for (x = 0; x < HIS_STEPS; x++) { - if (bins[0][x] > nr) + if (bins[0][x] > nr) { nr = bins[0][x]; - if (bins[1][x] > ng) + } + if (bins[1][x] > ng) { ng = bins[1][x]; - if (bins[2][x] > nb) + } + if (bins[2][x] > nb) { nb = bins[2][x]; + } } for (x = 0; x < HIS_STEPS; x++) { @@ -598,12 +601,15 @@ static ImBuf *make_histogram_view_from_ibuf_float(ImBuf *ibuf) nr = nb = ng = 0; for (x = 0; x < HIS_STEPS; x++) { - if (bins[0][x] > nr) + if (bins[0][x] > nr) { nr = bins[0][x]; - if (bins[1][x] > ng) + } + if (bins[1][x] > ng) { ng = bins[1][x]; - if (bins[2][x] > nb) + } + if (bins[2][x] > nb) { nb = bins[2][x]; + } } for (x = 0; x < HIS_STEPS; x++) { diff --git a/source/blender/editors/space_sequencer/sequencer_select.c b/source/blender/editors/space_sequencer/sequencer_select.c index b87e0b185a4..7742d74d559 100644 --- a/source/blender/editors/space_sequencer/sequencer_select.c +++ b/source/blender/editors/space_sequencer/sequencer_select.c @@ -131,11 +131,13 @@ static void select_linked_time(ListBase *seqbase, Sequence *seq_link) /* clear for reselection */ seq->flag &= ~(SEQ_LEFTSEL | SEQ_RIGHTSEL); - if (left_match && seq_link->flag & SEQ_LEFTSEL) + if (left_match && seq_link->flag & SEQ_LEFTSEL) { seq->flag |= SELECT | SEQ_LEFTSEL; + } - if (right_match && seq_link->flag & SEQ_RIGHTSEL) + if (right_match && seq_link->flag & SEQ_RIGHTSEL) { seq->flag |= SELECT | SEQ_RIGHTSEL; + } recurs_sel_seq(seq); } @@ -159,18 +161,21 @@ void ED_sequencer_select_sequence_single(Scene *scene, Sequence *seq, bool desel { Editing *ed = BKE_sequencer_editing_get(scene, false); - if (deselect_all) + if (deselect_all) { ED_sequencer_deselect_all(scene); + } BKE_sequencer_active_set(scene, seq); if ((seq->type == SEQ_TYPE_IMAGE) || (seq->type == SEQ_TYPE_MOVIE)) { - if (seq->strip) + if (seq->strip) { BLI_strncpy(ed->act_imagedir, seq->strip->dir, FILE_MAXDIR); + } } else if (seq->type == SEQ_TYPE_SOUND_RAM) { - if (seq->strip) + if (seq->strip) { BLI_strncpy(ed->act_sounddir, seq->strip->dir, FILE_MAXDIR); + } } seq->flag |= SELECT; recurs_sel_seq(seq); @@ -322,16 +327,18 @@ static int sequencer_select_invoke(bContext *C, wmOperator *op, const wmEvent *e int hand, sel_side; TimeMarker *marker; - if (ed == NULL) + if (ed == NULL) { return OPERATOR_CANCELLED; + } marker = find_nearest_marker(SCE_MARKERS, 1); //XXX - dummy function for now seq = find_nearest_seq(scene, v2d, &hand, event->mval); // XXX - not nice, Ctrl+RMB needs to do left_right only when not over a strip - if (seq && linked_time && (left_right == SEQ_SELECT_LR_MOUSE)) + if (seq && linked_time && (left_right == SEQ_SELECT_LR_MOUSE)) { left_right = SEQ_SELECT_LR_NONE; + } if (marker) { @@ -339,10 +346,12 @@ static int sequencer_select_invoke(bContext *C, wmOperator *op, const wmEvent *e /* select timeline marker */ if (extend) { oldflag = marker->flag; - if (oldflag & SELECT) + if (oldflag & SELECT) { marker->flag &= ~SELECT; - else + } + else { marker->flag |= SELECT; + } } else { /* XXX, in 2.4x, seq selection used to deselect all, need to re-thnik this for 2.5 */ @@ -402,8 +411,9 @@ static int sequencer_select_invoke(bContext *C, wmOperator *op, const wmEvent *e act_orig = ed->act_seq; - if (extend == 0 && linked_handle == 0) + if (extend == 0 && linked_handle == 0) { ED_sequencer_deselect_all(scene); + } if (seq) { BKE_sequencer_active_set(scene, seq); @@ -448,13 +458,17 @@ static int sequencer_select_invoke(bContext *C, wmOperator *op, const wmEvent *e switch (sel_side) { case SEQ_SIDE_LEFT: if ((seq->flag & SEQ_LEFTSEL) && (neighbor->flag & SEQ_RIGHTSEL)) { - if (extend == 0) ED_sequencer_deselect_all(scene); + if (extend == 0) { + ED_sequencer_deselect_all(scene); + } seq->flag |= SELECT; select_active_side(ed->seqbasep, SEQ_SIDE_LEFT, seq->machine, seq->startdisp); } else { - if (extend == 0) ED_sequencer_deselect_all(scene); + if (extend == 0) { + ED_sequencer_deselect_all(scene); + } seq->flag |= SELECT; neighbor->flag |= SELECT; @@ -465,13 +479,17 @@ static int sequencer_select_invoke(bContext *C, wmOperator *op, const wmEvent *e break; case SEQ_SIDE_RIGHT: if ((seq->flag & SEQ_RIGHTSEL) && (neighbor->flag & SEQ_LEFTSEL)) { - if (extend == 0) ED_sequencer_deselect_all(scene); + if (extend == 0) { + ED_sequencer_deselect_all(scene); + } seq->flag |= SELECT; select_active_side(ed->seqbasep, SEQ_SIDE_RIGHT, seq->machine, seq->startdisp); } else { - if (extend == 0) ED_sequencer_deselect_all(scene); + if (extend == 0) { + ED_sequencer_deselect_all(scene); + } seq->flag |= SELECT; neighbor->flag |= SELECT; @@ -483,7 +501,9 @@ static int sequencer_select_invoke(bContext *C, wmOperator *op, const wmEvent *e } } else { - if (extend == 0) ED_sequencer_deselect_all(scene); + if (extend == 0) { + ED_sequencer_deselect_all(scene); + } select_active_side(ed->seqbasep, sel_side, seq->machine, seq->startdisp); } } @@ -492,8 +512,9 @@ static int sequencer_select_invoke(bContext *C, wmOperator *op, const wmEvent *e if (extend && (seq->flag & SELECT) && ed->act_seq == act_orig) { switch (hand) { case SEQ_SIDE_NONE: - if (linked_handle == 0) + if (linked_handle == 0) { seq->flag &= ~SEQ_ALLSEL; + } break; case SEQ_SIDE_LEFT: seq->flag ^= SEQ_LEFTSEL; @@ -505,8 +526,12 @@ static int sequencer_select_invoke(bContext *C, wmOperator *op, const wmEvent *e } else { seq->flag |= SELECT; - if (hand == SEQ_SIDE_LEFT) seq->flag |= SEQ_LEFTSEL; - if (hand == SEQ_SIDE_RIGHT) seq->flag |= SEQ_RIGHTSEL; + if (hand == SEQ_SIDE_LEFT) { + seq->flag |= SEQ_LEFTSEL; + } + if (hand == SEQ_SIDE_RIGHT) { + seq->flag |= SEQ_RIGHTSEL; + } } } @@ -581,8 +606,9 @@ static bool select_more_less_seq__internal(Scene *scene, bool sel, const bool li bool changed = false; int isel; - if (ed == NULL) + if (ed == NULL) { return changed; + } if (sel) { sel = SELECT; @@ -646,8 +672,9 @@ static int sequencer_select_more_exec(bContext *C, wmOperator *UNUSED(op)) { Scene *scene = CTX_data_scene(C); - if (!select_more_less_seq__internal(scene, true, false)) + if (!select_more_less_seq__internal(scene, true, false)) { return OPERATOR_CANCELLED; + } WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER | NA_SELECTED, scene); @@ -677,8 +704,9 @@ static int sequencer_select_less_exec(bContext *C, wmOperator *UNUSED(op)) { Scene *scene = CTX_data_scene(C); - if (!select_more_less_seq__internal(scene, false, false)) + if (!select_more_less_seq__internal(scene, false, false)) { return OPERATOR_CANCELLED; + } WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER | NA_SELECTED, scene); @@ -716,11 +744,13 @@ static int sequencer_select_linked_pick_invoke(bContext *C, wmOperator *op, cons /* this works like UV, not mesh */ mouse_seq = find_nearest_seq(scene, v2d, &hand, event->mval); - if (!mouse_seq) + if (!mouse_seq) { return OPERATOR_FINISHED; /* user error as with mesh?? */ + } - if (extend == 0) + if (extend == 0) { ED_sequencer_deselect_all(scene); + } mouse_seq->flag |= SELECT; recurs_sel_seq(mouse_seq); @@ -845,8 +875,9 @@ static int sequencer_select_active_side_exec(bContext *C, wmOperator *op) Editing *ed = BKE_sequencer_editing_get(scene, false); Sequence *seq_act = BKE_sequencer_active_get(scene); - if (ed == NULL || seq_act == NULL) + if (ed == NULL || seq_act == NULL) { return OPERATOR_CANCELLED; + } seq_act->flag |= SELECT; @@ -1028,8 +1059,9 @@ static bool select_grouped_data(Editing *ed, Sequence *actseq, const int channel bool changed = false; const char *dir = actseq->strip ? actseq->strip->dir : NULL; - if (!SEQ_USE_DATA(actseq)) + if (!SEQ_USE_DATA(actseq)) { return changed; + } if (SEQ_HAS_PATH(actseq) && dir) { SEQP_BEGIN (ed, seq) @@ -1085,8 +1117,9 @@ static bool select_grouped_effect(Editing *ed, Sequence *actseq, const int chann bool effects[SEQ_TYPE_MAX + 1]; int i; - for (i = 0; i <= SEQ_TYPE_MAX; i++) + for (i = 0; i <= SEQ_TYPE_MAX; i++) { effects[i] = false; + } SEQP_BEGIN (ed, seq) { @@ -1101,9 +1134,9 @@ static bool select_grouped_effect(Editing *ed, Sequence *actseq, const int chann SEQP_BEGIN (ed, seq) { if (SEQ_CHANNEL_CHECK(seq, channel) && effects[seq->type]) { - if (seq->seq1) seq->seq1->flag |= SELECT; - if (seq->seq2) seq->seq2->flag |= SELECT; - if (seq->seq3) seq->seq3->flag |= SELECT; + if (seq->seq1) { seq->seq1->flag |= SELECT; } + if (seq->seq2) { seq->seq2->flag |= SELECT; } + if (seq->seq3) { seq->seq3->flag |= SELECT; } changed = true; } } @@ -1166,9 +1199,15 @@ static bool select_grouped_effect_link(Editing *ed, Sequence *actseq, const int (seq->seq2 && seq->seq2->tmp) || (seq->seq3 && seq->seq3->tmp))) { - if (startdisp > seq->startdisp) startdisp = seq->startdisp; - if (enddisp < seq->enddisp) enddisp = seq->enddisp; - if (machine < seq->machine) machine = seq->machine; + if (startdisp > seq->startdisp) { + startdisp = seq->startdisp; + } + if (enddisp < seq->enddisp) { + enddisp = seq->enddisp; + } + if (machine < seq->machine) { + machine = seq->machine; + } seq->tmp = POINTER_FROM_INT(true); diff --git a/source/blender/editors/space_sequencer/sequencer_view.c b/source/blender/editors/space_sequencer/sequencer_view.c index d0e31dbbe79..30f526c0675 100644 --- a/source/blender/editors/space_sequencer/sequencer_view.c +++ b/source/blender/editors/space_sequencer/sequencer_view.c @@ -177,8 +177,9 @@ static int sample_invoke(bContext *C, wmOperator *op, const wmEvent *event) SpaceSeq *sseq = CTX_wm_space_seq(C); ImageSampleInfo *info; - if (sseq->mainb != SEQ_DRAW_IMG_IMBUF) + if (sseq->mainb != SEQ_DRAW_IMG_IMBUF) { return OPERATOR_CANCELLED; + } info = MEM_callocN(sizeof(ImageSampleInfo), "ImageSampleInfo"); info->art = ar->type; diff --git a/source/blender/editors/space_sequencer/space_sequencer.c b/source/blender/editors/space_sequencer/space_sequencer.c index dec70c4bf43..561d603ab08 100644 --- a/source/blender/editors/space_sequencer/space_sequencer.c +++ b/source/blender/editors/space_sequencer/space_sequencer.c @@ -74,13 +74,17 @@ ARegion *sequencer_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 sequencer"); @@ -97,9 +101,11 @@ static ARegion *sequencer_find_region(ScrArea *sa, short type) { ARegion *ar = NULL; - for (ar = sa->regionbase.first; ar; ar = ar->next) - if (ar->regiontype == type) + for (ar = sa->regionbase.first; ar; ar = ar->next) { + if (ar->regiontype == type) { return ar; + } + } return ar; } @@ -199,20 +205,25 @@ static void sequencer_free(SpaceLink *sl) // XXX if (sseq->gpd) BKE_gpencil_free(sseq->gpd); - if (scopes->zebra_ibuf) + if (scopes->zebra_ibuf) { IMB_freeImBuf(scopes->zebra_ibuf); + } - if (scopes->waveform_ibuf) + if (scopes->waveform_ibuf) { IMB_freeImBuf(scopes->waveform_ibuf); + } - if (scopes->sep_waveform_ibuf) + if (scopes->sep_waveform_ibuf) { IMB_freeImBuf(scopes->sep_waveform_ibuf); + } - if (scopes->vector_ibuf) + if (scopes->vector_ibuf) { IMB_freeImBuf(scopes->vector_ibuf); + } - if (scopes->histogram_ibuf) + if (scopes->histogram_ibuf) { IMB_freeImBuf(scopes->histogram_ibuf); + } } @@ -347,12 +358,14 @@ static void sequencer_listener( break; case NC_WINDOW: case NC_SPACE: - if (wmn->data == ND_SPACE_SEQUENCER) + if (wmn->data == ND_SPACE_SEQUENCER) { sequencer_scopes_tag_refresh(sa); + } break; case NC_GPENCIL: - if (wmn->data & ND_GPENCIL_EDITMODE) + if (wmn->data & ND_GPENCIL_EDITMODE) { ED_area_tag_redraw(sa); + } break; } } @@ -365,10 +378,13 @@ static bool image_drop_poll(bContext *C, wmDrag *drag, const wmEvent *event, con Scene *scene = CTX_data_scene(C); int hand; - if (drag->type == WM_DRAG_PATH) - if (ELEM(drag->icon, ICON_FILE_IMAGE, ICON_FILE_BLANK)) /* rule might not work? */ - if (find_nearest_seq(scene, &ar->v2d, &hand, event->mval) == NULL) + if (drag->type == WM_DRAG_PATH) { + if (ELEM(drag->icon, ICON_FILE_IMAGE, ICON_FILE_BLANK)) { /* rule might not work? */ + if (find_nearest_seq(scene, &ar->v2d, &hand, event->mval) == NULL) { return 1; + } + } + } return 0; } @@ -379,10 +395,13 @@ static bool movie_drop_poll(bContext *C, wmDrag *drag, const wmEvent *event, con Scene *scene = CTX_data_scene(C); int hand; - if (drag->type == WM_DRAG_PATH) - if (ELEM(drag->icon, 0, ICON_FILE_MOVIE, ICON_FILE_BLANK)) /* rule might not work? */ - if (find_nearest_seq(scene, &ar->v2d, &hand, event->mval) == NULL) + if (drag->type == WM_DRAG_PATH) { + if (ELEM(drag->icon, 0, ICON_FILE_MOVIE, ICON_FILE_BLANK)) { /* rule might not work? */ + if (find_nearest_seq(scene, &ar->v2d, &hand, event->mval) == NULL) { return 1; + } + } + } return 0; } @@ -392,18 +411,22 @@ static bool sound_drop_poll(bContext *C, wmDrag *drag, const wmEvent *event, con Scene *scene = CTX_data_scene(C); int hand; - if (drag->type == WM_DRAG_PATH) - if (ELEM(drag->icon, ICON_FILE_SOUND, ICON_FILE_BLANK)) /* rule might not work? */ - if (find_nearest_seq(scene, &ar->v2d, &hand, event->mval) == NULL) + if (drag->type == WM_DRAG_PATH) { + if (ELEM(drag->icon, ICON_FILE_SOUND, ICON_FILE_BLANK)) { /* rule might not work? */ + if (find_nearest_seq(scene, &ar->v2d, &hand, event->mval) == NULL) { return 1; + } + } + } return 0; } static void sequencer_drop_copy(wmDrag *drag, wmDropBox *drop) { /* copy drag path to properties */ - if (RNA_struct_find_property(drop->ptr, "filepath")) + if (RNA_struct_find_property(drop->ptr, "filepath")) { RNA_string_set(drop->ptr, "filepath", drag->path); + } if (RNA_struct_find_property(drop->ptr, "directory")) { PointerRNA itemptr; @@ -514,16 +537,19 @@ static void sequencer_main_region_listener( } break; case NC_SPACE: - if (wmn->data == ND_SPACE_SEQUENCER) + if (wmn->data == ND_SPACE_SEQUENCER) { 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_SCREEN: - if (ELEM(wmn->data, ND_ANIMPLAY)) + if (ELEM(wmn->data, ND_ANIMPLAY)) { ED_region_tag_redraw(ar); + } break; } } @@ -627,21 +653,27 @@ static void sequencer_preview_region_draw(const bContext *C, ARegion *ar) (sseq->mainb == SEQ_DRAW_IMG_IMBUF)); /* XXX temp fix for wrong setting in sseq->mainb */ - if (sseq->mainb == SEQ_DRAW_SEQUENCE) sseq->mainb = SEQ_DRAW_IMG_IMBUF; + if (sseq->mainb == SEQ_DRAW_SEQUENCE) { + sseq->mainb = SEQ_DRAW_IMG_IMBUF; + } - if (!show_split || sseq->overlay_type != SEQ_DRAW_OVERLAY_REFERENCE) + if (!show_split || sseq->overlay_type != SEQ_DRAW_OVERLAY_REFERENCE) { sequencer_draw_preview(C, scene, ar, sseq, scene->r.cfra, 0, false, false); + } if (show_split && sseq->overlay_type != SEQ_DRAW_OVERLAY_CURRENT) { int over_cfra; - if (scene->ed->over_flag & SEQ_EDIT_OVERLAY_ABS) + if (scene->ed->over_flag & SEQ_EDIT_OVERLAY_ABS) { over_cfra = scene->ed->over_cfra; - else + } + else { over_cfra = scene->r.cfra + scene->ed->over_ofs; + } - if (over_cfra != scene->r.cfra || sseq->overlay_type != SEQ_DRAW_OVERLAY_RECT) + if (over_cfra != scene->r.cfra || sseq->overlay_type != SEQ_DRAW_OVERLAY_RECT) { sequencer_draw_preview(C, scene, ar, sseq, scene->r.cfra, over_cfra - scene->r.cfra, true, false); + } } if ((U.uiflag & USER_SHOW_FPS) && ED_screen_animation_no_scrub(wm)) { @@ -685,8 +717,9 @@ static void sequencer_preview_region_listener( } break; case NC_SPACE: - if (wmn->data == ND_SPACE_SEQUENCER) + if (wmn->data == ND_SPACE_SEQUENCER) { ED_region_tag_redraw(ar); + } break; case NC_ID: switch (wmn->data) { @@ -741,12 +774,14 @@ static void sequencer_buttons_region_listener( } break; case NC_SPACE: - if (wmn->data == ND_SPACE_SEQUENCER) + if (wmn->data == ND_SPACE_SEQUENCER) { 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; } } diff --git a/source/blender/editors/space_statusbar/space_statusbar.c b/source/blender/editors/space_statusbar/space_statusbar.c index e85d438e80d..3c5ccb7e59b 100644 --- a/source/blender/editors/space_statusbar/space_statusbar.c +++ b/source/blender/editors/space_statusbar/space_statusbar.c @@ -116,20 +116,24 @@ static void statusbar_header_region_listener( } break; case NC_WM: - if (wmn->data == ND_JOB) + if (wmn->data == ND_JOB) { ED_region_tag_redraw(ar); + } break; case NC_SCENE: - if (wmn->data == ND_RENDER_RESULT) + if (wmn->data == ND_RENDER_RESULT) { ED_region_tag_redraw(ar); + } break; case NC_SPACE: - if (wmn->data == ND_SPACE_INFO) + if (wmn->data == ND_SPACE_INFO) { 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; } } diff --git a/source/blender/editors/space_topbar/space_topbar.c b/source/blender/editors/space_topbar/space_topbar.c index 61a6517a83e..a65ced8987f 100644 --- a/source/blender/editors/space_topbar/space_topbar.c +++ b/source/blender/editors/space_topbar/space_topbar.c @@ -147,20 +147,24 @@ static void topbar_main_region_listener(wmWindow *UNUSED(win), ScrArea *UNUSED(s /* context changes */ switch (wmn->category) { case NC_WM: - if (wmn->data == ND_HISTORY) + if (wmn->data == ND_HISTORY) { ED_region_tag_redraw(ar); + } break; case NC_SCENE: - if (wmn->data == ND_MODE) + if (wmn->data == ND_MODE) { 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_GPENCIL: - if (wmn->data == ND_DATA) + if (wmn->data == ND_DATA) { ED_region_tag_redraw(ar); + } break; } } @@ -171,20 +175,24 @@ static void topbar_header_listener(wmWindow *UNUSED(win), ScrArea *UNUSED(sa), A /* context changes */ switch (wmn->category) { case NC_WM: - if (wmn->data == ND_JOB) + if (wmn->data == ND_JOB) { ED_region_tag_redraw(ar); + } break; case NC_SPACE: - if (wmn->data == ND_SPACE_INFO) + if (wmn->data == ND_SPACE_INFO) { ED_region_tag_redraw(ar); + } break; case NC_SCREEN: - if (wmn->data == ND_LAYER) + if (wmn->data == ND_LAYER) { ED_region_tag_redraw(ar); + } break; case NC_SCENE: - if (wmn->data == ND_SCENEBROWSE) + if (wmn->data == ND_SCENEBROWSE) { ED_region_tag_redraw(ar); + } break; } } 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