From ab4a2aaf4a4b2b4e416aa1f113b30362cbe0dec3 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 24 Mar 2012 06:38:07 +0000 Subject: style cleanup: follow style guide for formatting of if/for/while loops, and else if's --- .../blender/editors/animation/anim_channels_edit.c | 2 +- source/blender/editors/animation/anim_deps.c | 2 +- source/blender/editors/animation/anim_filter.c | 2 +- source/blender/editors/animation/anim_markers.c | 18 +- source/blender/editors/animation/anim_ops.c | 2 +- source/blender/editors/animation/keyframes_draw.c | 2 +- source/blender/editors/animation/keyframing.c | 8 +- source/blender/editors/animation/keyingsets.c | 2 +- source/blender/editors/armature/armature_ops.c | 6 +- source/blender/editors/armature/editarmature.c | 222 +-- .../editors/armature/editarmature_retarget.c | 20 +- .../blender/editors/armature/editarmature_sketch.c | 6 +- source/blender/editors/armature/meshlaplacian.c | 450 +++--- source/blender/editors/armature/poseSlide.c | 2 +- source/blender/editors/armature/poseobject.c | 36 +- source/blender/editors/armature/reeb.c | 132 +- source/blender/editors/curve/editcurve.c | 1622 ++++++++++--------- source/blender/editors/curve/editfont.c | 478 +++--- .../blender/editors/gpencil/editaction_gpencil.c | 2 +- source/blender/editors/gpencil/gpencil_edit.c | 6 +- source/blender/editors/gpencil/gpencil_paint.c | 6 +- source/blender/editors/gpencil/gpencil_undo.c | 22 +- source/blender/editors/interface/interface.c | 792 ++++----- source/blender/editors/interface/interface_draw.c | 170 +- .../blender/editors/interface/interface_handlers.c | 1676 ++++++++++---------- source/blender/editors/interface/interface_icons.c | 104 +- .../blender/editors/interface/interface_layout.c | 536 +++---- source/blender/editors/interface/interface_ops.c | 46 +- source/blender/editors/interface/interface_panel.c | 410 ++--- .../blender/editors/interface/interface_regions.c | 549 +++---- source/blender/editors/interface/interface_style.c | 28 +- .../editors/interface/interface_templates.c | 452 +++--- source/blender/editors/interface/interface_utils.c | 40 +- .../blender/editors/interface/interface_widgets.c | 382 ++--- source/blender/editors/interface/resources.c | 156 +- source/blender/editors/interface/view2d.c | 90 +- source/blender/editors/interface/view2d_ops.c | 10 +- source/blender/editors/mesh/editface.c | 158 +- source/blender/editors/mesh/editmesh_add.c | 4 +- source/blender/editors/mesh/editmesh_bvh.c | 3 +- source/blender/editors/mesh/editmesh_tools.c | 9 +- source/blender/editors/mesh/mesh_data.c | 124 +- source/blender/editors/mesh/mesh_navmesh.c | 72 +- source/blender/editors/mesh/mesh_ops.c | 2 +- source/blender/editors/mesh/meshtools.c | 248 +-- source/blender/editors/metaball/mball_edit.c | 84 +- source/blender/editors/object/object_add.c | 287 ++-- source/blender/editors/object/object_bake.c | 286 ++-- source/blender/editors/object/object_constraint.c | 24 +- source/blender/editors/object/object_edit.c | 364 ++--- source/blender/editors/object/object_group.c | 24 +- source/blender/editors/object/object_hook.c | 121 +- source/blender/editors/object/object_lattice.c | 52 +- source/blender/editors/object/object_modifier.c | 213 +-- source/blender/editors/object/object_ops.c | 13 +- source/blender/editors/object/object_relations.c | 332 ++-- source/blender/editors/object/object_select.c | 121 +- source/blender/editors/object/object_shapekey.c | 82 +- source/blender/editors/object/object_transform.c | 137 +- source/blender/editors/object/object_vgroup.c | 443 +++--- source/blender/editors/physics/dynamicpaint_ops.c | 8 +- source/blender/editors/physics/particle_boids.c | 48 +- source/blender/editors/physics/particle_edit.c | 797 +++++----- source/blender/editors/physics/particle_object.c | 106 +- source/blender/editors/physics/physics_fluid.c | 93 +- .../blender/editors/physics/physics_pointcache.c | 30 +- source/blender/editors/render/render_internal.c | 100 +- source/blender/editors/render/render_opengl.c | 94 +- source/blender/editors/render/render_preview.c | 229 +-- source/blender/editors/render/render_shading.c | 116 +- source/blender/editors/render/render_update.c | 116 +- source/blender/editors/render/render_view.c | 76 +- source/blender/editors/screen/area.c | 330 ++-- source/blender/editors/screen/glutil.c | 77 +- source/blender/editors/screen/screen_context.c | 114 +- source/blender/editors/screen/screen_edit.c | 422 ++--- source/blender/editors/screen/screen_ops.c | 468 +++--- source/blender/editors/screen/screendump.c | 54 +- source/blender/editors/sculpt_paint/paint_cursor.c | 36 +- source/blender/editors/sculpt_paint/paint_hide.c | 42 +- source/blender/editors/sculpt_paint/paint_image.c | 347 ++-- source/blender/editors/sculpt_paint/paint_ops.c | 24 +- source/blender/editors/sculpt_paint/paint_stroke.c | 54 +- source/blender/editors/sculpt_paint/paint_undo.c | 74 +- source/blender/editors/sculpt_paint/paint_utils.c | 30 +- source/blender/editors/sculpt_paint/paint_vertex.c | 413 ++--- source/blender/editors/sculpt_paint/sculpt.c | 430 ++--- source/blender/editors/sculpt_paint/sculpt_undo.c | 129 +- source/blender/editors/sculpt_paint/sculpt_uv.c | 16 +- source/blender/editors/sound/sound_ops.c | 44 +- .../blender/editors/space_action/action_select.c | 2 +- source/blender/editors/space_action/space_action.c | 12 +- source/blender/editors/space_api/spacetypes.c | 24 +- .../editors/space_buttons/buttons_context.c | 323 ++-- .../blender/editors/space_buttons/buttons_header.c | 6 +- source/blender/editors/space_buttons/buttons_ops.c | 20 +- .../editors/space_buttons/buttons_texture.c | 98 +- .../blender/editors/space_buttons/space_buttons.c | 46 +- source/blender/editors/space_clip/clip_buttons.c | 53 +- source/blender/editors/space_clip/clip_draw.c | 430 ++--- source/blender/editors/space_clip/clip_editor.c | 57 +- .../blender/editors/space_clip/clip_graph_draw.c | 27 +- source/blender/editors/space_clip/clip_graph_ops.c | 44 +- source/blender/editors/space_clip/clip_ops.c | 89 +- source/blender/editors/space_clip/clip_toolbar.c | 32 +- source/blender/editors/space_clip/clip_utils.c | 46 +- source/blender/editors/space_clip/space_clip.c | 44 +- source/blender/editors/space_clip/tracking_ops.c | 625 ++++---- .../blender/editors/space_console/console_draw.c | 4 +- source/blender/editors/space_console/console_ops.c | 83 +- .../blender/editors/space_console/space_console.c | 14 +- source/blender/editors/space_file/file_draw.c | 28 +- source/blender/editors/space_file/file_ops.c | 122 +- source/blender/editors/space_file/file_panels.c | 16 +- source/blender/editors/space_file/filelist.c | 246 +-- source/blender/editors/space_file/filesel.c | 90 +- source/blender/editors/space_file/fsmenu.c | 27 +- source/blender/editors/space_file/space_file.c | 33 +- source/blender/editors/space_graph/graph_buttons.c | 10 +- source/blender/editors/space_graph/graph_draw.c | 2 +- source/blender/editors/space_graph/graph_edit.c | 2 +- source/blender/editors/space_graph/space_graph.c | 12 +- source/blender/editors/space_image/image_buttons.c | 148 +- source/blender/editors/space_image/image_draw.c | 126 +- source/blender/editors/space_image/image_ops.c | 318 ++-- source/blender/editors/space_image/space_image.c | 96 +- source/blender/editors/space_info/info_draw.c | 12 +- source/blender/editors/space_info/info_ops.c | 32 +- source/blender/editors/space_info/info_report.c | 64 +- source/blender/editors/space_info/info_stats.c | 114 +- source/blender/editors/space_info/space_info.c | 19 +- source/blender/editors/space_info/textview.c | 51 +- source/blender/editors/space_logic/logic_buttons.c | 22 +- source/blender/editors/space_logic/logic_ops.c | 10 +- source/blender/editors/space_logic/logic_window.c | 455 +++--- source/blender/editors/space_logic/space_logic.c | 8 +- source/blender/editors/space_nla/nla_buttons.c | 2 +- source/blender/editors/space_nla/nla_channels.c | 2 +- source/blender/editors/space_nla/space_nla.c | 14 +- source/blender/editors/space_node/drawnode.c | 149 +- source/blender/editors/space_node/node_buttons.c | 6 +- source/blender/editors/space_node/node_draw.c | 194 +-- source/blender/editors/space_node/node_edit.c | 567 +++---- source/blender/editors/space_node/node_header.c | 30 +- source/blender/editors/space_node/node_select.c | 32 +- source/blender/editors/space_node/node_state.c | 8 +- source/blender/editors/space_node/node_templates.c | 162 +- source/blender/editors/space_node/space_node.c | 100 +- .../blender/editors/space_outliner/outliner_draw.c | 269 ++-- .../blender/editors/space_outliner/outliner_edit.c | 140 +- .../editors/space_outliner/outliner_select.c | 229 +-- .../editors/space_outliner/outliner_tools.c | 187 +-- .../blender/editors/space_outliner/outliner_tree.c | 398 ++--- .../editors/space_outliner/space_outliner.c | 36 +- source/blender/editors/space_script/script_edit.c | 2 +- .../editors/space_sequencer/sequencer_add.c | 97 +- .../editors/space_sequencer/sequencer_buttons.c | 2 +- .../editors/space_sequencer/sequencer_draw.c | 175 +- .../editors/space_sequencer/sequencer_edit.c | 389 ++--- .../editors/space_sequencer/sequencer_scopes.c | 18 +- .../editors/space_sequencer/sequencer_select.c | 135 +- .../editors/space_sequencer/space_sequencer.c | 46 +- source/blender/editors/space_text/space_text.c | 20 +- source/blender/editors/space_text/text_draw.c | 505 +++--- source/blender/editors/space_text/text_header.c | 12 +- source/blender/editors/space_text/text_ops.c | 551 +++---- source/blender/editors/space_text/text_python.c | 224 +-- source/blender/editors/space_time/space_time.c | 18 +- source/blender/editors/space_view3d/drawarmature.c | 2 +- source/blender/editors/space_view3d/drawmesh.c | 2 +- source/blender/editors/space_view3d/drawobject.c | 8 +- source/blender/editors/space_view3d/view3d_draw.c | 2 +- source/blender/editors/space_view3d/view3d_edit.c | 2 +- source/blender/editors/space_view3d/view3d_snap.c | 2 +- source/blender/editors/transform/transform.c | 347 ++-- .../editors/transform/transform_constraints.c | 38 +- .../editors/transform/transform_conversions.c | 643 ++++---- .../blender/editors/transform/transform_generics.c | 146 +- source/blender/editors/transform/transform_input.c | 6 +- .../editors/transform/transform_manipulator.c | 386 ++--- source/blender/editors/transform/transform_ops.c | 6 +- .../editors/transform/transform_orientations.c | 51 +- source/blender/editors/transform/transform_snap.c | 65 +- source/blender/editors/util/crazyspace.c | 102 +- source/blender/editors/util/ed_util.c | 36 +- source/blender/editors/util/editmode_undo.c | 80 +- source/blender/editors/util/numinput.c | 9 +- source/blender/editors/util/undo.c | 104 +- source/blender/editors/uvedit/uvedit_buttons.c | 12 +- source/blender/editors/uvedit/uvedit_draw.c | 124 +- source/blender/editors/uvedit/uvedit_ops.c | 502 +++--- .../blender/editors/uvedit/uvedit_parametrizer.c | 36 +- .../blender/editors/uvedit/uvedit_smart_stitch.c | 341 ++-- source/blender/editors/uvedit/uvedit_unwrap_ops.c | 180 +-- 194 files changed, 14581 insertions(+), 14121 deletions(-) (limited to 'source/blender/editors') diff --git a/source/blender/editors/animation/anim_channels_edit.c b/source/blender/editors/animation/anim_channels_edit.c index 69f45975c76..aa15d53abe6 100644 --- a/source/blender/editors/animation/anim_channels_edit.c +++ b/source/blender/editors/animation/anim_channels_edit.c @@ -1909,7 +1909,7 @@ static int animchannels_borderselect_exec(bContext *C, wmOperator *op) gesture_mode= RNA_int_get(op->ptr, "gesture_mode"); extend= RNA_boolean_get(op->ptr, "extend"); - if(!extend) + if (!extend) ANIM_deselect_anim_channels(&ac, ac.data, ac.datatype, 1, ACHANNEL_SETFLAG_CLEAR); if (gesture_mode == GESTURE_MODAL_SELECT) diff --git a/source/blender/editors/animation/anim_deps.c b/source/blender/editors/animation/anim_deps.c index be66edb8dc9..3f0e1b1be14 100644 --- a/source/blender/editors/animation/anim_deps.c +++ b/source/blender/editors/animation/anim_deps.c @@ -88,7 +88,7 @@ void ANIM_list_elem_update(Scene *scene, bAnimListElem *ale) RNA_id_pointer_create(id, &id_ptr); - if(RNA_path_resolve(&id_ptr, fcu->rna_path, &ptr, &prop)) + if (RNA_path_resolve(&id_ptr, fcu->rna_path, &ptr, &prop)) RNA_property_update_main(G.main, scene, &ptr, prop); } else { diff --git a/source/blender/editors/animation/anim_filter.c b/source/blender/editors/animation/anim_filter.c index 05a2cc33fac..a17d15d144f 100644 --- a/source/blender/editors/animation/anim_filter.c +++ b/source/blender/editors/animation/anim_filter.c @@ -1188,7 +1188,7 @@ static size_t animfilter_block_data (bAnimContext *ac, ListBase *anim_data, bDop size_t items = 0; /* image object datablocks have no anim-data so check for NULL */ - if(adt) { + if (adt) { IdAdtTemplate *iat = (IdAdtTemplate*)id; /* NOTE: this macro is used instead of inlining the logic here, since this sort of filtering is still needed diff --git a/source/blender/editors/animation/anim_markers.c b/source/blender/editors/animation/anim_markers.c index 7937d1969ef..86e3c8050c2 100644 --- a/source/blender/editors/animation/anim_markers.c +++ b/source/blender/editors/animation/anim_markers.c @@ -410,7 +410,7 @@ static void draw_marker(View2D *v2d, TimeMarker *marker, int cfra, int flag) } else { UI_ThemeColor(TH_TEXT); - if((marker->frame <= cfra) && (marker->frame+5 > cfra)) { + if ((marker->frame <= cfra) && (marker->frame+5 > cfra)) { x= xpos*xscale + 4.0f; y= (ypixels <= 39.0f)? (ypixels - 10.0f) : 29.0f; } @@ -421,7 +421,7 @@ static void draw_marker(View2D *v2d, TimeMarker *marker, int cfra, int flag) } #ifdef DURIAN_CAMERA_SWITCH - if(marker->camera && (marker->camera->restrictflag & OB_RESTRICT_RENDER)) { + if (marker->camera && (marker->camera->restrictflag & OB_RESTRICT_RENDER)) { float col[4]; glGetFloatv(GL_CURRENT_COLOR, col); col[3]= 0.4; @@ -638,7 +638,7 @@ static int ed_marker_move_init(bContext *C, wmOperator *op) int totmark=0; int a; - if(markers == NULL) return 0; + if (markers == NULL) return 0; for (marker= markers->first; marker; marker= marker->next) if (marker->flag & SELECT) totmark++; @@ -681,7 +681,7 @@ static void ed_marker_move_exit(bContext *C, wmOperator *op) static int ed_marker_move_invoke(bContext *C, wmOperator *op, wmEvent *evt) { - if(ed_marker_move_init(C, op)) { + if (ed_marker_move_init(C, op)) { MarkerMove *mm= op->customdata; mm->evtx= evt->x; @@ -872,7 +872,7 @@ static int ed_marker_move_modal(bContext *C, wmOperator *op, wmEvent *evt) static int ed_marker_move_exec(bContext *C, wmOperator *op) { - if(ed_marker_move_init(C, op)) { + if (ed_marker_move_init(C, op)) { ed_marker_move_apply(op); ed_marker_move_exit(C, op); return OPERATOR_FINISHED; @@ -1051,7 +1051,7 @@ static int ed_marker_select(bContext *C, wmEvent *evt, int extend, int camera) scene_deselect_all(scene); for (marker= markers->first; marker; marker= marker->next) { - if(marker->frame==cfra) { + if (marker->frame==cfra) { sel= (marker->flag & SELECT); break; } @@ -1063,7 +1063,7 @@ static int ed_marker_select(bContext *C, wmEvent *evt, int extend, int camera) base= object_in_scene(marker->camera, scene); if (base) { ED_base_object_select(base, sel); - if(sel) + if (sel) ED_base_object_activate(C, base); } } @@ -1223,7 +1223,7 @@ static int ed_marker_select_all_exec(bContext *C, wmOperator *op) action = (ED_markers_get_first_selected(markers) != NULL) ? SEL_DESELECT : SEL_SELECT; } - for(marker= markers->first; marker; marker= marker->next) { + for (marker= markers->first; marker; marker= marker->next) { switch (action) { case SEL_SELECT: marker->flag |= SELECT; @@ -1431,7 +1431,7 @@ static int ed_marker_camera_bind_exec(bContext *C, wmOperator *UNUSED(op)) TimeMarker *marker; marker= ED_markers_get_first_selected(markers); - if(marker == NULL) + if (marker == NULL) return OPERATOR_CANCELLED; marker->camera= ob; diff --git a/source/blender/editors/animation/anim_ops.c b/source/blender/editors/animation/anim_ops.c index 6ca7ffd5bf3..8286e81b792 100644 --- a/source/blender/editors/animation/anim_ops.c +++ b/source/blender/editors/animation/anim_ops.c @@ -65,7 +65,7 @@ static int change_frame_poll(bContext *C) ScrArea *curarea= CTX_wm_area(C); /* XXX temp? prevent changes during render */ - if(G.rendering) return 0; + if (G.rendering) return 0; /* as long as there is an active area, and it isn't a Graph Editor * (since the Graph Editor has its own version which does extra stuff), diff --git a/source/blender/editors/animation/keyframes_draw.c b/source/blender/editors/animation/keyframes_draw.c index 8b93688f4cb..1c0bb9beaa1 100644 --- a/source/blender/editors/animation/keyframes_draw.c +++ b/source/blender/editors/animation/keyframes_draw.c @@ -269,7 +269,7 @@ static void nupdate_abk_bezt (void *node, void *data) if (abk->numBezts >= MAX_ABK_BUFSIZE) { // TODO: need to allocate new array to cater... //bezts_extra= MEM_callocN(...); - if(G.f & G_DEBUG) + if (G.f & G_DEBUG) printf("FIXME: nupdate_abk_bezt() missing case for too many overlapping BezTriples \n"); } else { diff --git a/source/blender/editors/animation/keyframing.c b/source/blender/editors/animation/keyframing.c index fdd790f58fc..71e70536d15 100644 --- a/source/blender/editors/animation/keyframing.c +++ b/source/blender/editors/animation/keyframing.c @@ -317,9 +317,9 @@ int insert_vert_fcurve (FCurve *fcu, float x, float y, short flag) /* use default interpolation mode, with exceptions for int/discrete values */ beztr.ipo= U.ipo_new; - if(fcu->flag & FCURVE_DISCRETE_VALUES) + if (fcu->flag & FCURVE_DISCRETE_VALUES) beztr.ipo = BEZT_IPO_CONST; - else if(beztr.ipo == BEZT_IPO_BEZ && (fcu->flag & FCURVE_INT_VALUES)) + else if (beztr.ipo == BEZT_IPO_BEZ && (fcu->flag & FCURVE_INT_VALUES)) beztr.ipo = BEZT_IPO_LIN; /* add temp beztriple to keyframes */ @@ -573,7 +573,7 @@ static short visualkey_can_use (PointerRNA *ptr, PropertyRNA *prop) return 0; /* location or rotation identifiers only... */ - if(identifier == NULL) { + if (identifier == NULL) { printf("%s failed: NULL identifier\n", __func__); return 0; } @@ -1429,7 +1429,7 @@ static int insert_key_button_exec (bContext *C, wmOperator *op) if (all) { length= RNA_property_array_length(&ptr, prop); - if(length) index= 0; + if (length) index= 0; else length= 1; } else diff --git a/source/blender/editors/animation/keyingsets.c b/source/blender/editors/animation/keyingsets.c index 32078060ca6..f66aa31f3f4 100644 --- a/source/blender/editors/animation/keyingsets.c +++ b/source/blender/editors/animation/keyingsets.c @@ -607,7 +607,7 @@ void ANIM_keyingset_info_unregister (Main *bmain, KeyingSetInfo *ksi) BKE_keyingset_free(ks); BLI_remlink(&builtin_keyingsets, ks); - for(scene= bmain->scene.first; scene; scene= scene->id.next) + for (scene= bmain->scene.first; scene; scene= scene->id.next) BLI_remlink_safe(&scene->keyingsets, ks); MEM_freeN(ks); diff --git a/source/blender/editors/armature/armature_ops.c b/source/blender/editors/armature/armature_ops.c index 4155f76e515..21b97188522 100644 --- a/source/blender/editors/armature/armature_ops.c +++ b/source/blender/editors/armature/armature_ops.c @@ -171,7 +171,7 @@ void ED_operatormacros_armature(void) wmOperatorTypeMacro *otmacro; ot = WM_operatortype_append_macro("ARMATURE_OT_duplicate_move", "Duplicate", OPTYPE_UNDO|OPTYPE_REGISTER); - if(ot) { + if (ot) { ot->description = "Make copies of the selected bones within the same armature and move them"; WM_operatortype_macro_define(ot, "ARMATURE_OT_duplicate"); otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate"); @@ -179,7 +179,7 @@ void ED_operatormacros_armature(void) } ot = WM_operatortype_append_macro("ARMATURE_OT_extrude_move", "Extrude", OPTYPE_UNDO|OPTYPE_REGISTER); - if(ot) { + if (ot) { ot->description = "Create new bones from the selected joints and move them"; otmacro=WM_operatortype_macro_define(ot, "ARMATURE_OT_extrude"); RNA_boolean_set(otmacro->ptr, "forked", FALSE); @@ -190,7 +190,7 @@ void ED_operatormacros_armature(void) // XXX would it be nicer to just be able to have standard extrude_move, but set the forked property separate? // that would require fixing a properties bug 19733 ot = WM_operatortype_append_macro("ARMATURE_OT_extrude_forked", "Extrude Forked", OPTYPE_UNDO|OPTYPE_REGISTER); - if(ot) { + if (ot) { ot->description = "Create new bones from the selected joints and move them"; otmacro=WM_operatortype_macro_define(ot, "ARMATURE_OT_extrude"); RNA_boolean_set(otmacro->ptr, "forked", TRUE); diff --git a/source/blender/editors/armature/editarmature.c b/source/blender/editors/armature/editarmature.c index 71c0e41ee33..4090fc1acaa 100644 --- a/source/blender/editors/armature/editarmature.c +++ b/source/blender/editors/armature/editarmature.c @@ -123,18 +123,18 @@ void ED_armature_validate_active(struct bArmature *arm) { EditBone *ebone= arm->act_edbone; - if(ebone) { - if(ebone->flag & BONE_HIDDEN_A) + if (ebone) { + if (ebone->flag & BONE_HIDDEN_A) arm->act_edbone= NULL; } } static void bone_free(bArmature *arm, EditBone *bone) { - if(arm->act_edbone==bone) + if (arm->act_edbone==bone) arm->act_edbone= NULL; - if(bone->prop) { + if (bone->prop) { IDP_FreeProperty(bone->prop); MEM_freeN(bone->prop); } @@ -275,9 +275,9 @@ EditBone *make_boneList(ListBase *edbo, ListBase *bones, EditBone *parent, Bone else { /* if the bone is not selected, but connected to its parent * copy the parents tip selection state */ - if(eBone->parent && (eBone->flag & BONE_CONNECTED)) { + if (eBone->parent && (eBone->flag & BONE_CONNECTED)) { /* selecting with the mouse gives this behavior */ - if(eBone->parent->flag & BONE_TIPSEL) { + if (eBone->parent->flag & BONE_TIPSEL) { eBone->flag |= BONE_ROOTSEL; } else { @@ -306,7 +306,7 @@ EditBone *make_boneList(ListBase *edbo, ListBase *bones, EditBone *parent, Bone eBone->segments = curBone->segments; eBone->layer = curBone->layer; - if(curBone->prop) + if (curBone->prop) eBone->prop= IDP_CopyProperty(curBone->prop); BLI_addtail(edbo, eBone); @@ -314,11 +314,11 @@ EditBone *make_boneList(ListBase *edbo, ListBase *bones, EditBone *parent, Bone /* Add children if necessary */ if (curBone->childbase.first) { eBoneTest= make_boneList(edbo, &curBone->childbase, eBone, actBone); - if(eBoneTest) + if (eBoneTest) eBoneAct= eBoneTest; } - if(curBone==actBone) + if (curBone==actBone) eBoneAct= eBone; } @@ -434,7 +434,7 @@ void ED_armature_from_edit(Object *obedit) newBone->segments= eBone->segments; newBone->layer = eBone->layer; - if(eBone->prop) + if (eBone->prop) newBone->prop= IDP_CopyProperty(eBone->prop); } @@ -542,7 +542,7 @@ void docenter_armature (Scene *scene, Object *ob, float cursor[3], int centermod float cent[3]; /* Put the armature into editmode */ - if(ob != obedit) { + if (ob != obedit) { ED_armature_to_edit(ob); obedit= NULL; /* we cant use this so behave as if there is no obedit */ } @@ -554,7 +554,7 @@ void docenter_armature (Scene *scene, Object *ob, float cursor[3], int centermod mul_m4_v3(ob->imat, cent); } else { - if(around==V3D_CENTROID) { + if (around==V3D_CENTROID) { int total= 0; zero_v3(cent); for (ebone= arm->edbo->first; ebone; ebone=ebone->next) { @@ -582,13 +582,13 @@ void docenter_armature (Scene *scene, Object *ob, float cursor[3], int centermod } /* Turn the list into an armature */ - if(obedit==NULL) { + if (obedit==NULL) { ED_armature_from_edit(ob); ED_armature_edit_free(ob); } /* Adjust object location for new centerpoint */ - if(centermode && obedit==NULL) { + if (centermode && obedit==NULL) { mul_mat3_m4_v3(ob->obmat, cent); /* ommit translation part */ add_v3_v3(ob->loc, cent); } @@ -1043,12 +1043,12 @@ static void separated_armature_fix_links(Object *origArm, Object *newArm) */ if (ct->subtarget[0] != 0) { if (ct->tar == origArm) { - if(BLI_findstring(npchans, ct->subtarget, offsetof(bPoseChannel, name))) { + if (BLI_findstring(npchans, ct->subtarget, offsetof(bPoseChannel, name))) { ct->tar= newArm; } } else if (ct->tar == newArm) { - if(BLI_findstring(opchans, ct->subtarget, offsetof(bPoseChannel, name))) { + if (BLI_findstring(opchans, ct->subtarget, offsetof(bPoseChannel, name))) { ct->tar= origArm; } } @@ -1079,14 +1079,14 @@ static void separated_armature_fix_links(Object *origArm, Object *newArm) * - the target isn't origArm/newArm itself * - the target is one that can be found in newArm/origArm */ - if(ct->subtarget[0] != '\0') { + if (ct->subtarget[0] != '\0') { if (ct->tar == origArm) { - if(BLI_findstring(npchans, ct->subtarget, offsetof(bPoseChannel, name))) { + if (BLI_findstring(npchans, ct->subtarget, offsetof(bPoseChannel, name))) { ct->tar= newArm; } } else if (ct->tar == newArm) { - if(BLI_findstring(opchans, ct->subtarget, offsetof(bPoseChannel, name))) { + if (BLI_findstring(opchans, ct->subtarget, offsetof(bPoseChannel, name))) { ct->tar= origArm; } } @@ -1104,7 +1104,7 @@ static void separated_armature_fix_links(Object *origArm, Object *newArm) if (ob->parent && (ob->parent == origArm)) { /* Is object parented to a bone of this src armature? */ if ((ob->partype == PARBONE) && (ob->parsubstr[0] != '\0')) { - if(BLI_findstring(npchans, ob->parsubstr, offsetof(bPoseChannel, name))) { + if (BLI_findstring(npchans, ob->parsubstr, offsetof(bPoseChannel, name))) { ob->parent= newArm; } } @@ -1263,7 +1263,7 @@ void ARMATURE_OT_separate (wmOperatorType *ot) Bone *get_indexed_bone (Object *ob, int index) { bPoseChannel *pchan; - if(ob->pose==NULL) return NULL; + if (ob->pose==NULL) return NULL; index>>=16; // bone selection codes use left 2 bytes pchan= BLI_findlink(&ob->pose->chanbase, index); @@ -1281,17 +1281,17 @@ static void *get_bone_from_selectbuffer(Scene *scene, Base *base, unsigned int * unsigned int hitresult; short i, takeNext=0, sel; - for (i=0; i< hits; i++){ + for (i=0; i< hits; i++) { hitresult = buffer[3+(i*4)]; if (!(hitresult & BONESEL_NOSEL)) { // -1 - if(hitresult & BONESEL_ANY) { // to avoid including objects in selection + if (hitresult & BONESEL_ANY) { // to avoid including objects in selection hitresult &= ~(BONESEL_ANY); /* Determine what the current bone is */ if (obedit==NULL || base->object!=obedit) { /* no singular posemode, so check for correct object */ - if(base->selcol == (hitresult & 0xFFFF)) { + if (base->selcol == (hitresult & 0xFFFF)) { bone = get_indexed_bone(base->object, hitresult); if (findunsel) @@ -1306,7 +1306,7 @@ static void *get_bone_from_selectbuffer(Scene *scene, Base *base, unsigned int * sel= 0; } } - else{ + else { bArmature *arm= obedit->data; ebone = BLI_findlink(arm->edbo, hitresult); @@ -1318,9 +1318,9 @@ static void *get_bone_from_selectbuffer(Scene *scene, Base *base, unsigned int * data = ebone; } - if(data) { + if (data) { if (sel) { - if(!firstSel) firstSel= data; + if (!firstSel) firstSel= data; takeNext=1; } else { @@ -1430,7 +1430,7 @@ static int pose_select_connected_invoke(bContext *C, wmOperator *op, wmEvent *ev return OPERATOR_CANCELLED; /* Select parents */ - for (curBone=bone; curBone; curBone=next){ + for (curBone=bone; curBone; curBone=next) { /* ignore bone if cannot be selected */ if ((curBone->flag & BONE_UNSELECTABLE) == 0) { // XXX old cruft! use notifiers instead @@ -1512,7 +1512,7 @@ static int armature_select_linked_invoke(bContext *C, wmOperator *op, wmEvent *e if (extend) { curBone->flag &= ~(BONE_SELECTED|BONE_TIPSEL|BONE_ROOTSEL); } - else{ + else { curBone->flag |= (BONE_SELECTED|BONE_TIPSEL|BONE_ROOTSEL); } } @@ -1596,7 +1596,7 @@ static EditBone *get_nearest_editbonepoint (ViewContext *vc, const int mval[2], rect.ymax = mval[1]+5; hits= view3d_opengl_select(vc, buffer, MAXPICKBUF, &rect); - if(hits==0) { + if (hits==0) { rect.xmin = mval[0]-12; rect.xmax = mval[0]+12; rect.ymin = mval[1]-12; @@ -1606,7 +1606,7 @@ static EditBone *get_nearest_editbonepoint (ViewContext *vc, const int mval[2], /* See if there are any selected bones in this group */ if (hits>0) { - if(hits==1) { + if (hits==1) { if (!(buffer[3] & BONESEL_NOSEL)) besthitresult= buffer[3]; } @@ -1619,12 +1619,12 @@ static EditBone *get_nearest_editbonepoint (ViewContext *vc, const int mval[2], ebone = BLI_findlink(edbo, hitresult & ~BONESEL_ANY); /* clicks on bone points get advantage */ - if( hitresult & (BONESEL_ROOT|BONESEL_TIP)) { + if ( hitresult & (BONESEL_ROOT|BONESEL_TIP)) { /* but also the unselected one */ - if(findunsel) { - if( (hitresult & BONESEL_ROOT) && (ebone->flag & BONE_ROOTSEL)==0) + if (findunsel) { + if ( (hitresult & BONESEL_ROOT) && (ebone->flag & BONE_ROOTSEL)==0) dep= 1; - else if( (hitresult & BONESEL_TIP) && (ebone->flag & BONE_TIPSEL)==0) + else if ( (hitresult & BONESEL_TIP) && (ebone->flag & BONE_TIPSEL)==0) dep= 1; else dep= 2; @@ -1633,15 +1633,15 @@ static EditBone *get_nearest_editbonepoint (ViewContext *vc, const int mval[2], } else { /* bone found */ - if(findunsel) { - if((ebone->flag & BONE_SELECTED)==0) + if (findunsel) { + if ((ebone->flag & BONE_SELECTED)==0) dep= 2; else dep= 3; } else dep= 3; } - if(dep < mindep) { + if (dep < mindep) { mindep= dep; besthitresult= hitresult; } @@ -1729,7 +1729,7 @@ static int armature_delete_selected_exec(bContext *C, wmOperator *UNUSED(op)) ebone_next= curBone->next; if (arm->layer & curBone->layer) { if (curBone->flag & BONE_SELECTED) { - if(curBone==arm->act_edbone) arm->act_edbone= NULL; + if (curBone==arm->act_edbone) arm->act_edbone= NULL; ED_armature_edit_bone_remove(arm, curBone); } } @@ -1769,12 +1769,12 @@ void ED_armature_deselect_all(Object *obedit, int toggle) EditBone *eBone; int sel=1; - if(toggle==1) { + if (toggle==1) { /* Determine if there are any selected bones * and therefore whether we are selecting or deselecting */ - for (eBone=arm->edbo->first;eBone;eBone=eBone->next){ - // if(arm->layer & eBone->layer) { - if (eBone->flag & (BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL)){ + for (eBone=arm->edbo->first;eBone;eBone=eBone->next) { + // if (arm->layer & eBone->layer) { + if (eBone->flag & (BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL)) { sel=0; break; } @@ -1787,24 +1787,24 @@ void ED_armature_deselect_all(Object *obedit, int toggle) for (eBone=arm->edbo->first;eBone;eBone=eBone->next) { if (sel==2) { /* invert selection of bone */ - if(EBONE_VISIBLE(arm, eBone)) { + if (EBONE_VISIBLE(arm, eBone)) { eBone->flag ^= (BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL); - if(arm->act_edbone==eBone) + if (arm->act_edbone==eBone) arm->act_edbone= NULL; } } else if (sel==1) { /* select bone */ - if(EBONE_VISIBLE(arm, eBone)) { + if (EBONE_VISIBLE(arm, eBone)) { eBone->flag |= (BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL); - if(eBone->parent) + if (eBone->parent) eBone->parent->flag |= (BONE_TIPSEL); } } else { /* deselect bone */ eBone->flag &= ~(BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL); - if(arm->act_edbone==eBone) + if (arm->act_edbone==eBone) arm->act_edbone= NULL; } } @@ -1830,7 +1830,7 @@ void ED_armature_deselect_all_visible(Object *obedit) /* accounts for connected parents */ static int ebone_select_flag(EditBone *ebone) { - if(ebone->parent && (ebone->flag & BONE_CONNECTED)) { + if (ebone->parent && (ebone->flag & BONE_CONNECTED)) { return ((ebone->parent->flag & BONE_TIPSEL) ? BONE_ROOTSEL : 0) | (ebone->flag & (BONE_SELECTED|BONE_TIPSEL)); } else { @@ -1860,16 +1860,16 @@ int mouse_armature(bContext *C, const int mval[2], int extend) /* by definition the non-root connected bones have no root point drawn, * so a root selection needs to be delivered to the parent tip */ - if(selmask & BONE_SELECTED) { - if(nearBone->parent && (nearBone->flag & BONE_CONNECTED)) { + if (selmask & BONE_SELECTED) { + if (nearBone->parent && (nearBone->flag & BONE_CONNECTED)) { /* click in a chain */ - if(extend) { + if (extend) { /* hold shift inverts this bone's selection */ - if(nearBone->flag & BONE_SELECTED) { + if (nearBone->flag & BONE_SELECTED) { /* deselect this bone */ nearBone->flag &= ~(BONE_TIPSEL|BONE_SELECTED); /* only deselect parent tip if it is not selected */ - if(!(nearBone->parent->flag & BONE_SELECTED)) + if (!(nearBone->parent->flag & BONE_SELECTED)) nearBone->parent->flag &= ~BONE_TIPSEL; } else { @@ -1885,9 +1885,9 @@ int mouse_armature(bContext *C, const int mval[2], int extend) } } else { - if(extend) { + if (extend) { /* hold shift inverts this bone's selection */ - if(nearBone->flag & BONE_SELECTED) + if (nearBone->flag & BONE_SELECTED) nearBone->flag &= ~(BONE_TIPSEL|BONE_ROOTSEL); else nearBone->flag |= (BONE_TIPSEL|BONE_ROOTSEL); @@ -1904,9 +1904,9 @@ int mouse_armature(bContext *C, const int mval[2], int extend) ED_armature_sync_selection(arm->edbo); - if(nearBone) { + if (nearBone) { /* then now check for active status */ - if(ebone_select_flag(nearBone)) { + if (ebone_select_flag(nearBone)) { arm->act_edbone= nearBone; } } @@ -1966,15 +1966,15 @@ float ED_rollBoneToVector(EditBone *bone, const float align_axis[3], const short vec_roll_to_mat3(nor, 0.0f, mat); /* check the bone isn't aligned with the axis */ - if(!is_zero_v3(align_axis) && angle_v3v3(align_axis, mat[2]) > FLT_EPSILON) { + if (!is_zero_v3(align_axis) && angle_v3v3(align_axis, mat[2]) > FLT_EPSILON) { float vec[3], align_axis_proj[3], roll; /* project the new_up_axis along the normal */ project_v3_v3v3(vec, align_axis, nor); sub_v3_v3v3(align_axis_proj, align_axis, vec); - if(axis_only) { - if(angle_v3v3(align_axis_proj, mat[2]) > (float)(M_PI/2.0)) { + if (axis_only) { + if (angle_v3v3(align_axis_proj, mat[2]) > (float)(M_PI/2.0)) { negate_v3(align_axis_proj); } } @@ -2020,7 +2020,7 @@ static int armature_calc_roll_exec(bContext *C, wmOperator *op) copy_m3_m4(imat, ob->obmat); invert_m3(imat); - if(type==7) { /* Cursor */ + if (type==7) { /* Cursor */ Scene *scene= CTX_data_scene(C); View3D *v3d= CTX_wm_view3d(C); /* can be NULL */ float cursor_local[3]; @@ -2031,20 +2031,20 @@ static int armature_calc_roll_exec(bContext *C, wmOperator *op) mul_m3_v3(imat, cursor_local); /* cursor */ - for(ebone= arm->edbo->first; ebone; ebone= ebone->next) { - if(EBONE_VISIBLE(arm, ebone) && EBONE_EDITABLE(ebone)) { + for (ebone= arm->edbo->first; ebone; ebone= ebone->next) { + if (EBONE_VISIBLE(arm, ebone) && EBONE_EDITABLE(ebone)) { float cursor_rel[3]; sub_v3_v3v3(cursor_rel, cursor_local, ebone->head); - if(axis_flip) negate_v3(cursor_rel); + if (axis_flip) negate_v3(cursor_rel); ebone->roll= ED_rollBoneToVector(ebone, cursor_rel, axis_only); } } } else { float vec[3]= {0.0f, 0.0f, 0.0f}; - if(type==6) { /* View */ + if (type==6) { /* View */ RegionView3D *rv3d= CTX_wm_region_view3d(C); - if(rv3d==NULL) { + if (rv3d==NULL) { BKE_report(op->reports, RPT_ERROR, "No region view3d available"); return OPERATOR_CANCELLED; } @@ -2055,7 +2055,7 @@ static int armature_calc_roll_exec(bContext *C, wmOperator *op) else if (type==5) { float mat[3][3], nor[3]; ebone= (EditBone *)arm->act_edbone; - if(ebone==NULL) { + if (ebone==NULL) { BKE_report(op->reports, RPT_ERROR, "No active bone set"); return OPERATOR_CANCELLED; } @@ -2066,15 +2066,15 @@ static int armature_calc_roll_exec(bContext *C, wmOperator *op) } else { /* Axis */ assert(type >= 0 && type <= 5); - if(type<3) vec[type]= 1.0f; + if (type<3) vec[type]= 1.0f; else vec[type-2]= -1.0f; mul_m3_v3(imat, vec); } - if(axis_flip) negate_v3(vec); + if (axis_flip) negate_v3(vec); - for(ebone= arm->edbo->first; ebone; ebone= ebone->next) { - if(EBONE_VISIBLE(arm, ebone) && EBONE_EDITABLE(ebone)) { + for (ebone= arm->edbo->first; ebone; ebone= ebone->next) { + if (EBONE_VISIBLE(arm, ebone) && EBONE_EDITABLE(ebone)) { /* roll func is a callback which assumes that all is well */ ebone->roll= ED_rollBoneToVector(ebone, vec, axis_only); } @@ -2082,8 +2082,8 @@ static int armature_calc_roll_exec(bContext *C, wmOperator *op) } if (arm->flag & ARM_MIRROR_EDIT) { - for(ebone= arm->edbo->first; ebone; ebone= ebone->next) { - if((EBONE_VISIBLE(arm, ebone) && EBONE_EDITABLE(ebone)) == 0) { + for (ebone= arm->edbo->first; ebone; ebone= ebone->next) { + if ((EBONE_VISIBLE(arm, ebone) && EBONE_EDITABLE(ebone)) == 0) { EditBone *ebone_mirr= ED_armature_bone_get_mirrored(arm->edbo, ebone); if (ebone_mirr && (EBONE_VISIBLE(arm, ebone_mirr) && EBONE_EDITABLE(ebone_mirr))) { ebone->roll= -ebone_mirr->roll; @@ -2135,14 +2135,14 @@ static void undoBones_to_editBones(void *uarmv, void *armv, void *UNUSED(data)) BLI_freelistN(arm->edbo); /* copy */ - for(ebo= uarm->lb.first; ebo; ebo= ebo->next) { + for (ebo= uarm->lb.first; ebo; ebo= ebo->next) { newebo= MEM_dupallocN(ebo); ebo->temp= newebo; BLI_addtail(arm->edbo, newebo); } /* active bone */ - if(uarm->act_edbone) { + if (uarm->act_edbone) { ebo= uarm->act_edbone; arm->act_edbone= ebo->temp; } @@ -2150,11 +2150,11 @@ static void undoBones_to_editBones(void *uarmv, void *armv, void *UNUSED(data)) arm->act_edbone= NULL; /* set pointers */ - for(newebo= arm->edbo->first; newebo; newebo= newebo->next) { - if(newebo->parent) newebo->parent= newebo->parent->temp; + for (newebo= arm->edbo->first; newebo; newebo= newebo->next) { + if (newebo->parent) newebo->parent= newebo->parent->temp; } /* be sure they don't hang ever */ - for(newebo= arm->edbo->first; newebo; newebo= newebo->next) { + for (newebo= arm->edbo->first; newebo; newebo= newebo->next) { newebo->temp= NULL; } } @@ -2168,21 +2168,21 @@ static void *editBones_to_undoBones(void *armv, void *UNUSED(obdata)) uarm= MEM_callocN(sizeof(UndoArmature), "listbase undo"); /* copy */ - for(ebo= arm->edbo->first; ebo; ebo= ebo->next) { + for (ebo= arm->edbo->first; ebo; ebo= ebo->next) { newebo= MEM_dupallocN(ebo); ebo->temp= newebo; BLI_addtail(&uarm->lb, newebo); } /* active bone */ - if(arm->act_edbone) { + if (arm->act_edbone) { ebo= arm->act_edbone; uarm->act_edbone= ebo->temp; } /* set pointers */ - for(newebo= uarm->lb.first; newebo; newebo= newebo->next) { - if(newebo->parent) newebo->parent= newebo->parent->temp; + for (newebo= uarm->lb.first; newebo; newebo= newebo->next) { + if (newebo->parent) newebo->parent= newebo->parent->temp; } return uarm; @@ -2199,7 +2199,7 @@ static void free_undoBones(void *uarmv) static void *get_armature_edit(bContext *C) { Object *obedit= CTX_data_edit_object(C); - if(obedit && obedit->type==OB_ARMATURE) { + if (obedit && obedit->type==OB_ARMATURE) { return obedit->data; } return NULL; @@ -2541,7 +2541,7 @@ EditBone *duplicateEditBoneObjects(EditBone *curBone, const char *name, ListBase BLI_addtail(editbones, eBone); /* copy the ID property */ - if(curBone->prop) + if (curBone->prop) eBone->prop= IDP_CopyProperty(curBone->prop); /* Lets duplicate the list of constraints that the @@ -2557,7 +2557,7 @@ EditBone *duplicateEditBoneObjects(EditBone *curBone, const char *name, ListBase */ channew= verify_pose_channel(dst_ob->pose, eBone->name); - if(channew) { + if (channew) { duplicate_pose_channel_data(channew, chanold); } } @@ -2653,9 +2653,9 @@ static int armature_duplicate_selected_exec(bContext *C, wmOperator *UNUSED(op)) } /* correct the active bone */ - if(arm->act_edbone) { + if (arm->act_edbone) { eBone= arm->act_edbone; - if(eBone->temp) + if (eBone->temp) arm->act_edbone= eBone->temp; } @@ -3205,7 +3205,7 @@ static int armature_reveal_exec(bContext *C, wmOperator *UNUSED(op)) EditBone *ebone; for (ebone = arm->edbo->first; ebone; ebone=ebone->next) { - if(arm->layer & ebone->layer) { + if (arm->layer & ebone->layer) { if (ebone->flag & BONE_HIDDEN_A) { ebone->flag |= (BONE_TIPSEL|BONE_SELECTED|BONE_ROOTSEL); ebone->flag &= ~BONE_HIDDEN_A; @@ -3281,7 +3281,7 @@ void show_all_armature_bones(Scene *scene) EditBone *ebone; for (ebone = arm->edbo->first; ebone; ebone=ebone->next) { - if(arm->layer & ebone->layer) { + if (arm->layer & ebone->layer) { if (ebone->flag & BONE_HIDDEN_A) { ebone->flag |= (BONE_TIPSEL|BONE_SELECTED|BONE_ROOTSEL); ebone->flag &= ~BONE_HIDDEN_A; @@ -3481,7 +3481,7 @@ static int armature_bone_primitive_add_exec(bContext *C, wmOperator *op) copy_v3_v3(bone->head, curs); - if(rv3d && (U.flag & USER_ADD_VIEWALIGNED)) + if (rv3d && (U.flag & USER_ADD_VIEWALIGNED)) add_v3_v3v3(bone->tail, bone->head, imat[1]); // bone with unit length 1 else add_v3_v3v3(bone->tail, bone->head, imat[2]); // bone with unit length 1, pointing up Z @@ -3988,7 +3988,7 @@ static int armature_de_select_all_exec(bContext *C, wmOperator *op) switch (action) { case SEL_SELECT: ebone->flag |= (BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL); - if(ebone->parent) + if (ebone->parent) ebone->parent->flag |= (BONE_TIPSEL); break; case SEL_DESELECT: @@ -4000,7 +4000,7 @@ static int armature_de_select_all_exec(bContext *C, wmOperator *op) } else { ebone->flag |= (BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL); - if(ebone->parent) + if (ebone->parent) ebone->parent->flag |= (BONE_TIPSEL); } break; @@ -4312,7 +4312,7 @@ int ED_do_pose_selectbuffer(Scene *scene, Base *base, unsigned int *buffer, shor else { if (nearBone->flag & BONE_SELECTED) { /* if not active, we make it active */ - if(nearBone != arm->act_bone) { + if (nearBone != arm->act_bone) { arm->act_bone= nearBone; } else { @@ -4416,7 +4416,7 @@ static int bone_skinnable_cb(Object *ob, Bone *bone, void *datap) int a, segments; struct { Object *armob; void *list; int heat; } *data = datap; - if(!(ob->mode & OB_MODE_WEIGHT_PAINT) || !(bone->flag & BONE_HIDDEN_P)) { + if (!(ob->mode & OB_MODE_WEIGHT_PAINT) || !(bone->flag & BONE_HIDDEN_P)) { if (!(bone->flag & BONE_NO_DEFORM)) { if (data->heat && data->armob->pose && get_pose_channel(data->armob->pose, bone->name)) segments = bone->segments; @@ -4490,7 +4490,7 @@ static int dgroup_skinnable_cb(Object *ob, Bone *bone, void *datap) else segments = 1; - if(!wpmode || ((arm->layer & bone->layer) && (bone->flag & BONE_SELECTED))) + if (!wpmode || ((arm->layer & bone->layer) && (bone->flag & BONE_SELECTED))) if (!(defgroup = defgroup_find_name(ob, bone->name))) defgroup = ED_vgroup_add_name(ob, bone->name); @@ -4710,7 +4710,7 @@ static void add_verts_to_dgroups(ReportList *reports, Scene *scene, Object *ob, heat_bone_weighting(ob, mesh, verts, numbones, dgrouplist, dgroupflip, root, tip, selected, &error); - if(error) { + if (error) { BKE_report(reports, RPT_WARNING, error); } } @@ -4739,7 +4739,7 @@ void create_vgroups_from_armature(ReportList *reports, Scene *scene, Object *ob, */ bArmature *arm= par->data; - if(mode == ARM_GROUPS_NAME) { + if (mode == ARM_GROUPS_NAME) { /* Traverse the bone list, trying to create empty vertex * groups corresponding to the bone. */ @@ -4748,7 +4748,7 @@ void create_vgroups_from_armature(ReportList *reports, Scene *scene, Object *ob, if (ob->type == OB_MESH) ED_vgroup_data_create(ob->data); } - else if(mode == ARM_GROUPS_ENVELOPE || mode == ARM_GROUPS_AUTO) { + else if (mode == ARM_GROUPS_ENVELOPE || mode == ARM_GROUPS_AUTO) { /* Traverse the bone list, trying to create vertex groups * that are populated with the vertices for which the * bone is closest. @@ -5148,7 +5148,7 @@ static int hide_selected_pose_bone_cb(Object *ob, Bone *bone, void *UNUSED(ptr)) if (bone->flag & BONE_SELECTED) { bone->flag |= BONE_HIDDEN_P; bone->flag &= ~BONE_SELECTED; - if(arm->act_bone==bone) + if (arm->act_bone==bone) arm->act_bone= NULL; } } @@ -5163,7 +5163,7 @@ static int hide_unselected_pose_bone_cb(Object *ob, Bone *bone, void *UNUSED(ptr // hrm... typo here? if ((bone->flag & BONE_SELECTED)==0) { bone->flag |= BONE_HIDDEN_P; - if(arm->act_bone==bone) + if (arm->act_bone==bone) arm->act_bone= NULL; } } @@ -5176,7 +5176,7 @@ static int pose_hide_exec(bContext *C, wmOperator *op) Object *ob= object_pose_armature_get(CTX_data_active_object(C)); bArmature *arm= ob->data; - if(RNA_boolean_get(op->ptr, "unselected")) + if (RNA_boolean_get(op->ptr, "unselected")) bone_looper(ob, arm->bonebase.first, NULL, hide_unselected_pose_bone_cb); else bone_looper(ob, arm->bonebase.first, NULL, hide_selected_pose_bone_cb); @@ -5296,7 +5296,7 @@ void ED_armature_bone_rename(bArmature *arm, const char *oldnamep, const char *n char oldname[MAXBONENAME]; /* names better differ! */ - if(strncmp(oldnamep, newnamep, MAXBONENAME)) { + if (strncmp(oldnamep, newnamep, MAXBONENAME)) { /* we alter newname string... so make copy */ BLI_strncpy(newname, newnamep, MAXBONENAME); @@ -5371,7 +5371,7 @@ void ED_armature_bone_rename(bArmature *arm, const char *oldnamep, const char *n if (modifiers_usesArmature(ob, arm)) { bDeformGroup *dg= defgroup_find_name(ob, oldname); - if(dg) { + if (dg) { BLI_strncpy(dg->name, newname, MAXBONENAME); } } @@ -5398,15 +5398,15 @@ void ED_armature_bone_rename(bArmature *arm, const char *oldnamep, const char *n /* correct view locking */ { bScreen *screen; - for(screen= G.main->screen.first; screen; screen= screen->id.next) { + for (screen= G.main->screen.first; screen; screen= screen->id.next) { ScrArea *sa; /* add regions */ - for(sa= screen->areabase.first; sa; sa= sa->next) { + for (sa= screen->areabase.first; sa; sa= sa->next) { SpaceLink *sl; for (sl= sa->spacedata.first; sl; sl= sl->next) { - if(sl->spacetype==SPACE_VIEW3D) { + if (sl->spacetype==SPACE_VIEW3D) { View3D *v3d= (View3D *)sl; - if(v3d->ob_centre && v3d->ob_centre->data == arm) { + if (v3d->ob_centre && v3d->ob_centre->data == arm) { if (!strcmp(v3d->ob_centre_bone, oldname)) { BLI_strncpy(v3d->ob_centre_bone, newname, MAXBONENAME); } @@ -5480,7 +5480,7 @@ static int armature_autoside_names_exec (bContext *C, wmOperator *op) CTX_DATA_BEGIN(C, EditBone *, ebone, selected_editable_bones) { BLI_strncpy(newname, ebone->name, sizeof(newname)); - if(bone_autoside_name(newname, 1, axis, ebone->head[axis], ebone->tail[axis])) + if (bone_autoside_name(newname, 1, axis, ebone->head[axis], ebone->tail[axis])) ED_armature_bone_rename(arm, ebone->name, newname); } CTX_DATA_END; @@ -5642,7 +5642,7 @@ EditBone * subdivideByAngle(Scene *scene, Object *obedit, ReebArc *arc, ReebNode * to let subsequent subdivision methods do their thing. * */ if (parent == root) { - if(parent==arm->act_edbone) arm->act_edbone= NULL; + if (parent==arm->act_edbone) arm->act_edbone= NULL; ED_armature_edit_bone_remove(arm, parent); parent = NULL; } @@ -5862,7 +5862,7 @@ void generateSkeletonFromReebGraph(Scene *scene, ReebGraph *rg) EditBone *childBone = BLI_ghash_lookup(arcBoneMap, arc); /* find the root bone */ - while(childBone->parent != NULL) + while (childBone->parent != NULL) { childBone = childBone->parent; } diff --git a/source/blender/editors/armature/editarmature_retarget.c b/source/blender/editors/armature/editarmature_retarget.c index 375184d3229..261018329ab 100644 --- a/source/blender/editors/armature/editarmature_retarget.c +++ b/source/blender/editors/armature/editarmature_retarget.c @@ -323,7 +323,7 @@ static RigGraph *newRigGraph(void) rg->free_node = NULL; #ifdef USE_THREADS -// if(G.scene->r.mode & R_FIXED_THREADS) +// if (G.scene->r.mode & R_FIXED_THREADS) // { // totthread = G.scene->r.threads; // } @@ -1008,7 +1008,7 @@ static void RIG_reconnectControlBones(RigGraph *rg) /* look on deform bones first */ BLI_ghashIterator_init(&ghi, rg->bones_map); - for( ; !BLI_ghashIterator_isDone(&ghi); BLI_ghashIterator_step(&ghi)) + for ( ; !BLI_ghashIterator_isDone(&ghi); BLI_ghashIterator_step(&ghi)) { EditBone *bone = (EditBone*)BLI_ghashIterator_getValue(&ghi); @@ -1298,7 +1298,7 @@ static void RIG_arcFromBoneChain(RigGraph *rg, ListBase *list, EditBone *root_bo RigArc *arc = NULL; int contain_head = 0; - for(bone = root_bone; bone; bone = nextEditBoneChild(list, bone, 0)) + for (bone = root_bone; bone; bone = nextEditBoneChild(list, bone, 0)) { int nb_children; @@ -1550,7 +1550,7 @@ RigGraph *RIG_graphFromArmature(const bContext *C, Object *ob, bArmature *arm) rg->ob = ob; /* Do the rotations */ - for (ebone = rg->editbones->first; ebone; ebone=ebone->next){ + for (ebone = rg->editbones->first; ebone; ebone=ebone->next) { if (ebone->parent == NULL) { RIG_arcFromBoneChain(rg, rg->editbones, ebone, NULL, 0); @@ -1602,7 +1602,7 @@ static RigGraph *armatureSelectedToGraph(bContext *C, Object *ob, bArmature *arm rg->ob = ob; /* Do the rotations */ - for (ebone = rg->editbones->first; ebone; ebone=ebone->next){ + for (ebone = rg->editbones->first; ebone; ebone=ebone->next) { if (ebone->parent == NULL) { RIG_arcFromBoneChain(rg, rg->editbones, ebone, NULL, 1); @@ -2488,7 +2488,7 @@ static void markMultiResolutionChildArc(ReebNode *end_enode, ReebNode *enode) { int i; - for(i = 0; i < enode->degree; i++) + for (i = 0; i < enode->degree; i++) { ReebArc *earc = (ReebArc*)enode->arcs[i]; @@ -2593,7 +2593,7 @@ static void findCorrespondingArc(RigGraph *rigg, RigArc *start_arc, RigNode *sta // RIG_printArcBones(next_iarc); // } - for(i = 0; i < enode->degree; i++) + for (i = 0; i < enode->degree; i++) { next_earc = (ReebArc*)enode->arcs[i]; @@ -2644,14 +2644,14 @@ static void findCorrespondingArc(RigGraph *rigg, RigArc *start_arc, RigNode *sta // printf("flag %i -- level %i -- flag %i -- group %i\n", ARC_FREE, symmetry_level, symmetry_flag, symmetry_group); // // printf("CANDIDATES\n"); -// for(i = 0; i < enode->degree; i++) +// for (i = 0; i < enode->degree; i++) // { // next_earc = (ReebArc*)enode->arcs[i]; // printf("flag %i -- level %i -- flag %i -- group %i\n", next_earc->flag, next_earc->symmetry_level, next_earc->symmetry_flag, next_earc->symmetry_group); // } /* Emergency matching */ - for(i = 0; i < enode->degree; i++) + for (i = 0; i < enode->degree; i++) { next_earc = (ReebArc*)enode->arcs[i]; @@ -2687,7 +2687,7 @@ static void retargetSubgraph(bContext *C, RigGraph *rigg, RigArc *start_arc, Rig matchMultiResolutionNode(rigg, inode, enode); } - for(i = 0; i < inode->degree; i++) + for (i = 0; i < inode->degree; i++) { RigArc *next_iarc = (RigArc*)inode->arcs[i]; diff --git a/source/blender/editors/armature/editarmature_sketch.c b/source/blender/editors/armature/editarmature_sketch.c index f9f3cd60d0b..81b020a4cf9 100644 --- a/source/blender/editors/armature/editarmature_sketch.c +++ b/source/blender/editors/armature/editarmature_sketch.c @@ -1870,7 +1870,7 @@ int sk_detectCommandGesture(bContext *UNUSED(C), SK_Gesture *gest, SK_Sketch *UN SK_Intersection *isect, *self_isect; /* get the the last intersection of the first pair */ - for( isect = gest->intersections.first; isect; isect = isect->next ) + for ( isect = gest->intersections.first; isect; isect = isect->next ) { if (isect->stroke == isect->next->stroke) { @@ -1897,7 +1897,7 @@ void sk_applyCommandGesture(bContext *UNUSED(C), SK_Gesture *gest, SK_Sketch *UN // XXX // command = pupmenu("Action %t|Flatten %x1|Straighten %x2|Polygonize %x3"); - if(command < 1) return; + if (command < 1) return; for (isect = gest->intersections.first; isect; isect = isect->next) { @@ -2177,7 +2177,7 @@ static int sk_selectStroke(bContext *C, SK_Sketch *sketch, const int mval[2], in { int besthitresult = -1; - if(hits == 1) { + if (hits == 1) { besthitresult = buffer[3]; } else { diff --git a/source/blender/editors/armature/meshlaplacian.c b/source/blender/editors/armature/meshlaplacian.c index de9b4a890cb..4c1315e847e 100644 --- a/source/blender/editors/armature/meshlaplacian.c +++ b/source/blender/editors/armature/meshlaplacian.c @@ -142,7 +142,7 @@ static void laplacian_increase_edge_count(EdgeHash *edgehash, int v1, int v2) { void **p = BLI_edgehash_lookup_p(edgehash, v1, v2); - if(p) + if (p) *p = (void*)((intptr_t)*p + (intptr_t)1); else BLI_edgehash_insert(edgehash, v1, v2, (void*)(intptr_t)1); @@ -184,8 +184,8 @@ static void laplacian_triangle_area(LaplacianSystem *sys, int i1, int i2, int i3 t3= cotan_weight(v3, v1, v2); if (angle_v3v3v3(v2, v1, v3) > DEG2RADF(90.0f)) obtuse= 1; - else if(angle_v3v3v3(v1, v2, v3) > DEG2RADF(90.0f)) obtuse= 2; - else if(angle_v3v3v3(v1, v3, v2) > DEG2RADF(90.0f)) obtuse= 3; + else if (angle_v3v3v3(v1, v2, v3) > DEG2RADF(90.0f)) obtuse= 2; + else if (angle_v3v3v3(v1, v3, v2) > DEG2RADF(90.0f)) obtuse= 3; if (obtuse > 0) { area= area_tri_v3(v1, v2, v3); @@ -237,7 +237,7 @@ static void laplacian_triangle_weights(LaplacianSystem *sys, int f, int i1, int nlMatrixAdd(i3, i1, -t2*varea[i3]); nlMatrixAdd(i1, i3, -t2*varea[i1]); - if(sys->storeweights) { + if (sys->storeweights) { sys->fweights[f][0]= t1*varea[i1]; sys->fweights[f][1]= t2*varea[i2]; sys->fweights[f][2]= t3*varea[i3]; @@ -263,7 +263,7 @@ static LaplacianSystem *laplacian_system_construct_begin(int totvert, int totfac /* create opennl context */ nlNewContext(); nlSolverParameteri(NL_NB_VARIABLES, totvert); - if(lsq) + if (lsq) nlSolverParameteri(NL_LEAST_SQUARES, NL_TRUE); sys->context= nlGetCurrent(); @@ -296,39 +296,39 @@ static void laplacian_system_construct_end(LaplacianSystem *sys) sys->varea= MEM_callocN(sizeof(float)*totvert, "LaplacianSystemVarea"); sys->edgehash= BLI_edgehash_new(); - for(a=0, face=sys->faces; atotface; a++, face++) { + for (a=0, face=sys->faces; atotface; a++, face++) { laplacian_increase_edge_count(sys->edgehash, (*face)[0], (*face)[1]); laplacian_increase_edge_count(sys->edgehash, (*face)[1], (*face)[2]); laplacian_increase_edge_count(sys->edgehash, (*face)[2], (*face)[0]); } - if(sys->areaweights) - for(a=0, face=sys->faces; atotface; a++, face++) + if (sys->areaweights) + for (a=0, face=sys->faces; atotface; a++, face++) laplacian_triangle_area(sys, (*face)[0], (*face)[1], (*face)[2]); - for(a=0; aareaweights) { - if(sys->varea[a] != 0.0f) + for (a=0; aareaweights) { + if (sys->varea[a] != 0.0f) sys->varea[a]= 0.5f/sys->varea[a]; } else sys->varea[a]= 1.0f; /* for heat weighting */ - if(sys->heat.H) + if (sys->heat.H) nlMatrixAdd(a, a, sys->heat.H[a]); } - if(sys->storeweights) + if (sys->storeweights) sys->fweights= MEM_callocN(sizeof(float)*3*totface, "LaplacianFWeight"); - for(a=0, face=sys->faces; afaces; afaces); sys->faces= NULL; - if(sys->varea) { + if (sys->varea) { MEM_freeN(sys->varea); sys->varea= NULL; } @@ -339,11 +339,11 @@ static void laplacian_system_construct_end(LaplacianSystem *sys) static void laplacian_system_delete(LaplacianSystem *sys) { - if(sys->verts) MEM_freeN(sys->verts); - if(sys->varea) MEM_freeN(sys->varea); - if(sys->vpinned) MEM_freeN(sys->vpinned); - if(sys->faces) MEM_freeN(sys->faces); - if(sys->fweights) MEM_freeN(sys->fweights); + if (sys->verts) MEM_freeN(sys->verts); + if (sys->varea) MEM_freeN(sys->varea); + if (sys->vpinned) MEM_freeN(sys->vpinned); + if (sys->faces) MEM_freeN(sys->faces); + if (sys->fweights) MEM_freeN(sys->fweights); nlDeleteContext(sys->context); MEM_freeN(sys); @@ -356,9 +356,9 @@ void laplacian_begin_solve(LaplacianSystem *sys, int index) if (!sys->nlbegun) { nlBegin(NL_SYSTEM); - if(index >= 0) { - for(a=0; atotvert; a++) { - if(sys->vpinned[a]) { + if (index >= 0) { + for (a=0; atotvert; a++) { + if (sys->vpinned[a]) { nlSetVariable(0, a, sys->verts[a][index]); nlLockVariable(a); } @@ -415,9 +415,9 @@ static void bvh_callback(void *userdata, int index, const BVHTreeRay *UNUSED(ray mul_v3_v3fl(dir, data->vec, hit->dist); - if(isect_ray_tri_v3(data->start, dir, verts[mf->v1], verts[mf->v2], verts[mf->v3], &lambda, uv)) { + if (isect_ray_tri_v3(data->start, dir, verts[mf->v1], verts[mf->v2], verts[mf->v3], &lambda, uv)) { normal_tri_v3(n, verts[mf->v1], verts[mf->v2], verts[mf->v3]); - if(lambda < 1.0f && dot_v3v3(n, data->vec) < -1e-5f) { + if (lambda < 1.0f && dot_v3v3(n, data->vec) < -1e-5f) { hit->index = index; hit->dist *= lambda; } @@ -425,9 +425,9 @@ static void bvh_callback(void *userdata, int index, const BVHTreeRay *UNUSED(ray mul_v3_v3fl(dir, data->vec, hit->dist); - if(isect_ray_tri_v3(data->start, dir, verts[mf->v1], verts[mf->v3], verts[mf->v4], &lambda, uv)) { + if (isect_ray_tri_v3(data->start, dir, verts[mf->v1], verts[mf->v3], verts[mf->v4], &lambda, uv)) { normal_tri_v3(n, verts[mf->v1], verts[mf->v3], verts[mf->v4]); - if(lambda < 1.0f && dot_v3v3(n, data->vec) < -1e-5f) { + if (lambda < 1.0f && dot_v3v3(n, data->vec) < -1e-5f) { hit->index = index; hit->dist *= lambda; } @@ -446,7 +446,7 @@ static void heat_ray_tree_create(LaplacianSystem *sys) sys->heat.bvhtree = BLI_bvhtree_new(totface, 0.0f, 4, 6); sys->heat.vface = MEM_callocN(sizeof(MFace*)*totvert, "HeatVFaces"); - for(a=0; av1], bb, bb+3); DO_MINMAX(verts[mf->v2], bb, bb+3); DO_MINMAX(verts[mf->v3], bb, bb+3); - if(mf->v4) { + if (mf->v4) { DO_MINMAX(verts[mf->v4], bb, bb+3); } @@ -464,7 +464,7 @@ static void heat_ray_tree_create(LaplacianSystem *sys) sys->heat.vface[mf->v1]= mf; sys->heat.vface[mf->v2]= mf; sys->heat.vface[mf->v3]= mf; - if(mf->v4) sys->heat.vface[mf->v4]= mf; + if (mf->v4) sys->heat.vface[mf->v4]= mf; } BLI_bvhtree_balance(sys->heat.bvhtree); @@ -479,13 +479,13 @@ static int heat_ray_source_visible(LaplacianSystem *sys, int vertex, int source) int visible; mface= sys->heat.vface[vertex]; - if(!mface) + if (!mface) return 1; data.sys= sys; copy_v3_v3(data.start, sys->heat.verts[vertex]); - if(sys->heat.root) /* bone */ + if (sys->heat.root) /* bone */ closest_to_line_segment_v3(end, data.start, sys->heat.root[source], sys->heat.tip[source]); else /* vertex */ @@ -509,7 +509,7 @@ static float heat_source_distance(LaplacianSystem *sys, int vertex, int source) float closest[3], d[3], dist, cosine; /* compute euclidian distance */ - if(sys->heat.root) /* bone */ + if (sys->heat.root) /* bone */ closest_to_line_segment_v3(closest, sys->heat.verts[vertex], sys->heat.root[source], sys->heat.tip[source]); else /* vertex */ @@ -530,8 +530,8 @@ static int heat_source_closest(LaplacianSystem *sys, int vertex, int source) dist= heat_source_distance(sys, vertex, source); - if(dist <= sys->heat.mindist[vertex]*(1.0f + DISTANCE_EPSILON)) - if(heat_ray_source_visible(sys, vertex, source)) + if (dist <= sys->heat.mindist[vertex]*(1.0f + DISTANCE_EPSILON)) + if (heat_ray_source_visible(sys, vertex, source)) return 1; return 0; @@ -545,24 +545,24 @@ static void heat_set_H(LaplacianSystem *sys, int vertex) mindist= 1e10; /* compute minimum distance */ - for(j=0; jheat.numsource; j++) { + for (j=0; jheat.numsource; j++) { dist= heat_source_distance(sys, vertex, j); - if(dist < mindist) + if (dist < mindist) mindist= dist; } sys->heat.mindist[vertex]= mindist; /* count number of sources with approximately this minimum distance */ - for(j=0; jheat.numsource; j++) - if(heat_source_closest(sys, vertex, j)) + for (j=0; jheat.numsource; j++) + if (heat_source_closest(sys, vertex, j)) numclosest++; sys->heat.p[vertex]= (numclosest > 0)? 1.0f/numclosest: 0.0f; /* compute H entry */ - if(numclosest > 0) { + if (numclosest > 0) { mindist= maxf(mindist, 1e-4f); h= numclosest*C_WEIGHT/(mindist*mindist); } @@ -579,7 +579,7 @@ static void heat_calc_vnormals(LaplacianSystem *sys) sys->heat.vnors= MEM_callocN(sizeof(float)*3*sys->totvert, "HeatVNors"); - for(a=0, face=sys->faces; atotface; a++, face++) { + for (a=0, face=sys->faces; atotface; a++, face++) { v1= (*face)[0]; v2= (*face)[1]; v3= (*face)[2]; @@ -591,7 +591,7 @@ static void heat_calc_vnormals(LaplacianSystem *sys) add_v3_v3(sys->heat.vnors[v3], fnor); } - for(a=0; atotvert; a++) + for (a=0; atotvert; a++) normalize_v3(sys->heat.vnors[a]); } @@ -608,19 +608,19 @@ static void heat_laplacian_create(LaplacianSystem *sys) sys->heat.p= MEM_callocN(sizeof(float)*totvert, "HeatP"); /* add verts and faces to laplacian */ - for(a=0; aheat.verts[a], 0); - for(a=0, mf=mface; av1, mf->v2, mf->v3); - if(mf->v4) + if (mf->v4) laplacian_add_triangle(sys, mf->v1, mf->v3, mf->v4); } /* for distance computation in set_H */ heat_calc_vnormals(sys); - for(a=0; aeditflag & ME_EDIT_PAINT_MASK) != 0) || + if ( (use_face_sel= (me->editflag & ME_EDIT_PAINT_MASK) != 0) || (use_vert_sel= ((me->editflag & ME_EDIT_VERT_SEL) != 0))) { mask= MEM_callocN(sizeof(int)*me->totvert, "heat_bone_weighting mask"); } - for(a = 0, mp=me->mpoly; a < me->totpoly; mp++, a++) { + for (a = 0, mp=me->mpoly; a < me->totpoly; mp++, a++) { /* (added selectedVerts content for vertex mask, they used to just equal 1) */ - if(use_vert_sel) { + if (use_vert_sel) { for (j = 0, ml = me->mloop + mp->loopstart; j < mp->totloop; j++, ml++) { if (use_vert_sel) { mask[ml->v] = (mvert[ml->v].flag & SELECT) != 0; @@ -694,9 +694,9 @@ void heat_bone_weighting(Object *ob, Mesh *me, float (*verts)[3], int numsource, /* bone heat needs triangulated faces */ BKE_mesh_tessface_ensure(me); - for(tottri = 0, a = 0, mf = me->mface; a < me->totface; mf++, a++) { + for (tottri = 0, a = 0, mf = me->mface; a < me->totface; mf++, a++) { tottri++; - if(mf->v4) tottri++; + if (mf->v4) tottri++; } /* create laplacian */ @@ -715,15 +715,15 @@ void heat_bone_weighting(Object *ob, Mesh *me, float (*verts)[3], int numsource, laplacian_system_construct_end(sys); - if(dgroupflip) { + if (dgroupflip) { vertsflipped = MEM_callocN(sizeof(int)*me->totvert, "vertsflipped"); - for(a=0; atotvert; a++) + for (a=0; atotvert; a++) vertsflipped[a] = mesh_get_x_mirror_vert(ob, a); } /* compute weights per bone */ - for(j=0; jtotvert; a++) { - if(mask && !mask[a]) + if (bbone && firstsegment) { + for (a=0; atotvert; a++) { + if (mask && !mask[a]) continue; ED_vgroup_vert_remove(ob, dgrouplist[j], a); - if(vertsflipped && dgroupflip[j] && vertsflipped[a] >= 0) + if (vertsflipped && dgroupflip[j] && vertsflipped[a] >= 0) ED_vgroup_vert_remove(ob, dgroupflip[j], vertsflipped[a]); } } @@ -745,28 +745,28 @@ void heat_bone_weighting(Object *ob, Mesh *me, float (*verts)[3], int numsource, /* fill right hand side */ laplacian_begin_solve(sys, -1); - for(a=0; atotvert; a++) - if(heat_source_closest(sys, a, j)) + for (a=0; atotvert; a++) + if (heat_source_closest(sys, a, j)) laplacian_add_right_hand_side(sys, a, sys->heat.H[a]*sys->heat.p[a]); /* solve */ - if(laplacian_system_solve(sys)) { + if (laplacian_system_solve(sys)) { /* load solution into vertex groups */ - for(a=0; atotvert; a++) { - if(mask && !mask[a]) + for (a=0; atotvert; a++) { + if (mask && !mask[a]) continue; solution= laplacian_system_get_solution(a); - if(bbone) { - if(solution > 0.0f) + if (bbone) { + if (solution > 0.0f) ED_vgroup_vert_add(ob, dgrouplist[j], a, solution, WEIGHT_ADD); } else { weight= heat_limit_weight(solution); - if(weight > 0.0f) + if (weight > 0.0f) ED_vgroup_vert_add(ob, dgrouplist[j], a, weight, WEIGHT_REPLACE); else @@ -774,15 +774,15 @@ void heat_bone_weighting(Object *ob, Mesh *me, float (*verts)[3], int numsource, } /* do same for mirror */ - if(vertsflipped && dgroupflip[j] && vertsflipped[a] >= 0) { - if(bbone) { - if(solution > 0.0f) + if (vertsflipped && dgroupflip[j] && vertsflipped[a] >= 0) { + if (bbone) { + if (solution > 0.0f) ED_vgroup_vert_add(ob, dgroupflip[j], vertsflipped[a], solution, WEIGHT_ADD); } else { weight= heat_limit_weight(solution); - if(weight > 0.0f) + if (weight > 0.0f) ED_vgroup_vert_add(ob, dgroupflip[j], vertsflipped[a], weight, WEIGHT_REPLACE); else @@ -791,26 +791,26 @@ void heat_bone_weighting(Object *ob, Mesh *me, float (*verts)[3], int numsource, } } } - else if(*err_str == NULL) { + else if (*err_str == NULL) { *err_str= "Bone Heat Weighting: failed to find solution for one or more bones"; break; } /* remove too small vertex weights */ - if(bbone && lastsegment) { - for(a=0; atotvert; a++) { - if(mask && !mask[a]) + if (bbone && lastsegment) { + for (a=0; atotvert; a++) { + if (mask && !mask[a]) continue; weight= ED_vgroup_vert_weight(ob, dgrouplist[j], a); weight= heat_limit_weight(weight); - if(weight <= 0.0f) + if (weight <= 0.0f) ED_vgroup_vert_remove(ob, dgrouplist[j], a); - if(vertsflipped && dgroupflip[j] && vertsflipped[a] >= 0) { + if (vertsflipped && dgroupflip[j] && vertsflipped[a] >= 0) { weight= ED_vgroup_vert_weight(ob, dgroupflip[j], vertsflipped[a]); weight= heat_limit_weight(weight); - if(weight <= 0.0f) + if (weight <= 0.0f) ED_vgroup_vert_remove(ob, dgroupflip[j], vertsflipped[a]); } } @@ -818,8 +818,8 @@ void heat_bone_weighting(Object *ob, Mesh *me, float (*verts)[3], int numsource, } /* free */ - if(vertsflipped) MEM_freeN(vertsflipped); - if(mask) MEM_freeN(mask); + if (vertsflipped) MEM_freeN(vertsflipped); + if (mask) MEM_freeN(mask); heat_system_free(sys); @@ -903,7 +903,7 @@ void rigid_deform_iteration() EditFace *efa; int a, i; - if(!sys) + if (!sys) return; nlMakeCurrent(sys->context); @@ -913,12 +913,12 @@ void rigid_deform_iteration() memset(sys->rigid.R, 0, sizeof(float)*3*3*sys->totvert); memset(sys->rigid.rhs, 0, sizeof(float)*3*sys->totvert); - for(a=0, efa=em->faces.first; efa; efa=efa->next, a++) { + for (a=0, efa=em->faces.first; efa; efa=efa->next, a++) { rigid_add_edge_to_R(sys, efa->v1, efa->v2, sys->fweights[a][2]); rigid_add_edge_to_R(sys, efa->v2, efa->v3, sys->fweights[a][0]); rigid_add_edge_to_R(sys, efa->v3, efa->v1, sys->fweights[a][1]); - if(efa->v4) { + if (efa->v4) { a++; rigid_add_edge_to_R(sys, efa->v1, efa->v3, sys->fweights[a][2]); rigid_add_edge_to_R(sys, efa->v3, efa->v4, sys->fweights[a][0]); @@ -926,18 +926,18 @@ void rigid_deform_iteration() } } - for(a=0, eve=em->verts.first; eve; eve=eve->next, a++) { + for (a=0, eve=em->verts.first; eve; eve=eve->next, a++) { rigid_orthogonalize_R(sys->rigid.R[a]); eve->tmp.l= a; } /* compute right hand sides for solving */ - for(a=0, efa=em->faces.first; efa; efa=efa->next, a++) { + for (a=0, efa=em->faces.first; efa; efa=efa->next, a++) { rigid_add_edge_to_rhs(sys, efa->v1, efa->v2, sys->fweights[a][2]); rigid_add_edge_to_rhs(sys, efa->v2, efa->v3, sys->fweights[a][0]); rigid_add_edge_to_rhs(sys, efa->v3, efa->v1, sys->fweights[a][1]); - if(efa->v4) { + if (efa->v4) { a++; rigid_add_edge_to_rhs(sys, efa->v1, efa->v3, sys->fweights[a][2]); rigid_add_edge_to_rhs(sys, efa->v3, efa->v4, sys->fweights[a][0]); @@ -946,19 +946,19 @@ void rigid_deform_iteration() } /* solve for positions, for X,Y and Z separately */ - for(i=0; i<3; i++) { + for (i=0; i<3; i++) { laplacian_begin_solve(sys, i); - for(a=0; atotvert; a++) - if(!sys->vpinned[a]) + for (a=0; atotvert; a++) + if (!sys->vpinned[a]) laplacian_add_right_hand_side(sys, a, sys->rigid.rhs[a][i]); - if(laplacian_system_solve(sys)) { - for(a=0, eve=em->verts.first; eve; eve=eve->next, a++) + if (laplacian_system_solve(sys)) { + for (a=0, eve=em->verts.first; eve; eve=eve->next, a++) eve->co[i]= laplacian_system_get_solution(a); } else { - if(!sys->rigid.thrownerror) { + if (!sys->rigid.thrownerror) { error("RigidDeform: failed to find solution"); sys->rigid.thrownerror= 1; } @@ -975,15 +975,15 @@ static void rigid_laplacian_create(LaplacianSystem *sys) int a; /* add verts and faces to laplacian */ - for(a=0, eve=em->verts.first; eve; eve=eve->next, a++) { + for (a=0, eve=em->verts.first; eve; eve=eve->next, a++) { laplacian_add_vertex(sys, eve->co, eve->pinned); eve->tmp.l= a; } - for(efa=em->faces.first; efa; efa=efa->next) { + for (efa=em->faces.first; efa; efa=efa->next) { laplacian_add_triangle(sys, efa->v1->tmp.l, efa->v2->tmp.l, efa->v3->tmp.l); - if(efa->v4) + if (efa->v4) laplacian_add_triangle(sys, efa->v1->tmp.l, efa->v3->tmp.l, efa->v4->tmp.l); } @@ -997,12 +997,12 @@ void rigid_deform_begin(EditMesh *em) int a, totvert, totface; /* count vertices, triangles */ - for(totvert=0, eve=em->verts.first; eve; eve=eve->next) + for (totvert=0, eve=em->verts.first; eve; eve=eve->next) totvert++; - for(totface=0, efa=em->faces.first; efa; efa=efa->next) { + for (totface=0, efa=em->faces.first; efa; efa=efa->next) { totface++; - if(efa->v4) totface++; + if (efa->v4) totface++; } /* create laplacian */ @@ -1013,7 +1013,7 @@ void rigid_deform_begin(EditMesh *em) sys->rigid.rhs = MEM_callocN(sizeof(float)*3*totvert, "RigidDeformRHS"); sys->rigid.origco = MEM_callocN(sizeof(float)*3*totvert, "RigidDeformCo"); - for(a=0, eve=em->verts.first; eve; eve=eve->next, a++) + for (a=0, eve=em->verts.first; eve; eve=eve->next, a++) copy_v3_v3(sys->rigid.origco[a], eve->co); sys->areaweights= 0; @@ -1030,19 +1030,19 @@ void rigid_deform_end(int cancel) { LaplacianSystem *sys = RigidDeformSystem; - if(sys) { + if (sys) { EditMesh *em = sys->rigid.mesh; EditVert *eve; int a; - if(cancel) - for(a=0, eve=em->verts.first; eve; eve=eve->next, a++) - if(!eve->pinned) + if (cancel) + for (a=0, eve=em->verts.first; eve; eve=eve->next, a++) + if (!eve->pinned) copy_v3_v3(eve->co, sys->rigid.origco[a]); - if(sys->rigid.R) MEM_freeN(sys->rigid.R); - if(sys->rigid.rhs) MEM_freeN(sys->rigid.rhs); - if(sys->rigid.origco) MEM_freeN(sys->rigid.origco); + if (sys->rigid.R) MEM_freeN(sys->rigid.R); + if (sys->rigid.rhs) MEM_freeN(sys->rigid.rhs); + if (sys->rigid.origco) MEM_freeN(sys->rigid.origco); /* free */ laplacian_system_delete(sys); @@ -1176,10 +1176,10 @@ static int meshdeform_tri_intersect(float orig[3], float end[3], float vert0[3], /* check if it is within the length of the line segment */ sub_v3_v3v3(isectdir, isectco, orig); - if(dot_v3v3(dir, isectdir) < -EPSILON) + if (dot_v3v3(dir, isectdir) < -EPSILON) return 0; - if(dot_v3v3(dir, dir) + EPSILON < dot_v3v3(isectdir, isectdir)) + if (dot_v3v3(dir, dir) + EPSILON < dot_v3v3(isectdir, isectdir)) return 0; return 1; @@ -1198,16 +1198,16 @@ static int meshdeform_intersect(MeshDeformBind *mdb, MeshDeformIsect *isec) add_v3_v3v3(end, isec->start, isec->vec); - for(f=0; fcagecos[mface->v1]); copy_v3_v3(face[1], mdb->cagecos[mface->v2]); copy_v3_v3(face[2], mdb->cagecos[mface->v3]); - if(mface->v4) { + if (mface->v4) { copy_v3_v3(face[3], mdb->cagecos[mface->v4]); hit = meshdeform_tri_intersect(isec->start, end, face[0], face[1], face[2], co, uvw); - if(hit) { + if (hit) { normal_tri_v3( nor,face[0], face[1], face[2]); } else { @@ -1220,9 +1220,9 @@ static int meshdeform_intersect(MeshDeformBind *mdb, MeshDeformIsect *isec) normal_tri_v3( nor,face[0], face[1], face[2]); } - if(hit) { + if (hit) { len= len_v3v3(isec->start, co)/len_v3v3(isec->start, end); - if(len < isec->labda) { + if (len < isec->labda) { isec->labda= len; isec->face = mface; isec->isect= (dot_v3v3(isec->vec, nor) <= 0.0f); @@ -1251,7 +1251,7 @@ static MDefBoundIsect *meshdeform_ray_tree_intersect(MeshDeformBind *mdb, float add_v3_v3v3(end, co2, epsilon); sub_v3_v3v3(isec.vec, end, isec.start); - if(meshdeform_intersect(mdb, &isec)) { + if (meshdeform_intersect(mdb, &isec)) { len= isec.labda; mface=(MFace*)isec.face; @@ -1264,7 +1264,7 @@ static MDefBoundIsect *meshdeform_ray_tree_intersect(MeshDeformBind *mdb, float isect->co[2]= co1[2] + isec.vec[2]*len; isect->len= len_v3v3(co1, isect->co); - if(isect->len < MESHDEFORM_LEN_THRESHOLD) + if (isect->len < MESHDEFORM_LEN_THRESHOLD) isect->len= MESHDEFORM_LEN_THRESHOLD; isect->v[0]= mface->v1; @@ -1280,7 +1280,7 @@ static MDefBoundIsect *meshdeform_ray_tree_intersect(MeshDeformBind *mdb, float copy_v3_v3(vert[0], cagecos[mface->v1]); copy_v3_v3(vert[1], cagecos[mface->v2]); copy_v3_v3(vert[2], cagecos[mface->v3]); - if(mface->v4) copy_v3_v3(vert[3], cagecos[mface->v4]); + if (mface->v4) copy_v3_v3(vert[3], cagecos[mface->v4]); interp_weights_poly_v3( isect->uvw,vert, isect->nvert, isect->co); return isect; @@ -1295,7 +1295,7 @@ static int meshdeform_inside_cage(MeshDeformBind *mdb, float *co) float outside[3], start[3], dir[3]; int i; - for(i=1; i<=6; i++) { + for (i=1; i<=6; i++) { outside[0] = co[0] + (mdb->max[0] - mdb->min[0] + 1.0f)*MESHDEFORM_OFFSET[i][0]; outside[1] = co[1] + (mdb->max[1] - mdb->min[1] + 1.0f)*MESHDEFORM_OFFSET[i][1]; outside[2] = co[2] + (mdb->max[2] - mdb->min[2] + 1.0f)*MESHDEFORM_OFFSET[i][2]; @@ -1305,7 +1305,7 @@ static int meshdeform_inside_cage(MeshDeformBind *mdb, float *co) normalize_v3(dir); isect = meshdeform_ray_tree_intersect(mdb, start, outside); - if(isect && !isect->facing) + if (isect && !isect->facing) return 1; } @@ -1322,11 +1322,11 @@ static int meshdeform_index(MeshDeformBind *mdb, int x, int y, int z, int n) y += MESHDEFORM_OFFSET[n][1]; z += MESHDEFORM_OFFSET[n][2]; - if(x < 0 || x >= mdb->size) + if (x < 0 || x >= mdb->size) return -1; - if(y < 0 || y >= mdb->size) + if (y < 0 || y >= mdb->size) return -1; - if(z < 0 || z >= mdb->size) + if (z < 0 || z >= mdb->size) return -1; return x + y*size + z*size*size; @@ -1353,14 +1353,14 @@ static void meshdeform_add_intersections(MeshDeformBind *mdb, int x, int y, int meshdeform_cell_center(mdb, x, y, z, 0, center); /* check each outgoing edge for intersection */ - for(i=1; i<=6; i++) { - if(meshdeform_index(mdb, x, y, z, i) == -1) + for (i=1; i<=6; i++) { + if (meshdeform_index(mdb, x, y, z, i) == -1) continue; meshdeform_cell_center(mdb, x, y, z, i, ncenter); isect= meshdeform_ray_tree_intersect(mdb, center, ncenter); - if(isect) { + if (isect) { mdb->boundisect[a][i-1]= isect; mdb->tag[a]= MESHDEFORM_TAG_BOUNDARY; } @@ -1380,18 +1380,18 @@ static void meshdeform_bind_floodfill(MeshDeformBind *mdb) stacksize= 1; /* floodfill exterior tag */ - while(stacksize > 0) { + while (stacksize > 0) { a= stack[--stacksize]; xyz[2]= a/(size*size); xyz[1]= (a - xyz[2]*size*size)/size; xyz[0]= a - xyz[1]*size - xyz[2]*size*size; - for(i=1; i<=6; i++) { + for (i=1; i<=6; i++) { b= meshdeform_index(mdb, xyz[0], xyz[1], xyz[2], i); - if(b != -1) { - if(tag[b] == MESHDEFORM_TAG_UNTYPED || + if (b != -1) { + if (tag[b] == MESHDEFORM_TAG_UNTYPED || (tag[b] == MESHDEFORM_TAG_BOUNDARY && !mdb->boundisect[a][i-1])) { tag[b]= MESHDEFORM_TAG_EXTERIOR; stack[stacksize++]= b; @@ -1401,23 +1401,23 @@ static void meshdeform_bind_floodfill(MeshDeformBind *mdb) } /* other cells are interior */ - for(a=0; asemibound[a]) + if (mdb->semibound[a]) ts++; } @@ -1432,8 +1432,8 @@ static float meshdeform_boundary_phi(MeshDeformBind *UNUSED(mdb), MDefBoundIsect { int a; - for(a=0; anvert; a++) - if(isect->v[a] == cagevert) + for (a=0; anvert; a++) + if (isect->v[a] == cagevert) return isect->uvw[a]; return 0.0f; @@ -1445,19 +1445,19 @@ static float meshdeform_interp_w(MeshDeformBind *mdb, float *gridvec, float *UNU float weight, totweight= 0.0f; int i, a, x, y, z; - for(i=0; i<3; i++) { + for (i=0; i<3; i++) { ivec[i]= (int)gridvec[i]; dvec[i]= gridvec[i] - ivec[i]; } - for(i=0; i<8; i++) { - if(i & 1) { x= ivec[0]+1; wx= dvec[0]; } + for (i=0; i<8; i++) { + if (i & 1) { x= ivec[0]+1; wx= dvec[0]; } else { x= ivec[0]; wx= 1.0f-dvec[0]; } - if(i & 2) { y= ivec[1]+1; wy= dvec[1]; } + if (i & 2) { y= ivec[1]+1; wy= dvec[1]; } else { y= ivec[1]; wy= 1.0f-dvec[1]; } - if(i & 4) { z= ivec[2]+1; wz= dvec[2]; } + if (i & 4) { z= ivec[2]+1; wz= dvec[2]; } else { z= ivec[2]; wz= 1.0f-dvec[2]; } CLAMP(x, 0, mdb->size-1); @@ -1470,7 +1470,7 @@ static float meshdeform_interp_w(MeshDeformBind *mdb, float *gridvec, float *UNU totweight += weight; } - if(totweight > 0.0f) + if (totweight > 0.0f) result /= totweight; return result; @@ -1481,11 +1481,11 @@ static void meshdeform_check_semibound(MeshDeformBind *mdb, int x, int y, int z) int i, a; a= meshdeform_index(mdb, x, y, z, 0); - if(mdb->tag[a] != MESHDEFORM_TAG_EXTERIOR) + if (mdb->tag[a] != MESHDEFORM_TAG_EXTERIOR) return; - for(i=1; i<=6; i++) - if(mdb->boundisect[a][i-1]) + for (i=1; i<=6; i++) + if (mdb->boundisect[a][i-1]) mdb->semibound[a]= 1; } @@ -1497,13 +1497,13 @@ static float meshdeform_boundary_total_weight(MeshDeformBind *mdb, int x, int y, a= meshdeform_index(mdb, x, y, z, 0); /* count weight for neighbor cells */ - for(i=1; i<=6; i++) { - if(meshdeform_index(mdb, x, y, z, i) == -1) + for (i=1; i<=6; i++) { + if (meshdeform_index(mdb, x, y, z, i) == -1) continue; - if(mdb->boundisect[a][i-1]) + if (mdb->boundisect[a][i-1]) weight= 1.0f/mdb->boundisect[a][i-1]->len; - else if(!mdb->semibound[a]) + else if (!mdb->semibound[a]) weight= 1.0f/mdb->width[0]; else weight= 0.0f; @@ -1521,15 +1521,15 @@ static void meshdeform_matrix_add_cell(MeshDeformBind *mdb, int x, int y, int z) int i, a, acenter; acenter= meshdeform_index(mdb, x, y, z, 0); - if(mdb->tag[acenter] == MESHDEFORM_TAG_EXTERIOR) + if (mdb->tag[acenter] == MESHDEFORM_TAG_EXTERIOR) return; nlMatrixAdd(mdb->varidx[acenter], mdb->varidx[acenter], 1.0f); totweight= meshdeform_boundary_total_weight(mdb, x, y, z); - for(i=1; i<=6; i++) { + for (i=1; i<=6; i++) { a= meshdeform_index(mdb, x, y, z, i); - if(a == -1 || mdb->tag[a] == MESHDEFORM_TAG_EXTERIOR) + if (a == -1 || mdb->tag[a] == MESHDEFORM_TAG_EXTERIOR) continue; isect= mdb->boundisect[acenter][i-1]; @@ -1547,13 +1547,13 @@ static void meshdeform_matrix_add_rhs(MeshDeformBind *mdb, int x, int y, int z, int i, a, acenter; acenter= meshdeform_index(mdb, x, y, z, 0); - if(mdb->tag[acenter] == MESHDEFORM_TAG_EXTERIOR) + if (mdb->tag[acenter] == MESHDEFORM_TAG_EXTERIOR) return; totweight= meshdeform_boundary_total_weight(mdb, x, y, z); - for(i=1; i<=6; i++) { + for (i=1; i<=6; i++) { a= meshdeform_index(mdb, x, y, z, i); - if(a == -1) + if (a == -1) continue; isect= mdb->boundisect[acenter][i-1]; @@ -1573,13 +1573,13 @@ static void meshdeform_matrix_add_semibound_phi(MeshDeformBind *mdb, int x, int int i, a; a= meshdeform_index(mdb, x, y, z, 0); - if(!mdb->semibound[a]) + if (!mdb->semibound[a]) return; mdb->phi[a]= 0.0f; totweight= meshdeform_boundary_total_weight(mdb, x, y, z); - for(i=1; i<=6; i++) { + for (i=1; i<=6; i++) { isect= mdb->boundisect[a][i-1]; if (isect) { @@ -1596,21 +1596,21 @@ static void meshdeform_matrix_add_exterior_phi(MeshDeformBind *mdb, int x, int y int i, a, acenter; acenter= meshdeform_index(mdb, x, y, z, 0); - if(mdb->tag[acenter] != MESHDEFORM_TAG_EXTERIOR || mdb->semibound[acenter]) + if (mdb->tag[acenter] != MESHDEFORM_TAG_EXTERIOR || mdb->semibound[acenter]) return; phi= 0.0f; totweight= 0.0f; - for(i=1; i<=6; i++) { + for (i=1; i<=6; i++) { a= meshdeform_index(mdb, x, y, z, i); - if(a != -1 && mdb->semibound[a]) { + if (a != -1 && mdb->semibound[a]) { phi += mdb->phi[a]; totweight += 1.0f; } } - if(totweight != 0.0f) + if (totweight != 0.0f) mdb->phi[acenter]= phi/totweight; } @@ -1623,10 +1623,10 @@ static void meshdeform_matrix_solve(MeshDeformModifierData *mmd, MeshDeformBind /* setup variable indices */ mdb->varidx= MEM_callocN(sizeof(int)*mdb->size3, "MeshDeformDSvaridx"); - for(a=0, totvar=0; asize3; a++) + for (a=0, totvar=0; asize3; a++) mdb->varidx[a]= (mdb->tag[a] == MESHDEFORM_TAG_EXTERIOR)? -1: totvar++; - if(totvar == 0) { + if (totvar == 0) { MEM_freeN(mdb->varidx); return; } @@ -1645,22 +1645,22 @@ static void meshdeform_matrix_solve(MeshDeformModifierData *mmd, MeshDeformBind nlBegin(NL_MATRIX); /* build matrix */ - for(z=0; zsize; z++) - for(y=0; ysize; y++) - for(x=0; xsize; x++) + for (z=0; zsize; z++) + for (y=0; ysize; y++) + for (x=0; xsize; x++) meshdeform_matrix_add_cell(mdb, x, y, z); /* solve for each cage vert */ - for(a=0; atotcagevert; a++) { - if(a != 0) { + for (a=0; atotcagevert; a++) { + if (a != 0) { nlBegin(NL_SYSTEM); nlBegin(NL_MATRIX); } /* fill in right hand side and solve */ - for(z=0; zsize; z++) - for(y=0; ysize; y++) - for(x=0; xsize; x++) + for (z=0; zsize; z++) + for (y=0; ysize; y++) + for (x=0; xsize; x++) meshdeform_matrix_add_rhs(mdb, x, y, z, a); nlEnd(NL_MATRIX); @@ -1670,27 +1670,27 @@ static void meshdeform_matrix_solve(MeshDeformModifierData *mmd, MeshDeformBind nlPrintMatrix(); #endif - if(nlSolveAdvanced(NULL, NL_TRUE)) { - for(z=0; zsize; z++) - for(y=0; ysize; y++) - for(x=0; xsize; x++) + if (nlSolveAdvanced(NULL, NL_TRUE)) { + for (z=0; zsize; z++) + for (y=0; ysize; y++) + for (x=0; xsize; x++) meshdeform_matrix_add_semibound_phi(mdb, x, y, z, a); - for(z=0; zsize; z++) - for(y=0; ysize; y++) - for(x=0; xsize; x++) + for (z=0; zsize; z++) + for (y=0; ysize; y++) + for (x=0; xsize; x++) meshdeform_matrix_add_exterior_phi(mdb, x, y, z, a); - for(b=0; bsize3; b++) { - if(mdb->tag[b] != MESHDEFORM_TAG_EXTERIOR) + for (b=0; bsize3; b++) { + if (mdb->tag[b] != MESHDEFORM_TAG_EXTERIOR) mdb->phi[b]= nlGetVariable(0, mdb->varidx[b]); mdb->totalphi[b] += mdb->phi[b]; } - if(mdb->weights) { + if (mdb->weights) { /* static bind : compute weights for each vertex */ - for(b=0; btotvert; b++) { - if(mdb->inside[b]) { + for (b=0; btotvert; b++) { + if (mdb->inside[b]) { copy_v3_v3(vec, mdb->vertexcos[b]); gridvec[0]= (vec[0] - mdb->min[0] - mdb->halfwidth[0])/mdb->width[0]; gridvec[1]= (vec[1] - mdb->min[1] - mdb->halfwidth[1])/mdb->width[1]; @@ -1704,8 +1704,8 @@ static void meshdeform_matrix_solve(MeshDeformModifierData *mmd, MeshDeformBind MDefBindInfluence *inf; /* dynamic bind */ - for(b=0; bsize3; b++) { - if(mdb->phi[b] >= MESHDEFORM_MIN_INFLUENCE) { + for (b=0; bsize3; b++) { + if (mdb->phi[b] >= MESHDEFORM_MIN_INFLUENCE) { inf= BLI_memarena_alloc(mdb->memarena, sizeof(*inf)); inf->vertex= a; inf->weight= mdb->phi[b]; @@ -1727,9 +1727,9 @@ static void meshdeform_matrix_solve(MeshDeformModifierData *mmd, MeshDeformBind #if 0 /* sanity check */ - for(b=0; bsize3; b++) - if(mdb->tag[b] != MESHDEFORM_TAG_EXTERIOR) - if(fabs(mdb->totalphi[b] - 1.0f) > 1e-4) + for (b=0; bsize3; b++) + if (mdb->tag[b] != MESHDEFORM_TAG_EXTERIOR) + if (fabs(mdb->totalphi[b] - 1.0f) > 1e-4) printf("totalphi deficiency [%s|%d] %d: %.10f\n", (mdb->tag[b] == MESHDEFORM_TAG_INTERIOR)? "interior": "boundary", mdb->semibound[b], mdb->varidx[b], mdb->totalphi[b]); #endif @@ -1751,7 +1751,7 @@ static void harmonic_coordinates_bind(Scene *UNUSED(scene), MeshDeformModifierDa /* compute bounding box of the cage mesh */ INIT_MINMAX(mdb->min, mdb->max); - for(a=0; atotcagevert; a++) + for (a=0; atotcagevert; a++) DO_MINMAX(mdb->cagecos[a], mdb->min, mdb->max); /* allocate memory */ @@ -1765,7 +1765,7 @@ static void harmonic_coordinates_bind(Scene *UNUSED(scene), MeshDeformModifierDa mdb->inside= MEM_callocN(sizeof(int)*mdb->totvert, "MDefInside"); - if(mmd->flag & MOD_MDEF_DYNAMIC_BIND) + if (mmd->flag & MOD_MDEF_DYNAMIC_BIND) mdb->dyngrid= MEM_callocN(sizeof(MDefBindInfluence*)*mdb->size3, "MDefDynGrid"); else mdb->weights= MEM_callocN(sizeof(float)*mdb->totvert*mdb->totcagevert, "MDefWeights"); @@ -1776,11 +1776,11 @@ static void harmonic_coordinates_bind(Scene *UNUSED(scene), MeshDeformModifierDa /* make bounding box equal size in all directions, add padding, and compute * width of the cells */ maxwidth = -1.0f; - for(a=0; a<3; a++) - if(mdb->max[a]-mdb->min[a] > maxwidth) + for (a=0; a<3; a++) + if (mdb->max[a]-mdb->min[a] > maxwidth) maxwidth= mdb->max[a]-mdb->min[a]; - for(a=0; a<3; a++) { + for (a=0; a<3; a++) { center[a]= (mdb->min[a]+mdb->max[a])*0.5f; mdb->min[a]= center[a] - maxwidth*0.5f; mdb->max[a]= center[a] + maxwidth*0.5f; @@ -1796,10 +1796,10 @@ static void harmonic_coordinates_bind(Scene *UNUSED(scene), MeshDeformModifierDa progress_bar(0, "Setting up mesh deform system"); totinside= 0; - for(a=0; atotvert; a++) { + for (a=0; atotvert; a++) { copy_v3_v3(vec, mdb->vertexcos[a]); mdb->inside[a]= meshdeform_inside_cage(mdb, vec); - if(mdb->inside[a]) + if (mdb->inside[a]) totinside++; } @@ -1808,53 +1808,53 @@ static void harmonic_coordinates_bind(Scene *UNUSED(scene), MeshDeformModifierDa mdb->memarena= BLI_memarena_new(BLI_MEMARENA_STD_BUFSIZE, "harmonic coords arena"); /* start with all cells untyped */ - for(a=0; asize3; a++) + for (a=0; asize3; a++) mdb->tag[a]= MESHDEFORM_TAG_UNTYPED; /* detect intersections and tag boundary cells */ - for(z=0; zsize; z++) - for(y=0; ysize; y++) - for(x=0; xsize; x++) + for (z=0; zsize; z++) + for (y=0; ysize; y++) + for (x=0; xsize; x++) meshdeform_add_intersections(mdb, x, y, z); /* compute exterior and interior tags */ meshdeform_bind_floodfill(mdb); - for(z=0; zsize; z++) - for(y=0; ysize; y++) - for(x=0; xsize; x++) + for (z=0; zsize; z++) + for (y=0; ysize; y++) + for (x=0; xsize; x++) meshdeform_check_semibound(mdb, x, y, z); /* solve */ meshdeform_matrix_solve(mmd, mdb); /* assign results */ - if(mmd->flag & MOD_MDEF_DYNAMIC_BIND) { + if (mmd->flag & MOD_MDEF_DYNAMIC_BIND) { mmd->totinfluence= 0; - for(a=0; asize3; a++) - for(inf=mdb->dyngrid[a]; inf; inf=inf->next) + for (a=0; asize3; a++) + for (inf=mdb->dyngrid[a]; inf; inf=inf->next) mmd->totinfluence++; /* convert MDefBindInfluences to smaller MDefInfluences */ mmd->dyngrid= MEM_callocN(sizeof(MDefCell)*mdb->size3, "MDefDynGrid"); mmd->dyninfluences= MEM_callocN(sizeof(MDefInfluence)*mmd->totinfluence, "MDefInfluence"); offset= 0; - for(a=0; asize3; a++) { + for (a=0; asize3; a++) { cell= &mmd->dyngrid[a]; cell->offset= offset; totweight= 0.0f; mdinf= mmd->dyninfluences + cell->offset; - for(inf=mdb->dyngrid[a]; inf; inf=inf->next, mdinf++) { + for (inf=mdb->dyngrid[a]; inf; inf=inf->next, mdinf++) { mdinf->weight= inf->weight; mdinf->vertex= inf->vertex; totweight += mdinf->weight; cell->totinfluence++; } - if(totweight > 0.0f) { + if (totweight > 0.0f) { mdinf= mmd->dyninfluences + cell->offset; - for(b=0; btotinfluence; b++, mdinf++) + for (b=0; btotinfluence; b++, mdinf++) mdinf->weight /= totweight; } @@ -1893,9 +1893,9 @@ static void heat_weighting_bind(Scene *scene, DerivedMesh *dm, MeshDeformModifie mdb->weights= MEM_callocN(sizeof(float)*mdb->totvert*mdb->totcagevert, "MDefWeights"); /* count triangles */ - for(tottri=0, a=0, mf=mface; av4) tottri++; + if (mf->v4) tottri++; } /* create laplacian */ @@ -1914,27 +1914,27 @@ static void heat_weighting_bind(Scene *scene, DerivedMesh *dm, MeshDeformModifie laplacian_system_construct_end(sys); /* compute weights per bone */ - for(j=0; jtotcagevert; j++) { + for (j=0; jtotcagevert; j++) { /* fill right hand side */ laplacian_begin_solve(sys, -1); - for(a=0; aheat.H[a]*sys->heat.p[a]); /* solve */ - if(laplacian_system_solve(sys)) { + if (laplacian_system_solve(sys)) { /* load solution into vertex groups */ - for(a=0; a 0.0f) + if (weight > 0.0f) mdb->weights[a*mdb->totcagevert + j] = weight; } } - else if(!thrownerror) { + else if (!thrownerror) { error("Mesh Deform Heat Weighting:" " failed to find solution for one or more vertices"); thrownerror= 1; @@ -1971,14 +1971,14 @@ void mesh_deform_bind(Scene *scene, MeshDeformModifierData *mmd, float *vertexco copy_m4_m4(mdb.cagemat, cagemat); mvert= mdb.cagedm->getVertArray(mdb.cagedm); - for(a=0; amode == MOD_MDEF_VOLUME) + if (mmd->mode == MOD_MDEF_VOLUME) harmonic_coordinates_bind(scene, mmd, &mdb); else heat_weighting_bind(scene, dm, mmd, &mdb); @@ -1993,7 +1993,7 @@ void mesh_deform_bind(Scene *scene, MeshDeformModifierData *mmd, float *vertexco copy_m4_m4(mmd->bindmat, mmd->object->obmat); /* transform bindcagecos to world space */ - for(a=0; aobject->obmat, mmd->bindcagecos+a*3); /* free */ diff --git a/source/blender/editors/armature/poseSlide.c b/source/blender/editors/armature/poseSlide.c index de7a243f75f..be520d1e8a0 100644 --- a/source/blender/editors/armature/poseSlide.c +++ b/source/blender/editors/armature/poseSlide.c @@ -1102,7 +1102,7 @@ static void pose_propagate_fcurve (wmOperator *op, Object *ob, FCurve *fcu, * doesn't need to firstly keyframe the pose (though this doesn't mean that * they can't either) */ - if( !pose_propagate_get_refVal(ob, fcu, &refVal)) + if ( !pose_propagate_get_refVal(ob, fcu, &refVal)) return; /* find the first keyframe to start propagating from diff --git a/source/blender/editors/armature/poseobject.c b/source/blender/editors/armature/poseobject.c index 2689ec68563..3d33930fa49 100644 --- a/source/blender/editors/armature/poseobject.c +++ b/source/blender/editors/armature/poseobject.c @@ -109,7 +109,7 @@ void ED_armature_enter_posemode(bContext *C, Base *base) void ED_armature_exit_posemode(bContext *C, Base *base) { - if(base) { + if (base) { Object *ob= base->object; ob->restore_mode = ob->mode; @@ -154,18 +154,18 @@ static int pose_channel_in_IK_chain(Object *ob, bPoseChannel *pchan, int level) /* No need to check if constraint is active (has influence), * since all constraints with CONSTRAINT_IK_AUTO are active */ - for(con= pchan->constraints.first; con; con= con->next) { - if(con->type==CONSTRAINT_TYPE_KINEMATIC) { + for (con= pchan->constraints.first; con; con= con->next) { + if (con->type==CONSTRAINT_TYPE_KINEMATIC) { bKinematicConstraint *data= con->data; - if(data->rootbone == 0 || data->rootbone > level) { - if((data->flag & CONSTRAINT_IK_AUTO)==0) + if (data->rootbone == 0 || data->rootbone > level) { + if ((data->flag & CONSTRAINT_IK_AUTO)==0) return 1; } } } - for(bone= pchan->bone->childbase.first; bone; bone= bone->next) { + for (bone= pchan->bone->childbase.first; bone; bone= bone->next) { pchan= get_pose_channel(ob->pose, bone->name); - if(pchan && pose_channel_in_IK_chain(ob, pchan, level + 1)) + if (pchan && pose_channel_in_IK_chain(ob, pchan, level + 1)) return 1; } return 0; @@ -338,7 +338,7 @@ static int pose_select_constraint_target_exec(bContext *C, wmOperator *UNUSED(op for (ct= targets.first; ct; ct= ct->next) { if ((ct->tar == ob) && (ct->subtarget[0])) { bPoseChannel *pchanc= get_pose_channel(ob->pose, ct->subtarget); - if((pchanc) && !(pchanc->bone->flag & BONE_UNSELECTABLE)) { + if ((pchanc) && !(pchanc->bone->flag & BONE_UNSELECTABLE)) { pchanc->bone->flag |= BONE_SELECTED|BONE_TIPSEL|BONE_ROOTSEL; found= 1; } @@ -687,23 +687,23 @@ static int pose_bone_flip_active_exec (bContext *C, wmOperator *UNUSED(op)) Object *ob_act= CTX_data_active_object(C); Object *ob= object_pose_armature_get(ob_act); - if(ob && (ob->mode & OB_MODE_POSE)) { + if (ob && (ob->mode & OB_MODE_POSE)) { bArmature *arm= ob->data; - if(arm->act_bone) { + if (arm->act_bone) { bPoseChannel *pchanf; char name[MAXBONENAME]; flip_side_name(name, arm->act_bone->name, TRUE); pchanf= get_pose_channel(ob->pose, name); - if(pchanf && pchanf->bone != arm->act_bone) { + if (pchanf && pchanf->bone != arm->act_bone) { arm->act_bone->flag &= ~BONE_SELECTED; pchanf->bone->flag |= BONE_SELECTED; arm->act_bone= pchanf->bone; /* in weightpaint we select the associated vertex group too */ - if(ob_act->mode & OB_MODE_WEIGHT_PAINT) { + if (ob_act->mode & OB_MODE_WEIGHT_PAINT) { ED_vgroup_select_by_name(ob_act, name); DAG_id_tag_update(&ob_act->id, OB_RECALC_DATA); } @@ -876,7 +876,7 @@ static void pose_copy_menu(Scene *scene) BLI_duplicatelist(&const_copy, &(pchanact->constraints)); /* build the puplist of constraints */ - for (con = pchanact->constraints.first, i=0; con; con=con->next, i++){ + for (con = pchanact->constraints.first, i=0; con; con=con->next, i++) { const_toggle[i]= 1; // add_numbut(i, TOG|INT, con->name, 0, 0, &(const_toggle[i]), ""); } @@ -946,7 +946,7 @@ void free_posebuf(void) bPoseChannel *pchan; for (pchan= g_posebuf->chanbase.first; pchan; pchan= pchan->next) { - if(pchan->prop) { + if (pchan->prop) { IDP_FreeProperty(pchan->prop); MEM_freeN(pchan->prop); } @@ -968,8 +968,8 @@ static void set_pose_keys (Object *ob) bArmature *arm= ob->data; bPoseChannel *chan; - if (ob->pose){ - for (chan=ob->pose->chanbase.first; chan; chan=chan->next){ + if (ob->pose) { + for (chan=ob->pose->chanbase.first; chan; chan=chan->next) { Bone *bone= chan->bone; if ((bone) && (bone->flag & BONE_SELECTED) && (arm->layer & bone->layer)) chan->flag |= POSE_KEY; @@ -1789,7 +1789,7 @@ static int pose_autoside_names_exec (bContext *C, wmOperator *op) CTX_DATA_BEGIN(C, bPoseChannel*, pchan, selected_pose_bones) { BLI_strncpy(newname, pchan->name, sizeof(newname)); - if(bone_autoside_name(newname, 1, axis, pchan->bone->head[axis], pchan->bone->tail[axis])) + if (bone_autoside_name(newname, 1, axis, pchan->bone->head[axis], pchan->bone->tail[axis])) ED_armature_bone_rename(arm, pchan->name, newname); } CTX_DATA_END; @@ -2046,7 +2046,7 @@ static int pose_bone_layers_exec (bContext *C, wmOperator *op) PointerRNA ptr; int layers[32]; /* hardcoded for now - we can only have 32 armature layers, so this should be fine... */ - if(ob==NULL || ob->data==NULL) { + if (ob==NULL || ob->data==NULL) { return OPERATOR_CANCELLED; } diff --git a/source/blender/editors/armature/reeb.c b/source/blender/editors/armature/reeb.c index e832247e67c..30f929c9603 100644 --- a/source/blender/editors/armature/reeb.c +++ b/source/blender/editors/armature/reeb.c @@ -126,7 +126,7 @@ static VertexData *allocVertexData(EditMesh *em) data = MEM_callocN(sizeof(VertexData) * totvert, "VertexData"); - for(index = 0, eve = em->verts.first; eve; index++, eve = eve->next) + for (index = 0, eve = em->verts.first; eve; index++, eve = eve->next) { data[index].i = index; data[index].w = 0; @@ -183,7 +183,7 @@ void REEB_freeGraph(ReebGraph *rg) ReebNode *node; // free nodes - for( node = rg->nodes.first; node; node = node->next ) + for ( node = rg->nodes.first; node; node = node->next ) { BLI_freeNode((BGraph*)rg, (BNode*)node); } @@ -191,7 +191,7 @@ void REEB_freeGraph(ReebGraph *rg) // free arcs arc = rg->arcs.first; - while( arc ) + while ( arc ) { ReebArc *next = arc->next; REEB_freeArc((BArc*)arc); @@ -407,7 +407,7 @@ ReebGraph *BIF_graphForMultiNode(ReebGraph *rg, ReebNode *node) { ReebGraph *multi_rg = rg; - while(multi_rg && multi_rg->multi_level != node->multi_level) + while (multi_rg && multi_rg->multi_level != node->multi_level) { multi_rg = multi_rg->link_up; } @@ -436,7 +436,7 @@ static void printArc(ReebArc *arc) ReebNode *tail = (ReebNode*)arc->tail; printf("arc: (%i) %f -> (%i) %f\n", head->index, head->weight, tail->index, tail->weight); - for(edge = arc->edges.first; edge ; edge = edge->next) + for (edge = arc->edges.first; edge ; edge = edge->next) { printf("\tedge (%i, %i)\n", edge->v1->index, edge->v2->index); } @@ -484,12 +484,12 @@ void repositionNodes(ReebGraph *rg) BNode *node = NULL; // Reset node positions - for(node = rg->nodes.first; node; node = node->next) + for (node = rg->nodes.first; node; node = node->next) { node->p[0] = node->p[1] = node->p[2] = 0; } - for(arc = rg->arcs.first; arc; arc = arc->next) + for (arc = rg->arcs.first; arc; arc = arc->next) { if (((ReebArc*)arc)->bcount > 0) { @@ -512,10 +512,10 @@ void verifyNodeDegree(ReebGraph *rg) ReebNode *node = NULL; ReebArc *arc = NULL; - for(node = rg->nodes.first; node; node = node->next) + for (node = rg->nodes.first; node; node = node->next) { int count = 0; - for(arc = rg->arcs.first; arc; arc = arc->next) + for (arc = rg->arcs.first; arc; arc = arc->next) { if (arc->head == node || arc->tail == node) { @@ -542,7 +542,7 @@ static void verifyBucketsArc(ReebGraph *UNUSED(rg), ReebArc *arc) if (arc->bcount > 0) { int i; - for(i = 0; i < arc->bcount; i++) + for (i = 0; i < arc->bcount; i++) { if (arc->buckets[i].nv == 0) { @@ -568,7 +568,7 @@ void verifyBuckets(ReebGraph *rg) { #ifdef DEBUG_REEB ReebArc *arc = NULL; - for(arc = rg->arcs.first; arc; arc = arc->next) + for (arc = rg->arcs.first; arc; arc = arc->next) { verifyBucketsArc(rg, arc); } @@ -580,7 +580,7 @@ void verifyFaces(ReebGraph *rg) #ifdef DEBUG_REEB int total = 0; ReebArc *arc = NULL; - for(arc = rg->arcs.first; arc; arc = arc->next) + for (arc = rg->arcs.first; arc; arc = arc->next) { total += BLI_ghash_size(arc->faces); } @@ -667,17 +667,17 @@ static void mergeArcBuckets(ReebArc *aDst, ReebArc *aSrc, float start, float end start = MAX3(start, aDst->buckets[0].val, aSrc->buckets[0].val); - while(indexDst < aDst->bcount && aDst->buckets[indexDst].val < start) + while (indexDst < aDst->bcount && aDst->buckets[indexDst].val < start) { indexDst++; } - while(indexSrc < aSrc->bcount && aSrc->buckets[indexSrc].val < start) + while (indexSrc < aSrc->bcount && aSrc->buckets[indexSrc].val < start) { indexSrc++; } - for( ; indexDst < aDst->bcount && + for ( ; indexDst < aDst->bcount && indexSrc < aSrc->bcount && aDst->buckets[indexDst].val <= end && aSrc->buckets[indexSrc].val <= end @@ -718,7 +718,7 @@ static void allocArcBuckets(ReebArc *arc) { arc->buckets = MEM_callocN(sizeof(EmbedBucket) * arc->bcount, "embed bucket"); - for(i = 0; i < arc->bcount; i++) + for (i = 0; i < arc->bcount; i++) { arc->buckets[i].val = start + i; } @@ -779,7 +779,7 @@ static void reweightBuckets(ReebArc *arc) if (arc->bcount > 0) { - for(i = 0; i < arc->bcount; i++) + for (i = 0; i < arc->bcount; i++) { arc->buckets[i].val = start + i; } @@ -810,7 +810,7 @@ static void fillArcEmptyBuckets(ReebArc *arc) start_p = arc->head->p; - for(i = 0; i < arc->bcount; i++) + for (i = 0; i < arc->bcount; i++) { EmbedBucket *bucket = arc->buckets + i; @@ -1013,12 +1013,12 @@ void REEB_RadialSymmetry(BNode* root_node, RadialArc* ring, int count) bucket2 = IT_next(iter2); /* Make sure they both start at the same value */ - while(bucket1 && bucket2 && bucket1->val < bucket2->val) + while (bucket1 && bucket2 && bucket1->val < bucket2->val) { bucket1 = IT_next(iter1); } - while(bucket1 && bucket2 && bucket2->val < bucket1->val) + while (bucket1 && bucket2 && bucket2->val < bucket1->val) { bucket2 = IT_next(iter2); } @@ -1075,12 +1075,12 @@ void REEB_RadialSymmetry(BNode* root_node, RadialArc* ring, int count) bucket2 = IT_next(iter2); /* Make sure they both start at the same value */ - while(bucket1 && bucket1->val < bucket2->val) + while (bucket1 && bucket1->val < bucket2->val) { bucket1 = IT_next(iter1); } - while(bucket2 && bucket2->val < bucket1->val) + while (bucket2 && bucket2->val < bucket1->val) { bucket2 = IT_next(iter2); } @@ -1136,12 +1136,12 @@ void REEB_AxialSymmetry(BNode* root_node, BNode* node1, BNode* node2, struct BAr bucket2 = IT_next(iter2); /* Make sure they both start at the same value */ - while(bucket1 && bucket1->val < bucket2->val) + while (bucket1 && bucket1->val < bucket2->val) { bucket1 = IT_next(iter1); } - while(bucket2 && bucket2->val < bucket1->val) + while (bucket2 && bucket2->val < bucket1->val) { bucket2 = IT_next(iter2); } @@ -1194,13 +1194,13 @@ void postprocessGraph(ReebGraph *rg, char mode) return; } - for(arc = rg->arcs.first; arc; arc = arc->next) + for (arc = rg->arcs.first; arc; arc = arc->next) { EmbedBucket *buckets = arc->buckets; int bcount = arc->bcount; int index; - for(index = 1; index < bcount - 1; index++) + for (index = 1; index < bcount - 1; index++) { interp_v3_v3v3(buckets[index].p, buckets[index].p, buckets[index - 1].p, fac1 / (fac1 + fac2)); interp_v3_v3v3(buckets[index].p, buckets[index].p, buckets[index + 1].p, fac3 / (fac1 + fac2 + fac3)); @@ -1511,7 +1511,7 @@ static void filterArc(ReebGraph *rg, ReebNode *newNode, ReebNode *removedNode, R if (merging) { /* first pass, merge buckets for arcs that spawned the two nodes into the source arc*/ - for(arc = rg->arcs.first; arc; arc = arc->next) + for (arc = rg->arcs.first; arc; arc = arc->next) { if (arc->head == srcArc->head && arc->tail == srcArc->tail && arc != srcArc) { @@ -1524,7 +1524,7 @@ static void filterArc(ReebGraph *rg, ReebNode *newNode, ReebNode *removedNode, R /* second pass, replace removedNode by newNode, remove arcs that are collapsed in a loop */ arc = rg->arcs.first; - while(arc) + while (arc) { nextArc = arc->next; @@ -1587,7 +1587,7 @@ void filterNullReebGraph(ReebGraph *rg) ReebArc *arc = NULL, *nextArc = NULL; arc = rg->arcs.first; - while(arc) + while (arc) { nextArc = arc->next; // Only collapse arcs too short to have any embed bucket @@ -1749,14 +1749,14 @@ int filterSmartReebGraph(ReebGraph *UNUSED(rg), float UNUSED(threshold)) #ifdef DEBUG_REEB { EditFace *efa; - for(efa=G.editMesh->faces.first; efa; efa=efa->next) { + for (efa=G.editMesh->faces.first; efa; efa=efa->next) { efa->tmp.fp = -1; } } #endif arc = rg->arcs.first; - while(arc) + while (arc) { nextArc = arc->next; @@ -1772,7 +1772,7 @@ int filterSmartReebGraph(ReebGraph *UNUSED(rg), float UNUSED(threshold)) float avg_angle = 0; float avg_vec[3] = {0,0,0}; - for(BLI_ghashIterator_init(&ghi, arc->faces); + for (BLI_ghashIterator_init(&ghi, arc->faces); !BLI_ghashIterator_isDone(&ghi); BLI_ghashIterator_step(&ghi)) { @@ -1963,7 +1963,7 @@ static void finalizeGraph(ReebGraph *rg, char passes, char method) sortArcs(rg); - for(i = 0; i < passes; i++) + for (i = 0; i < passes; i++) { postprocessGraph(rg, method); } @@ -2001,17 +2001,17 @@ static void spreadWeight(EditMesh *em) verts = MEM_callocN(sizeof(EditVert*) * totvert, "verts array"); - for(eve = em->verts.first, i = 0; eve; eve = eve->next, i++) + for (eve = em->verts.first, i = 0; eve; eve = eve->next, i++) { verts[i] = eve; } - while(work_needed == 1) + while (work_needed == 1) { work_needed = 0; qsort(verts, totvert, sizeof(EditVert*), compareVerts); - for(i = 0; i < totvert; i++) + for (i = 0; i < totvert; i++) { eve = verts[i]; @@ -2053,14 +2053,14 @@ void REEB_exportGraph(ReebGraph *rg, int count) } f = BLI_fopen(filename, "w"); - for(arc = rg->arcs.first; arc; arc = arc->next) + for (arc = rg->arcs.first; arc; arc = arc->next) { int i; float p[3]; exportNode(f, "v1", arc->head); - for(i = 0; i < arc->bcount; i++) + for (i = 0; i < arc->bcount; i++) { fprintf(f, "b nv:%i %f %f %f\n", arc->buckets[i].nv, arc->buckets[i].p[0], arc->buckets[i].p[1], arc->buckets[i].p[2]); } @@ -2098,7 +2098,7 @@ void removeNormalNodes(ReebGraph *rg) ReebArc *arc, *nextArc; // Merge degree 2 nodes - for(arc = rg->arcs.first; arc; arc = nextArc) + for (arc = rg->arcs.first; arc; arc = nextArc) { nextArc = arc->next; @@ -2176,7 +2176,7 @@ static ReebArc *nextArcMappedToEdge(ReebArc *arc, ReebEdge *e) ReebArc *result = NULL; /* Find the ReebEdge in the edge list */ - for(edge = arc->edges.first; edge && !edgeEquals(edge, e); edge = edge->next) + for (edge = arc->edges.first; edge && !edgeEquals(edge, e); edge = edge->next) { } nextEdge = edge->nextEdge; @@ -2198,7 +2198,7 @@ void mergeArcFaces(ReebGraph *UNUSED(rg), ReebArc *aDst, ReebArc *aSrc) { GHashIterator ghi; - for(BLI_ghashIterator_init(&ghi, aSrc->faces); + for (BLI_ghashIterator_init(&ghi, aSrc->faces); !BLI_ghashIterator_isDone(&ghi); BLI_ghashIterator_step(&ghi)) { @@ -2213,7 +2213,7 @@ void mergeArcEdges(ReebGraph *rg, ReebArc *aDst, ReebArc *aSrc, MergeDirection d if (direction == MERGE_APPEND) { - for(e = aSrc->edges.first; e; e = e->next) + for (e = aSrc->edges.first; e; e = e->next) { e->arc = aDst; // Edge is stolen by new arc } @@ -2222,7 +2222,7 @@ void mergeArcEdges(ReebGraph *rg, ReebArc *aDst, ReebArc *aSrc, MergeDirection d } else { - for(e = aSrc->edges.first; e; e = e->next) + for (e = aSrc->edges.first; e; e = e->next) { ReebEdge *newEdge = copyEdge(e); @@ -2246,7 +2246,7 @@ void mergeArcEdges(ReebGraph *rg, ReebArc *aDst, ReebArc *aSrc, MergeDirection d { ReebEdge *previous = (ReebEdge*)*p; - while(previous->nextEdge != e) + while (previous->nextEdge != e) { previous = previous->nextEdge; } @@ -2497,7 +2497,7 @@ static ReebEdge * createArc(ReebGraph *rg, ReebNode *node1, ReebNode *node2) addVertToBucket(&(arc->buckets[arc->bcount - 1]), arc->tail->co); } #else - for(i = 0; i < arc->bcount; i++) + for (i = 0; i < arc->bcount; i++) { float co[3]; float f = (arc->buckets[i].val - offset) / len; @@ -2595,7 +2595,7 @@ ReebGraph * generateReebGraph(EditMesh *em, int subdivisions) renormalizeWeight(em, (float)rg->resolution); /* Adding vertice */ - for(index = 0, eve = em->verts.first; eve; eve = eve->next) + for (index = 0, eve = em->verts.first; eve; eve = eve->next) { if (eve->h == 0) { @@ -2606,7 +2606,7 @@ ReebGraph * generateReebGraph(EditMesh *em, int subdivisions) } /* Adding face, edge per edge */ - for(efa = em->faces.first; efa; efa = efa->next) + for (efa = em->faces.first; efa; efa = efa->next) { if (efa->h == 0) { @@ -2656,7 +2656,7 @@ void renormalizeWeight(EditMesh *em, float newmax) eve = em->verts.first; minimum = weightData(eve); maximum = minimum; - for(; eve; eve = eve->next) + for (; eve; eve = eve->next) { maximum = MAX2(maximum, weightData(eve)); minimum = MIN2(minimum, weightData(eve)); @@ -2665,7 +2665,7 @@ void renormalizeWeight(EditMesh *em, float newmax) range = maximum - minimum; /* Normalize weights */ - for(eve = em->verts.first; eve; eve = eve->next) + for (eve = em->verts.first; eve; eve = eve->next) { float weight = (weightData(eve) - minimum) / range * newmax; weightSetData(eve, weight); @@ -2681,7 +2681,7 @@ int weightFromLoc(EditMesh *em, int axis) return 0; /* Copy coordinate in weight */ - for(eve = em->verts.first; eve; eve = eve->next) + for (eve = em->verts.first; eve; eve = eve->next) { weightSetData(eve, eve->co[axis]); } @@ -2745,7 +2745,7 @@ int weightToHarmonic(EditMesh *em, EdgeIndex *indexed_edges) int rval; /* Find local extrema */ - for(eve = em->verts.first; eve; eve = eve->next) + for (eve = em->verts.first; eve; eve = eve->next) { totvert++; } @@ -2759,7 +2759,7 @@ int weightToHarmonic(EditMesh *em, EdgeIndex *indexed_edges) nlBegin(NL_SYSTEM); /* Find local extrema */ - for(index = 0, eve = em->verts.first; eve; index++, eve = eve->next) + for (index = 0, eve = em->verts.first; eve; index++, eve = eve->next) { if (eve->h == 0) { @@ -2768,7 +2768,7 @@ int weightToHarmonic(EditMesh *em, EdgeIndex *indexed_edges) int minimum = 1; NextEdgeForVert(indexed_edges, -1); /* Reset next edge */ - for(eed = NextEdgeForVert(indexed_edges, index); eed && (maximum || minimum); eed = NextEdgeForVert(indexed_edges, index)) + for (eed = NextEdgeForVert(indexed_edges, index); eed && (maximum || minimum); eed = NextEdgeForVert(indexed_edges, index)) { EditVert *eve2; @@ -2813,13 +2813,13 @@ int weightToHarmonic(EditMesh *em, EdgeIndex *indexed_edges) nlBegin(NL_MATRIX); /* Zero edge weight */ - for(eed = em->edges.first; eed; eed = eed->next) + for (eed = em->edges.first; eed; eed = eed->next) { eed->tmp.l = 0; } /* Add faces count to the edge weight */ - for(efa = em->faces.first; efa; efa = efa->next) + for (efa = em->faces.first; efa; efa = efa->next) { if (efa->h == 0) { @@ -2835,7 +2835,7 @@ int weightToHarmonic(EditMesh *em, EdgeIndex *indexed_edges) } /* Add faces angle to the edge weight */ - for(efa = em->faces.first; efa; efa = efa->next) + for (efa = em->faces.first; efa; efa = efa->next) { if (efa->h == 0) { @@ -2860,7 +2860,7 @@ int weightToHarmonic(EditMesh *em, EdgeIndex *indexed_edges) if (success) { rval = 1; - for(index = 0, eve = em->verts.first; eve; index++, eve = eve->next) + for (index = 0, eve = em->verts.first; eve; index++, eve = eve->next) { weightSetData(eve, nlGetVariable(0, index)); } @@ -2916,7 +2916,7 @@ static void shortestPathsFromVert(EditMesh *em, EditVert *starting_vert, EdgeInd BLI_heap_insert(edge_heap, FLT_MAX, NULL); /* Initialize edge flag */ - for(eed= em->edges.first; eed; eed= eed->next) + for (eed= em->edges.first; eed; eed= eed->next) { eed->f1 = 0; } @@ -2929,7 +2929,7 @@ static void shortestPathsFromVert(EditMesh *em, EditVert *starting_vert, EdgeInd /* Add all new edges connected to current_eve to the list */ NextEdgeForVert(indexed_edges, -1); // Reset next edge - for(eed = NextEdgeForVert(indexed_edges, indexData(current_eve)); eed; eed = NextEdgeForVert(indexed_edges, indexData(current_eve))) + for (eed = NextEdgeForVert(indexed_edges, indexData(current_eve)); eed; eed = NextEdgeForVert(indexed_edges, indexData(current_eve))) { if (eed->f1 == 0) { @@ -2983,7 +2983,7 @@ static void buildIndexedEdges(EditMesh *em, EdgeIndex *indexed_edges) indexed_edges->offset = MEM_callocN(totvert * sizeof(int), "EdgeIndex offset"); - for(eed = em->edges.first; eed; eed = eed->next) + for (eed = em->edges.first; eed; eed = eed->next) { if (eed->v1->h == 0 && eed->v2->h == 0) { @@ -2998,7 +2998,7 @@ static void buildIndexedEdges(EditMesh *em, EdgeIndex *indexed_edges) indexed_edges->edges = MEM_callocN(tot_indexed * sizeof(EditEdge*), "EdgeIndex edges"); /* setting vert offsets */ - for(eve = em->verts.first; eve; eve = eve->next) + for (eve = em->verts.first; eve; eve = eve->next) { if (eve->h == 0) { @@ -3009,7 +3009,7 @@ static void buildIndexedEdges(EditMesh *em, EdgeIndex *indexed_edges) } /* adding edges in array */ - for(eed = em->edges.first; eed; eed= eed->next) + for (eed = em->edges.first; eed; eed= eed->next) { if (eed->v1->h == 0 && eed->v2->h == 0) { @@ -3057,7 +3057,7 @@ int weightFromDistance(EditMesh *em, EdgeIndex *indexed_edges) } /* Initialize vertice flag and find at least one selected vertex */ - for(eve = em->verts.first; eve; eve = eve->next) + for (eve = em->verts.first; eve; eve = eve->next) { eve->f1 = 0; if (eve->f & SELECT) @@ -3076,7 +3076,7 @@ int weightFromDistance(EditMesh *em, EdgeIndex *indexed_edges) int allDone = 0; /* Calculate edge weight */ - for(eed = em->edges.first; eed; eed= eed->next) + for (eed = em->edges.first; eed; eed= eed->next) { if (eed->v1->h == 0 && eed->v2->h == 0) { @@ -3085,7 +3085,7 @@ int weightFromDistance(EditMesh *em, EdgeIndex *indexed_edges) } /* Apply dijkstra spf for each selected vert */ - for(eve = em->verts.first; eve; eve = eve->next) + for (eve = em->verts.first; eve; eve = eve->next) { if (eve->f & SELECT) { @@ -3137,7 +3137,7 @@ int weightFromDistance(EditMesh *em, EdgeIndex *indexed_edges) } } - for(eve = em->verts.first; eve && vCount == 0; eve = eve->next) + for (eve = em->verts.first; eve && vCount == 0; eve = eve->next) { if (eve->f1 == 0) { diff --git a/source/blender/editors/curve/editcurve.c b/source/blender/editors/curve/editcurve.c index 7b855398802..fbcda86eb75 100644 --- a/source/blender/editors/curve/editcurve.c +++ b/source/blender/editors/curve/editcurve.c @@ -117,7 +117,7 @@ static float nurbcircle[8][2]= { ListBase *object_editcurve_get(Object *ob) { - if(ob && ELEM(ob->type, OB_CURVE, OB_SURF)) { + if (ob && ELEM(ob->type, OB_CURVE, OB_SURF)) { Curve *cu= ob->data; return &cu->editnurb->nurbs; } @@ -129,7 +129,7 @@ static void set_actNurb(Object *obedit, Nurb *nu) { Curve *cu= obedit->data; - if(nu==NULL) + if (nu==NULL) cu->actnu = -1; else { ListBase *nurbs= curve_editnurbs(cu); @@ -157,9 +157,9 @@ static Nurb *get_actNurb(Object *obedit) /* returns 1 in case (de)selection was successful */ static short select_beztriple(BezTriple *bezt, short selstatus, short flag, short hidden) { - if(bezt) { - if((bezt->hide==0) || (hidden==1)) { - if(selstatus==1) { /* selects */ + if (bezt) { + if ((bezt->hide==0) || (hidden==1)) { + if (selstatus==1) { /* selects */ bezt->f1 |= flag; bezt->f2 |= flag; bezt->f3 |= flag; @@ -180,9 +180,9 @@ static short select_beztriple(BezTriple *bezt, short selstatus, short flag, shor /* returns 1 in case (de)selection was successful */ static short select_bpoint(BPoint *bp, short selstatus, short flag, short hidden) { - if(bp) { - if((bp->hide==0) || (hidden==1)) { - if(selstatus==1) { + if (bp) { + if ((bp->hide==0) || (hidden==1)) { + if (selstatus==1) { bp->f1 |= flag; return 1; } @@ -198,7 +198,7 @@ static short select_bpoint(BPoint *bp, short selstatus, short flag, short hidden static short swap_selection_beztriple(BezTriple *bezt) { - if(bezt->f2 & SELECT) + if (bezt->f2 & SELECT) return select_beztriple(bezt, DESELECT, 1, VISIBLE); else return select_beztriple(bezt, SELECT, 1, VISIBLE); @@ -206,7 +206,7 @@ static short swap_selection_beztriple(BezTriple *bezt) static short swap_selection_bpoint(BPoint *bp) { - if(bp->f1 & SELECT) + if (bp->f1 & SELECT) return select_bpoint(bp, DESELECT, 1, VISIBLE); else return select_bpoint(bp, SELECT, 1, VISIBLE); @@ -218,19 +218,19 @@ int isNurbsel(Nurb *nu) BPoint *bp; int a; - if(nu->type == CU_BEZIER) { + if (nu->type == CU_BEZIER) { bezt= nu->bezt; a= nu->pntsu; - while(a--) { - if( (bezt->f1 & SELECT) || (bezt->f2 & SELECT) || (bezt->f3 & SELECT) ) return 1; + while (a--) { + if ( (bezt->f1 & SELECT) || (bezt->f2 & SELECT) || (bezt->f3 & SELECT) ) return 1; bezt++; } } else { bp= nu->bp; a= nu->pntsu*nu->pntsv; - while(a--) { - if( (bp->f1 & SELECT) ) return 1; + while (a--) { + if ( (bp->f1 & SELECT) ) return 1; bp++; } } @@ -243,10 +243,10 @@ static int isNurbsel_count(Curve *cu, Nurb *nu) BPoint *bp; int a, sel=0; - if(nu->type == CU_BEZIER) { + if (nu->type == CU_BEZIER) { bezt= nu->bezt; a= nu->pntsu; - while(a--) { + while (a--) { if (BEZSELECTED_HIDDENHANDLES(cu, bezt)) sel++; bezt++; } @@ -254,8 +254,8 @@ static int isNurbsel_count(Curve *cu, Nurb *nu) else { bp= nu->bp; a= nu->pntsu*nu->pntsv; - while(a--) { - if( (bp->f1 & SELECT) ) sel++; + while (a--) { + if ( (bp->f1 & SELECT) ) sel++; bp++; } } @@ -270,15 +270,15 @@ void printknots(Object *obedit) Nurb *nu; int a, num; - for(nu= editnurb->first; nu; nu= nu->next) { - if(isNurbsel(nu) && nu->type == CU_NURBS) { - if(nu->knotsu) { + for (nu= editnurb->first; nu; nu= nu->next) { + if (isNurbsel(nu) && nu->type == CU_NURBS) { + if (nu->knotsu) { num= KNOTSU(nu); - for(a=0;aknotsu[a]); + for (a=0;aknotsu[a]); } - if(nu->knotsv) { + if (nu->knotsv) { num= KNOTSV(nu); - for(a=0;aknotsv[a]); + for (a=0;aknotsv[a]); } } } @@ -310,7 +310,7 @@ static void init_editNurb_keyIndex(EditNurb *editnurb, ListBase *origBase) CVKeyIndex *keyIndex; int a, key_index= 0, nu_index= 0, pt_index= 0; - if(editnurb->keyindex) return; + if (editnurb->keyindex) return; gh= BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, "editNurb keyIndex"); @@ -328,7 +328,8 @@ static void init_editNurb_keyIndex(EditNurb *editnurb, ListBase *origBase) origbezt++; pt_index++; } - } else { + } + else { a= orignu->pntsu * orignu->pntsv; bp= nu->bp; origbp= orignu->bp; @@ -424,7 +425,8 @@ static void keyIndex_delNurb(EditNurb *editnurb, Nurb *nu) BLI_ghash_remove(editnurb->keyindex, bezt, NULL, (GHashValFreeFP)MEM_freeN); ++bezt; } - } else { + } + else { BPoint *bp= nu->bp; a= nu->pntsu * nu->pntsv; @@ -487,7 +489,8 @@ static void keyIndex_updateNurb(EditNurb *editnurb, Nurb *nu, Nurb *newnu) { if (nu->bezt) { keyIndex_updateBezt(editnurb, nu->bezt, newnu->bezt, newnu->pntsu); - } else { + } + else { keyIndex_updateBP(editnurb, nu->bp, newnu->bp, newnu->pntsu * newnu->pntsv); } } @@ -500,8 +503,8 @@ static void keyIndex_swap(EditNurb *editnurb, void *a, void *b) BLI_ghash_remove(editnurb->keyindex, a, NULL, NULL); BLI_ghash_remove(editnurb->keyindex, b, NULL, NULL); - if(index2) BLI_ghash_insert(editnurb->keyindex, a, index2); - if(index1) BLI_ghash_insert(editnurb->keyindex, b, index1); + if (index2) BLI_ghash_insert(editnurb->keyindex, a, index2); + if (index1) BLI_ghash_insert(editnurb->keyindex, b, index1); } static void keyIndex_switchDirection(EditNurb *editnurb, Nurb *nu) @@ -525,18 +528,19 @@ static void keyIndex_switchDirection(EditNurb *editnurb, Nurb *nu) index1= getCVKeyIndex(editnurb, bezt1); index2= getCVKeyIndex(editnurb, bezt2); - if(index1) index1->switched= !index1->switched; + if (index1) index1->switched= !index1->switched; if (bezt1 != bezt2) { keyIndex_swap(editnurb, bezt1, bezt2); - if(index2) index2->switched= !index2->switched; + if (index2) index2->switched= !index2->switched; } bezt1++; bezt2--; } - } else { + } + else { BPoint *bp1, *bp2; if (nu->pntsv == 1) { @@ -544,14 +548,14 @@ static void keyIndex_switchDirection(EditNurb *editnurb, Nurb *nu) bp1= nu->bp; bp2= bp1+(a-1); a/= 2; - while(bp1!=bp2 && a>0) { + while (bp1!=bp2 && a>0) { index1= getCVKeyIndex(editnurb, bp1); index2= getCVKeyIndex(editnurb, bp2); - if(index1) index1->switched= !index1->switched; + if (index1) index1->switched= !index1->switched; if (bp1 != bp2) { - if(index2) index2->switched= !index2->switched; + if (index2) index2->switched= !index2->switched; keyIndex_swap(editnurb, bp1, bp2); } @@ -560,24 +564,25 @@ static void keyIndex_switchDirection(EditNurb *editnurb, Nurb *nu) bp1++; bp2--; } - } else { + } + else { int b; - for(b=0; bpntsv; b++) { + for (b=0; bpntsv; b++) { bp1= nu->bp+b*nu->pntsu; a= nu->pntsu; bp2= bp1+(a-1); a/= 2; - while(bp1!=bp2 && a>0) { + while (bp1!=bp2 && a>0) { index1= getCVKeyIndex(editnurb, bp1); index2= getCVKeyIndex(editnurb, bp2); - if(index1) index1->switched= !index1->switched; + if (index1) index1->switched= !index1->switched; if (bp1 != bp2) { - if(index2) index2->switched= !index2->switched; + if (index2) index2->switched= !index2->switched; keyIndex_swap(editnurb, bp1, bp2); } @@ -602,7 +607,7 @@ static void switch_keys_direction(Curve *cu, Nurb *actnu) int a; currkey = cu->key->block.first; - while(currkey) { + while (currkey) { fp= currkey->data; nu= nubase->first; @@ -612,26 +617,29 @@ static void switch_keys_direction(Curve *cu, Nurb *actnu) a= nu->pntsu; if (nu == actnu) { while (a--) { - if(getKeyIndexOrig_bezt(editnurb, bezt)) { + if (getKeyIndexOrig_bezt(editnurb, bezt)) { swap_v3_v3(fp, fp + 6); *(fp+9) = -*(fp+9); fp += 12; } bezt++; } - } else fp += a * 12; - } else { + } + else fp += a * 12; + } + else { BPoint *bp= nu->bp; a= nu->pntsu * nu->pntsv; if (nu == actnu) { while (a--) { - if(getKeyIndexOrig_bp(editnurb, bp)) { + if (getKeyIndexOrig_bp(editnurb, bp)) { *(fp+3) = -*(fp+3); fp += 4; } bp++; } - } else fp += a * 4; + } + else fp += a * 4; } nu= nu->next; @@ -651,7 +659,7 @@ static void keyData_switchDirectionNurb(Curve *cu, Nurb *nu) } keyIndex_switchDirection(editnurb, nu); - if(cu->key) + if (cu->key) switch_keys_direction(cu, nu); } @@ -662,7 +670,7 @@ static GHash *dupli_keyIndexHash(GHash *keyindex) gh= BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, "dupli_keyIndex gh"); - for(hashIter = BLI_ghashIterator_new(keyindex); + for (hashIter = BLI_ghashIterator_new(keyindex); !BLI_ghashIterator_isDone(hashIter); BLI_ghashIterator_step(hashIter)) { void *cv = BLI_ghashIterator_getKey(hashIter); @@ -710,10 +718,11 @@ static void calc_keyHandles(ListBase *nurb, float *key) a= nu->pntsu; startfp= fp; - if(nu->flagu & CU_NURB_CYCLIC) { + if (nu->flagu & CU_NURB_CYCLIC) { prevp= bezt+(a-1); prevfp= fp+(12 * (a-1)); - } else { + } + else { prevp= NULL; prevfp= NULL; } @@ -732,11 +741,12 @@ static void calc_keyHandles(ListBase *nurb, float *key) prevp= bezt; prevfp= fp; - if(a==1) { - if(nu->flagu & CU_NURB_CYCLIC) { + if (a==1) { + if (nu->flagu & CU_NURB_CYCLIC) { nextp= nu->bezt; nextfp= startfp; - } else { + } + else { nextp= NULL; nextfp= NULL; } @@ -749,7 +759,8 @@ static void calc_keyHandles(ListBase *nurb, float *key) ++bezt; fp += 12; } - } else { + } + else { a= nu->pntsu * nu->pntsv; fp += a * 4; } @@ -763,7 +774,7 @@ static void calc_shapeKeys(Object *obedit) Curve *cu= (Curve*)obedit->data; /* are there keys? */ - if(cu->key) { + if (cu->key) { int a, i; EditNurb *editnurb= cu->editnurb; KeyBlock *currkey; @@ -777,26 +788,27 @@ static void calc_shapeKeys(Object *obedit) float *oldkey, *newkey, *ofp; /* editing the base key should update others */ - if(cu->key->type==KEY_RELATIVE) { + if (cu->key->type==KEY_RELATIVE) { int act_is_basis = 0; /* find if this key is a basis for any others */ - for(currkey = cu->key->block.first; currkey; currkey= currkey->next) { - if(editnurb->shapenr-1 == currkey->relative) { + for (currkey = cu->key->block.first; currkey; currkey= currkey->next) { + if (editnurb->shapenr-1 == currkey->relative) { act_is_basis = 1; break; } } - if(act_is_basis) { /* active key is a base */ + if (act_is_basis) { /* active key is a base */ int totvec= 0; /* Calculate needed memory to store offset */ nu= editnurb->nurbs.first; - while(nu) { + while (nu) { if (nu->bezt) { /* Three vects to store handles and one for alfa */ totvec+= nu->pntsu * 4; - } else { + } + else { totvec+= 2 * nu->pntsu * nu->pntsv; } @@ -806,11 +818,11 @@ static void calc_shapeKeys(Object *obedit) ofs= MEM_callocN(sizeof(float) * 3 * totvec, "currkey->data"); nu= editnurb->nurbs.first; i= 0; - while(nu) { - if(nu->bezt) { + while (nu) { + if (nu->bezt) { bezt= nu->bezt; a= nu->pntsu; - while(a--) { + while (a--) { oldbezt= getKeyIndexOrig_bezt(editnurb, bezt); if (oldbezt) { @@ -820,7 +832,8 @@ static void calc_shapeKeys(Object *obedit) i++; } ofs[i++][0]= bezt->alfa - oldbezt->alfa; - } else { + } + else { i += 4; } bezt++; @@ -829,7 +842,7 @@ static void calc_shapeKeys(Object *obedit) else { bp= nu->bp; a= nu->pntsu*nu->pntsv; - while(a--) { + while (a--) { oldbp= getKeyIndexOrig_bp(editnurb, bp); if (oldbp) { sub_v3_v3v3(ofs[i], bp->vec, oldbp->vec); @@ -846,7 +859,7 @@ static void calc_shapeKeys(Object *obedit) } currkey = cu->key->block.first; - while(currkey) { + while (currkey) { int apply_offset = (ofs && (currkey != actkey) && (editnurb->shapenr-1 == currkey->relative)); float *fp= newkey= MEM_callocN(cu->key->elemsize * totvert, "currkey->data"); @@ -854,14 +867,14 @@ static void calc_shapeKeys(Object *obedit) nu= editnurb->nurbs.first; i = 0; - while(nu) { - if(currkey == actkey) { + while (nu) { + if (currkey == actkey) { int restore= actkey != cu->key->refkey; - if(nu->bezt) { + if (nu->bezt) { bezt= nu->bezt; a= nu->pntsu; - while(a--) { + while (a--) { int j; oldbezt= getKeyIndexOrig_bezt(editnurb, bezt); @@ -876,7 +889,7 @@ static void calc_shapeKeys(Object *obedit) } fp[0]= bezt->alfa; - if(restore && oldbezt) { + if (restore && oldbezt) { bezt->alfa= oldbezt->alfa; } @@ -887,14 +900,14 @@ static void calc_shapeKeys(Object *obedit) else { bp= nu->bp; a= nu->pntsu*nu->pntsv; - while(a--) { + while (a--) { oldbp= getKeyIndexOrig_bp(editnurb, bp); copy_v3_v3(fp, bp->vec); fp[3]= bp->alfa; - if(restore && oldbp) { + if (restore && oldbp) { copy_v3_v3(bp->vec, oldbp->vec); bp->alfa= oldbp->alfa; } @@ -909,12 +922,12 @@ static void calc_shapeKeys(Object *obedit) int index; float *curofp; - if(oldkey) { - if(nu->bezt) { + if (oldkey) { + if (nu->bezt) { bezt= nu->bezt; a= nu->pntsu; - while(a--) { + while (a--) { index= getKeyIndexOrig_keyIndex(editnurb, bezt); if (index >= 0) { int j; @@ -923,7 +936,7 @@ static void calc_shapeKeys(Object *obedit) for (j= 0; j < 3; ++j, ++i) { copy_v3_v3(fp, curofp); - if(apply_offset) { + if (apply_offset) { add_v3_v3(fp, ofs[i]); } @@ -931,14 +944,15 @@ static void calc_shapeKeys(Object *obedit) } fp[0]= curofp[0]; - if(apply_offset) { + if (apply_offset) { /* apply alfa offsets */ add_v3_v3(fp, ofs[i]); ++i; } fp+= 3; /* alphas */ - } else { + } + else { int j; for (j= 0; j < 3; ++j, ++i) { copy_v3_v3(fp, bezt->vec[j]); @@ -954,7 +968,7 @@ static void calc_shapeKeys(Object *obedit) else { bp= nu->bp; a= nu->pntsu*nu->pntsv; - while(a--) { + while (a--) { index= getKeyIndexOrig_keyIndex(editnurb, bp); if (index >= 0) { @@ -962,11 +976,12 @@ static void calc_shapeKeys(Object *obedit) copy_v3_v3(fp, curofp); fp[3]= curofp[3]; - if(apply_offset) { + if (apply_offset) { add_v3_v3(fp, ofs[i]); fp[3]+=ofs[i+1][0]; } - } else { + } + else { copy_v3_v3(fp, bp->vec); fp[3]= bp->alfa; } @@ -988,13 +1003,13 @@ static void calc_shapeKeys(Object *obedit) } currkey->totelem= totvert; - if(currkey->data) MEM_freeN(currkey->data); + if (currkey->data) MEM_freeN(currkey->data); currkey->data = newkey; currkey= currkey->next; } - if(ofs) MEM_freeN(ofs); + if (ofs) MEM_freeN(ofs); } } @@ -1016,7 +1031,7 @@ static void fcurve_path_rename(AnimData *ad, char *orig_rna_path, char *rna_path fcu= orig_curves->first; while (fcu) { nextfcu= fcu->next; - if(!strncmp(fcu->rna_path, orig_rna_path, len)) { + if (!strncmp(fcu->rna_path, orig_rna_path, len)) { char *spath, *suffix= fcu->rna_path + len; nfcu= copy_fcurve(fcu); spath= nfcu->rna_path; @@ -1042,7 +1057,7 @@ static void fcurve_path_rename(AnimData *ad, char *orig_rna_path, char *rna_path static void fcurve_remove(AnimData *ad, ListBase *orig_curves, FCurve *fcu) { - if(orig_curves==&ad->drivers) BLI_remlink(&ad->drivers, fcu); + if (orig_curves==&ad->drivers) BLI_remlink(&ad->drivers, fcu); else action_groups_remove_channel(ad->action, fcu); free_fcurve(fcu); @@ -1060,19 +1075,19 @@ static void curve_rename_fcurves(Object *obedit, ListBase *orig_curves) ListBase curves= {NULL, NULL}; FCurve *fcu, *next; - while(nu) { - if(nu->bezt) { + while (nu) { + if (nu->bezt) { BezTriple *bezt= nu->bezt; a= nu->pntsu; pt_index= 0; while (a--) { keyIndex= getCVKeyIndex(editnurb, bezt); - if(keyIndex) { + if (keyIndex) { BLI_snprintf(rna_path, sizeof(rna_path), "splines[%d].bezier_points[%d]", nu_index, pt_index); BLI_snprintf(orig_rna_path, sizeof(orig_rna_path), "splines[%d].bezier_points[%d]", keyIndex->nu_index, keyIndex->pt_index); - if(keyIndex->switched) { + if (keyIndex->switched) { char handle_path[64], orig_handle_path[64]; BLI_snprintf(orig_handle_path, sizeof(orig_rna_path), "%s.handle_left", orig_rna_path); BLI_snprintf(handle_path, sizeof(rna_path), "%s.handle_right", rna_path); @@ -1092,14 +1107,15 @@ static void curve_rename_fcurves(Object *obedit, ListBase *orig_curves) bezt++; pt_index++; } - } else { + } + else { BPoint *bp= nu->bp; a= nu->pntsu * nu->pntsv; pt_index= 0; while (a--) { keyIndex= getCVKeyIndex(editnurb, bp); - if(keyIndex) { + if (keyIndex) { BLI_snprintf(rna_path, sizeof(rna_path), "splines[%d].points[%d]", nu_index, pt_index); BLI_snprintf(orig_rna_path, sizeof(orig_rna_path), "splines[%d].points[%d]", keyIndex->nu_index, keyIndex->pt_index); fcurve_path_rename(ad, orig_rna_path, rna_path, orig_curves, &curves); @@ -1119,10 +1135,10 @@ static void curve_rename_fcurves(Object *obedit, ListBase *orig_curves) /* remove paths for removed control points * need this to make further step with copying non-cv related curves copying * not touching cv's f-curves */ - for(fcu= orig_curves->first; fcu; fcu= next) { + for (fcu= orig_curves->first; fcu; fcu= next) { next= fcu->next; - if(!strncmp(fcu->rna_path, "splines", 7)) { + if (!strncmp(fcu->rna_path, "splines", 7)) { char *ch= strchr(fcu->rna_path, '.'); if (ch && (!strncmp(ch, ".bezier_points", 14) || !strncmp(ch, ".points", 7))) @@ -1132,14 +1148,14 @@ static void curve_rename_fcurves(Object *obedit, ListBase *orig_curves) nu_index= 0; nu= editnurb->nurbs.first; - while(nu) { + while (nu) { keyIndex= NULL; - if(nu->pntsu) { - if(nu->bezt) keyIndex= getCVKeyIndex(editnurb, &nu->bezt[0]); + if (nu->pntsu) { + if (nu->bezt) keyIndex= getCVKeyIndex(editnurb, &nu->bezt[0]); else keyIndex= getCVKeyIndex(editnurb, &nu->bp[0]); } - if(keyIndex) { + if (keyIndex) { BLI_snprintf(rna_path, sizeof(rna_path), "splines[%d]", nu_index); BLI_snprintf(orig_rna_path, sizeof(orig_rna_path), "splines[%d]", keyIndex->nu_index); fcurve_path_rename(ad, orig_rna_path, rna_path, orig_curves, &curves); @@ -1151,10 +1167,10 @@ static void curve_rename_fcurves(Object *obedit, ListBase *orig_curves) /* the remainders in orig_curves can be copied back (like follow path) */ /* (if it's not path to spline) */ - for(fcu= orig_curves->first; fcu; fcu= next) { + for (fcu= orig_curves->first; fcu; fcu= next) { next= fcu->next; - if(!strncmp(fcu->rna_path, "splines", 7)) fcurve_remove(ad, orig_curves, fcu); + if (!strncmp(fcu->rna_path, "splines", 7)) fcurve_remove(ad, orig_curves, fcu); else BLI_addtail(&curves, fcu); } @@ -1167,9 +1183,9 @@ int ED_curve_updateAnimPaths(Object *obedit) Curve *cu= (Curve*)obedit->data; AnimData *ad= BKE_animdata_from_id(&cu->id); - if(!curve_is_animated(obedit)) return 0; + if (!curve_is_animated(obedit)) return 0; - if(ad->action) + if (ad->action) curve_rename_fcurves(obedit, &ad->action->curves); curve_rename_fcurves(obedit, &ad->drivers); @@ -1184,7 +1200,7 @@ void load_editNurb(Object *obedit) { ListBase *editnurb= object_editcurve_get(obedit); - if(obedit==NULL) return; + if (obedit==NULL) return; set_actNurb(obedit, NULL); @@ -1193,11 +1209,11 @@ void load_editNurb(Object *obedit) Nurb *nu, *newnu; ListBase newnurb= {NULL, NULL}, oldnurb= cu->nurb; - for(nu= editnurb->first; nu; nu= nu->next) { + for (nu= editnurb->first; nu; nu= nu->next) { newnu= duplicateNurb(nu); BLI_addtail(&newnurb, newnu); - if(nu->type == CU_NURBS) { + if (nu->type == CU_NURBS) { clamp_nurb_order_u(nu); } } @@ -1227,17 +1243,18 @@ void make_editNurb(Object *obedit) if (ELEM(obedit->type, OB_CURVE, OB_SURF)) { actkey= ob_get_keyblock(obedit); - if(actkey) { + if (actkey) { // XXX strcpy(G.editModeTitleExtra, "(Key) "); undo_editmode_clear(); key_to_curve(actkey, cu, &cu->nurb); } - if(editnurb) { + if (editnurb) { freeNurblist(&editnurb->nurbs); free_curve_editNurb_keyIndex(editnurb); editnurb->keyindex= NULL; - } else { + } + else { editnurb= MEM_callocN(sizeof(EditNurb), "editnurb"); cu->editnurb= editnurb; } @@ -1245,7 +1262,7 @@ void make_editNurb(Object *obedit) nu= cu->nurb.first; cu->lastsel= NULL; /* for select row */ - while(nu) { + while (nu) { newnu= duplicateNurb(nu); test2DNurb(newnu); // after join, or any other creation of curve BLI_addtail(&editnurb->nurbs, newnu); @@ -1258,7 +1275,7 @@ void make_editNurb(Object *obedit) nu= nu->next; } - if(actkey) + if (actkey) editnurb->shapenr= obedit->shapenr; /* animation could be added in editmode even if there was no animdata i @@ -1307,14 +1324,14 @@ void CU_select_swap(Object *obedit) cu->lastsel= NULL; - for(nu= editnurb->first; nu; nu= nu->next) { - if(nu->type == CU_BEZIER) { + for (nu= editnurb->first; nu; nu= nu->next) { + if (nu->type == CU_BEZIER) { bezt= nu->bezt; a= nu->pntsu; - while(a--) { - if(bezt->hide==0) { + while (a--) { + if (bezt->hide==0) { bezt->f2 ^= SELECT; /* always do the center point */ - if((cu->drawflag & CU_HIDE_HANDLES)==0) { + if ((cu->drawflag & CU_HIDE_HANDLES)==0) { bezt->f1 ^= SELECT; bezt->f3 ^= SELECT; } @@ -1325,7 +1342,7 @@ void CU_select_swap(Object *obedit) else { bp= nu->bp; a= nu->pntsu*nu->pntsv; - while(a--) { + while (a--) { swap_selection_bpoint(bp); bp++; } @@ -1351,7 +1368,7 @@ static int separate_exec(bContext *C, wmOperator *op) oldcu= oldob->data; oldedit= oldcu->editnurb; - if(oldcu->key) { + if (oldcu->key) { BKE_report(op->reports, RPT_ERROR, "Can't separate a curve with vertex keys"); return OPERATOR_CANCELLED; } @@ -1374,10 +1391,10 @@ static int separate_exec(bContext *C, wmOperator *op) free_curve_editNurb_keyIndex(newedit); /* 3. move over parts from old object */ - for(nu= oldedit->nurbs.first; nu; nu=nu1) { + for (nu= oldedit->nurbs.first; nu; nu=nu1) { nu1= nu->next; - if(isNurbsel(nu)) { + if (isNurbsel(nu)) { BLI_remlink(&oldedit->nurbs, nu); BLI_addtail(&newedit->nurbs, nu); } @@ -1424,33 +1441,33 @@ static short isNurbselUV(Nurb *nu, int *u, int *v, int flag) *u= *v= -1; bp= nu->bp; - for(b=0; bpntsv; b++) { + for (b=0; bpntsv; b++) { sel= 0; - for(a=0; apntsu; a++, bp++) { - if(bp->f1 & flag) sel++; + for (a=0; apntsu; a++, bp++) { + if (bp->f1 & flag) sel++; } - if(sel==nu->pntsu) { - if(*u== -1) *u= b; + if (sel==nu->pntsu) { + if (*u== -1) *u= b; else return 0; } - else if(sel>1) return 0; /* because sel==1 is still ok */ + else if (sel>1) return 0; /* because sel==1 is still ok */ } - for(a=0; apntsu; a++) { + for (a=0; apntsu; a++) { sel= 0; bp= nu->bp+a; - for(b=0; bpntsv; b++, bp+=nu->pntsu) { - if(bp->f1 & flag) sel++; + for (b=0; bpntsv; b++, bp+=nu->pntsu) { + if (bp->f1 & flag) sel++; } - if(sel==nu->pntsv) { - if(*v== -1) *v= a; + if (sel==nu->pntsv) { + if (*v== -1) *v= a; else return 0; } - else if(sel>1) return 0; + else if (sel>1) return 0; } - if(*u==-1 && *v>-1) return 1; - if(*v==-1 && *u>-1) return 1; + if (*u==-1 && *v>-1) return 1; + if (*v==-1 && *u>-1) return 1; return 0; } @@ -1461,11 +1478,11 @@ static void setflagsNurb(ListBase *editnurb, short flag) BPoint *bp; int a; - for(nu= editnurb->first; nu; nu= nu->next) { - if(nu->type == CU_BEZIER) { + for (nu= editnurb->first; nu; nu= nu->next) { + if (nu->type == CU_BEZIER) { a= nu->pntsu; bezt= nu->bezt; - while(a--) { + while (a--) { bezt->f1= bezt->f2= bezt->f3= flag; bezt++; } @@ -1473,7 +1490,7 @@ static void setflagsNurb(ListBase *editnurb, short flag) else { a= nu->pntsu*nu->pntsv; bp= nu->bp; - while(a--) { + while (a--) { bp->f1= flag; bp++; } @@ -1488,13 +1505,13 @@ static void rotateflagNurb(ListBase *editnurb, short flag, float *cent, float ro BPoint *bp; int a; - for(nu= editnurb->first; nu; nu= nu->next) { - if(nu->type == CU_NURBS) { + for (nu= editnurb->first; nu; nu= nu->next) { + if (nu->type == CU_NURBS) { bp= nu->bp; a= nu->pntsu*nu->pntsv; - while(a--) { - if(bp->f1 & flag) { + while (a--) { + if (bp->f1 & flag) { sub_v3_v3(bp->vec, cent); mul_m3_v3(rotmat, bp->vec); add_v3_v3(bp->vec, cent); @@ -1513,22 +1530,22 @@ static void translateflagNurb(ListBase *editnurb, short flag, const float vec[3] BPoint *bp; int a; - for(nu= editnurb->first; nu; nu= nu->next) { - if(nu->type == CU_BEZIER) { + for (nu= editnurb->first; nu; nu= nu->next) { + if (nu->type == CU_BEZIER) { a= nu->pntsu; bezt= nu->bezt; - while(a--) { - if(bezt->f1 & flag) add_v3_v3(bezt->vec[0], vec); - if(bezt->f2 & flag) add_v3_v3(bezt->vec[1], vec); - if(bezt->f3 & flag) add_v3_v3(bezt->vec[2], vec); + while (a--) { + if (bezt->f1 & flag) add_v3_v3(bezt->vec[0], vec); + if (bezt->f2 & flag) add_v3_v3(bezt->vec[1], vec); + if (bezt->f3 & flag) add_v3_v3(bezt->vec[2], vec); bezt++; } } else { a= nu->pntsu*nu->pntsv; bp= nu->bp; - while(a--) { - if(bp->f1 & flag) add_v3_v3(bp->vec, vec); + while (a--) { + if (bp->f1 & flag) add_v3_v3(bp->vec, vec); bp++; } } @@ -1543,12 +1560,12 @@ static void weightflagNurb(ListBase *editnurb, short flag, float w) BPoint *bp; int a; - for(nu= editnurb->first; nu; nu= nu->next) { - if(nu->type == CU_NURBS) { + for (nu= editnurb->first; nu; nu= nu->next) { + if (nu->type == CU_NURBS) { a= nu->pntsu*nu->pntsv; bp= nu->bp; - while(a--) { - if(bp->f1 & flag) { + while (a--) { + if (bp->f1 & flag) { /* a mode used to exist for replace/multiple but is was unused */ bp->vec[3]*= w; } @@ -1567,25 +1584,25 @@ static int deleteflagNurb(bContext *C, wmOperator *UNUSED(op), int flag) BPoint *bp, *bpn, *newbp; int a, b, newu, newv, sel; - if(obedit->type==OB_SURF); + if (obedit->type==OB_SURF); else return OPERATOR_CANCELLED; cu->lastsel= NULL; nu= editnurb->first; - while(nu) { + while (nu) { next= nu->next; /* is entire nurb selected */ bp= nu->bp; a= nu->pntsu*nu->pntsv; - while(a) { + while (a) { a--; - if(bp->f1 & flag); + if (bp->f1 & flag); else break; bp++; } - if(a==0) { + if (a==0) { BLI_remlink(editnurb, nu); keyIndex_delNurb(cu->editnurb, nu); freeNurb(nu); nu=NULL; @@ -1594,30 +1611,31 @@ static int deleteflagNurb(bContext *C, wmOperator *UNUSED(op), int flag) /* is nurb in U direction selected */ newv= nu->pntsv; bp= nu->bp; - for(b=0; bpntsv; b++) { + for (b=0; bpntsv; b++) { sel= 0; - for(a=0; apntsu; a++, bp++) { - if(bp->f1 & flag) sel++; + for (a=0; apntsu; a++, bp++) { + if (bp->f1 & flag) sel++; } - if(sel==nu->pntsu) { + if (sel==nu->pntsu) { newv--; } - else if(sel>=1) { + else if (sel>=1) { /* don't delete */ break; } } - if(newv!=nu->pntsv && b==nu->pntsv) { + if (newv!=nu->pntsv && b==nu->pntsv) { /* delete */ bp= nu->bp; bpn = newbp = (BPoint*) MEM_mallocN(newv * nu->pntsu * sizeof(BPoint), "deleteNurb"); - for(b=0; bpntsv; b++) { - if((bp->f1 & flag)==0) { + for (b=0; bpntsv; b++) { + if ((bp->f1 & flag)==0) { memcpy(bpn, bp, nu->pntsu*sizeof(BPoint)); keyIndex_updateBP(cu->editnurb, bp, bpn, nu->pntsu); bpn+= nu->pntsu; - } else { + } + else { keyIndex_delBP(cu->editnurb, bp); } bp+= nu->pntsu; @@ -1632,44 +1650,45 @@ static int deleteflagNurb(bContext *C, wmOperator *UNUSED(op), int flag) else { /* is the nurb in V direction selected */ newu= nu->pntsu; - for(a=0; apntsu; a++) { + for (a=0; apntsu; a++) { bp= nu->bp+a; sel= 0; - for(b=0; bpntsv; b++, bp+=nu->pntsu) { - if(bp->f1 & flag) sel++; + for (b=0; bpntsv; b++, bp+=nu->pntsu) { + if (bp->f1 & flag) sel++; } - if(sel==nu->pntsv) { + if (sel==nu->pntsv) { newu--; } - else if(sel>=1) { + else if (sel>=1) { /* don't delete */ break; } } - if(newu!=nu->pntsu && a==nu->pntsu) { + if (newu!=nu->pntsu && a==nu->pntsu) { /* delete */ bp= nu->bp; bpn = newbp = (BPoint*) MEM_mallocN(newu * nu->pntsv * sizeof(BPoint), "deleteNurb"); - for(b=0; bpntsv; b++) { - for(a=0; apntsu; a++, bp++) { - if((bp->f1 & flag)==0) { + for (b=0; bpntsv; b++) { + for (a=0; apntsu; a++, bp++) { + if ((bp->f1 & flag)==0) { *bpn= *bp; keyIndex_updateBP(cu->editnurb, bp, bpn, 1); bpn++; - } else { + } + else { keyIndex_delBP(cu->editnurb, bp); } } } MEM_freeN(nu->bp); nu->bp= newbp; - if(newu==1 && nu->pntsv>1) { /* make a U spline */ + if (newu==1 && nu->pntsv>1) { /* make a U spline */ nu->pntsu= nu->pntsv; nu->pntsv= 1; SWAP(short, nu->orderu, nu->orderv); clamp_nurb_order_u(nu); - if(nu->knotsv) MEM_freeN(nu->knotsv); + if (nu->knotsv) MEM_freeN(nu->knotsv); nu->knotsv= NULL; } else { @@ -1683,7 +1702,7 @@ static int deleteflagNurb(bContext *C, wmOperator *UNUSED(op), int flag) nu= next; } - if(ED_curve_updateAnimPaths(obedit)) + if (ED_curve_updateAnimPaths(obedit)) WM_event_add_notifier(C, NC_OBJECT|ND_KEYS, obedit); return OPERATOR_FINISHED; @@ -1697,18 +1716,18 @@ static short extrudeflagNurb(EditNurb *editnurb, int flag) int ok= 0, a, u, v, len; nu= editnurb->nurbs.first; - while(nu) { + while (nu) { - if(nu->pntsv==1) { + if (nu->pntsv==1) { bp= nu->bp; a= nu->pntsu; - while(a) { - if(bp->f1 & flag); + while (a) { + if (bp->f1 & flag); else break; bp++; a--; } - if(a==0) { + if (a==0) { ok= 1; newbp = (BPoint*)MEM_mallocN(2 * nu->pntsu * sizeof(BPoint), "extrudeNurb1"); @@ -1718,7 +1737,7 @@ static short extrudeflagNurb(EditNurb *editnurb, int flag) MEM_freeN(nu->bp); nu->bp= newbp; a= nu->pntsu; - while(a--) { + while (a--) { select_bpoint(bp, SELECT, flag, HIDDEN); select_bpoint(newbp, DESELECT, flag, HIDDEN); bp++; @@ -1733,22 +1752,22 @@ static short extrudeflagNurb(EditNurb *editnurb, int flag) else { /* which row or column is selected */ - if( isNurbselUV(nu, &u, &v, flag) ) { + if ( isNurbselUV(nu, &u, &v, flag) ) { /* deselect all */ bp= nu->bp; a= nu->pntsu*nu->pntsv; - while(a--) { + while (a--) { select_bpoint(bp, DESELECT, flag, HIDDEN); bp++; } - if(u==0 || u== nu->pntsv-1) { /* row in u-direction selected */ + if (u==0 || u== nu->pntsv-1) { /* row in u-direction selected */ ok= 1; newbp = (BPoint*) MEM_mallocN(nu->pntsu*(nu->pntsv + 1) * sizeof(BPoint), "extrudeNurb1"); - if(u==0) { + if (u==0) { len= nu->pntsv*nu->pntsu; ED_curve_bpcpy(editnurb, newbp+nu->pntsu, nu->bp, len); ED_curve_bpcpy(editnurb, newbp, nu->bp, nu->pntsu); @@ -1762,7 +1781,7 @@ static short extrudeflagNurb(EditNurb *editnurb, int flag) } a= nu->pntsu; - while(a--) { + while (a--) { select_bpoint(bp, SELECT, flag, HIDDEN); bp++; } @@ -1772,14 +1791,14 @@ static short extrudeflagNurb(EditNurb *editnurb, int flag) nu->pntsv++; nurbs_knot_calc_v(nu); } - else if(v==0 || v== nu->pntsu-1) { /* column in v-direction selected */ + else if (v==0 || v== nu->pntsu-1) { /* column in v-direction selected */ ok= 1; bpn = newbp = (BPoint*) MEM_mallocN((nu->pntsu + 1) * nu->pntsv * sizeof(BPoint), "extrudeNurb1"); bp= nu->bp; - for(a=0; apntsv; a++) { - if(v==0) { + for (a=0; apntsv; a++) { + if (v==0) { *bpn= *bp; bpn->f1 |= flag; bpn++; @@ -1787,7 +1806,7 @@ static short extrudeflagNurb(EditNurb *editnurb, int flag) ED_curve_bpcpy(editnurb, bpn, bp, nu->pntsu); bp+= nu->pntsu; bpn+= nu->pntsu; - if(v== nu->pntsu-1) { + if (v== nu->pntsu-1) { *bpn= *(bp-1); bpn->f1 |= flag; bpn++; @@ -1820,20 +1839,20 @@ static void adduplicateflagNurb(Object *obedit, short flag) cu->lastsel= NULL; nu= editnurb->last; - while(nu) { - if(nu->type == CU_BEZIER) { + while (nu) { + if (nu->type == CU_BEZIER) { bezt= nu->bezt; - for(a=0; apntsu; a++) { + for (a=0; apntsu; a++) { enda= -1; starta= a; - while( (bezt->f1 & flag) || (bezt->f2 & flag) || (bezt->f3 & flag) ) { + while ( (bezt->f1 & flag) || (bezt->f2 & flag) || (bezt->f3 & flag) ) { select_beztriple(bezt, DESELECT, flag, HIDDEN); enda=a; - if(a>=nu->pntsu-1) break; + if (a>=nu->pntsu-1) break; a++; bezt++; } - if(enda>=starta) { + if (enda>=starta) { newnu = (Nurb*)MEM_mallocN(sizeof(Nurb), "adduplicateN"); memcpy(newnu, nu, sizeof(Nurb)); BLI_addtail(editnurb, newnu); @@ -1845,13 +1864,13 @@ static void adduplicateflagNurb(Object *obedit, short flag) b= newnu->pntsu; bezt1= newnu->bezt; - while(b--) { + while (b--) { select_beztriple(bezt1, SELECT, flag, HIDDEN); bezt1++; } - if(nu->flagu & CU_NURB_CYCLIC) { - if(starta!=0 || enda!=nu->pntsu-1) { + if (nu->flagu & CU_NURB_CYCLIC) { + if (starta!=0 || enda!=nu->pntsu-1) { newnu->flagu &= ~CU_NURB_CYCLIC; } } @@ -1859,19 +1878,19 @@ static void adduplicateflagNurb(Object *obedit, short flag) bezt++; } } - else if(nu->pntsv==1) { /* because UV Nurb has a different method for dupli */ + else if (nu->pntsv==1) { /* because UV Nurb has a different method for dupli */ bp= nu->bp; - for(a=0; apntsu; a++) { + for (a=0; apntsu; a++) { enda= -1; starta= a; - while(bp->f1 & flag) { + while (bp->f1 & flag) { select_bpoint(bp, DESELECT, flag, HIDDEN); enda= a; - if(a>=nu->pntsu-1) break; + if (a>=nu->pntsu-1) break; a++; bp++; } - if(enda>=starta) { + if (enda>=starta) { newnu = (Nurb*)MEM_mallocN(sizeof(Nurb), "adduplicateN3"); memcpy(newnu, nu, sizeof(Nurb)); set_actNurb(obedit, newnu); @@ -1882,13 +1901,13 @@ static void adduplicateflagNurb(Object *obedit, short flag) b= newnu->pntsu; bp1= newnu->bp; - while(b--) { + while (b--) { select_bpoint(bp1, SELECT, flag, HIDDEN); bp1++; } - if(nu->flagu & CU_NURB_CYCLIC) { - if(starta!=0 || enda!=nu->pntsu-1) { + if (nu->flagu & CU_NURB_CYCLIC) { + if (starta!=0 || enda!=nu->pntsu-1) { newnu->flagu &= ~CU_NURB_CYCLIC; } } @@ -1902,19 +1921,19 @@ static void adduplicateflagNurb(Object *obedit, short flag) } else { /* a rectangular area in nurb has to be selected */ - if(isNurbsel(nu)) { + if (isNurbsel(nu)) { usel= MEM_callocN(nu->pntsu, "adduplicateN4"); bp= nu->bp; - for(a=0; apntsv; a++) { - for(b=0; bpntsu; b++, bp++) { - if(bp->f1 & flag) usel[b]++; + for (a=0; apntsv; a++) { + for (b=0; bpntsu; b++, bp++) { + if (bp->f1 & flag) usel[b]++; } } newu= 0; newv= 0; - for(a=0; apntsu; a++) { - if(usel[a]) { - if(newv==0 || usel[a]==newv) { + for (a=0; apntsu; a++) { + if (usel[a]) { + if (newv==0 || usel[a]==newv) { newv= usel[a]; newu++; } @@ -1924,13 +1943,13 @@ static void adduplicateflagNurb(Object *obedit, short flag) } } } - if(newu==0 || newv==0) { + if (newu==0 || newv==0) { if (G.f & G_DEBUG) printf("Can't duplicate Nurb\n"); } else { - if(newu==1) SWAP(short, newu, newv); + if (newu==1) SWAP(short, newu, newv); newnu = (Nurb*)MEM_mallocN(sizeof(Nurb), "adduplicateN5"); memcpy(newnu, nu, sizeof(Nurb)); @@ -1947,9 +1966,9 @@ static void adduplicateflagNurb(Object *obedit, short flag) bp= newnu->bp; bp1= nu->bp; - for(a=0; apntsv; a++) { - for(b=0; bpntsu; b++, bp1++) { - if(bp1->f1 & flag) { + for (a=0; apntsv; a++) { + for (b=0; bpntsu; b++, bp1++) { + if (bp1->f1 & flag) { memcpy(bp, bp1, sizeof(BPoint)); select_bpoint(bp1, DESELECT, flag, HIDDEN); bp++; @@ -1957,16 +1976,18 @@ static void adduplicateflagNurb(Object *obedit, short flag) } } if (check_valid_nurb_u(newnu)) { - if(nu->pntsu==newnu->pntsu && nu->knotsu) { + if (nu->pntsu==newnu->pntsu && nu->knotsu) { newnu->knotsu= MEM_dupallocN( nu->knotsu ); - } else { + } + else { nurbs_knot_calc_u(newnu); } } if (check_valid_nurb_v(newnu)) { - if(nu->pntsv==newnu->pntsv && nu->knotsv) { + if (nu->pntsv==newnu->pntsv && nu->knotsv) { newnu->knotsv= MEM_dupallocN( nu->knotsv ); - } else { + } + else { nurbs_knot_calc_v(newnu); } } @@ -1990,13 +2011,13 @@ static int switch_direction_exec(bContext *C, wmOperator *UNUSED(op)) EditNurb *editnurb= cu->editnurb; Nurb *nu; - for(nu= editnurb->nurbs.first; nu; nu= nu->next) - if(isNurbsel(nu)) { + for (nu= editnurb->nurbs.first; nu; nu= nu->next) + if (isNurbsel(nu)) { switchdirectionNurb(nu); keyData_switchDirectionNurb(cu, nu); } - if(ED_curve_updateAnimPaths(obedit)) + if (ED_curve_updateAnimPaths(obedit)) WM_event_add_notifier(C, NC_OBJECT|ND_KEYS, obedit); DAG_id_tag_update(obedit->data, 0); @@ -2032,16 +2053,16 @@ static int set_goal_weight_exec(bContext *C, wmOperator *op) float weight= RNA_float_get(op->ptr, "weight"); int a; - for(nu= editnurb->first; nu; nu= nu->next) { - if(nu->bezt) { - for(bezt=nu->bezt, a=0; apntsu; a++, bezt++) { - if(bezt->f2 & SELECT) + for (nu= editnurb->first; nu; nu= nu->next) { + if (nu->bezt) { + for (bezt=nu->bezt, a=0; apntsu; a++, bezt++) { + if (bezt->f2 & SELECT) bezt->weight= weight; } } - else if(nu->bp) { - for(bp=nu->bp, a=0; apntsu*nu->pntsv; a++, bp++) { - if(bp->f1 & SELECT) + else if (nu->bp) { + for (bp=nu->bp, a=0; apntsu*nu->pntsv; a++, bp++) { + if (bp->f1 & SELECT) bp->weight= weight; } } @@ -2084,16 +2105,16 @@ static int set_radius_exec(bContext *C, wmOperator *op) float radius= RNA_float_get(op->ptr, "radius"); int a; - for(nu= editnurb->first; nu; nu= nu->next) { - if(nu->bezt) { - for(bezt=nu->bezt, a=0; apntsu; a++, bezt++) { - if(bezt->f2 & SELECT) + for (nu= editnurb->first; nu; nu= nu->next) { + if (nu->bezt) { + for (bezt=nu->bezt, a=0; apntsu; a++, bezt++) { + if (bezt->f2 & SELECT) bezt->radius= radius; } } - else if(nu->bp) { - for(bp=nu->bp, a=0; apntsu*nu->pntsv; a++, bp++) { - if(bp->f1 & SELECT) + else if (nu->bp) { + for (bp=nu->bp, a=0; apntsu*nu->pntsv; a++, bp++) { + if (bp->f1 & SELECT) bp->radius= radius; } } @@ -2136,13 +2157,13 @@ static int smooth_exec(bContext *C, wmOperator *UNUSED(op)) float val, newval, offset; int a, i, change = 0; - for(nu= editnurb->first; nu; nu= nu->next) { - if(nu->bezt) { + for (nu= editnurb->first; nu; nu= nu->next) { + if (nu->bezt) { change = 0; beztOrig = MEM_dupallocN( nu->bezt ); - for(bezt=nu->bezt+1, a=1; apntsu-1; a++, bezt++) { - if(bezt->f2 & SELECT) { - for(i=0; i<3; i++) { + for (bezt=nu->bezt+1, a=1; apntsu-1; a++, bezt++) { + if (bezt->f2 & SELECT) { + for (i=0; i<3; i++) { val = bezt->vec[1][i]; newval = ((beztOrig+(a-1))->vec[1][i] * 0.5f) + ((beztOrig+(a+1))->vec[1][i] * 0.5f); offset = (val*((1.0f/6.0f)*5.0f)) + (newval*(1.0f/6.0f)) - val; @@ -2157,12 +2178,13 @@ static int smooth_exec(bContext *C, wmOperator *UNUSED(op)) MEM_freeN(beztOrig); if (change) calchandlesNurb(nu); - } else if (nu->bp) { + } + else if (nu->bp) { bpOrig = MEM_dupallocN( nu->bp ); /* Same as above, keep these the same! */ - for(bp=nu->bp+1, a=1; apntsu-1; a++, bp++) { - if(bp->f1 & SELECT) { - for(i=0; i<3; i++) { + for (bp=nu->bp+1, a=1; apntsu-1; a++, bp++) { + if (bp->f1 & SELECT) { + for (i=0; i<3; i++) { val = bp->vec[i]; newval = ((bpOrig+(a-1))->vec[i] * 0.5f) + ((bpOrig+(a+1))->vec[i] * 0.5f); offset = (val*((1.0f/6.0f)*5.0f)) + (newval*(1.0f/6.0f)) - val; @@ -2213,24 +2235,24 @@ static int smooth_radius_exec(bContext *C, wmOperator *UNUSED(op)) int start_sel, end_sel; /* selection indices, inclusive */ float start_rad, end_rad, fac, range; - for(nu= editnurb->first; nu; nu= nu->next) { - if(nu->bezt) { + for (nu= editnurb->first; nu; nu= nu->next) { + if (nu->bezt) { for (last_sel=0; last_sel < nu->pntsu; last_sel++) { /* loop over selection segments of a curve, smooth each */ /* Start BezTriple code, this is duplicated below for points, make sure these functions stay in sync */ start_sel = -1; - for(bezt=nu->bezt+last_sel, a=last_sel; apntsu; a++, bezt++) { - if(bezt->f2 & SELECT) { + for (bezt=nu->bezt+last_sel, a=last_sel; apntsu; a++, bezt++) { + if (bezt->f2 & SELECT) { start_sel = a; break; } } /* in case there are no other selected verts */ end_sel = start_sel; - for(bezt=nu->bezt+(start_sel+1), a=start_sel+1; apntsu; a++, bezt++) { - if((bezt->f2 & SELECT)==0) { + for (bezt=nu->bezt+(start_sel+1), a=start_sel+1; apntsu; a++, bezt++) { + if ((bezt->f2 & SELECT)==0) { break; } end_sel = a; @@ -2238,7 +2260,8 @@ static int smooth_radius_exec(bContext *C, wmOperator *UNUSED(op)) if (start_sel == -1) { last_sel = nu->pntsu; /* next... */ - } else { + } + else { last_sel = end_sel; /* before we modify it */ /* now blend between start and end sel */ @@ -2252,47 +2275,51 @@ static int smooth_radius_exec(bContext *C, wmOperator *UNUSED(op)) if (start_rad >= 0.0f && end_rad >= 0.0f) (nu->bezt+start_sel)->radius = (start_rad + end_rad)/2; else if (start_rad >= 0.0f) (nu->bezt+start_sel)->radius = start_rad; else if (end_rad >= 0.0f) (nu->bezt+start_sel)->radius = end_rad; - } else { + } + else { /* if endpoints selected, then use them */ if (start_sel==0) { start_rad = (nu->bezt+start_sel)->radius; start_sel++; /* we don't want to edit the selected endpoint */ - } else { + } + else { start_rad = (nu->bezt+start_sel-1)->radius; } if (end_sel==nu->pntsu-1) { end_rad = (nu->bezt+end_sel)->radius; end_sel--; /* we don't want to edit the selected endpoint */ - } else { + } + else { end_rad = (nu->bezt+end_sel+1)->radius; } /* Now Blend between the points */ range = (float)(end_sel - start_sel) + 2.0f; - for(bezt=nu->bezt+start_sel, a=start_sel; a<=end_sel; a++, bezt++) { + for (bezt=nu->bezt+start_sel, a=start_sel; a<=end_sel; a++, bezt++) { fac = (float)(1+a-start_sel) / range; bezt->radius = start_rad*(1.0f-fac) + end_rad*fac; } } } } - } else if (nu->bp) { + } + else if (nu->bp) { /* Same as above, keep these the same! */ for (last_sel=0; last_sel < nu->pntsu; last_sel++) { /* loop over selection segments of a curve, smooth each */ /* Start BezTriple code, this is duplicated below for points, make sure these functions stay in sync */ start_sel = -1; - for(bp=nu->bp+last_sel, a=last_sel; apntsu; a++, bp++) { - if(bp->f1 & SELECT) { + for (bp=nu->bp+last_sel, a=last_sel; apntsu; a++, bp++) { + if (bp->f1 & SELECT) { start_sel = a; break; } } /* in case there are no other selected verts */ end_sel = start_sel; - for(bp=nu->bp+(start_sel+1), a=start_sel+1; apntsu; a++, bp++) { - if((bp->f1 & SELECT)==0) { + for (bp=nu->bp+(start_sel+1), a=start_sel+1; apntsu; a++, bp++) { + if ((bp->f1 & SELECT)==0) { break; } end_sel = a; @@ -2300,7 +2327,8 @@ static int smooth_radius_exec(bContext *C, wmOperator *UNUSED(op)) if (start_sel == -1) { last_sel = nu->pntsu; /* next... */ - } else { + } + else { last_sel = end_sel; /* before we modify it */ /* now blend between start and end sel */ @@ -2314,24 +2342,27 @@ static int smooth_radius_exec(bContext *C, wmOperator *UNUSED(op)) if (start_rad >= 0.0f && end_rad >= 0.0f) (nu->bp+start_sel)->radius = (start_rad + end_rad)/2; else if (start_rad >= 0.0f) (nu->bp+start_sel)->radius = start_rad; else if (end_rad >= 0.0f) (nu->bp+start_sel)->radius = end_rad; - } else { + } + else { /* if endpoints selected, then use them */ if (start_sel==0) { start_rad = (nu->bp+start_sel)->radius; start_sel++; /* we don't want to edit the selected endpoint */ - } else { + } + else { start_rad = (nu->bp+start_sel-1)->radius; } if (end_sel==nu->pntsu-1) { end_rad = (nu->bp+end_sel)->radius; end_sel--; /* we don't want to edit the selected endpoint */ - } else { + } + else { end_rad = (nu->bp+end_sel+1)->radius; } /* Now Blend between the points */ range = (float)(end_sel - start_sel) + 2.0f; - for(bp=nu->bp+start_sel, a=start_sel; a<=end_sel; a++, bp++) { + for (bp=nu->bp+start_sel, a=start_sel; a<=end_sel; a++, bp++) { fac = (float)(1+a-start_sel) / range; bp->radius = start_rad*(1.0f-fac) + end_rad*fac; } @@ -2376,21 +2407,21 @@ static void select_adjacent_cp(ListBase *editnurb, short next, short cont, short int a; short lastsel= 0; - if(next==0) return; + if (next==0) return; - for(nu= editnurb->first; nu; nu= nu->next) { + for (nu= editnurb->first; nu; nu= nu->next) { lastsel=0; - if(nu->type == CU_BEZIER) { + if (nu->type == CU_BEZIER) { a= nu->pntsu; bezt= nu->bezt; - if(next < 0) bezt= (nu->bezt + (a-1)); - while(a--) { - if(a-abs(next) < 0) break; - if((lastsel==0) && (bezt->hide==0) && ((bezt->f2 & SELECT) || (selstatus==0))) { + if (next < 0) bezt= (nu->bezt + (a-1)); + while (a--) { + if (a-abs(next) < 0) break; + if ((lastsel==0) && (bezt->hide==0) && ((bezt->f2 & SELECT) || (selstatus==0))) { bezt+=next; - if(!(bezt->f2 & SELECT) || (selstatus==0)) { + if (!(bezt->f2 & SELECT) || (selstatus==0)) { short sel= select_beztriple(bezt, selstatus, 1, VISIBLE); - if((sel==1) && (cont==0)) lastsel= 1; + if ((sel==1) && (cont==0)) lastsel= 1; } } else { @@ -2404,14 +2435,14 @@ static void select_adjacent_cp(ListBase *editnurb, short next, short cont, short else { a= nu->pntsu*nu->pntsv; bp= nu->bp; - if(next < 0) bp= (nu->bp + (a-1)); - while(a--) { - if(a-abs(next) < 0) break; - if((lastsel==0) && (bp->hide==0) && ((bp->f1 & SELECT) || (selstatus==0))) { + if (next < 0) bp= (nu->bp + (a-1)); + while (a--) { + if (a-abs(next) < 0) break; + if ((lastsel==0) && (bp->hide==0) && ((bp->f1 & SELECT) || (selstatus==0))) { bp+=next; - if(!(bp->f1 & SELECT) || (selstatus==0)) { + if (!(bp->f1 & SELECT) || (selstatus==0)) { short sel= select_bpoint(bp, selstatus, 1, VISIBLE); - if((sel==1) && (cont==0)) lastsel= 1; + if ((sel==1) && (cont==0)) lastsel= 1; } } else { @@ -2440,49 +2471,49 @@ void selectend_nurb(Object *obedit, short selfirst, short doswap, short selstatu Curve *cu; int a; - if(obedit==NULL) return; + if (obedit==NULL) return; cu= (Curve*)obedit->data; cu->lastsel= NULL; - for(nu= editnurb->first; nu; nu= nu->next) { - if(nu->type == CU_BEZIER) { + for (nu= editnurb->first; nu; nu= nu->next) { + if (nu->type == CU_BEZIER) { a= nu->pntsu; /* which point? */ - if(selfirst==0) { /* select last */ + if (selfirst==0) { /* select last */ bezt= (nu->bezt + (a-1)); } else { /* select first */ bezt= nu->bezt; } - while(a--) { + while (a--) { short sel; - if(doswap) sel= swap_selection_beztriple(bezt); + if (doswap) sel= swap_selection_beztriple(bezt); else sel= select_beztriple(bezt, selstatus, 1, VISIBLE); - if(sel==1) break; + if (sel==1) break; } } else { a= nu->pntsu*nu->pntsv; /* which point? */ - if(selfirst==0) { /* select last */ + if (selfirst==0) { /* select last */ bp= (nu->bp + (a-1)); } - else{ /* select first */ + else { /* select first */ bp= nu->bp; } - while(a--) { + while (a--) { if (bp->hide == 0) { short sel; - if(doswap) sel= swap_selection_bpoint(bp); + if (doswap) sel= swap_selection_bpoint(bp); else sel= select_bpoint(bp, selstatus, 1, VISIBLE); - if(sel==1) break; + if (sel==1) break; } } } @@ -2546,13 +2577,13 @@ static short nurb_has_selected_cps(ListBase *editnurb) BPoint *bp; int a; - for(nu= editnurb->first; nu; nu= nu->next) { - if(nu->type == CU_BEZIER) { + for (nu= editnurb->first; nu; nu= nu->next) { + if (nu->type == CU_BEZIER) { a= nu->pntsu; bezt= nu->bezt; - while(a--) { - if(bezt->hide==0) { - if((bezt->f1 & SELECT) + while (a--) { + if (bezt->hide==0) { + if ((bezt->f1 & SELECT) || (bezt->f2 & SELECT) || (bezt->f3 & SELECT)) return 1; } @@ -2562,8 +2593,8 @@ static short nurb_has_selected_cps(ListBase *editnurb) else { a= nu->pntsu*nu->pntsv; bp= nu->bp; - while(a--) { - if((bp->hide==0) && (bp->f1 & SELECT)) return 1; + while (a--) { + if ((bp->hide==0) && (bp->f1 & SELECT)) return 1; bp++; } } @@ -2580,7 +2611,7 @@ static int de_select_all_exec(bContext *C, wmOperator *op) if (action == SEL_TOGGLE) { action = SEL_SELECT; - if(nurb_has_selected_cps(editnurb)) + if (nurb_has_selected_cps(editnurb)) action = SEL_DESELECT; } @@ -2630,42 +2661,42 @@ static int hide_exec(bContext *C, wmOperator *op) BezTriple *bezt; int a, sel, invert= RNA_boolean_get(op->ptr, "unselected"); - for(nu= editnurb->first; nu; nu= nu->next) { - if(nu->type == CU_BEZIER) { + for (nu= editnurb->first; nu; nu= nu->next) { + if (nu->type == CU_BEZIER) { bezt= nu->bezt; a= nu->pntsu; sel= 0; - while(a--) { - if(invert == 0 && BEZSELECTED_HIDDENHANDLES(cu, bezt)) { + while (a--) { + if (invert == 0 && BEZSELECTED_HIDDENHANDLES(cu, bezt)) { select_beztriple(bezt, DESELECT, 1, HIDDEN); bezt->hide= 1; } - else if(invert && !BEZSELECTED_HIDDENHANDLES(cu, bezt)) { + else if (invert && !BEZSELECTED_HIDDENHANDLES(cu, bezt)) { select_beztriple(bezt, DESELECT, 1, HIDDEN); bezt->hide= 1; } - if(bezt->hide) sel++; + if (bezt->hide) sel++; bezt++; } - if(sel==nu->pntsu) nu->hide= 1; + if (sel==nu->pntsu) nu->hide= 1; } else { bp= nu->bp; a= nu->pntsu*nu->pntsv; sel= 0; - while(a--) { - if(invert==0 && (bp->f1 & SELECT)) { + while (a--) { + if (invert==0 && (bp->f1 & SELECT)) { select_bpoint(bp, DESELECT, 1, HIDDEN); bp->hide= 1; } - else if(invert && (bp->f1 & SELECT)==0) { + else if (invert && (bp->f1 & SELECT)==0) { select_bpoint(bp, DESELECT, 1, HIDDEN); bp->hide= 1; } - if(bp->hide) sel++; + if (bp->hide) sel++; bp++; } - if(sel==nu->pntsu*nu->pntsv) nu->hide= 1; + if (sel==nu->pntsu*nu->pntsv) nu->hide= 1; } } @@ -2703,13 +2734,13 @@ static int reveal_exec(bContext *C, wmOperator *UNUSED(op)) BezTriple *bezt; int a; - for(nu= editnurb->first; nu; nu= nu->next) { + for (nu= editnurb->first; nu; nu= nu->next) { nu->hide= 0; - if(nu->type == CU_BEZIER) { + if (nu->type == CU_BEZIER) { bezt= nu->bezt; a= nu->pntsu; - while(a--) { - if(bezt->hide) { + while (a--) { + if (bezt->hide) { select_beztriple(bezt, SELECT, 1, HIDDEN); bezt->hide= 0; } @@ -2719,8 +2750,8 @@ static int reveal_exec(bContext *C, wmOperator *UNUSED(op)) else { bp= nu->bp; a= nu->pntsu*nu->pntsv; - while(a--) { - if(bp->hide) { + while (a--) { + if (bp->hide) { select_bpoint(bp, SELECT, 1, HIDDEN); bp->hide= 0; } @@ -2768,16 +2799,16 @@ static void subdividenurb(Object *obedit, int number_cuts) // printf("*** subdivideNurb: entering subdivide\n"); - for(nu= editnurb->nurbs.first; nu; nu= nu->next) { + for (nu= editnurb->nurbs.first; nu; nu= nu->next) { amount= 0; - if(nu->type == CU_BEZIER) { + if (nu->type == CU_BEZIER) { /* * Insert a point into a 2D Bezier curve. * Endpoints are preserved. Otherwise, all selected and inserted points are * newly created. Old points are discarded. */ /* count */ - if(nu->flagu & CU_NURB_CYCLIC) { + if (nu->flagu & CU_NURB_CYCLIC) { a= nu->pntsu; bezt= nu->bezt; prevbezt= bezt+(a-1); @@ -2787,18 +2818,18 @@ static void subdividenurb(Object *obedit, int number_cuts) prevbezt= nu->bezt; bezt= prevbezt+1; } - while(a--) { - if( BEZSELECTED_HIDDENHANDLES(cu, prevbezt) && BEZSELECTED_HIDDENHANDLES(cu, bezt) ) amount+=number_cuts; + while (a--) { + if ( BEZSELECTED_HIDDENHANDLES(cu, prevbezt) && BEZSELECTED_HIDDENHANDLES(cu, bezt) ) amount+=number_cuts; prevbezt= bezt; bezt++; } - if(amount) { + if (amount) { /* insert */ beztnew = (BezTriple*)MEM_mallocN((amount + nu->pntsu) * sizeof(BezTriple), "subdivNurb"); beztn= beztnew; - if(nu->flagu & CU_NURB_CYCLIC) { + if (nu->flagu & CU_NURB_CYCLIC) { a= nu->pntsu; bezt= nu->bezt; prevbezt= bezt+(a-1); @@ -2808,12 +2839,12 @@ static void subdividenurb(Object *obedit, int number_cuts) prevbezt= nu->bezt; bezt= prevbezt+1; } - while(a--) { + while (a--) { memcpy(beztn, prevbezt, sizeof(BezTriple)); keyIndex_updateBezt(editnurb, prevbezt, beztn, 1); beztn++; - if( BEZSELECTED_HIDDENHANDLES(cu, prevbezt) && BEZSELECTED_HIDDENHANDLES(cu, bezt) ) { + if ( BEZSELECTED_HIDDENHANDLES(cu, prevbezt) && BEZSELECTED_HIDDENHANDLES(cu, bezt) ) { float prevvec[3][3]; memcpy(prevvec, prevbezt->vec, sizeof(float) * 9); @@ -2838,7 +2869,7 @@ static void subdividenurb(Object *obedit, int number_cuts) interp_v3_v3v3(beztn->vec[1], vec+9, vec+12, factor); copy_v3_v3(beztn->vec[2], vec+12); /* handle of next bezt */ - if(a==0 && i == number_cuts - 1 && (nu->flagu & CU_NURB_CYCLIC)) {copy_v3_v3(beztnew->vec[0], vec+6);} + if (a==0 && i == number_cuts - 1 && (nu->flagu & CU_NURB_CYCLIC)) {copy_v3_v3(beztnew->vec[0], vec+6);} else {copy_v3_v3(bezt->vec[0], vec+6);} beztn->radius = (prevbezt->radius + bezt->radius)/2; @@ -2853,7 +2884,7 @@ static void subdividenurb(Object *obedit, int number_cuts) bezt++; } /* last point */ - if((nu->flagu & CU_NURB_CYCLIC)==0) { + if ((nu->flagu & CU_NURB_CYCLIC)==0) { memcpy(beztn, prevbezt, sizeof(BezTriple)); keyIndex_updateBezt(editnurb, prevbezt, beztn, 1); } @@ -2873,7 +2904,7 @@ static void subdividenurb(Object *obedit, int number_cuts) * stable... nzc 30-5-'00 */ /* count */ - if(nu->flagu & CU_NURB_CYCLIC) { + if (nu->flagu & CU_NURB_CYCLIC) { a= nu->pntsu; bp= nu->bp; prevbp= bp+(a-1); @@ -2883,19 +2914,19 @@ static void subdividenurb(Object *obedit, int number_cuts) prevbp= nu->bp; bp= prevbp+1; } - while(a--) { - if( (bp->f1 & SELECT) && (prevbp->f1 & SELECT) ) amount+=number_cuts; + while (a--) { + if ( (bp->f1 & SELECT) && (prevbp->f1 & SELECT) ) amount+=number_cuts; prevbp= bp; bp++; } - if(amount) { + if (amount) { /* insert */ bpnew = (BPoint*)MEM_mallocN((amount + nu->pntsu) * sizeof(BPoint), "subdivNurb2"); bpn= bpnew; - if(nu->flagu & CU_NURB_CYCLIC) { + if (nu->flagu & CU_NURB_CYCLIC) { a= nu->pntsu; bp= nu->bp; prevbp= bp+(a-1); @@ -2905,12 +2936,12 @@ static void subdividenurb(Object *obedit, int number_cuts) prevbp= nu->bp; bp= prevbp+1; } - while(a--) { + while (a--) { memcpy(bpn, prevbp, sizeof(BPoint)); keyIndex_updateBP(editnurb, prevbp, bpn, 1); bpn++; - if( (bp->f1 & SELECT) && (prevbp->f1 & SELECT) ) { + if ( (bp->f1 & SELECT) && (prevbp->f1 & SELECT) ) { // printf("*** subdivideNurb: insert 'linear' point\n"); for (i = 0; i < number_cuts; i++) { factor = (float)(i + 1) / (number_cuts + 1); @@ -2924,7 +2955,7 @@ static void subdividenurb(Object *obedit, int number_cuts) prevbp= bp; bp++; } - if((nu->flagu & CU_NURB_CYCLIC)==0) { /* last point */ + if ((nu->flagu & CU_NURB_CYCLIC)==0) { /* last point */ memcpy(bpn, prevbp, sizeof(BPoint)); keyIndex_updateBP(editnurb, prevbp, bpn, 1); } @@ -2933,12 +2964,12 @@ static void subdividenurb(Object *obedit, int number_cuts) nu->bp= bpnew; nu->pntsu+= amount; - if(nu->type & CU_NURBS) { + if (nu->type & CU_NURBS) { nurbs_knot_calc_u(nu); } } - } /* End of 'else if(nu->pntsv==1)' */ - else if(nu->type == CU_NURBS) { + } /* End of 'else if (nu->pntsv==1)' */ + else if (nu->type == CU_NURBS) { /* This is a very strange test ... */ /** * Subdivide NURB surfaces - nzc 30-5-'00 - @@ -2988,9 +3019,9 @@ static void subdividenurb(Object *obedit, int number_cuts) /* Count the number of selected points. */ bp= nu->bp; - for(a=0; apntsv; a++) { - for(b=0; bpntsu; b++) { - if(bp->f1 & SELECT) { + for (a=0; apntsv; a++) { + for (b=0; bpntsu; b++) { + if (bp->f1 & SELECT) { usel[b]++; vsel[a]++; sel++; @@ -2998,7 +3029,7 @@ static void subdividenurb(Object *obedit, int number_cuts) bp++; } } - if( sel == (nu->pntsu*nu->pntsv) ) { /* subdivide entire nurb */ + if ( sel == (nu->pntsu*nu->pntsv) ) { /* subdivide entire nurb */ /* Global subdivision is a special case of partial * subdivision. Strange it is considered separately... */ @@ -3011,13 +3042,13 @@ static void subdividenurb(Object *obedit, int number_cuts) bpn=bpnew= MEM_mallocN( tot*sizeof(BPoint), "subdivideNurb4"); bp= nu->bp; /* first subdivide rows */ - for(a=0; apntsv; a++) { - for(b=0; bpntsu; b++) { + for (a=0; apntsv; a++) { + for (b=0; bpntsu; b++) { *bpn= *bp; keyIndex_updateBP(editnurb, bp, bpn, 1); bpn++; bp++; - if(bpntsu-1) { + if (bpntsu-1) { prevbp= bp-1; for (i = 0; i < number_cuts; i++) { factor = (float)(i + 1) / (number_cuts + 1); @@ -3033,9 +3064,9 @@ static void subdividenurb(Object *obedit, int number_cuts) bpn= bpnew+((number_cuts+1)*nu->pntsu - number_cuts); bp= bpnew+(number_cuts+1)*((number_cuts+1)*nu->pntsu-number_cuts); prevbp= bpnew; - for(a=1; apntsv; a++) { + for (a=1; apntsv; a++) { - for(b=0; b<(number_cuts+1)*nu->pntsu-number_cuts; b++) { + for (b=0; b<(number_cuts+1)*nu->pntsu-number_cuts; b++) { BPoint *tmp= bpn; for (i = 0; i < number_cuts; i++) { factor = (float)(i + 1) / (number_cuts + 1); @@ -3061,25 +3092,25 @@ static void subdividenurb(Object *obedit, int number_cuts) else { /* subdivide in v direction? */ sel= 0; - for(a=0; apntsv-1; a++) { - if(vsel[a]==nu->pntsu && vsel[a+1]==nu->pntsu) sel+=number_cuts; + for (a=0; apntsv-1; a++) { + if (vsel[a]==nu->pntsu && vsel[a+1]==nu->pntsu) sel+=number_cuts; } - if(sel) { /* V ! */ + if (sel) { /* V ! */ bpn=bpnew= MEM_mallocN( (sel+nu->pntsv)*nu->pntsu*sizeof(BPoint), "subdivideNurb4"); bp= nu->bp; - for(a=0; apntsv; a++) { - for(b=0; bpntsu; b++) { + for (a=0; apntsv; a++) { + for (b=0; bpntsu; b++) { *bpn= *bp; keyIndex_updateBP(editnurb, bp, bpn, 1); bpn++; bp++; } - if( (apntsv-1) && vsel[a]==nu->pntsu && vsel[a+1]==nu->pntsu ) { + if ( (apntsv-1) && vsel[a]==nu->pntsu && vsel[a+1]==nu->pntsu ) { for (i = 0; i < number_cuts; i++) { factor = (float)(i + 1) / (number_cuts + 1); prevbp= bp- nu->pntsu; - for(b=0; bpntsu; b++) { + for (b=0; bpntsu; b++) { /* * This simple bisection must be replaces by a * subtle resampling of a number of points. Our @@ -3106,22 +3137,22 @@ static void subdividenurb(Object *obedit, int number_cuts) else { /* or in u direction? */ sel= 0; - for(a=0; apntsu-1; a++) { - if(usel[a]==nu->pntsv && usel[a+1]==nu->pntsv) sel+=number_cuts; + for (a=0; apntsu-1; a++) { + if (usel[a]==nu->pntsv && usel[a+1]==nu->pntsv) sel+=number_cuts; } - if(sel) { /* U ! */ + if (sel) { /* U ! */ /* Inserting U points is sort of 'default' Flat curves only get */ /* U points inserted in them. */ bpn=bpnew= MEM_mallocN( (sel+nu->pntsu)*nu->pntsv*sizeof(BPoint), "subdivideNurb4"); bp= nu->bp; - for(a=0; apntsv; a++) { - for(b=0; bpntsu; b++) { + for (a=0; apntsv; a++) { + for (b=0; bpntsu; b++) { *bpn= *bp; keyIndex_updateBP(editnurb, bp, bpn, 1); bpn++; bp++; - if( (bpntsu-1) && usel[b]==nu->pntsv && usel[b+1]==nu->pntsv ) { + if ( (bpntsu-1) && usel[b]==nu->pntsv && usel[b+1]==nu->pntsv ) { /* * One thing that bugs me here is that the * orders of things are not the same as in @@ -3160,7 +3191,7 @@ static int subdivide_exec(bContext *C, wmOperator *op) subdividenurb(obedit, number_cuts); - if(ED_curve_updateAnimPaths(obedit)) + if (ED_curve_updateAnimPaths(obedit)) WM_event_add_notifier(C, NC_OBJECT|ND_KEYS, obedit); WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data); @@ -3201,12 +3232,15 @@ static void findnearestNurbvert__doClosest(void *userData, Nurb *nu, BPoint *bp, if (bp) { flag = bp->f1; - } else { + } + else { if (beztindex==0) { flag = bezt->f1; - } else if (beztindex==1) { + } + else if (beztindex==1) { flag = bezt->f2; - } else { + } + else { flag = bezt->f3; } } @@ -3260,19 +3294,19 @@ static void findselectedNurbvert(ListBase *editnurb, Nurb **nu, BezTriple **bezt *nu= NULL; *bezt= NULL; *bp= NULL; - for(nu1= editnurb->first; nu1; nu1= nu1->next) { - if(nu1->type == CU_BEZIER) { + for (nu1= editnurb->first; nu1; nu1= nu1->next) { + if (nu1->type == CU_BEZIER) { bezt1= nu1->bezt; a= nu1->pntsu; - while(a--) { - if( (bezt1->f1 & SELECT) || (bezt1->f2 & SELECT) || (bezt1->f3 & SELECT) ) { - if(*nu != NULL && *nu != nu1) { + while (a--) { + if ( (bezt1->f1 & SELECT) || (bezt1->f2 & SELECT) || (bezt1->f3 & SELECT) ) { + if (*nu != NULL && *nu != nu1) { *nu= NULL; *bp= NULL; *bezt= NULL; return; } - else if(*bezt || *bp) { + else if (*bezt || *bp) { *bp= NULL; *bezt= NULL; } @@ -3287,15 +3321,15 @@ static void findselectedNurbvert(ListBase *editnurb, Nurb **nu, BezTriple **bezt else { bp1= nu1->bp; a= nu1->pntsu*nu1->pntsv; - while(a--) { - if( bp1->f1 & 1 ) { - if(*nu != NULL && *nu != nu1) { + while (a--) { + if ( bp1->f1 & 1 ) { + if (*nu != NULL && *nu != nu1) { *bp= NULL; *bezt= NULL; *nu= NULL; return; } - else if(*bezt || *bp) { + else if (*bezt || *bp) { *bp= NULL; *bezt= NULL; } @@ -3318,15 +3352,15 @@ static int convertspline(short type, Nurb *nu) BPoint *bp; int a, c, nr; - if(nu->type == CU_POLY) { - if(type==CU_BEZIER) { /* to Bezier with vecthandles */ + if (nu->type == CU_POLY) { + if (type==CU_BEZIER) { /* to Bezier with vecthandles */ nr= nu->pntsu; bezt = (BezTriple*)MEM_callocN(nr * sizeof(BezTriple), "setsplinetype2"); nu->bezt= bezt; a= nr; bp= nu->bp; - while(a--) { + while (a--) { copy_v3_v3(bezt->vec[1], bp->vec); bezt->f1=bezt->f2=bezt->f3= bp->f1; bezt->h1= bezt->h2= HD_VECT; @@ -3341,28 +3375,28 @@ static int convertspline(short type, Nurb *nu) nu->type = CU_BEZIER; calchandlesNurb(nu); } - else if(type==CU_NURBS) { + else if (type==CU_NURBS) { nu->type = CU_NURBS; nu->orderu= 4; nu->flagu &= CU_NURB_CYCLIC; /* disable all flags except for cyclic */ nurbs_knot_calc_u(nu); a= nu->pntsu*nu->pntsv; bp= nu->bp; - while(a--) { + while (a--) { bp->vec[3]= 1.0; bp++; } } } - else if(nu->type == CU_BEZIER) { /* Bezier */ - if(type==CU_POLY || type==CU_NURBS) { + else if (nu->type == CU_BEZIER) { /* Bezier */ + if (type==CU_POLY || type==CU_NURBS) { nr= 3*nu->pntsu; nu->bp = MEM_callocN(nr * sizeof(BPoint), "setsplinetype"); a= nu->pntsu; bezt= nu->bezt; bp= nu->bp; - while(a--) { - if(type==CU_POLY && bezt->h1==HD_VECT && bezt->h2==HD_VECT) { + while (a--) { + if (type==CU_POLY && bezt->h1==HD_VECT && bezt->h2==HD_VECT) { /* vector handle becomes 1 poly vertice */ copy_v3_v3(bp->vec, bezt->vec[1]); bp->vec[3]= 1.0; @@ -3373,11 +3407,11 @@ static int convertspline(short type, Nurb *nu) bp++; } else { - for(c=0;c<3;c++) { + for (c=0;c<3;c++) { copy_v3_v3(bp->vec, bezt->vec[c]); bp->vec[3]= 1.0; - if(c==0) bp->f1= bezt->f1; - else if(c==1) bp->f1= bezt->f2; + if (c==0) bp->f1= bezt->f1; + else if (c==1) bp->f1= bezt->f2; else bp->f1= bezt->f3; bp->radius= bezt->radius; bp->weight= bezt->weight; @@ -3395,36 +3429,36 @@ static int convertspline(short type, Nurb *nu) nu->type = type; #if 0 /* UNUSED */ - if(nu->flagu & CU_NURB_CYCLIC) c= nu->orderu-1; + if (nu->flagu & CU_NURB_CYCLIC) c= nu->orderu-1; else c= 0; #endif - if(type== CU_NURBS) { + if (type== CU_NURBS) { nu->flagu &= CU_NURB_CYCLIC; /* disable all flags except for cyclic */ nu->flagu |= CU_NURB_BEZIER; nurbs_knot_calc_u(nu); } } } - else if(nu->type == CU_NURBS) { - if(type==CU_POLY) { + else if (nu->type == CU_NURBS) { + if (type==CU_POLY) { nu->type = CU_POLY; - if(nu->knotsu) MEM_freeN(nu->knotsu); /* python created nurbs have a knotsu of zero */ + if (nu->knotsu) MEM_freeN(nu->knotsu); /* python created nurbs have a knotsu of zero */ nu->knotsu= NULL; - if(nu->knotsv) MEM_freeN(nu->knotsv); + if (nu->knotsv) MEM_freeN(nu->knotsv); nu->knotsv= NULL; } - else if(type==CU_BEZIER) { /* to Bezier */ + else if (type==CU_BEZIER) { /* to Bezier */ nr= nu->pntsu/3; - if(nr<2) + if (nr<2) return 1; /* conversion impossible */ else { bezt = MEM_callocN(nr * sizeof(BezTriple), "setsplinetype2"); nu->bezt= bezt; a= nr; bp= nu->bp; - while(a--) { + while (a--) { copy_v3_v3(bezt->vec[0], bp->vec); bezt->f1= bp->f1; bp++; @@ -3463,22 +3497,22 @@ static int set_spline_type_exec(bContext *C, wmOperator *op) Nurb *nu; int changed=0, type= RNA_enum_get(op->ptr, "type"); - if(type==CU_CARDINAL || type==CU_BSPLINE) { + if (type==CU_CARDINAL || type==CU_BSPLINE) { BKE_report(op->reports, RPT_ERROR, "Not implemented yet"); return OPERATOR_CANCELLED; } - for(nu= editnurb->first; nu; nu= nu->next) { - if(isNurbsel(nu)) { - if(convertspline(type, nu)) + for (nu= editnurb->first; nu; nu= nu->next) { + if (isNurbsel(nu)) { + if (convertspline(type, nu)) BKE_report(op->reports, RPT_ERROR, "No conversion possible"); else changed= 1; } } - if(changed) { - if(ED_curve_updateAnimPaths(obedit)) + if (changed) { + if (ED_curve_updateAnimPaths(obedit)) WM_event_add_notifier(C, NC_OBJECT|ND_KEYS, obedit); DAG_id_tag_update(obedit->data, 0); @@ -3570,14 +3604,14 @@ static void switchdirection_knots(float *base, int tot) float *fp1, *fp2, *tempf; int a; - if(base==NULL || tot==0) return; + if (base==NULL || tot==0) return; /* reverse knots */ a= tot; fp1= base; fp2= fp1+(a-1); a/= 2; - while(fp1!=fp2 && a>0) { + while (fp1!=fp2 && a>0) { SWAP(float, *fp1, *fp2); a--; fp1++; @@ -3587,7 +3621,7 @@ static void switchdirection_knots(float *base, int tot) a= tot; fp1= base; fp2=tempf= MEM_mallocN(sizeof(float)*a, "switchdirect"); - while(a--) { + while (a--) { fp2[0]= fabs(fp1[1]-fp1[0]); fp1++; fp2++; @@ -3598,7 +3632,7 @@ static void switchdirection_knots(float *base, int tot) fp2= tempf; fp1[0]= 0.0; fp1++; - while(a--) { + while (a--) { fp1[0]= fp1[-1]+fp2[0]; fp1++; fp2++; @@ -3621,8 +3655,8 @@ static void rotate_direction_nurb(Nurb *nu) temp= MEM_dupallocN(nu->bp); bp1= nu->bp; - for(v=0; vpntsv; v++) { - for(u=0; upntsu; u++, bp1++) { + for (v=0; vpntsv; v++) { + for (u=0; upntsu; u++, bp1++) { bp2= temp + (nu->pntsu-u-1)*(nu->pntsv) + v; *bp1= *bp2; } @@ -3638,8 +3672,8 @@ static int is_u_selected(Nurb *nu, int u) /* what about resolu == 2? */ bp= nu->bp+u; - for(v=0; vpntsv-1; v++, bp+=nu->pntsu) { - if(v) if(bp->f1 & SELECT) return 1; + for (v=0; vpntsv-1; v++, bp+=nu->pntsu) { + if (v) if(bp->f1 & SELECT) return 1; } return 0; @@ -3663,8 +3697,8 @@ static void make_selection_list_nurb(ListBase *editnurb) float dist, headdist, taildist; int a; - for(nu= editnurb->first; nu; nu= nu->next) { - if( isNurbsel(nu) ) { + for (nu= editnurb->first; nu; nu= nu->next) { + if ( isNurbsel(nu) ) { nus = (NurbSort*)MEM_callocN(sizeof(NurbSort), "sort"); BLI_addhead(&nbase, nus); @@ -3672,7 +3706,7 @@ static void make_selection_list_nurb(ListBase *editnurb) bp= nu->bp; a= nu->pntsu; - while(a--) { + while (a--) { add_v3_v3(nus->vec, bp->vec); bp++; } @@ -3688,29 +3722,29 @@ static void make_selection_list_nurb(ListBase *editnurb) BLI_addtail( &nsortbase, nus); /* now add, either at head or tail, the closest one */ - while(nbase.first) { + while (nbase.first) { headdist= taildist= 1.0e30; headdo= taildo= NULL; nustest= nbase.first; - while(nustest) { + while (nustest) { dist= len_v3v3(nustest->vec, ((NurbSort *)nsortbase.first)->vec); - if(distvec, ((NurbSort *)nsortbase.last)->vec); - if(distnext; } - if(headdistpntsu-1) ); + if ( is_u_selected(nu1, nu1->pntsu-1) ); else { /* For 2D curves blender uses orderv=0. It doesn't make any sense mathematically. */ /* but after rotating orderu=0 will be confusing. */ if (nu1->orderv == 0) nu1->orderv= 1; rotate_direction_nurb(nu1); - if( is_u_selected(nu1, nu1->pntsu-1) ); + if ( is_u_selected(nu1, nu1->pntsu-1) ); else { rotate_direction_nurb(nu1); - if( is_u_selected(nu1, nu1->pntsu-1) ); + if ( is_u_selected(nu1, nu1->pntsu-1) ); else { rotate_direction_nurb(nu1); - if( is_u_selected(nu1, nu1->pntsu-1) ); + if ( is_u_selected(nu1, nu1->pntsu-1) ); else { /* rotate again, now its OK! */ - if(nu1->pntsv!=1) rotate_direction_nurb(nu1); + if (nu1->pntsv!=1) rotate_direction_nurb(nu1); return; } } @@ -3756,28 +3790,28 @@ static void merge_2_nurb(wmOperator *op, ListBase *editnurb, Nurb *nu1, Nurb *nu } /* 2nd nurbs: u = 0 selected */ - if( is_u_selected(nu2, 0) ); + if ( is_u_selected(nu2, 0) ); else { if (nu2->orderv == 0) nu2->orderv= 1; rotate_direction_nurb(nu2); - if( is_u_selected(nu2, 0) ); + if ( is_u_selected(nu2, 0) ); else { rotate_direction_nurb(nu2); - if( is_u_selected(nu2, 0) ); + if ( is_u_selected(nu2, 0) ); else { rotate_direction_nurb(nu2); - if( is_u_selected(nu2, 0) ); + if ( is_u_selected(nu2, 0) ); else { /* rotate again, now its OK! */ - if(nu1->pntsu==1) rotate_direction_nurb(nu1); - if(nu2->pntsv!=1) rotate_direction_nurb(nu2); + if (nu1->pntsu==1) rotate_direction_nurb(nu1); + if (nu2->pntsv!=1) rotate_direction_nurb(nu2); return; } } } } - if( nu1->pntsv != nu2->pntsv ) { + if ( nu1->pntsv != nu2->pntsv ) { BKE_report(op->reports, RPT_ERROR, "Resolution doesn't match"); return; } @@ -3789,7 +3823,7 @@ static void merge_2_nurb(wmOperator *op, ListBase *editnurb, Nurb *nu1, Nurb *nu bp2= nu2->bp; len1= 0.0; - for(v=0; vpntsv; v++, bp1+=nu1->pntsu, bp2+=nu2->pntsu) { + for (v=0; vpntsv; v++, bp1+=nu1->pntsu, bp2+=nu2->pntsu) { len1+= len_v3v3(bp1->vec, bp2->vec); } @@ -3797,29 +3831,29 @@ static void merge_2_nurb(wmOperator *op, ListBase *editnurb, Nurb *nu1, Nurb *nu bp2= nu2->bp + nu2->pntsu*(nu2->pntsv-1); len2= 0.0; - for(v=0; vpntsv; v++, bp1+=nu1->pntsu, bp2-=nu2->pntsu) { + for (v=0; vpntsv; v++, bp1+=nu1->pntsu, bp2-=nu2->pntsu) { len2+= len_v3v3(bp1->vec, bp2->vec); } /* merge */ origu= nu1->pntsu; nu1->pntsu+= nu2->pntsu; - if(nu1->orderu<3 && nu1->orderupntsu) nu1->orderu++; - if(nu1->orderv<3 && nu1->ordervpntsv) nu1->orderv++; + if (nu1->orderu<3 && nu1->orderupntsu) nu1->orderu++; + if (nu1->orderv<3 && nu1->ordervpntsv) nu1->orderv++; temp= nu1->bp; nu1->bp= MEM_mallocN(nu1->pntsu*nu1->pntsv*sizeof(BPoint), "mergeBP"); bp= nu1->bp; bp1= temp; - for(v=0; vpntsv; v++) { + for (v=0; vpntsv; v++) { /* switch direction? */ - if(len1bp + v*nu2->pntsu; + if (len1bp + v*nu2->pntsu; else bp2= nu2->bp + (nu1->pntsv-v-1)*nu2->pntsu; - for(u=0; upntsu; u++, bp++) { - if(upntsu; u++, bp++) { + if (utype == CU_NURBS) { + if (nu1->type == CU_NURBS) { /* merge knots */ nurbs_knot_calc_u(nu1); @@ -3851,7 +3885,7 @@ static int merge_nurb(bContext *C, wmOperator *op) make_selection_list_nurb(editnurb); - if(nsortbase.first == nsortbase.last) { + if (nsortbase.first == nsortbase.last) { BLI_freelistN(&nsortbase); BKE_report(op->reports, RPT_ERROR, "Too few selections to merge"); return OPERATOR_CANCELLED; @@ -3861,27 +3895,27 @@ static int merge_nurb(bContext *C, wmOperator *op) nus2= nus1->next; /* resolution match, to avoid uv rotations */ - if(nus1->nu->pntsv==1) { - if(nus1->nu->pntsu==nus2->nu->pntsu || nus1->nu->pntsu==nus2->nu->pntsv); + if (nus1->nu->pntsv==1) { + if (nus1->nu->pntsu==nus2->nu->pntsu || nus1->nu->pntsu==nus2->nu->pntsv); else ok= 0; } - else if(nus2->nu->pntsv==1) { - if(nus2->nu->pntsu==nus1->nu->pntsu || nus2->nu->pntsu==nus1->nu->pntsv); + else if (nus2->nu->pntsv==1) { + if (nus2->nu->pntsu==nus1->nu->pntsu || nus2->nu->pntsu==nus1->nu->pntsv); else ok= 0; } - else if( nus1->nu->pntsu==nus2->nu->pntsu || nus1->nu->pntsv==nus2->nu->pntsv); - else if( nus1->nu->pntsu==nus2->nu->pntsv || nus1->nu->pntsv==nus2->nu->pntsu); + else if ( nus1->nu->pntsu==nus2->nu->pntsu || nus1->nu->pntsv==nus2->nu->pntsv); + else if ( nus1->nu->pntsu==nus2->nu->pntsv || nus1->nu->pntsv==nus2->nu->pntsu); else { ok= 0; } - if(ok==0) { + if (ok==0) { BKE_report(op->reports, RPT_ERROR, "Resolution doesn't match"); BLI_freelistN(&nsortbase); return OPERATOR_CANCELLED; } - while(nus2) { + while (nus2) { merge_2_nurb(op, editnurb, nus1->nu, nus2->nu); nus2= nus2->next; } @@ -3908,18 +3942,18 @@ static int make_segment_exec(bContext *C, wmOperator *op) int a, ok= 0; /* first decide if this is a surface merge! */ - if(obedit->type==OB_SURF) nu= nubase->first; + if (obedit->type==OB_SURF) nu= nubase->first; else nu= NULL; - while(nu) { - if( isNurbsel(nu) ) { + while (nu) { + if ( isNurbsel(nu) ) { - if(nu->pntsu>1 && nu->pntsv>1) break; - if(isNurbsel_count(cu, nu)>1) break; - if(isNurbsel_count(cu, nu)==1) { + if (nu->pntsu>1 && nu->pntsv>1) break; + if (isNurbsel_count(cu, nu)>1) break; + if (isNurbsel_count(cu, nu)==1) { /* only 1 selected, not first or last, a little complex, but intuitive */ - if(nu->pntsv==1) { - if( (nu->bp->f1 & SELECT) || ((nu->bp+nu->pntsu-1)->f1 & SELECT)); + if (nu->pntsv==1) { + if ( (nu->bp->f1 & SELECT) || ((nu->bp+nu->pntsu-1)->f1 & SELECT)); else break; } } @@ -3927,62 +3961,62 @@ static int make_segment_exec(bContext *C, wmOperator *op) nu= nu->next; } - if(nu) + if (nu) return merge_nurb(C, op); /* find both nurbs and points, nu1 will be put behind nu2 */ - for(nu= nubase->first; nu; nu= nu->next) { - if(nu->pntsu == 1) + for (nu= nubase->first; nu; nu= nu->next) { + if (nu->pntsu == 1) nu->flagu&= ~CU_NURB_CYCLIC; - if((nu->flagu & CU_NURB_CYCLIC)==0) { /* not cyclic */ - if(nu->type == CU_BEZIER) { - if(nu1==NULL) { - if( BEZSELECTED_HIDDENHANDLES(cu, nu->bezt) ) nu1= nu; + if ((nu->flagu & CU_NURB_CYCLIC)==0) { /* not cyclic */ + if (nu->type == CU_BEZIER) { + if (nu1==NULL) { + if ( BEZSELECTED_HIDDENHANDLES(cu, nu->bezt) ) nu1= nu; else { - if( BEZSELECTED_HIDDENHANDLES(cu, &(nu->bezt[nu->pntsu-1])) ) { + if ( BEZSELECTED_HIDDENHANDLES(cu, &(nu->bezt[nu->pntsu-1])) ) { nu1= nu; switchdirectionNurb(nu); keyData_switchDirectionNurb(cu, nu); } } } - else if(nu2==NULL) { - if( BEZSELECTED_HIDDENHANDLES(cu, nu->bezt) ) { + else if (nu2==NULL) { + if ( BEZSELECTED_HIDDENHANDLES(cu, nu->bezt) ) { nu2= nu; switchdirectionNurb(nu); keyData_switchDirectionNurb(cu, nu); } else { - if( BEZSELECTED_HIDDENHANDLES(cu, &(nu->bezt[nu->pntsu-1])) ) { + if ( BEZSELECTED_HIDDENHANDLES(cu, &(nu->bezt[nu->pntsu-1])) ) { nu2= nu; } } } else break; } - else if(nu->pntsv==1) { + else if (nu->pntsv==1) { bp= nu->bp; - if(nu1==NULL) { - if( bp->f1 & SELECT) nu1= nu; + if (nu1==NULL) { + if ( bp->f1 & SELECT) nu1= nu; else { bp= bp+(nu->pntsu-1); - if( bp->f1 & SELECT ) { + if ( bp->f1 & SELECT ) { nu1= nu; switchdirectionNurb(nu); keyData_switchDirectionNurb(cu, nu); } } } - else if(nu2==NULL) { - if( bp->f1 & SELECT ) { + else if (nu2==NULL) { + if ( bp->f1 & SELECT ) { nu2= nu; switchdirectionNurb(nu); keyData_switchDirectionNurb(cu, nu); } else { bp= bp+(nu->pntsu-1); - if( bp->f1 & SELECT ) { + if ( bp->f1 & SELECT ) { nu2= nu; } } @@ -3992,9 +4026,9 @@ static int make_segment_exec(bContext *C, wmOperator *op) } } - if((nu1 && nu2) && (nu1!=nu2)) { - if( nu1->type==nu2->type) { - if(nu1->type == CU_BEZIER) { + if ((nu1 && nu2) && (nu1!=nu2)) { + if ( nu1->type==nu2->type) { + if (nu1->type == CU_BEZIER) { BezTriple *bezt = (BezTriple*)MEM_mallocN((nu1->pntsu+nu2->pntsu) * sizeof(BezTriple), "addsegmentN"); ED_curve_beztcpy(cu->editnurb, bezt, nu2->bezt, nu2->pntsu); @@ -4021,8 +4055,8 @@ static int make_segment_exec(bContext *C, wmOperator *op) BLI_remlink(nubase, nu2); /* now join the knots */ - if(nu1->type == CU_NURBS) { - if(nu1->knotsu==NULL) { + if (nu1->type == CU_NURBS) { + if (nu1->knotsu==NULL) { nurbs_knot_calc_u(nu1); } else { @@ -4034,8 +4068,8 @@ static int make_segment_exec(bContext *C, wmOperator *op) offset= nu1->knotsu[a-1] + 1.0f; fp= nu1->knotsu+a; - for(a=0; apntsu; a++, fp++) { - if(nu2->knotsu) + for (a=0; apntsu; a++, fp++) { + if (nu2->knotsu) *fp= offset+nu2->knotsu[a+1]; else *fp = offset; @@ -4048,14 +4082,16 @@ static int make_segment_exec(bContext *C, wmOperator *op) set_actNurb(obedit, nu1); /* for selected */ ok= 1; } - } else if(nu1 && !nu2) { - if(!(nu1->flagu & CU_NURB_CYCLIC) && nu1->pntsu>1) { + } + else if (nu1 && !nu2) { + if (!(nu1->flagu & CU_NURB_CYCLIC) && nu1->pntsu>1) { if (nu1->type == CU_BEZIER && BEZSELECTED_HIDDENHANDLES(cu, nu1->bezt) && BEZSELECTED_HIDDENHANDLES(cu, nu1->bezt+(nu1->pntsu-1))) { nu1->flagu|= CU_NURB_CYCLIC; calchandlesNurb(nu1); ok= 1; - } else if (nu1->type == CU_NURBS && nu1->bp->f1&SELECT && (nu1->bp+(nu1->pntsu-1))->f1&SELECT) { + } + else if (nu1->type == CU_NURBS && nu1->bp->f1&SELECT && (nu1->bp+(nu1->pntsu-1))->f1&SELECT) { nu1->flagu|= CU_NURB_CYCLIC; nurbs_knot_calc_u(nu1); ok= 1; @@ -4063,12 +4099,12 @@ static int make_segment_exec(bContext *C, wmOperator *op) } } - if(!ok) { + if (!ok) { BKE_report(op->reports, RPT_ERROR, "Can't make segment"); return OPERATOR_CANCELLED; } - if(ED_curve_updateAnimPaths(obedit)) + if (ED_curve_updateAnimPaths(obedit)) WM_event_add_notifier(C, NC_OBJECT|ND_KEYS, obedit); WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data); @@ -4112,18 +4148,19 @@ int mouse_nurb(bContext *C, const int mval[2], int extend) location[1]= mval[1]; hand= findnearestNurbvert(&vc, 1, location, &nu, &bezt, &bp); - if(bezt || bp) { - if(extend==0) { + if (bezt || bp) { + if (extend==0) { setflagsNurb(editnurb, 0); - if(bezt) { + if (bezt) { - if(hand==1) { + if (hand==1) { select_beztriple(bezt, SELECT, 1, HIDDEN); cu->lastsel= bezt; - } else { - if(hand==0) bezt->f1|= SELECT; + } + else { + if (hand==0) bezt->f1|= SELECT; else bezt->f3|= SELECT; cu->lastsel= NULL; @@ -4136,26 +4173,30 @@ int mouse_nurb(bContext *C, const int mval[2], int extend) } else { - if(bezt) { - if(hand==1) { - if(bezt->f2 & SELECT) { + if (bezt) { + if (hand==1) { + if (bezt->f2 & SELECT) { select_beztriple(bezt, DESELECT, 1, HIDDEN); if (bezt == cu->lastsel) cu->lastsel = NULL; - } else { + } + else { select_beztriple(bezt, SELECT, 1, HIDDEN); cu->lastsel= bezt; } - } else if(hand==0) { + } + else if (hand==0) { bezt->f1 ^= SELECT; - } else { + } + else { bezt->f3 ^= SELECT; } } else { - if(bp->f1 & SELECT) { + if (bp->f1 & SELECT) { select_bpoint(bp, DESELECT, 1, HIDDEN); if (cu->lastsel == bp) cu->lastsel = NULL; - } else { + } + else { select_bpoint(bp, SELECT, 1, HIDDEN); cu->lastsel= bp; } @@ -4163,7 +4204,7 @@ int mouse_nurb(bContext *C, const int mval[2], int extend) } - if(nu!=get_actNurb(obedit)) + if (nu!=get_actNurb(obedit)) set_actNurb(obedit, nu); WM_event_add_notifier(C, NC_GEOM|ND_SELECT, obedit->data); @@ -4227,17 +4268,17 @@ static int spin_nurb(float viewmat[][4], Object *obedit, float *axis, float *cen ok= 1; - for(a=0;a<7;a++) { + for (a=0;a<7;a++) { ok= extrudeflagNurb(cu->editnurb, 1); - if(ok==0) + if (ok==0) return changed; changed= 1; rotateflagNurb(editnurb, SELECT, cent, rotmat); - if( (a & SELECT)==0 ) { + if ( (a & SELECT)==0 ) { rotateflagNurb(editnurb, SELECT, cent, scalemat1); weightflagNurb(editnurb, SELECT, 0.25*M_SQRT2); } @@ -4247,9 +4288,9 @@ static int spin_nurb(float viewmat[][4], Object *obedit, float *axis, float *cen } } - if(ok) { - for(nu= editnurb->first; nu; nu= nu->next) { - if(isNurbsel(nu)) { + if (ok) { + for (nu= editnurb->first; nu; nu= nu->next) { + if (isNurbsel(nu)) { nu->orderv= 4; nu->flagv |= CU_NURB_CYCLIC; nurbs_knot_calc_v(nu); @@ -4272,17 +4313,17 @@ static int spin_exec(bContext *C, wmOperator *op) invert_m4_m4(obedit->imat, obedit->obmat); mul_m4_v3(obedit->imat, cent); - if(rv3d) + if (rv3d) copy_m4_m4(viewmat, rv3d->viewmat); else unit_m4(viewmat); - if(!spin_nurb(viewmat, obedit, axis, cent)) { + if (!spin_nurb(viewmat, obedit, axis, cent)) { BKE_report(op->reports, RPT_ERROR, "Can't spin"); return OPERATOR_CANCELLED; } - if(ED_curve_updateAnimPaths(obedit)) + if (ED_curve_updateAnimPaths(obedit)) WM_event_add_notifier(C, NC_OBJECT|ND_KEYS, obedit); WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data); @@ -4298,7 +4339,7 @@ static int spin_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) RegionView3D *rv3d= ED_view3d_context_rv3d(C); float axis[3]= {0.0f, 0.0f, 1.0f}; - if(rv3d) + if (rv3d) copy_v3_v3(axis, rv3d->viewinv[2]); RNA_float_set_array(op->ptr, "center", give_cursor(scene, v3d)); @@ -4343,11 +4384,11 @@ static int addvert_Nurb(bContext *C, short mode, float location[3]) findselectedNurbvert(&editnurb->nurbs, &nu, &bezt, &bp); if ((nu == NULL) || (nu->type==CU_BEZIER && bezt==NULL) || (nu->type!=CU_BEZIER && bp==NULL)) { - if(mode!='e') { - if(cu->actnu >= 0) + if (mode!='e') { + if (cu->actnu >= 0) nu= BLI_findlink(&editnurb->nurbs, cu->actnu); - if(!nu || nu->type==CU_BEZIER) { + if (!nu || nu->type==CU_BEZIER) { newbezt= (BezTriple*)MEM_callocN(sizeof(BezTriple), "addvert_Nurb"); newbezt->radius= 1; newbezt->alfa= 0; @@ -4355,14 +4396,15 @@ static int addvert_Nurb(bContext *C, short mode, float location[3]) newbezt->h2= newbezt->h1= HD_AUTO; newnu= (Nurb*)MEM_callocN(sizeof(Nurb), "addvert_Nurb newnu"); - if(!nu) { + if (!nu) { /* no selected sement -- create new one which is BEZIER tpye * type couldn't be determined from Curve bt could be changed * in the future, so shouldn't make much headache */ newnu->type= CU_BEZIER; newnu->resolu= cu->resolu; newnu->flag |= CU_SMOOTH; - } else memcpy(newnu, nu, sizeof(Nurb)); + } + else memcpy(newnu, nu, sizeof(Nurb)); BLI_addtail(&editnurb->nurbs, newnu); set_actNurb(obedit, newnu); @@ -4383,7 +4425,8 @@ static int addvert_Nurb(bContext *C, short mode, float location[3]) ok= 1; nu= newnu; - } else if(nu->pntsv == 1) { + } + else if (nu->pntsv == 1) { newbp= (BPoint*)MEM_callocN(sizeof(BPoint), "addvert_Nurb5"); newbp->radius= 1; newbp->alfa= 0; @@ -4410,13 +4453,13 @@ static int addvert_Nurb(bContext *C, short mode, float location[3]) } - if(!ok) + if (!ok) return OPERATOR_CANCELLED; } - if(!ok && nu->type == CU_BEZIER) { + if (!ok && nu->type == CU_BEZIER) { /* which bezpoint? */ - if(bezt== (nu->bezt+nu->pntsu-1)) { /* last */ + if (bezt== (nu->bezt+nu->pntsu-1)) { /* last */ BEZ_DESEL(bezt); newbezt = (BezTriple*)MEM_callocN((nu->pntsu+1) * sizeof(BezTriple), "addvert_Nurb"); @@ -4432,7 +4475,7 @@ static int addvert_Nurb(bContext *C, short mode, float location[3]) bezt= nu->bezt+nu->pntsu-1; ok= 1; } - else if(bezt== nu->bezt) { /* first */ + else if (bezt== nu->bezt) { /* first */ BEZ_DESEL(bezt); newbezt = (BezTriple*)MEM_callocN((nu->pntsu+1) * sizeof(BezTriple), "addvert_Nurb"); @@ -4447,7 +4490,7 @@ static int addvert_Nurb(bContext *C, short mode, float location[3]) bezt= newbezt+1; ok= 1; } - else if(mode!='e') { + else if (mode!='e') { BEZ_DESEL(bezt); newbezt= (BezTriple*)MEM_callocN(sizeof(BezTriple), "addvert_Nurb"); *newbezt= *bezt; @@ -4469,10 +4512,10 @@ static int addvert_Nurb(bContext *C, short mode, float location[3]) } else bezt= NULL; - if(bezt) { - if(!newnu) nu->pntsu++; + if (bezt) { + if (!newnu) nu->pntsu++; - if(mode=='e') { + if (mode=='e') { copy_v3_v3(newbezt->vec[0], bezt->vec[0]); copy_v3_v3(newbezt->vec[1], bezt->vec[1]); copy_v3_v3(newbezt->vec[2], bezt->vec[2]); @@ -4483,14 +4526,14 @@ static int addvert_Nurb(bContext *C, short mode, float location[3]) add_v3_v3v3(newbezt->vec[0], bezt->vec[0],temp); add_v3_v3v3(newbezt->vec[2], bezt->vec[2],temp); - if(newnu) calchandlesNurb(newnu); + if (newnu) calchandlesNurb(newnu); else calchandlesNurb(nu); } } } - else if(!ok && nu->pntsv==1) { + else if (!ok && nu->pntsv==1) { /* which b-point? */ - if(bp== (nu->bp+nu->pntsu-1)) { /* last */ + if (bp== (nu->bp+nu->pntsu-1)) { /* last */ bp->f1= 0; newbp = (BPoint*)MEM_callocN((nu->pntsu+1) * sizeof(BPoint), "addvert_Nurb4"); @@ -4504,7 +4547,7 @@ static int addvert_Nurb(bContext *C, short mode, float location[3]) bp= newbp - 1; ok= 1; } - else if(bp== nu->bp) { /* first */ + else if (bp== nu->bp) { /* first */ bp->f1= 0; newbp = (BPoint*)MEM_callocN((nu->pntsu+1) * sizeof(BPoint), "addvert_Nurb3"); @@ -4517,7 +4560,7 @@ static int addvert_Nurb(bContext *C, short mode, float location[3]) bp= newbp + 1; ok= 1; } - else if(mode!='e') { + else if (mode!='e') { bp->f1= 0; newbp= (BPoint*)MEM_callocN(sizeof(BPoint), "addvert_Nurb5"); *newbp= *bp; @@ -4538,29 +4581,30 @@ static int addvert_Nurb(bContext *C, short mode, float location[3]) } else bp= NULL; - if(bp) { - if(mode=='e') { + if (bp) { + if (mode=='e') { copy_v3_v3(newbp->vec, bp->vec); } else { mul_v3_m4v3(newbp->vec, imat, location); newbp->vec[3]= 1.0; - if(!newnu && nu->orderu<4 && nu->orderu<=nu->pntsu) + if (!newnu && nu->orderu<4 && nu->orderu<=nu->pntsu) nu->orderu++; } - if(!newnu) { + if (!newnu) { nu->pntsu++; nurbs_knot_calc_u(nu); - } else nurbs_knot_calc_u(newnu); + } + else nurbs_knot_calc_u(newnu); } } - if(ok) { + if (ok) { test2DNurb(nu); - if(ED_curve_updateAnimPaths(obedit)) + if (ED_curve_updateAnimPaths(obedit)) WM_event_add_notifier(C, NC_OBJECT|ND_KEYS, obedit); WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data); @@ -4584,7 +4628,7 @@ static int add_vertex_invoke(bContext *C, wmOperator *op, wmEvent *event) { RegionView3D *rv3d= CTX_wm_region_view3d(C); - if(rv3d && !RNA_struct_property_is_set(op->ptr, "location")) { + if (rv3d && !RNA_struct_property_is_set(op->ptr, "location")) { Curve *cu; ViewContext vc; float location[3]; @@ -4599,7 +4643,7 @@ static int add_vertex_invoke(bContext *C, wmOperator *op, wmEvent *event) findselectedNurbvert(&cu->editnurb->nurbs, &nu, &bezt, &bp); - if(bezt) { + if (bezt) { mul_v3_m4v3(location, vc.obedit->obmat, bezt->vec[1]); } else if (bp) { @@ -4644,16 +4688,16 @@ static int extrude_exec(bContext *C, wmOperator *UNUSED(op)) Nurb *nu; /* first test: curve? */ - for(nu= editnurb->nurbs.first; nu; nu= nu->next) - if(nu->pntsv==1 && isNurbsel_count(cu, nu)==1) + for (nu= editnurb->nurbs.first; nu; nu= nu->next) + if (nu->pntsv==1 && isNurbsel_count(cu, nu)==1) break; - if(obedit->type==OB_CURVE || nu) { + if (obedit->type==OB_CURVE || nu) { addvert_Nurb(C, 'e', NULL); } else { - if(extrudeflagNurb(editnurb, 1)) { /* '1'= flag */ - if(ED_curve_updateAnimPaths(obedit)) + if (extrudeflagNurb(editnurb, 1)) { /* '1'= flag */ + if (ED_curve_updateAnimPaths(obedit)) WM_event_add_notifier(C, NC_OBJECT|ND_KEYS, obedit); WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data); @@ -4694,24 +4738,24 @@ static int toggle_cyclic_exec(bContext *C, wmOperator *op) BPoint *bp; int a, direction= RNA_enum_get(op->ptr, "direction"); - for(nu= editnurb->first; nu; nu= nu->next) { - if( nu->pntsu>1 || nu->pntsv>1) { - if(nu->type == CU_POLY) { + for (nu= editnurb->first; nu; nu= nu->next) { + if ( nu->pntsu>1 || nu->pntsv>1) { + if (nu->type == CU_POLY) { a= nu->pntsu; bp= nu->bp; - while(a--) { - if( bp->f1 & SELECT ) { + while (a--) { + if ( bp->f1 & SELECT ) { nu->flagu ^= CU_NURB_CYCLIC; break; } bp++; } } - else if(nu->type == CU_BEZIER) { + else if (nu->type == CU_BEZIER) { a= nu->pntsu; bezt= nu->bezt; - while(a--) { - if( BEZSELECTED_HIDDENHANDLES(cu, bezt) ) { + while (a--) { + if ( BEZSELECTED_HIDDENHANDLES(cu, bezt) ) { nu->flagu ^= CU_NURB_CYCLIC; break; } @@ -4719,12 +4763,12 @@ static int toggle_cyclic_exec(bContext *C, wmOperator *op) } calchandlesNurb(nu); } - else if(nu->pntsv==1 && nu->type == CU_NURBS) { + else if (nu->pntsv==1 && nu->type == CU_NURBS) { if (nu->knotsu) { /* if check_valid_nurb_u fails the knotsu can be NULL */ a= nu->pntsu; bp= nu->bp; - while(a--) { - if( bp->f1 & SELECT ) { + while (a--) { + if ( bp->f1 & SELECT ) { nu->flagu ^= CU_NURB_CYCLIC; nurbs_knot_calc_u(nu); /* 1==u type is ignored for cyclic curves */ break; @@ -4733,17 +4777,17 @@ static int toggle_cyclic_exec(bContext *C, wmOperator *op) } } } - else if(nu->type==CU_NURBS) { + else if (nu->type==CU_NURBS) { a= nu->pntsu*nu->pntsv; bp= nu->bp; - while(a--) { + while (a--) { - if( bp->f1 & SELECT) { - if(direction==0 && nu->pntsu>1) { + if ( bp->f1 & SELECT) { + if (direction==0 && nu->pntsu>1) { nu->flagu ^= CU_NURB_CYCLIC; nurbs_knot_calc_u(nu); /* 1==u type is ignored for cyclic curves */ } - if(direction==1 && nu->pntsv>1) { + if (direction==1 && nu->pntsv>1) { nu->flagv ^= CU_NURB_CYCLIC; nurbs_knot_calc_v(nu); /* 2==v type is ignored for cyclic curves */ } @@ -4770,10 +4814,10 @@ static int toggle_cyclic_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(eve uiLayout *layout; Nurb *nu; - if(obedit->type == OB_SURF) { - for(nu= editnurb->first; nu; nu= nu->next) { - if(nu->pntsu>1 || nu->pntsv>1) { - if(nu->type==CU_NURBS) { + if (obedit->type == OB_SURF) { + for (nu= editnurb->first; nu; nu= nu->next) { + if (nu->pntsu>1 || nu->pntsv>1) { + if (nu->type==CU_NURBS) { pup= uiPupMenuBegin(C, "Direction", ICON_NONE); layout= uiPupMenuLayout(pup); uiItemsEnumO(layout, op->type->idname, "direction"); @@ -4824,15 +4868,15 @@ static int select_linked_exec(bContext *C, wmOperator *UNUSED(op)) BPoint *bp; int a; - for(nu= nurbs->first; nu; nu= nu->next) { - if(nu->type == CU_BEZIER) { + for (nu= nurbs->first; nu; nu= nu->next) { + if (nu->type == CU_BEZIER) { bezt= nu->bezt; a= nu->pntsu; - while(a--) { - if( (bezt->f1 & SELECT) || (bezt->f2 & SELECT) || (bezt->f3 & SELECT) ) { + while (a--) { + if ( (bezt->f1 & SELECT) || (bezt->f2 & SELECT) || (bezt->f3 & SELECT) ) { a= nu->pntsu; bezt= nu->bezt; - while(a--) { + while (a--) { select_beztriple(bezt, SELECT, 1, VISIBLE); bezt++; } @@ -4844,11 +4888,11 @@ static int select_linked_exec(bContext *C, wmOperator *UNUSED(op)) else { bp= nu->bp; a= nu->pntsu*nu->pntsv; - while(a--) { - if( bp->f1 & 1 ) { + while (a--) { + if ( bp->f1 & 1 ) { a= nu->pntsu*nu->pntsv; bp= nu->bp; - while(a--) { + while (a--) { select_bpoint(bp, SELECT, 1, VISIBLE); bp++; } @@ -4905,20 +4949,20 @@ static int select_linked_pick_invoke(bContext *C, wmOperator *op, wmEvent *event findnearestNurbvert(&vc, 1, event->mval, &nu, &bezt, &bp); - if(bezt) { + if (bezt) { a= nu->pntsu; bezt= nu->bezt; - while(a--) { - if(deselect) select_beztriple(bezt, DESELECT, 1, VISIBLE); + while (a--) { + if (deselect) select_beztriple(bezt, DESELECT, 1, VISIBLE); else select_beztriple(bezt, SELECT, 1, VISIBLE); bezt++; } } - else if(bp) { + else if (bp) { a= nu->pntsu*nu->pntsv; bp= nu->bp; - while(a--) { - if(deselect) select_bpoint(bp, DESELECT, 1, VISIBLE); + while (a--) { + if (deselect) select_bpoint(bp, DESELECT, 1, VISIBLE); else select_bpoint(bp, SELECT, 1, VISIBLE); bp++; } @@ -4959,41 +5003,41 @@ static int select_row_exec(bContext *C, wmOperator *UNUSED(op)) BPoint *bp; int u = 0, v = 0, a, b, ok=0; - if(editnurb->first == NULL) + if (editnurb->first == NULL) return OPERATOR_CANCELLED; - if(cu->lastsel==NULL) + if (cu->lastsel==NULL) return OPERATOR_CANCELLED; /* find the correct nurb and toggle with u of v */ - for(nu= editnurb->first; nu; nu= nu->next) { + for (nu= editnurb->first; nu; nu= nu->next) { bp= nu->bp; - for(v=0; vpntsv; v++) { - for(u=0; upntsu; u++, bp++) { - if(bp==cu->lastsel) { - if(bp->f1 & SELECT) { + for (v=0; vpntsv; v++) { + for (u=0; upntsu; u++, bp++) { + if (bp==cu->lastsel) { + if (bp->f1 & SELECT) { ok= 1; break; } } } - if(ok) break; + if (ok) break; } - if(ok) { - if(last==cu->lastsel) { + if (ok) { + if (last==cu->lastsel) { direction= 1-direction; setflagsNurb(editnurb, 0); } last= cu->lastsel; bp= nu->bp; - for(a=0; apntsv; a++) { - for(b=0; bpntsu; b++, bp++) { - if(direction) { - if(a==v) select_bpoint(bp, SELECT, 1, VISIBLE); + for (a=0; apntsv; a++) { + for (b=0; bpntsu; b++, bp++) { + if (direction) { + if (a==v) select_bpoint(bp, SELECT, 1, VISIBLE); } else { - if(b==u) select_bpoint(bp, SELECT, 1, VISIBLE); + if (b==u) select_bpoint(bp, SELECT, 1, VISIBLE); } } } @@ -5091,40 +5135,40 @@ static int select_more_exec(bContext *C, wmOperator *UNUSED(op)) /* the behavior of "select more" of mesh tools. */ /* The algorithm is designed to work in planar cases so it */ /* may not be optimal always (example: end of NURBS sphere) */ - if(obedit->type==OB_SURF) { - for(nu= editnurb->first; nu; nu= nu->next) { + if (obedit->type==OB_SURF) { + for (nu= editnurb->first; nu; nu= nu->next) { a= nu->pntsu*nu->pntsv; bp= nu->bp; selbpoints= MEM_callocN(sizeof(short)*a-nu->pntsu, "selectlist"); - while(a > 0) { - if((selbpoints[a]!=1) && (bp->hide==0) && (bp->f1 & SELECT)) { + while (a > 0) { + if ((selbpoints[a]!=1) && (bp->hide==0) && (bp->f1 & SELECT)) { /* upper control point */ - if(a%nu->pntsu != 0) { + if (a%nu->pntsu != 0) { tempbp= bp-1; - if(!(tempbp->f1 & SELECT)) select_bpoint(tempbp, SELECT, 1, VISIBLE); + if (!(tempbp->f1 & SELECT)) select_bpoint(tempbp, SELECT, 1, VISIBLE); } /* left control point. select only if it is not selected already */ - if(a-nu->pntsu > 0) { + if (a-nu->pntsu > 0) { sel= 0; tempbp= bp+nu->pntsu; - if(!(tempbp->f1 & SELECT)) sel= select_bpoint(tempbp, SELECT, 1, VISIBLE); + if (!(tempbp->f1 & SELECT)) sel= select_bpoint(tempbp, SELECT, 1, VISIBLE); /* make sure selected bpoint is discarded */ - if(sel == 1) selbpoints[a-nu->pntsu]= 1; + if (sel == 1) selbpoints[a-nu->pntsu]= 1; } /* right control point */ - if(a+nu->pntsu < nu->pntsu*nu->pntsv) { + if (a+nu->pntsu < nu->pntsu*nu->pntsv) { tempbp= bp-nu->pntsu; - if(!(tempbp->f1 & SELECT)) select_bpoint(tempbp, SELECT, 1, VISIBLE); + if (!(tempbp->f1 & SELECT)) select_bpoint(tempbp, SELECT, 1, VISIBLE); } /* lower control point. skip next bp in case selection was made */ - if(a%nu->pntsu != 1) { + if (a%nu->pntsu != 1) { sel= 0; tempbp= bp+1; - if(!(tempbp->f1 & 1)) sel= select_bpoint(tempbp, SELECT, 1, VISIBLE); - if(sel) { + if (!(tempbp->f1 & 1)) sel= select_bpoint(tempbp, SELECT, 1, VISIBLE); + if (sel) { bp++; a--; } @@ -5176,46 +5220,46 @@ static int select_less_exec(bContext *C, wmOperator *UNUSED(op)) short sel= 0, lastsel= 0; short *selbpoints; - if(obedit->type==OB_SURF) { - for(nu= editnurb->first; nu; nu= nu->next) { + if (obedit->type==OB_SURF) { + for (nu= editnurb->first; nu; nu= nu->next) { a= nu->pntsu*nu->pntsv; bp= nu->bp; selbpoints= MEM_callocN(sizeof(short)*a, "selectlist"); - while(a--) { - if((bp->hide==0) && (bp->f1 & SELECT)) { + while (a--) { + if ((bp->hide==0) && (bp->f1 & SELECT)) { sel= 0; /* check if neighbors have been selected */ /* edges of surface are an exception */ - if((a+1)%nu->pntsu==0) sel++; + if ((a+1)%nu->pntsu==0) sel++; else { bp--; - if((selbpoints[a+1]==1) || ((bp->hide==0) && (bp->f1 & SELECT))) sel++; + if ((selbpoints[a+1]==1) || ((bp->hide==0) && (bp->f1 & SELECT))) sel++; bp++; } - if((a+1)%nu->pntsu==1) sel++; + if ((a+1)%nu->pntsu==1) sel++; else { bp++; - if((bp->hide==0) && (bp->f1 & SELECT)) sel++; + if ((bp->hide==0) && (bp->f1 & SELECT)) sel++; bp--; } - if(a+1 > nu->pntsu*nu->pntsv-nu->pntsu) sel++; + if (a+1 > nu->pntsu*nu->pntsv-nu->pntsu) sel++; else { bp-=nu->pntsu; - if((selbpoints[a+nu->pntsu]==1) || ((bp->hide==0) && (bp->f1 & SELECT))) sel++; + if ((selbpoints[a+nu->pntsu]==1) || ((bp->hide==0) && (bp->f1 & SELECT))) sel++; bp+=nu->pntsu; } - if(a < nu->pntsu) sel++; + if (a < nu->pntsu) sel++; else { bp+=nu->pntsu; - if((bp->hide==0) && (bp->f1 & SELECT)) sel++; + if ((bp->hide==0) && (bp->f1 & SELECT)) sel++; bp-=nu->pntsu; } - if(sel!=4) { + if (sel!=4) { select_bpoint(bp, DESELECT, 1, VISIBLE); selbpoints[a]= 1; } @@ -5229,34 +5273,34 @@ static int select_less_exec(bContext *C, wmOperator *UNUSED(op)) } } else { - for(nu= editnurb->first; nu; nu= nu->next) { + for (nu= editnurb->first; nu; nu= nu->next) { lastsel=0; /* check what type of curve/nurb it is */ - if(nu->type == CU_BEZIER) { + if (nu->type == CU_BEZIER) { a= nu->pntsu; bezt= nu->bezt; - while(a--) { - if((bezt->hide==0) && (bezt->f2 & SELECT)) { - if(lastsel==1) sel= 1; + while (a--) { + if ((bezt->hide==0) && (bezt->f2 & SELECT)) { + if (lastsel==1) sel= 1; else sel= 0; /* check if neighbors have been selected */ /* first and last are exceptions */ - if(a==nu->pntsu-1) sel++; + if (a==nu->pntsu-1) sel++; else { bezt--; - if((bezt->hide==0) && (bezt->f2 & SELECT)) sel++; + if ((bezt->hide==0) && (bezt->f2 & SELECT)) sel++; bezt++; } - if(a==0) sel++; + if (a==0) sel++; else { bezt++; - if((bezt->hide==0) && (bezt->f2 & SELECT)) sel++; + if ((bezt->hide==0) && (bezt->f2 & SELECT)) sel++; bezt--; } - if(sel!=2) { + if (sel!=2) { select_beztriple(bezt, DESELECT, 1, VISIBLE); lastsel= 1; } @@ -5270,27 +5314,27 @@ static int select_less_exec(bContext *C, wmOperator *UNUSED(op)) else { a= nu->pntsu*nu->pntsv; bp= nu->bp; - while(a--) { - if((lastsel==0) && (bp->hide==0) && (bp->f1 & SELECT)) { - if(lastsel!=0) sel= 1; + while (a--) { + if ((lastsel==0) && (bp->hide==0) && (bp->f1 & SELECT)) { + if (lastsel!=0) sel= 1; else sel= 0; /* first and last are exceptions */ - if(a==nu->pntsu*nu->pntsv-1) sel++; + if (a==nu->pntsu*nu->pntsv-1) sel++; else { bp--; - if((bp->hide==0) && (bp->f1 & SELECT)) sel++; + if ((bp->hide==0) && (bp->f1 & SELECT)) sel++; bp++; } - if(a==0) sel++; + if (a==0) sel++; else { bp++; - if((bp->hide==0) && (bp->f1 & SELECT)) sel++; + if ((bp->hide==0) && (bp->f1 & SELECT)) sel++; bp--; } - if(sel!=2) { + if (sel!=2) { select_bpoint(bp, DESELECT, 1, VISIBLE); lastsel= 1; } @@ -5334,11 +5378,11 @@ static void selectrandom_curve(ListBase *editnurb, float randfac) BLI_srand( BLI_rand() ); /* random seed */ - for(nu= editnurb->first; nu; nu= nu->next) { - if(nu->type == CU_BEZIER) { + for (nu= editnurb->first; nu; nu= nu->next) { + if (nu->type == CU_BEZIER) { bezt= nu->bezt; a= nu->pntsu; - while(a--) { + while (a--) { if (BLI_frand() < randfac) select_beztriple(bezt, SELECT, 1, VISIBLE); bezt++; @@ -5348,7 +5392,7 @@ static void selectrandom_curve(ListBase *editnurb, float randfac) bp= nu->bp; a= nu->pntsu*nu->pntsv; - while(a--) { + while (a--) { if (BLI_frand() < randfac) select_bpoint(bp, SELECT, 1, VISIBLE); bp++; @@ -5362,7 +5406,7 @@ static int select_random_exec(bContext *C, wmOperator *op) Object *obedit= CTX_data_edit_object(C); ListBase *editnurb= object_editcurve_get(obedit); - if(!RNA_boolean_get(op->ptr, "extend")) + if (!RNA_boolean_get(op->ptr, "extend")) CU_deselect_all(obedit); selectrandom_curve(editnurb, RNA_float_get(op->ptr, "percent")/100.0f); @@ -5397,7 +5441,8 @@ static int point_on_nurb(Nurb *nu, void *point) if (nu->bezt) { BezTriple *bezt= (BezTriple*)point; return bezt >= nu->bezt && bezt < nu->bezt + nu->pntsu; - } else { + } + else { BPoint *bp= (BPoint*)point; return bp >= nu->bp && bp < nu->bp + nu->pntsu * nu->pntsv; } @@ -5408,7 +5453,7 @@ static Nurb *get_lastsel_nurb(Curve *cu) ListBase *nubase= curve_editnurbs(cu); Nurb *nu= nubase->first; - if(!cu->lastsel) + if (!cu->lastsel) return NULL; while (nu) { @@ -5478,7 +5523,8 @@ int CU_select_nth(Object *obedit, int nth) if (nu->bezt) { select_nth_bezt(nu, cu->lastsel, nth); - } else { + } + else { select_nth_bp(nu, cu->lastsel, nth); } @@ -5493,7 +5539,8 @@ static int select_nth_exec(bContext *C, wmOperator *op) if (!CU_select_nth(obedit, nth)) { if (obedit->type == OB_SURF) { BKE_report(op->reports, RPT_ERROR, "Surface hasn't got active point"); - } else { + } + else { BKE_report(op->reports, RPT_ERROR, "Curve hasn't got active point"); } @@ -5563,14 +5610,15 @@ static int delete_exec(bContext *C, wmOperator *op) int a, cut= 0, type= RNA_enum_get(op->ptr, "type"); int nuindex= 0; - if(obedit->type==OB_SURF) { - if(type==0) { + if (obedit->type==OB_SURF) { + if (type==0) { deleteflagNurb(C, op, 1); - } else { + } + else { keyIndex_delNurbList(editnurb, nubase); freeNurblist(nubase); - if(ED_curve_updateAnimPaths(obedit)) + if (ED_curve_updateAnimPaths(obedit)) WM_event_add_notifier(C, NC_OBJECT|ND_KEYS, obedit); } @@ -5580,24 +5628,24 @@ static int delete_exec(bContext *C, wmOperator *op) return OPERATOR_FINISHED; } - if(type==0) { + if (type==0) { /* first loop, can we remove entire pieces? */ Nurb *next; nu= nubase->first; - while(nu) { + while (nu) { next= nu->next; - if(nu->type == CU_BEZIER) { + if (nu->type == CU_BEZIER) { bezt= nu->bezt; a= nu->pntsu; - if(a) { - while(a) { - if( BEZSELECTED_HIDDENHANDLES(cu, bezt) ); + if (a) { + while (a) { + if ( BEZSELECTED_HIDDENHANDLES(cu, bezt) ); else break; a--; bezt++; } - if(a==0) { - if(cu->actnu == nuindex) + if (a==0) { + if (cu->actnu == nuindex) cu->actnu= -1; BLI_remlink(nubase, nu); @@ -5609,15 +5657,15 @@ static int delete_exec(bContext *C, wmOperator *op) else { bp= nu->bp; a= nu->pntsu*nu->pntsv; - if(a) { - while(a) { - if(bp->f1 & SELECT); + if (a) { + while (a) { + if (bp->f1 & SELECT); else break; a--; bp++; } - if(a==0) { - if(cu->actnu == nuindex) + if (a==0) { + if (cu->actnu == nuindex) cu->actnu= -1; BLI_remlink(nubase, nu); @@ -5639,14 +5687,14 @@ static int delete_exec(bContext *C, wmOperator *op) } /* 2nd loop, delete small pieces: just for curves */ nu= nubase->first; - while(nu) { + while (nu) { next= nu->next; type= 0; - if(nu->type == CU_BEZIER) { + if (nu->type == CU_BEZIER) { int delta= 0; bezt= nu->bezt; - for(a=0;apntsu;a++) { - if( BEZSELECTED_HIDDENHANDLES(cu, bezt) ) { + for (a=0;apntsu;a++) { + if ( BEZSELECTED_HIDDENHANDLES(cu, bezt) ) { memmove(bezt, bezt+1, (nu->pntsu-a-1)*sizeof(BezTriple)); keyIndex_delBezt(editnurb, bezt + delta); keyIndex_updateBezt(editnurb, bezt + 1, bezt, nu->pntsu-a-1); @@ -5657,7 +5705,7 @@ static int delete_exec(bContext *C, wmOperator *op) } else bezt++; } - if(type) { + if (type) { bezt1 = (BezTriple*)MEM_mallocN((nu->pntsu) * sizeof(BezTriple), "delNurb"); memcpy(bezt1, nu->bezt, (nu->pntsu)*sizeof(BezTriple) ); @@ -5667,12 +5715,12 @@ static int delete_exec(bContext *C, wmOperator *op) calchandlesNurb(nu); } } - else if(nu->pntsv==1) { + else if (nu->pntsv==1) { int delta= 0; bp= nu->bp; - for(a=0;apntsu;a++) { - if( bp->f1 & SELECT ) { + for (a=0;apntsu;a++) { + if ( bp->f1 & SELECT ) { memmove(bp, bp+1, (nu->pntsu-a-1)*sizeof(BPoint)); keyIndex_delBP(editnurb, bp + delta); keyIndex_updateBP(editnurb, bp+1, bp, nu->pntsu-a-1); @@ -5685,7 +5733,7 @@ static int delete_exec(bContext *C, wmOperator *op) bp++; } } - if(type) { + if (type) { bp1 = (BPoint*)MEM_mallocN(nu->pntsu * sizeof(BPoint), "delNurb2"); memcpy(bp1, nu->bp, (nu->pntsu)*sizeof(BPoint) ); keyIndex_updateBP(editnurb, nu->bp, bp1, nu->pntsu); @@ -5706,26 +5754,26 @@ static int delete_exec(bContext *C, wmOperator *op) nu= next; } } - else if(type==1) { /* erase segment */ + else if (type==1) { /* erase segment */ /* find the 2 selected points */ bezt1= bezt2= NULL; bp1= bp2= NULL; nu1= NULL; nuindex= 0; - for(nu= nubase->first; nu; nu= nu->next) { - if(nu->type == CU_BEZIER) { + for (nu= nubase->first; nu; nu= nu->next) { + if (nu->type == CU_BEZIER) { bezt= nu->bezt; - for(a=0; apntsu-1; a++) { - if( BEZSELECTED_HIDDENHANDLES(cu, bezt) ) { + for (a=0; apntsu-1; a++) { + if ( BEZSELECTED_HIDDENHANDLES(cu, bezt) ) { bezt1= bezt; bezt2= bezt+1; if ((bezt2->f1 & SELECT) || (bezt2->f2 & SELECT) || (bezt2->f3 & SELECT)) { /* pass */ } else { /* maybe do not make cyclic */ - if(a==0 && (nu->flagu & CU_NURB_CYCLIC) ) { + if (a==0 && (nu->flagu & CU_NURB_CYCLIC) ) { bezt2= bezt+(nu->pntsu-1); - if( (bezt2->f1 & SELECT) || (bezt2->f2 & SELECT) || (bezt2->f3 & SELECT) ) { + if ( (bezt2->f1 & SELECT) || (bezt2->f2 & SELECT) || (bezt2->f3 & SELECT) ) { nu->flagu &= ~CU_NURB_CYCLIC; calchandlesNurb(nu); WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data); @@ -5742,19 +5790,19 @@ static int delete_exec(bContext *C, wmOperator *op) bezt++; } } - else if(nu->pntsv==1) { + else if (nu->pntsv==1) { bp= nu->bp; - for(a=0; apntsu-1; a++) { - if( bp->f1 & SELECT ) { + for (a=0; apntsu-1; a++) { + if ( bp->f1 & SELECT ) { bp1= bp; bp2= bp+1; if (bp2->f1 & 1) { /* pass */ } else { /* maybe do not make cyclic */ - if(a==0 && (nu->flagu & CU_NURB_CYCLIC) ) { + if (a==0 && (nu->flagu & CU_NURB_CYCLIC) ) { bp2= bp+(nu->pntsu-1); - if( bp2->f1 & SELECT ) { + if ( bp2->f1 & SELECT ) { nu->flagu &= ~CU_NURB_CYCLIC; WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data); DAG_id_tag_update(obedit->data, 0); @@ -5770,19 +5818,19 @@ static int delete_exec(bContext *C, wmOperator *op) bp++; } } - if(nu1) break; + if (nu1) break; nuindex++; } - if(nu1) { - if(bezt1) { - if(nu1->pntsu==2) { /* remove completely */ - if(cu->actnu == nuindex) + if (nu1) { + if (bezt1) { + if (nu1->pntsu==2) { /* remove completely */ + if (cu->actnu == nuindex) cu->actnu= -1; BLI_remlink(nubase, nu); freeNurb(nu); nu = NULL; } - else if(nu1->flagu & CU_NURB_CYCLIC) { /* cyclic */ + else if (nu1->flagu & CU_NURB_CYCLIC) { /* cyclic */ bezt = (BezTriple*)MEM_mallocN((cut+1) * sizeof(BezTriple), "delNurb1"); ED_curve_beztcpy(editnurb, bezt, nu1->bezt, cut+1); @@ -5820,15 +5868,15 @@ static int delete_exec(bContext *C, wmOperator *op) calchandlesNurb(nu1); } } - else if(bp1) { - if(nu1->pntsu==2) { /* remove completely */ - if(cu->actnu == nuindex) + else if (bp1) { + if (nu1->pntsu==2) { /* remove completely */ + if (cu->actnu == nuindex) cu->actnu= -1; BLI_remlink(nubase, nu); freeNurb(nu); nu= NULL; } - else if(nu1->flagu & CU_NURB_CYCLIC) { /* cyclic */ + else if (nu1->flagu & CU_NURB_CYCLIC) { /* cyclic */ bp = (BPoint*)MEM_mallocN((cut+1) * sizeof(BPoint), "delNurb5"); ED_curve_bpcpy(editnurb, bp, nu1->bp, cut+1); @@ -5865,13 +5913,13 @@ static int delete_exec(bContext *C, wmOperator *op) } } } - else if(type==2) { + else if (type==2) { cu->actnu= -1; keyIndex_delNurbList(editnurb, nubase); freeNurblist(nubase); } - if(ED_curve_updateAnimPaths(obedit)) + if (ED_curve_updateAnimPaths(obedit)) WM_event_add_notifier(C, NC_OBJECT|ND_KEYS, obedit); WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data); @@ -5886,7 +5934,7 @@ static int delete_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) uiPopupMenu *pup; uiLayout *layout; - if(obedit->type==OB_SURF) { + if (obedit->type==OB_SURF) { pup= uiPupMenuBegin(C, "Delete", ICON_NONE); layout= uiPupMenuLayout(pup); uiItemEnumO_ptr(layout, op->type, NULL, 0, "type", 0); @@ -5937,12 +5985,12 @@ static int shade_smooth_exec(bContext *C, wmOperator *op) Nurb *nu; int clear= (strcmp(op->idname, "CURVE_OT_shade_flat") == 0); - if(obedit->type != OB_CURVE) + if (obedit->type != OB_CURVE) return OPERATOR_CANCELLED; - for(nu= editnurb->first; nu; nu= nu->next) { - if(isNurbsel(nu)) { - if(!clear) nu->flag |= CU_SMOOTH; + for (nu= editnurb->first; nu; nu= nu->next) { + if (isNurbsel(nu)) { + if (!clear) nu->flag |= CU_SMOOTH; else nu->flag &= ~CU_SMOOTH; } } @@ -6002,26 +6050,27 @@ int join_curve_exec(bContext *C, wmOperator *UNUSED(op)) invert_m4_m4(imat, ob->obmat); CTX_DATA_BEGIN(C, Base*, base, selected_editable_bases) { - if(base->object->type==ob->type) { - if(base->object != ob) { + if (base->object->type==ob->type) { + if (base->object != ob) { cu= base->object->data; - if(cu->nurb.first) { + if (cu->nurb.first) { /* watch it: switch order here really goes wrong */ mult_m4_m4m4(cmat, imat, base->object->obmat); nu= cu->nurb.first; - while(nu) { + while (nu) { newnu= duplicateNurb(nu); - if(ob->totcol) { /* TODO, merge material lists */ + if (ob->totcol) { /* TODO, merge material lists */ CLAMP(newnu->mat_nr, 0, ob->totcol-1); - } else newnu->mat_nr= 0; + } + else newnu->mat_nr= 0; BLI_addtail(&tempbase, newnu); - if( (bezt= newnu->bezt) ) { + if ( (bezt= newnu->bezt) ) { a= newnu->pntsu; - while(a--) { + while (a--) { mul_m4_v3(cmat, bezt->vec[0]); mul_m4_v3(cmat, bezt->vec[1]); mul_m4_v3(cmat, bezt->vec[2]); @@ -6029,9 +6078,9 @@ int join_curve_exec(bContext *C, wmOperator *UNUSED(op)) } calchandlesNurb(newnu); } - if( (bp= newnu->bp) ) { + if ( (bp= newnu->bp) ) { a= newnu->pntsu*nu->pntsv; - while(a--) { + while (a--) { mul_m4_v3(cmat, bp->vec); bp++; } @@ -6065,7 +6114,7 @@ static const char *get_curve_defname(int type) { int stype= type & CU_PRIMITIVE; - if((type & CU_TYPE)==CU_BEZIER) { + if ((type & CU_TYPE)==CU_BEZIER) { switch (stype) { case CU_PRIM_CURVE: return "BezierCurve"; case CU_PRIM_CIRCLE: return "BezierCircle"; @@ -6121,7 +6170,7 @@ Nurb *add_nurbs_primitive(bContext *C, float mat[4][4], int type, int newob) const int stype= (type & CU_PRIMITIVE); const int force_3d = ((Curve *)obedit->data)->flag & CU_3D; /* could be adding to an existing 3D curve */ - if(rv3d) { + if (rv3d) { copy_m4_m4(viewmat, rv3d->viewmat); copy_v3_v3(zvec, rv3d->viewinv[2]); } @@ -6139,7 +6188,7 @@ Nurb *add_nurbs_primitive(bContext *C, float mat[4][4], int type, int newob) switch(stype) { case CU_PRIM_CURVE: /* curve */ nu->resolu= cu->resolu; - if(cutype==CU_BEZIER) { + if (cutype==CU_BEZIER) { if (!force_3d) nu->flag |= CU_2D; nu->pntsu= 2; nu->bezt = @@ -6154,7 +6203,7 @@ Nurb *add_nurbs_primitive(bContext *C, float mat[4][4], int type, int newob) bezt->vec[0][1]+= -0.5f*grid; bezt->vec[2][0]+= -0.5f*grid; bezt->vec[2][1]+= 0.5f*grid; - for(a=0;a<3;a++) mul_m4_v3(mat, bezt->vec[a]); + for (a=0;a<3;a++) mul_m4_v3(mat, bezt->vec[a]); bezt++; bezt->h1= bezt->h2= HD_ALIGN; @@ -6167,7 +6216,7 @@ Nurb *add_nurbs_primitive(bContext *C, float mat[4][4], int type, int newob) bezt->vec[1][1] = 0; bezt->vec[2][0] = grid*2; bezt->vec[2][1] = 0; - for(a=0;a<3;a++) mul_m4_v3(mat, bezt->vec[a]); + for (a=0;a<3;a++) mul_m4_v3(mat, bezt->vec[a]); calchandlesNurb(nu); } @@ -6179,7 +6228,7 @@ Nurb *add_nurbs_primitive(bContext *C, float mat[4][4], int type, int newob) nu->bp= callocstructN(BPoint, 4, "addNurbprim3"); bp= nu->bp; - for(a=0;a<4;a++, bp++) { + for (a=0;a<4;a++, bp++) { bp->vec[3]= 1.0; bp->f1= SELECT; bp->radius = bp->weight = 1.0; @@ -6197,9 +6246,9 @@ Nurb *add_nurbs_primitive(bContext *C, float mat[4][4], int type, int newob) bp->vec[0]+= 1.5f*grid; bp= nu->bp; - for(a=0;a<4;a++, bp++) mul_m4_v3(mat,bp->vec); + for (a=0;a<4;a++, bp++) mul_m4_v3(mat,bp->vec); - if(cutype==CU_NURBS) { + if (cutype==CU_NURBS) { nu->knotsu= NULL; /* nurbs_knot_calc_u allocates */ nurbs_knot_calc_u(nu); } @@ -6215,7 +6264,7 @@ Nurb *add_nurbs_primitive(bContext *C, float mat[4][4], int type, int newob) nu->bp= callocstructN(BPoint, 5, "addNurbprim3"); bp= nu->bp; - for(a=0;a<5;a++, bp++) { + for (a=0;a<5;a++, bp++) { bp->vec[3]= 1.0; bp->f1= SELECT; bp->radius = bp->weight = 1.0; @@ -6231,9 +6280,9 @@ Nurb *add_nurbs_primitive(bContext *C, float mat[4][4], int type, int newob) bp->vec[0]+= 2.0f*grid; bp= nu->bp; - for(a=0;a<5;a++, bp++) mul_m4_v3(mat,bp->vec); + for (a=0;a<5;a++, bp++) mul_m4_v3(mat,bp->vec); - if(cutype==CU_NURBS) { + if (cutype==CU_NURBS) { nu->knotsu= NULL; /* nurbs_knot_calc_u allocates */ nurbs_knot_calc_u(nu); } @@ -6242,7 +6291,7 @@ Nurb *add_nurbs_primitive(bContext *C, float mat[4][4], int type, int newob) case CU_PRIM_CIRCLE: /* circle */ nu->resolu= cu->resolu; - if(cutype==CU_BEZIER) { + if (cutype==CU_BEZIER) { if (!force_3d) nu->flag |= CU_2D; nu->pntsu= 4; nu->bezt= callocstructN(BezTriple, 4, "addNurbprim1"); @@ -6252,33 +6301,33 @@ Nurb *add_nurbs_primitive(bContext *C, float mat[4][4], int type, int newob) bezt->h1= bezt->h2= HD_AUTO; bezt->f1= bezt->f2= bezt->f3= SELECT; bezt->vec[1][0]+= -grid; - for(a=0;a<3;a++) mul_m4_v3(mat,bezt->vec[a]); + for (a=0;a<3;a++) mul_m4_v3(mat,bezt->vec[a]); bezt->radius = bezt->weight = 1.0; bezt++; bezt->h1= bezt->h2= HD_AUTO; bezt->f1= bezt->f2= bezt->f3= SELECT; bezt->vec[1][1]+= grid; - for(a=0;a<3;a++) mul_m4_v3(mat,bezt->vec[a]); + for (a=0;a<3;a++) mul_m4_v3(mat,bezt->vec[a]); bezt->radius = bezt->weight = 1.0; bezt++; bezt->h1= bezt->h2= HD_AUTO; bezt->f1= bezt->f2= bezt->f3= SELECT; bezt->vec[1][0]+= grid; - for(a=0;a<3;a++) mul_m4_v3(mat,bezt->vec[a]); + for (a=0;a<3;a++) mul_m4_v3(mat,bezt->vec[a]); bezt->radius = bezt->weight = 1.0; bezt++; bezt->h1= bezt->h2= HD_AUTO; bezt->f1= bezt->f2= bezt->f3= SELECT; bezt->vec[1][1]+= -grid; - for(a=0;a<3;a++) mul_m4_v3(mat,bezt->vec[a]); + for (a=0;a<3;a++) mul_m4_v3(mat,bezt->vec[a]); bezt->radius = bezt->weight = 1.0; calchandlesNurb(nu); } - else if( cutype==CU_NURBS ) { /* nurb */ + else if ( cutype==CU_NURBS ) { /* nurb */ nu->pntsu= 8; nu->pntsv= 1; nu->orderu= 4; @@ -6286,9 +6335,9 @@ Nurb *add_nurbs_primitive(bContext *C, float mat[4][4], int type, int newob) nu->flagu= CU_NURB_CYCLIC; bp= nu->bp; - for(a=0; a<8; a++) { + for (a=0; a<8; a++) { bp->f1= SELECT; - if(xzproj==0) { + if (xzproj==0) { bp->vec[0]+= nurbcircle[a][0]*grid; bp->vec[1]+= nurbcircle[a][1]*grid; } @@ -6296,7 +6345,7 @@ Nurb *add_nurbs_primitive(bContext *C, float mat[4][4], int type, int newob) bp->vec[0]+= 0.25f*nurbcircle[a][0]*grid-0.75f*grid; bp->vec[2]+= 0.25f*nurbcircle[a][1]*grid; } - if(a & 1) bp->vec[3]= 0.25*M_SQRT2; + if (a & 1) bp->vec[3]= 0.25*M_SQRT2; else bp->vec[3]= 1.0; mul_m4_v3(mat,bp->vec); bp->radius = bp->weight = 1.0; @@ -6308,7 +6357,7 @@ Nurb *add_nurbs_primitive(bContext *C, float mat[4][4], int type, int newob) } break; case CU_PRIM_PATCH: /* 4x4 patch */ - if( cutype==CU_NURBS ) { /* nurb */ + if ( cutype==CU_NURBS ) { /* nurb */ nu->pntsu= 4; nu->pntsv= 4; @@ -6320,14 +6369,14 @@ Nurb *add_nurbs_primitive(bContext *C, float mat[4][4], int type, int newob) nu->flagv= 0; bp= nu->bp; - for(a=0; a<4; a++) { - for(b=0; b<4; b++) { + for (a=0; a<4; a++) { + for (b=0; b<4; b++) { bp->f1= SELECT; fac= (float)a -1.5f; bp->vec[0]+= fac*grid; fac= (float)b -1.5f; bp->vec[1]+= fac*grid; - if(a==1 || a==2) if(b==1 || b==2) { + if (a==1 || a==2) if(b==1 || b==2) { bp->vec[2]+= grid; } mul_m4_v3(mat,bp->vec); @@ -6341,7 +6390,7 @@ Nurb *add_nurbs_primitive(bContext *C, float mat[4][4], int type, int newob) } break; case CU_PRIM_TUBE: /* Cylinder */ - if( cutype==CU_NURBS ) { + if ( cutype==CU_NURBS ) { nu= add_nurbs_primitive(C, mat, CU_NURBS|CU_PRIM_CIRCLE, 0); /* circle */ nu->resolu= cu->resolu; nu->flag= CU_SMOOTH; @@ -6349,7 +6398,7 @@ Nurb *add_nurbs_primitive(bContext *C, float mat[4][4], int type, int newob) vec[0]=vec[1]= 0.0; vec[2]= -grid; - if(newob && (U.flag & USER_ADD_VIEWALIGNED) == 0) { + if (newob && (U.flag & USER_ADD_VIEWALIGNED) == 0) { /* pass */ } else { @@ -6367,14 +6416,14 @@ Nurb *add_nurbs_primitive(bContext *C, float mat[4][4], int type, int newob) a= nu->pntsu*nu->pntsv; bp= nu->bp; - while(a-- >0) { + while (a-- >0) { bp->f1 |= SELECT; bp++; } } break; case CU_PRIM_SPHERE: /* sphere */ - if( cutype==CU_NURBS ) { + if ( cutype==CU_NURBS ) { float tmp_cent[3] = {0.f, 0.f, 0.f}; float tmp_vec[3] = {0.f, 0.f, 1.f}; @@ -6388,11 +6437,11 @@ Nurb *add_nurbs_primitive(bContext *C, float mat[4][4], int type, int newob) nu->flagu= 0; bp= nu->bp; - for(a=0; a<5; a++) { + for (a=0; a<5; a++) { bp->f1= SELECT; bp->vec[0]+= nurbcircle[a][0]*grid; bp->vec[2]+= nurbcircle[a][1]*grid; - if(a & 1) bp->vec[3]= 0.5*M_SQRT2; + if (a & 1) bp->vec[3]= 0.5*M_SQRT2; else bp->vec[3]= 1.0; mul_m4_v3(mat,bp->vec); bp++; @@ -6402,7 +6451,7 @@ Nurb *add_nurbs_primitive(bContext *C, float mat[4][4], int type, int newob) BLI_addtail(editnurb, nu); /* temporal for spin */ - if(newob && (U.flag & USER_ADD_VIEWALIGNED) == 0) spin_nurb(umat, obedit, tmp_vec, tmp_cent); + if (newob && (U.flag & USER_ADD_VIEWALIGNED) == 0) spin_nurb(umat, obedit, tmp_vec, tmp_cent); else if ((U.flag & USER_ADD_VIEWALIGNED)) spin_nurb(viewmat, obedit, zvec, mat[3]); else spin_nurb(umat, obedit, tmp_vec, mat[3]); @@ -6410,7 +6459,7 @@ Nurb *add_nurbs_primitive(bContext *C, float mat[4][4], int type, int newob) a= nu->pntsu*nu->pntsv; bp= nu->bp; - while(a-- >0) { + while (a-- >0) { bp->f1 |= SELECT; bp++; } @@ -6418,7 +6467,7 @@ Nurb *add_nurbs_primitive(bContext *C, float mat[4][4], int type, int newob) } break; case CU_PRIM_DONUT: /* torus */ - if( cutype==CU_NURBS ) { + if ( cutype==CU_NURBS ) { float tmp_cent[3] = {0.f, 0.f, 0.f}; float tmp_vec[3] = {0.f, 0.f, 1.f}; @@ -6431,7 +6480,7 @@ Nurb *add_nurbs_primitive(bContext *C, float mat[4][4], int type, int newob) BLI_addtail(editnurb, nu); /* temporal for spin */ /* same as above */ - if(newob && (U.flag & USER_ADD_VIEWALIGNED) == 0) spin_nurb(umat, obedit, tmp_vec, tmp_cent); + if (newob && (U.flag & USER_ADD_VIEWALIGNED) == 0) spin_nurb(umat, obedit, tmp_vec, tmp_cent); else if ((U.flag & USER_ADD_VIEWALIGNED)) spin_nurb(viewmat, obedit, zvec, mat[3]); else spin_nurb(umat, obedit, tmp_vec, mat[3]); @@ -6440,7 +6489,7 @@ Nurb *add_nurbs_primitive(bContext *C, float mat[4][4], int type, int newob) a= nu->pntsu*nu->pntsv; bp= nu->bp; - while(a-- >0) { + while (a-- >0) { bp->f1 |= SELECT; bp++; } @@ -6455,7 +6504,7 @@ Nurb *add_nurbs_primitive(bContext *C, float mat[4][4], int type, int newob) BLI_assert(nu != NULL); - if(nu) { /* should always be set */ + if (nu) { /* should always be set */ nu->flag |= CU_SMOOTH; test2DNurb(nu); @@ -6475,11 +6524,11 @@ static int curvesurf_prim_add(bContext *C, wmOperator *op, int type, int isSurf) float loc[3], rot[3]; float mat[4][4]; - if(!ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer, &is_aligned)) + if (!ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer, &is_aligned)) return OPERATOR_CANCELLED; if (!isSurf) { /* adding curve */ - if(obedit==NULL || obedit->type!=OB_CURVE) { + if (obedit==NULL || obedit->type!=OB_CURVE) { Curve *cu; obedit= ED_object_add_type(C, OB_CURVE, loc, rot, TRUE, layer); @@ -6488,13 +6537,13 @@ static int curvesurf_prim_add(bContext *C, wmOperator *op, int type, int isSurf) cu= (Curve*)obedit->data; cu->flag |= CU_DEFORM_FILL; - if(type & CU_PRIM_PATH) + if (type & CU_PRIM_PATH) cu->flag |= CU_PATH|CU_3D; } else DAG_id_tag_update(&obedit->id, OB_RECALC_DATA); } else { /* adding surface */ - if(obedit==NULL || obedit->type!=OB_SURF) { + if (obedit==NULL || obedit->type!=OB_SURF) { obedit= ED_object_add_type(C, OB_SURF, loc, rot, TRUE, layer); newob = 1; } @@ -6502,9 +6551,9 @@ static int curvesurf_prim_add(bContext *C, wmOperator *op, int type, int isSurf) } /* rename here, the undo stack checks name for valid undo pushes */ - if(newob) { + if (newob) { - if(obedit->type==OB_CURVE) { + if (obedit->type==OB_CURVE) { rename_id((ID *)obedit, get_curve_defname(type)); rename_id((ID *)obedit->data, get_curve_defname(type)); } @@ -6515,7 +6564,7 @@ static int curvesurf_prim_add(bContext *C, wmOperator *op, int type, int isSurf) } /* ED_object_add_type doesnt do an undo, is needed for redo operator on primitive */ - if(newob && enter_editmode) + if (newob && enter_editmode) ED_undo_push(C, "Enter Editmode"); ED_object_new_primitive_matrix(C, obedit, loc, rot, mat); @@ -6812,20 +6861,20 @@ static int clear_tilt_exec(bContext *C, wmOperator *UNUSED(op)) BPoint *bp; int a; - for(nu= editnurb->first; nu; nu= nu->next) { - if( nu->bezt ) { + for (nu= editnurb->first; nu; nu= nu->next) { + if ( nu->bezt ) { bezt= nu->bezt; a= nu->pntsu; - while(a--) { - if(BEZSELECTED_HIDDENHANDLES(cu, bezt)) bezt->alfa= 0.0; + while (a--) { + if (BEZSELECTED_HIDDENHANDLES(cu, bezt)) bezt->alfa= 0.0; bezt++; } } - else if(nu->bp) { + else if (nu->bp) { bp= nu->bp; a= nu->pntsu*nu->pntsv; - while(a--) { - if(bp->f1 & SELECT) bp->alfa= 0.0; + while (a--) { + if (bp->f1 & SELECT) bp->alfa= 0.0; bp++; } } @@ -6860,7 +6909,8 @@ static void *undo_check_lastsel(void *lastsel, Nurb *nu, Nurb *newnu) if (lastbezt >= nu->bezt && lastbezt < nu->bezt + nu->pntsu) { return newnu->bezt + (lastbezt - nu->bezt); } - } else { + } + else { BPoint *lastbp= (BPoint*)lastsel; if (lastbp >= nu->bp && lastbp < nu->bp + nu->pntsu*nu->pntsv) { return newnu->bp + (lastbp - nu->bp); @@ -6888,8 +6938,8 @@ static void undoCurve_to_editCurve(void *ucu, void *UNUSED(edata), void *cu_v) editnurb->keyindex= dupli_keyIndexHash(undoCurve->undoIndex); } - if(ad) { - if(ad->action) { + if (ad) { + if (ad->action) { free_fcurves(&ad->action->curves); copy_fcurves(&ad->action->curves, &undoCurve->fcurves); } @@ -6899,7 +6949,7 @@ static void undoCurve_to_editCurve(void *ucu, void *UNUSED(edata), void *cu_v) } /* copy */ - for(nu= undobase->first; nu; nu= nu->next) { + for (nu= undobase->first; nu; nu= nu->next) { newnu= duplicateNurb(nu); if (lastsel == NULL) { @@ -6938,15 +6988,15 @@ static void *editCurve_to_undoCurve(void *UNUSED(edata), void *cu_v) tmpEditnurb.keyindex= undoCurve->undoIndex; } - if(ad) { - if(ad->action) + if (ad) { + if (ad->action) copy_fcurves(&undoCurve->fcurves, &ad->action->curves); copy_fcurves(&undoCurve->drivers, &ad->drivers); } /* copy */ - for(nu= nubase->first; nu; nu= nu->next) { + for (nu= nubase->first; nu; nu= nu->next) { newnu= duplicateNurb(nu); if (lastsel == NULL) { @@ -6972,7 +7022,7 @@ static void free_undoCurve(void *ucv) freeNurblist(&undoCurve->nubase); - if(undoCurve->undoIndex) + if (undoCurve->undoIndex) BLI_ghash_free(undoCurve->undoIndex, NULL, (GHashValFreeFP)MEM_freeN); free_fcurves(&undoCurve->fcurves); @@ -7009,10 +7059,10 @@ int ED_curve_actSelection(Curve *cu, float center[3]) { Nurb *nu= get_lastsel_nurb(cu); - if(!nu) + if (!nu) return 0; - if(nu->bezt) { + if (nu->bezt) { BezTriple *bezt= cu->lastsel; copy_v3_v3(center, bezt->vec[1]); diff --git a/source/blender/editors/curve/editfont.c b/source/blender/editors/curve/editfont.c index 7f31b34b367..1f1d1495276 100644 --- a/source/blender/editors/curve/editfont.c +++ b/source/blender/editors/curve/editfont.c @@ -82,130 +82,130 @@ static char findaccent(char char1, unsigned int code) { char new= 0; - if(char1=='a') { - if(code=='`') new= 224; - else if(code==39) new= 225; - else if(code=='^') new= 226; - else if(code=='~') new= 227; - else if(code=='"') new= 228; - else if(code=='o') new= 229; - else if(code=='e') new= 230; - else if(code=='-') new= 170; + if (char1=='a') { + if (code=='`') new= 224; + else if (code==39) new= 225; + else if (code=='^') new= 226; + else if (code=='~') new= 227; + else if (code=='"') new= 228; + else if (code=='o') new= 229; + else if (code=='e') new= 230; + else if (code=='-') new= 170; } - else if(char1=='c') { - if(code==',') new= 231; - if(code=='|') new= 162; + else if (char1=='c') { + if (code==',') new= 231; + if (code=='|') new= 162; } - else if(char1=='e') { - if(code=='`') new= 232; - else if(code==39) new= 233; - else if(code=='^') new= 234; - else if(code=='"') new= 235; + else if (char1=='e') { + if (code=='`') new= 232; + else if (code==39) new= 233; + else if (code=='^') new= 234; + else if (code=='"') new= 235; } - else if(char1=='i') { - if(code=='`') new= 236; - else if(code==39) new= 237; - else if(code=='^') new= 238; - else if(code=='"') new= 239; + else if (char1=='i') { + if (code=='`') new= 236; + else if (code==39) new= 237; + else if (code=='^') new= 238; + else if (code=='"') new= 239; } - else if(char1=='n') { - if(code=='~') new= 241; + else if (char1=='n') { + if (code=='~') new= 241; } - else if(char1=='o') { - if(code=='`') new= 242; - else if(code==39) new= 243; - else if(code=='^') new= 244; - else if(code=='~') new= 245; - else if(code=='"') new= 246; - else if(code=='/') new= 248; - else if(code=='-') new= 186; - else if(code=='e') new= 143; + else if (char1=='o') { + if (code=='`') new= 242; + else if (code==39) new= 243; + else if (code=='^') new= 244; + else if (code=='~') new= 245; + else if (code=='"') new= 246; + else if (code=='/') new= 248; + else if (code=='-') new= 186; + else if (code=='e') new= 143; } - else if(char1=='s') { - if(code=='s') new= 167; + else if (char1=='s') { + if (code=='s') new= 167; } - else if(char1=='u') { - if(code=='`') new= 249; - else if(code==39) new= 250; - else if(code=='^') new= 251; - else if(code=='"') new= 252; + else if (char1=='u') { + if (code=='`') new= 249; + else if (code==39) new= 250; + else if (code=='^') new= 251; + else if (code=='"') new= 252; } - else if(char1=='y') { - if(code==39) new= 253; - else if(code=='"') new= 255; + else if (char1=='y') { + if (code==39) new= 253; + else if (code=='"') new= 255; } - else if(char1=='A') { - if(code=='`') new= 192; - else if(code==39) new= 193; - else if(code=='^') new= 194; - else if(code=='~') new= 195; - else if(code=='"') new= 196; - else if(code=='o') new= 197; - else if(code=='e') new= 198; + else if (char1=='A') { + if (code=='`') new= 192; + else if (code==39) new= 193; + else if (code=='^') new= 194; + else if (code=='~') new= 195; + else if (code=='"') new= 196; + else if (code=='o') new= 197; + else if (code=='e') new= 198; } - else if(char1=='C') { - if(code==',') new= 199; + else if (char1=='C') { + if (code==',') new= 199; } - else if(char1=='E') { - if(code=='`') new= 200; - else if(code==39) new= 201; - else if(code=='^') new= 202; - else if(code=='"') new= 203; + else if (char1=='E') { + if (code=='`') new= 200; + else if (code==39) new= 201; + else if (code=='^') new= 202; + else if (code=='"') new= 203; } - else if(char1=='I') { - if(code=='`') new= 204; - else if(code==39) new= 205; - else if(code=='^') new= 206; - else if(code=='"') new= 207; + else if (char1=='I') { + if (code=='`') new= 204; + else if (code==39) new= 205; + else if (code=='^') new= 206; + else if (code=='"') new= 207; } - else if(char1=='N') { - if(code=='~') new= 209; + else if (char1=='N') { + if (code=='~') new= 209; } - else if(char1=='O') { - if(code=='`') new= 210; - else if(code==39) new= 211; - else if(code=='^') new= 212; - else if(code=='~') new= 213; - else if(code=='"') new= 214; - else if(code=='/') new= 216; - else if(code=='e') new= 141; + else if (char1=='O') { + if (code=='`') new= 210; + else if (code==39) new= 211; + else if (code=='^') new= 212; + else if (code=='~') new= 213; + else if (code=='"') new= 214; + else if (code=='/') new= 216; + else if (code=='e') new= 141; } - else if(char1=='U') { - if(code=='`') new= 217; - else if(code==39) new= 218; - else if(code=='^') new= 219; - else if(code=='"') new= 220; + else if (char1=='U') { + if (code=='`') new= 217; + else if (code==39) new= 218; + else if (code=='^') new= 219; + else if (code=='"') new= 220; } - else if(char1=='Y') { - if(code==39) new= 221; + else if (char1=='Y') { + if (code==39) new= 221; } - else if(char1=='1') { - if(code=='4') new= 188; - if(code=='2') new= 189; + else if (char1=='1') { + if (code=='4') new= 188; + if (code=='2') new= 189; } - else if(char1=='3') { - if(code=='4') new= 190; + else if (char1=='3') { + if (code=='4') new= 190; } - else if(char1==':') { - if(code=='-') new= 247; + else if (char1==':') { + if (code=='-') new= 247; } - else if(char1=='-') { - if(code==':') new= 247; - if(code=='|') new= 135; - if(code=='+') new= 177; + else if (char1=='-') { + if (code==':') new= 247; + if (code=='|') new= 135; + if (code=='+') new= 177; } - else if(char1=='|') { - if(code=='-') new= 135; - if(code=='=') new= 136; + else if (char1=='|') { + if (code=='-') new= 135; + if (code=='=') new= 136; } - else if(char1=='=') { - if(code=='|') new= 136; + else if (char1=='=') { + if (code=='|') new= 136; } - else if(char1=='+') { - if(code=='-') new= 177; + else if (char1=='+') { + if (code=='-') new= 177; } - if(new) return new; + if (new) return new; else return char1; } @@ -232,12 +232,12 @@ static int insert_into_textbuf(Object *obedit, uintptr_t c) { Curve *cu= obedit->data; - if(cu->lenleneditfont; int x; - for(x= cu->len; x>cu->pos; x--) ef->textbuf[x]= ef->textbuf[x-1]; - for(x= cu->len; x>cu->pos; x--) ef->textbufinfo[x]= ef->textbufinfo[x-1]; + for (x= cu->len; x>cu->pos; x--) ef->textbuf[x]= ef->textbuf[x-1]; + for (x= cu->len; x>cu->pos; x--) ef->textbufinfo[x]= ef->textbufinfo[x-1]; ef->textbuf[cu->pos]= c; ef->textbufinfo[cu->pos] = cu->curinfo; ef->textbufinfo[cu->pos].kern = 0; @@ -262,7 +262,7 @@ static void text_update_edited(bContext *C, Scene *scene, Object *obedit, int re EditFont *ef= cu->editfont; cu->curinfo = ef->textbufinfo[cu->pos?cu->pos-1:0]; - if(obedit->totcol > 0) { + if (obedit->totcol > 0) { obedit->actcol= ef->textbufinfo[cu->pos?cu->pos-1:0].mat_nr; /* since this array is calloc'd, it can be 0 even though we try ensure @@ -272,12 +272,12 @@ static void text_update_edited(bContext *C, Scene *scene, Object *obedit, int re } } - if(mode == FO_EDIT) + if (mode == FO_EDIT) update_string(cu); BKE_text_to_curve(bmain, scene, obedit, mode); - if(recalc) + if (recalc) DAG_id_tag_update(obedit->data, 0); WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data); } @@ -291,22 +291,22 @@ static int insert_lorem_exec(bContext *C, wmOperator *UNUSED(op)) int i; static const char *lastlorem; - if(lastlorem) + if (lastlorem) p= lastlorem; else p= ED_lorem; i= rand()/(RAND_MAX/6)+4; - for(p2=p; *p2 && i; p2++) { + for (p2=p; *p2 && i; p2++) { insert_into_textbuf(obedit, *p2); - if(*p2=='.') + if (*p2=='.') i--; } lastlorem = p2+1; - if(strlen(lastlorem)<5) + if (strlen(lastlorem)<5) lastlorem = ED_lorem; insert_into_textbuf(obedit, '\n'); @@ -350,8 +350,8 @@ static int paste_file(bContext *C, ReportList *reports, const char *filename) fp= BLI_fopen(filename, "r"); - if(!fp) { - if(reports) + if (!fp) { + if (reports) BKE_reportf(reports, RPT_ERROR, "Failed to open file %s", filename); return OPERATOR_CANCELLED; } @@ -368,7 +368,7 @@ static int paste_file(bContext *C, ReportList *reports, const char *filename) fclose(fp); strp[filelen]= 0; - if(cu->len+filelenlen+filelenptr, "filepath")) + if (RNA_struct_property_is_set(op->ptr, "filepath")) return paste_file_exec(C, op); WM_event_add_fileselect(C, op); @@ -452,11 +452,11 @@ static void txt_add_object(bContext *C, TextLine *firstline, int totline, float cu->vfont= get_builtin_font(); cu->vfont->id.us++; - for(tmp=firstline, a=0; cu->lennext, a++) + for (tmp=firstline, a=0; cu->lennext, a++) nchars += strlen(tmp->line) + 1; - if(cu->str) MEM_freeN(cu->str); - if(cu->strinfo) MEM_freeN(cu->strinfo); + if (cu->str) MEM_freeN(cu->str); + if (cu->strinfo) MEM_freeN(cu->strinfo); cu->str= MEM_callocN(nchars+4, "str"); cu->strinfo= MEM_callocN((nchars+4)*sizeof(CharInfo), "strinfo"); @@ -465,11 +465,11 @@ static void txt_add_object(bContext *C, TextLine *firstline, int totline, float cu->len= 0; cu->pos= 0; - for(tmp=firstline, a=0; cu->lennext, a++) { + for (tmp=firstline, a=0; cu->lennext, a++) { strcat(cu->str, tmp->line); cu->len+= strlen(tmp->line); - if(tmp->next) { + if (tmp->next) { strcat(cu->str, "\n"); cu->len++; } @@ -487,12 +487,12 @@ void ED_text_to_object(bContext *C, Text *text, int split_lines) float offset[3]; int linenum= 0; - if(!text || !text->lines.first) return; + if (!text || !text->lines.first) return; - if(split_lines) { - for(line=text->lines.first; line; line=line->next) { + if (split_lines) { + for (line=text->lines.first; line; line=line->next) { /* skip lines with no text, but still make space for them */ - if(line->line[0] == '\0') { + if (line->line[0] == '\0') { linenum++; continue; } @@ -502,7 +502,7 @@ void ED_text_to_object(bContext *C, Text *text, int split_lines) offset[1] = -linenum; offset[2] = 0; - if(rv3d) + if (rv3d) mul_mat3_m4_v3(rv3d->viewinv, offset); txt_add_object(C, line, 1, offset); @@ -524,19 +524,19 @@ void ED_text_to_object(bContext *C, Text *text, int split_lines) static short next_word(Curve *cu) { short s; - for(s=cu->pos; (cu->str[s]) && (cu->str[s]!=' ') && (cu->str[s]!='\n') && + for (s=cu->pos; (cu->str[s]) && (cu->str[s]!=' ') && (cu->str[s]!='\n') && (cu->str[s]!=1) && (cu->str[s]!='\r'); s++); - if(cu->str[s]) return(s+1); else return(s); + if (cu->str[s]) return(s+1); else return(s); } static short prev_word(Curve *cu) { short s; - if(cu->pos==0) return(0); - for(s=cu->pos-2; (cu->str[s]) && (cu->str[s]!=' ') && (cu->str[s]!='\n') && + if (cu->pos==0) return(0); + for (s=cu->pos-2; (cu->str[s]) && (cu->str[s]!=' ') && (cu->str[s]!='\n') && (cu->str[s]!=1) && (cu->str[s]!='\r'); s--); - if(cu->str[s]) return(s+1); else return(s); + if (cu->str[s]) return(s+1); else return(s); } static int kill_selection(Object *obedit, int ins) /* 1 == new character */ @@ -548,16 +548,16 @@ static int kill_selection(Object *obedit, int ins) /* 1 == new character */ int getfrom; direction = BKE_font_getselection(obedit, &selstart, &selend); - if(direction) { + if (direction) { int size; - if(ins) offset = 1; - if(cu->pos >= selstart) cu->pos = selstart+offset; - if((direction == -1) && ins) { + if (ins) offset = 1; + if (cu->pos >= selstart) cu->pos = selstart+offset; + if ((direction == -1) && ins) { selstart++; selend++; } getfrom = selend+offset; - if(ins==0) getfrom++; + if (ins==0) getfrom++; size = (cu->len * sizeof(wchar_t)) - (selstart * sizeof(wchar_t)) + (offset*sizeof(wchar_t)); memmove(ef->textbuf+selstart, ef->textbuf+getfrom, size); memmove(ef->textbufinfo+selstart, ef->textbufinfo+getfrom, ((cu->len-selstart)+offset)*sizeof(CharInfo)); @@ -584,11 +584,11 @@ static int set_style(bContext *C, const int style, const int clear) EditFont *ef= cu->editfont; int i, selstart, selend; - if(!BKE_font_getselection(obedit, &selstart, &selend)) + if (!BKE_font_getselection(obedit, &selstart, &selend)) return OPERATOR_CANCELLED; - for(i=selstart; i<=selend; i++) { - if(clear) + for (i=selstart; i<=selend; i++) { + if (clear) ef->textbufinfo[i].flag &= ~style; else ef->textbufinfo[i].flag |= style; @@ -635,7 +635,7 @@ static int toggle_style_exec(bContext *C, wmOperator *op) Curve *cu= obedit->data; int style, clear, selstart, selend; - if(!BKE_font_getselection(obedit, &selstart, &selend)) + if (!BKE_font_getselection(obedit, &selstart, &selend)) return OPERATOR_CANCELLED; style= RNA_enum_get(op->ptr, "style"); @@ -670,7 +670,7 @@ static void copy_selection(Object *obedit) { int selstart, selend; - if(BKE_font_getselection(obedit, &selstart, &selend)) { + if (BKE_font_getselection(obedit, &selstart, &selend)) { Curve *cu= obedit->data; EditFont *ef= cu->editfont; @@ -709,7 +709,7 @@ static int cut_text_exec(bContext *C, wmOperator *UNUSED(op)) Object *obedit= CTX_data_edit_object(C); int selstart, selend; - if(!BKE_font_getselection(obedit, &selstart, &selend)) + if (!BKE_font_getselection(obedit, &selstart, &selend)) return OPERATOR_CANCELLED; copy_selection(obedit); @@ -744,8 +744,8 @@ static int paste_selection(Object *obedit, ReportList *reports) int len= wcslen(ef->copybuf); // Verify that the copy buffer => [copy buffer len] + cu->len < MAXTEXT - if(cu->len + len <= MAXTEXT) { - if(len) { + if (cu->len + len <= MAXTEXT) { + if (len) { int size = (cu->len * sizeof(wchar_t)) - (cu->pos*sizeof(wchar_t)) + sizeof(wchar_t); memmove(ef->textbuf+cu->pos+len, ef->textbuf+cu->pos, size); memcpy(ef->textbuf+cu->pos, ef->copybuf, len * sizeof(wchar_t)); @@ -770,7 +770,7 @@ static int paste_text_exec(bContext *C, wmOperator *op) Scene *scene= CTX_data_scene(C); Object *obedit= CTX_data_edit_object(C); - if(!paste_selection(obedit, op->reports)) + if (!paste_selection(obedit, op->reports)) return OPERATOR_CANCELLED; text_update_edited(C, scene, obedit, 1, FO_EDIT); @@ -818,77 +818,77 @@ static int move_cursor(bContext *C, int type, int select) switch(type) { case LINE_BEGIN: - if((select) && (cu->selstart==0)) cu->selstart = cu->selend = cu->pos+1; - while(cu->pos>0) { - if(ef->textbuf[cu->pos-1]=='\n') break; - if(ef->textbufinfo[cu->pos-1].flag & CU_CHINFO_WRAP) break; + if ((select) && (cu->selstart==0)) cu->selstart = cu->selend = cu->pos+1; + while (cu->pos>0) { + if (ef->textbuf[cu->pos-1]=='\n') break; + if (ef->textbufinfo[cu->pos-1].flag & CU_CHINFO_WRAP) break; cu->pos--; } cursmove=FO_CURS; break; case LINE_END: - if((select) && (cu->selstart==0)) cu->selstart = cu->selend = cu->pos+1; - while(cu->poslen) { - if(ef->textbuf[cu->pos]==0) break; - if(ef->textbuf[cu->pos]=='\n') break; - if(ef->textbufinfo[cu->pos].flag & CU_CHINFO_WRAP ) break; + if ((select) && (cu->selstart==0)) cu->selstart = cu->selend = cu->pos+1; + while (cu->poslen) { + if (ef->textbuf[cu->pos]==0) break; + if (ef->textbuf[cu->pos]=='\n') break; + if (ef->textbufinfo[cu->pos].flag & CU_CHINFO_WRAP ) break; cu->pos++; } cursmove=FO_CURS; break; case PREV_WORD: - if((select) && (cu->selstart==0)) cu->selstart = cu->selend = cu->pos+1; + if ((select) && (cu->selstart==0)) cu->selstart = cu->selend = cu->pos+1; cu->pos= prev_word(cu); cursmove= FO_CURS; break; case NEXT_WORD: - if((select) && (cu->selstart==0)) cu->selstart = cu->selend = cu->pos+1; + if ((select) && (cu->selstart==0)) cu->selstart = cu->selend = cu->pos+1; cu->pos= next_word(cu); cursmove= FO_CURS; break; case PREV_CHAR: - if((select) && (cu->selstart==0)) cu->selstart = cu->selend = cu->pos+1; + if ((select) && (cu->selstart==0)) cu->selstart = cu->selend = cu->pos+1; cu->pos--; cursmove=FO_CURS; break; case NEXT_CHAR: - if((select) && (cu->selstart==0)) cu->selstart = cu->selend = cu->pos+1; + if ((select) && (cu->selstart==0)) cu->selstart = cu->selend = cu->pos+1; cu->pos++; cursmove= FO_CURS; break; case PREV_LINE: - if((select) && (cu->selstart==0)) cu->selstart = cu->selend = cu->pos+1; + if ((select) && (cu->selstart==0)) cu->selstart = cu->selend = cu->pos+1; cursmove=FO_CURSUP; break; case NEXT_LINE: - if((select) && (cu->selstart==0)) cu->selstart = cu->selend = cu->pos+1; + if ((select) && (cu->selstart==0)) cu->selstart = cu->selend = cu->pos+1; cursmove= FO_CURSDOWN; break; case PREV_PAGE: - if((select) && (cu->selstart==0)) cu->selstart = cu->selend = cu->pos+1; + if ((select) && (cu->selstart==0)) cu->selstart = cu->selend = cu->pos+1; cursmove=FO_PAGEUP; break; case NEXT_PAGE: - if((select) && (cu->selstart==0)) cu->selstart = cu->selend = cu->pos+1; + if ((select) && (cu->selstart==0)) cu->selstart = cu->selend = cu->pos+1; cursmove=FO_PAGEDOWN; break; } - if(cursmove == -1) + if (cursmove == -1) return OPERATOR_CANCELLED; - if(select == 0) { - if(cu->selstart) { + if (select == 0) { + if (cu->selstart) { struct Main *bmain= CTX_data_main(C); cu->selstart = cu->selend = 0; update_string(cu); @@ -896,13 +896,13 @@ static int move_cursor(bContext *C, int type, int select) } } - if(cu->pos>cu->len) cu->pos= cu->len; - else if(cu->pos>=MAXTEXT) cu->pos= MAXTEXT; - else if(cu->pos<0) cu->pos= 0; + if (cu->pos>cu->len) cu->pos= cu->len; + else if (cu->pos>=MAXTEXT) cu->pos= MAXTEXT; + else if (cu->pos<0) cu->pos= 0; text_update_edited(C, scene, obedit, select, cursmove); - if(select) + if (select) cu->selend = cu->pos; return OPERATOR_FINISHED; @@ -974,7 +974,7 @@ static int change_spacing_exec(bContext *C, wmOperator *op) kern += delta; CLAMP(kern, -20, 20); - if(ef->textbufinfo[cu->pos-1].kern == kern) + if (ef->textbufinfo[cu->pos-1].kern == kern) return OPERATOR_CANCELLED; ef->textbufinfo[cu->pos-1].kern = kern; @@ -1012,14 +1012,14 @@ static int change_character_exec(bContext *C, wmOperator *op) EditFont *ef= cu->editfont; int character, delta= RNA_int_get(op->ptr, "delta"); - if(cu->pos <= 0) + if (cu->pos <= 0) return OPERATOR_CANCELLED; character= ef->textbuf[cu->pos - 1]; character += delta; CLAMP(character, 0, 255); - if(character == ef->textbuf[cu->pos - 1]) + if (character == ef->textbuf[cu->pos - 1]) return OPERATOR_CANCELLED; ef->textbuf[cu->pos - 1]= character; @@ -1057,9 +1057,9 @@ static int line_break_exec(bContext *C, wmOperator *op) EditFont *ef= cu->editfont; const int ctrl= RNA_boolean_get(op->ptr, "ctrl"); - if(ctrl) { + if (ctrl) { insert_into_textbuf(obedit, 1); - if(ef->textbuf[cu->pos]!='\n') + if (ef->textbuf[cu->pos]!='\n') insert_into_textbuf(obedit, '\n'); } else @@ -1109,16 +1109,16 @@ static int delete_exec(bContext *C, wmOperator *op) EditFont *ef= cu->editfont; int x, selstart, selend, type= RNA_enum_get(op->ptr, "type"); - if(cu->len == 0) + if (cu->len == 0) return OPERATOR_CANCELLED; - if(BKE_font_getselection(obedit, &selstart, &selend)) { - if(type == DEL_NEXT_SEL) type= DEL_SELECTION; - else if(type == DEL_PREV_SEL) type= DEL_SELECTION; + if (BKE_font_getselection(obedit, &selstart, &selend)) { + if (type == DEL_NEXT_SEL) type= DEL_SELECTION; + else if (type == DEL_PREV_SEL) type= DEL_SELECTION; } else { - if(type == DEL_NEXT_SEL) type= DEL_NEXT_CHAR; - else if(type == DEL_PREV_SEL) type= DEL_PREV_CHAR; + if (type == DEL_NEXT_SEL) type= DEL_NEXT_CHAR; + else if (type == DEL_PREV_SEL) type= DEL_PREV_CHAR; } switch(type) { @@ -1127,28 +1127,28 @@ static int delete_exec(bContext *C, wmOperator *op) ef->textbuf[0]= 0; break; case DEL_SELECTION: - if(!kill_selection(obedit, 0)) + if (!kill_selection(obedit, 0)) return OPERATOR_CANCELLED; break; case DEL_PREV_CHAR: - if(cu->pos<=0) + if (cu->pos<=0) return OPERATOR_CANCELLED; - for(x=cu->pos;x<=cu->len;x++) + for (x=cu->pos;x<=cu->len;x++) ef->textbuf[x-1]= ef->textbuf[x]; - for(x=cu->pos;x<=cu->len;x++) + for (x=cu->pos;x<=cu->len;x++) ef->textbufinfo[x-1]= ef->textbufinfo[x]; cu->pos--; ef->textbuf[--cu->len]='\0'; break; case DEL_NEXT_CHAR: - if(cu->pos>=cu->len) + if (cu->pos>=cu->len) return OPERATOR_CANCELLED; - for(x=cu->pos;xlen;x++) + for (x=cu->pos;xlen;x++) ef->textbuf[x]= ef->textbuf[x+1]; - for(x=cu->pos;xlen;x++) + for (x=cu->pos;xlen;x++) ef->textbufinfo[x]= ef->textbufinfo[x+1]; ef->textbuf[--cu->len]='\0'; @@ -1190,7 +1190,7 @@ static int insert_text_exec(bContext *C, wmOperator *op) wchar_t *inserted_text; int a, len; - if(!RNA_struct_property_is_set(op->ptr, "text")) + if (!RNA_struct_property_is_set(op->ptr, "text")) return OPERATOR_CANCELLED; inserted_utf8= RNA_string_get_alloc(op->ptr, "text", NULL, 0); @@ -1199,7 +1199,7 @@ static int insert_text_exec(bContext *C, wmOperator *op) inserted_text= MEM_callocN(sizeof(wchar_t)*(len+1), "FONT_insert_text"); BLI_strncpy_wchar_from_utf8(inserted_text, inserted_utf8, len+1); - for(a=0; atype, val= evt->val; wchar_t inserted_text[2]= {0}; - if(RNA_struct_property_is_set(op->ptr, "text")) + if (RNA_struct_property_is_set(op->ptr, "text")) return insert_text_exec(C, op); - if(RNA_struct_property_is_set(op->ptr, "accent")) { - if(cu->len!=0 && cu->pos>0) + if (RNA_struct_property_is_set(op->ptr, "accent")) { + if (cu->len!=0 && cu->pos>0) accentcode= 1; return OPERATOR_FINISHED; } /* tab should exit editmode, but we allow it to be typed using modifier keys */ - if(event==TABKEY) { - if((alt||ctrl||shift) == 0) + if (event==TABKEY) { + if ((alt||ctrl||shift) == 0) return OPERATOR_PASS_THROUGH; else ascii= 9; } - else if(event==BACKSPACEKEY) + else if (event==BACKSPACEKEY) ascii= 0; - if(val && (ascii || evt->utf8_buf[0])) { + if (val && (ascii || evt->utf8_buf[0])) { /* handle case like TAB (== 9) */ - if( (ascii > 31 && ascii < 254 && ascii != 127) || + if ( (ascii > 31 && ascii < 254 && ascii != 127) || (ascii==13) || (ascii==10) || (ascii==8) || @@ -1257,34 +1257,34 @@ static int insert_text_invoke(bContext *C, wmOperator *op, wmEvent *evt) insert_into_textbuf(obedit, ascii); accentcode= 0; } - else if(accentcode) { - if(cu->pos>0) { + else if (accentcode) { + if (cu->pos>0) { inserted_text[0]= findaccent(ef->textbuf[cu->pos-1], ascii); ef->textbuf[cu->pos-1]= inserted_text[0]; } accentcode= 0; } - else if(cu->lenlen') ascii= 187; - else if(ascii=='<') ascii= 171; + if (ascii=='t') ascii= 137; + else if (ascii=='c') ascii= 169; + else if (ascii=='f') ascii= 164; + else if (ascii=='g') ascii= 176; + else if (ascii=='l') ascii= 163; + else if (ascii=='r') ascii= 174; + else if (ascii=='s') ascii= 223; + else if (ascii=='y') ascii= 165; + else if (ascii=='.') ascii= 138; + else if (ascii=='1') ascii= 185; + else if (ascii=='2') ascii= 178; + else if (ascii=='3') ascii= 179; + else if (ascii=='%') ascii= 139; + else if (ascii=='?') ascii= 191; + else if (ascii=='!') ascii= 161; + else if (ascii=='x') ascii= 215; + else if (ascii=='>') ascii= 187; + else if (ascii=='<') ascii= 171; } inserted_text[0]= ascii; @@ -1300,8 +1300,8 @@ static int insert_text_invoke(bContext *C, wmOperator *op, wmEvent *evt) text_update_edited(C, scene, obedit, 1, FO_EDIT); } } - else if(val && event == BACKSPACEKEY) { - if(alt && cu->len!=0 && cu->pos>0) + else if (val && event == BACKSPACEKEY) { + if (alt && cu->len!=0 && cu->pos>0) accentcode= 1; return OPERATOR_PASS_THROUGH; @@ -1309,7 +1309,7 @@ static int insert_text_invoke(bContext *C, wmOperator *op, wmEvent *evt) else return OPERATOR_PASS_THROUGH; - if(inserted_text[0]) { + if (inserted_text[0]) { /* store as utf8 in RNA string */ char inserted_utf8[8] = {0}; @@ -1431,7 +1431,7 @@ void make_editText(Object *obedit) Curve *cu= obedit->data; EditFont *ef= cu->editfont; - if(ef==NULL) { + if (ef==NULL) { ef= cu->editfont= MEM_callocN(sizeof(EditFont), "editfont"); ef->textbuf= MEM_callocN((MAXTEXT+4)*sizeof(wchar_t), "texteditbuf"); @@ -1451,9 +1451,9 @@ void make_editText(Object *obedit) memcpy(ef->textbufinfo, cu->strinfo, (cu->len)*sizeof(CharInfo)); memcpy(ef->oldstrinfo, cu->strinfo, (cu->len)*sizeof(CharInfo)); - if(cu->pos>cu->len) cu->pos= cu->len; + if (cu->pos>cu->len) cu->pos= cu->len; - if(cu->pos) + if (cu->pos) cu->curinfo = ef->textbufinfo[cu->pos-1]; else cu->curinfo = ef->textbufinfo[0]; @@ -1474,7 +1474,7 @@ void load_editText(Object *obedit) update_string(cu); - if(cu->strinfo) + if (cu->strinfo) MEM_freeN(cu->strinfo); cu->strinfo= MEM_callocN((cu->len+4)*sizeof(CharInfo), "texteditinfo"); memcpy(cu->strinfo, ef->textbufinfo, (cu->len)*sizeof(CharInfo)); @@ -1483,7 +1483,7 @@ void load_editText(Object *obedit) /* this memory system is weak... */ - if(cu->selboxes) { + if (cu->selboxes) { MEM_freeN(cu->selboxes); cu->selboxes= NULL; } @@ -1512,18 +1512,18 @@ static int set_case(bContext *C, int ccase) len= wcslen(ef->textbuf); str= ef->textbuf; - while(len) { - if(*str>='a' && *str<='z') + while (len) { + if (*str>='a' && *str<='z') *str-= 32; len--; str++; } - if(ccase == CASE_LOWER) { + if (ccase == CASE_LOWER) { len= wcslen(ef->textbuf); str= ef->textbuf; - while(len) { - if(*str>='A' && *str<='Z') { + while (len) { + if (*str>='A' && *str<='Z') { *str+= 32; } len--; @@ -1571,8 +1571,8 @@ static int toggle_case_exec(bContext *C, wmOperator *UNUSED(op)) len= wcslen(ef->textbuf); str= ef->textbuf; - while(len) { - if(*str>='a' && *str<='z') { + while (len) { + if (*str>='a' && *str<='z') { ccase= CASE_LOWER; break; } @@ -1627,18 +1627,18 @@ static int font_open_exec(bContext *C, wmOperator *op) font= load_vfont(bmain, filepath); - if(!font) { - if(op->customdata) MEM_freeN(op->customdata); + if (!font) { + if (op->customdata) MEM_freeN(op->customdata); return OPERATOR_CANCELLED; } - if(!op->customdata) + if (!op->customdata) font_ui_template_init(C, op); /* hook into UI */ pprop= op->customdata; - if(pprop->prop) { + if (pprop->prop) { /* when creating new ID blocks, use is already 1, but RNA * pointer se also increases user, so this compensates it */ font->id.us--; @@ -1666,14 +1666,14 @@ static int open_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) /* hook into UI */ pprop= op->customdata; - if(pprop->prop) { + if (pprop->prop) { idptr= RNA_property_pointer_get((PointerRNA *)pprop, pprop->prop); font= idptr.id.data; } path = (font && strcmp(font->name, FO_BUILTIN_NAME) != 0)? font->name: U.fontdir; - if(RNA_struct_property_is_set(op->ptr, "filepath")) + if (RNA_struct_property_is_set(op->ptr, "filepath")) return font_open_exec(C, op); RNA_string_set(op->ptr, "filepath", path); @@ -1711,7 +1711,7 @@ static int font_unlink_exec(bContext *C, wmOperator *op) uiIDContextProperty(C, &pprop.ptr, &pprop.prop); - if(pprop.prop==NULL) { + if (pprop.prop==NULL) { BKE_report(op->reports, RPT_ERROR, "Incorrect context for running font unlink"); return OPERATOR_CANCELLED; } @@ -1783,7 +1783,7 @@ static void free_undoFont(void *strv) static void *get_undoFont(bContext *C) { Object *obedit= CTX_data_edit_object(C); - if(obedit && obedit->type==OB_FONT) { + if (obedit && obedit->type==OB_FONT) { return obedit->data; } return NULL; diff --git a/source/blender/editors/gpencil/editaction_gpencil.c b/source/blender/editors/gpencil/editaction_gpencil.c index 36f78e151d5..3b0847c2e0f 100644 --- a/source/blender/editors/gpencil/editaction_gpencil.c +++ b/source/blender/editors/gpencil/editaction_gpencil.c @@ -589,7 +589,7 @@ static short mirror_gpf_marker (bGPDframe *gpf, Scene *scene) else { /* try to find a marker */ marker= ED_markers_get_first_selected(&scene->markers); - if(marker) { + if (marker) { initialized= 1; } } diff --git a/source/blender/editors/gpencil/gpencil_edit.c b/source/blender/editors/gpencil/gpencil_edit.c index 34eaaf2a31b..ced7dab91f4 100644 --- a/source/blender/editors/gpencil/gpencil_edit.c +++ b/source/blender/editors/gpencil/gpencil_edit.c @@ -143,7 +143,7 @@ bGPdata **gpencil_data_get_pointers (bContext *C, PointerRNA *ptr) SpaceClip *sc= (SpaceClip *)CTX_wm_space_data(C); MovieClip *clip= ED_space_clip(sc); - if(clip) { + if (clip) { /* for now, as long as there's a clip, default to using that in Clip Editor */ if (ptr) RNA_id_pointer_create(&clip->id, ptr); return &clip->gpd; @@ -402,7 +402,7 @@ static void gp_strokepoint_convertcoords (bContext *C, bGPDstroke *gps, bGPDspoi VECCOPY2D(mvalf, mvali); } else { - if(subrect) { + if (subrect) { mvalf[0]= (((float)pt->x/100.0f) * (subrect->xmax - subrect->xmin)) + subrect->xmin; mvalf[1]= (((float)pt->y/100.0f) * (subrect->ymax - subrect->ymin)) + subrect->ymin; } @@ -561,7 +561,7 @@ static void gp_layer_to_curve (bContext *C, bGPdata *gpd, bGPDlayer *gpl, short return; /* initialize camera framing */ - if(gp_camera_view_subrect(C, &subrect)) { + if (gp_camera_view_subrect(C, &subrect)) { subrect_ptr= &subrect; } diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c index 4dee4c44694..b21c059fcc1 100644 --- a/source/blender/editors/gpencil/gpencil_paint.c +++ b/source/blender/editors/gpencil/gpencil_paint.c @@ -902,7 +902,7 @@ static void gp_stroke_eraser_dostroke (tGPsdata *p, int mval[], int mvalo[], sho } #endif else { - if(p->subrect == NULL) { /* normal 3D view */ + if (p->subrect == NULL) { /* normal 3D view */ x0= (int)(pt1->x / 100 * p->ar->winx); y0= (int)(pt1->y / 100 * p->ar->winy); x1= (int)(pt2->x / 100 * p->ar->winx); @@ -1204,7 +1204,7 @@ static void gp_paint_initstroke (tGPsdata *p, short paintmode) if (p->gpl == NULL) { p->gpl= gpencil_layer_addnew(p->gpd); - if(p->custom_color[3]) + if (p->custom_color[3]) copy_v3_v3(p->gpl->color, p->custom_color); } if (p->gpl->flag & GP_LAYER_LOCKED) { @@ -1756,7 +1756,7 @@ static tGPsdata *gpencil_stroke_begin(bContext *C, wmOperator *op) if (gp_session_initdata(C, p)) gp_paint_initstroke(p, p->paintmode); - if(p->status != GP_STATUS_ERROR) + if (p->status != GP_STATUS_ERROR) p->status= GP_STATUS_PAINTING; return op->customdata; diff --git a/source/blender/editors/gpencil/gpencil_undo.c b/source/blender/editors/gpencil/gpencil_undo.c index 1ab00082043..36624b88a9f 100644 --- a/source/blender/editors/gpencil/gpencil_undo.c +++ b/source/blender/editors/gpencil/gpencil_undo.c @@ -69,10 +69,10 @@ int ED_undo_gpencil_step(bContext *C, int step, const char *name) gpd_ptr= gpencil_data_get_pointers(C, NULL); - if(step==1) { /* undo */ + if (step==1) { /* undo */ //printf("\t\tGP - undo step\n"); - if(cur_node->prev) { - if(!name || strcmp(cur_node->name, name) == 0) { + if (cur_node->prev) { + if (!name || strcmp(cur_node->name, name) == 0) { cur_node= cur_node->prev; new_gpd= cur_node->gpd; } @@ -80,17 +80,17 @@ int ED_undo_gpencil_step(bContext *C, int step, const char *name) } else if (step==-1) { //printf("\t\tGP - redo step\n"); - if(cur_node->next) { - if(!name || strcmp(cur_node->name, name) == 0) { + if (cur_node->next) { + if (!name || strcmp(cur_node->name, name) == 0) { cur_node= cur_node->next; new_gpd= cur_node->gpd; } } } - if(new_gpd) { - if(gpd_ptr) { - if(*gpd_ptr) { + if (new_gpd) { + if (gpd_ptr) { + if (*gpd_ptr) { bGPdata *gpd= *gpd_ptr; bGPDlayer *gpl, *gpld; @@ -124,11 +124,11 @@ void gpencil_undo_push(bGPdata *gpd) //printf("\t\tGP - undo push\n"); - if(cur_node) { + if (cur_node) { /* remove all un-done nodes from stack */ undo_node= cur_node->next; - while(undo_node) { + while (undo_node) { bGPundonode *next_node= undo_node->next; free_gpencil_data(undo_node->gpd); @@ -153,7 +153,7 @@ void gpencil_undo_finish(void) { bGPundonode *undo_node= undo_nodes.first; - while(undo_node) { + while (undo_node) { free_gpencil_data(undo_node->gpd); MEM_freeN(undo_node->gpd); diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index 229a9dea471..b9002648709 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -107,7 +107,7 @@ void ui_block_to_window_fl(const ARegion *ar, uiBlock *block, float *x, float *y gx= *x; gy= *y; - if(block->panel) { + if (block->panel) { gx += block->panel->ofsx; gy += block->panel->ofsy; } @@ -167,7 +167,7 @@ void ui_window_to_block_fl(const ARegion *ar, uiBlock *block, float *x, float *y *y= (a*(py-f) + d*(c-px))/(a*e-d*b); *x= (px- b*(*y)- c)/a; - if(block->panel) { + if (block->panel) { *x -= block->panel->ofsx; *y -= block->panel->ofsy; } @@ -198,7 +198,7 @@ void ui_block_translate(uiBlock *block, int x, int y) { uiBut *bt; - for(bt= block->buttons.first; bt; bt=bt->next) { + for (bt= block->buttons.first; bt; bt=bt->next) { bt->x1 += x; bt->y1 += y; bt->x2 += x; @@ -220,21 +220,21 @@ static void ui_text_bounds_block(uiBlock *block, float offset) uiStyleFontSet(&style->widget); - for(bt= block->buttons.first; bt; bt= bt->next) { - if(bt->type!=SEPR) { + for (bt= block->buttons.first; bt; bt= bt->next) { + if (bt->type!=SEPR) { j= BLF_width(style->widget.uifont_id, bt->drawstr); - if(j > i) i = j; + if (j > i) i = j; } - if(bt->next && bt->x1 < bt->next->x1) + if (bt->next && bt->x1 < bt->next->x1) lastcol++; } /* cope with multi collumns */ bt= block->buttons.first; - while(bt) { - if(bt->next && bt->x1 < bt->next->x1) { + while (bt) { + if (bt->next && bt->x1 < bt->next->x1) { nextcol= 1; col++; } @@ -243,12 +243,12 @@ static void ui_text_bounds_block(uiBlock *block, float offset) bt->x1 = x1addval; bt->x2 = bt->x1 + i + block->bounds; - if(col == lastcol) + if (col == lastcol) bt->x2= MAX2(bt->x2, offset + block->minbounds); ui_check_but(bt); // clips text again - if(nextcol) + if (nextcol) x1addval+= i + block->bounds; bt= bt->next; @@ -260,8 +260,8 @@ void ui_bounds_block(uiBlock *block) uiBut *bt; int xof; - if(block->buttons.first==NULL) { - if(block->panel) { + if (block->buttons.first==NULL) { + if (block->panel) { block->minx= 0.0; block->maxx= block->panel->sizex; block->miny= 0.0; block->maxy= block->panel->sizey; } @@ -272,12 +272,12 @@ void ui_bounds_block(uiBlock *block) block->maxx= block->maxy= -10000; bt= block->buttons.first; - while(bt) { - if(bt->x1 < block->minx) block->minx= bt->x1; - if(bt->y1 < block->miny) block->miny= bt->y1; + while (bt) { + if (bt->x1 < block->minx) block->minx= bt->x1; + if (bt->y1 < block->miny) block->miny= bt->y1; - if(bt->x2 > block->maxx) block->maxx= bt->x2; - if(bt->y2 > block->maxy) block->maxy= bt->y2; + if (bt->x2 > block->maxx) block->maxx= bt->x2; + if (bt->y2 > block->maxy) block->maxy= bt->y2; bt= bt->next; } @@ -292,7 +292,7 @@ void ui_bounds_block(uiBlock *block) /* hardcoded exception... but that one is annoying with larger safety */ bt= block->buttons.first; - if(bt && strncmp(bt->str, "ERROR", 5)==0) xof= 10; + if (bt && strncmp(bt->str, "ERROR", 5)==0) xof= 10; else xof= 40; block->safety.xmin = block->minx-xof; @@ -345,8 +345,8 @@ static void ui_popup_bounds_block(const bContext *C, uiBlock *block, int bounds_ oldheight= block->maxy - block->miny; /* first we ensure wide enough text bounds */ - if(bounds_calc==UI_BLOCK_BOUNDS_POPUP_MENU) { - if(block->flag & UI_BLOCK_LOOP) { + if (bounds_calc==UI_BLOCK_BOUNDS_POPUP_MENU) { + if (block->flag & UI_BLOCK_LOOP) { block->bounds= 50; ui_text_bounds_block(block, block->minx); } @@ -369,19 +369,19 @@ static void ui_popup_bounds_block(const bContext *C, uiBlock *block, int bounds_ startx= window->eventstate->x + block->minx + (block->mx*width)/oldwidth; starty= window->eventstate->y + block->miny + (block->my*height)/oldheight; - if(startx<10) + if (startx<10) startx= 10; - if(starty<10) + if (starty<10) starty= 10; endx= startx+width; endy= starty+height; - if(endx>xmax) { + if (endx>xmax) { endx= xmax-10; startx= endx-width; } - if(endy>ymax-20) { + if (endy>ymax-20) { endy= ymax-20; starty= endy-height; } @@ -395,7 +395,7 @@ static void ui_popup_bounds_block(const bContext *C, uiBlock *block, int bounds_ /* used for various cases */ void uiBoundsBlock(uiBlock *block, int addval) { - if(block==NULL) + if (block==NULL) return; block->bounds= addval; @@ -452,7 +452,7 @@ static int ui_but_float_precision(uiBut *but, double value) int prec; /* first check if prec is 0 and fallback to a simple default */ - if((prec= (int)but->a2) == 0) { + if ((prec= (int)but->a2) == 0) { prec= (but->hardmax < 10.001f) ? 3 : 2; } @@ -460,16 +460,16 @@ static int ui_but_float_precision(uiBut *but, double value) * the number, this is so 0.00001 is not displayed as 0.00, * _but_, this is only for small values si 10.0001 will not get * the same treatment */ - if(value != 0.0 && (value= ABS(value)) < 0.1) { + if (value != 0.0 && (value= ABS(value)) < 0.1) { int value_i= (int)((value * PRECISION_FLOAT_MAX_POW) + 0.5); - if(value_i != 0) { + if (value_i != 0) { const int prec_span= 3; /* show: 0.01001, 5 would allow 0.0100001 for eg. */ int test_prec; int prec_min= -1; int dec_flag= 0; int i= PRECISION_FLOAT_MAX; - while(i && value_i) { - if(value_i % 10) { + while (i && value_i) { + if (value_i % 10) { dec_flag |= 1<> (prec_min + 1)) & ((1 << prec_span) - 1); - while(dec_flag) { + while (dec_flag) { test_prec++; dec_flag = dec_flag >> 1; } - if(test_prec > prec) { + if (test_prec > prec) { prec= test_prec; } } @@ -502,14 +502,14 @@ static void ui_draw_linkline(uiLinkLine *line) { rcti rect; - if(line->from==NULL || line->to==NULL) return; + if (line->from==NULL || line->to==NULL) return; rect.xmin = (line->from->x1+line->from->x2)/2.0f; rect.ymin = (line->from->y1+line->from->y2)/2.0f; rect.xmax = (line->to->x1+line->to->x2)/2.0f; rect.ymax = (line->to->y1+line->to->y2)/2.0f; - if(line->flag & UI_SELECT) + if (line->flag & UI_SELECT) glColor3ub(100,100,100); else glColor3ub(0,0,0); @@ -523,10 +523,10 @@ static void ui_draw_links(uiBlock *block) uiLinkLine *line; but= block->buttons.first; - while(but) { - if(but->type==LINK && but->link) { + while (but) { + if (but->type==LINK && but->link) { line= but->link->lines.first; - while(line) { + while (line) { ui_draw_linkline(line); line= line->next; } @@ -542,16 +542,16 @@ static int ui_but_equals_old(uiBut *but, uiBut *oldbut) { /* various properties are being compared here, hopefully sufficient * to catch all cases, but it is simple to add more checks later */ - if(but->retval != oldbut->retval) return 0; - if(but->rnapoin.data != oldbut->rnapoin.data) return 0; - if(but->rnaprop != oldbut->rnaprop) - if(but->rnaindex != oldbut->rnaindex) return 0; - if(but->func != oldbut->func) return 0; - if(but->funcN != oldbut->funcN) return 0; - if(oldbut->func_arg1 != oldbut && but->func_arg1 != oldbut->func_arg1) return 0; - if(oldbut->func_arg2 != oldbut && but->func_arg2 != oldbut->func_arg2) return 0; - if(!but->funcN && ((but->poin != oldbut->poin && (uiBut*)oldbut->poin != oldbut) || but->pointype != oldbut->pointype)) return 0; - if(but->optype != oldbut->optype) return 0; + if (but->retval != oldbut->retval) return 0; + if (but->rnapoin.data != oldbut->rnapoin.data) return 0; + if (but->rnaprop != oldbut->rnaprop) + if (but->rnaindex != oldbut->rnaindex) return 0; + if (but->func != oldbut->func) return 0; + if (but->funcN != oldbut->funcN) return 0; + if (oldbut->func_arg1 != oldbut && but->func_arg1 != oldbut->func_arg1) return 0; + if (oldbut->func_arg2 != oldbut && but->func_arg2 != oldbut->func_arg2) return 0; + if (!but->funcN && ((but->poin != oldbut->poin && (uiBut*)oldbut->poin != oldbut) || but->pointype != oldbut->pointype)) return 0; + if (but->optype != oldbut->optype) return 0; return 1; } @@ -563,25 +563,25 @@ static void ui_but_update_linklines(uiBlock *block, uiBut *oldbut, uiBut *newbut uiBut *but; /* if active button is LINK */ - if(newbut->type==LINK && newbut->link) { + if (newbut->type==LINK && newbut->link) { SWAP(uiLink *, oldbut->link, newbut->link); - for(line= oldbut->link->lines.first; line; line= line->next) { - if(line->to==newbut) + for (line= oldbut->link->lines.first; line; line= line->next) { + if (line->to==newbut) line->to= oldbut; - if(line->from==newbut) + if (line->from==newbut) line->from= oldbut; } } /* check all other button links */ - for(but= block->buttons.first; but; but= but->next) { - if(but!=newbut && but->type==LINK && but->link) { - for(line= but->link->lines.first; line; line= line->next) { - if(line->to==newbut) + for (but= block->buttons.first; but; but= but->next) { + if (but!=newbut && but->type==LINK && but->link) { + for (line= but->link->lines.first; line; line= line->next) { + if (line->to==newbut) line->to= oldbut; - if(line->from==newbut) + if (line->from==newbut) line->from= oldbut; } } @@ -595,12 +595,12 @@ static int ui_but_update_from_old_block(const bContext *C, uiBlock *block, uiBut int found= 0; oldblock= block->oldblock; - if(!oldblock) + if (!oldblock) return found; - for(oldbut=oldblock->buttons.first; oldbut; oldbut=oldbut->next) { - if(ui_but_equals_old(oldbut, but)) { - if(oldbut->active) { + for (oldbut=oldblock->buttons.first; oldbut; oldbut=oldbut->next) { + if (ui_but_equals_old(oldbut, but)) { + if (oldbut->active) { #if 0 // but->flag= oldbut->flag; #else @@ -638,14 +638,14 @@ static int ui_but_update_from_old_block(const bContext *C, uiBlock *block, uiBut /* typically the same pointers, but not on undo/redo */ /* XXX some menu buttons store button itself in but->poin. Ugly */ - if(oldbut->poin != (char *)oldbut) { + if (oldbut->poin != (char *)oldbut) { SWAP(char *, oldbut->poin, but->poin) SWAP(void *, oldbut->func_argN, but->func_argN) } /* copy hardmin for list rows to prevent 'sticking' highlight to mouse position * when scrolling without moving mouse (see [#28432]) */ - if(ELEM(oldbut->type, ROW, LISTROW)) + if (ELEM(oldbut->type, ROW, LISTROW)) oldbut->hardmax= but->hardmax; ui_but_update_linklines(block, oldbut, but); @@ -679,24 +679,24 @@ int uiButActiveOnly(const bContext *C, uiBlock *block, uiBut *but) int activate= 0, found= 0, isactive= 0; oldblock= block->oldblock; - if(!oldblock) + if (!oldblock) activate= 1; else { - for(oldbut=oldblock->buttons.first; oldbut; oldbut=oldbut->next) { - if(ui_but_equals_old(oldbut, but)) { + for (oldbut=oldblock->buttons.first; oldbut; oldbut=oldbut->next) { + if (ui_but_equals_old(oldbut, but)) { found= 1; - if(oldbut->active) + if (oldbut->active) isactive= 1; break; } } } - if(activate || found==0) { + if (activate || found==0) { ui_button_activate_do( (bContext *)C, CTX_wm_region(C), but); } - else if(found && isactive==0) { + else if (found && isactive==0) { BLI_remlink(&block->buttons, but); ui_free_but(C, but); @@ -710,13 +710,13 @@ int uiButActiveOnly(const bContext *C, uiBlock *block, uiBut *but) * returns FALSE if undo needs to be disabled. */ static int ui_but_is_rna_undo(uiBut *but) { - if(but->rnapoin.id.data) { + if (but->rnapoin.id.data) { /* avoid undo push for buttons who's ID are screen or wm level * we could disable undo for buttons with no ID too but may have * unforeseen consequences, so best check for ID's we _know_ are not * handled by undo - campbell */ ID *id= but->rnapoin.id.data; - if(ID_CHECK_UNDO(id) == FALSE) { + if (ID_CHECK_UNDO(id) == FALSE) { return FALSE; } else { @@ -743,32 +743,32 @@ static void ui_menu_block_set_keyaccels(uiBlock *block) int tot_missing= 0; /* only do it before bounding */ - if(block->minx != block->maxx) + if (block->minx != block->maxx) return; - for(pass=0; pass<2; pass++) { + for (pass=0; pass<2; pass++) { /* 2 Passes, on for first letter only, second for any letter if first fails * fun first pass on all buttons so first word chars always get first priority */ - for(but=block->buttons.first; but; but=but->next) { - if(!ELEM4(but->type, BUT, MENU, BLOCK, PULLDOWN) || (but->flag & UI_HIDDEN)) { + for (but=block->buttons.first; but; but=but->next) { + if (!ELEM4(but->type, BUT, MENU, BLOCK, PULLDOWN) || (but->flag & UI_HIDDEN)) { /* pass */ } - else if(but->menu_key=='\0') { - if(but->str) { - for(str_pt= but->str; *str_pt; ) { + else if (but->menu_key=='\0') { + if (but->str) { + for (str_pt= but->str; *str_pt; ) { menu_key= tolower(*str_pt); - if((menu_key >= 'a' && menu_key <= 'z') && !(menu_key_mask & 1<<(menu_key-'a'))) { + if ((menu_key >= 'a' && menu_key <= 'z') && !(menu_key_mask & 1<<(menu_key-'a'))) { menu_key_mask |= 1<<(menu_key-'a'); break; } - if(pass==0) { + if (pass==0) { /* Skip to next delimiter on first pass (be picky) */ - while(isalpha(*str_pt)) + while (isalpha(*str_pt)) str_pt++; - if(*str_pt) + if (*str_pt) str_pt++; } else { @@ -777,7 +777,7 @@ static void ui_menu_block_set_keyaccels(uiBlock *block) } } - if(*str_pt) { + if (*str_pt) { but->menu_key= menu_key; } else { @@ -786,7 +786,7 @@ static void ui_menu_block_set_keyaccels(uiBlock *block) } /* if all keys have been used just exit, unlikely */ - if(menu_key_mask == (1<<26)-1) { + if (menu_key_mask == (1<<26)-1) { return; } } @@ -794,7 +794,7 @@ static void ui_menu_block_set_keyaccels(uiBlock *block) } /* check if second pass is needed */ - if(!tot_missing) { + if (!tot_missing) { break; } } @@ -808,7 +808,7 @@ void ui_but_add_shortcut(uiBut *but, const char *shortcut_str, const short do_st if (do_strip) { char *cpoin= strchr(but->str, '|'); - if(cpoin) { + if (cpoin) { *cpoin= '\0'; } } @@ -844,14 +844,14 @@ static void ui_menu_block_set_keymaps(const bContext *C, uiBlock *block) IDProperty *prop_menu_name= NULL; /* only do it before bounding */ - if(block->minx != block->maxx) + if (block->minx != block->maxx) return; - for(but=block->buttons.first; but; but=but->next) { - if(but->optype) { + for (but=block->buttons.first; but; but=but->next) { + if (but->optype) { IDProperty *prop= (but->opptr)? but->opptr->data: NULL; - if(WM_key_event_operator_string(C, but->optype->idname, but->opcontext, prop, TRUE, + if (WM_key_event_operator_string(C, but->optype->idname, but->opcontext, prop, TRUE, buf, sizeof(buf))) { ui_but_add_shortcut(but, buf, FALSE); @@ -868,7 +868,7 @@ static void ui_menu_block_set_keymaps(const bContext *C, uiBlock *block) IDP_AssignString(prop_menu_name, mt->idname, sizeof(mt->idname)); - if(WM_key_event_operator_string(C, "WM_OT_call_menu", WM_OP_INVOKE_REGION_WIN, prop_menu, FALSE, + if (WM_key_event_operator_string(C, "WM_OT_call_menu", WM_OP_INVOKE_REGION_WIN, prop_menu, FALSE, buf, sizeof(buf))) { ui_but_add_shortcut(but, buf, FALSE); @@ -894,30 +894,30 @@ void uiEndBlock(const bContext *C, uiBlock *block) * on matching buttons, we need this to make button event handling non * blocking, while still allowing buttons to be remade each redraw as it * is expected by blender code */ - for(but=block->buttons.first; but; but=but->next) { - if(ui_but_update_from_old_block(C, block, &but)) + for (but=block->buttons.first; but; but=but->next) { + if (ui_but_update_from_old_block(C, block, &but)) ui_check_but(but); /* temp? Proper check for greying out */ - if(but->optype) { + if (but->optype) { wmOperatorType *ot= but->optype; - if(but->context) + if (but->context) CTX_store_set((bContext*)C, but->context); - if(ot == NULL || WM_operator_poll_context((bContext*)C, ot, but->opcontext)==0) { + if (ot == NULL || WM_operator_poll_context((bContext*)C, ot, but->opcontext)==0) { but->flag |= UI_BUT_DISABLED; but->lock = 1; } - if(but->context) + if (but->context) CTX_store_set((bContext*)C, NULL); } ui_but_anim_flag(but, (scene)? scene->r.cfra: 0.0f); } - if(block->oldblock) { + if (block->oldblock) { block->auto_open= block->oldblock->auto_open; block->auto_open_last= block->oldblock->auto_open_last; block->tooltipdisabled= block->oldblock->tooltipdisabled; @@ -926,21 +926,21 @@ void uiEndBlock(const bContext *C, uiBlock *block) } /* handle pending stuff */ - if(block->layouts.first) uiBlockLayoutResolve(block, NULL, NULL); + if (block->layouts.first) uiBlockLayoutResolve(block, NULL, NULL); ui_block_do_align(block); - if((block->flag & UI_BLOCK_LOOP) && (block->flag & UI_BLOCK_NUMSELECT)) { + if ((block->flag & UI_BLOCK_LOOP) && (block->flag & UI_BLOCK_NUMSELECT)) { ui_menu_block_set_keyaccels(block); /* could use a different flag to check */ } - if(block->flag & UI_BLOCK_LOOP) ui_menu_block_set_keymaps(C, block); + if (block->flag & UI_BLOCK_LOOP) ui_menu_block_set_keymaps(C, block); /* after keymaps! */ - if(block->dobounds == UI_BLOCK_BOUNDS) ui_bounds_block(block); - else if(block->dobounds == UI_BLOCK_BOUNDS_TEXT) ui_text_bounds_block(block, 0.0f); - else if(block->dobounds == UI_BLOCK_BOUNDS_POPUP_CENTER) ui_centered_bounds_block(C, block); - else if(block->dobounds) ui_popup_bounds_block(C, block, block->dobounds); + if (block->dobounds == UI_BLOCK_BOUNDS) ui_bounds_block(block); + else if (block->dobounds == UI_BLOCK_BOUNDS_TEXT) ui_text_bounds_block(block, 0.0f); + else if (block->dobounds == UI_BLOCK_BOUNDS_POPUP_CENTER) ui_centered_bounds_block(C, block); + else if (block->dobounds) ui_popup_bounds_block(C, block, block->dobounds); - if(block->minx==0.0f && block->maxx==0.0f) uiBoundsBlock(block, 0); - if(block->flag & UI_BUT_ALIGN) uiBlockEndAlign(block); + if (block->minx==0.0f && block->maxx==0.0f) uiBoundsBlock(block, 0); + if (block->flag & UI_BUT_ALIGN) uiBlockEndAlign(block); block->endblock= 1; } @@ -949,14 +949,14 @@ void uiEndBlock(const bContext *C, uiBlock *block) void ui_fontscale(short *points, float aspect) { - if(aspect < 0.9f || aspect > 1.1f) { + if (aspect < 0.9f || aspect > 1.1f) { float pointsf= *points; /* for some reason scaling fonts goes too fast compared to widget size */ aspect= sqrt(aspect); pointsf /= aspect; - if(aspect > 1.0f) + if (aspect > 1.0f) *points= ceilf(pointsf); else *points= floorf(pointsf); @@ -997,15 +997,15 @@ void uiDrawBlock(const bContext *C, uiBlock *block) /* get menu region or area region */ ar= CTX_wm_menu(C); - if(!ar) + if (!ar) ar= CTX_wm_region(C); - if(!block->endblock) + if (!block->endblock) uiEndBlock(C, block); /* disable AA, makes widgets too blurry */ multisample_enabled= glIsEnabled(GL_MULTISAMPLE_ARB); - if(multisample_enabled) + if (multisample_enabled) glDisable(GL_MULTISAMPLE_ARB); /* we set this only once */ @@ -1030,19 +1030,19 @@ void uiDrawBlock(const bContext *C, uiBlock *block) wmOrtho2(-0.01f, ar->winx-0.01f, -0.01f, ar->winy-0.01f); /* back */ - if(block->flag & UI_BLOCK_LOOP) + if (block->flag & UI_BLOCK_LOOP) ui_draw_menu_back(&style, block, &rect); - else if(block->panel) + else if (block->panel) ui_draw_aligned_panel(&style, block, &rect); /* widgets */ - for(but= block->buttons.first; but; but= but->next) { - if(!(but->flag & (UI_HIDDEN|UI_SCROLLED))) { + for (but= block->buttons.first; but; but= but->next) { + if (!(but->flag & (UI_HIDDEN|UI_SCROLLED))) { ui_but_to_pixelrect(&rect, ar, block, but); /* XXX: figure out why invalid coordinates happen when closing render window */ /* and material preview is redrawn in main window (temp fix for bug #23848) */ - if(rect.xmin < rect.xmax && rect.ymin < rect.ymax) + if (rect.xmin < rect.xmax && rect.ymin < rect.ymax) ui_draw_but(C, ar, &style, but, &rect); } } @@ -1053,7 +1053,7 @@ void uiDrawBlock(const bContext *C, uiBlock *block) glMatrixMode(GL_MODELVIEW); glPopMatrix(); - if(multisample_enabled) + if (multisample_enabled) glEnable(GL_MULTISAMPLE_ARB); ui_draw_links(block); @@ -1065,13 +1065,13 @@ static void ui_is_but_sel(uiBut *but, double *value) { short is_push=0, is_true=1; - if(ELEM3(but->type, TOGN, ICONTOGN, OPTIONN)) is_true= 0; + if (ELEM3(but->type, TOGN, ICONTOGN, OPTIONN)) is_true= 0; - if( but->bit ) { + if ( but->bit ) { int lvalue; UI_GET_BUT_VALUE_INIT(but, *value) lvalue= (int)*value; - if( BTST(lvalue, (but->bitnr)) ) is_push= is_true; + if ( BTST(lvalue, (but->bitnr)) ) is_push= is_true; else is_push= !is_true; } else { @@ -1091,23 +1091,23 @@ static void ui_is_but_sel(uiBut *but, double *value) case ICONTOG: case OPTION: UI_GET_BUT_VALUE_INIT(but, *value) - if(*value != (double)but->hardmin) is_push= 1; + if (*value != (double)but->hardmin) is_push= 1; break; case ICONTOGN: case TOGN: case OPTIONN: UI_GET_BUT_VALUE_INIT(but, *value) - if(*value==0.0) is_push= 1; + if (*value==0.0) is_push= 1; break; case ROW: case LISTROW: UI_GET_BUT_VALUE_INIT(but, *value) /* support for rna enum buts */ - if(but->rnaprop && (RNA_property_flag(but->rnaprop) & PROP_ENUM_FLAG)) { - if((int)*value & (int)but->hardmax) is_push= 1; + if (but->rnaprop && (RNA_property_flag(but->rnaprop) & PROP_ENUM_FLAG)) { + if ((int)*value & (int)but->hardmax) is_push= 1; } else { - if(*value == (double)but->hardmax) is_push= 1; + if (*value == (double)but->hardmax) is_push= 1; } break; case COL: @@ -1119,8 +1119,8 @@ static void ui_is_but_sel(uiBut *but, double *value) } } - if(is_push==2); - else if(is_push==1) but->flag |= UI_SELECT; + if (is_push==2); + else if (is_push==1) but->flag |= UI_SELECT; else but->flag &= ~UI_SELECT; } @@ -1129,9 +1129,9 @@ static uiBut *ui_find_inlink(uiBlock *block, void *poin) uiBut *but; but= block->buttons.first; - while(but) { - if(but->type==INLINK) { - if(but->poin == poin) return but; + while (but) { + if (but->type==INLINK) { + if (but->poin == poin) return but; } but= but->next; } @@ -1161,24 +1161,24 @@ void uiComposeLinks(uiBlock *block) int a; but= block->buttons.first; - while(but) { - if(but->type==LINK) { + while (but) { + if (but->type==LINK) { link= but->link; /* for all pointers in the array */ - if(link) { - if(link->ppoin) { + if (link) { + if (link->ppoin) { ppoin= link->ppoin; - for(a=0; a < *(link->totlink); a++) { + for (a=0; a < *(link->totlink); a++) { bt= ui_find_inlink(block, (*ppoin)[a] ); - if(bt) { + if (bt) { ui_add_link_line(&link->lines, but, bt); } } } - else if(link->poin) { + else if (link->poin) { bt= ui_find_inlink(block, *(link->poin) ); - if(bt) { + if (bt) { ui_add_link_line(&link->lines, but, bt); } } @@ -1193,7 +1193,7 @@ void uiComposeLinks(uiBlock *block) void uiBlockSetButLock(uiBlock *block, int val, const char *lockstr) { - if(val) { + if (val) { block->lock= val ? 1:0; block->lockstr= lockstr; } @@ -1217,18 +1217,18 @@ void ui_delete_linkline(uiLinkLine *line, uiBut *but) link= line->from->link; /* are there more pointers allowed? */ - if(link->ppoin) { + if (link->ppoin) { - if(*(link->totlink)==1) { + if (*(link->totlink)==1) { *(link->totlink)= 0; MEM_freeN(*(link->ppoin)); *(link->ppoin)= NULL; } else { b= 0; - for(a=0; a< (*(link->totlink)); a++) { + for (a=0; a< (*(link->totlink)); a++) { - if( (*(link->ppoin))[a] != line->to->poin ) { + if ( (*(link->ppoin))[a] != line->to->poin ) { (*(link->ppoin))[b]= (*(link->ppoin))[a]; b++; } @@ -1254,30 +1254,30 @@ void ui_get_but_vectorf(uiBut *but, float vec[3]) PropertyRNA *prop; int a, tot; - if(but->editvec) { + if (but->editvec) { copy_v3_v3(vec, but->editvec); } - if(but->rnaprop) { + if (but->rnaprop) { prop= but->rnaprop; vec[0]= vec[1]= vec[2]= 0.0f; - if(RNA_property_type(prop) == PROP_FLOAT) { + if (RNA_property_type(prop) == PROP_FLOAT) { tot= RNA_property_array_length(&but->rnapoin, prop); tot= MIN2(tot, 3); - for(a=0; arnapoin, prop, a); } } - else if(but->pointype == CHA) { + else if (but->pointype == CHA) { char *cp= (char *)but->poin; vec[0]= ((float)cp[0])/255.0f; vec[1]= ((float)cp[1])/255.0f; vec[2]= ((float)cp[2])/255.0f; } - else if(but->pointype == FLO) { + else if (but->pointype == FLO) { float *fp= (float *)but->poin; copy_v3_v3(vec, fp); } @@ -1298,14 +1298,14 @@ void ui_set_but_vectorf(uiBut *but, const float vec[3]) { PropertyRNA *prop; - if(but->editvec) { + if (but->editvec) { copy_v3_v3(but->editvec, vec); } - if(but->rnaprop) { + if (but->rnaprop) { prop= but->rnaprop; - if(RNA_property_type(prop) == PROP_FLOAT) { + if (RNA_property_type(prop) == PROP_FLOAT) { int tot; int a; @@ -1317,13 +1317,13 @@ void ui_set_but_vectorf(uiBut *but, const float vec[3]) } } } - else if(but->pointype == CHA) { + else if (but->pointype == CHA) { char *cp= (char *)but->poin; cp[0]= (char)(0.5f + vec[0]*255.0f); cp[1]= (char)(0.5f + vec[1]*255.0f); cp[2]= (char)(0.5f + vec[2]*255.0f); } - else if(but->pointype == FLO) { + else if (but->pointype == FLO) { float *fp= (float *)but->poin; copy_v3_v3(fp, vec); } @@ -1331,10 +1331,10 @@ void ui_set_but_vectorf(uiBut *but, const float vec[3]) int ui_is_but_float(uiBut *but) { - if(but->pointype==FLO && but->poin) + if (but->pointype==FLO && but->poin) return 1; - if(but->rnaprop && RNA_property_type(but->rnaprop) == PROP_FLOAT) + if (but->rnaprop && RNA_property_type(but->rnaprop) == PROP_FLOAT) return 1; return 0; @@ -1345,7 +1345,7 @@ int ui_is_but_unit(uiBut *but) UnitSettings *unit= but->block->unit; const int unit_type= uiButGetUnitType(but); - if(unit_type == PROP_UNIT_NONE) + if (unit_type == PROP_UNIT_NONE) return 0; #if 1 // removed so angle buttons get correct snapping @@ -1382,27 +1382,27 @@ double ui_get_but_val(uiBut *but) PropertyRNA *prop; double value = 0.0; - if(but->editval) { return *(but->editval); } - if(but->poin==NULL && but->rnapoin.data==NULL) return 0.0; + if (but->editval) { return *(but->editval); } + if (but->poin==NULL && but->rnapoin.data==NULL) return 0.0; - if(but->rnaprop) { + if (but->rnaprop) { prop= but->rnaprop; switch(RNA_property_type(prop)) { case PROP_BOOLEAN: - if(RNA_property_array_check(prop)) + if (RNA_property_array_check(prop)) value= RNA_property_boolean_get_index(&but->rnapoin, prop, but->rnaindex); else value= RNA_property_boolean_get(&but->rnapoin, prop); break; case PROP_INT: - if(RNA_property_array_check(prop)) + if (RNA_property_array_check(prop)) value= RNA_property_int_get_index(&but->rnapoin, prop, but->rnaindex); else value= RNA_property_int_get(&but->rnapoin, prop); break; case PROP_FLOAT: - if(RNA_property_array_check(prop)) + if (RNA_property_array_check(prop)) value= RNA_property_float_get_index(&but->rnapoin, prop, but->rnaindex); else value= RNA_property_float_get(&but->rnapoin, prop); @@ -1415,7 +1415,7 @@ double ui_get_but_val(uiBut *but) break; } } - else if(but->type== HSVSLI) { + else if (but->type== HSVSLI) { float h, s, v, *fp; fp= (but->editvec)? but->editvec: (float *)but->poin; @@ -1427,16 +1427,16 @@ double ui_get_but_val(uiBut *but) case 'V': value= v; break; } } - else if( but->pointype == CHA ) { + else if ( but->pointype == CHA ) { value= *(char *)but->poin; } - else if( but->pointype == SHO ) { + else if ( but->pointype == SHO ) { value= *(short *)but->poin; } - else if( but->pointype == INT ) { + else if ( but->pointype == INT ) { value= *(int *)but->poin; } - else if( but->pointype == FLO ) { + else if ( but->pointype == FLO ) { value= *(float *)but->poin; } @@ -1448,31 +1448,31 @@ void ui_set_but_val(uiBut *but, double value) PropertyRNA *prop; /* value is a hsv value: convert to rgb */ - if(but->rnaprop) { + if (but->rnaprop) { prop= but->rnaprop; - if(RNA_property_editable(&but->rnapoin, prop)) { + if (RNA_property_editable(&but->rnapoin, prop)) { switch(RNA_property_type(prop)) { case PROP_BOOLEAN: - if(RNA_property_array_length(&but->rnapoin, prop)) + if (RNA_property_array_length(&but->rnapoin, prop)) RNA_property_boolean_set_index(&but->rnapoin, prop, but->rnaindex, value); else RNA_property_boolean_set(&but->rnapoin, prop, value); break; case PROP_INT: - if(RNA_property_array_length(&but->rnapoin, prop)) + if (RNA_property_array_length(&but->rnapoin, prop)) RNA_property_int_set_index(&but->rnapoin, prop, but->rnaindex, (int)value); else RNA_property_int_set(&but->rnapoin, prop, (int)value); break; case PROP_FLOAT: - if(RNA_property_array_length(&but->rnapoin, prop)) + if (RNA_property_array_length(&but->rnapoin, prop)) RNA_property_float_set_index(&but->rnapoin, prop, but->rnaindex, value); else RNA_property_float_set(&but->rnapoin, prop, value); break; case PROP_ENUM: - if(RNA_property_flag(prop) & PROP_ENUM_FLAG) { + if (RNA_property_flag(prop) & PROP_ENUM_FLAG) { int ivalue= (int)value; ivalue ^= RNA_property_enum_get(&but->rnapoin, prop); /* toggle for enum/flag buttons */ RNA_property_enum_set(&but->rnapoin, prop, ivalue); @@ -1490,8 +1490,8 @@ void ui_set_but_val(uiBut *but, double value) * so leave this unset */ value= UI_BUT_VALUE_UNSET; } - else if(but->pointype==0); - else if(but->type==HSVSLI ) { + else if (but->pointype==0); + else if (but->type==HSVSLI ) { float h, s, v, *fp; fp= (but->editvec)? but->editvec: (float *)but->poin; @@ -1508,9 +1508,9 @@ void ui_set_but_val(uiBut *but, double value) } else { /* first do rounding */ - if(but->pointype==CHA) + if (but->pointype==CHA) value= (char)floor(value+0.5); - else if(but->pointype==SHO ) { + else if (but->pointype==SHO ) { /* gcc 3.2.1 seems to have problems * casting a double like 32772.0 to * a short so we cast to an int, then @@ -1519,24 +1519,24 @@ void ui_set_but_val(uiBut *but, double value) gcckludge = (int) floor(value+0.5); value= (short)gcckludge; } - else if(but->pointype==INT ) + else if (but->pointype==INT ) value= (int)floor(value+0.5); - else if(but->pointype==FLO ) { + else if (but->pointype==FLO ) { float fval= (float)value; - if(fval>= -0.00001f && fval<= 0.00001f) fval= 0.0f; /* prevent negative zero */ + if (fval>= -0.00001f && fval<= 0.00001f) fval= 0.0f; /* prevent negative zero */ value= fval; } /* then set value with possible edit override */ - if(but->editval) + if (but->editval) value= *but->editval= value; - else if(but->pointype==CHA) + else if (but->pointype==CHA) value= *((char *)but->poin)= (char)value; - else if(but->pointype==SHO) + else if (but->pointype==SHO) value= *((short *)but->poin)= (short)value; - else if(but->pointype==INT) + else if (but->pointype==INT) value= *((int *)but->poin)= (int)value; - else if(but->pointype==FLO) + else if (but->pointype==FLO) value= *((float *)but->poin)= (float)value; } @@ -1546,9 +1546,9 @@ void ui_set_but_val(uiBut *but, double value) int ui_get_but_string_max_length(uiBut *but) { - if(ELEM(but->type, TEX, SEARCH_MENU)) + if (ELEM(but->type, TEX, SEARCH_MENU)) return but->hardmax; - else if(but->type == IDPOIN) + else if (but->type == IDPOIN) return MAX_ID_NAME-2; else return UI_MAX_DRAW_STR; @@ -1559,16 +1559,16 @@ static double ui_get_but_scale_unit(uiBut *but, double value) UnitSettings *unit= but->block->unit; int unit_type= uiButGetUnitType(but); - if(unit_type == PROP_UNIT_LENGTH) { + if (unit_type == PROP_UNIT_LENGTH) { return value * (double)unit->scale_length; } - else if(unit_type == PROP_UNIT_AREA) { + else if (unit_type == PROP_UNIT_AREA) { return value * pow(unit->scale_length, 2); } - else if(unit_type == PROP_UNIT_VOLUME) { + else if (unit_type == PROP_UNIT_VOLUME) { return value * pow(unit->scale_length, 3); } - else if(unit_type == PROP_UNIT_TIME) { /* WARNING - using evil_C :| */ + else if (unit_type == PROP_UNIT_TIME) { /* WARNING - using evil_C :| */ Scene *scene= CTX_data_scene(but->block->evil_C); return FRA2TIME(value); } @@ -1580,7 +1580,7 @@ static double ui_get_but_scale_unit(uiBut *but, double value) /* str will be overwritten */ void ui_convert_to_unit_alt_name(uiBut *but, char *str, size_t maxlen) { - if(ui_is_but_unit(but)) { + if (ui_is_but_unit(but)) { UnitSettings *unit= but->block->unit; int unit_type= uiButGetUnitType(but); char *orig_str; @@ -1601,11 +1601,11 @@ static void ui_get_but_string_unit(uiBut *but, char *str, int len_max, double va int unit_type= uiButGetUnitType(but); int precision= but->a2; - if(unit->scale_length<0.0001f) unit->scale_length= 1.0f; // XXX do_versions + if (unit->scale_length<0.0001f) unit->scale_length= 1.0f; // XXX do_versions /* Sanity checks */ - if(precision > PRECISION_FLOAT_MAX) precision= PRECISION_FLOAT_MAX; - else if(precision==0) precision= 2; + if (precision > PRECISION_FLOAT_MAX) precision= PRECISION_FLOAT_MAX; + else if (precision==0) precision= 2; bUnit_AsString(str, len_max, ui_get_but_scale_unit(but, value), precision, unit->system, unit_type>>16, do_split, pad); } @@ -1617,7 +1617,7 @@ static float ui_get_but_step_unit(uiBut *but, float step_default) step = bUnit_ClosestScalar(ui_get_but_scale_unit(but, step_default), but->block->unit->system, unit_type); - if(step > 0.0f) { /* -1 is an error value */ + if (step > 0.0f) { /* -1 is an error value */ return (float)((double)step/ui_get_but_scale_unit(but, 1.0))*100.0f; } else { @@ -1628,37 +1628,37 @@ static float ui_get_but_step_unit(uiBut *but, float step_default) void ui_get_but_string(uiBut *but, char *str, size_t maxlen) { - if(but->rnaprop && ELEM3(but->type, TEX, IDPOIN, SEARCH_MENU)) { + if (but->rnaprop && ELEM3(but->type, TEX, IDPOIN, SEARCH_MENU)) { PropertyType type; char *buf= NULL; int buf_len; type= RNA_property_type(but->rnaprop); - if(type == PROP_STRING) { + if (type == PROP_STRING) { /* RNA string */ buf= RNA_property_string_get_alloc(&but->rnapoin, but->rnaprop, str, maxlen, &buf_len); } - else if(type == PROP_POINTER) { + else if (type == PROP_POINTER) { /* RNA pointer */ PointerRNA ptr= RNA_property_pointer_get(&but->rnapoin, but->rnaprop); buf= RNA_struct_name_get_alloc(&ptr, str, maxlen, &buf_len); } - if(!buf) { + if (!buf) { str[0] = '\0'; } - else if(buf && buf != str) { + else if (buf && buf != str) { /* string was too long, we have to truncate */ memcpy(str, buf, MIN2(maxlen, buf_len+1)); MEM_freeN(buf); } } - else if(but->type == IDPOIN) { + else if (but->type == IDPOIN) { /* ID pointer */ - if(but->idpoin_idpp) { /* Can be NULL for ID properties by python */ + if (but->idpoin_idpp) { /* Can be NULL for ID properties by python */ ID *id= *(but->idpoin_idpp); - if(id) { + if (id) { BLI_strncpy(str, id->name+2, maxlen); return; } @@ -1666,17 +1666,17 @@ void ui_get_but_string(uiBut *but, char *str, size_t maxlen) str[0] = '\0'; return; } - else if(but->type == TEX) { + else if (but->type == TEX) { /* string */ BLI_strncpy(str, but->poin, maxlen); return; } - else if(but->type == SEARCH_MENU) { + else if (but->type == SEARCH_MENU) { /* string */ BLI_strncpy(str, but->poin, maxlen); return; } - else if(ui_but_anim_expression_get(but, str, maxlen)) + else if (ui_but_anim_expression_get(but, str, maxlen)) ; /* driver expression */ else { /* number editing */ @@ -1684,8 +1684,8 @@ void ui_get_but_string(uiBut *but, char *str, size_t maxlen) value= ui_get_but_val(but); - if(ui_is_but_float(but)) { - if(ui_is_but_unit(but)) { + if (ui_is_but_float(but)) { + if (ui_is_but_unit(but)) { ui_get_but_string_unit(but, str, maxlen, value, 0); } else { @@ -1722,12 +1722,12 @@ int ui_set_but_string_eval_num(bContext *C, uiBut *but, const char *str, double #ifdef WITH_PYTHON - if(str[0] != '\0') { + if (str[0] != '\0') { int is_unit_but= ui_is_but_unit(but); /* only enable verbose if we won't run again with units */ - if(BPY_button_exec(C, str, value, is_unit_but==FALSE) != -1) { + if (BPY_button_exec(C, str, value, is_unit_but==FALSE) != -1) { /* if the value parsed ok without unit conversion this button may still need a unit multiplier */ - if(is_unit_but) { + if (is_unit_but) { char str_new[128]; BLI_snprintf(str_new, sizeof(str_new), "%f", *value); @@ -1737,7 +1737,7 @@ int ui_set_but_string_eval_num(bContext *C, uiBut *but, const char *str, double ok= TRUE; /* parse normal string via py (no unit conversion needed) */ } } - else if(is_unit_but) { + else if (is_unit_but) { /* parse failed, this is a unit but so run replacements and parse again */ ok= ui_set_but_string_eval_num_unit(C, but, str, value); } @@ -1759,23 +1759,23 @@ int ui_set_but_string_eval_num(bContext *C, uiBut *but, const char *str, double int ui_set_but_string(bContext *C, uiBut *but, const char *str) { - if(but->rnaprop && ELEM3(but->type, TEX, IDPOIN, SEARCH_MENU)) { - if(RNA_property_editable(&but->rnapoin, but->rnaprop)) { + if (but->rnaprop && ELEM3(but->type, TEX, IDPOIN, SEARCH_MENU)) { + if (RNA_property_editable(&but->rnapoin, but->rnaprop)) { PropertyType type; type= RNA_property_type(but->rnaprop); - if(type == PROP_STRING) { + if (type == PROP_STRING) { /* RNA string */ RNA_property_string_set(&but->rnapoin, but->rnaprop, str); return 1; } - else if(type == PROP_POINTER) { + else if (type == PROP_POINTER) { /* RNA pointer */ PointerRNA ptr, rptr; PropertyRNA *prop; - if(str == NULL || str[0] == '\0') { + if (str == NULL || str[0] == '\0') { RNA_property_pointer_set(&but->rnapoin, but->rnaprop, PointerRNA_NULL); return 1; } @@ -1783,7 +1783,7 @@ int ui_set_but_string(bContext *C, uiBut *but, const char *str) ptr= but->rnasearchpoin; prop= but->rnasearchprop; - if(prop && RNA_property_collection_lookup_string(&ptr, prop, str, &rptr)) + if (prop && RNA_property_collection_lookup_string(&ptr, prop, str, &rptr)) RNA_property_pointer_set(&but->rnapoin, but->rnaprop, rptr); return 1; @@ -1793,28 +1793,28 @@ int ui_set_but_string(bContext *C, uiBut *but, const char *str) } } } - else if(but->type == IDPOIN) { + else if (but->type == IDPOIN) { /* ID pointer */ but->idpoin_func(C, str, but->idpoin_idpp); return 1; } - else if(but->type == TEX) { + else if (but->type == TEX) { /* string */ - if(ui_is_but_utf8(but)) BLI_strncpy_utf8(but->poin, str, but->hardmax); + if (ui_is_but_utf8(but)) BLI_strncpy_utf8(but->poin, str, but->hardmax); else BLI_strncpy(but->poin, str, but->hardmax); return 1; } - else if(but->type == SEARCH_MENU) { + else if (but->type == SEARCH_MENU) { /* string */ BLI_strncpy(but->poin, str, but->hardmax); return 1; } - else if(ui_but_anim_expression_set(but, str)) { + else if (ui_but_anim_expression_set(but, str)) { /* driver expression */ return 1; } - else if(str[0]=='#') { + else if (str[0]=='#') { /* shortcut to create new driver expression (versus immediate Py-execution) */ return ui_but_anim_expression_create(but, str+1); } @@ -1822,16 +1822,16 @@ int ui_set_but_string(bContext *C, uiBut *but, const char *str) /* number editing */ double value; - if(ui_set_but_string_eval_num(C, but, str, &value) == FALSE) { + if (ui_set_but_string_eval_num(C, but, str, &value) == FALSE) { return 0; } - if(!ui_is_but_float(but)) value= (int)floor(value + 0.5); - if(but->type==NUMABS) value= fabs(value); + if (!ui_is_but_float(but)) value= (int)floor(value + 0.5); + if (but->type==NUMABS) value= fabs(value); /* not that we use hard limits here */ - if(value < (double)but->hardmin) value= but->hardmin; - if(value > (double)but->hardmax) value= but->hardmax; + if (value < (double)but->hardmin) value= but->hardmin; + if (value > (double)but->hardmax) value= but->hardmax; ui_set_but_val(but, value); return 1; @@ -1855,9 +1855,9 @@ static double soft_range_round_up(double value, double max) /* round up to .., 0.1, 0.2, 0.5, 1, 2, 5, 10, 20, 50, .. */ double newmax= pow(10.0, ceil(log(value)/M_LN10)); - if(newmax*0.2 >= max && newmax*0.2 >= value) + if (newmax*0.2 >= max && newmax*0.2 >= value) return newmax*0.2; - else if(newmax*0.5 >= max && newmax*0.5 >= value) + else if (newmax*0.5 >= max && newmax*0.5 >= value) return newmax*0.5; else return newmax; @@ -1868,9 +1868,9 @@ static double soft_range_round_down(double value, double max) /* round down to .., 0.1, 0.2, 0.5, 1, 2, 5, 10, 20, 50, .. */ double newmax= pow(10.0, floor(log(value)/M_LN10)); - if(newmax*5.0 <= max && newmax*5.0 <= value) + if (newmax*5.0 <= max && newmax*5.0 <= value) return newmax*5.0; - else if(newmax*2.0 <= max && newmax*2.0 <= value) + else if (newmax*2.0 <= max && newmax*2.0 <= value) return newmax*2.0; else return newmax; @@ -1882,7 +1882,7 @@ void ui_set_but_soft_range(uiBut *but, double value) * enough worst case is very long vectors wont use a smart soft-range * which isn't so bad. */ - if(but->rnaprop) { + if (but->rnaprop) { const PropertyType type= RNA_property_type(but->rnaprop); double softmin, softmax /*, step, precision*/; double value_min= value; @@ -1890,7 +1890,7 @@ void ui_set_but_soft_range(uiBut *but, double value) /* clamp button range to something reasonable in case * we get -inf/inf from RNA properties */ - if(type == PROP_INT) { + if (type == PROP_INT) { int imin, imax, istep; const int array_len= RNA_property_array_length(&but->rnapoin, but->rnaprop); @@ -1900,14 +1900,14 @@ void ui_set_but_soft_range(uiBut *but, double value) /*step= istep;*/ /*UNUSED*/ /*precision= 1;*/ /*UNUSED*/ - if(array_len >= 2) { + if (array_len >= 2) { int value_range[2]; RNA_property_int_get_array_range(&but->rnapoin, but->rnaprop, value_range); value_min= (double)value_range[0]; value_max= (double)value_range[1]; } } - else if(type == PROP_FLOAT) { + else if (type == PROP_FLOAT) { float fmin, fmax, fstep, fprecision; const int array_len= RNA_property_array_length(&but->rnapoin, but->rnaprop); @@ -1917,7 +1917,7 @@ void ui_set_but_soft_range(uiBut *but, double value) /*step= fstep;*/ /*UNUSED*/ /*precision= fprecision;*/ /*UNUSED*/ - if(array_len >= 2) { + if (array_len >= 2) { float value_range[2]; RNA_property_float_get_array_range(&but->rnapoin, but->rnaprop, value_range); value_min= (double)value_range[0]; @@ -1928,22 +1928,22 @@ void ui_set_but_soft_range(uiBut *but, double value) return; /* if the value goes out of the soft/max range, adapt the range */ - if(value_min+1e-10 < softmin) { - if(value_min < 0.0) + if (value_min+1e-10 < softmin) { + if (value_min < 0.0) softmin= -soft_range_round_up(-value_min, -softmin); else softmin= soft_range_round_down(value_min, softmin); - if(softmin < (double)but->hardmin) + if (softmin < (double)but->hardmin) softmin= (double)but->hardmin; } - if(value_max-1e-10 > softmax) { - if(value_max < 0.0) + if (value_max-1e-10 > softmax) { + if (value_max < 0.0) softmax= -soft_range_round_down(-value_max, -softmax); else softmax= soft_range_round_up(value_max, softmax); - if(softmax > (double)but->hardmax) + if (softmax > (double)but->hardmax) softmax= but->hardmax; } @@ -1956,7 +1956,7 @@ void ui_set_but_soft_range(uiBut *but, double value) static void ui_free_link(uiLink *link) { - if(link) { + if (link) { BLI_freelistN(&link->lines); MEM_freeN(link); } @@ -1965,16 +1965,16 @@ static void ui_free_link(uiLink *link) /* can be called with C==NULL */ static void ui_free_but(const bContext *C, uiBut *but) { - if(but->opptr) { + if (but->opptr) { WM_operator_properties_free(but->opptr); MEM_freeN(but->opptr); } - if(but->func_argN) { + if (but->func_argN) { MEM_freeN(but->func_argN); } - if(but->active) { + if (but->active) { /* XXX solve later, buttons should be free-able without context ideally, * however they may have open tooltips or popup windows, which need to * be closed using a context pointer */ @@ -1982,7 +1982,7 @@ static void ui_free_but(const bContext *C, uiBut *but) ui_button_active_free(C, but); } else { - if(but->active) { + if (but->active) { MEM_freeN(but->active); } } @@ -2004,7 +2004,7 @@ void uiFreeBlock(const bContext *C, uiBlock *block) { uiBut *but; - while( (but= block->buttons.first) ) { + while ( (but= block->buttons.first) ) { BLI_remlink(&block->buttons, but); ui_free_but(C, but); } @@ -2029,7 +2029,7 @@ void uiFreeBlocks(const bContext *C, ListBase *lb) { uiBlock *block; - while( (block= lb->first) ) { + while ( (block= lb->first) ) { BLI_remlink(lb, block); uiFreeBlock(C, block); } @@ -2039,11 +2039,11 @@ void uiFreeInactiveBlocks(const bContext *C, ListBase *lb) { uiBlock *block, *nextblock; - for(block=lb->first; block; block=nextblock) { + for (block=lb->first; block; block=nextblock) { nextblock= block->next; - if(!block->handle) { - if(!block->active) { + if (!block->handle) { + if (!block->active) { BLI_remlink(lb, block); uiFreeBlock(C, block); } @@ -2060,7 +2060,7 @@ void uiBlockSetRegion(uiBlock *block, ARegion *region) /* each listbase only has one block with this name, free block * if is already there so it can be rebuilt from scratch */ - if(lb) { + if (lb) { oldblock= BLI_findstring(lb, block->name, offsetof(uiBlock, name)); if (oldblock) { @@ -2100,11 +2100,11 @@ uiBlock *uiBeginBlock(const bContext *C, ARegion *region, const char *name, shor BLI_strncpy(block->name, name, sizeof(block->name)); - if(region) + if (region) uiBlockSetRegion(block, region); /* window matrix and aspect */ - if(region && region->swinid) { + if (region && region->swinid) { wm_subwindow_getmatrix(window, region->swinid, block->winmat); wm_subwindow_getsize(window, region->swinid, &getsizex, &getsizey); @@ -2146,7 +2146,7 @@ void ui_check_but(uiBut *but) ui_is_but_sel(but, &value); /* only update soft range while not editing */ - if(but->rnaprop && !(but->editval || but->editstr || but->editvec)) { + if (but->rnaprop && !(but->editval || but->editstr || but->editvec)) { UI_GET_BUT_VALUE_INIT(but, value) ui_set_but_soft_range(but, value); } @@ -2159,8 +2159,8 @@ void ui_check_but(uiBut *but) case NUMSLI: case HSVSLI: UI_GET_BUT_VALUE_INIT(but, value) - if(value < (double)but->hardmin) ui_set_but_val(but, but->hardmin); - else if(value > (double)but->hardmax) ui_set_but_val(but, but->hardmax); + if (value < (double)but->hardmin) ui_set_but_val(but, but->hardmin); + else if (value > (double)but->hardmax) ui_set_but_val(but, but->hardmax); break; case NUMABS: @@ -2168,27 +2168,27 @@ void ui_check_but(uiBut *but) double value_abs; UI_GET_BUT_VALUE_INIT(but, value) value_abs= fabs(value); - if(value_abs < (double)but->hardmin) ui_set_but_val(but, but->hardmin); - else if(value_abs > (double)but->hardmax) ui_set_but_val(but, but->hardmax); + if (value_abs < (double)but->hardmin) ui_set_but_val(but, but->hardmin); + else if (value_abs > (double)but->hardmax) ui_set_but_val(but, but->hardmax); break; } case ICONTOG: case ICONTOGN: - if(!but->rnaprop || (RNA_property_flag(but->rnaprop) & PROP_ICONS_CONSECUTIVE)) { - if(but->flag & UI_SELECT) but->iconadd= 1; + if (!but->rnaprop || (RNA_property_flag(but->rnaprop) & PROP_ICONS_CONSECUTIVE)) { + if (but->flag & UI_SELECT) but->iconadd= 1; else but->iconadd= 0; } break; case ICONROW: - if(!but->rnaprop || (RNA_property_flag(but->rnaprop) & PROP_ICONS_CONSECUTIVE)) { + if (!but->rnaprop || (RNA_property_flag(but->rnaprop) & PROP_ICONS_CONSECUTIVE)) { UI_GET_BUT_VALUE_INIT(but, value) but->iconadd= (int)value- (int)(but->hardmin); } break; case ICONTEXTROW: - if(!but->rnaprop || (RNA_property_flag(but->rnaprop) & PROP_ICONS_CONSECUTIVE)) { + if (!but->rnaprop || (RNA_property_flag(but->rnaprop) & PROP_ICONS_CONSECUTIVE)) { UI_GET_BUT_VALUE_INIT(but, value) but->iconadd= (int)value- (int)(but->hardmin); } @@ -2205,7 +2205,7 @@ void ui_check_but(uiBut *but) case MENU: case ICONTEXTROW: - if(but->x2 - but->x1 > 24) { + if (but->x2 - but->x1 > 24) { UI_GET_BUT_VALUE_INIT(but, value) ui_set_name_menu(but, (int)value); } @@ -2218,11 +2218,11 @@ void ui_check_but(uiBut *but) UI_GET_BUT_VALUE_INIT(but, value) - if(ui_is_but_float(but)) { - if(value == (double) FLT_MAX) BLI_snprintf(but->drawstr, sizeof(but->drawstr), "%sinf", but->str); - else if(value == (double) -FLT_MAX) BLI_snprintf(but->drawstr, sizeof(but->drawstr), "%s-inf", but->str); + if (ui_is_but_float(but)) { + if (value == (double) FLT_MAX) BLI_snprintf(but->drawstr, sizeof(but->drawstr), "%sinf", but->str); + else if (value == (double) -FLT_MAX) BLI_snprintf(but->drawstr, sizeof(but->drawstr), "%s-inf", but->str); /* support length type buttons */ - else if(ui_is_but_unit(but)) { + else if (ui_is_but_unit(but)) { char new_str[sizeof(but->drawstr)]; ui_get_but_string_unit(but, new_str, sizeof(new_str), value, TRUE); BLI_snprintf(but->drawstr, sizeof(but->drawstr), "%s%s", but->str, new_str); @@ -2236,7 +2236,7 @@ void ui_check_but(uiBut *but) BLI_snprintf(but->drawstr, sizeof(but->drawstr), "%s%d", but->str, (int)value); } - if(but->rnaprop) { + if (but->rnaprop) { PropertySubType pstype = RNA_property_subtype(but->rnaprop); if (pstype == PROP_PERCENTAGE) @@ -2245,7 +2245,7 @@ void ui_check_but(uiBut *but) break; case LABEL: - if(ui_is_but_float(but)) { + if (ui_is_but_float(but)) { int prec; UI_GET_BUT_VALUE_INIT(but, value) prec= ui_but_float_precision(but, value); @@ -2260,7 +2260,7 @@ void ui_check_but(uiBut *but) case IDPOIN: case TEX: case SEARCH_MENU: - if(!but->editstr) { + if (!but->editstr) { char str[UI_MAX_DRAW_STR]; ui_get_but_string(but, str, UI_MAX_DRAW_STR-strlen(but->str)); @@ -2284,16 +2284,16 @@ void ui_check_but(uiBut *but) if (but->flag & UI_SELECT) { but->drawstr[0]= '\0'; - if(but->modifier_key) { + if (but->modifier_key) { char *str= but->drawstr; - if(but->modifier_key & KM_SHIFT) + if (but->modifier_key & KM_SHIFT) str= strcat(str, "Shift "); - if(but->modifier_key & KM_CTRL) + if (but->modifier_key & KM_CTRL) str= strcat(str, "Ctrl "); - if(but->modifier_key & KM_ALT) + if (but->modifier_key & KM_ALT) str= strcat(str, "Alt "); - if(but->modifier_key & KM_OSKEY) + if (but->modifier_key & KM_OSKEY) str= strcat(str, "Cmd "); (void)str; /* UNUSED */ @@ -2308,7 +2308,7 @@ void ui_check_but(uiBut *but) case BUT_TOGDUAL: /* trying to get the dual-icon to left of text... not very nice */ - if(but->str[0]) { + if (but->str[0]) { BLI_strncpy(but->drawstr, " ", UI_MAX_DRAW_STR); BLI_strncpy(but->drawstr+2, but->str, UI_MAX_DRAW_STR-2); } @@ -2323,7 +2323,7 @@ void ui_check_but(uiBut *but) } /* if we are doing text editing, this will override the drawstr */ - if(but->editstr) + if (but->editstr) BLI_strncpy(but->drawstr, but->editstr, UI_MAX_DRAW_STR); /* text clipping moved to widget drawing code itself */ @@ -2333,7 +2333,7 @@ void ui_check_but(uiBut *but) void uiBlockBeginAlign(uiBlock *block) { /* if other align was active, end it */ - if(block->flag & UI_BUT_ALIGN) uiBlockEndAlign(block); + if (block->flag & UI_BUT_ALIGN) uiBlockEndAlign(block); block->flag |= UI_BUT_ALIGN_DOWN; block->alignnr++; @@ -2348,7 +2348,7 @@ static int buts_are_horiz(uiBut *but1, uiBut *but2) dx= fabs( but1->x2 - but2->x1); dy= fabs( but1->y1 - but2->y2); - if(dx > dy) return 0; + if (dx > dy) return 0; return 1; } @@ -2369,9 +2369,9 @@ static void ui_block_do_align_but(uiBut *first, short nr) /* auto align */ - for(but=first; but && but->alignnr == nr; but=but->next) { - if(but->next && but->next->alignnr == nr) { - if(buts_are_horiz(but, but->next)) cols++; + for (but=first; but && but->alignnr == nr; but=but->next) { + if (but->next && but->next->alignnr == nr) { + if (buts_are_horiz(but, but->next)) cols++; else rows++; } } @@ -2379,18 +2379,18 @@ static void ui_block_do_align_but(uiBut *first, short nr) /* rows==0: 1 row, cols==0: 1 column */ /* note; how it uses 'flag' in loop below (either set it, or OR it) is confusing */ - for(but=first, prev=NULL; but && but->alignnr == nr; prev=but, but=but->next) { + for (but=first, prev=NULL; but && but->alignnr == nr; prev=but, but=but->next) { next= but->next; - if(next && next->alignnr != nr) + if (next && next->alignnr != nr) next= NULL; /* clear old flag */ but->flag &= ~UI_BUT_ALIGN; - if(flag==0) { /* first case */ - if(next) { - if(buts_are_horiz(but, next)) { - if(rows==0) + if (flag==0) { /* first case */ + if (next) { + if (buts_are_horiz(but, next)) { + if (rows==0) flag= UI_BUT_ALIGN_RIGHT; else flag= UI_BUT_ALIGN_DOWN|UI_BUT_ALIGN_RIGHT; @@ -2400,10 +2400,10 @@ static void ui_block_do_align_but(uiBut *first, short nr) } } } - else if(next==NULL) { /* last case */ - if(prev) { - if(buts_are_horiz(prev, but)) { - if(rows==0) + else if (next==NULL) { /* last case */ + if (prev) { + if (buts_are_horiz(prev, but)) { + if (rows==0) flag= UI_BUT_ALIGN_LEFT; else flag= UI_BUT_ALIGN_TOP|UI_BUT_ALIGN_LEFT; @@ -2411,39 +2411,39 @@ static void ui_block_do_align_but(uiBut *first, short nr) else flag= UI_BUT_ALIGN_TOP; } } - else if(buts_are_horiz(but, next)) { + else if (buts_are_horiz(but, next)) { /* check if this is already second row */ - if( prev && buts_are_horiz(prev, but)==0) { + if ( prev && buts_are_horiz(prev, but)==0) { flag &= ~UI_BUT_ALIGN_LEFT; flag |= UI_BUT_ALIGN_TOP; /* exception case: bottom row */ - if(rows>0) { + if (rows>0) { uiBut *bt= but; - while(bt && bt->alignnr == nr) { - if(bt->next && bt->next->alignnr == nr && buts_are_horiz(bt, bt->next)==0 ) break; + while (bt && bt->alignnr == nr) { + if (bt->next && bt->next->alignnr == nr && buts_are_horiz(bt, bt->next)==0 ) break; bt= bt->next; } - if(bt==NULL || bt->alignnr != nr) flag= UI_BUT_ALIGN_TOP|UI_BUT_ALIGN_RIGHT; + if (bt==NULL || bt->alignnr != nr) flag= UI_BUT_ALIGN_TOP|UI_BUT_ALIGN_RIGHT; } } else flag |= UI_BUT_ALIGN_LEFT; } else { - if(cols==0) { + if (cols==0) { flag |= UI_BUT_ALIGN_TOP; } else { /* next button switches to new row */ - if(prev && buts_are_horiz(prev, but)) + if (prev && buts_are_horiz(prev, but)) flag |= UI_BUT_ALIGN_LEFT; else { flag &= ~UI_BUT_ALIGN_LEFT; flag |= UI_BUT_ALIGN_TOP; } - if( (flag & UI_BUT_ALIGN_TOP)==0) { /* stil top row */ - if(prev) { - if(next && buts_are_horiz(but, next)) + if ( (flag & UI_BUT_ALIGN_TOP)==0) { /* stil top row */ + if (prev) { + if (next && buts_are_horiz(but, next)) flag = UI_BUT_ALIGN_DOWN|UI_BUT_ALIGN_LEFT|UI_BUT_ALIGN_RIGHT; else { /* last button in top row */ @@ -2461,30 +2461,30 @@ static void ui_block_do_align_but(uiBut *first, short nr) but->flag |= flag; /* merge coordinates */ - if(prev) { + if (prev) { // simple cases - if(rows==0) { + if (rows==0) { but->x1= (prev->x2+but->x1)/2.0f; prev->x2= but->x1; } - else if(cols==0) { + else if (cols==0) { but->y2= (prev->y1+but->y2)/2.0f; prev->y1= but->y2; } else { - if(buts_are_horiz(prev, but)) { + if (buts_are_horiz(prev, but)) { but->x1= (prev->x2+but->x1)/2.0f; prev->x2= but->x1; /* copy height too */ but->y2= prev->y2; } - else if(prev->prev && buts_are_horiz(prev->prev, prev)==0) { + else if (prev->prev && buts_are_horiz(prev->prev, prev)==0) { /* the previous button is a single one in its row */ but->y2= (prev->y1+but->y2)/2.0f; prev->y1= but->y2; but->x1= prev->x1; - if(next && buts_are_horiz(but, next)==0) + if (next && buts_are_horiz(but, next)==0) but->x2= prev->x2; } else { @@ -2502,15 +2502,15 @@ void ui_block_do_align(uiBlock *block) short nr; /* align buttons with same align nr */ - for(but=block->buttons.first; but;) { - if(but->alignnr) { + for (but=block->buttons.first; but;) { + if (but->alignnr) { nr= but->alignnr; ui_block_do_align_but(but, nr); /* skip with same number */ - for(; but && but->alignnr == nr; but=but->next); + for (; but && but->alignnr == nr; but=but->next); - if(!but) + if (!but) break; } else @@ -2531,8 +2531,8 @@ static uiBut *ui_def_but(uiBlock *block, int type, int retval, const char *str, uiBut *but; int slen; - if(type & BUTPOIN) { /* a pointer is required */ - if(poin==NULL) + if (type & BUTPOIN) { /* a pointer is required */ + if (poin==NULL) return NULL; } @@ -2548,7 +2548,7 @@ static uiBut *ui_def_but(uiBlock *block, int type, int retval, const char *str, but->retval= retval; slen= strlen(str); - if(slen >= UI_MAX_NAME_STR-1) { + if (slen >= UI_MAX_NAME_STR-1) { but->str= MEM_mallocN(slen+2, "ui_def_but str"); /* why +2 ? */ } else { @@ -2575,7 +2575,7 @@ static uiBut *ui_def_but(uiBlock *block, int type, int retval, const char *str, but->aspect= 1.0f; //XXX block->aspect; but->block= block; // pointer back, used for frontbuffer status, and picker - if((block->flag & UI_BUT_ALIGN) && ui_but_can_align(but)) + if ((block->flag & UI_BUT_ALIGN) && ui_but_can_align(but)) but->alignnr= block->alignnr; but->func= block->func; @@ -2583,24 +2583,24 @@ static uiBut *ui_def_but(uiBlock *block, int type, int retval, const char *str, but->func_arg2= block->func_arg2; but->funcN= block->funcN; - if(block->func_argN) + if (block->func_argN) but->func_argN= MEM_dupallocN(block->func_argN); but->pos= -1; /* cursor invisible */ - if(ELEM4(but->type, NUM, NUMABS, NUMSLI, HSVSLI)) { /* add a space to name */ + if (ELEM4(but->type, NUM, NUMABS, NUMSLI, HSVSLI)) { /* add a space to name */ /* slen remains unchanged from previous assignment, ensure this stays true */ - if(slen>0 && slenstr[slen-1]!=' ') { + if (slen>0 && slenstr[slen-1]!=' ') { but->str[slen]= ' '; but->str[slen+1]= 0; } } } - if((block->flag & UI_BLOCK_LOOP) || ELEM8(but->type, MENU, TEX, LABEL, IDPOIN, BLOCK, BUTM, SEARCH_MENU, PROGRESSBAR)) + if ((block->flag & UI_BLOCK_LOOP) || ELEM8(but->type, MENU, TEX, LABEL, IDPOIN, BLOCK, BUTM, SEARCH_MENU, PROGRESSBAR)) but->flag |= (UI_TEXT_LEFT|UI_ICON_LEFT); - else if(but->type==BUT_TOGDUAL) + else if (but->type==BUT_TOGDUAL) but->flag |= UI_ICON_LEFT; but->flag |= (block->flag & UI_BUT_ALIGN); @@ -2612,14 +2612,14 @@ static uiBut *ui_def_but(uiBlock *block, int type, int retval, const char *str, } /* keep track of UI_interface.h */ - if(ELEM7(but->type, BLOCK, BUT, LABEL, PULLDOWN, ROUNDBOX, LISTBOX, BUTM)); - else if(ELEM3(but->type, SCROLL, SEPR, FTPREVIEW)); - else if(but->type >= SEARCH_MENU); + if (ELEM7(but->type, BLOCK, BUT, LABEL, PULLDOWN, ROUNDBOX, LISTBOX, BUTM)); + else if (ELEM3(but->type, SCROLL, SEPR, FTPREVIEW)); + else if (but->type >= SEARCH_MENU); else but->flag |= UI_BUT_UNDO; BLI_addtail(&block->buttons, but); - if(block->curlayout) + if (block->curlayout) ui_layout_add_but(block->curlayout, but); #ifdef WITH_PYTHON @@ -2653,8 +2653,8 @@ static uiBut *ui_def_but_rna(uiBlock *block, int type, int retval, const char *s int freestr= 0, icon= 0; /* use rna values if parameters are not specified */ - if(!str) { - if(type == MENU && proptype == PROP_ENUM) { + if (!str) { + if (type == MENU && proptype == PROP_ENUM) { EnumPropertyItem *item; DynStr *dynstr; int i, totitem, value, free; @@ -2664,19 +2664,19 @@ static uiBut *ui_def_but_rna(uiBlock *block, int type, int retval, const char *s dynstr= BLI_dynstr_new(); BLI_dynstr_appendf(dynstr, "%s%%t", RNA_property_ui_name(prop)); - for(i=0; ievil_C, ptr, prop, &item, &totitem, &free); - for(i=0; irnapoin= *ptr; but->rnaprop= prop; - if(RNA_property_array_length(&but->rnapoin, but->rnaprop)) + if (RNA_property_array_length(&but->rnapoin, but->rnaprop)) but->rnaindex= index; else but->rnaindex= 0; - if(icon) { + if (icon) { but->icon= (BIFIconID)icon; but->flag |= UI_HAS_ICON; but->flag|= UI_ICON_LEFT; @@ -2781,7 +2781,7 @@ static uiBut *ui_def_but_rna(uiBlock *block, int type, int retval, const char *s } /* If this button uses units, calculate the step from this */ - if((proptype == PROP_FLOAT) && ui_is_but_unit(but)) { + if ((proptype == PROP_FLOAT) && ui_is_but_unit(but)) { but->a1= ui_get_but_step_unit(but, but->a1); } @@ -2797,7 +2797,7 @@ static uiBut *ui_def_but_rna_propname(uiBlock *block, int type, int retval, cons PropertyRNA *prop= RNA_struct_find_property(ptr, propname); uiBut *but; - if(prop) { + if (prop) { but= ui_def_but_rna(block, type, retval, str, x1, y1, x2, y2, ptr, prop, index, min, max, a1, a2, tip); } else { @@ -2813,7 +2813,7 @@ static uiBut *ui_def_but_operator_ptr(uiBlock *block, int type, wmOperatorType * { uiBut *but; - if(!str) { + if (!str) { if (ot && ot->srna) str = RNA_struct_ui_name(ot->srna); else @@ -2829,7 +2829,7 @@ static uiBut *ui_def_but_operator_ptr(uiBlock *block, int type, wmOperatorType * but->opcontext= opcontext; but->flag &= ~UI_BUT_UNDO; /* no need for ui_but_is_undo(), we never need undo here */ - if(!ot) { + if (!ot) { but->flag |= UI_BUT_DISABLED; but->lock = 1; but->lockstr = ""; @@ -2854,8 +2854,8 @@ static uiBut *ui_def_but_operator_text(uiBlock *block, int type, const char *opn ot= WM_operatortype_find(opname, 0); - if(!str) { - if(ot) str= ot->name; + if (!str) { + if (ot) str= ot->name; else str= opname; } @@ -2868,7 +2868,7 @@ static uiBut *ui_def_but_operator_text(uiBlock *block, int type, const char *opn but->opcontext= opcontext; but->flag &= ~UI_BUT_UNDO; /* no need for ui_but_is_undo(), we never need undo here */ - if(!ot) { + if (!ot) { but->flag |= UI_BUT_DISABLED; but->lock = 1; but->lockstr = ""; @@ -2894,7 +2894,8 @@ static int findBitIndex(unsigned int x) { if (!x || !is_power_of_2_i(x)) { /* is_power_of_2_i(x) strips lowest bit */ return -1; - } else { + } + else { int idx= 0; if (x&0xFFFF0000) idx+=16, x>>=16; @@ -2932,23 +2933,23 @@ void autocomplete_do_name(AutoComplete *autocpl, const char *name) const char *startname= autocpl->startname; int a; - for(a=0; amaxlen-1; a++) { - if(startname[a]==0 || startname[a]!=name[a]) + for (a=0; amaxlen-1; a++) { + if (startname[a]==0 || startname[a]!=name[a]) break; } /* found a match */ - if(startname[a]==0) { + if (startname[a]==0) { /* first match */ - if(truncate[0]==0) + if (truncate[0]==0) BLI_strncpy(truncate, name, autocpl->maxlen); else { /* remove from truncate what is not in bone->name */ - for(a=0; amaxlen-1; a++) { - if(name[a] == 0) { + for (a=0; amaxlen-1; a++) { + if (name[a] == 0) { truncate[a]= 0; break; } - else if(truncate[a]!=name[a]) + else if (truncate[a]!=name[a]) truncate[a]= 0; } } @@ -2957,7 +2958,7 @@ void autocomplete_do_name(AutoComplete *autocpl, const char *name) void autocomplete_end(AutoComplete *autocpl, char *autoname) { - if(autocpl->truncate[0]) + if (autocpl->truncate[0]) BLI_strncpy(autoname, autocpl->truncate, autocpl->maxlen); else { if (autoname != autocpl->startname) /* don't copy a string over its self */ @@ -2973,14 +2974,14 @@ static void autocomplete_id(bContext *C, char *str, void *arg_v) int blocktype= (intptr_t)arg_v; ListBase *listb= which_libbase(CTX_data_main(C), blocktype); - if(listb==NULL) return; + if (listb==NULL) return; /* search if str matches the beginning of an ID struct */ - if(str[0]) { + if (str[0]) { AutoComplete *autocpl= autocomplete_begin(str, MAX_ID_NAME-2); ID *id; - for(id= listb->first; id; id= id->next) + for (id= listb->first; id; id= id->next) autocomplete_do_name(autocpl, id->name+2); autocomplete_end(autocpl, str); @@ -2989,7 +2990,7 @@ static void autocomplete_id(bContext *C, char *str, void *arg_v) static void ui_check_but_and_iconize(uiBut *but, int icon) { - if(icon) { + if (icon) { but->icon= (BIFIconID) icon; but->flag|= UI_HAS_ICON; } @@ -3002,7 +3003,8 @@ static uiBut *uiDefButBit(uiBlock *block, int type, int bit, int retval, const c int bitIdx= findBitIndex(bit); if (bitIdx==-1) { return NULL; - } else { + } + else { return uiDefBut(block, type|BIT|bitIdx, retval, str, x1, y1, x2, y2, poin, min, max, a1, a2, tip); } } @@ -3086,7 +3088,8 @@ static uiBut *uiDefIconButBit(uiBlock *block, int type, int bit, int retval, int int bitIdx= findBitIndex(bit); if (bitIdx==-1) { return NULL; - } else { + } + else { return uiDefIconBut(block, type|BIT|bitIdx, retval, icon, x1, y1, x2, y2, poin, min, max, a1, a2, tip); } } @@ -3164,7 +3167,8 @@ static uiBut *uiDefIconTextButBit(uiBlock *block, int type, int bit, int retval, int bitIdx= findBitIndex(bit); if (bitIdx==-1) { return NULL; - } else { + } + else { return uiDefIconTextBut(block, type|BIT|bitIdx, retval, icon, str, x1, y1, x2, y2, poin, min, max, a1, a2, tip); } } @@ -3272,19 +3276,19 @@ void uiBlockFlipOrder(uiBlock *block) uiBut *but, *next; float centy, miny=10000, maxy= -10000; - if(U.uiflag & USER_MENUFIXEDORDER) + if (U.uiflag & USER_MENUFIXEDORDER) return; - else if(block->flag & UI_BLOCK_NO_FLIP) + else if (block->flag & UI_BLOCK_NO_FLIP) return; - for(but= block->buttons.first; but; but= but->next) { - if(but->flag & UI_BUT_ALIGN) return; - if(but->y1 < miny) miny= but->y1; - if(but->y2 > maxy) maxy= but->y2; + for (but= block->buttons.first; but; but= but->next) { + if (but->flag & UI_BUT_ALIGN) return; + if (but->y1 < miny) miny= but->y1; + if (but->y2 > maxy) maxy= but->y2; } /* mirror trick */ centy= (miny+maxy)/2.0f; - for(but= block->buttons.first; but; but= but->next) { + for (but= block->buttons.first; but; but= but->next) { but->y1 = centy-(but->y1-centy); but->y2 = centy-(but->y2-centy); SWAP(float, but->y1, but->y2); @@ -3293,7 +3297,7 @@ void uiBlockFlipOrder(uiBlock *block) /* also flip order in block itself, for example for arrowkey */ lb.first= lb.last= NULL; but= block->buttons.first; - while(but) { + while (but) { next= but->next; BLI_remlink(&block->buttons, but); BLI_addtail(&lb, but); @@ -3374,7 +3378,7 @@ void uiButSetDragImage(uiBut *but, const char *path, int icon, struct ImBuf *imb PointerRNA *uiButGetOperatorPtrRNA(uiBut *but) { - if(but->optype && !but->opptr) { + if (but->optype && !but->opptr) { but->opptr= MEM_callocN(sizeof(PointerRNA), "uiButOpPtr"); WM_operator_properties_create_ptr(but->opptr, but->optype); } @@ -3477,7 +3481,7 @@ uiBut *uiDefIDPoinBut(uiBlock *block, uiIDPoinFuncFP func, short blocktype, int but->idpoin_idpp= (ID**) idpp; ui_check_but(but); - if(blocktype) + if (blocktype) uiButSetCompleteFunc(but, autocomplete_id, (void *)(intptr_t)blocktype); return but; @@ -3556,7 +3560,7 @@ uiBut *uiDefIconTextBlockBut(uiBlock *block, uiBlockCreateFunc func, void *arg, uiBut *but= ui_def_but(block, BLOCK, 0, str, x1, y1, x2, y2, arg, 0.0, 0.0, 0.0, 0.0, tip); /* XXX temp, old menu calls pass on icon arrow, which is now UI_ICON_SUBMENU flag */ - if(icon!=ICON_RIGHTARROW_THIN) { + if (icon!=ICON_RIGHTARROW_THIN) { but->icon= (BIFIconID) icon; but->flag|= UI_ICON_LEFT; } @@ -3630,9 +3634,9 @@ void uiButSetSearchFunc(uiBut *but, uiButSearchFunc sfunc, void *arg, uiButHandl uiButSetFunc(but, bfunc, arg, active); /* search buttons show red-alert if item doesn't exist, not for menus */ - if(0==(but->block->flag & UI_BLOCK_LOOP)) { + if (0==(but->block->flag & UI_BLOCK_LOOP)) { /* skip empty buttons, not all buttons need input, we only show invalid */ - if(but->drawstr[0]) + if (but->drawstr[0]) ui_but_search_test(but); } } diff --git a/source/blender/editors/interface/interface_draw.c b/source/blender/editors/interface/interface_draw.c index c8fbda8c28a..25c616cc67e 100644 --- a/source/blender/editors/interface/interface_draw.c +++ b/source/blender/editors/interface/interface_draw.c @@ -83,16 +83,16 @@ void uiDrawBox(int mode, float minx, float miny, float maxx, float maxy, float r int a; /* mult */ - for(a=0; a<7; a++) { + for (a=0; a<7; a++) { vec[a][0]*= rad; vec[a][1]*= rad; } glBegin(mode); /* start with corner right-bottom */ - if(roundboxtype & UI_CNR_BOTTOM_RIGHT) { + if (roundboxtype & UI_CNR_BOTTOM_RIGHT) { glVertex2f(maxx-rad, miny); - for(a=0; a<7; a++) { + for (a=0; a<7; a++) { glVertex2f(maxx-rad+vec[a][0], miny+vec[a][1]); } glVertex2f(maxx, miny+rad); @@ -100,9 +100,9 @@ void uiDrawBox(int mode, float minx, float miny, float maxx, float maxy, float r else glVertex2f(maxx, miny); /* corner right-top */ - if(roundboxtype & UI_CNR_TOP_RIGHT) { + if (roundboxtype & UI_CNR_TOP_RIGHT) { glVertex2f(maxx, maxy-rad); - for(a=0; a<7; a++) { + for (a=0; a<7; a++) { glVertex2f(maxx-vec[a][1], maxy-rad+vec[a][0]); } glVertex2f(maxx-rad, maxy); @@ -110,9 +110,9 @@ void uiDrawBox(int mode, float minx, float miny, float maxx, float maxy, float r else glVertex2f(maxx, maxy); /* corner left-top */ - if(roundboxtype & UI_CNR_TOP_LEFT) { + if (roundboxtype & UI_CNR_TOP_LEFT) { glVertex2f(minx+rad, maxy); - for(a=0; a<7; a++) { + for (a=0; a<7; a++) { glVertex2f(minx+rad-vec[a][0], maxy-vec[a][1]); } glVertex2f(minx, maxy-rad); @@ -120,9 +120,9 @@ void uiDrawBox(int mode, float minx, float miny, float maxx, float maxy, float r else glVertex2f(minx, maxy); /* corner left-bottom */ - if(roundboxtype & UI_CNR_BOTTOM_LEFT) { + if (roundboxtype & UI_CNR_BOTTOM_LEFT) { glVertex2f(minx, miny+rad); - for(a=0; a<7; a++) { + for (a=0; a<7; a++) { glVertex2f(minx+vec[a][1], miny+rad-vec[a][0]); } glVertex2f(minx+rad, miny); @@ -154,7 +154,7 @@ void uiDrawBoxShade(int mode, float minx, float miny, float maxx, float maxy, fl int a; /* mult */ - for(a=0; a<7; a++) { + for (a=0; a<7; a++) { vec[a][0]*= rad; vec[a][1]*= rad; } /* get current color, needs to be outside of glBegin/End */ @@ -172,12 +172,12 @@ void uiDrawBoxShade(int mode, float minx, float miny, float maxx, float maxy, fl glBegin(mode); /* start with corner right-bottom */ - if(roundboxtype & UI_CNR_BOTTOM_RIGHT) { + if (roundboxtype & UI_CNR_BOTTOM_RIGHT) { round_box_shade_col(coltop, coldown, 0.0); glVertex2f(maxx-rad, miny); - for(a=0; a<7; a++) { + for (a=0; a<7; a++) { round_box_shade_col(coltop, coldown, vec[a][1]*idiv); glVertex2f(maxx-rad+vec[a][0], miny+vec[a][1]); } @@ -191,12 +191,12 @@ void uiDrawBoxShade(int mode, float minx, float miny, float maxx, float maxy, fl } /* corner right-top */ - if(roundboxtype & UI_CNR_TOP_RIGHT) { + if (roundboxtype & UI_CNR_TOP_RIGHT) { round_box_shade_col(coltop, coldown, (div-rad)*idiv); glVertex2f(maxx, maxy-rad); - for(a=0; a<7; a++) { + for (a=0; a<7; a++) { round_box_shade_col(coltop, coldown, (div-rad+vec[a][1])*idiv); glVertex2f(maxx-vec[a][1], maxy-rad+vec[a][0]); } @@ -209,12 +209,12 @@ void uiDrawBoxShade(int mode, float minx, float miny, float maxx, float maxy, fl } /* corner left-top */ - if(roundboxtype & UI_CNR_TOP_LEFT) { + if (roundboxtype & UI_CNR_TOP_LEFT) { round_box_shade_col(coltop, coldown, 1.0); glVertex2f(minx+rad, maxy); - for(a=0; a<7; a++) { + for (a=0; a<7; a++) { round_box_shade_col(coltop, coldown, (div-vec[a][1])*idiv); glVertex2f(minx+rad-vec[a][0], maxy-vec[a][1]); } @@ -228,12 +228,12 @@ void uiDrawBoxShade(int mode, float minx, float miny, float maxx, float maxy, fl } /* corner left-bottom */ - if(roundboxtype & UI_CNR_BOTTOM_LEFT) { + if (roundboxtype & UI_CNR_BOTTOM_LEFT) { round_box_shade_col(coltop, coldown, rad*idiv); glVertex2f(minx, miny+rad); - for(a=0; a<7; a++) { + for (a=0; a<7; a++) { round_box_shade_col(coltop, coldown, (rad-vec[a][1])*idiv); glVertex2f(minx+vec[a][1], miny+rad-vec[a][0]); } @@ -262,7 +262,7 @@ void uiDrawBoxVerticalShade(int mode, float minx, float miny, float maxx, float int a; /* mult */ - for(a=0; a<7; a++) { + for (a=0; a<7; a++) { vec[a][0]*= rad; vec[a][1]*= rad; } /* get current color, needs to be outside of glBegin/End */ @@ -280,11 +280,11 @@ void uiDrawBoxVerticalShade(int mode, float minx, float miny, float maxx, float glBegin(mode); /* start with corner right-bottom */ - if(roundboxtype & UI_CNR_BOTTOM_RIGHT) { + if (roundboxtype & UI_CNR_BOTTOM_RIGHT) { round_box_shade_col(colLeft, colRight, 0.0); glVertex2f(maxx-rad, miny); - for(a=0; a<7; a++) { + for (a=0; a<7; a++) { round_box_shade_col(colLeft, colRight, vec[a][0]*idiv); glVertex2f(maxx-rad+vec[a][0], miny+vec[a][1]); } @@ -298,11 +298,11 @@ void uiDrawBoxVerticalShade(int mode, float minx, float miny, float maxx, float } /* corner right-top */ - if(roundboxtype & UI_CNR_TOP_RIGHT) { + if (roundboxtype & UI_CNR_TOP_RIGHT) { round_box_shade_col(colLeft, colRight, 0.0); glVertex2f(maxx, maxy-rad); - for(a=0; a<7; a++) { + for (a=0; a<7; a++) { round_box_shade_col(colLeft, colRight, (div-rad-vec[a][0])*idiv); glVertex2f(maxx-vec[a][1], maxy-rad+vec[a][0]); @@ -316,11 +316,11 @@ void uiDrawBoxVerticalShade(int mode, float minx, float miny, float maxx, float } /* corner left-top */ - if(roundboxtype & UI_CNR_TOP_LEFT) { + if (roundboxtype & UI_CNR_TOP_LEFT) { round_box_shade_col(colLeft, colRight, (div-rad)*idiv); glVertex2f(minx+rad, maxy); - for(a=0; a<7; a++) { + for (a=0; a<7; a++) { round_box_shade_col(colLeft, colRight, (div-rad+vec[a][0])*idiv); glVertex2f(minx+rad-vec[a][0], maxy-vec[a][1]); } @@ -334,11 +334,11 @@ void uiDrawBoxVerticalShade(int mode, float minx, float miny, float maxx, float } /* corner left-bottom */ - if(roundboxtype & UI_CNR_BOTTOM_LEFT) { + if (roundboxtype & UI_CNR_BOTTOM_LEFT) { round_box_shade_col(colLeft, colRight, 1.0); glVertex2f(minx, miny+rad); - for(a=0; a<7; a++) { + for (a=0; a<7; a++) { round_box_shade_col(colLeft, colRight, (vec[a][0])*idiv); glVertex2f(minx+vec[a][1], miny+rad-vec[a][0]); } @@ -360,7 +360,7 @@ void uiRoundRect(float minx, float miny, float maxx, float maxy, float rad) { float color[4]; - if(roundboxtype & UI_RB_ALPHA) { + if (roundboxtype & UI_RB_ALPHA) { glGetFloatv(GL_CURRENT_COLOR, color); color[3]= 0.5; glColor4fv(color); @@ -382,7 +382,7 @@ void uiRoundBox(float minx, float miny, float maxx, float maxy, float rad) { float color[4]; - if(roundboxtype & UI_RB_ALPHA) { + if (roundboxtype & UI_RB_ALPHA) { glGetFloatv(GL_CURRENT_COLOR, color); color[3]= 0.5; glColor4fv(color); @@ -401,7 +401,7 @@ void uiEmboss(float x1, float y1, float x2, float y2, int sel) { /* below */ - if(sel) glColor3ub(200,200,200); + if (sel) glColor3ub(200,200,200); else glColor3ub(50,50,50); fdrawline(x1, y1, x2, y1); @@ -409,7 +409,7 @@ void uiEmboss(float x1, float y1, float x2, float y2, int sel) fdrawline(x2, y1, x2, y2); /* top */ - if(sel) glColor3ub(50,50,50); + if (sel) glColor3ub(50,50,50); else glColor3ub(200,200,200); fdrawline(x1, y2, x2, y2); @@ -477,8 +477,8 @@ static void ui_draw_but_CHARTAB(uiBut *but) int charmax = G.charmax; /* FO_BUILTIN_NAME font in use. There are TTF FO_BUILTIN_NAME and non-TTF FO_BUILTIN_NAME fonts */ - if(!strcmp(G.selfont->name, FO_BUILTIN_NAME)) { - if(G.ui_international == TRUE) { + if (!strcmp(G.selfont->name, FO_BUILTIN_NAME)) { + if (G.ui_international == TRUE) { charmax = 0xff; } else { @@ -487,7 +487,7 @@ static void ui_draw_but_CHARTAB(uiBut *but) } /* Category list exited without selecting the area */ - if(G.charmax == 0) + if (G.charmax == 0) charmax = G.charmax = 0xffff; /* Calculate the size of the button */ @@ -506,9 +506,9 @@ static void ui_draw_but_CHARTAB(uiBut *but) cs = G.charstart; /* Set the font, in case it is not FO_BUILTIN_NAME font */ - if(G.selfont && strcmp(G.selfont->name, FO_BUILTIN_NAME)) { + if (G.selfont && strcmp(G.selfont->name, FO_BUILTIN_NAME)) { // Is the font file packed, if so then use the packed file - if(G.selfont->packedfile) { + if (G.selfont->packedfile) { pf = G.selfont->packedfile; FTF_SetFont(pf->data, pf->size, 14.0); } @@ -522,7 +522,7 @@ static void ui_draw_but_CHARTAB(uiBut *but) } } else { - if(G.ui_international == TRUE) { + if (G.ui_international == TRUE) { FTF_SetFont((unsigned char *) datatoc_bfont_ttf, datatoc_bfont_ttf_size, 14.0); } } @@ -534,14 +534,14 @@ static void ui_draw_but_CHARTAB(uiBut *but) glRectf((rect->xmin), (rect->ymin), (rect->xmax), (rect->ymax)); glColor3ub(0, 0, 0); - for(y = 0; y < 6; y++) { + for (y = 0; y < 6; y++) { // Do not draw more than the category allows - if(cs > charmax) break; + if (cs > charmax) break; - for(x = 0; x < 12; x++) + for (x = 0; x < 12; x++) { // Do not draw more than the category allows - if(cs > charmax) break; + if (cs > charmax) break; // Draw one grid cell glBegin(GL_LINE_LOOP); @@ -610,7 +610,7 @@ static void ui_draw_but_CHARTAB(uiBut *but) glShadeModel(GL_FLAT); /* Return Font Settings to original */ - if(U.fontsize && U.fontname[0]) { + if (U.fontsize && U.fontname[0]) { result = FTF_SetFont((unsigned char *)U.fontname, 0, U.fontsize); } else if (U.fontsize) { @@ -622,7 +622,7 @@ static void ui_draw_but_CHARTAB(uiBut *but) } /* resets the font size */ - if(G.ui_international == TRUE) { + if (G.ui_international == TRUE) { // uiSetCurFont(but->block, UI_HELV); } } @@ -769,8 +769,8 @@ void ui_draw_but_WAVEFORM(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wcol), /* log scale for alpha */ alpha = scopes->wavefrm_alpha*scopes->wavefrm_alpha; - for(c=0; c<3; c++) { - for(i=0; i<3; i++) { + for (c=0; c<3; c++) { + for (i=0; i<3; i++) { colors_alpha[c][i] = colors[c][i] * alpha; colorsycc_alpha[c][i] = colorsycc[c][i] * alpha; } @@ -811,7 +811,7 @@ void ui_draw_but_WAVEFORM(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wcol), fdrawline(rect.xmin+w, rect.ymin, rect.xmin+w, rect.ymax); /* 16-235-240 level in case of ITU-R BT601/709 */ glColor4f(1.f, 0.4f, 0.f, 0.2f); - if (ELEM(scopes->wavefrm_mode, SCOPES_WAVEFRM_YCC_601, SCOPES_WAVEFRM_YCC_709)){ + if (ELEM(scopes->wavefrm_mode, SCOPES_WAVEFRM_YCC_601, SCOPES_WAVEFRM_YCC_709)) { fdrawline(rect.xmin+22, yofs+h*16.0f/255.0f, rect.xmax+1, yofs+h*16.0f/255.0f); fdrawline(rect.xmin+22, yofs+h*235.0f/255.0f, rect.xmin+w3, yofs+h*235.0f/255.0f); fdrawline(rect.xmin+3*w3, yofs+h*235.0f/255.0f, rect.xmax+1, yofs+h*235.0f/255.0f); @@ -826,7 +826,7 @@ void ui_draw_but_WAVEFORM(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wcol), /* LUMA (1 channel) */ glBlendFunc(GL_ONE,GL_ONE); glColor3f(alpha, alpha, alpha); - if (scopes->wavefrm_mode == SCOPES_WAVEFRM_LUMA){ + if (scopes->wavefrm_mode == SCOPES_WAVEFRM_LUMA) { glBlendFunc(GL_ONE,GL_ONE); @@ -1004,9 +1004,9 @@ void ui_draw_but_VECTORSCOPE(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wco fdrawline(centerx - (diam/2)-5, centery, centerx + (diam/2)+5, centery); fdrawline(centerx, centery - (diam/2)-5, centerx, centery + (diam/2)+5); /* circles */ - for(j=0; j<5; j++) { + for (j=0; j<5; j++) { glBegin(GL_LINE_STRIP); - for(i=0; i<=360; i=i+15) { + for (i=0; i<=360; i=i+15) { const float a= DEG2RADF((float)i); const float r= (j+1)/10.0f; glVertex2f(polar_to_x(centerx,diam,r,a), polar_to_y(centery,diam,r,a)); @@ -1018,7 +1018,7 @@ void ui_draw_but_VECTORSCOPE(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wco fdrawline(polar_to_x(centerx, diam, 0.5f, skin_rad), polar_to_y(centery,diam,0.5,skin_rad), polar_to_x(centerx, diam, 0.1f, skin_rad), polar_to_y(centery,diam,0.1,skin_rad)); /* saturation points */ - for(i=0; i<6; i++) + for (i=0; i<6; i++) vectorscope_draw_target(centerx, centery, diam, colors[i]); if (scopes->ok && scopes->vecscope != NULL) { @@ -1055,7 +1055,7 @@ void ui_draw_but_COLORBAND(uiBut *but, uiWidgetColors *UNUSED(wcol), rcti *rect) float pos, colf[4]= {0,0,0,0}; /* initialize in case the colorband isn't valid */ coba= (ColorBand *)(but->editcoba? but->editcoba: but->poin); - if(coba==NULL) return; + if (coba==NULL) return; x1= rect->xmin; y1= rect->ymin; @@ -1086,7 +1086,7 @@ void ui_draw_but_COLORBAND(uiBut *but, uiWidgetColors *UNUSED(wcol), rcti *rect) glColor4fv( &cbd->r ); glVertex2fv(v1); glVertex2fv(v2); - for( a = 1; a <= sizex; a++ ) { + for ( a = 1; a <= sizex; a++ ) { pos = ((float)a) / (sizex-1); do_colorband(coba, pos, colf); if (but->block->color_profile != BLI_PR_NONE) @@ -1117,10 +1117,10 @@ void ui_draw_but_COLORBAND(uiBut *but, uiWidgetColors *UNUSED(wcol), rcti *rect) cbd= coba->data; glBegin(GL_LINES); - for(a=0; atot; a++, cbd++) { + for (a=0; atot; a++, cbd++) { v1[0]=v2[0]=v3[0]=v1a[0]=v2a[0]= x1+ cbd->pos*sizex; - if(a==coba->cur) { + if (a==coba->cur) { glColor3ub(0, 0, 0); glVertex2fv(v1); glVertex2fv(v3); @@ -1185,7 +1185,7 @@ void ui_draw_but_NORMAL(uiBut *but, uiWidgetColors *wcol, rcti *rect) glCullFace(GL_BACK); glEnable(GL_CULL_FACE); /* disable blender light */ - for(a=0; a<8; a++) { + for (a=0; a<8; a++) { old[a]= glIsEnabled(GL_LIGHT0+a); glDisable(GL_LIGHT0+a); } @@ -1207,14 +1207,14 @@ void ui_draw_but_NORMAL(uiBut *but, uiWidgetColors *wcol, rcti *rect) glPushMatrix(); glTranslatef(rect->xmin + 0.5f*(rect->xmax-rect->xmin), rect->ymin+ 0.5f*(rect->ymax-rect->ymin), 0.0f); - if( rect->xmax-rect->xmin < rect->ymax-rect->ymin) + if ( rect->xmax-rect->xmin < rect->ymax-rect->ymin) size= (rect->xmax-rect->xmin)/200.f; else size= (rect->ymax-rect->ymin)/200.f; glScalef(size, size, size); - if(displist==0) { + if (displist==0) { GLUquadricObj *qobj; displist= glGenLists(1); @@ -1249,8 +1249,8 @@ void ui_draw_but_NORMAL(uiBut *but, uiWidgetColors *wcol, rcti *rect) glPopMatrix(); /* enable blender light */ - for(a=0; a<8; a++) { - if(old[a]) + for (a=0; a<8; a++) { + if (old[a]) glEnable(GL_LIGHT0+a); } } @@ -1262,8 +1262,8 @@ static void ui_draw_but_curve_grid(rcti *rect, float zoomx, float zoomy, float o glBegin(GL_LINES); dx= step*zoomx; fx= rect->xmin + zoomx*(-offsx); - if(fx > rect->xmin) fx -= dx*(floorf(fx-rect->xmin)); - while(fx < rect->xmax) { + if (fx > rect->xmin) fx -= dx*(floorf(fx-rect->xmin)); + while (fx < rect->xmax) { glVertex2f(fx, rect->ymin); glVertex2f(fx, rect->ymax); fx+= dx; @@ -1271,8 +1271,8 @@ static void ui_draw_but_curve_grid(rcti *rect, float zoomx, float zoomy, float o dy= step*zoomy; fy= rect->ymin + zoomy*(-offsy); - if(fy > rect->ymin) fy -= dy*(floorf(fy-rect->ymin)); - while(fy < rect->ymax) { + if (fy > rect->ymin) fy -= dy*(floorf(fy-rect->ymin)); + while (fy < rect->ymax) { glVertex2f(rect->xmin, fy); glVertex2f(rect->xmax, fy); fy+= dy; @@ -1317,7 +1317,7 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, uiWidgetColors *wcol, rcti *rect offsy= cumap->curr.ymin-but->aspect/zoomy; /* backdrop */ - if(cumap->flag & CUMA_DO_CLIP) { + if (cumap->flag & CUMA_DO_CLIP) { glColor3ubvShade((unsigned char *)wcol->inner, -20); glRectf(rect->xmin, rect->ymin, rect->xmax, rect->ymax); glColor3ubv((unsigned char*)wcol->inner); @@ -1367,7 +1367,7 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, uiWidgetColors *wcol, rcti *rect /* cfra option */ /* XXX 2.48 */ #if 0 - if(cumap->flag & CUMA_DRAW_CFRA) { + if (cumap->flag & CUMA_DRAW_CFRA) { glColor3ub(0x60, 0xc0, 0x40); glBegin(GL_LINES); glVertex2f(rect->xmin + zoomx*(cumap->sample[0]-offsx), rect->ymin); @@ -1379,8 +1379,8 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, uiWidgetColors *wcol, rcti *rect /* XXX 2.48 */ #if 0 - if(cumap->flag & CUMA_DRAW_SAMPLE) { - if(cumap->cur==3) { + if (cumap->flag & CUMA_DRAW_SAMPLE) { + if (cumap->cur==3) { float lum= cumap->sample[0]*0.35f + cumap->sample[1]*0.45f + cumap->sample[2]*0.2f; glColor3ub(240, 240, 240); @@ -1390,9 +1390,9 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, uiWidgetColors *wcol, rcti *rect glEnd(); } else { - if(cumap->cur==0) + if (cumap->cur==0) glColor3ub(240, 100, 100); - else if(cumap->cur==1) + else if (cumap->cur==1) glColor3ub(100, 240, 100); else glColor3ub(100, 100, 240); @@ -1411,25 +1411,25 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, uiWidgetColors *wcol, rcti *rect glEnable(GL_BLEND); glBegin(GL_LINE_STRIP); - if(cuma->table==NULL) + if (cuma->table==NULL) curvemapping_changed(cumap, 0); /* 0 = no remove doubles */ cmp= cuma->table; /* first point */ - if((cuma->flag & CUMA_EXTEND_EXTRAPOLATE)==0) + if ((cuma->flag & CUMA_EXTEND_EXTRAPOLATE)==0) glVertex2f(rect->xmin, rect->ymin + zoomy*(cmp[0].y-offsy)); else { fx= rect->xmin + zoomx*(cmp[0].x-offsx + cuma->ext_in[0]); fy= rect->ymin + zoomy*(cmp[0].y-offsy + cuma->ext_in[1]); glVertex2f(fx, fy); } - for(a=0; a<=CM_TABLE; a++) { + for (a=0; a<=CM_TABLE; a++) { fx= rect->xmin + zoomx*(cmp[a].x-offsx); fy= rect->ymin + zoomy*(cmp[a].y-offsy); glVertex2f(fx, fy); } /* last point */ - if((cuma->flag & CUMA_EXTEND_EXTRAPOLATE)==0) + if ((cuma->flag & CUMA_EXTEND_EXTRAPOLATE)==0) glVertex2f(rect->xmax, rect->ymin + zoomy*(cmp[CM_TABLE].y-offsy)); else { fx= rect->xmin + zoomx*(cmp[CM_TABLE].x-offsx - cuma->ext_out[0]); @@ -1444,8 +1444,8 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, uiWidgetColors *wcol, rcti *rect cmp= cuma->curve; glPointSize(3.0f); bglBegin(GL_POINTS); - for(a=0; atotpoint; a++) { - if(cmp[a].flag & SELECT) + for (a=0; atotpoint; a++) { + if (cmp[a].flag & SELECT) UI_ThemeColor(TH_TEXT_HI); else UI_ThemeColor(TH_TEXT); @@ -1475,7 +1475,7 @@ static ImBuf *scale_trackpreview_ibuf(ImBuf *ibuf, float track_pos[2], int width scaleibuf= IMB_allocImBuf(width, height, 32, IB_rect); - for(y= 0; ywinrct.xmin + (rect.xmin-1), ar->winrct.ymin+(rect.ymin-1), (rect.xmax+1)-(rect.xmin-1), (rect.ymax+1)-(rect.ymin-1)); - if(scopes->track_disabled) { + if (scopes->track_disabled) { glColor4f(0.7f, 0.3f, 0.3f, 0.3f); uiSetRoundBox(15); uiDrawBox(GL_POLYGON, rect.xmin-1, rect.ymin, rect.xmax+1, rect.ymax+1, 3.0f); ok= 1; } - else if(scopes->track_preview) { + else if (scopes->track_preview) { /* additional margin around image */ /* NOTE: should be kept in sync with value from BKE_movieclip_update_scopes */ const int margin= 3; @@ -1532,7 +1532,7 @@ void ui_draw_but_TRACKPREVIEW(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wc width= rect.xmax-rect.xmin+1; height = rect.ymax-rect.ymin; - if(width > 0 && height > 0) { + if (width > 0 && height > 0) { zoomx= (float)width / (scopes->track_preview->x-2*margin); zoomy= (float)height / (scopes->track_preview->y-2*margin); @@ -1549,8 +1549,8 @@ void ui_draw_but_TRACKPREVIEW(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wc glTranslatef(off_x+rect.xmin+track_pos[0]*zoomx, off_y+rect.ymin+track_pos[1]*zoomy, 0.f); glScissor(ar->winrct.xmin + rect.xmin, ar->winrct.ymin+rect.ymin, rect.xmax-rect.xmin, rect.ymax-rect.ymin); - for(a= 0; a< 2; a++) { - if(a==1) { + for (a= 0; a< 2; a++) { + if (a==1) { glLineStipple(3, 0xaaaa); glEnable(GL_LINE_STIPPLE); UI_ThemeColor(TH_SEL_MARKER); @@ -1574,7 +1574,7 @@ void ui_draw_but_TRACKPREVIEW(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wc ok= 1; } - if(!ok) { + if (!ok) { glColor4f(0.f, 0.f, 0.f, 0.3f); uiSetRoundBox(15); uiDrawBox(GL_POLYGON, rect.xmin-1, rect.ymin, rect.xmax+1, rect.ymax+1, 3.0f); @@ -1647,14 +1647,14 @@ void ui_dropshadow(rctf *rct, float radius, float aspect, int UNUSED(select)) glEnable(GL_BLEND); - if(radius > (rct->ymax-rct->ymin-10.0f)/2.0f) + if (radius > (rct->ymax-rct->ymin-10.0f)/2.0f) rad= (rct->ymax-rct->ymin-10.0f)/2.0f; else rad= radius; i= 12; #if 0 - if(select) { + if (select) { a= i*aspect; /* same as below */ } else @@ -1663,7 +1663,7 @@ void ui_dropshadow(rctf *rct, float radius, float aspect, int UNUSED(select)) a= i*aspect; } - for(; i--; a-=aspect) { + for (; i--; a-=aspect) { /* alpha ranges from 2 to 20 or so */ glColor4ub(0, 0, 0, alpha); alpha+= 2; diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index de5f12d597e..21c3f4ca038 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -212,18 +212,18 @@ static int ui_but_editable(uiBut *but) static uiBut *ui_but_prev(uiBut *but) { - while(but->prev) { + while (but->prev) { but= but->prev; - if(!ui_but_editable(but)) return but; + if (!ui_but_editable(but)) return but; } return NULL; } static uiBut *ui_but_next(uiBut *but) { - while(but->next) { + while (but->next) { but= but->next; - if(!ui_but_editable(but)) return but; + if (!ui_but_editable(but)) return but; } return NULL; } @@ -233,8 +233,8 @@ static uiBut *ui_but_first(uiBlock *block) uiBut *but; but= block->buttons.first; - while(but) { - if(!ui_but_editable(but)) return but; + while (but) { + if (!ui_but_editable(but)) return but; but= but->next; } return NULL; @@ -245,8 +245,8 @@ static uiBut *ui_but_last(uiBlock *block) uiBut *but; but= block->buttons.last; - while(but) { - if(!ui_but_editable(but)) return but; + while (but) { + if (!ui_but_editable(but)) return but; but= but->prev; } return NULL; @@ -254,8 +254,8 @@ static uiBut *ui_but_last(uiBlock *block) static int ui_is_a_warp_but(uiBut *but) { - if(U.uiflag & USER_CONTINUOUS_MOUSE) - if(ELEM4(but->type, NUM, NUMABS, HSVCIRCLE, TRACKPREVIEW)) + if (U.uiflag & USER_CONTINUOUS_MOUSE) + if (ELEM4(but->type, NUM, NUMABS, HSVCIRCLE, TRACKPREVIEW)) return TRUE; return FALSE; @@ -286,10 +286,10 @@ static void ui_apply_but_func(bContext *C, uiBut *but) * handling is done, i.e. menus are closed, in order to avoid conflicts * with these functions removing the buttons we are working with */ - if(but->func || but->funcN || block->handle_func || but->rename_func || (but->type == BUTM && block->butm_func) || but->optype || but->rnaprop) { + if (but->func || but->funcN || block->handle_func || but->rename_func || (but->type == BUTM && block->butm_func) || but->optype || but->rnaprop) { after= MEM_callocN(sizeof(uiAfterFunc), "uiAfterFunc"); - if(but->func && ELEM(but, but->func_arg1, but->func_arg2)) { + if (but->func && ELEM(but, but->func_arg1, but->func_arg2)) { /* exception, this will crash due to removed button otherwise */ but->func(C, but->func_arg1, but->func_arg2); } @@ -311,7 +311,7 @@ static void ui_apply_but_func(bContext *C, uiBut *but) after->handle_func_arg= block->handle_func_arg; after->retval= but->retval; - if(but->type == BUTM) { + if (but->type == BUTM) { after->butm_func= block->butm_func; after->butm_func_arg= block->butm_func_arg; after->a2= but->a2; @@ -324,7 +324,7 @@ static void ui_apply_but_func(bContext *C, uiBut *but) after->rnapoin= but->rnapoin; after->rnaprop= but->rnaprop; - if(but->context) + if (but->context) after->context= CTX_store_copy(but->context); but->optype= NULL; @@ -340,17 +340,17 @@ static void ui_apply_autokey_undo(bContext *C, uiBut *but) Scene *scene= CTX_data_scene(C); uiAfterFunc *after; - if(but->flag & UI_BUT_UNDO) { + if (but->flag & UI_BUT_UNDO) { const char *str= NULL; /* define which string to use for undo */ if ELEM(but->type, LINK, INLINK) str= "Add button link"; else if ELEM(but->type, MENU, ICONTEXTROW) str= but->drawstr; - else if(but->drawstr[0]) str= but->drawstr; + else if (but->drawstr[0]) str= but->drawstr; else str= but->tip; /* fallback, else we don't get an undo! */ - if(str == NULL || str[0] == '\0') { + if (str == NULL || str[0] == '\0') { str= "Unknown Action"; } @@ -374,51 +374,51 @@ static void ui_apply_but_funcs_after(bContext *C) funcs= UIAfterFuncs; UIAfterFuncs.first= UIAfterFuncs.last= NULL; - for(afterf=funcs.first; afterf; afterf=after.next) { + for (afterf=funcs.first; afterf; afterf=after.next) { after= *afterf; /* copy to avoid memleak on exit() */ BLI_freelinkN(&funcs, afterf); - if(after.context) + if (after.context) CTX_store_set(C, after.context); - if(after.opptr) { + if (after.opptr) { /* free in advance to avoid leak on exit */ opptr= *after.opptr, MEM_freeN(after.opptr); } - if(after.optype) + if (after.optype) WM_operator_name_call(C, after.optype->idname, after.opcontext, (after.opptr)? &opptr: NULL); - if(after.opptr) + if (after.opptr) WM_operator_properties_free(&opptr); - if(after.rnapoin.data) + if (after.rnapoin.data) RNA_property_update(C, &after.rnapoin, after.rnaprop); - if(after.context) { + if (after.context) { CTX_store_set(C, NULL); CTX_store_free(after.context); } - if(after.func) + if (after.func) after.func(C, after.func_arg1, after.func_arg2); - if(after.funcN) + if (after.funcN) after.funcN(C, after.func_argN, after.func_arg2); - if(after.func_argN) + if (after.func_argN) MEM_freeN(after.func_argN); - if(after.handle_func) + if (after.handle_func) after.handle_func(C, after.handle_func_arg, after.retval); - if(after.butm_func) + if (after.butm_func) after.butm_func(C, after.butm_func_arg, after.a2); - if(after.rename_func) + if (after.rename_func) after.rename_func(C, after.rename_arg1, after.rename_orig); - if(after.rename_orig) + if (after.rename_orig) MEM_freeN(after.rename_orig); - if(after.undostr[0]) + if (after.undostr[0]) ED_undo_push(C, after.undostr); } } @@ -442,7 +442,7 @@ static void ui_apply_but_BUTM(bContext *C, uiBut *but, uiHandleButtonData *data) static void ui_apply_but_BLOCK(bContext *C, uiBut *but, uiHandleButtonData *data) { - if(ELEM3(but->type, MENU, ICONROW, ICONTEXTROW)) + if (ELEM3(but->type, MENU, ICONROW, ICONTEXTROW)) ui_set_but_val(but, data->value); ui_check_but(but); @@ -457,50 +457,50 @@ static void ui_apply_but_TOG(bContext *C, uiBut *but, uiHandleButtonData *data) int w, lvalue, push; /* local hack... */ - if(but->type==BUT_TOGDUAL && data->togdual) { - if(but->pointype==SHO) + if (but->type==BUT_TOGDUAL && data->togdual) { + if (but->pointype==SHO) but->poin += 2; - else if(but->pointype==INT) + else if (but->pointype==INT) but->poin += 4; } value= ui_get_but_val(but); lvalue= (int)value; - if(but->bit) { + if (but->bit) { w= BTST(lvalue, but->bitnr); - if(w) lvalue = BCLR(lvalue, but->bitnr); + if (w) lvalue = BCLR(lvalue, but->bitnr); else lvalue = BSET(lvalue, but->bitnr); - if(but->type==TOGR) { - if(!data->togonly) { + if (but->type==TOGR) { + if (!data->togonly) { lvalue= 1<<(but->bitnr); ui_set_but_val(but, (double)lvalue); } else { - if(lvalue==0) lvalue= 1<<(but->bitnr); + if (lvalue==0) lvalue= 1<<(but->bitnr); } } ui_set_but_val(but, (double)lvalue); - if(but->type==ICONTOG || but->type==ICONTOGN) ui_check_but(but); + if (but->type==ICONTOG || but->type==ICONTOGN) ui_check_but(but); } else { - if(value==0.0) push= 1; + if (value==0.0) push= 1; else push= 0; - if(ELEM3(but->type, TOGN, ICONTOGN, OPTIONN)) push= !push; + if (ELEM3(but->type, TOGN, ICONTOGN, OPTIONN)) push= !push; ui_set_but_val(but, (double)push); - if(but->type==ICONTOG || but->type==ICONTOGN) ui_check_but(but); + if (but->type==ICONTOG || but->type==ICONTOGN) ui_check_but(but); } /* end local hack... */ - if(but->type==BUT_TOGDUAL && data->togdual) { - if(but->pointype==SHO) + if (but->type==BUT_TOGDUAL && data->togdual) { + if (but->pointype==SHO) but->poin -= 2; - else if(but->pointype==INT) + else if (but->pointype==INT) but->poin -= 4; } @@ -517,8 +517,8 @@ static void ui_apply_but_ROW(bContext *C, uiBlock *block, uiBut *but, uiHandleBu ui_set_but_val(but, but->hardmax); /* states of other row buttons */ - for(bt= block->buttons.first; bt; bt= bt->next) - if(bt!=but && bt->poin==but->poin && ELEM(bt->type, ROW, LISTROW)) + for (bt= block->buttons.first; bt; bt= bt->next) + if (bt!=but && bt->poin==but->poin && ELEM(bt->type, ROW, LISTROW)) ui_check_but(bt); ui_apply_but_func(C, but); @@ -529,7 +529,7 @@ static void ui_apply_but_ROW(bContext *C, uiBlock *block, uiBut *but, uiHandleBu static void ui_apply_but_TEX(bContext *C, uiBut *but, uiHandleButtonData *data) { - if(!data->str) + if (!data->str) return; ui_set_but_string(C, but, data->str); @@ -548,8 +548,8 @@ static void ui_apply_but_TEX(bContext *C, uiBut *but, uiHandleButtonData *data) static void ui_apply_but_NUM(bContext *C, uiBut *but, uiHandleButtonData *data) { - if(data->str) { - if(ui_set_but_string(C, but, data->str)) { + if (data->str) { + if (ui_set_but_string(C, but, data->str)) { data->value= ui_get_but_val(but); } else { @@ -569,27 +569,29 @@ static void ui_apply_but_NUM(bContext *C, uiBut *but, uiHandleButtonData *data) static void ui_apply_but_TOG3(bContext *C, uiBut *but, uiHandleButtonData *data) { - if(but->pointype==SHO ) { + if (but->pointype==SHO ) { short *sp= (short *)but->poin; - if( BTST(sp[1], but->bitnr)) { + if ( BTST(sp[1], but->bitnr)) { sp[1]= BCLR(sp[1], but->bitnr); sp[0]= BCLR(sp[0], but->bitnr); } - else if( BTST(sp[0], but->bitnr)) { + else if ( BTST(sp[0], but->bitnr)) { sp[1]= BSET(sp[1], but->bitnr); - } else { + } + else { sp[0]= BSET(sp[0], but->bitnr); } } else { - if( BTST(*(but->poin+2), but->bitnr)) { + if ( BTST(*(but->poin+2), but->bitnr)) { *(but->poin+2)= BCLR(*(but->poin+2), but->bitnr); *(but->poin)= BCLR(*(but->poin), but->bitnr); } - else if( BTST(*(but->poin), but->bitnr)) { + else if ( BTST(*(but->poin), but->bitnr)) { *(but->poin+2)= BSET(*(but->poin+2), but->bitnr); - } else { + } + else { *(but->poin)= BSET(*(but->poin), but->bitnr); } } @@ -654,8 +656,8 @@ static int ui_but_mouse_inside_icon(uiBut *but, ARegion *ar, wmEvent *event) rect.xmin = but->x1; rect.xmax = but->x2; rect.ymin = but->y1; rect.ymax = but->y2; - if(but->imb); /* use button size itself */ - else if(but->flag & UI_ICON_LEFT) { + if (but->imb); /* use button size itself */ + else if (but->flag & UI_ICON_LEFT) { rect.xmax = rect.xmin + (rect.ymax-rect.ymin); } else { @@ -672,14 +674,14 @@ static int ui_but_start_drag(bContext *C, uiBut *but, uiHandleButtonData *data, /* prevent other WM gestures to start while we try to drag */ WM_gestures_remove(C); - if( ABS(data->dragstartx - event->x) + ABS(data->dragstarty - event->y) > U.dragthreshold ) { + if ( ABS(data->dragstartx - event->x) + ABS(data->dragstarty - event->y) > U.dragthreshold ) { wmDrag *drag; button_activate_state(C, but, BUTTON_STATE_EXIT); data->cancel= 1; drag= WM_event_start_drag(C, but->icon, but->dragtype, but->dragpoin, ui_get_but_val(but)); - if(but->imb) + if (but->imb) WM_event_drag_image(drag, but->imb, but->imb_scale, but->x2-but->x1, but->y2-but->y1); return 1; } @@ -697,31 +699,31 @@ static void ui_delete_active_linkline(uiBlock *block) int a, b; but= block->buttons.first; - while(but) { - if(but->type==LINK && but->link) { + while (but) { + if (but->type==LINK && but->link) { line= but->link->lines.first; - while(line) { + while (line) { nline= line->next; - if(line->flag & UI_SELECT) { + if (line->flag & UI_SELECT) { BLI_remlink(&but->link->lines, line); link= line->from->link; /* are there more pointers allowed? */ - if(link->ppoin) { + if (link->ppoin) { - if(*(link->totlink)==1) { + if (*(link->totlink)==1) { *(link->totlink)= 0; MEM_freeN(*(link->ppoin)); *(link->ppoin)= NULL; } else { b= 0; - for(a=0; a< (*(link->totlink)); a++) { + for (a=0; a< (*(link->totlink)); a++) { - if( (*(link->ppoin))[a] != line->to->poin ) { + if ( (*(link->ppoin))[a] != line->to->poin ) { (*(link->ppoin))[b]= (*(link->ppoin))[a]; b++; } @@ -749,10 +751,10 @@ static uiLinkLine *ui_is_a_link(uiBut *from, uiBut *to) uiLink *link; link= from->link; - if(link) { + if (link) { line= link->lines.first; - while(line) { - if(line->from==from && line->to==to) return line; + while (line) { + if (line->from==from && line->to==to) return line; line= line->next; } } @@ -772,7 +774,7 @@ static void ui_add_smart_controller(bContext *C, uiBut *from, uiBut *to) uiLink *link= from->link; - if(link->ppoin) + if (link->ppoin) sens_from_links= (bController ***)(link->ppoin); else return; @@ -790,7 +792,7 @@ static void ui_add_smart_controller(bContext *C, uiBut *from, uiBut *to) if (ob) break; } CTX_DATA_END; - if(!ob) return; + if (!ob) return; /* (2) check if the sensor and the actuator are from the same object */ for (act_iter= ob->actuators.first; act_iter; act_iter= (bActuator *)act_iter->next) { @@ -799,7 +801,7 @@ static void ui_add_smart_controller(bContext *C, uiBut *from, uiBut *to) } // only works if the sensor and the actuator are from the same object - if(!act_iter) return; + if (!act_iter) return; /* (3) add a new controller */ if (WM_operator_name_call(C, "LOGIC_OT_controller_add", WM_OP_EXEC_DEFAULT, NULL) & OPERATOR_FINISHED) { @@ -831,7 +833,7 @@ static void ui_add_link(bContext *C, uiBut *from, uiBut *to) void **oldppoin; int a; - if( (line= ui_is_a_link(from, to)) ) { + if ( (line= ui_is_a_link(from, to)) ) { line->flag |= UI_SELECT; ui_delete_active_linkline(from->block); return; @@ -841,13 +843,13 @@ static void ui_add_link(bContext *C, uiBut *from, uiBut *to) return; } else if (from->type==LINK && to->type==INLINK) { - if( from->link->tocode != (int)to->hardmin ) { + if ( from->link->tocode != (int)to->hardmin ) { ui_add_smart_controller(C, from, to); return; } } - else if(from->type==INLINK && to->type==LINK) { - if( to->link->tocode == (int)from->hardmin ) { + else if (from->type==INLINK && to->type==LINK) { + if ( to->link->tocode == (int)from->hardmin ) { return; } } @@ -855,18 +857,18 @@ static void ui_add_link(bContext *C, uiBut *from, uiBut *to) link= from->link; /* are there more pointers allowed? */ - if(link->ppoin) { + if (link->ppoin) { oldppoin= *(link->ppoin); (*(link->totlink))++; *(link->ppoin)= MEM_callocN( *(link->totlink)*sizeof(void *), "new link"); - for(a=0; a< (*(link->totlink))-1; a++) { + for (a=0; a< (*(link->totlink))-1; a++) { (*(link->ppoin))[a]= oldppoin[a]; } (*(link->ppoin))[a]= to->poin; - if(oldppoin) MEM_freeN(oldppoin); + if (oldppoin) MEM_freeN(oldppoin); } else { *(link->poin)= to->poin; @@ -880,15 +882,15 @@ static void ui_apply_but_LINK(bContext *C, uiBut *but, uiHandleButtonData *data) ARegion *ar= CTX_wm_region(C); uiBut *bt; - for(bt= but->block->buttons.first; bt; bt= bt->next) { - if( ui_mouse_inside_button(ar, bt, but->linkto[0]+ar->winrct.xmin, but->linkto[1]+ar->winrct.ymin) ) + for (bt= but->block->buttons.first; bt; bt= bt->next) { + if ( ui_mouse_inside_button(ar, bt, but->linkto[0]+ar->winrct.xmin, but->linkto[1]+ar->winrct.ymin) ) break; } - if(bt && bt!=but) { + if (bt && bt!=but) { if (!ELEM(bt->type, LINK, INLINK) || !ELEM(but->type, LINK, INLINK)) return; - if(but->type==LINK) ui_add_link(C, but, bt); + if (but->type==LINK) ui_add_link(C, but, bt); else ui_add_link(C, bt, but); ui_apply_but_func(C, but); @@ -938,11 +940,11 @@ static void ui_apply_button(bContext *C, uiBlock *block, uiBut *but, uiHandleBut /* if we cancel and have not applied yet, there is nothing to do, * otherwise we have to restore the original value again */ - if(data->cancel) { - if(!data->applied) + if (data->cancel) { + if (!data->applied) return; - if(data->str) MEM_freeN(data->str); + if (data->str) MEM_freeN(data->str); data->str= data->origstr; data->origstr= NULL; data->value= data->origvalue; @@ -953,9 +955,9 @@ static void ui_apply_button(bContext *C, uiBlock *block, uiBut *but, uiHandleBut else { /* we avoid applying interactive edits a second time * at the end with the appliedinteractive flag */ - if(interactive) + if (interactive) data->appliedinteractive= 1; - else if(data->appliedinteractive) + else if (data->appliedinteractive) return; } @@ -1076,13 +1078,13 @@ static void ui_but_drop(bContext *C, wmEvent *event, uiBut *but, uiHandleButtonD wmDrag *wmd; ListBase *drags= event->customdata; /* drop event type has listbase customdata by default */ - for(wmd= drags->first; wmd; wmd= wmd->next) { - if(wmd->type==WM_DRAG_ID) { + for (wmd= drags->first; wmd; wmd= wmd->next) { + if (wmd->type==WM_DRAG_ID) { /* align these types with UI_but_active_drop_name */ - if(ELEM3(but->type, TEX, IDPOIN, SEARCH_MENU)) { + if (ELEM3(but->type, TEX, IDPOIN, SEARCH_MENU)) { ID *id= (ID *)wmd->poin; - if(but->poin==NULL && but->rnapoin.data==NULL) {} + if (but->poin==NULL && but->rnapoin.data==NULL) {} button_activate_state(C, but, BUTTON_STATE_TEXT_EDITING); BLI_strncpy(data->str, id->name+2, data->maxlen); button_activate_state(C, but, BUTTON_STATE_EXIT); @@ -1100,14 +1102,14 @@ static void ui_but_copy_paste(bContext *C, uiBut *but, uiHandleButtonData *data, static ColorBand but_copypaste_coba = {0}; char buf[UI_MAX_DRAW_STR+1]= {0}; - if(mode=='v' && but->lock) + if (mode=='v' && but->lock) return; - if(mode=='v') { + if (mode=='v') { /* extract first line from clipboard in case of multi-line copies */ char *p, *pbuf= WM_clipboard_text_get(0); p= pbuf; - if(p) { + if (p) { int i = 0; while (*p && *p!='\r' && *p!='\n' && itype, NUM, NUMABS, NUMSLI, HSVSLI) { - if(but->poin==NULL && but->rnapoin.data==NULL); - else if(mode=='c') { + if (but->poin==NULL && but->rnapoin.data==NULL); + else if (mode=='c') { ui_get_but_string(but, buf, sizeof(buf)); WM_clipboard_text_set(buf, 0); } @@ -1139,11 +1141,11 @@ static void ui_but_copy_paste(bContext *C, uiBut *but, uiHandleButtonData *data, } /* RGB triple */ - else if(but->type==COL) { + else if (but->type==COL) { float rgb[3]; - if(but->poin==NULL && but->rnapoin.data==NULL); - else if(mode=='c') { + if (but->poin==NULL && but->rnapoin.data==NULL); + else if (mode=='c') { ui_get_but_vectorf(but, rgb); BLI_snprintf(buf, sizeof(buf), "[%f, %f, %f]", rgb[0], rgb[1], rgb[2]); @@ -1160,11 +1162,11 @@ static void ui_but_copy_paste(bContext *C, uiBut *but, uiHandleButtonData *data, } /* text/string and ID data */ - else if(ELEM3(but->type, TEX, IDPOIN, SEARCH_MENU)) { + else if (ELEM3(but->type, TEX, IDPOIN, SEARCH_MENU)) { uiHandleButtonData *active_data= but->active; - if(but->poin==NULL && but->rnapoin.data==NULL); - else if(mode=='c') { + if (but->poin==NULL && but->rnapoin.data==NULL); + else if (mode=='c') { button_activate_state(C, but, BUTTON_STATE_TEXT_EDITING); BLI_strncpy(buf, active_data->str, UI_MAX_DRAW_STR); WM_clipboard_text_set(active_data->str, 0); @@ -1174,10 +1176,10 @@ static void ui_but_copy_paste(bContext *C, uiBut *but, uiHandleButtonData *data, else { button_activate_state(C, but, BUTTON_STATE_TEXT_EDITING); - if(ui_is_but_utf8(but)) BLI_strncpy_utf8(active_data->str, buf, active_data->maxlen); + if (ui_is_but_utf8(but)) BLI_strncpy_utf8(active_data->str, buf, active_data->maxlen); else BLI_strncpy(active_data->str, buf, active_data->maxlen); - if(but->type == SEARCH_MENU) { + if (but->type == SEARCH_MENU) { /* else uiSearchboxData.active member is not updated [#26856] */ ui_searchbox_update(C, data->searchbox, but, 1); } @@ -1185,18 +1187,18 @@ static void ui_but_copy_paste(bContext *C, uiBut *but, uiHandleButtonData *data, } } /* colorband (not supported by system clipboard) */ - else if(but->type==BUT_COLORBAND) { - if(mode=='c') { - if(but->poin==NULL) + else if (but->type==BUT_COLORBAND) { + if (mode=='c') { + if (but->poin==NULL) return; memcpy(&but_copypaste_coba, but->poin, sizeof(ColorBand)); } else { - if(but_copypaste_coba.tot==0) + if (but_copypaste_coba.tot==0) return; - if(!but->poin) + if (!but->poin) but->poin= MEM_callocN(sizeof(ColorBand), "colorband"); button_activate_state(C, but, BUTTON_STATE_NUM_EDITING); @@ -1206,7 +1208,7 @@ static void ui_but_copy_paste(bContext *C, uiBut *but, uiHandleButtonData *data, } /* operator button (any type) */ else if (but->optype) { - if(mode=='c') { + if (mode=='c') { PointerRNA *opptr; char *str; opptr= uiButGetOperatorPtrRNA(but); /* allocated when needed, the button owns it */ @@ -1228,7 +1230,7 @@ static int ui_textedit_delete_selection(uiBut *but, uiHandleButtonData *data) char *str= data->str; int len= strlen(str); int change= 0; - if(but->selsta != but->selend && len) { + if (but->selsta != but->selend && len) { memmove(str + but->selsta, str + but->selend, (len - but->selend) + 1); change= 1; } @@ -1255,9 +1257,9 @@ static void ui_textedit_set_cursor_pos(uiBut *but, uiHandleButtonData *data, sho BLI_strncpy(origstr, but->drawstr, data->maxlen); /* XXX solve generic */ - if(but->type==NUM || but->type==NUMSLI) + if (but->type==NUM || but->type==NUMSLI) startx += (int)(0.5f*(but->y2 - but->y1)); - else if(ELEM(but->type, TEX, SEARCH_MENU)) { + else if (ELEM(but->type, TEX, SEARCH_MENU)) { startx += 5; if (but->flag & UI_HAS_ICON) startx += UI_DPI_ICON_SIZE; @@ -1319,7 +1321,7 @@ static void ui_textedit_set_cursor_pos(uiBut *but, uiHandleButtonData *data, sho } } but->pos += but->ofs; - if(but->pos<0) but->pos= 0; + if (but->pos<0) but->pos= 0; } if (fstyle->kerning == 1) @@ -1353,7 +1355,7 @@ static int ui_textedit_type_buf(uiBut *but, uiHandleButtonData *data, str= data->str; len= strlen(str); - if(len-(but->selend - but->selsta)+1 <= data->maxlen) { + if (len-(but->selend - but->selsta)+1 <= data->maxlen) { int step= utf8_buf_len; /* type over the current selection */ @@ -1362,7 +1364,7 @@ static int ui_textedit_type_buf(uiBut *but, uiHandleButtonData *data, len= strlen(str); } - if(len + step < data->maxlen) { + if (len + step < data->maxlen) { memmove(&str[but->pos + step], &str[but->pos], (len + 1) - but->pos); memcpy(&str[but->pos], utf8_buf, step * sizeof(char)); but->pos += step; @@ -1417,11 +1419,11 @@ static void ui_textedit_move(uiBut *but, uiHandleButtonData *data, strCursorJump BLI_str_cursor_step_utf8(str, len, &pos_i, direction, jump); but->pos = pos_i; - if(select) { + if (select) { /* existing selection */ if (has_sel) { - if(data->selextend == 0) { + if (data->selextend == 0) { data->selextend= EXTEND_RIGHT; } @@ -1472,11 +1474,11 @@ static int ui_textedit_delete(uiBut *but, uiHandleButtonData *data, int directio int changed= 0; if (jump == STRCUR_JUMP_ALL) { - if(len) changed=1; + if (len) changed=1; str[0]= '\0'; but->pos= 0; } - else if(direction) { /* delete */ + else if (direction) { /* delete */ if ((but->selend - but->selsta) > 0) { changed= ui_textedit_delete_selection(but, data); } @@ -1494,7 +1496,7 @@ static int ui_textedit_delete(uiBut *but, uiHandleButtonData *data, int directio if ((but->selend - but->selsta) > 0) { changed= ui_textedit_delete_selection(but, data); } - else if(but->pos>0) { + else if (but->pos>0) { int pos = but->pos; int step; @@ -1517,7 +1519,7 @@ static int ui_textedit_autocomplete(bContext *C, uiBut *but, uiHandleButtonData str= data->str; - if(data->searchbox) + if (data->searchbox) ui_searchbox_autocomplete(C, data->searchbox, but, data->str); else but->autocomplete_func(C, str, but->autofunc_arg); @@ -1542,7 +1544,7 @@ static int ui_textedit_copypaste(uiBut *but, uiHandleButtonData *data, int paste /* extract the first line from the clipboard */ p = pbuf= WM_clipboard_text_get(0); - if(p && p[0]) { + if (p && p[0]) { unsigned int y; i= 0; while (*p && *p!='\r' && *p!='\n' && imaxlen) { - for(x= data->maxlen; x>but->pos; x--) + if (len+1 < data->maxlen) { + for (x= data->maxlen; x>but->pos; x--) str[x]= str[x-1]; str[but->pos]= buf[y]; but->pos++; @@ -1580,7 +1582,7 @@ static int ui_textedit_copypaste(uiBut *but, uiHandleButtonData *data, int paste /* cut & copy */ else if (copy || cut) { /* copy the contents to the copypaste buffer */ - for(x= but->selsta; x <= but->selend; x++) { + for (x= but->selsta; x <= but->selend; x++) { if (x==but->selend) buf[x] = '\0'; else @@ -1590,8 +1592,8 @@ static int ui_textedit_copypaste(uiBut *but, uiHandleButtonData *data, int paste WM_clipboard_text_set(buf, 0); /* for cut only, delete the selection afterwards */ - if(cut) - if((but->selend - but->selsta) > 0) + if (cut) + if ((but->selend - but->selsta) > 0) changed= ui_textedit_delete_selection(but, data); } @@ -1602,7 +1604,7 @@ static void ui_textedit_begin(bContext *C, uiBut *but, uiHandleButtonData *data) { int len; - if(data->str) { + if (data->str) { MEM_freeN(data->str); data->str= NULL; } @@ -1612,7 +1614,7 @@ static void ui_textedit_begin(bContext *C, uiBut *but, uiHandleButtonData *data) data->str= MEM_callocN(sizeof(char)*data->maxlen + 1, "textedit str"); ui_get_but_string(but, data->str, data->maxlen); - if(ELEM3(but->type, NUM, NUMABS, NUMSLI)) { + if (ELEM3(but->type, NUM, NUMABS, NUMSLI)) { ui_convert_to_unit_alt_name(but, data->str, data->maxlen); } @@ -1630,7 +1632,7 @@ static void ui_textedit_begin(bContext *C, uiBut *but, uiHandleButtonData *data) but->selend = len; /* optional searchbox */ - if(but->type==SEARCH_MENU) { + if (but->type==SEARCH_MENU) { data->searchbox= ui_searchbox_create(C, data->region, but); ui_searchbox_update(C, data->searchbox, but, 1); /* 1= reset */ } @@ -1642,18 +1644,18 @@ static void ui_textedit_begin(bContext *C, uiBut *but, uiHandleButtonData *data) static void ui_textedit_end(bContext *C, uiBut *but, uiHandleButtonData *data) { - if(but) { - if(ui_is_but_utf8(but)) { + if (but) { + if (ui_is_but_utf8(but)) { int strip= BLI_utf8_invalid_strip(but->editstr, strlen(but->editstr)); /* not a file?, strip non utf-8 chars */ - if(strip) { + if (strip) { /* wont happen often so isn't that annoying to keep it here for a while */ printf("%s: invalid utf8 - stripped chars %d\n", __func__, strip); } } - if(data->searchbox) { - if(data->cancel==0) + if (data->searchbox) { + if (data->cancel==0) ui_searchbox_apply(but, data->searchbox); ui_searchbox_free(C, data->searchbox); @@ -1672,21 +1674,21 @@ static void ui_textedit_next_but(uiBlock *block, uiBut *actbut, uiHandleButtonDa uiBut *but; /* label and roundbox can overlap real buttons (backdrops...) */ - if(ELEM4(actbut->type, LABEL, SEPR, ROUNDBOX, LISTBOX)) + if (ELEM4(actbut->type, LABEL, SEPR, ROUNDBOX, LISTBOX)) return; - for(but= actbut->next; but; but= but->next) { - if(ELEM7(but->type, TEX, NUM, NUMABS, NUMSLI, HSVSLI, IDPOIN, SEARCH_MENU)) { - if(!(but->flag & UI_BUT_DISABLED)) { + for (but= actbut->next; but; but= but->next) { + if (ELEM7(but->type, TEX, NUM, NUMABS, NUMSLI, HSVSLI, IDPOIN, SEARCH_MENU)) { + if (!(but->flag & UI_BUT_DISABLED)) { data->postbut= but; data->posttype= BUTTON_ACTIVATE_TEXT_EDITING; return; } } } - for(but= block->buttons.first; but!=actbut; but= but->next) { - if(ELEM7(but->type, TEX, NUM, NUMABS, NUMSLI, HSVSLI, IDPOIN, SEARCH_MENU)) { - if(!(but->flag & UI_BUT_DISABLED)) { + for (but= block->buttons.first; but!=actbut; but= but->next) { + if (ELEM7(but->type, TEX, NUM, NUMABS, NUMSLI, HSVSLI, IDPOIN, SEARCH_MENU)) { + if (!(but->flag & UI_BUT_DISABLED)) { data->postbut= but; data->posttype= BUTTON_ACTIVATE_TEXT_EDITING; return; @@ -1700,21 +1702,21 @@ static void ui_textedit_prev_but(uiBlock *block, uiBut *actbut, uiHandleButtonDa uiBut *but; /* label and roundbox can overlap real buttons (backdrops...) */ - if(ELEM4(actbut->type, LABEL, SEPR, ROUNDBOX, LISTBOX)) + if (ELEM4(actbut->type, LABEL, SEPR, ROUNDBOX, LISTBOX)) return; - for(but= actbut->prev; but; but= but->prev) { - if(ELEM7(but->type, TEX, NUM, NUMABS, NUMSLI, HSVSLI, IDPOIN, SEARCH_MENU)) { - if(!(but->flag & UI_BUT_DISABLED)) { + for (but= actbut->prev; but; but= but->prev) { + if (ELEM7(but->type, TEX, NUM, NUMABS, NUMSLI, HSVSLI, IDPOIN, SEARCH_MENU)) { + if (!(but->flag & UI_BUT_DISABLED)) { data->postbut= but; data->posttype= BUTTON_ACTIVATE_TEXT_EDITING; return; } } } - for(but= block->buttons.last; but!=actbut; but= but->prev) { - if(ELEM7(but->type, TEX, NUM, NUMABS, NUMSLI, HSVSLI, IDPOIN, SEARCH_MENU)) { - if(!(but->flag & UI_BUT_DISABLED)) { + for (but= block->buttons.last; but!=actbut; but= but->prev) { + if (ELEM7(but->type, TEX, NUM, NUMABS, NUMSLI, HSVSLI, IDPOIN, SEARCH_MENU)) { + if (!(but->flag & UI_BUT_DISABLED)) { data->postbut= but; data->posttype= BUTTON_ACTIVATE_TEXT_EDITING; return; @@ -1732,7 +1734,7 @@ static void ui_do_but_textedit(bContext *C, uiBlock *block, uiBut *but, uiHandle case WHEELUPMOUSE: case WHEELDOWNMOUSE: case MOUSEMOVE: - if(data->searchbox) + if (data->searchbox) ui_searchbox_event(C, data->searchbox, but, event); break; @@ -1746,10 +1748,10 @@ static void ui_do_but_textedit(bContext *C, uiBlock *block, uiBut *but, uiHandle case LEFTMOUSE: { /* exit on LMB only on RELEASE for searchbox, to mimic other popups, and allow multiple menu levels */ - if(data->searchbox) + if (data->searchbox) inbox= ui_searchbox_inside(data->searchbox, event->x, event->y); - if(event->val==KM_PRESS) { + if (event->val==KM_PRESS) { mx= event->x; my= event->y; ui_window_to_block(data->region, block, &mx, &my); @@ -1762,15 +1764,15 @@ static void ui_do_but_textedit(bContext *C, uiBlock *block, uiBut *but, uiHandle button_activate_state(C, but, BUTTON_STATE_TEXT_SELECTING); retval= WM_UI_HANDLER_BREAK; } - else if(inbox==0) { + else if (inbox==0) { /* if searchbox, click outside will cancel */ - if(data->searchbox) + if (data->searchbox) data->cancel= data->escapecancel= 1; button_activate_state(C, but, BUTTON_STATE_EXIT); retval= WM_UI_HANDLER_BREAK; } } - else if(inbox) { + else if (inbox) { button_activate_state(C, but, BUTTON_STATE_EXIT); retval= WM_UI_HANDLER_BREAK; } @@ -1778,17 +1780,17 @@ static void ui_do_but_textedit(bContext *C, uiBlock *block, uiBut *but, uiHandle } } - if(event->val==KM_PRESS) { + if (event->val==KM_PRESS) { switch (event->type) { case VKEY: case XKEY: case CKEY: - if(event->ctrl || event->oskey) { - if(event->type == VKEY) + if (event->ctrl || event->oskey) { + if (event->type == VKEY) changed= ui_textedit_copypaste(but, data, 1, 0, 0); - else if(event->type == CKEY) + else if (event->type == CKEY) changed= ui_textedit_copypaste(but, data, 0, 1, 0); - else if(event->type == XKEY) + else if (event->type == XKEY) changed= ui_textedit_copypaste(but, data, 0, 0, 1); retval= WM_UI_HANDLER_BREAK; @@ -1803,7 +1805,7 @@ static void ui_do_but_textedit(bContext *C, uiBlock *block, uiBut *but, uiHandle retval= WM_UI_HANDLER_BREAK; break; case DOWNARROWKEY: - if(data->searchbox) { + if (data->searchbox) { ui_searchbox_event(C, data->searchbox, but, event); break; } @@ -1813,7 +1815,7 @@ static void ui_do_but_textedit(bContext *C, uiBlock *block, uiBut *but, uiHandle retval= WM_UI_HANDLER_BREAK; break; case UPARROWKEY: - if(data->searchbox) { + if (data->searchbox) { ui_searchbox_event(C, data->searchbox, but, event); break; } @@ -1839,12 +1841,12 @@ static void ui_do_but_textedit(bContext *C, uiBlock *block, uiBut *but, uiHandle case TABKEY: /* there is a key conflict here, we can't tab with autocomplete */ - if(but->autocomplete_func || data->searchbox) { + if (but->autocomplete_func || data->searchbox) { changed= ui_textedit_autocomplete(C, but, data); update= 1; /* do live update for tab key */ } /* the hotkey here is not well defined, was G.qual so we check all */ - else if(event->shift || event->ctrl || event->alt || event->oskey) { + else if (event->shift || event->ctrl || event->alt || event->oskey) { ui_textedit_prev_but(block, but, data); button_activate_state(C, but, BUTTON_STATE_EXIT); } @@ -1856,20 +1858,20 @@ static void ui_do_but_textedit(bContext *C, uiBlock *block, uiBut *but, uiHandle break; } - if((event->ascii || event->utf8_buf[0]) && (retval == WM_UI_HANDLER_CONTINUE)) { + if ((event->ascii || event->utf8_buf[0]) && (retval == WM_UI_HANDLER_CONTINUE)) { char ascii = event->ascii; const char *utf8_buf= event->utf8_buf; /* exception that's useful for number buttons, some keyboard * numpads have a comma instead of a period */ - if(ELEM3(but->type, NUM, NUMABS, NUMSLI)) { /* could use data->min*/ - if(event->type == PADPERIOD && ascii == ',') { + if (ELEM3(but->type, NUM, NUMABS, NUMSLI)) { /* could use data->min*/ + if (event->type == PADPERIOD && ascii == ',') { ascii = '.'; utf8_buf= NULL; /* force ascii fallback */ } } - if(utf8_buf && utf8_buf[0]) { + if (utf8_buf && utf8_buf[0]) { int utf8_buf_len= BLI_str_utf8_size(utf8_buf); /* keep this printf until utf8 is well tested */ if (utf8_buf_len != 1) { @@ -1887,21 +1889,21 @@ static void ui_do_but_textedit(bContext *C, uiBlock *block, uiBut *but, uiHandle } /* textbutton with magnifier icon: do live update for search button */ - if(but->icon==ICON_VIEWZOOM) + if (but->icon==ICON_VIEWZOOM) update= 1; } - if(changed) { + if (changed) { /* only update when typing for TAB key */ - if(update && data->interactive) ui_apply_button(C, block, but, data, 1); + if (update && data->interactive) ui_apply_button(C, block, but, data, 1); else ui_check_but(but); but->changed= TRUE; - if(data->searchbox) + if (data->searchbox) ui_searchbox_update(C, data->searchbox, but, 1); /* 1 = reset */ } - if(changed || (retval == WM_UI_HANDLER_BREAK)) + if (changed || (retval == WM_UI_HANDLER_BREAK)) ED_region_tag_redraw(data->region); } @@ -1920,13 +1922,13 @@ static void ui_do_but_textedit_select(bContext *C, uiBlock *block, uiBut *but, u break; } case LEFTMOUSE: - if(event->val == KM_RELEASE) + if (event->val == KM_RELEASE) button_activate_state(C, but, BUTTON_STATE_TEXT_EDITING); retval= WM_UI_HANDLER_BREAK; break; } - if(retval == WM_UI_HANDLER_BREAK) { + if (retval == WM_UI_HANDLER_BREAK) { ui_check_but(but); ED_region_tag_redraw(data->region); } @@ -1936,14 +1938,14 @@ static void ui_do_but_textedit_select(bContext *C, uiBlock *block, uiBut *but, u static void ui_numedit_begin(uiBut *but, uiHandleButtonData *data) { - if(but->type == BUT_CURVE) { + if (but->type == BUT_CURVE) { but->editcumap= (CurveMapping*)but->poin; } - else if(but->type == BUT_COLORBAND) { + else if (but->type == BUT_COLORBAND) { data->coba= (ColorBand*)but->poin; but->editcoba= data->coba; } - else if(ELEM3(but->type, BUT_NORMAL, HSVCUBE, HSVCIRCLE)) { + else if (ELEM3(but->type, BUT_NORMAL, HSVCUBE, HSVCIRCLE)) { ui_get_but_vectorf(but, data->origvec); copy_v3_v3(data->vec, data->origvec); but->editvec= data->vec; @@ -1984,7 +1986,7 @@ static void ui_numedit_end(uiBut *but, uiHandleButtonData *data) static void ui_numedit_apply(bContext *C, uiBlock *block, uiBut *but, uiHandleButtonData *data) { - if(data->interactive) ui_apply_button(C, block, but, data, 1); + if (data->interactive) ui_apply_button(C, block, but, data, 1); else ui_check_but(but); ED_region_tag_redraw(data->region); @@ -2003,7 +2005,7 @@ static void ui_blockopen_begin(bContext *C, uiBut *but, uiHandleButtonData *data switch(but->type) { case BLOCK: case PULLDOWN: - if(but->menu_create_func) { + if (but->menu_create_func) { menufunc= but->menu_create_func; arg= but->poin; } @@ -2013,7 +2015,7 @@ static void ui_blockopen_begin(bContext *C, uiBut *but, uiHandleButtonData *data } break; case MENU: - if(but->menu_create_func) { + if (but->menu_create_func) { menufunc= but->menu_create_func; arg= but->poin; } @@ -2043,14 +2045,14 @@ static void ui_blockopen_begin(bContext *C, uiBut *but, uiHandleButtonData *data break; } - if(func || handlefunc) { + if (func || handlefunc) { data->menu= ui_popup_block_create(C, data->region, but, func, handlefunc, arg); - if(but->block->handle) + if (but->block->handle) data->menu->popup= but->block->handle->popup; } - else if(menufunc || menustr) { + else if (menufunc || menustr) { data->menu= ui_popup_menu_create(C, data->region, but, menufunc, arg, menustr); - if(but->block->handle) + if (but->block->handle) data->menu->popup= but->block->handle->popup; } @@ -2060,14 +2062,14 @@ static void ui_blockopen_begin(bContext *C, uiBut *but, uiHandleButtonData *data static void ui_blockopen_end(bContext *C, uiBut *but, uiHandleButtonData *data) { - if(but) { + if (but) { but->editval= NULL; but->editvec= NULL; but->block->auto_open_last= PIL_check_seconds_timer(); } - if(data->menu) { + if (data->menu) { ui_popup_block_free(C, data->menu); data->menu= NULL; } @@ -2077,23 +2079,23 @@ static void ui_blockopen_end(bContext *C, uiBut *but, uiHandleButtonData *data) static int ui_do_but_BUT(bContext *C, uiBut *but, uiHandleButtonData *data, wmEvent *event) { - if(data->state == BUTTON_STATE_HIGHLIGHT) { - if(event->type == LEFTMOUSE && event->val==KM_PRESS) { + if (data->state == BUTTON_STATE_HIGHLIGHT) { + if (event->type == LEFTMOUSE && event->val==KM_PRESS) { button_activate_state(C, but, BUTTON_STATE_WAIT_RELEASE); return WM_UI_HANDLER_BREAK; } - else if(event->type == LEFTMOUSE && but->block->handle) { + else if (event->type == LEFTMOUSE && but->block->handle) { button_activate_state(C, but, BUTTON_STATE_EXIT); return WM_UI_HANDLER_BREAK; } - else if(ELEM(event->type, PADENTER, RETKEY) && event->val==KM_PRESS) { + else if (ELEM(event->type, PADENTER, RETKEY) && event->val==KM_PRESS) { button_activate_state(C, but, BUTTON_STATE_WAIT_FLASH); return WM_UI_HANDLER_BREAK; } } - else if(data->state == BUTTON_STATE_WAIT_RELEASE) { - if(event->type == LEFTMOUSE && event->val!=KM_PRESS) { - if(!(but->flag & UI_SELECT)) + else if (data->state == BUTTON_STATE_WAIT_RELEASE) { + if (event->type == LEFTMOUSE && event->val!=KM_PRESS) { + if (!(but->flag & UI_SELECT)) data->cancel= 1; button_activate_state(C, but, BUTTON_STATE_EXIT); return WM_UI_HANDLER_BREAK; @@ -2105,24 +2107,24 @@ static int ui_do_but_BUT(bContext *C, uiBut *but, uiHandleButtonData *data, wmEv static int ui_do_but_HOTKEYEVT(bContext *C, uiBut *but, uiHandleButtonData *data, wmEvent *event) { - if(data->state == BUTTON_STATE_HIGHLIGHT) { - if(ELEM3(event->type, LEFTMOUSE, PADENTER, RETKEY) && event->val==KM_PRESS) { + if (data->state == BUTTON_STATE_HIGHLIGHT) { + if (ELEM3(event->type, LEFTMOUSE, PADENTER, RETKEY) && event->val==KM_PRESS) { but->drawstr[0]= 0; but->modifier_key= 0; button_activate_state(C, but, BUTTON_STATE_WAIT_KEY_EVENT); return WM_UI_HANDLER_BREAK; } } - else if(data->state == BUTTON_STATE_WAIT_KEY_EVENT) { + else if (data->state == BUTTON_STATE_WAIT_KEY_EVENT) { - if(event->type == MOUSEMOVE) + if (event->type == MOUSEMOVE) return WM_UI_HANDLER_CONTINUE; - if(event->type == LEFTMOUSE && event->val==KM_PRESS) { + if (event->type == LEFTMOUSE && event->val==KM_PRESS) { /* only cancel if click outside the button */ - if(ui_mouse_inside_button(but->active->region, but, event->x, event->y) == 0) { + if (ui_mouse_inside_button(but->active->region, but, event->x, event->y) == 0) { /* data->cancel doesnt work, this button opens immediate */ - if(but->flag & UI_BUT_IMMEDIATE) + if (but->flag & UI_BUT_IMMEDIATE) ui_set_but_val(but, 0); else data->cancel= 1; @@ -2133,18 +2135,18 @@ static int ui_do_but_HOTKEYEVT(bContext *C, uiBut *but, uiHandleButtonData *data /* always set */ but->modifier_key = 0; - if(event->shift) but->modifier_key |= KM_SHIFT; - if(event->alt) but->modifier_key |= KM_ALT; - if(event->ctrl) but->modifier_key |= KM_CTRL; - if(event->oskey) but->modifier_key |= KM_OSKEY; + if (event->shift) but->modifier_key |= KM_SHIFT; + if (event->alt) but->modifier_key |= KM_ALT; + if (event->ctrl) but->modifier_key |= KM_CTRL; + if (event->oskey) but->modifier_key |= KM_OSKEY; ui_check_but(but); ED_region_tag_redraw(data->region); - if(event->val==KM_PRESS) { - if(ISHOTKEY(event->type)) { + if (event->val==KM_PRESS) { + if (ISHOTKEY(event->type)) { - if(WM_key_event_string(event->type)[0]) + if (WM_key_event_string(event->type)[0]) ui_set_but_val(but, event->type); else data->cancel= 1; @@ -2152,7 +2154,7 @@ static int ui_do_but_HOTKEYEVT(bContext *C, uiBut *but, uiHandleButtonData *data button_activate_state(C, but, BUTTON_STATE_EXIT); return WM_UI_HANDLER_BREAK; } - else if(event->type == ESCKEY) { + else if (event->type == ESCKEY) { data->cancel= 1; data->escapecancel= 1; button_activate_state(C, but, BUTTON_STATE_EXIT); @@ -2166,18 +2168,18 @@ static int ui_do_but_HOTKEYEVT(bContext *C, uiBut *but, uiHandleButtonData *data static int ui_do_but_KEYEVT(bContext *C, uiBut *but, uiHandleButtonData *data, wmEvent *event) { - if(data->state == BUTTON_STATE_HIGHLIGHT) { - if(ELEM3(event->type, LEFTMOUSE, PADENTER, RETKEY) && event->val==KM_PRESS) { + if (data->state == BUTTON_STATE_HIGHLIGHT) { + if (ELEM3(event->type, LEFTMOUSE, PADENTER, RETKEY) && event->val==KM_PRESS) { button_activate_state(C, but, BUTTON_STATE_WAIT_KEY_EVENT); return WM_UI_HANDLER_BREAK; } } - else if(data->state == BUTTON_STATE_WAIT_KEY_EVENT) { - if(event->type == MOUSEMOVE) + else if (data->state == BUTTON_STATE_WAIT_KEY_EVENT) { + if (event->type == MOUSEMOVE) return WM_UI_HANDLER_CONTINUE; - if(event->val==KM_PRESS) { - if(WM_key_event_string(event->type)[0]) + if (event->val==KM_PRESS) { + if (WM_key_event_string(event->type)[0]) ui_set_but_val(but, event->type); else data->cancel= 1; @@ -2191,20 +2193,20 @@ static int ui_do_but_KEYEVT(bContext *C, uiBut *but, uiHandleButtonData *data, w static int ui_do_but_TEX(bContext *C, uiBlock *block, uiBut *but, uiHandleButtonData *data, wmEvent *event) { - if(data->state == BUTTON_STATE_HIGHLIGHT) { - if(ELEM(event->type, LEFTMOUSE, EVT_BUT_OPEN) && event->val==KM_PRESS) { - if(but->dt == UI_EMBOSSN && !event->ctrl); + if (data->state == BUTTON_STATE_HIGHLIGHT) { + if (ELEM(event->type, LEFTMOUSE, EVT_BUT_OPEN) && event->val==KM_PRESS) { + if (but->dt == UI_EMBOSSN && !event->ctrl); else { button_activate_state(C, but, BUTTON_STATE_TEXT_EDITING); return WM_UI_HANDLER_BREAK; } } } - else if(data->state == BUTTON_STATE_TEXT_EDITING) { + else if (data->state == BUTTON_STATE_TEXT_EDITING) { ui_do_but_textedit(C, block, but, data, event); return WM_UI_HANDLER_BREAK; } - else if(data->state == BUTTON_STATE_TEXT_SELECTING) { + else if (data->state == BUTTON_STATE_TEXT_SELECTING) { ui_do_but_textedit_select(C, block, but, data, event); return WM_UI_HANDLER_BREAK; } @@ -2214,8 +2216,8 @@ static int ui_do_but_TEX(bContext *C, uiBlock *block, uiBut *but, uiHandleButton static int ui_do_but_TOG(bContext *C, uiBut *but, uiHandleButtonData *data, wmEvent *event) { - if(data->state == BUTTON_STATE_HIGHLIGHT) { - if(ELEM3(event->type, LEFTMOUSE, PADENTER, RETKEY) && event->val==KM_PRESS) { + if (data->state == BUTTON_STATE_HIGHLIGHT) { + if (ELEM3(event->type, LEFTMOUSE, PADENTER, RETKEY) && event->val==KM_PRESS) { data->togdual= event->ctrl; data->togonly= !event->shift; button_activate_state(C, but, BUTTON_STATE_EXIT); @@ -2228,11 +2230,11 @@ static int ui_do_but_TOG(bContext *C, uiBut *but, uiHandleButtonData *data, wmEv static int ui_do_but_EXIT(bContext *C, uiBut *but, uiHandleButtonData *data, wmEvent *event) { - if(data->state == BUTTON_STATE_HIGHLIGHT) { + if (data->state == BUTTON_STATE_HIGHLIGHT) { /* first handle click on icondrag type button */ - if(event->type==LEFTMOUSE && but->dragpoin) { - if(ui_but_mouse_inside_icon(but, data->region, event)) { + if (event->type==LEFTMOUSE && but->dragpoin) { + if (ui_but_mouse_inside_icon(but, data->region, event)) { /* tell the button to wait and keep checking further events to * see if it should start dragging */ @@ -2243,27 +2245,27 @@ static int ui_do_but_EXIT(bContext *C, uiBut *but, uiHandleButtonData *data, wmE } } - if(ELEM3(event->type, LEFTMOUSE, PADENTER, RETKEY) && event->val==KM_PRESS) { + if (ELEM3(event->type, LEFTMOUSE, PADENTER, RETKEY) && event->val==KM_PRESS) { int ret = WM_UI_HANDLER_BREAK; /* XXX (a bit ugly) Special case handling for filebrowser drag button */ - if(but->dragpoin && but->imb && ui_but_mouse_inside_icon(but, data->region, event)) { + if (but->dragpoin && but->imb && ui_but_mouse_inside_icon(but, data->region, event)) { ret = WM_UI_HANDLER_CONTINUE; } button_activate_state(C, but, BUTTON_STATE_EXIT); return ret; } } - else if(data->state == BUTTON_STATE_WAIT_DRAG) { + else if (data->state == BUTTON_STATE_WAIT_DRAG) { /* this function also ends state */ - if(ui_but_start_drag(C, but, data, event)) { + if (ui_but_start_drag(C, but, data, event)) { return WM_UI_HANDLER_BREAK; } /* If the mouse has been pressed and released, getting to * this point without triggering a drag, then clear the * drag state for this button and continue to pass on the event */ - if(event->type==LEFTMOUSE && event->val==KM_RELEASE) { + if (event->type==LEFTMOUSE && event->val==KM_RELEASE) { button_activate_state(C, but, BUTTON_STATE_EXIT); return WM_UI_HANDLER_CONTINUE; } @@ -2279,25 +2281,25 @@ static int ui_do_but_EXIT(bContext *C, uiBut *but, uiHandleButtonData *data, wmE /* var names match ui_numedit_but_NUM */ static float ui_numedit_apply_snapf(uiBut *but, float tempf, float softmin, float softmax, float softrange, int snap) { - if(tempf==softmin || tempf==softmax || snap==0) { + if (tempf==softmin || tempf==softmax || snap==0) { /* pass */ } else { float fac= 1.0f; - if(ui_is_but_unit(but)) { + if (ui_is_but_unit(but)) { UnitSettings *unit= but->block->unit; int unit_type= uiButGetUnitType(but)>>16; - if(bUnit_IsValid(unit->system, unit_type)) { + if (bUnit_IsValid(unit->system, unit_type)) { fac= (float)bUnit_BaseScalar(unit->system, unit_type); - if(ELEM3(unit_type, B_UNIT_LENGTH, B_UNIT_AREA, B_UNIT_VOLUME)) { + if (ELEM3(unit_type, B_UNIT_LENGTH, B_UNIT_AREA, B_UNIT_VOLUME)) { fac /= unit->scale_length; } } } - if(fac != 1.0f) { + if (fac != 1.0f) { /* snap in unit-space */ tempf /= fac; /* softmin /= fac; */ /* UNUSED */ @@ -2305,18 +2307,18 @@ static float ui_numedit_apply_snapf(uiBut *but, float tempf, float softmin, floa softrange /= fac; } - if(snap==1) { - if(softrange < 2.10f) tempf= 0.1f*floorf(10.0f*tempf); - else if(softrange < 21.0f) tempf= floorf(tempf); + if (snap==1) { + if (softrange < 2.10f) tempf= 0.1f*floorf(10.0f*tempf); + else if (softrange < 21.0f) tempf= floorf(tempf); else tempf= 10.0f*floorf(tempf/10.0f); } - else if(snap==2) { - if(softrange < 2.10f) tempf= 0.01f*floorf(100.0f*tempf); - else if(softrange < 21.0f) tempf= 0.1f*floorf(10.0f*tempf); + else if (snap==2) { + if (softrange < 2.10f) tempf= 0.01f*floorf(100.0f*tempf); + else if (softrange < 21.0f) tempf= 0.1f*floorf(10.0f*tempf); else tempf= floor(tempf); } - if(fac != 1.0f) + if (fac != 1.0f) tempf *= fac; } @@ -2325,7 +2327,7 @@ static float ui_numedit_apply_snapf(uiBut *but, float tempf, float softmin, floa static float ui_numedit_apply_snap(int temp, float softmin, float softmax, int snap) { - if(temp==softmin || temp==softmax) + if (temp==softmin || temp==softmax) return temp; switch(snap) { @@ -2347,13 +2349,13 @@ static int ui_numedit_but_NUM(uiBut *but, uiHandleButtonData *data, float fac, i float deler, tempf, softmin, softmax, softrange; int lvalue, temp, changed= 0; - if(mx == data->draglastx) + if (mx == data->draglastx) return changed; /* drag-lock - prevent unwanted scroll adjustments */ /* change value (now 3) to adjust threshold in pixels */ - if(data->draglock) { - if(abs(mx-data->dragstartx) <= 3) + if (data->draglock) { + if (abs(mx-data->dragstartx) <= 3) return changed; data->draglock= 0; @@ -2364,19 +2366,20 @@ static int ui_numedit_but_NUM(uiBut *but, uiHandleButtonData *data, float fac, i softmax= but->softmax; softrange= softmax - softmin; - if(ui_is_a_warp_but(but)) { + if (ui_is_a_warp_but(but)) { /* Mouse location isn't screen clamped to the screen so use a linear mapping * 2px == 1-int, or 1px == 1-ClickStep */ - if(ui_is_but_float(but)) { + if (ui_is_but_float(but)) { fac *= 0.01f*but->a1; tempf = (float)data->startvalue + ((float)(mx - data->dragstartx) * fac); tempf= ui_numedit_apply_snapf(but, tempf, softmin, softmax, softrange, snap); #if 1 /* fake moving the click start, nicer for dragging back after passing the limit */ - if(tempf < softmin) { + if (tempf < softmin) { data->dragstartx -= (softmin-tempf) / fac; tempf= softmin; - } else if (tempf > softmax) { + } + else if (tempf > softmax) { data->dragstartx += (tempf-softmax) / fac; tempf= softmax; } @@ -2384,25 +2387,26 @@ static int ui_numedit_but_NUM(uiBut *but, uiHandleButtonData *data, float fac, i CLAMP(tempf, softmin, softmax); #endif - if(tempf != (float)data->value) { + if (tempf != (float)data->value) { data->dragchange= 1; data->value= tempf; changed= 1; } } else { - if(softrange > 256) fac= 1.0; /* 1px == 1 */ - else if(softrange > 32) fac= 1.0/2.0; /* 2px == 1 */ + if (softrange > 256) fac= 1.0; /* 1px == 1 */ + else if (softrange > 32) fac= 1.0/2.0; /* 2px == 1 */ else fac= 1.0/16.0; /* 16px == 1? */ temp= data->startvalue + (((double)mx - data->dragstartx) * (double)fac); temp= ui_numedit_apply_snap(temp, softmin, softmax, snap); #if 1 /* fake moving the click start, nicer for dragging back after passing the limit */ - if(temp < softmin) { + if (temp < softmin) { data->dragstartx -= (softmin-temp) / fac; temp= softmin; - } else if (temp > softmax) { + } + else if (temp > softmax) { data->dragstartx += (temp-softmax) / fac; temp= softmax; } @@ -2410,7 +2414,7 @@ static int ui_numedit_but_NUM(uiBut *but, uiHandleButtonData *data, float fac, i CLAMP(temp, softmin, softmax); #endif - if(temp != data->value) { + if (temp != data->value) { data->dragchange= 1; data->value= temp; changed= 1; @@ -2422,7 +2426,7 @@ static int ui_numedit_but_NUM(uiBut *but, uiHandleButtonData *data, float fac, i else { /* Use a non-linear mapping of the mouse drag especially for large floats (normal behavior) */ deler= 500; - if(!ui_is_but_float(but)) { + if (!ui_is_but_float(but)) { /* prevent large ranges from getting too out of control */ if (softrange > 600) deler = powf(softrange, 0.75); @@ -2431,13 +2435,15 @@ static int ui_numedit_but_NUM(uiBut *but, uiHandleButtonData *data, float fac, i } deler /= fac; - if(softrange > 11) { + if (softrange > 11) { /* non linear change in mouse input- good for high precicsion */ data->dragf+= (((float)(mx-data->draglastx))/deler) * (fabsf(data->dragstartx-mx)*0.002f); - } else if (softrange > 129) { /* only scale large int buttons */ + } + else if (softrange > 129) { /* only scale large int buttons */ /* non linear change in mouse input- good for high precicsionm ints need less fine tuning */ data->dragf+= (((float)(mx-data->draglastx))/deler) * (fabsf(data->dragstartx-mx)*0.004f); - } else { + } + else { /*no scaling */ data->dragf += ((float)(mx - data->draglastx)) / deler; } @@ -2447,7 +2453,7 @@ static int ui_numedit_but_NUM(uiBut *but, uiHandleButtonData *data, float fac, i tempf= (softmin + data->dragf*softrange); - if(!ui_is_but_float(but)) { + if (!ui_is_but_float(but)) { temp= floorf(tempf + 0.5f); temp= ui_numedit_apply_snap(temp, softmin, softmax, snap); @@ -2455,7 +2461,7 @@ static int ui_numedit_but_NUM(uiBut *but, uiHandleButtonData *data, float fac, i CLAMP(temp, softmin, softmax); lvalue= (int)data->value; - if(temp != lvalue) { + if (temp != lvalue) { data->dragchange= 1; data->value= (double)temp; changed= 1; @@ -2467,7 +2473,7 @@ static int ui_numedit_but_NUM(uiBut *but, uiHandleButtonData *data, float fac, i CLAMP(tempf, softmin, softmax); - if(tempf != (float)data->value) { + if (tempf != (float)data->value) { data->dragchange= 1; data->value= tempf; changed= 1; @@ -2491,27 +2497,27 @@ static int ui_do_but_NUM(bContext *C, uiBlock *block, uiBut *but, uiHandleButton ui_window_to_block(data->region, block, &mx, &my); - if(data->state == BUTTON_STATE_HIGHLIGHT) { + if (data->state == BUTTON_STATE_HIGHLIGHT) { /* XXX hardcoded keymap check.... */ - if(event->type == WHEELDOWNMOUSE && event->alt) { + if (event->type == WHEELDOWNMOUSE && event->alt) { mx= but->x1; click= 1; } - else if(event->type == WHEELUPMOUSE && event->alt) { + else if (event->type == WHEELUPMOUSE && event->alt) { mx= but->x2; click= 1; } - else if(event->val==KM_PRESS) { - if(ELEM3(event->type, LEFTMOUSE, PADENTER, RETKEY) && event->ctrl) { + else if (event->val==KM_PRESS) { + if (ELEM3(event->type, LEFTMOUSE, PADENTER, RETKEY) && event->ctrl) { button_activate_state(C, but, BUTTON_STATE_TEXT_EDITING); retval= WM_UI_HANDLER_BREAK; } - else if(event->type == LEFTMOUSE) { + else if (event->type == LEFTMOUSE) { data->dragstartx= data->draglastx= ui_is_a_warp_but(but) ? screen_mx:mx; button_activate_state(C, but, BUTTON_STATE_NUM_EDITING); retval= WM_UI_HANDLER_BREAK; } - else if(ELEM(event->type, PADENTER, RETKEY) && event->val==KM_PRESS) + else if (ELEM(event->type, PADENTER, RETKEY) && event->val==KM_PRESS) click= 1; else if (event->type == MINUSKEY && event->val==KM_PRESS) { button_activate_state(C, but, BUTTON_STATE_NUM_EDITING); @@ -2522,43 +2528,43 @@ static int ui_do_but_NUM(bContext *C, uiBlock *block, uiBut *but, uiHandleButton } } - else if(data->state == BUTTON_STATE_NUM_EDITING) { - if(event->type == ESCKEY) { + else if (data->state == BUTTON_STATE_NUM_EDITING) { + if (event->type == ESCKEY) { data->cancel= 1; data->escapecancel= 1; button_activate_state(C, but, BUTTON_STATE_EXIT); } - else if(event->type == LEFTMOUSE && event->val!=KM_PRESS) { - if(data->dragchange) + else if (event->type == LEFTMOUSE && event->val!=KM_PRESS) { + if (data->dragchange) button_activate_state(C, but, BUTTON_STATE_EXIT); else click= 1; } - else if(event->type == MOUSEMOVE) { + else if (event->type == MOUSEMOVE) { float fac; int snap; fac= 1.0f; - if(event->shift) fac /= 10.0f; - if(event->alt) fac /= 20.0f; + if (event->shift) fac /= 10.0f; + if (event->alt) fac /= 20.0f; snap= (event->ctrl)? (event->shift)? 2: 1: 0; - if(ui_numedit_but_NUM(but, data, fac, snap, (ui_is_a_warp_but(but) ? screen_mx:mx))) + if (ui_numedit_but_NUM(but, data, fac, snap, (ui_is_a_warp_but(but) ? screen_mx:mx))) ui_numedit_apply(C, block, but, data); } retval= WM_UI_HANDLER_BREAK; } - else if(data->state == BUTTON_STATE_TEXT_EDITING) { + else if (data->state == BUTTON_STATE_TEXT_EDITING) { ui_do_but_textedit(C, block, but, data, event); retval= WM_UI_HANDLER_BREAK; } - else if(data->state == BUTTON_STATE_TEXT_SELECTING) { + else if (data->state == BUTTON_STATE_TEXT_SELECTING) { ui_do_but_textedit_select(C, block, but, data, event); retval= WM_UI_HANDLER_BREAK; } - if(click) { + if (click) { /* we can click on the side arrows to increment/decrement, * or click inside to edit the value directly */ float tempf, softmin, softmax; @@ -2567,23 +2573,23 @@ static int ui_do_but_NUM(bContext *C, uiBlock *block, uiBut *but, uiHandleButton softmin= but->softmin; softmax= but->softmax; - if(!ui_is_but_float(but)) { - if(mx < (but->x1 + (but->x2 - but->x1)/3 - 3)) { + if (!ui_is_but_float(but)) { + if (mx < (but->x1 + (but->x2 - but->x1)/3 - 3)) { button_activate_state(C, but, BUTTON_STATE_NUM_EDITING); temp= (int)data->value - 1; - if(temp>=softmin && temp<=softmax) + if (temp>=softmin && temp<=softmax) data->value= (double)temp; else data->cancel= 1; button_activate_state(C, but, BUTTON_STATE_EXIT); } - else if(mx > (but->x1 + (2*(but->x2 - but->x1)/3) + 3)) { + else if (mx > (but->x1 + (2*(but->x2 - but->x1)/3) + 3)) { button_activate_state(C, but, BUTTON_STATE_NUM_EDITING); temp= (int)data->value + 1; - if(temp>=softmin && temp<=softmax) + if (temp>=softmin && temp<=softmax) data->value= (double)temp; else data->cancel= 1; @@ -2594,7 +2600,7 @@ static int ui_do_but_NUM(bContext *C, uiBlock *block, uiBut *but, uiHandleButton button_activate_state(C, but, BUTTON_STATE_TEXT_EDITING); } else { - if(mx < (but->x1 + (but->x2 - but->x1)/3 - 3)) { + if (mx < (but->x1 + (but->x2 - but->x1)/3 - 3)) { button_activate_state(C, but, BUTTON_STATE_NUM_EDITING); tempf= (float)data->value - 0.01f * but->a1; @@ -2603,7 +2609,7 @@ static int ui_do_but_NUM(bContext *C, uiBlock *block, uiBut *but, uiHandleButton button_activate_state(C, but, BUTTON_STATE_EXIT); } - else if(mx > but->x1 + (2*((but->x2 - but->x1)/3) + 3)) { + else if (mx > but->x1 + (2*((but->x2 - but->x1)/3) + 3)) { button_activate_state(C, but, BUTTON_STATE_NUM_EDITING); tempf= (float)data->value + 0.01f * but->a1; @@ -2631,9 +2637,9 @@ static int ui_numedit_but_SLI(uiBut *but, uiHandleButtonData *data, int shift, i softmax= but->softmax; softrange= softmax - softmin; - if(but->type==NUMSLI) deler= ((but->x2-but->x1) - 5.0f*but->aspect); - else if(but->type==HSVSLI) deler= ((but->x2-but->x1)/2.0f - 5.0f*but->aspect); - else if(but->type==SCROLL) { + if (but->type==NUMSLI) deler= ((but->x2-but->x1) - 5.0f*but->aspect); + else if (but->type==HSVSLI) deler= ((but->x2-but->x1)/2.0f - 5.0f*but->aspect); + else if (but->type==SCROLL) { int horizontal= (but->x2 - but->x1 > but->y2 - but->y1); float size= (horizontal)? (but->x2-but->x1): -(but->y2-but->y1); deler= size*(but->softmax - but->softmin)/(but->softmax - but->softmin + but->a1); @@ -2642,26 +2648,26 @@ static int ui_numedit_but_SLI(uiBut *but, uiHandleButtonData *data, int shift, i f= (float)(mx-data->dragstartx)/deler + data->dragfstart; - if(shift) + if (shift) f= (f-data->dragfstart)/10.0f + data->dragfstart; CLAMP(f, 0.0f, 1.0f); tempf= softmin + f*softrange; temp= floorf(tempf+0.5f); - if(ctrl) { - if(tempf==softmin || tempf==softmax); - else if(ui_is_but_float(but)) { + if (ctrl) { + if (tempf==softmin || tempf==softmax); + else if (ui_is_but_float(but)) { - if(shift) { - if(tempf==softmin || tempf==softmax); - else if(softmax-softmin < 2.10f) tempf= 0.01f * floorf(100.0f*tempf); - else if(softmax-softmin < 21.0f) tempf= 0.1f * floorf(10.0f*tempf); + if (shift) { + if (tempf==softmin || tempf==softmax); + else if (softmax-softmin < 2.10f) tempf= 0.01f * floorf(100.0f*tempf); + else if (softmax-softmin < 21.0f) tempf= 0.1f * floorf(10.0f*tempf); else tempf= floorf(tempf); } else { - if(softmax-softmin < 2.10f) tempf= 0.1f * floorf(10.0f*tempf); - else if(softmax-softmin < 21.0f) tempf= floorf(tempf); + if (softmax-softmin < 2.10f) tempf= 0.1f * floorf(10.0f*tempf); + else if (softmax-softmin < 21.0f) tempf= floorf(tempf); else tempf= 10.0f*floorf(tempf/10.0f); } } @@ -2671,12 +2677,12 @@ static int ui_numedit_but_SLI(uiBut *but, uiHandleButtonData *data, int shift, i } } - if(!ui_is_but_float(but)) { + if (!ui_is_but_float(but)) { lvalue= floor(data->value+0.5); CLAMP(temp, softmin, softmax); - if(temp != lvalue) { + if (temp != lvalue) { data->value= temp; data->dragchange= 1; changed= 1; @@ -2685,7 +2691,7 @@ static int ui_numedit_but_SLI(uiBut *but, uiHandleButtonData *data, int shift, i else { CLAMP(tempf, softmin, softmax); - if(tempf != (float)data->value) { + if (tempf != (float)data->value) { data->value= tempf; data->dragchange= 1; changed= 1; @@ -2704,23 +2710,23 @@ static int ui_do_but_SLI(bContext *C, uiBlock *block, uiBut *but, uiHandleButton my= event->y; ui_window_to_block(data->region, block, &mx, &my); - if(data->state == BUTTON_STATE_HIGHLIGHT) { + if (data->state == BUTTON_STATE_HIGHLIGHT) { /* XXX hardcoded keymap check.... */ - if(event->type == WHEELDOWNMOUSE && event->alt) { + if (event->type == WHEELDOWNMOUSE && event->alt) { mx= but->x1; click= 2; } - else if(event->type == WHEELUPMOUSE && event->alt) { + else if (event->type == WHEELUPMOUSE && event->alt) { mx= but->x2; click= 2; } - else if(event->val==KM_PRESS) { - if(ELEM3(event->type, LEFTMOUSE, PADENTER, RETKEY) && event->ctrl) { + else if (event->val==KM_PRESS) { + if (ELEM3(event->type, LEFTMOUSE, PADENTER, RETKEY) && event->ctrl) { button_activate_state(C, but, BUTTON_STATE_TEXT_EDITING); retval= WM_UI_HANDLER_BREAK; } /* alt-click on sides to get "arrows" like in NUM buttons, and match wheel usage above */ - else if(event->type == LEFTMOUSE && event->alt) { + else if (event->type == LEFTMOUSE && event->alt) { int halfpos = (but->x1 + but->x2) / 2; click = 2; if (mx < halfpos) @@ -2728,13 +2734,13 @@ static int ui_do_but_SLI(bContext *C, uiBlock *block, uiBut *but, uiHandleButton else mx = but->x2; } - else if(event->type == LEFTMOUSE) { + else if (event->type == LEFTMOUSE) { data->dragstartx= mx; data->draglastx= mx; button_activate_state(C, but, BUTTON_STATE_NUM_EDITING); retval= WM_UI_HANDLER_BREAK; } - else if(ELEM(event->type, PADENTER, RETKEY) && event->val==KM_PRESS) + else if (ELEM(event->type, PADENTER, RETKEY) && event->val==KM_PRESS) click= 1; else if (event->type == MINUSKEY && event->val==KM_PRESS) { button_activate_state(C, but, BUTTON_STATE_NUM_EDITING); @@ -2744,34 +2750,34 @@ static int ui_do_but_SLI(bContext *C, uiBlock *block, uiBut *but, uiHandleButton } } } - else if(data->state == BUTTON_STATE_NUM_EDITING) { - if(event->type == ESCKEY) { + else if (data->state == BUTTON_STATE_NUM_EDITING) { + if (event->type == ESCKEY) { data->cancel= 1; data->escapecancel= 1; button_activate_state(C, but, BUTTON_STATE_EXIT); } - else if(event->type == LEFTMOUSE && event->val!=KM_PRESS) { - if(data->dragchange) + else if (event->type == LEFTMOUSE && event->val!=KM_PRESS) { + if (data->dragchange) button_activate_state(C, but, BUTTON_STATE_EXIT); else click= 1; } - else if(event->type == MOUSEMOVE) { - if(ui_numedit_but_SLI(but, data, event->shift, event->ctrl, mx)) + else if (event->type == MOUSEMOVE) { + if (ui_numedit_but_SLI(but, data, event->shift, event->ctrl, mx)) ui_numedit_apply(C, block, but, data); } retval= WM_UI_HANDLER_BREAK; } - else if(data->state == BUTTON_STATE_TEXT_EDITING) { + else if (data->state == BUTTON_STATE_TEXT_EDITING) { ui_do_but_textedit(C, block, but, data, event); retval= WM_UI_HANDLER_BREAK; } - else if(data->state == BUTTON_STATE_TEXT_SELECTING) { + else if (data->state == BUTTON_STATE_TEXT_SELECTING) { ui_do_but_textedit_select(C, block, but, data, event); retval= WM_UI_HANDLER_BREAK; } - if(click) { + if (click) { if (click==2) { /* nudge slider to the left or right */ float f, tempf, softmin, softmax, softrange; @@ -2787,7 +2793,7 @@ static int ui_do_but_SLI(bContext *C, uiBlock *block, uiBut *but, uiHandleButton temp= (int)data->value; #if 0 - if(but->type==SLI) { + if (but->type==SLI) { f= (float)(mx-but->x1)/(but->x2-but->x1); /* same as below */ } else @@ -2798,20 +2804,20 @@ static int ui_do_but_SLI(bContext *C, uiBlock *block, uiBut *but, uiHandleButton f= softmin + f*softrange; - if(!ui_is_but_float(but)) { - if(f=softmin && temp<=softmax) + if (temp>=softmin && temp<=softmax) data->value= temp; else data->cancel= 1; } else { - if(f=softmin && tempf<=softmax) + if (tempf>=softmin && tempf<=softmax) data->value= tempf; else data->cancel= 1; @@ -2840,10 +2846,10 @@ static int ui_do_but_SCROLL(bContext *C, uiBlock *block, uiBut *but, uiHandleBut my= event->y; ui_window_to_block(data->region, block, &mx, &my); - if(data->state == BUTTON_STATE_HIGHLIGHT) { - if(event->val==KM_PRESS) { - if(event->type == LEFTMOUSE) { - if(horizontal) { + if (data->state == BUTTON_STATE_HIGHLIGHT) { + if (event->val==KM_PRESS) { + if (event->type == LEFTMOUSE) { + if (horizontal) { data->dragstartx= mx; data->draglastx= mx; } @@ -2856,22 +2862,22 @@ static int ui_do_but_SCROLL(bContext *C, uiBlock *block, uiBut *but, uiHandleBut } /* UNUSED - otherwise code is ok, add back if needed */ #if 0 - else if(ELEM(event->type, PADENTER, RETKEY) && event->val==KM_PRESS) + else if (ELEM(event->type, PADENTER, RETKEY) && event->val==KM_PRESS) click= 1; #endif } } - else if(data->state == BUTTON_STATE_NUM_EDITING) { - if(event->type == ESCKEY) { + else if (data->state == BUTTON_STATE_NUM_EDITING) { + if (event->type == ESCKEY) { data->cancel= 1; data->escapecancel= 1; button_activate_state(C, but, BUTTON_STATE_EXIT); } - else if(event->type == LEFTMOUSE && event->val!=KM_PRESS) { + else if (event->type == LEFTMOUSE && event->val!=KM_PRESS) { button_activate_state(C, but, BUTTON_STATE_EXIT); } - else if(event->type == MOUSEMOVE) { - if(ui_numedit_but_SLI(but, data, 0, 0, (horizontal)? mx: my)) + else if (event->type == MOUSEMOVE) { + if (ui_numedit_but_SLI(but, data, 0, 0, (horizontal)? mx: my)) ui_numedit_apply(C, block, but, data); } @@ -2885,11 +2891,11 @@ static int ui_do_but_SCROLL(bContext *C, uiBlock *block, uiBut *but, uiHandleBut static int ui_do_but_BLOCK(bContext *C, uiBut *but, uiHandleButtonData *data, wmEvent *event) { - if(data->state == BUTTON_STATE_HIGHLIGHT) { + if (data->state == BUTTON_STATE_HIGHLIGHT) { /* first handle click on icondrag type button */ - if(event->type==LEFTMOUSE && but->dragpoin && event->val==KM_PRESS) { - if(ui_but_mouse_inside_icon(but, data->region, event)) { + if (event->type==LEFTMOUSE && but->dragpoin && event->val==KM_PRESS) { + if (ui_but_mouse_inside_icon(but, data->region, event)) { button_activate_state(C, but, BUTTON_STATE_WAIT_DRAG); data->dragstartx= event->x; data->dragstarty= event->y; @@ -2898,13 +2904,13 @@ static int ui_do_but_BLOCK(bContext *C, uiBut *but, uiHandleButtonData *data, wm } /* regular open menu */ - if(ELEM3(event->type, LEFTMOUSE, PADENTER, RETKEY) && event->val==KM_PRESS) { + if (ELEM3(event->type, LEFTMOUSE, PADENTER, RETKEY) && event->val==KM_PRESS) { button_activate_state(C, but, BUTTON_STATE_MENU_OPEN); return WM_UI_HANDLER_BREAK; } - else if(ELEM3(but->type, MENU, ICONROW, ICONTEXTROW)) { + else if (ELEM3(but->type, MENU, ICONROW, ICONTEXTROW)) { - if(event->type == WHEELDOWNMOUSE && event->alt) { + if (event->type == WHEELDOWNMOUSE && event->alt) { data->value= ui_step_name_menu(but, -1); button_activate_state(C, but, BUTTON_STATE_EXIT); ui_apply_button(C, but->block, but, data, 1); @@ -2921,7 +2927,7 @@ static int ui_do_but_BLOCK(bContext *C, uiBut *but, uiHandleButtonData *data, wm return WM_UI_HANDLER_BREAK; } - else if(event->type == WHEELUPMOUSE && event->alt) { + else if (event->type == WHEELUPMOUSE && event->alt) { data->value= ui_step_name_menu(but, 1); button_activate_state(C, but, BUTTON_STATE_EXIT); ui_apply_button(C, but->block, but, data, 1); @@ -2933,15 +2939,15 @@ static int ui_do_but_BLOCK(bContext *C, uiBut *but, uiHandleButtonData *data, wm return WM_UI_HANDLER_BREAK; } } - else if(but->type==COL) { - if( ELEM(event->type, WHEELDOWNMOUSE, WHEELUPMOUSE) && event->alt) { + else if (but->type==COL) { + if ( ELEM(event->type, WHEELDOWNMOUSE, WHEELUPMOUSE) && event->alt) { float *hsv= ui_block_hsv_get(but->block); float col[3]; ui_get_but_vectorf(but, col); rgb_to_hsv_compat(col[0], col[1], col[2], hsv, hsv+1, hsv+2); - if(event->type==WHEELDOWNMOUSE) + if (event->type==WHEELDOWNMOUSE) hsv[2]= CLAMPIS(hsv[2]-0.05f, 0.0f, 1.0f); else hsv[2]= CLAMPIS(hsv[2]+0.05f, 0.0f, 1.0f); @@ -2955,21 +2961,21 @@ static int ui_do_but_BLOCK(bContext *C, uiBut *but, uiHandleButtonData *data, wm } } } - else if(data->state == BUTTON_STATE_WAIT_DRAG) { + else if (data->state == BUTTON_STATE_WAIT_DRAG) { /* this function also ends state */ - if(ui_but_start_drag(C, but, data, event)) { + if (ui_but_start_drag(C, but, data, event)) { return WM_UI_HANDLER_BREAK; } /* outside icon quit, not needed if drag activated */ - if(0==ui_but_mouse_inside_icon(but, data->region, event)) { + if (0==ui_but_mouse_inside_icon(but, data->region, event)) { button_activate_state(C, but, BUTTON_STATE_EXIT); data->cancel= 1; return WM_UI_HANDLER_BREAK; } - if(event->type==LEFTMOUSE && event->val==KM_RELEASE) { + if (event->type==LEFTMOUSE && event->val==KM_RELEASE) { button_activate_state(C, but, BUTTON_STATE_MENU_OPEN); return WM_UI_HANDLER_BREAK; } @@ -2994,11 +3000,11 @@ static int ui_numedit_but_NORMAL(uiBut *but, uiHandleButtonData *data, int mx, i rad= (but->x2 - but->x1); radsq= rad*rad; - if(fp[2]>0.0f) { + if (fp[2]>0.0f) { mdx= (rad*fp[0]); mdy= (rad*fp[1]); } - else if(fp[2]> -1.0f) { + else if (fp[2]> -1.0f) { mrad= rad/sqrtf(fp[0]*fp[0] + fp[1]*fp[1]); mdx= 2.0f*mrad*fp[0] - (rad*fp[0]); @@ -3011,7 +3017,7 @@ static int ui_numedit_but_NORMAL(uiBut *but, uiHandleButtonData *data, int mx, i fp= data->vec; mrad= dx*dx+dy*dy; - if(mrad < radsq) { /* inner circle */ + if (mrad < radsq) { /* inner circle */ fp[0]= dx; fp[1]= dy; fp[2]= sqrt( radsq-dx*dx-dy*dy ); @@ -3024,7 +3030,7 @@ static int ui_numedit_but_NORMAL(uiBut *but, uiHandleButtonData *data, int mx, i dy*= (2.0f*mrad - 1.0f); mrad= dx*dx+dy*dy; - if(mrad < radsq) { + if (mrad < radsq) { fp[0]= dx; fp[1]= dy; fp[2]= -sqrt( radsq-dx*dx-dy*dy ); @@ -3046,8 +3052,8 @@ static int ui_do_but_NORMAL(bContext *C, uiBlock *block, uiBut *but, uiHandleBut my= event->y; ui_window_to_block(data->region, block, &mx, &my); - if(data->state == BUTTON_STATE_HIGHLIGHT) { - if(event->type==LEFTMOUSE && event->val==KM_PRESS) { + if (data->state == BUTTON_STATE_HIGHLIGHT) { + if (event->type==LEFTMOUSE && event->val==KM_PRESS) { data->dragstartx= mx; data->dragstarty= my; data->draglastx= mx; @@ -3055,20 +3061,20 @@ static int ui_do_but_NORMAL(bContext *C, uiBlock *block, uiBut *but, uiHandleBut button_activate_state(C, but, BUTTON_STATE_NUM_EDITING); /* also do drag the first time */ - if(ui_numedit_but_NORMAL(but, data, mx, my)) + if (ui_numedit_but_NORMAL(but, data, mx, my)) ui_numedit_apply(C, block, but, data); return WM_UI_HANDLER_BREAK; } } - else if(data->state == BUTTON_STATE_NUM_EDITING) { - if(event->type == MOUSEMOVE) { - if(mx!=data->draglastx || my!=data->draglasty) { - if(ui_numedit_but_NORMAL(but, data, mx, my)) + else if (data->state == BUTTON_STATE_NUM_EDITING) { + if (event->type == MOUSEMOVE) { + if (mx!=data->draglastx || my!=data->draglasty) { + if (ui_numedit_but_NORMAL(but, data, mx, my)) ui_numedit_apply(C, block, but, data); } } - else if(event->type==LEFTMOUSE && event->val!=KM_PRESS) + else if (event->type==LEFTMOUSE && event->val!=KM_PRESS) button_activate_state(C, but, BUTTON_STATE_EXIT); return WM_UI_HANDLER_BREAK; @@ -3212,8 +3218,8 @@ static int ui_do_but_HSVCUBE(bContext *C, uiBlock *block, uiBut *but, uiHandleBu my= event->y; ui_window_to_block(data->region, block, &mx, &my); - if(data->state == BUTTON_STATE_HIGHLIGHT) { - if(event->type==LEFTMOUSE && event->val==KM_PRESS) { + if (data->state == BUTTON_STATE_HIGHLIGHT) { + if (event->type==LEFTMOUSE && event->val==KM_PRESS) { data->dragstartx= mx; data->dragstarty= my; data->draglastx= mx; @@ -3221,7 +3227,7 @@ static int ui_do_but_HSVCUBE(bContext *C, uiBlock *block, uiBut *but, uiHandleBu button_activate_state(C, but, BUTTON_STATE_NUM_EDITING); /* also do drag the first time */ - if(ui_numedit_but_HSVCUBE(but, data, mx, my)) + if (ui_numedit_but_HSVCUBE(but, data, mx, my)) ui_numedit_apply(C, block, but, data); return WM_UI_HANDLER_BREAK; @@ -3238,7 +3244,7 @@ static int ui_do_but_HSVCUBE(bContext *C, uiBlock *block, uiBut *but, uiHandleBu } /* XXX hardcoded keymap check.... */ else if (event->type == BACKSPACEKEY && event->val == KM_PRESS) { - if (but->a1==UI_GRAD_V_ALT){ + if (but->a1==UI_GRAD_V_ALT) { int len; /* reset only value */ @@ -3267,19 +3273,19 @@ static int ui_do_but_HSVCUBE(bContext *C, uiBlock *block, uiBut *but, uiHandleBu } } } - else if(data->state == BUTTON_STATE_NUM_EDITING) { - if(event->type == ESCKEY) { + else if (data->state == BUTTON_STATE_NUM_EDITING) { + if (event->type == ESCKEY) { data->cancel= 1; data->escapecancel= 1; button_activate_state(C, but, BUTTON_STATE_EXIT); } - else if(event->type == MOUSEMOVE) { - if(mx!=data->draglastx || my!=data->draglasty) { - if(ui_numedit_but_HSVCUBE(but, data, mx, my)) + else if (event->type == MOUSEMOVE) { + if (mx!=data->draglastx || my!=data->draglasty) { + if (ui_numedit_but_HSVCUBE(but, data, mx, my)) ui_numedit_apply(C, block, but, data); } } - else if(event->type==LEFTMOUSE && event->val!=KM_PRESS) + else if (event->type==LEFTMOUSE && event->val!=KM_PRESS) button_activate_state(C, but, BUTTON_STATE_EXIT); return WM_UI_HANDLER_BREAK; @@ -3308,7 +3314,7 @@ static int ui_numedit_but_HSVCIRCLE(uiBut *but, uiHandleButtonData *data, int mx if (hsv[2] == 0.f) hsv[2] = 0.0001f; } - if(U.uiflag & USER_CONTINUOUS_MOUSE) { + if (U.uiflag & USER_CONTINUOUS_MOUSE) { float fac= shift ? 0.05f : 1.0f; /* slow down the mouse, this is fairly picky */ mx = (data->dragstartx*(1.0f-fac) + mx*fac); @@ -3317,12 +3323,12 @@ static int ui_numedit_but_HSVCIRCLE(uiBut *but, uiHandleButtonData *data, int mx ui_hsvcircle_vals_from_pos(hsv, hsv+1, &rect, (float)mx, (float)my); - if(but->flag & UI_BUT_COLOR_CUBIC) + if (but->flag & UI_BUT_COLOR_CUBIC) hsv[1]= 1.0f - sqrt3f(1.0f - hsv[1]); hsv_to_rgb(hsv[0], hsv[1], hsv[2], rgb, rgb+1, rgb+2); - if((but->flag & UI_BUT_VEC_SIZE_LOCK) && (rgb[0] || rgb[1] || rgb[2])) { + if ((but->flag & UI_BUT_VEC_SIZE_LOCK) && (rgb[0] || rgb[1] || rgb[2])) { normalize_v3(rgb); mul_v3_fl(rgb, but->a2); } @@ -3379,7 +3385,7 @@ static void ui_ndofedit_but_HSVCIRCLE(uiBut *but, uiHandleButtonData *data, wmND hsv_to_rgb(hsv[0], hsv[1], hsv[2], data->vec, data->vec+1, data->vec+2); - if((but->flag & UI_BUT_VEC_SIZE_LOCK) && (data->vec[0] || data->vec[1] || data->vec[2])) { + if ((but->flag & UI_BUT_VEC_SIZE_LOCK) && (data->vec[0] || data->vec[1] || data->vec[2])) { normalize_v3(data->vec); mul_v3_fl(data->vec, but->a2); } @@ -3395,8 +3401,8 @@ static int ui_do_but_HSVCIRCLE(bContext *C, uiBlock *block, uiBut *but, uiHandle my= event->y; ui_window_to_block(data->region, block, &mx, &my); - if(data->state == BUTTON_STATE_HIGHLIGHT) { - if(event->type==LEFTMOUSE && event->val==KM_PRESS) { + if (data->state == BUTTON_STATE_HIGHLIGHT) { + if (event->type==LEFTMOUSE && event->val==KM_PRESS) { data->dragstartx= mx; data->dragstarty= my; data->draglastx= mx; @@ -3404,7 +3410,7 @@ static int ui_do_but_HSVCIRCLE(bContext *C, uiBlock *block, uiBut *but, uiHandle button_activate_state(C, but, BUTTON_STATE_NUM_EDITING); /* also do drag the first time */ - if(ui_numedit_but_HSVCIRCLE(but, data, mx, my, event->shift)) + if (ui_numedit_but_HSVCIRCLE(but, data, mx, my, event->shift)) ui_numedit_apply(C, block, but, data); return WM_UI_HANDLER_BREAK; @@ -3448,32 +3454,32 @@ static int ui_do_but_HSVCIRCLE(bContext *C, uiBlock *block, uiBut *but, uiHandle return WM_UI_HANDLER_BREAK; } } - else if(data->state == BUTTON_STATE_NUM_EDITING) { - if(event->type == ESCKEY) { + else if (data->state == BUTTON_STATE_NUM_EDITING) { + if (event->type == ESCKEY) { data->cancel= 1; data->escapecancel= 1; button_activate_state(C, but, BUTTON_STATE_EXIT); } /* XXX hardcoded keymap check.... */ - else if(event->type == WHEELDOWNMOUSE) { + else if (event->type == WHEELDOWNMOUSE) { float *hsv= ui_block_hsv_get(but->block); hsv[2]= CLAMPIS(hsv[2]-0.05f, 0.0f, 1.0f); ui_set_but_hsv(but); // converts to rgb ui_numedit_apply(C, block, but, data); } - else if(event->type == WHEELUPMOUSE) { + else if (event->type == WHEELUPMOUSE) { float *hsv= ui_block_hsv_get(but->block); hsv[2]= CLAMPIS(hsv[2]+0.05f, 0.0f, 1.0f); ui_set_but_hsv(but); // converts to rgb ui_numedit_apply(C, block, but, data); } - else if(event->type == MOUSEMOVE) { - if(mx!=data->draglastx || my!=data->draglasty) { - if(ui_numedit_but_HSVCIRCLE(but, data, mx, my, event->shift)) + else if (event->type == MOUSEMOVE) { + if (mx!=data->draglastx || my!=data->draglasty) { + if (ui_numedit_but_HSVCIRCLE(but, data, mx, my, event->shift)) ui_numedit_apply(C, block, but, data); } } - else if(event->type==LEFTMOUSE && event->val!=KM_PRESS) { + else if (event->type==LEFTMOUSE && event->val!=KM_PRESS) { button_activate_state(C, but, BUTTON_STATE_EXIT); } return WM_UI_HANDLER_BREAK; @@ -3488,7 +3494,7 @@ static int ui_numedit_but_COLORBAND(uiBut *but, uiHandleButtonData *data, int mx float dx; int changed= 0; - if(data->draglastx == mx) + if (data->draglastx == mx) return changed; dx= ((float)(mx - data->draglastx))/(but->x2-but->x1); @@ -3514,11 +3520,11 @@ static int ui_do_but_COLORBAND(bContext *C, uiBlock *block, uiBut *but, uiHandle my= event->y; ui_window_to_block(data->region, block, &mx, &my); - if(data->state == BUTTON_STATE_HIGHLIGHT) { - if(event->type==LEFTMOUSE && event->val==KM_PRESS) { + if (data->state == BUTTON_STATE_HIGHLIGHT) { + if (event->type==LEFTMOUSE && event->val==KM_PRESS) { coba= (ColorBand*)but->poin; - if(event->ctrl) { + if (event->ctrl) { /* insert new key on mouse location */ float pos= ((float)(mx - but->x1))/(but->x2-but->x1); colorband_element_add(coba, pos); @@ -3531,11 +3537,11 @@ static int ui_do_but_COLORBAND(bContext *C, uiBlock *block, uiBut *but, uiHandle data->draglasty= my; /* activate new key when mouse is close */ - for(a=0, cbd= coba->data; atot; a++, cbd++) { + for (a=0, cbd= coba->data; atot; a++, cbd++) { xco= but->x1 + (cbd->pos*(but->x2-but->x1)); xco= ABS(xco-mx); - if(a==coba->cur) xco+= 5; // selected one disadvantage - if(xcocur) xco+= 5; // selected one disadvantage + if (xcocur= a; mindist= xco; } @@ -3548,14 +3554,14 @@ static int ui_do_but_COLORBAND(bContext *C, uiBlock *block, uiBut *but, uiHandle return WM_UI_HANDLER_BREAK; } } - else if(data->state == BUTTON_STATE_NUM_EDITING) { - if(event->type == MOUSEMOVE) { - if(mx!=data->draglastx || my!=data->draglasty) { - if(ui_numedit_but_COLORBAND(but, data, mx)) + else if (data->state == BUTTON_STATE_NUM_EDITING) { + if (event->type == MOUSEMOVE) { + if (mx!=data->draglastx || my!=data->draglasty) { + if (ui_numedit_but_COLORBAND(but, data, mx)) ui_numedit_apply(C, block, but, data); } } - else if(event->type==LEFTMOUSE && event->val!=KM_PRESS) + else if (event->type==LEFTMOUSE && event->val!=KM_PRESS) button_activate_state(C, but, BUTTON_STATE_EXIT); return WM_UI_HANDLER_BREAK; @@ -3577,38 +3583,38 @@ static int ui_numedit_but_CURVE(uiBut *but, uiHandleButtonData *data, int snap, /* offsx= cumap->curr.xmin; */ /* offsy= cumap->curr.ymin; */ - if(snap) { + if (snap) { float d[2]; d[0]= mx - data->dragstartx; d[1]= my - data->dragstarty; - if(len_v2(d) < 3.0f) + if (len_v2(d) < 3.0f) snap= 0; } - if(data->dragsel != -1) { + if (data->dragsel != -1) { int moved_point= 0; /* for ctrl grid, can't use orig coords because of sorting */ fx= (mx-data->draglastx)/zoomx; fy= (my-data->draglasty)/zoomy; - for(a=0; atotpoint; a++) { - if(cmp[a].flag & SELECT) { + for (a=0; atotpoint; a++) { + if (cmp[a].flag & SELECT) { float origx= cmp[a].x, origy= cmp[a].y; cmp[a].x+= fx; cmp[a].y+= fy; - if(snap) { + if (snap) { cmp[a].x= 0.125f*floorf(0.5f + 8.0f*cmp[a].x); cmp[a].y= 0.125f*floorf(0.5f + 8.0f*cmp[a].y); } - if(cmp[a].x!=origx || cmp[a].y!=origy) + if (cmp[a].x!=origx || cmp[a].y!=origy) moved_point= 1; } } curvemapping_changed(cumap, 0); /* no remove doubles */ - if(moved_point) { + if (moved_point) { data->draglastx= mx; data->draglasty= my; changed= 1; @@ -3621,14 +3627,14 @@ static int ui_numedit_but_CURVE(uiBut *but, uiHandleButtonData *data, int snap, fy= (my-data->draglasty)/zoomy; /* clamp for clip */ - if(cumap->flag & CUMA_DO_CLIP) { - if(cumap->curr.xmin-fx < cumap->clipr.xmin) + if (cumap->flag & CUMA_DO_CLIP) { + if (cumap->curr.xmin-fx < cumap->clipr.xmin) fx= cumap->curr.xmin - cumap->clipr.xmin; - else if(cumap->curr.xmax-fx > cumap->clipr.xmax) + else if (cumap->curr.xmax-fx > cumap->clipr.xmax) fx= cumap->curr.xmax - cumap->clipr.xmax; - if(cumap->curr.ymin-fy < cumap->clipr.ymin) + if (cumap->curr.ymin-fy < cumap->clipr.ymin) fy= cumap->curr.ymin - cumap->clipr.ymin; - else if(cumap->curr.ymax-fy > cumap->clipr.ymax) + else if (cumap->curr.ymax-fy > cumap->clipr.ymax) fy= cumap->curr.ymax - cumap->clipr.ymax; } @@ -3654,8 +3660,8 @@ static int ui_do_but_CURVE(bContext *C, uiBlock *block, uiBut *but, uiHandleButt my= event->y; ui_window_to_block(data->region, block, &mx, &my); - if(data->state == BUTTON_STATE_HIGHLIGHT) { - if(event->type==LEFTMOUSE && event->val==KM_PRESS) { + if (data->state == BUTTON_STATE_HIGHLIGHT) { + if (event->type==LEFTMOUSE && event->val==KM_PRESS) { CurveMapping *cumap= (CurveMapping*)but->poin; CurveMap *cuma= cumap->cm+cumap->cur; CurveMapPoint *cmp; @@ -3668,7 +3674,7 @@ static int ui_do_but_CURVE(bContext *C, uiBlock *block, uiBut *but, uiHandleButt offsx= cumap->curr.xmin; offsy= cumap->curr.ymin; - if(event->ctrl) { + if (event->ctrl) { fx= ((float)my - but->x1)/zoomx + offsx; fy= ((float)my - but->y1)/zoomy + offsy; @@ -3679,11 +3685,11 @@ static int ui_do_but_CURVE(bContext *C, uiBlock *block, uiBut *but, uiHandleButt /* check for selecting of a point */ cmp= cuma->curve; /* ctrl adds point, new malloc */ - for(a=0; atotpoint; a++) { + for (a=0; atotpoint; a++) { fx= but->x1 + zoomx*(cmp[a].x-offsx); fy= but->y1 + zoomy*(cmp[a].y-offsy); dist= (fx-mx)*(fx-mx) + (fy-my)*(fy-my); - if(dist < mindist) { + if (dist < mindist) { sel= a; mindist= dist; } @@ -3701,7 +3707,7 @@ static int ui_do_but_CURVE(bContext *C, uiBlock *block, uiBut *but, uiHandleButt /* loop through the curve segment table and find what's near the mouse. * 0.05 is kinda arbitrary, but seems to be what works nicely. */ - for(i=0; i<=CM_TABLE; i++) { + for (i=0; i<=CM_TABLE; i++) { if ( (fabsf(fx - cmp[i].x) < 0.05f) && (fabsf(fy - cmp[i].y) < 0.05f)) { @@ -3715,8 +3721,8 @@ static int ui_do_but_CURVE(bContext *C, uiBlock *block, uiBut *but, uiHandleButt cmp= cuma->curve; /* find newly added point and make it 'sel' */ - for(a=0; atotpoint; a++) - if(cmp[a].x == fx) + for (a=0; atotpoint; a++) + if (cmp[a].x == fx) sel = a; break; @@ -3724,11 +3730,11 @@ static int ui_do_but_CURVE(bContext *C, uiBlock *block, uiBut *but, uiHandleButt } } - if(sel!= -1) { + if (sel!= -1) { /* ok, we move a point */ /* deselect all if this one is deselect. except if we hold shift */ - if(event->shift == FALSE) { - for(a=0; atotpoint; a++) + if (event->shift == FALSE) { + for (a=0; atotpoint; a++) cmp[a].flag &= ~SELECT; cmp[sel].flag |= SELECT; } @@ -3751,23 +3757,23 @@ static int ui_do_but_CURVE(bContext *C, uiBlock *block, uiBut *but, uiHandleButt return WM_UI_HANDLER_BREAK; } } - else if(data->state == BUTTON_STATE_NUM_EDITING) { - if(event->type == MOUSEMOVE) { - if(mx!=data->draglastx || my!=data->draglasty) { - if(ui_numedit_but_CURVE(but, data, event->ctrl, mx, my)) + else if (data->state == BUTTON_STATE_NUM_EDITING) { + if (event->type == MOUSEMOVE) { + if (mx!=data->draglastx || my!=data->draglasty) { + if (ui_numedit_but_CURVE(but, data, event->ctrl, mx, my)) ui_numedit_apply(C, block, but, data); } } - else if(event->type==LEFTMOUSE && event->val!=KM_PRESS) { - if(data->dragsel != -1) { + else if (event->type==LEFTMOUSE && event->val!=KM_PRESS) { + if (data->dragsel != -1) { CurveMapping *cumap= (CurveMapping*)but->poin; CurveMap *cuma= cumap->cm+cumap->cur; CurveMapPoint *cmp= cuma->curve; - if(!data->dragchange) { + if (!data->dragchange) { /* deselect all, select one */ - if(event->shift == FALSE) { - for(a=0; atotpoint; a++) + if (event->shift == FALSE) { + for (a=0; atotpoint; a++) cmp[a].flag &= ~SELECT; cmp[data->dragsel].flag |= SELECT; } @@ -3811,7 +3817,8 @@ static int ui_numedit_but_HISTOGRAM(uiBut *but, uiHandleButtonData *data, int mx if (in_scope_resize_zone(but, data->dragstartx, data->dragstarty)) { /* resize histogram widget itself */ hist->height = (but->y2 - but->y1) + (data->dragstarty - my); - } else { + } + else { /* scale histogram values */ yfac = MIN2(powf(hist->ymax, 2.f), 1.f) * 0.5f; hist->ymax += dy * yfac; @@ -3833,8 +3840,8 @@ static int ui_do_but_HISTOGRAM(bContext *C, uiBlock *block, uiBut *but, uiHandle my= event->y; ui_window_to_block(data->region, block, &mx, &my); - if(data->state == BUTTON_STATE_HIGHLIGHT) { - if(event->type==LEFTMOUSE && event->val==KM_PRESS) { + if (data->state == BUTTON_STATE_HIGHLIGHT) { + if (event->type==LEFTMOUSE && event->val==KM_PRESS) { data->dragstartx= mx; data->dragstarty= my; data->draglastx= mx; @@ -3842,7 +3849,7 @@ static int ui_do_but_HISTOGRAM(bContext *C, uiBlock *block, uiBut *but, uiHandle button_activate_state(C, but, BUTTON_STATE_NUM_EDITING); /* also do drag the first time */ - if(ui_numedit_but_HISTOGRAM(but, data, mx, my)) + if (ui_numedit_but_HISTOGRAM(but, data, mx, my)) ui_numedit_apply(C, block, but, data); return WM_UI_HANDLER_BREAK; @@ -3856,19 +3863,19 @@ static int ui_do_but_HISTOGRAM(bContext *C, uiBlock *block, uiBut *but, uiHandle return WM_UI_HANDLER_BREAK; } } - else if(data->state == BUTTON_STATE_NUM_EDITING) { - if(event->type == ESCKEY) { + else if (data->state == BUTTON_STATE_NUM_EDITING) { + if (event->type == ESCKEY) { data->cancel= 1; data->escapecancel= 1; button_activate_state(C, but, BUTTON_STATE_EXIT); } - else if(event->type == MOUSEMOVE) { - if(mx!=data->draglastx || my!=data->draglasty) { - if(ui_numedit_but_HISTOGRAM(but, data, mx, my)) + else if (event->type == MOUSEMOVE) { + if (mx!=data->draglastx || my!=data->draglasty) { + if (ui_numedit_but_HISTOGRAM(but, data, mx, my)) ui_numedit_apply(C, block, but, data); } } - else if(event->type==LEFTMOUSE && event->val!=KM_PRESS) { + else if (event->type==LEFTMOUSE && event->val!=KM_PRESS) { button_activate_state(C, but, BUTTON_STATE_EXIT); } return WM_UI_HANDLER_BREAK; @@ -3894,7 +3901,8 @@ static int ui_numedit_but_WAVEFORM(uiBut *but, uiHandleButtonData *data, int mx, if (in_scope_resize_zone(but, data->dragstartx, data->dragstarty)) { /* resize waveform widget itself */ scopes->wavefrm_height = (but->y2 - but->y1) + (data->dragstarty - my); - } else { + } + else { /* scale waveform values */ /* yfac = scopes->wavefrm_yfac; */ /* UNUSED */ scopes->wavefrm_yfac += dy/200.0f; @@ -3916,8 +3924,8 @@ static int ui_do_but_WAVEFORM(bContext *C, uiBlock *block, uiBut *but, uiHandleB my= event->y; ui_window_to_block(data->region, block, &mx, &my); - if(data->state == BUTTON_STATE_HIGHLIGHT) { - if(event->type==LEFTMOUSE && event->val==KM_PRESS) { + if (data->state == BUTTON_STATE_HIGHLIGHT) { + if (event->type==LEFTMOUSE && event->val==KM_PRESS) { data->dragstartx= mx; data->dragstarty= my; data->draglastx= mx; @@ -3925,7 +3933,7 @@ static int ui_do_but_WAVEFORM(bContext *C, uiBlock *block, uiBut *but, uiHandleB button_activate_state(C, but, BUTTON_STATE_NUM_EDITING); /* also do drag the first time */ - if(ui_numedit_but_WAVEFORM(but, data, mx, my)) + if (ui_numedit_but_WAVEFORM(but, data, mx, my)) ui_numedit_apply(C, block, but, data); return WM_UI_HANDLER_BREAK; @@ -3939,19 +3947,19 @@ static int ui_do_but_WAVEFORM(bContext *C, uiBlock *block, uiBut *but, uiHandleB return WM_UI_HANDLER_BREAK; } } - else if(data->state == BUTTON_STATE_NUM_EDITING) { - if(event->type == ESCKEY) { + else if (data->state == BUTTON_STATE_NUM_EDITING) { + if (event->type == ESCKEY) { data->cancel= 1; data->escapecancel= 1; button_activate_state(C, but, BUTTON_STATE_EXIT); } - else if(event->type == MOUSEMOVE) { - if(mx!=data->draglastx || my!=data->draglasty) { - if(ui_numedit_but_WAVEFORM(but, data, mx, my)) + else if (event->type == MOUSEMOVE) { + if (mx!=data->draglastx || my!=data->draglasty) { + if (ui_numedit_but_WAVEFORM(but, data, mx, my)) ui_numedit_apply(C, block, but, data); } } - else if(event->type==LEFTMOUSE && event->val!=KM_PRESS) { + else if (event->type==LEFTMOUSE && event->val!=KM_PRESS) { button_activate_state(C, but, BUTTON_STATE_EXIT); } return WM_UI_HANDLER_BREAK; @@ -3992,8 +4000,8 @@ static int ui_do_but_VECTORSCOPE(bContext *C, uiBlock *block, uiBut *but, uiHand my= event->y; ui_window_to_block(data->region, block, &mx, &my); - if(data->state == BUTTON_STATE_HIGHLIGHT) { - if(event->type==LEFTMOUSE && event->val==KM_PRESS) { + if (data->state == BUTTON_STATE_HIGHLIGHT) { + if (event->type==LEFTMOUSE && event->val==KM_PRESS) { data->dragstartx= mx; data->dragstarty= my; data->draglastx= mx; @@ -4001,25 +4009,25 @@ static int ui_do_but_VECTORSCOPE(bContext *C, uiBlock *block, uiBut *but, uiHand button_activate_state(C, but, BUTTON_STATE_NUM_EDITING); /* also do drag the first time */ - if(ui_numedit_but_VECTORSCOPE(but, data, mx, my)) + if (ui_numedit_but_VECTORSCOPE(but, data, mx, my)) ui_numedit_apply(C, block, but, data); return WM_UI_HANDLER_BREAK; } } - else if(data->state == BUTTON_STATE_NUM_EDITING) { - if(event->type == ESCKEY) { + else if (data->state == BUTTON_STATE_NUM_EDITING) { + if (event->type == ESCKEY) { data->cancel= 1; data->escapecancel= 1; button_activate_state(C, but, BUTTON_STATE_EXIT); } - else if(event->type == MOUSEMOVE) { - if(mx!=data->draglastx || my!=data->draglasty) { - if(ui_numedit_but_VECTORSCOPE(but, data, mx, my)) + else if (event->type == MOUSEMOVE) { + if (mx!=data->draglastx || my!=data->draglasty) { + if (ui_numedit_but_VECTORSCOPE(but, data, mx, my)) ui_numedit_apply(C, block, but, data); } } - else if(event->type==LEFTMOUSE && event->val!=KM_PRESS) { + else if (event->type==LEFTMOUSE && event->val!=KM_PRESS) { button_activate_state(C, but, BUTTON_STATE_EXIT); } return WM_UI_HANDLER_BREAK; @@ -4042,8 +4050,8 @@ static int ui_do_but_CHARTAB(bContext *UNUSED(C), uiBlock *UNUSED(block), uiBut my= event->y; ui_window_to_block(data->region, block, &mx, &my); - if(data->state == BUTTON_STATE_HIGHLIGHT) { - if(ELEM3(event->type, LEFTMOUSE, PADENTER, RETKEY) && event->val==KM_PRESS) { + if (data->state == BUTTON_STATE_HIGHLIGHT) { + if (ELEM3(event->type, LEFTMOUSE, PADENTER, RETKEY) && event->val==KM_PRESS) { /* Calculate the size of the button */ width = abs(but->x2 - but->x1); height = abs(but->y2 - but->y1); @@ -4065,30 +4073,30 @@ static int ui_do_but_CHARTAB(bContext *UNUSED(C), uiBlock *UNUSED(block), uiBut che = cs + (y*12) + x; - if(che > G.charmax) + if (che > G.charmax) che = 0; - if(G.obedit) { + if (G.obedit) { do_textedit(0,0,che); } button_activate_state(C, but, BUTTON_STATE_EXIT); return WM_UI_HANDLER_BREAK; } - else if(ELEM(event->type, WHEELUPMOUSE, PAGEUPKEY)) { - for(but= block->buttons.first; but; but= but->next) { - if(but->type == CHARTAB) { + else if (ELEM(event->type, WHEELUPMOUSE, PAGEUPKEY)) { + for (but= block->buttons.first; but; but= but->next) { + if (but->type == CHARTAB) { G.charstart = G.charstart - (12*6); - if(G.charstart < 0) + if (G.charstart < 0) G.charstart = 0; - if(G.charstart < G.charmin) + if (G.charstart < G.charmin) G.charstart = G.charmin; ui_draw_but(but); //Really nasty... to update the num button from the same butblock - for(bt= block->buttons.first; bt; bt= bt->next) + for (bt= block->buttons.first; bt; bt= bt->next) { - if(ELEM(bt->type, NUM, NUMABS)) { + if (ELEM(bt->type, NUM, NUMABS)) { ui_check_but(bt); ui_draw_but(bt); } @@ -4100,19 +4108,19 @@ static int ui_do_but_CHARTAB(bContext *UNUSED(C), uiBlock *UNUSED(block), uiBut return WM_UI_HANDLER_BREAK; } - else if(ELEM(event->type, WHEELDOWNMOUSE, PAGEDOWNKEY)) { - for(but= block->buttons.first; but; but= but->next) { - if(but->type == CHARTAB) { + else if (ELEM(event->type, WHEELDOWNMOUSE, PAGEDOWNKEY)) { + for (but= block->buttons.first; but; but= but->next) { + if (but->type == CHARTAB) { G.charstart = G.charstart + (12*6); - if(G.charstart > (0xffff - 12*6)) + if (G.charstart > (0xffff - 12*6)) G.charstart = 0xffff - (12*6); - if(G.charstart > G.charmax - 12*6) + if (G.charstart > G.charmax - 12*6) G.charstart = G.charmax - 12*6; ui_draw_but(but); - for(bt= block->buttons.first; bt; bt= bt->next) + for (bt= block->buttons.first; bt; bt= bt->next) { - if(ELEM(bt->type, NUM, NUMABS)) { + if (ELEM(bt->type, NUM, NUMABS)) { ui_check_but(bt); ui_draw_but(bt); } @@ -4138,20 +4146,20 @@ static int ui_do_but_LINK(bContext *C, uiBut *but, uiHandleButtonData *data, wmE { VECCOPY2D(but->linkto, event->mval); - if(data->state == BUTTON_STATE_HIGHLIGHT) { - if(event->type == LEFTMOUSE && event->val==KM_PRESS) { + if (data->state == BUTTON_STATE_HIGHLIGHT) { + if (event->type == LEFTMOUSE && event->val==KM_PRESS) { button_activate_state(C, but, BUTTON_STATE_WAIT_RELEASE); return WM_UI_HANDLER_BREAK; } - else if(event->type == LEFTMOUSE && but->block->handle) { + else if (event->type == LEFTMOUSE && but->block->handle) { button_activate_state(C, but, BUTTON_STATE_EXIT); return WM_UI_HANDLER_BREAK; } } - else if(data->state == BUTTON_STATE_WAIT_RELEASE) { + else if (data->state == BUTTON_STATE_WAIT_RELEASE) { - if(event->type == LEFTMOUSE && event->val!=KM_PRESS) { - if(!(but->flag & UI_SELECT)) + if (event->type == LEFTMOUSE && event->val!=KM_PRESS) { + if (!(but->flag & UI_SELECT)) data->cancel= 1; button_activate_state(C, but, BUTTON_STATE_EXIT); return WM_UI_HANDLER_BREAK; @@ -4170,7 +4178,7 @@ static int ui_numedit_but_TRACKPREVIEW(bContext *C, uiBut *but, uiHandleButtonDa dx = mx - data->draglastx; dy = my - data->draglasty; - if(shift) { + if (shift) { dx /= 5.0f; dy /= 5.0f; } @@ -4178,9 +4186,10 @@ static int ui_numedit_but_TRACKPREVIEW(bContext *C, uiBut *but, uiHandleButtonDa if (in_scope_resize_zone(but, data->dragstartx, data->dragstarty)) { /* resize preview widget itself */ scopes->track_preview_height = (but->y2 - but->y1) + (data->dragstarty - my); - } else { - if(scopes->marker) { - if(scopes->marker->framenr!=scopes->framenr) + } + else { + if (scopes->marker) { + if (scopes->marker->framenr!=scopes->framenr) scopes->marker= BKE_tracking_ensure_marker(scopes->track, scopes->framenr); scopes->marker->flag&= ~(MARKER_DISABLED|MARKER_TRACKED); @@ -4207,8 +4216,8 @@ static int ui_do_but_TRACKPREVIEW(bContext *C, uiBlock *block, uiBut *but, uiHan my= event->y; ui_window_to_block(data->region, block, &mx, &my); - if(data->state == BUTTON_STATE_HIGHLIGHT) { - if(event->type==LEFTMOUSE && event->val==KM_PRESS) { + if (data->state == BUTTON_STATE_HIGHLIGHT) { + if (event->type==LEFTMOUSE && event->val==KM_PRESS) { data->dragstartx= mx; data->dragstarty= my; data->draglastx= mx; @@ -4216,25 +4225,25 @@ static int ui_do_but_TRACKPREVIEW(bContext *C, uiBlock *block, uiBut *but, uiHan button_activate_state(C, but, BUTTON_STATE_NUM_EDITING); /* also do drag the first time */ - if(ui_numedit_but_TRACKPREVIEW(C, but, data, mx, my, event->shift)) + if (ui_numedit_but_TRACKPREVIEW(C, but, data, mx, my, event->shift)) ui_numedit_apply(C, block, but, data); return WM_UI_HANDLER_BREAK; } } - else if(data->state == BUTTON_STATE_NUM_EDITING) { - if(event->type == ESCKEY) { + else if (data->state == BUTTON_STATE_NUM_EDITING) { + if (event->type == ESCKEY) { data->cancel= 1; data->escapecancel= 1; button_activate_state(C, but, BUTTON_STATE_EXIT); } - else if(event->type == MOUSEMOVE) { - if(mx!=data->draglastx || my!=data->draglasty) { - if(ui_numedit_but_TRACKPREVIEW(C, but, data, mx, my, event->shift)) + else if (event->type == MOUSEMOVE) { + if (mx!=data->draglastx || my!=data->draglasty) { + if (ui_numedit_but_TRACKPREVIEW(C, but, data, mx, my, event->shift)) ui_numedit_apply(C, block, but, data); } } - else if(event->type==LEFTMOUSE && event->val!=KM_PRESS) { + else if (event->type==LEFTMOUSE && event->val!=KM_PRESS) { button_activate_state(C, but, BUTTON_STATE_EXIT); } return WM_UI_HANDLER_BREAK; @@ -4253,7 +4262,7 @@ static void but_shortcut_name_func(bContext *C, void *arg1, int UNUSED(event)) IDProperty *prop= (but->opptr)? but->opptr->data: NULL; /* complex code to change name of button */ - if(WM_key_event_operator_string(C, but->optype->idname, but->opcontext, prop, TRUE, + if (WM_key_event_operator_string(C, but->optype->idname, but->opcontext, prop, TRUE, shortcut_str, sizeof(shortcut_str))) { ui_but_add_shortcut(but, shortcut_str, TRUE); @@ -4316,7 +4325,7 @@ static uiBlock *menu_add_shortcut(bContext *C, ARegion *ar, void *arg) kmi_id = kmi->id; /* copy properties, prop can be NULL for reset */ - if(prop) + if (prop) prop= IDP_CopyProperty(prop); WM_keymap_properties_reset(kmi, prop); @@ -4379,12 +4388,12 @@ static int ui_but_menu(bContext *C, uiBut *but) int length; const char *name; - if((but->rnapoin.data && but->rnaprop)==0 && but->optype==NULL) + if ((but->rnapoin.data && but->rnaprop)==0 && but->optype==NULL) return 0; button_timers_tooltip_remove(C, but); - if(but->rnaprop) + if (but->rnaprop) name= RNA_property_ui_name(but->rnaprop); else if (but->optype) name= but->optype->name; @@ -4396,19 +4405,19 @@ static int ui_but_menu(bContext *C, uiBut *but) uiLayoutSetOperatorContext(layout, WM_OP_INVOKE_DEFAULT); - if(but->rnapoin.data && but->rnaprop) { + if (but->rnapoin.data && but->rnaprop) { short is_anim= RNA_property_animateable(&but->rnapoin, but->rnaprop); /* second slower test, saved people finding keyframe items in menus when its not possible */ - if(is_anim) + if (is_anim) is_anim= RNA_property_path_from_ID_check(&but->rnapoin, but->rnaprop); length= RNA_property_array_length(&but->rnapoin, but->rnaprop); /* Keyframes */ - if(but->flag & UI_BUT_ANIMATED_KEY) { + if (but->flag & UI_BUT_ANIMATED_KEY) { /* replace/delete keyfraemes */ - if(length) { + if (length) { uiItemBooleanO(layout, "Replace Keyframes", ICON_NONE, "ANIM_OT_keyframe_insert_button", "all", 1); uiItemBooleanO(layout, "Replace Single Keyframe", ICON_NONE, "ANIM_OT_keyframe_insert_button", "all", 0); uiItemBooleanO(layout, "Delete Keyframes", ICON_NONE, "ANIM_OT_keyframe_delete_button", "all", 1); @@ -4424,9 +4433,9 @@ static int ui_but_menu(bContext *C, uiBut *but) } - else if(but->flag & UI_BUT_DRIVEN); - else if(is_anim) { - if(length) { + else if (but->flag & UI_BUT_DRIVEN); + else if (is_anim) { + if (length) { uiItemBooleanO(layout, "Insert Keyframes", ICON_NONE, "ANIM_OT_keyframe_insert_button", "all", 1); uiItemBooleanO(layout, "Insert Single Keyframe", ICON_NONE, "ANIM_OT_keyframe_insert_button", "all", 0); } @@ -4435,10 +4444,10 @@ static int ui_but_menu(bContext *C, uiBut *but) } /* Drivers */ - if(but->flag & UI_BUT_DRIVEN) { + if (but->flag & UI_BUT_DRIVEN) { uiItemS(layout); - if(length) { + if (length) { uiItemBooleanO(layout, "Delete Drivers", ICON_NONE, "ANIM_OT_driver_button_remove", "all", 1); uiItemBooleanO(layout, "Delete Single Driver", ICON_NONE, "ANIM_OT_driver_button_remove", "all", 0); } @@ -4449,11 +4458,11 @@ static int ui_but_menu(bContext *C, uiBut *but) if (ANIM_driver_can_paste()) uiItemO(layout, "Paste Driver", ICON_NONE, "ANIM_OT_paste_driver_button"); } - else if(but->flag & (UI_BUT_ANIMATED_KEY|UI_BUT_ANIMATED)); - else if(is_anim) { + else if (but->flag & (UI_BUT_ANIMATED_KEY|UI_BUT_ANIMATED)); + else if (is_anim) { uiItemS(layout); - if(length) { + if (length) { uiItemBooleanO(layout, "Add Drivers", ICON_NONE, "ANIM_OT_driver_button_add", "all", 1); uiItemBooleanO(layout, "Add Single Driver", ICON_NONE, "ANIM_OT_driver_button_add", "all", 0); } @@ -4466,10 +4475,10 @@ static int ui_but_menu(bContext *C, uiBut *but) /* Keying Sets */ // TODO: check on modifyability of Keying Set when doing this - if(is_anim) { + if (is_anim) { uiItemS(layout); - if(length) { + if (length) { uiItemBooleanO(layout, "Add All to Keying Set", ICON_NONE, "ANIM_OT_keyingset_button_add", "all", 1); uiItemBooleanO(layout, "Add Single to Keying Set", ICON_NONE, "ANIM_OT_keyingset_button_add", "all", 0); uiItemO(layout, "Remove from Keying Set", ICON_NONE, "ANIM_OT_keyingset_button_remove"); @@ -4487,7 +4496,7 @@ static int ui_but_menu(bContext *C, uiBut *but) //Copy Property Value //Paste Property Value - if(length) { + if (length) { uiItemBooleanO(layout, "Reset All to Default Values", ICON_NONE, "UI_OT_reset_default_button", "all", 1); uiItemBooleanO(layout, "Reset Single to Default Value", ICON_NONE, "UI_OT_reset_default_button", "all", 0); } @@ -4501,7 +4510,7 @@ static int ui_but_menu(bContext *C, uiBut *but) } /* Operator buttons */ - if(but->optype) { + if (but->optype) { uiBlock *block = uiLayoutGetBlock(layout); uiBut *but2; IDProperty *prop= (but->opptr)? but->opptr->data: NULL; @@ -4539,7 +4548,7 @@ static int ui_but_menu(bContext *C, uiBut *but) char buf[512]; PointerRNA ptr_props; - if(but->rnapoin.data && but->rnaprop) { + if (but->rnapoin.data && but->rnaprop) { BLI_snprintf(buf, sizeof(buf), "%s.%s", RNA_struct_identifier(but->rnapoin.type), RNA_property_identifier(but->rnaprop)); WM_operator_properties_create(&ptr_props, "WM_OT_doc_view"); @@ -4588,27 +4597,27 @@ static int ui_do_button(bContext *C, uiBlock *block, uiBut *but, wmEvent *event) data= but->active; retval= WM_UI_HANDLER_CONTINUE; - if(but->flag & UI_BUT_DISABLED) + if (but->flag & UI_BUT_DISABLED) return WM_UI_HANDLER_CONTINUE; - if( (data->state == BUTTON_STATE_HIGHLIGHT) && + if ( (data->state == BUTTON_STATE_HIGHLIGHT) && /* check prevval because of modal operators [#24016], * modifier check is to allow Ctrl+C for copy. * if this causes other problems, remove this check and suffer the bug :) - campbell */ ((event->prevval != KM_PRESS) || (ISKEYMODIFIER(event->prevtype)) || (event->type == EVT_DROP)) ) { /* handle copy-paste */ - if(ELEM(event->type, CKEY, VKEY) && event->val==KM_PRESS && (event->ctrl || event->oskey)) { + if (ELEM(event->type, CKEY, VKEY) && event->val==KM_PRESS && (event->ctrl || event->oskey)) { ui_but_copy_paste(C, but, data, (event->type == CKEY)? 'c': 'v'); return WM_UI_HANDLER_BREAK; } /* handle drop */ - else if(event->type == EVT_DROP) { + else if (event->type == EVT_DROP) { ui_but_drop (C, event, but, data); } /* handle keyframing */ - else if(event->type == IKEY && !ELEM3(KM_MOD_FIRST, event->ctrl, event->oskey, event->shift) && event->val == KM_PRESS) { - if(event->alt) + else if (event->type == IKEY && !ELEM3(KM_MOD_FIRST, event->ctrl, event->oskey, event->shift) && event->val == KM_PRESS) { + if (event->alt) ui_but_anim_delete_keyframe(C); else ui_but_anim_insert_keyframe(C); @@ -4618,8 +4627,8 @@ static int ui_do_button(bContext *C, uiBlock *block, uiBut *but, wmEvent *event) return WM_UI_HANDLER_BREAK; } /* handle drivers */ - else if(event->type == DKEY && !ELEM3(KM_MOD_FIRST, event->ctrl, event->oskey, event->shift) && event->val == KM_PRESS) { - if(event->alt) + else if (event->type == DKEY && !ELEM3(KM_MOD_FIRST, event->ctrl, event->oskey, event->shift) && event->val == KM_PRESS) { + if (event->alt) ui_but_anim_remove_driver(C); else ui_but_anim_add_driver(C); @@ -4629,8 +4638,8 @@ static int ui_do_button(bContext *C, uiBlock *block, uiBut *but, wmEvent *event) return WM_UI_HANDLER_BREAK; } /* handle keyingsets */ - else if(event->type == KKEY && !ELEM3(KM_MOD_FIRST, event->ctrl, event->oskey, event->shift) && event->val == KM_PRESS) { - if(event->alt) + else if (event->type == KKEY && !ELEM3(KM_MOD_FIRST, event->ctrl, event->oskey, event->shift) && event->val == KM_PRESS) { + if (event->alt) ui_but_anim_remove_keyingset(C); else ui_but_anim_add_keyingset(C); @@ -4641,13 +4650,13 @@ static int ui_do_button(bContext *C, uiBlock *block, uiBut *but, wmEvent *event) } /* reset to default */ /* XXX hardcoded keymap check.... */ - else if(event->type == BACKSPACEKEY && event->val == KM_PRESS) { + else if (event->type == BACKSPACEKEY && event->val == KM_PRESS) { /* ctrl+backspace = reset active button; backspace = reset a whole array*/ if (!(ELEM3(but->type, HSVCIRCLE, HSVCUBE, HISTOGRAM))) ui_set_but_default(C, !event->ctrl); } /* handle menu */ - else if(event->type == RIGHTMOUSE && event->val == KM_PRESS) { + else if (event->type == RIGHTMOUSE && event->val == KM_PRESS) { /* RMB has two options now */ if (ui_but_menu(C, but)) { return WM_UI_HANDLER_BREAK; @@ -4656,16 +4665,16 @@ static int ui_do_button(bContext *C, uiBlock *block, uiBut *but, wmEvent *event) } /* verify if we can edit this button */ - if(ELEM(event->type, LEFTMOUSE, RETKEY)) { + if (ELEM(event->type, LEFTMOUSE, RETKEY)) { /* this should become disabled button .. */ - if(but->lock) { - if(but->lockstr) { + if (but->lock) { + if (but->lockstr) { BKE_report(NULL, RPT_WARNING, but->lockstr); button_activate_state(C, but, BUTTON_STATE_EXIT); return WM_UI_HANDLER_BREAK; } } - else if(but->pointype && but->poin==NULL) { + else if (but->pointype && but->poin==NULL) { /* there's a pointer needed */ BKE_reportf(NULL, RPT_WARNING, "DoButton pointer error: %s", but->str); button_activate_state(C, but, BUTTON_STATE_EXIT); @@ -4741,7 +4750,7 @@ static int ui_do_button(bContext *C, uiBlock *block, uiBut *but, wmEvent *event) retval= ui_do_but_BUT(C, but, data, event); break; case COL: - if(but->a1 == UI_GRAD_V_ALT) // signal to prevent calling up color picker + if (but->a1 == UI_GRAD_V_ALT) // signal to prevent calling up color picker retval= ui_do_but_EXIT(C, but, data, event); else retval= ui_do_but_BLOCK(C, but, data, event); @@ -4791,9 +4800,9 @@ static uiBut *ui_but_find_activated(ARegion *ar) uiBlock *block; uiBut *but; - for(block=ar->uiblocks.first; block; block=block->next) - for(but=block->buttons.first; but; but= but->next) - if(but->active) + for (block=ar->uiblocks.first; block; block=block->next) + for (but=block->buttons.first; but; but= but->next) + if (but->active) return but; return NULL; @@ -4809,15 +4818,15 @@ void uiFreeActiveButtons(const bContext *C, bScreen *screen) { ScrArea *sa= screen->areabase.first; - for(;sa; sa= sa->next) { + for (;sa; sa= sa->next) { ARegion *ar= sa->regionbase.first; - for(;ar; ar= ar->next) { + for (;ar; ar= ar->next) { uiBut *but= ui_but_find_activated(ar); - if(but) { + if (but) { uiHandleButtonData *data= but->active; - if(data->menu==NULL && data->searchbox==NULL) - if(data->state == BUTTON_STATE_HIGHLIGHT) + if (data->menu==NULL && data->searchbox==NULL) + if (data->state == BUTTON_STATE_HIGHLIGHT) ui_button_active_free(C, but); } } @@ -4833,8 +4842,8 @@ int UI_but_active_drop_name(bContext *C) ARegion *ar= CTX_wm_region(C); uiBut *but= ui_but_find_activated(ar); - if(but) { - if(ELEM3(but->type, TEX, IDPOIN, SEARCH_MENU)) + if (but) { + if (ELEM3(but->type, TEX, IDPOIN, SEARCH_MENU)) return 1; } @@ -4845,12 +4854,12 @@ static void ui_blocks_set_tooltips(ARegion *ar, int enable) { uiBlock *block; - if(!ar) + if (!ar) return; /* we disabled buttons when when they were already shown, and * re-enable them on mouse move */ - for(block=ar->uiblocks.first; block; block=block->next) + for (block=ar->uiblocks.first; block; block=block->next) block->tooltipdisabled= !enable; } @@ -4859,8 +4868,8 @@ static int ui_mouse_inside_region(ARegion *ar, int x, int y) uiBlock *block; /* check if the mouse is in the region */ - if(!BLI_in_rcti(&ar->winrct, x, y)) { - for(block=ar->uiblocks.first; block; block=block->next) + if (!BLI_in_rcti(&ar->winrct, x, y)) { + for (block=ar->uiblocks.first; block; block=block->next) block->auto_open= FALSE; return 0; @@ -4871,7 +4880,7 @@ static int ui_mouse_inside_region(ARegion *ar, int x, int y) * even when they are not visible, so we need to make a copy of the mask to * use to check */ - if(ar->v2d.mask.xmin!=ar->v2d.mask.xmax) { + if (ar->v2d.mask.xmin!=ar->v2d.mask.xmax) { View2D *v2d= &ar->v2d; rcti mask_rct; int mx, my; @@ -4901,7 +4910,7 @@ static int ui_mouse_inside_region(ARegion *ar, int x, int y) } /* check if in the rect */ - if(!BLI_in_rcti(&mask_rct, mx, my)) + if (!BLI_in_rcti(&mask_rct, mx, my)) return 0; } @@ -4910,12 +4919,12 @@ static int ui_mouse_inside_region(ARegion *ar, int x, int y) static int ui_mouse_inside_button(ARegion *ar, uiBut *but, int x, int y) { - if(!ui_mouse_inside_region(ar, x, y)) + if (!ui_mouse_inside_region(ar, x, y)) return 0; ui_window_to_block(ar, but->block, &x, &y); - if(!ui_but_contains_pt(but, x, y)) + if (!ui_but_contains_pt(but, x, y)) return 0; return 1; @@ -4927,34 +4936,34 @@ static uiBut *ui_but_find_mouse_over(ARegion *ar, int x, int y) uiBut *but, *butover= NULL; int mx, my; -// if(!win->active) +// if (!win->active) // return NULL; - if(!ui_mouse_inside_region(ar, x, y)) + if (!ui_mouse_inside_region(ar, x, y)) return NULL; - for(block=ar->uiblocks.first; block; block=block->next) { + for (block=ar->uiblocks.first; block; block=block->next) { mx= x; my= y; ui_window_to_block(ar, block, &mx, &my); - for(but=block->buttons.first; but; but= but->next) { + for (but=block->buttons.first; but; but= but->next) { /* note, LABEL is included for hilights, this allows drags */ - if(but->type==LABEL && but->dragpoin==NULL) + if (but->type==LABEL && but->dragpoin==NULL) continue; - if(ELEM3(but->type, ROUNDBOX, SEPR, LISTBOX)) + if (ELEM3(but->type, ROUNDBOX, SEPR, LISTBOX)) continue; - if(but->flag & UI_HIDDEN) + if (but->flag & UI_HIDDEN) continue; - if(but->flag & UI_SCROLLED) + if (but->flag & UI_SCROLLED) continue; - if(ui_but_contains_pt(but, mx, my)) + if (ui_but_contains_pt(but, mx, my)) butover= but; } /* CLIP_EVENTS prevents the event from reaching other blocks */ if (block->flag & UI_BLOCK_CLIP_EVENTS) { /* check if mouse is inside block */ - if(block->minx <= mx && block->maxx >= mx && + if (block->minx <= mx && block->maxx >= mx && block->miny <= my && block->maxy >= my) break; } @@ -4969,18 +4978,18 @@ static uiBut *ui_list_find_mouse_over(ARegion *ar, int x, int y) uiBut *but; int mx, my; -// if(!win->active) +// if (!win->active) // return NULL; - if(!ui_mouse_inside_region(ar, x, y)) + if (!ui_mouse_inside_region(ar, x, y)) return NULL; - for(block=ar->uiblocks.first; block; block=block->next) { + for (block=ar->uiblocks.first; block; block=block->next) { mx= x; my= y; ui_window_to_block(ar, block, &mx, &my); - for(but=block->buttons.last; but; but= but->prev) - if(but->type == LISTBOX && ui_but_contains_pt(but, mx, my)) + for (but=block->buttons.last; but; but= but->prev) + if (but->type == LISTBOX && ui_but_contains_pt(but, mx, my)) return but; } @@ -5001,18 +5010,18 @@ static void button_timers_tooltip_remove(bContext *C, uiBut *but) uiHandleButtonData *data; data= but->active; - if(data) { + if (data) { - if(data->tooltiptimer) { + if (data->tooltiptimer) { WM_event_remove_timer(data->wm, data->window, data->tooltiptimer); data->tooltiptimer= NULL; } - if(data->tooltip) { + if (data->tooltip) { ui_tooltip_free(C, data->tooltip); data->tooltip= NULL; } - if(data->autoopentimer) { + if (data->autoopentimer) { WM_event_remove_timer(data->wm, data->window, data->autoopentimer); data->autoopentimer= NULL; } @@ -5026,14 +5035,14 @@ static void button_tooltip_timer_reset(bContext *C, uiBut *but) data= but->active; - if(data->tooltiptimer) { + if (data->tooltiptimer) { WM_event_remove_timer(data->wm, data->window, data->tooltiptimer); data->tooltiptimer= NULL; } - if(U.flag & USER_TOOLTIPS) - if(!but->block->tooltipdisabled) - if(!wm->drags.first) + if (U.flag & USER_TOOLTIPS) + if (!but->block->tooltipdisabled) + if (!wm->drags.first) data->tooltiptimer= WM_event_add_timer(data->wm, data->window, TIMER, BUTTON_TOOLTIP_DELAY); } @@ -5042,26 +5051,26 @@ static void button_activate_state(bContext *C, uiBut *but, uiHandleButtonState s uiHandleButtonData *data; data= but->active; - if(data->state == state) + if (data->state == state) return; /* highlight has timers for tooltips and auto open */ - if(state == BUTTON_STATE_HIGHLIGHT) { + if (state == BUTTON_STATE_HIGHLIGHT) { but->flag &= ~UI_SELECT; button_tooltip_timer_reset(C, but); /* automatic open pulldown block timer */ - if(ELEM3(but->type, BLOCK, PULLDOWN, ICONTEXTROW)) { - if(data->used_mouse && !data->autoopentimer) { + if (ELEM3(but->type, BLOCK, PULLDOWN, ICONTEXTROW)) { + if (data->used_mouse && !data->autoopentimer) { int time; - if(but->block->auto_open==TRUE) time= 1; // test for toolbox - else if((but->block->flag & UI_BLOCK_LOOP && but->type != BLOCK) || but->block->auto_open==TRUE) time= 5*U.menuthreshold2; - else if(U.uiflag & USER_MENUOPENAUTO) time= 5*U.menuthreshold1; + if (but->block->auto_open==TRUE) time= 1; // test for toolbox + else if ((but->block->flag & UI_BLOCK_LOOP && but->type != BLOCK) || but->block->auto_open==TRUE) time= 5*U.menuthreshold2; + else if (U.uiflag & USER_MENUOPENAUTO) time= 5*U.menuthreshold1; else time= -1; - if(time >= 0) + if (time >= 0) data->autoopentimer= WM_event_add_timer(data->wm, data->window, TIMER, 0.02*(double)time); } } @@ -5072,65 +5081,66 @@ static void button_activate_state(bContext *C, uiBut *but, uiHandleButtonState s } /* text editing */ - if(state == BUTTON_STATE_TEXT_EDITING && data->state != BUTTON_STATE_TEXT_SELECTING) + if (state == BUTTON_STATE_TEXT_EDITING && data->state != BUTTON_STATE_TEXT_SELECTING) ui_textedit_begin(C, but, data); - else if(data->state == BUTTON_STATE_TEXT_EDITING && state != BUTTON_STATE_TEXT_SELECTING) + else if (data->state == BUTTON_STATE_TEXT_EDITING && state != BUTTON_STATE_TEXT_SELECTING) ui_textedit_end(C, but, data); - else if(data->state == BUTTON_STATE_TEXT_SELECTING && state != BUTTON_STATE_TEXT_EDITING) + else if (data->state == BUTTON_STATE_TEXT_SELECTING && state != BUTTON_STATE_TEXT_EDITING) ui_textedit_end(C, but, data); /* number editing */ - if(state == BUTTON_STATE_NUM_EDITING) { - if(ui_is_a_warp_but(but)) + if (state == BUTTON_STATE_NUM_EDITING) { + if (ui_is_a_warp_but(but)) WM_cursor_grab(CTX_wm_window(C), TRUE, TRUE, NULL); ui_numedit_begin(but, data); - } else if(data->state == BUTTON_STATE_NUM_EDITING) { + } + else if (data->state == BUTTON_STATE_NUM_EDITING) { ui_numedit_end(but, data); - if(ui_is_a_warp_but(but)) + if (ui_is_a_warp_but(but)) WM_cursor_ungrab(CTX_wm_window(C)); } /* menu open */ - if(state == BUTTON_STATE_MENU_OPEN) + if (state == BUTTON_STATE_MENU_OPEN) ui_blockopen_begin(C, but, data); - else if(data->state == BUTTON_STATE_MENU_OPEN) + else if (data->state == BUTTON_STATE_MENU_OPEN) ui_blockopen_end(C, but, data); /* add a short delay before exiting, to ensure there is some feedback */ - if(state == BUTTON_STATE_WAIT_FLASH) { + if (state == BUTTON_STATE_WAIT_FLASH) { data->flashtimer= WM_event_add_timer(data->wm, data->window, TIMER, BUTTON_FLASH_DELAY); } - else if(data->flashtimer) { + else if (data->flashtimer) { WM_event_remove_timer(data->wm, data->window, data->flashtimer); data->flashtimer= NULL; } /* add a blocking ui handler at the window handler for blocking, modal states * but not for popups, because we already have a window level handler*/ - if(!(but->block->handle && but->block->handle->popup)) { - if(button_modal_state(state)) { - if(!button_modal_state(data->state)) + if (!(but->block->handle && but->block->handle->popup)) { + if (button_modal_state(state)) { + if (!button_modal_state(data->state)) WM_event_add_ui_handler(C, &data->window->modalhandlers, ui_handler_region_menu, NULL, data); } else { - if(button_modal_state(data->state)) + if (button_modal_state(data->state)) WM_event_remove_ui_handler(&data->window->modalhandlers, ui_handler_region_menu, NULL, data, 1); /* 1 = postpone free */ } } /* wait for mousemove to enable drag */ - if(state == BUTTON_STATE_WAIT_DRAG) { + if (state == BUTTON_STATE_WAIT_DRAG) { but->flag &= ~UI_SELECT; } data->state= state; - if(state != BUTTON_STATE_EXIT) { + if (state != BUTTON_STATE_EXIT) { /* When objects for eg. are removed, running ui_check_but() can access * the removed data - so disable update on exit. Also in case of * highlight when not in a popup menu, we remove because data used in * button below popup might have been removed by action of popup. Needs * a more reliable solution... */ - if(state != BUTTON_STATE_HIGHLIGHT || (but->block->flag & UI_BLOCK_LOOP)) + if (state != BUTTON_STATE_HIGHLIGHT || (but->block->flag & UI_BLOCK_LOOP)) ui_check_but(but); } @@ -5147,7 +5157,7 @@ static void button_activate_init(bContext *C, ARegion *ar, uiBut *but, uiButtonA data->wm= CTX_wm_manager(C); data->window= CTX_wm_window(C); data->region= ar; - if( ELEM(but->type, BUT_CURVE, SEARCH_MENU) ); // XXX curve is temp + if ( ELEM(but->type, BUT_CURVE, SEARCH_MENU) ); // XXX curve is temp else data->interactive= 1; data->state = BUTTON_STATE_INIT; @@ -5159,42 +5169,42 @@ static void button_activate_init(bContext *C, ARegion *ar, uiBut *but, uiButtonA /* we disable auto_open in the block after a threshold, because we still * want to allow auto opening adjacent menus even if no button is activated * in between going over to the other button, but only for a short while */ - if(type == BUTTON_ACTIVATE_OVER && but->block->auto_open==TRUE) - if(but->block->auto_open_last+BUTTON_AUTO_OPEN_THRESH < PIL_check_seconds_timer()) + if (type == BUTTON_ACTIVATE_OVER && but->block->auto_open==TRUE) + if (but->block->auto_open_last+BUTTON_AUTO_OPEN_THRESH < PIL_check_seconds_timer()) but->block->auto_open= FALSE; - if(type == BUTTON_ACTIVATE_OVER) { + if (type == BUTTON_ACTIVATE_OVER) { data->used_mouse= 1; } button_activate_state(C, but, BUTTON_STATE_HIGHLIGHT); /* activate right away */ - if(but->flag & UI_BUT_IMMEDIATE) { - if(but->type==HOTKEYEVT) + if (but->flag & UI_BUT_IMMEDIATE) { + if (but->type==HOTKEYEVT) button_activate_state(C, but, BUTTON_STATE_WAIT_KEY_EVENT); /* .. more to be added here */ } - if(type == BUTTON_ACTIVATE_OPEN) { + if (type == BUTTON_ACTIVATE_OPEN) { button_activate_state(C, but, BUTTON_STATE_MENU_OPEN); /* activate first button in submenu */ - if(data->menu && data->menu->region) { + if (data->menu && data->menu->region) { ARegion *subar= data->menu->region; uiBlock *subblock= subar->uiblocks.first; uiBut *subbut; - if(subblock) { + if (subblock) { subbut= ui_but_first(subblock); - if(subbut) + if (subbut) ui_handle_button_activate(C, subar, subbut, BUTTON_ACTIVATE); } } } - else if(type == BUTTON_ACTIVATE_TEXT_EDITING) + else if (type == BUTTON_ACTIVATE_TEXT_EDITING) button_activate_state(C, but, BUTTON_STATE_TEXT_EDITING); - else if(type == BUTTON_ACTIVATE_APPLY) + else if (type == BUTTON_ACTIVATE_APPLY) button_activate_state(C, but, BUTTON_STATE_WAIT_FLASH); } @@ -5204,18 +5214,18 @@ static void button_activate_exit(bContext *C, uiHandleButtonData *data, uiBut *b uiBut *bt; /* ensure we are in the exit state */ - if(data->state != BUTTON_STATE_EXIT) + if (data->state != BUTTON_STATE_EXIT) button_activate_state(C, but, BUTTON_STATE_EXIT); /* apply the button action or value */ - if(!onfree) + if (!onfree) ui_apply_button(C, block, but, data, 0); /* if this button is in a menu, this will set the button return * value to the button value and the menu return value to ok, the * menu return value will be picked up and the menu will close */ - if(block->handle && !(block->flag & UI_BLOCK_KEEP_OPEN)) { - if(!data->cancel || data->escapecancel) { + if (block->handle && !(block->flag & UI_BLOCK_KEEP_OPEN)) { + if (!data->cancel || data->escapecancel) { uiPopupBlockHandle *menu; menu= block->handle; @@ -5224,18 +5234,18 @@ static void button_activate_exit(bContext *C, uiHandleButtonData *data, uiBut *b } } - if(!onfree && !data->cancel) { + if (!onfree && !data->cancel) { /* autokey & undo push */ ui_apply_autokey_undo(C, but); /* popup menu memory */ - if(block->flag & UI_BLOCK_POPUP_MEMORY) + if (block->flag & UI_BLOCK_POPUP_MEMORY) ui_popup_menu_memory(block, but); } /* disable tooltips until mousemove + last active flag */ - for(block=data->region->uiblocks.first; block; block=block->next) { - for(bt=block->buttons.first; bt; bt=bt->next) + for (block=data->region->uiblocks.first; block; block=block->next) { + for (bt=block->buttons.first; bt; bt=bt->next) bt->flag &= ~UI_BUT_LAST_ACTIVE; block->tooltipdisabled= 1; @@ -5244,9 +5254,9 @@ static void button_activate_exit(bContext *C, uiHandleButtonData *data, uiBut *b ui_blocks_set_tooltips(data->region, 0); /* clean up */ - if(data->str) + if (data->str) MEM_freeN(data->str); - if(data->origstr) + if (data->origstr) MEM_freeN(data->origstr); /* redraw (data is but->active!) */ @@ -5257,13 +5267,13 @@ static void button_activate_exit(bContext *C, uiHandleButtonData *data, uiBut *b but->active= NULL; but->flag &= ~(UI_ACTIVE|UI_SELECT); but->flag |= UI_BUT_LAST_ACTIVE; - if(!onfree) + if (!onfree) ui_check_but(but); /* adds empty mousemove in queue for re-init handler, in case mouse is * still over a button. we cannot just check for this ourselfs because * at this point the mouse may be over a button in another region */ - if(mousemove) + if (mousemove) WM_event_add_mousemove(C); } @@ -5274,7 +5284,7 @@ void ui_button_active_free(const bContext *C, uiBut *but) /* this gets called when the button somehow disappears while it is still * active, this is bad for user interaction, but we need to handle this * case cleanly anyway in case it happens */ - if(but->active) { + if (but->active) { data= but->active; data->cancel= 1; button_activate_exit((bContext*)C, data, but, 0, 1); @@ -5288,27 +5298,27 @@ static uiBut *ui_context_button_active(const bContext *C, int (*but_check_cb)(ui ARegion *ar= CTX_wm_region(C); - while(ar) { + while (ar) { uiBlock *block; uiBut *but, *activebut= NULL; /* find active button */ - for(block=ar->uiblocks.first; block; block=block->next) { - for(but=block->buttons.first; but; but= but->next) { - if(but->active) + for (block=ar->uiblocks.first; block; block=block->next) { + for (but=block->buttons.first; but; but= but->next) { + if (but->active) activebut= but; - else if(!activebut && (but->flag & UI_BUT_LAST_ACTIVE)) + else if (!activebut && (but->flag & UI_BUT_LAST_ACTIVE)) activebut= but; } } - if(activebut && (but_check_cb == NULL || but_check_cb(activebut))) { + if (activebut && (but_check_cb == NULL || but_check_cb(activebut))) { uiHandleButtonData *data= activebut->active; but_found= activebut; /* recurse into opened menu, like colorpicker case */ - if(data && data->menu && (ar != data->menu->region)) { + if (data && data->menu && (ar != data->menu->region)) { ar = data->menu->region; } else { @@ -5345,7 +5355,7 @@ void uiContextActiveProperty(const bContext *C, struct PointerRNA *ptr, struct P memset(ptr, 0, sizeof(*ptr)); - if(activebut && activebut->rnapoin.data) { + if (activebut && activebut->rnapoin.data) { *ptr= activebut->rnapoin; *prop= activebut->rnaprop; *index= activebut->rnaindex; @@ -5359,7 +5369,7 @@ void uiContextActiveProperty(const bContext *C, struct PointerRNA *ptr, struct P void uiContextActivePropertyHandle(bContext *C) { uiBut *activebut= ui_context_rna_button_active(C); - if(activebut) { + if (activebut) { /* TODO, look into a better way to handle the button change * currently this is mainly so reset defaults works for the * operator redo panel - campbell */ @@ -5381,7 +5391,7 @@ wmOperator *uiContextActiveOperator(const struct bContext *C) } /* scan active regions ui */ - for(block=ar_ctx->uiblocks.first; block; block=block->next) { + for (block=ar_ctx->uiblocks.first; block; block=block->next) { if (block->ui_operator) { return block->ui_operator; } @@ -5396,7 +5406,7 @@ wmOperator *uiContextActiveOperator(const struct bContext *C) if (ar == ar_ctx) { continue; } - for(block=ar->uiblocks.first; block; block=block->next) { + for (block=ar->uiblocks.first; block; block=block->next) { if (block->ui_operator) { return block->ui_operator; } @@ -5415,26 +5425,26 @@ void uiContextAnimUpdate(const bContext *C) uiBlock *block; uiBut *but, *activebut; - while(ar) { + while (ar) { /* find active button */ activebut= NULL; - for(block=ar->uiblocks.first; block; block=block->next) { - for(but=block->buttons.first; but; but= but->next) { + for (block=ar->uiblocks.first; block; block=block->next) { + for (but=block->buttons.first; but; but= but->next) { ui_but_anim_flag(but, (scene)? scene->r.cfra: 0.0f); ED_region_tag_redraw(ar); - if(but->active) + if (but->active) activebut= but; - else if(!activebut && (but->flag & UI_BUT_LAST_ACTIVE)) + else if (!activebut && (but->flag & UI_BUT_LAST_ACTIVE)) activebut= but; } } - if(activebut) { + if (activebut) { /* always recurse into opened menu, so all buttons update (like colorpicker) */ uiHandleButtonData *data= activebut->active; - if(data && data->menu) + if (data && data->menu) ar = data->menu->region; else return; @@ -5453,9 +5463,9 @@ static uiBut *uit_but_find_open_event(ARegion *ar, wmEvent *event) uiBlock *block; uiBut *but; - for(block=ar->uiblocks.first; block; block=block->next) { - for(but=block->buttons.first; but; but= but->next) - if(but==event->customdata) + for (block=ar->uiblocks.first; block; block=block->next) { + for (but=block->buttons.first; but; but= but->next) + if (but==event->customdata) return but; } return NULL; @@ -5465,14 +5475,14 @@ static int ui_handle_button_over(bContext *C, wmEvent *event, ARegion *ar) { uiBut *but; - if(event->type == MOUSEMOVE) { + if (event->type == MOUSEMOVE) { but= ui_but_find_mouse_over(ar, event->x, event->y); - if(but) + if (but) button_activate_init(C, ar, but, BUTTON_ACTIVATE_OVER); } - else if(event->type == EVT_BUT_OPEN) { + else if (event->type == EVT_BUT_OPEN) { but= uit_but_find_open_event(ar, event); - if(but) { + if (but) { button_activate_init(C, ar, but, BUTTON_ACTIVATE_OVER); ui_do_button(C, but->block, but, event); } @@ -5504,7 +5514,7 @@ static void ui_handle_button_activate(bContext *C, ARegion *ar, uiBut *but, uiBu uiHandleButtonData *data; oldbut= ui_but_find_activated(ar); - if(oldbut) { + if (oldbut) { data= oldbut->active; data->cancel= 1; button_activate_exit(C, data, oldbut, 0, 0); @@ -5530,7 +5540,7 @@ static int ui_handle_button_event(bContext *C, wmEvent *event, uiBut *but) retval= WM_UI_HANDLER_CONTINUE; - if(data->state == BUTTON_STATE_HIGHLIGHT) { + if (data->state == BUTTON_STATE_HIGHLIGHT) { switch(event->type) { case WINDEACTIVATE: case EVT_BUT_CANCEL: @@ -5540,15 +5550,15 @@ static int ui_handle_button_event(bContext *C, wmEvent *event, uiBut *but) break; case MOUSEMOVE: /* verify if we are still over the button, if not exit */ - if(!ui_mouse_inside_button(ar, but, event->x, event->y)) { + if (!ui_mouse_inside_button(ar, but, event->x, event->y)) { data->cancel= 1; button_activate_state(C, but, BUTTON_STATE_EXIT); } - else if(ui_but_find_mouse_over(ar, event->x, event->y) != but) { + else if (ui_but_find_mouse_over(ar, event->x, event->y) != but) { data->cancel= 1; button_activate_state(C, but, BUTTON_STATE_EXIT); } - else if(event->x!=event->prevx || event->y!=event->prevy) { + else if (event->x!=event->prevx || event->y!=event->prevy) { /* re-enable tooltip on mouse move */ ui_blocks_set_tooltips(ar, 1); button_tooltip_timer_reset(C, but); @@ -5557,19 +5567,19 @@ static int ui_handle_button_event(bContext *C, wmEvent *event, uiBut *but) break; case TIMER: { /* handle tooltip timer */ - if(event->customdata == data->tooltiptimer) { + if (event->customdata == data->tooltiptimer) { WM_event_remove_timer(data->wm, data->window, data->tooltiptimer); data->tooltiptimer= NULL; - if(!data->tooltip) + if (!data->tooltip) data->tooltip= ui_tooltip_create(C, data->region, but); } /* handle menu auto open timer */ - else if(event->customdata == data->autoopentimer) { + else if (event->customdata == data->autoopentimer) { WM_event_remove_timer(data->wm, data->window, data->autoopentimer); data->autoopentimer= NULL; - if(ui_mouse_inside_button(ar, but, event->x, event->y)) + if (ui_mouse_inside_button(ar, but, event->x, event->y)) button_activate_state(C, but, BUTTON_STATE_MENU_OPEN); } @@ -5579,7 +5589,7 @@ static int ui_handle_button_event(bContext *C, wmEvent *event, uiBut *but) case WHEELDOWNMOUSE: case MIDDLEMOUSE: /* XXX hardcoded keymap check... but anyway, while view changes, tooltips should be removed */ - if(data->tooltiptimer) { + if (data->tooltiptimer) { WM_event_remove_timer(data->wm, data->window, data->tooltiptimer); data->tooltiptimer= NULL; } @@ -5590,7 +5600,7 @@ static int ui_handle_button_event(bContext *C, wmEvent *event, uiBut *but) } } } - else if(data->state == BUTTON_STATE_WAIT_RELEASE) { + else if (data->state == BUTTON_STATE_WAIT_RELEASE) { switch(event->type) { case WINDEACTIVATE: data->cancel= 1; @@ -5598,7 +5608,7 @@ static int ui_handle_button_event(bContext *C, wmEvent *event, uiBut *but) break; case MOUSEMOVE: - if(ELEM(but->type,LINK, INLINK)) { + if (ELEM(but->type,LINK, INLINK)) { but->flag |= UI_SELECT; ui_do_button(C, block, but, event); ED_region_tag_redraw(data->region); @@ -5606,15 +5616,15 @@ static int ui_handle_button_event(bContext *C, wmEvent *event, uiBut *but) else { /* deselect the button when moving the mouse away */ /* also de-activate for buttons that only show higlights */ - if(ui_mouse_inside_button(ar, but, event->x, event->y)) { - if(!(but->flag & UI_SELECT)) { + if (ui_mouse_inside_button(ar, but, event->x, event->y)) { + if (!(but->flag & UI_SELECT)) { but->flag |= (UI_SELECT|UI_ACTIVE); data->cancel= 0; ED_region_tag_redraw(data->region); } } else { - if(but->flag & UI_SELECT) { + if (but->flag & UI_SELECT) { but->flag &= ~(UI_SELECT|UI_ACTIVE); data->cancel= 1; ED_region_tag_redraw(data->region); @@ -5630,30 +5640,30 @@ static int ui_handle_button_event(bContext *C, wmEvent *event, uiBut *but) retval= WM_UI_HANDLER_BREAK; } - else if(data->state == BUTTON_STATE_WAIT_FLASH) { + else if (data->state == BUTTON_STATE_WAIT_FLASH) { switch(event->type) { case TIMER: { - if(event->customdata == data->flashtimer) + if (event->customdata == data->flashtimer) button_activate_state(C, but, BUTTON_STATE_EXIT); } } retval= WM_UI_HANDLER_CONTINUE; } - else if(data->state == BUTTON_STATE_MENU_OPEN) { + else if (data->state == BUTTON_STATE_MENU_OPEN) { /* check for exit because of mouse-over another button */ switch(event->type) { case MOUSEMOVE: - if(data->menu && data->menu->region) - if(ui_mouse_inside_region(data->menu->region, event->x, event->y)) + if (data->menu && data->menu->region) + if (ui_mouse_inside_region(data->menu->region, event->x, event->y)) break; { uiBut *bt= ui_but_find_mouse_over(ar, event->x, event->y); - if(bt && bt->active != data) { - if(but->type != COL) /* exception */ + if (bt && bt->active != data) { + if (but->type != COL) /* exception */ data->cancel= 1; button_activate_state(C, but, BUTTON_STATE_EXIT); } @@ -5669,14 +5679,14 @@ static int ui_handle_button_event(bContext *C, wmEvent *event, uiBut *but) // retval= WM_UI_HANDLER_BREAK; XXX why ? } - if(data->state == BUTTON_STATE_EXIT) { + if (data->state == BUTTON_STATE_EXIT) { postbut= data->postbut; posttype= data->posttype; button_activate_exit(C, data, but, (postbut == NULL), 0); /* for jumping to the next button with tab while text editing */ - if(postbut) + if (postbut) button_activate_init(C, ar, postbut, posttype); } @@ -5689,22 +5699,22 @@ static int ui_handle_list_event(bContext *C, wmEvent *event, ARegion *ar) int retval= WM_UI_HANDLER_CONTINUE; int value, min, max; - if(but && (event->val == KM_PRESS)) { + if (but && (event->val == KM_PRESS)) { Panel *pa= but->block->panel; - if(ELEM(event->type, UPARROWKEY, DOWNARROWKEY) || + if (ELEM(event->type, UPARROWKEY, DOWNARROWKEY) || ((ELEM(event->type, WHEELUPMOUSE, WHEELDOWNMOUSE) && event->alt))) { /* activate up/down the list */ value= RNA_property_int_get(&but->rnapoin, but->rnaprop); - if(ELEM(event->type, UPARROWKEY, WHEELUPMOUSE)) + if (ELEM(event->type, UPARROWKEY, WHEELUPMOUSE)) value--; else value++; - if(value < pa->list_scroll) + if (value < pa->list_scroll) pa->list_scroll= value; - else if(value >= pa->list_scroll+pa->list_size) + else if (value >= pa->list_scroll+pa->list_size) pa->list_scroll= value - pa->list_size + 1; RNA_property_int_range(&but->rnapoin, but->rnaprop, &min, &max); @@ -5716,12 +5726,12 @@ static int ui_handle_list_event(bContext *C, wmEvent *event, ARegion *ar) retval= WM_UI_HANDLER_BREAK; } - else if(ELEM(event->type, WHEELUPMOUSE, WHEELDOWNMOUSE) && event->shift) { + else if (ELEM(event->type, WHEELUPMOUSE, WHEELDOWNMOUSE) && event->shift) { /* silly replacement for proper grip */ - if(pa->list_grip_size == 0) + if (pa->list_grip_size == 0) pa->list_grip_size= pa->list_size; - if(event->type == WHEELUPMOUSE) + if (event->type == WHEELUPMOUSE) pa->list_grip_size--; else pa->list_grip_size++; @@ -5732,10 +5742,10 @@ static int ui_handle_list_event(bContext *C, wmEvent *event, ARegion *ar) retval= WM_UI_HANDLER_BREAK; } - else if(ELEM(event->type, WHEELUPMOUSE, WHEELDOWNMOUSE)) { - if(pa->list_last_len > pa->list_size) { + else if (ELEM(event->type, WHEELUPMOUSE, WHEELDOWNMOUSE)) { + if (pa->list_last_len > pa->list_size) { /* list template will clamp */ - if(event->type == WHEELUPMOUSE) + if (event->type == WHEELUPMOUSE) pa->list_scroll--; else pa->list_scroll++; @@ -5759,29 +5769,29 @@ static void ui_handle_button_return_submenu(bContext *C, wmEvent *event, uiBut * menu= data->menu; /* copy over return values from the closing menu */ - if((menu->menuretval & UI_RETURN_OK) || (menu->menuretval & UI_RETURN_UPDATE)) { - if(but->type == COL) + if ((menu->menuretval & UI_RETURN_OK) || (menu->menuretval & UI_RETURN_UPDATE)) { + if (but->type == COL) copy_v3_v3(data->vec, menu->retvec); - else if(ELEM3(but->type, MENU, ICONROW, ICONTEXTROW)) + else if (ELEM3(but->type, MENU, ICONROW, ICONTEXTROW)) data->value= menu->retvalue; } - if(menu->menuretval & UI_RETURN_UPDATE) { - if(data->interactive) ui_apply_button(C, but->block, but, data, 1); + if (menu->menuretval & UI_RETURN_UPDATE) { + if (data->interactive) ui_apply_button(C, but->block, but, data, 1); else ui_check_but(but); menu->menuretval= 0; } /* now change button state or exit, which will close the submenu */ - if((menu->menuretval & UI_RETURN_OK) || (menu->menuretval & UI_RETURN_CANCEL)) { - if(menu->menuretval != UI_RETURN_OK) + if ((menu->menuretval & UI_RETURN_OK) || (menu->menuretval & UI_RETURN_CANCEL)) { + if (menu->menuretval != UI_RETURN_OK) data->cancel= 1; button_activate_exit(C, data, but, 1, 0); } - else if(menu->menuretval & UI_RETURN_OUT) { - if(event->type==MOUSEMOVE && ui_mouse_inside_button(data->region, but, event->x, event->y)) { + else if (menu->menuretval & UI_RETURN_OUT) { + if (event->type==MOUSEMOVE && ui_mouse_inside_button(data->region, but, event->x, event->y)) { button_activate_state(C, but, BUTTON_STATE_HIGHLIGHT); } else { @@ -5811,12 +5821,12 @@ static void ui_handle_button_return_submenu(bContext *C, wmEvent *event, uiBut * static void ui_mouse_motion_towards_init(uiPopupBlockHandle *menu, int mx, int my, int force) { - if(!menu->dotowards || force) { + if (!menu->dotowards || force) { menu->dotowards= 1; menu->towardsx= mx; menu->towardsy= my; - if(force) + if (force) menu->towardstime= DBL_MAX; /* unlimited time */ else menu->towardstime= PIL_check_seconds_timer(); @@ -5828,7 +5838,7 @@ static int ui_mouse_motion_towards_check(uiBlock *block, uiPopupBlockHandle *men float p1[2], p2[2], p3[2], p4[2], oldp[2], newp[2]; int closer; - if(!menu->dotowards) return 0; + if (!menu->dotowards) return 0; /* verify that we are moving towards one of the edges of the * menu block, in other words, in the triangle formed by the @@ -5851,7 +5861,7 @@ static int ui_mouse_motion_towards_check(uiBlock *block, uiPopupBlockHandle *men newp[0]= mx; newp[1]= my; - if(len_v2v2(oldp, newp) < 4.0f) + if (len_v2v2(oldp, newp) < 4.0f) return menu->dotowards; closer= 0; @@ -5860,11 +5870,11 @@ static int ui_mouse_motion_towards_check(uiBlock *block, uiPopupBlockHandle *men closer |= isect_point_tri_v2(newp, oldp, p3, p4); closer |= isect_point_tri_v2(newp, oldp, p4, p1); - if(!closer) + if (!closer) menu->dotowards= 0; /* 1 second timer */ - if(PIL_check_seconds_timer() - menu->towardstime > BUTTON_MOUSE_TOWARDS_THRESH) + if (PIL_check_seconds_timer() - menu->towardstime > BUTTON_MOUSE_TOWARDS_THRESH) menu->dotowards= 0; return menu->dotowards; @@ -5872,12 +5882,12 @@ static int ui_mouse_motion_towards_check(uiBlock *block, uiPopupBlockHandle *men static char ui_menu_scroll_test(uiBlock *block, int my) { - if(block->flag & (UI_BLOCK_CLIPTOP|UI_BLOCK_CLIPBOTTOM)) { - if(block->flag & UI_BLOCK_CLIPTOP) - if(my > block->maxy-14) + if (block->flag & (UI_BLOCK_CLIPTOP|UI_BLOCK_CLIPBOTTOM)) { + if (block->flag & UI_BLOCK_CLIPTOP) + if (my > block->maxy-14) return 't'; - if(block->flag & UI_BLOCK_CLIPBOTTOM) - if(my < block->miny+14) + if (block->flag & UI_BLOCK_CLIPBOTTOM) + if (my < block->miny+14) return 'b'; } return 0; @@ -5887,7 +5897,7 @@ static int ui_menu_scroll(ARegion *ar, uiBlock *block, int my) { char test= ui_menu_scroll_test(block, my); - if(test) { + if (test) { uiBut *b1= block->buttons.first; uiBut *b2= block->buttons.last; uiBut *bnext; @@ -5895,36 +5905,36 @@ static int ui_menu_scroll(ARegion *ar, uiBlock *block, int my) int dy= 0; /* get first and last visible buttons */ - while(b1 && ui_but_next(b1) && (b1->flag & UI_SCROLLED)) + while (b1 && ui_but_next(b1) && (b1->flag & UI_SCROLLED)) b1= ui_but_next(b1); - while(b2 && ui_but_prev(b2) && (b2->flag & UI_SCROLLED)) + while (b2 && ui_but_prev(b2) && (b2->flag & UI_SCROLLED)) b2= ui_but_prev(b2); /* skips separators */ bnext= ui_but_next(b1); bprev= ui_but_prev(b2); - if(bnext==NULL || bprev==NULL) + if (bnext==NULL || bprev==NULL) return 0; - if(test=='t') { + if (test=='t') { /* bottom button is first button */ - if(b1->y1 < b2->y1) + if (b1->y1 < b2->y1) dy= bnext->y1 - b1->y1; /* bottom button is last button */ else dy= bprev->y1 - b2->y1; } - else if(test=='b') { + else if (test=='b') { /* bottom button is first button */ - if(b1->y1 < b2->y1) + if (b1->y1 < b2->y1) dy= b1->y1 - bnext->y1; /* bottom button is last button */ else dy= b2->y1 - bprev->y1; } - if(dy) { + if (dy) { - for(b1= block->buttons.first; b1; b1= b1->next) { + for (b1= block->buttons.first; b1; b1= b1->next) { b1->y1 -= dy; b1->y2 -= dy; } @@ -5959,43 +5969,43 @@ static int ui_handle_menu_event(bContext *C, wmEvent *event, uiPopupBlockHandle /* check if mouse is inside block */ inside= 0; - if(block->minx <= mx && block->maxx >= mx) - if(block->miny <= my && block->maxy >= my) + if (block->minx <= mx && block->maxx >= mx) + if (block->miny <= my && block->maxy >= my) inside= 1; /* if there's an active modal button, don't check events or outside, except for search menu */ but= ui_but_find_activated(ar); - if(but && button_modal_state(but->active->state) && but->type!=SEARCH_MENU) { + if (but && button_modal_state(but->active->state) && but->type!=SEARCH_MENU) { /* if a button is activated modal, always reset the start mouse * position of the towards mechanism to avoid loosing focus, * and don't handle events */ ui_mouse_motion_towards_init(menu, mx, my, 1); } - else if(event->type == TIMER) { - if(event->customdata == menu->scrolltimer) + else if (event->type == TIMER) { + if (event->customdata == menu->scrolltimer) ui_menu_scroll(ar, block, my); } else { /* for ui_mouse_motion_towards_block */ - if(event->type == MOUSEMOVE) { + if (event->type == MOUSEMOVE) { ui_mouse_motion_towards_init(menu, mx, my, 0); /* add menu scroll timer, if needed */ - if(ui_menu_scroll_test(block, my)) - if(menu->scrolltimer==NULL) + if (ui_menu_scroll_test(block, my)) + if (menu->scrolltimer==NULL) menu->scrolltimer= WM_event_add_timer(CTX_wm_manager(C), CTX_wm_window(C), TIMER, MENU_SCROLL_INTERVAL); } /* first block own event func */ - if(block->block_event_func && block->block_event_func(C, block, event)); + if (block->block_event_func && block->block_event_func(C, block, event)); /* events not for active search menu button */ - else if(but==NULL || but->type!=SEARCH_MENU) { + else if (but==NULL || but->type!=SEARCH_MENU) { switch(event->type) { /* closing sublevels of pulldowns */ case LEFTARROWKEY: - if(event->val==KM_PRESS && (block->flag & UI_BLOCK_LOOP)) - if(block->saferct.first) + if (event->val==KM_PRESS && (block->flag & UI_BLOCK_LOOP)) + if (block->saferct.first) menu->menuretval= UI_RETURN_OUT; retval= WM_UI_HANDLER_BREAK; @@ -6003,16 +6013,16 @@ static int ui_handle_menu_event(bContext *C, wmEvent *event, uiPopupBlockHandle /* opening sublevels of pulldowns */ case RIGHTARROWKEY: - if(event->val==KM_PRESS && (block->flag & UI_BLOCK_LOOP)) { + if (event->val==KM_PRESS && (block->flag & UI_BLOCK_LOOP)) { but= ui_but_find_activated(ar); - if(!but) { + if (!but) { /* no item active, we make first active */ - if(block->direction & UI_TOP) but= ui_but_last(block); + if (block->direction & UI_TOP) but= ui_but_last(block); else but= ui_but_first(block); } - if(but && ELEM(but->type, BLOCK, PULLDOWN)) + if (but && ELEM(but->type, BLOCK, PULLDOWN)) ui_handle_button_activate(C, ar, but, BUTTON_ACTIVATE_OPEN); } @@ -6024,40 +6034,40 @@ static int ui_handle_menu_event(bContext *C, wmEvent *event, uiPopupBlockHandle case WHEELUPMOUSE: case WHEELDOWNMOUSE: /* arrowkeys: only handle for block_loop blocks */ - if(event->alt || event->shift || event->ctrl || event->oskey); - else if(inside || (block->flag & UI_BLOCK_LOOP)) { - if(event->val==KM_PRESS) { + if (event->alt || event->shift || event->ctrl || event->oskey); + else if (inside || (block->flag & UI_BLOCK_LOOP)) { + if (event->val==KM_PRESS) { but= ui_but_find_activated(ar); - if(but) { + if (but) { /* is there a situation where UI_LEFT or UI_RIGHT would also change navigation direction? */ - if( ((ELEM(event->type, DOWNARROWKEY, WHEELDOWNMOUSE)) && (block->direction & UI_DOWN)) || + if ( ((ELEM(event->type, DOWNARROWKEY, WHEELDOWNMOUSE)) && (block->direction & UI_DOWN)) || ((ELEM(event->type, DOWNARROWKEY, WHEELDOWNMOUSE)) && (block->direction & UI_RIGHT)) || ((ELEM(event->type, UPARROWKEY, WHEELUPMOUSE)) && (block->direction & UI_TOP)) ) { /* the following is just a hack - uiBut->type set to BUT and BUTM have there menus built * opposite ways - this should be changed so that all popup-menus use the same uiBlock->direction */ - if(but->type & BUT) + if (but->type & BUT) but= ui_but_next(but); else but= ui_but_prev(but); } else { - if(but->type & BUT) + if (but->type & BUT) but= ui_but_prev(but); else but= ui_but_next(but); } - if(but) + if (but) ui_handle_button_activate(C, ar, but, BUTTON_ACTIVATE); } - if(!but) { - if( ((ELEM(event->type, UPARROWKEY, WHEELUPMOUSE)) && (block->direction & UI_DOWN)) || + if (!but) { + if ( ((ELEM(event->type, UPARROWKEY, WHEELUPMOUSE)) && (block->direction & UI_DOWN)) || ((ELEM(event->type, UPARROWKEY, WHEELUPMOUSE)) && (block->direction & UI_RIGHT)) || ((ELEM(event->type, DOWNARROWKEY, WHEELDOWNMOUSE)) && (block->direction & UI_TOP)) ) { - if((bt= ui_but_first(block)) && (bt->type & BUT)) { + if ((bt= ui_but_first(block)) && (bt->type & BUT)) { bt= ui_but_last(block); } else { @@ -6065,7 +6075,7 @@ static int ui_handle_menu_event(bContext *C, wmEvent *event, uiPopupBlockHandle } } else { - if((bt= ui_but_first(block)) && (bt->type & BUT)) { + if ((bt= ui_but_first(block)) && (bt->type & BUT)) { /* keep ui_but_first() */ } else { @@ -6073,7 +6083,7 @@ static int ui_handle_menu_event(bContext *C, wmEvent *event, uiPopupBlockHandle } } - if(bt) + if (bt) ui_handle_button_activate(C, ar, bt, BUTTON_ACTIVATE); } } @@ -6086,50 +6096,50 @@ static int ui_handle_menu_event(bContext *C, wmEvent *event, uiPopupBlockHandle case ONEKEY: case PAD1: act= 1; case TWOKEY: case PAD2: - if(act==0) act= 2; + if (act==0) act= 2; case THREEKEY: case PAD3: - if(act==0) act= 3; + if (act==0) act= 3; case FOURKEY: case PAD4: - if(act==0) act= 4; + if (act==0) act= 4; case FIVEKEY: case PAD5: - if(act==0) act= 5; + if (act==0) act= 5; case SIXKEY: case PAD6: - if(act==0) act= 6; + if (act==0) act= 6; case SEVENKEY: case PAD7: - if(act==0) act= 7; + if (act==0) act= 7; case EIGHTKEY: case PAD8: - if(act==0) act= 8; + if (act==0) act= 8; case NINEKEY: case PAD9: - if(act==0) act= 9; + if (act==0) act= 9; case ZEROKEY: case PAD0: - if(act==0) act= 10; + if (act==0) act= 10; - if((block->flag & UI_BLOCK_NUMSELECT) && event->val==KM_PRESS) { - if(event->alt) act+= 10; + if ((block->flag & UI_BLOCK_NUMSELECT) && event->val==KM_PRESS) { + if (event->alt) act+= 10; count= 0; - for(but= block->buttons.first; but; but= but->next) { + for (but= block->buttons.first; but; but= but->next) { int doit= 0; - if(but->type!=LABEL && but->type!=SEPR) + if (but->type!=LABEL && but->type!=SEPR) count++; /* exception for rna layer buts */ - if(but->rnapoin.data && but->rnaprop) { + if (but->rnapoin.data && but->rnaprop) { if (ELEM(RNA_property_subtype(but->rnaprop), PROP_LAYER, PROP_LAYER_MEMBER)) { if (but->rnaindex== act-1) doit=1; } } /* exception for menus like layer buts, with button aligning they're not drawn in order */ - else if(but->type==TOGR) { - if(but->bitnr==act-1) + else if (but->type==TOGR) { + if (but->bitnr==act-1) doit= 1; } - else if(count==act) + else if (count==act) doit=1; - if(doit) { + if (doit) { ui_handle_button_activate(C, ar, but, BUTTON_ACTIVATE_APPLY); break; } @@ -6167,19 +6177,19 @@ static int ui_handle_menu_event(bContext *C, wmEvent *event, uiPopupBlockHandle case YKEY: case ZKEY: { - if( (event->val == KM_PRESS) && + if ( (event->val == KM_PRESS) && (event->shift == FALSE) && (event->ctrl == FALSE) && (event->oskey == FALSE) ) { - for(but= block->buttons.first; but; but= but->next) { + for (but= block->buttons.first; but; but= but->next) { - if(but->menu_key==event->type) { - if(but->type == BUT) { + if (but->menu_key==event->type) { + if (but->type == BUT) { /* mainly for operator buttons */ ui_handle_button_activate(C, ar, but, BUTTON_ACTIVATE_APPLY); } - else if(ELEM(but->type, BLOCK, PULLDOWN)) { + else if (ELEM(but->type, BLOCK, PULLDOWN)) { /* open submenus (like right arrow key) */ ui_handle_button_activate(C, ar, but, BUTTON_ACTIVATE_OPEN); } @@ -6203,15 +6213,15 @@ static int ui_handle_menu_event(bContext *C, wmEvent *event, uiPopupBlockHandle } /* here we check return conditions for menus */ - if(block->flag & UI_BLOCK_LOOP) { + if (block->flag & UI_BLOCK_LOOP) { /* if we click outside the block, verify if we clicked on the * button that opened us, otherwise we need to close */ - if(inside==0) { + if (inside==0) { uiSafetyRct *saferct= block->saferct.first; - if(ELEM3(event->type, LEFTMOUSE, MIDDLEMOUSE, RIGHTMOUSE) && event->val==KM_PRESS) { - if(saferct && !BLI_in_rctf(&saferct->parent, event->x, event->y)) { - if(block->flag & (UI_BLOCK_OUT_1)) + if (ELEM3(event->type, LEFTMOUSE, MIDDLEMOUSE, RIGHTMOUSE) && event->val==KM_PRESS) { + if (saferct && !BLI_in_rctf(&saferct->parent, event->x, event->y)) { + if (block->flag & (UI_BLOCK_OUT_1)) menu->menuretval= UI_RETURN_OK; else menu->menuretval= UI_RETURN_OUT; @@ -6219,45 +6229,45 @@ static int ui_handle_menu_event(bContext *C, wmEvent *event, uiPopupBlockHandle } } - if(menu->menuretval); - else if(event->type==ESCKEY && event->val==KM_PRESS) { + if (menu->menuretval); + else if (event->type==ESCKEY && event->val==KM_PRESS) { /* esc cancels this and all preceding menus */ menu->menuretval= UI_RETURN_CANCEL; } - else if(ELEM(event->type, RETKEY, PADENTER) && event->val==KM_PRESS) { + else if (ELEM(event->type, RETKEY, PADENTER) && event->val==KM_PRESS) { /* enter will always close this block, we let the event * get handled by the button if it is activated, otherwise we cancel */ - if(!ui_but_find_activated(ar)) + if (!ui_but_find_activated(ar)) menu->menuretval= UI_RETURN_CANCEL | UI_RETURN_POPUP_OK; } else { ui_mouse_motion_towards_check(block, menu, mx, my); /* check mouse moving outside of the menu */ - if(inside==0 && (block->flag & UI_BLOCK_MOVEMOUSE_QUIT)) { + if (inside==0 && (block->flag & UI_BLOCK_MOVEMOUSE_QUIT)) { uiSafetyRct *saferct; /* check for all parent rects, enables arrowkeys to be used */ - for(saferct=block->saferct.first; saferct; saferct= saferct->next) { + for (saferct=block->saferct.first; saferct; saferct= saferct->next) { /* for mouse move we only check our own rect, for other * events we check all preceding block rects too to make * arrow keys navigation work */ - if(event->type!=MOUSEMOVE || saferct==block->saferct.first) { - if(BLI_in_rctf(&saferct->parent, (float)event->x, (float)event->y)) + if (event->type!=MOUSEMOVE || saferct==block->saferct.first) { + if (BLI_in_rctf(&saferct->parent, (float)event->x, (float)event->y)) break; - if(BLI_in_rctf(&saferct->safety, (float)event->x, (float)event->y)) + if (BLI_in_rctf(&saferct->safety, (float)event->x, (float)event->y)) break; } } /* strict check, and include the parent rect */ - if(!menu->dotowards && !saferct) { - if(block->flag & (UI_BLOCK_OUT_1)) + if (!menu->dotowards && !saferct) { + if (block->flag & (UI_BLOCK_OUT_1)) menu->menuretval= UI_RETURN_OK; else menu->menuretval= UI_RETURN_OUT; } - else if(menu->dotowards && event->type==MOUSEMOVE) + else if (menu->dotowards && event->type==MOUSEMOVE) retval= WM_UI_HANDLER_BREAK; } } @@ -6268,20 +6278,20 @@ static int ui_handle_menu_event(bContext *C, wmEvent *event, uiPopupBlockHandle * buttons inside this region. disabled inside check .. not sure * anymore why it was there? but it meant enter didn't work * for example when mouse was not over submenu */ - if((/*inside &&*/ (!menu->menuretval || (menu->menuretval & UI_RETURN_UPDATE)) && retval == WM_UI_HANDLER_CONTINUE) || event->type == TIMER) { + if ((/*inside &&*/ (!menu->menuretval || (menu->menuretval & UI_RETURN_UPDATE)) && retval == WM_UI_HANDLER_CONTINUE) || event->type == TIMER) { but= ui_but_find_activated(ar); - if(but) { + if (but) { ScrArea *ctx_area= CTX_wm_area(C); ARegion *ctx_region= CTX_wm_region(C); - if(menu->ctx_area) CTX_wm_area_set(C, menu->ctx_area); - if(menu->ctx_region) CTX_wm_region_set(C, menu->ctx_region); + if (menu->ctx_area) CTX_wm_area_set(C, menu->ctx_area); + if (menu->ctx_region) CTX_wm_region_set(C, menu->ctx_region); retval= ui_handle_button_event(C, event, but); - if(menu->ctx_area) CTX_wm_area_set(C, ctx_area); - if(menu->ctx_region) CTX_wm_region_set(C, ctx_region); + if (menu->ctx_area) CTX_wm_area_set(C, ctx_area); + if (menu->ctx_region) CTX_wm_region_set(C, ctx_region); } else retval= ui_handle_button_over(C, event, ar); @@ -6290,9 +6300,9 @@ static int ui_handle_menu_event(bContext *C, wmEvent *event, uiPopupBlockHandle /* if we set a menu return value, ensure we continue passing this on to * lower menus and buttons, so always set continue then, and if we are * inside the region otherwise, ensure we swallow the event */ - if(menu->menuretval) + if (menu->menuretval) return WM_UI_HANDLER_CONTINUE; - else if(inside) + else if (inside) return WM_UI_HANDLER_BREAK; else return retval; @@ -6314,11 +6324,11 @@ static int ui_handle_menu_return_submenu(bContext *C, wmEvent *event, uiPopupBlo data= but->active; submenu= data->menu; - if(submenu->menuretval) { + if (submenu->menuretval) { /* first decide if we want to close our own menu cascading, if * so pass on the sub menu return value to our own menu handle */ - if((submenu->menuretval & UI_RETURN_OK) || (submenu->menuretval & UI_RETURN_CANCEL)) { - if(!(block->flag & UI_BLOCK_KEEP_OPEN)) { + if ((submenu->menuretval & UI_RETURN_OK) || (submenu->menuretval & UI_RETURN_CANCEL)) { + if (!(block->flag & UI_BLOCK_KEEP_OPEN)) { menu->menuretval= submenu->menuretval; menu->butretval= data->retval; } @@ -6330,7 +6340,7 @@ static int ui_handle_menu_return_submenu(bContext *C, wmEvent *event, uiPopupBlo * will actually close the submenu too */ ui_handle_button_return_submenu(C, event, but); - if(update) + if (update) submenu->menuretval = 0; } @@ -6341,7 +6351,7 @@ static int ui_handle_menu_return_submenu(bContext *C, wmEvent *event, uiPopupBlo ui_window_to_block(ar, block, &mx, &my); ui_mouse_motion_towards_init(menu, mx, my, 1); - if(menu->menuretval) + if (menu->menuretval) return WM_UI_HANDLER_CONTINUE; else return WM_UI_HANDLER_BREAK; @@ -6359,12 +6369,12 @@ static int ui_handle_menus_recursive(bContext *C, wmEvent *event, uiPopupBlockHa data= (but)? but->active: NULL; submenu= (data)? data->menu: NULL; - if(submenu) + if (submenu) retval= ui_handle_menus_recursive(C, event, submenu); /* now handle events for our own menu */ - if(retval == WM_UI_HANDLER_CONTINUE || event->type == TIMER) { - if(submenu && submenu->menuretval) + if (retval == WM_UI_HANDLER_CONTINUE || event->type == TIMER) { + if (submenu && submenu->menuretval) retval= ui_handle_menu_return_submenu(C, event, menu); else retval= ui_handle_menu_event(C, event, menu, (submenu == NULL)); @@ -6385,26 +6395,26 @@ static int ui_handler_region(bContext *C, wmEvent *event, void *UNUSED(userdata) ar= CTX_wm_region(C); retval= WM_UI_HANDLER_CONTINUE; - if(ar==NULL) return retval; - if(ar->uiblocks.first==NULL) return retval; + if (ar==NULL) return retval; + if (ar->uiblocks.first==NULL) return retval; /* either handle events for already activated button or try to activate */ but= ui_but_find_activated(ar); retval= ui_handler_panel_region(C, event); - if(retval == WM_UI_HANDLER_CONTINUE) + if (retval == WM_UI_HANDLER_CONTINUE) retval= ui_handle_list_event(C, event, ar); - if(retval == WM_UI_HANDLER_CONTINUE) { - if(but) + if (retval == WM_UI_HANDLER_CONTINUE) { + if (but) retval= ui_handle_button_event(C, event, but); else retval= ui_handle_button_over(C, event, ar); } /* re-enable tooltips */ - if(event->type == MOUSEMOVE && (event->x!=event->prevx || event->y!=event->prevy)) + if (event->type == MOUSEMOVE && (event->x!=event->prevx || event->y!=event->prevy)) ui_blocks_set_tooltips(ar, 1); /* delayed apply callbacks */ @@ -6419,17 +6429,17 @@ static void ui_handler_remove_region(bContext *C, void *UNUSED(userdata)) ARegion *ar; ar= CTX_wm_region(C); - if(ar == NULL) return; + if (ar == NULL) return; uiFreeBlocks(C, &ar->uiblocks); sc= CTX_wm_screen(C); - if(sc == NULL) return; + if (sc == NULL) return; /* delayed apply callbacks, but not for screen level regions, those * we rather do at the very end after closing them all, which will * be done in ui_handler_region/window */ - if(BLI_findindex(&sc->regionbase, ar) == -1) + if (BLI_findindex(&sc->regionbase, ar) == -1) ui_apply_but_funcs_after(C); } @@ -6443,23 +6453,23 @@ static int ui_handler_region_menu(bContext *C, wmEvent *event, void *UNUSED(user /* here we handle buttons at the window level, modal, for example * while number sliding, text editing, or when a menu block is open */ ar= CTX_wm_menu(C); - if(!ar) + if (!ar) ar= CTX_wm_region(C); but= ui_but_find_activated(ar); - if(but) { + if (but) { /* handle activated button events */ data= but->active; - if(data->state == BUTTON_STATE_MENU_OPEN) { + if (data->state == BUTTON_STATE_MENU_OPEN) { /* handle events for menus and their buttons recursively, * this will handle events from the top to the bottom menu */ retval= ui_handle_menus_recursive(C, event, data->menu); /* handle events for the activated button */ - if(retval == WM_UI_HANDLER_CONTINUE || event->type == TIMER) { - if(data->menu->menuretval) + if (retval == WM_UI_HANDLER_CONTINUE || event->type == TIMER) { + if (data->menu->menuretval) ui_handle_button_return_submenu(C, event, but); else ui_handle_button_event(C, event, but); @@ -6472,7 +6482,7 @@ static int ui_handler_region_menu(bContext *C, wmEvent *event, void *UNUSED(user } /* re-enable tooltips */ - if(event->type == MOUSEMOVE && (event->x!=event->prevx || event->y!=event->prevy)) + if (event->type == MOUSEMOVE && (event->x!=event->prevx || event->y!=event->prevy)) ui_blocks_set_tooltips(ar, 1); /* delayed apply callbacks */ @@ -6490,25 +6500,25 @@ static int ui_handler_popup(bContext *C, wmEvent *event, void *userdata) ui_handle_menus_recursive(C, event, menu); /* free if done, does not free handle itself */ - if(menu->menuretval) { + if (menu->menuretval) { /* copy values, we have to free first (closes region) */ uiPopupBlockHandle temp= *menu; ui_popup_block_free(C, menu); UI_remove_popup_handlers(&CTX_wm_window(C)->modalhandlers, menu); - if((temp.menuretval & UI_RETURN_OK) || (temp.menuretval & UI_RETURN_POPUP_OK)) { - if(temp.popup_func) + if ((temp.menuretval & UI_RETURN_OK) || (temp.menuretval & UI_RETURN_POPUP_OK)) { + if (temp.popup_func) temp.popup_func(C, temp.popup_arg, temp.retvalue); - if(temp.optype) + if (temp.optype) WM_operator_name_call(C, temp.optype->idname, temp.opcontext, NULL); } - else if(temp.cancel_func) + else if (temp.cancel_func) temp.cancel_func(temp.popup_arg); } else { /* re-enable tooltips */ - if(event->type == MOUSEMOVE && (event->x!=event->prevx || event->y!=event->prevy)) + if (event->type == MOUSEMOVE && (event->x!=event->prevx || event->y!=event->prevy)) ui_blocks_set_tooltips(menu->region, 1); } diff --git a/source/blender/editors/interface/interface_icons.c b/source/blender/editors/interface/interface_icons.c index 403df8acbee..4b5612c6408 100644 --- a/source/blender/editors/interface/interface_icons.c +++ b/source/blender/editors/interface/interface_icons.c @@ -147,13 +147,13 @@ static void def_internal_icon(ImBuf *bbuf, int icon_id, int xofs, int yofs, int di = MEM_callocN(sizeof(DrawInfo), "drawinfo"); di->type= type; - if(type == ICON_TYPE_TEXTURE) { + if (type == ICON_TYPE_TEXTURE) { di->data.texture.x= xofs; di->data.texture.y= yofs; di->data.texture.w= size; di->data.texture.h= size; } - else if(type == ICON_TYPE_BUFFER) { + else if (type == ICON_TYPE_BUFFER) { iimg = MEM_mallocN(sizeof(IconImage), "icon_img"); iimg->rect = MEM_mallocN(size*size*sizeof(unsigned int), "icon_rect"); iimg->w = size; @@ -517,7 +517,7 @@ static void init_internal_icons(void) if (icondir) { BLI_join_dirfile(iconfilestr, sizeof(iconfilestr), icondir, btheme->tui.iconfile); bbuf = IMB_loadiffname(iconfilestr, IB_rect); /* if the image is missing bbuf will just be NULL */ - if(bbuf && (bbuf->x < ICON_IMAGE_W || bbuf->y < ICON_IMAGE_H)) { + if (bbuf && (bbuf->x < ICON_IMAGE_W || bbuf->y < ICON_IMAGE_H)) { printf("\n***WARNING***\nIcons file %s too small.\nUsing built-in Icons instead\n", iconfilestr); IMB_freeImBuf(bbuf); bbuf= NULL; @@ -527,21 +527,21 @@ static void init_internal_icons(void) printf("%s: 'icons' data path not found, continuing\n", __func__); } } - if(bbuf==NULL) + if (bbuf==NULL) bbuf = IMB_ibImageFromMemory((unsigned char*)datatoc_blender_icons_png, datatoc_blender_icons_png_size, IB_rect, ""); - if(bbuf) { + if (bbuf) { /* free existing texture if any */ - if(icongltex.id) { + if (icongltex.id) { glDeleteTextures(1, &icongltex.id); icongltex.id= 0; } /* we only use a texture for cards with non-power of two */ - if(GPU_non_power_of_two_support()) { + if (GPU_non_power_of_two_support()) { glGenTextures(1, &icongltex.id); - if(icongltex.id) { + if (icongltex.id) { icongltex.w = bbuf->x; icongltex.h = bbuf->y; icongltex.invw = 1.0f/bbuf->x; @@ -553,7 +553,7 @@ static void init_internal_icons(void) glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glBindTexture(GL_TEXTURE_2D, 0); - if(glGetError() == GL_OUT_OF_MEMORY) { + if (glGetError() == GL_OUT_OF_MEMORY) { glDeleteTextures(1, &icongltex.id); icongltex.id= 0; } @@ -561,12 +561,12 @@ static void init_internal_icons(void) } } - if(icongltex.id) + if (icongltex.id) icontype= ICON_TYPE_TEXTURE; else icontype= ICON_TYPE_BUFFER; - if(bbuf) { + if (bbuf) { for (y=0; yfirst = list->last = NULL; icondir = BLI_get_folder(BLENDER_DATAFILES, "icons"); - if(icondir==NULL) + if (icondir==NULL) return; /* since BLI_dir_contents changes the current working directory, restore it * back to old value afterwards */ - if(!BLI_current_working_dir(olddir, sizeof(olddir))) + if (!BLI_current_working_dir(olddir, sizeof(olddir))) restoredir = 0; totfile = BLI_dir_contents(icondir, &dir); if (restoredir && !chdir(olddir)) {} /* fix warning about checking return value */ - for(i=0; ix; ifiley = bbuf->y; IMB_freeImBuf(bbuf); @@ -678,7 +678,7 @@ static void free_iconfile_list(struct ListBase *list) { IconFile *ifile=NULL, *next_ifile=NULL; - for(ifile=list->first; ifile; ifile=next_ifile) { + for (ifile=list->first; ifile; ifile=next_ifile) { next_ifile = ifile->next; BLI_freelinkN(list, ifile); } @@ -689,7 +689,7 @@ int UI_iconfile_get_index(const char *filename) IconFile *ifile; ListBase *list=&(iconfilelist); - for(ifile=list->first; ifile; ifile=ifile->next) { + for (ifile=list->first; ifile; ifile=ifile->next) { if (BLI_path_cmp(filename, ifile->filename) == 0) { return ifile->index; } @@ -709,7 +709,7 @@ ListBase *UI_iconfile_list(void) void UI_icons_free(void) { #ifndef WITH_HEADLESS - if(icongltex.id) { + if (icongltex.id) { glDeleteTextures(1, &icongltex.id); icongltex.id= 0; } @@ -723,9 +723,9 @@ void UI_icons_free_drawinfo(void *drawinfo) { DrawInfo *di = drawinfo; - if(di) { - if(di->type == ICON_TYPE_BUFFER) { - if(di->data.buffer.image) { + if (di) { + if (di->type == ICON_TYPE_BUFFER) { + if (di->data.buffer.image) { MEM_freeN(di->data.buffer.image->rect); MEM_freeN(di->data.buffer.image); } @@ -860,24 +860,24 @@ static void icon_draw_rect(float x, float y, int w, int h, float UNUSED(aspect), ImBuf *ima= NULL; /* sanity check */ - if(w<=0 || h<=0 || w>2000 || h>2000) { + if (w<=0 || h<=0 || w>2000 || h>2000) { printf("%s: icons are %i x %i pixels?\n", __func__, w, h); BLI_assert(!"invalid icon size"); return; } /* modulate color */ - if(alpha != 1.0f) + if (alpha != 1.0f) glPixelTransferf(GL_ALPHA_SCALE, alpha); - if(rgb) { + if (rgb) { glPixelTransferf(GL_RED_SCALE, rgb[0]); glPixelTransferf(GL_GREEN_SCALE, rgb[1]); glPixelTransferf(GL_BLUE_SCALE, rgb[2]); } /* rect contains image in 'rendersize', we only scale if needed */ - if(rw!=w && rh!=h) { + if (rw!=w && rh!=h) { /* first allocate imbuf for scaling and copy preview into it */ ima = IMB_allocImBuf(rw, rh, 32, IB_rect); memcpy(ima->rect, rect, rw*rh*sizeof(unsigned int)); @@ -886,7 +886,7 @@ static void icon_draw_rect(float x, float y, int w, int h, float UNUSED(aspect), } /* draw */ - if(is_preview) { + if (is_preview) { glaDrawPixelsSafe(x, y, w, h, w, GL_RGBA, GL_UNSIGNED_BYTE, rect); } else { @@ -894,14 +894,14 @@ static void icon_draw_rect(float x, float y, int w, int h, float UNUSED(aspect), glDrawPixels(w, h, GL_RGBA, GL_UNSIGNED_BYTE, rect); } - if(ima) + if (ima) IMB_freeImBuf(ima); /* restore color */ - if(alpha != 0.0f) + if (alpha != 0.0f) glPixelTransferf(GL_ALPHA_SCALE, 1.0f); - if(rgb) { + if (rgb) { glPixelTransferf(GL_RED_SCALE, 1.0f); glPixelTransferf(GL_GREEN_SCALE, 1.0f); glPixelTransferf(GL_BLUE_SCALE, 1.0f); @@ -912,7 +912,7 @@ static void icon_draw_texture(float x, float y, float w, float h, int ix, int iy { float x1, x2, y1, y2; - if(rgb) glColor4f(rgb[0], rgb[1], rgb[2], alpha); + if (rgb) glColor4f(rgb[0], rgb[1], rgb[2], alpha); else glColor4f(1.0f, 1.0f, 1.0f, alpha); x1= ix*icongltex.invw; @@ -982,29 +982,29 @@ static void icon_draw_size(float x, float y, int icon_id, float aspect, float al w = (int)(fdraw_size/aspect + 0.5f); h = (int)(fdraw_size/aspect + 0.5f); - if(di->type == ICON_TYPE_VECTOR) { + if (di->type == ICON_TYPE_VECTOR) { /* vector icons use the uiBlock transformation, they are not drawn * with untransformed coordinates like the other icons */ di->data.vector.func((int)x, (int)y, ICON_DEFAULT_HEIGHT, ICON_DEFAULT_HEIGHT, 1.0f); } - else if(di->type == ICON_TYPE_TEXTURE) { + else if (di->type == ICON_TYPE_TEXTURE) { icon_draw_texture(x, y, (float)w, (float)h, di->data.texture.x, di->data.texture.y, di->data.texture.w, di->data.texture.h, alpha, rgb); } - else if(di->type == ICON_TYPE_BUFFER) { + else if (di->type == ICON_TYPE_BUFFER) { /* it is a builtin icon */ iimg= di->data.buffer.image; - if(!iimg->rect) return; /* something has gone wrong! */ + if (!iimg->rect) return; /* something has gone wrong! */ icon_draw_rect(x, y, w, h, aspect, iimg->w, iimg->h, iimg->rect, alpha, rgb, is_preview); } - else if(di->type == ICON_TYPE_PREVIEW) { + else if (di->type == ICON_TYPE_PREVIEW) { PreviewImage* pi = BKE_previewimg_get((ID*)icon->obj); - if(pi) { + if (pi) { /* no create icon on this level in code */ - if(!pi->rect[size]) return; /* something has gone wrong! */ + if (!pi->rect[size]) return; /* something has gone wrong! */ /* preview images use premul alpha ... */ glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); @@ -1041,13 +1041,13 @@ static void ui_id_brush_render(bContext *C, ID *id) PreviewImage *pi = BKE_previewimg_get(id); enum eIconSizes i; - if(!pi) + if (!pi) return; - for(i = 0; i < NUM_ICON_SIZES; i++) { + for (i = 0; i < NUM_ICON_SIZES; i++) { /* check if rect needs to be created; changed * only set by dynamic icons */ - if((pi->changed[i] || !pi->rect[i])) { + if ((pi->changed[i] || !pi->rect[i])) { icon_set_image(C, id, pi, i); pi->changed[i] = 0; } @@ -1059,7 +1059,7 @@ static int ui_id_brush_get_icon(bContext *C, ID *id) { Brush *br = (Brush*)id; - if(br->flag & BRUSH_CUSTOM_ICON) { + if (br->flag & BRUSH_CUSTOM_ICON) { BKE_icon_getid(id); ui_id_brush_render(C, id); } @@ -1073,34 +1073,34 @@ static int ui_id_brush_get_icon(bContext *C, ID *id) * be strictly in one paint mode only to avoid * checking various context stuff here */ - if(CTX_wm_view3d(C) && ob) { - if(ob->mode & OB_MODE_SCULPT) + if (CTX_wm_view3d(C) && ob) { + if (ob->mode & OB_MODE_SCULPT) mode = OB_MODE_SCULPT; - else if(ob->mode & (OB_MODE_VERTEX_PAINT|OB_MODE_WEIGHT_PAINT)) + else if (ob->mode & (OB_MODE_VERTEX_PAINT|OB_MODE_WEIGHT_PAINT)) mode = OB_MODE_VERTEX_PAINT; - else if(ob->mode & OB_MODE_TEXTURE_PAINT) + else if (ob->mode & OB_MODE_TEXTURE_PAINT) mode = OB_MODE_TEXTURE_PAINT; } - else if((sima = CTX_wm_space_image(C)) && + else if ((sima = CTX_wm_space_image(C)) && (sima->flag & SI_DRAWTOOL)) { mode = OB_MODE_TEXTURE_PAINT; } /* reset the icon */ - if(mode == OB_MODE_SCULPT) { + if (mode == OB_MODE_SCULPT) { items = brush_sculpt_tool_items; tool = br->sculpt_tool; } - else if(mode == OB_MODE_VERTEX_PAINT) { + else if (mode == OB_MODE_VERTEX_PAINT) { items = brush_vertex_tool_items; tool = br->vertexpaint_tool; } - else if(mode == OB_MODE_TEXTURE_PAINT) { + else if (mode == OB_MODE_TEXTURE_PAINT) { items = brush_image_tool_items; tool = br->imagepaint_tool; } - if(!items || !RNA_enum_icon_from_value(items, tool, &id->icon_id)) + if (!items || !RNA_enum_icon_from_value(items, tool, &id->icon_id)) id->icon_id = 0; } diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c index 1c2f2cacf62..88db06c5ec3 100644 --- a/source/blender/editors/interface/interface_layout.c +++ b/source/blender/editors/interface/interface_layout.c @@ -172,7 +172,7 @@ static const char *ui_item_name_add_colon(const char *name, char namestr[UI_MAX_ { int len= strlen(name); - if(len != 0 && len+1 < UI_MAX_NAME_STR) { + if (len != 0 && len+1 < UI_MAX_NAME_STR) { BLI_strncpy(namestr, name, UI_MAX_NAME_STR); namestr[len]= ':'; namestr[len+1]= '\0'; @@ -185,23 +185,23 @@ static const char *ui_item_name_add_colon(const char *name, char namestr[UI_MAX_ static int ui_item_fit(int item, int pos, int all, int available, int last, int alignment, int *offset) { /* available == 0 is unlimited */ - if(available == 0) + if (available == 0) return item; - if(offset) + if (offset) *offset= 0; - if(all > available) { + if (all > available) { /* contents is bigger than available space */ - if(last) + if (last) return available-pos; else return (item*available)/all; } else { /* contents is smaller or equal to available space */ - if(alignment == UI_LAYOUT_ALIGN_EXPAND) { - if(last) + if (alignment == UI_LAYOUT_ALIGN_EXPAND) { + if (last) return available-pos; else return (item*available)/all; @@ -225,9 +225,9 @@ static int ui_text_icon_width(uiLayout *layout, const char *name, int icon, int { int variable = ui_layout_vary_direction(layout) == UI_ITEM_VARY_X; - if(icon && !name[0]) + if (icon && !name[0]) return UI_UNIT_X; /* icon only */ - else if(icon) + else if (icon) return (variable)? UI_GetStringWidth(name) + (compact? 5: 10) + UI_UNIT_X: 10*UI_UNIT_X; /* icon + text */ else return (variable)? UI_GetStringWidth(name) + (compact? 5: 10) + UI_UNIT_X: 10*UI_UNIT_X; /* text only */ @@ -235,37 +235,37 @@ static int ui_text_icon_width(uiLayout *layout, const char *name, int icon, int static void ui_item_size(uiItem *item, int *r_w, int *r_h) { - if(item->type == ITEM_BUTTON) { + if (item->type == ITEM_BUTTON) { uiButtonItem *bitem= (uiButtonItem*)item; - if(r_w) *r_w= bitem->but->x2 - bitem->but->x1; - if(r_h) *r_h= bitem->but->y2 - bitem->but->y1; + if (r_w) *r_w= bitem->but->x2 - bitem->but->x1; + if (r_h) *r_h= bitem->but->y2 - bitem->but->y1; } else { uiLayout *litem= (uiLayout*)item; - if(r_w) *r_w= litem->w; - if(r_h) *r_h= litem->h; + if (r_w) *r_w= litem->w; + if (r_h) *r_h= litem->h; } } static void ui_item_offset(uiItem *item, int *r_x, int *r_y) { - if(item->type == ITEM_BUTTON) { + if (item->type == ITEM_BUTTON) { uiButtonItem *bitem= (uiButtonItem*)item; - if(r_x) *r_x= bitem->but->x1; - if(r_y) *r_y= bitem->but->y1; + if (r_x) *r_x= bitem->but->x1; + if (r_y) *r_y= bitem->but->y1; } else { - if(r_x) *r_x= 0; - if(r_y) *r_y= 0; + if (r_x) *r_x= 0; + if (r_y) *r_y= 0; } } static void ui_item_position(uiItem *item, int x, int y, int w, int h) { - if(item->type == ITEM_BUTTON) { + if (item->type == ITEM_BUTTON) { uiButtonItem *bitem= (uiButtonItem*)item; bitem->but->x1= x; @@ -308,7 +308,7 @@ static uiLayout *ui_item_local_sublayout(uiLayout *test, uiLayout *layout, int a { uiLayout *sub; - if(ui_layout_local_dir(test) == UI_LAYOUT_HORIZONTAL) + if (ui_layout_local_dir(test) == UI_LAYOUT_HORIZONTAL) sub= uiLayoutRow(layout, align); else sub= uiLayoutColumn(layout, align); @@ -327,16 +327,16 @@ static void ui_layer_but_cb(bContext *C, void *arg_but, void *arg_index) int shift= win->eventstate->shift; int len= RNA_property_array_length(ptr, prop); - if(!shift) { + if (!shift) { RNA_property_boolean_set_index(ptr, prop, index, TRUE); - for(i=0; iblock->buttons.first; cbut; cbut=cbut->next) + for (cbut=but->block->buttons.first; cbut; cbut=cbut->next) ui_check_but(cbut); } } @@ -359,11 +359,11 @@ static void ui_item_array(uiLayout *layout, uiBlock *block, const char *name, in uiBlockSetCurLayout(block, sub); /* create label */ - if(name[0]) + if (name[0]) uiDefBut(block, LABEL, 0, name, 0, 0, w, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, ""); /* create buttons */ - if(type == PROP_BOOLEAN && ELEM(subtype, PROP_LAYER, PROP_LAYER_MEMBER)) { + if (type == PROP_BOOLEAN && ELEM(subtype, PROP_LAYER, PROP_LAYER_MEMBER)) { /* special check for layer layout */ int butw, buth, unit; int cols= (len >= 20)? 2: 1; @@ -376,28 +376,28 @@ static void ui_item_array(uiLayout *layout, uiBlock *block, const char *name, in butw= unit; buth= unit; - if(ptr->type == &RNA_Armature) { + if (ptr->type == &RNA_Armature) { bArmature *arm= (bArmature *)ptr->data; layer_used= arm->layer_used; } - for(b=0; bbuttonspacex; } } - else if(subtype == PROP_MATRIX) { + else if (subtype == PROP_MATRIX) { int totdim, dim_size[3]; /* 3 == RNA_MAX_ARRAY_DIMENSION */ int row, col; @@ -417,16 +417,16 @@ static void ui_item_array(uiLayout *layout, uiBlock *block, const char *name, in w /= dim_size[0]; /* h /= dim_size[1]; */ /* UNUSED */ - for(a=0; atype==NUM) + if (slider && but->type==NUM) but->type= NUMSLI; } } - else if(subtype == PROP_DIRECTION) { + else if (subtype == PROP_DIRECTION) { uiDefButR_prop(block, BUT_NORMAL, 0, name, x, y, UI_UNIT_X*3, UI_UNIT_Y*3, ptr, prop, 0, 0, 0, -1, -1, NULL); } else { @@ -434,7 +434,7 @@ static void ui_item_array(uiLayout *layout, uiBlock *block, const char *name, in * to work with common cases, but may need to be re-worked */ /* special case, boolean array in a menu, this could be used in a more generic way too */ - if(ELEM(subtype, PROP_COLOR, PROP_COLOR_GAMMA) && !expand) { + if (ELEM(subtype, PROP_COLOR, PROP_COLOR_GAMMA) && !expand) { uiDefAutoButR(block, ptr, prop, -1, "", ICON_NONE, 0, 0, w, UI_UNIT_Y); } else { @@ -445,29 +445,29 @@ static void ui_item_array(uiLayout *layout, uiBlock *block, const char *name, in /* layout for known array subtypes */ char str[3]= {'\0'}; - if(!icon_only) { - if(type != PROP_BOOLEAN) { + if (!icon_only) { + if (type != PROP_BOOLEAN) { str[1]= ':'; } } /* show checkboxes for rna on a non-emboss block (menu for eg) */ - if(type == PROP_BOOLEAN && ELEM(layout->root->block->dt, UI_EMBOSSN, UI_EMBOSSP)) { + if (type == PROP_BOOLEAN && ELEM(layout->root->block->dt, UI_EMBOSSN, UI_EMBOSSP)) { boolarr= MEM_callocN(sizeof(int)*len, "ui_item_array"); RNA_property_boolean_get_array(ptr, prop, boolarr); } - for(a=0; atype==NUM) + if (slider && but->type==NUM) but->type= NUMSLI; - if(toggle && but->type==OPTION) + if (toggle && but->type==OPTION) but->type= TOG; } - if(boolarr) { + if (boolarr) { MEM_freeN(boolarr); } } @@ -486,8 +486,8 @@ static void ui_item_enum_expand(uiLayout *layout, uiBlock *block, PointerRNA *pt RNA_property_enum_items_gettexted(block->evil_C, ptr, prop, &item, &totitem, &free); uiBlockSetCurLayout(block, ui_item_local_sublayout(layout, layout, 1)); - for(a=0; acurlayout, name, icon, 0); - if(icon && name[0] && !icon_only) + if (icon && name[0] && !icon_only) but = uiDefIconTextButR_prop(block, ROW, 0, icon, name, 0, 0, itemw, h, ptr, prop, -1, 0, value, -1, -1, NULL); - else if(icon) + else if (icon) but = uiDefIconButR_prop(block, ROW, 0, icon, 0, 0, itemw, h, ptr, prop, -1, 0, value, -1, -1, NULL); else but = uiDefButR_prop(block, ROW, 0, name, 0, 0, itemw, h, ptr, prop, -1, 0, value, -1, -1, NULL); - if(ui_layout_local_dir(layout) != UI_LAYOUT_HORIZONTAL) + if (ui_layout_local_dir(layout) != UI_LAYOUT_HORIZONTAL) but->flag |= UI_TEXT_LEFT; } uiBlockSetCurLayout(block, layout); @@ -535,7 +535,7 @@ static uiBut *ui_item_with_label(uiLayout *layout, uiBlock *block, const char *n sub= uiLayoutRow(layout, 0); uiBlockSetCurLayout(block, sub); - if(name[0]) { + if (name[0]) { /* XXX UI_GetStringWidth is not accurate */ #if 0 labelw = UI_GetStringWidth(name); @@ -549,7 +549,7 @@ static uiBut *ui_item_with_label(uiLayout *layout, uiBlock *block, const char *n type= RNA_property_type(prop); subtype= RNA_property_subtype(prop); - if(subtype == PROP_FILEPATH || subtype == PROP_DIRPATH) { + if (subtype == PROP_FILEPATH || subtype == PROP_DIRPATH) { uiBlockSetCurLayout(block, uiLayoutRow(sub, 1)); uiDefAutoButR(block, ptr, prop, index, "", icon, x, y, w-UI_UNIT_X, h); @@ -559,11 +559,11 @@ static uiBut *ui_item_with_label(uiLayout *layout, uiBlock *block, const char *n "BUTTONS_OT_file_browse", WM_OP_INVOKE_DEFAULT, ICON_FILESEL, x, y, UI_UNIT_X, h, NULL); } - else if(flag & UI_ITEM_R_EVENT) { + else if (flag & UI_ITEM_R_EVENT) { uiDefButR_prop(block, KEYEVT, 0, name, x, y, w, h, ptr, prop, index, 0, 0, -1, -1, NULL); } - else if(flag & UI_ITEM_R_FULL_EVENT) { - if(RNA_struct_is_a(ptr->type, &RNA_KeyMapItem)) { + else if (flag & UI_ITEM_R_FULL_EVENT) { + if (RNA_struct_is_a(ptr->type, &RNA_KeyMapItem)) { char buf[128]; WM_keymap_item_to_string(ptr->data, buf, sizeof(buf)); @@ -590,16 +590,16 @@ void uiFileBrowseContextProperty(const bContext *C, PointerRNA *ptr, PropertyRNA memset(ptr, 0, sizeof(*ptr)); *prop= NULL; - if(!ar) + if (!ar) return; - for(block=ar->uiblocks.first; block; block=block->next) { - for(but=block->buttons.first; but; but= but->next) { + for (block=ar->uiblocks.first; block; block=block->next) { + for (but=block->buttons.first; but; but= but->next) { prevbut= but->prev; /* find the button before the active one */ - if((but->flag & UI_BUT_LAST_ACTIVE) && prevbut && prevbut->rnapoin.data) { - if(RNA_property_type(prevbut->rnaprop) == PROP_STRING) { + if ((but->flag & UI_BUT_LAST_ACTIVE) && prevbut && prevbut->rnapoin.data) { + if (RNA_property_type(prevbut->rnaprop) == PROP_STRING) { *ptr= prevbut->rnapoin; *prop= prevbut->rnaprop; return; @@ -620,7 +620,7 @@ static void ui_item_disabled(uiLayout *layout, const char *name) uiBlockSetCurLayout(block, layout); - if(!name) + if (!name) name= ""; w= ui_text_icon_width(layout, name, 0, 0); @@ -638,14 +638,14 @@ PointerRNA uiItemFullO_ptr(uiLayout *layout, wmOperatorType *ot, const char *nam uiBut *but; int w; - if(!name) { + if (!name) { if (ot && ot->srna) name = RNA_struct_ui_name(ot->srna); else name = ""; } - if(layout->root->type == UI_LAYOUT_MENU && !icon) + if (layout->root->type == UI_LAYOUT_MENU && !icon) icon= ICON_BLANK1; /* create button */ @@ -657,7 +657,7 @@ PointerRNA uiItemFullO_ptr(uiLayout *layout, wmOperatorType *ot, const char *nam uiBlockSetEmboss(block, UI_EMBOSSN); /* create the button */ - if(icon) { + if (icon) { if (name[0]) { but = uiDefIconTextButO_ptr(block, BUT, ot, context, icon, name, 0, 0, w, UI_UNIT_Y, NULL); } @@ -672,20 +672,20 @@ PointerRNA uiItemFullO_ptr(uiLayout *layout, wmOperatorType *ot, const char *nam assert(but->optype != NULL); /* text alignment for toolbar buttons */ - if((layout->root->type == UI_LAYOUT_TOOLBAR) && !icon) + if ((layout->root->type == UI_LAYOUT_TOOLBAR) && !icon) but->flag |= UI_TEXT_LEFT; if (flag & UI_ITEM_R_NO_BG) uiBlockSetEmboss(block, UI_EMBOSS); - if(layout->redalert) + if (layout->redalert) uiButSetFlag(but, UI_BUT_REDALERT); /* assign properties */ - if(properties || (flag & UI_ITEM_O_RETURN_PROPS)) { + if (properties || (flag & UI_ITEM_O_RETURN_PROPS)) { PointerRNA *opptr= uiButGetOperatorPtrRNA(but); - if(properties) { + if (properties) { opptr->data= properties; } else { @@ -733,7 +733,7 @@ static void uiItemEnumO_ptr__internal(uiLayout *layout, wmOperatorType *ot, cons WM_operator_properties_create_ptr(&ptr, ot); RNA_property_enum_set(&ptr, prop, value); - if(!name) + if (!name) name = ui_menu_enumpropname(layout, &ptr, prop, value); uiItemFullO_ptr(layout, ot, name, icon, ptr.data, layout->root->opcontext, 0); @@ -755,7 +755,7 @@ void uiItemEnumO_ptr(uiLayout *layout, wmOperatorType *ot, const char *name, int RNA_property_enum_set(&ptr, prop, value); - if(!name) + if (!name) name = ui_menu_enumpropname(layout, &ptr, prop, value); uiItemFullO_ptr(layout, ot, name, icon, ptr.data, layout->root->opcontext, 0); @@ -764,7 +764,7 @@ void uiItemEnumO(uiLayout *layout, const char *opname, const char *name, int ico { wmOperatorType *ot = WM_operatortype_find(opname, 0); /* print error next */ - if(ot) { + if (ot) { uiItemEnumO_ptr(layout, ot, name, icon, propname, value); } else { @@ -783,7 +783,7 @@ void uiItemsFullEnumO(uiLayout *layout, const char *opname, const char *propname uiBut *bt; uiBlock *block= layout->root->block; - if(!ot || !ot->srna) { + if (!ot || !ot->srna) { ui_item_disabled(layout, opname); RNA_warning("%s '%s'", ot ? "unknown operator" : "operator missing srna", opname); return; @@ -795,7 +795,7 @@ void uiItemsFullEnumO(uiLayout *layout, const char *opname, const char *propname /* don't let bad properties slip through */ BLI_assert((prop == NULL) || (RNA_property_type(prop) == PROP_ENUM)); - if(prop && RNA_property_type(prop) == PROP_ENUM) { + if (prop && RNA_property_type(prop) == PROP_ENUM) { EnumPropertyItem *item; int totitem, i, free; uiLayout *split= uiLayoutSplit(layout, 0, 0); @@ -803,13 +803,13 @@ void uiItemsFullEnumO(uiLayout *layout, const char *opname, const char *propname RNA_property_enum_items_gettexted(block->evil_C, &ptr, prop, &item, &totitem, &free); - for(i=0; iflag |= UI_BLOCK_NO_FLIP; @@ -873,7 +873,7 @@ void uiItemEnumO_value(uiLayout *layout, const char *name, int icon, const char RNA_property_enum_set(&ptr, prop, value); /* same as uiItemEnumO */ - if(!name) + if (!name) name = ui_menu_enumpropname(layout, &ptr, prop, value); uiItemFullO_ptr(layout, ot, name, icon, ptr.data, layout->root->opcontext, 0); @@ -893,10 +893,10 @@ void uiItemEnumO_string(uiLayout *layout, const char *name, int icon, const char WM_operator_properties_create_ptr(&ptr, ot); /* enum lookup */ - if((prop= RNA_struct_find_property(&ptr, propname))) { + if ((prop= RNA_struct_find_property(&ptr, propname))) { RNA_property_enum_items_gettexted(layout->root->block->evil_C, &ptr, prop, &item, NULL, &free); - if(item==NULL || RNA_enum_value_from_id(item, value_str, &value)==0) { - if(free) { + if (item==NULL || RNA_enum_value_from_id(item, value_str, &value)==0) { + if (free) { MEM_freeN(item); } RNA_warning("%s.%s, enum %s not found", RNA_struct_identifier(ptr.type), propname, value_str); @@ -915,7 +915,7 @@ void uiItemEnumO_string(uiLayout *layout, const char *name, int icon, const char RNA_property_enum_set(&ptr, prop, value); /* same as uiItemEnumO */ - if(!name) + if (!name) name = ui_menu_enumpropname(layout, &ptr, prop, value); uiItemFullO_ptr(layout, ot, name, icon, ptr.data, layout->root->opcontext, 0); @@ -991,32 +991,32 @@ static void ui_item_rna_size(uiLayout *layout, const char *name, int icon, Point subtype= RNA_property_subtype(prop); len= RNA_property_array_length(ptr, prop); - if(ELEM3(type, PROP_STRING, PROP_POINTER, PROP_ENUM) && !name[0] && !icon_only) + if (ELEM3(type, PROP_STRING, PROP_POINTER, PROP_ENUM) && !name[0] && !icon_only) name= "non-empty text"; - else if(type == PROP_BOOLEAN && !name[0] && !icon_only) + else if (type == PROP_BOOLEAN && !name[0] && !icon_only) icon= ICON_DOT; w= ui_text_icon_width(layout, name, icon, 0); h= UI_UNIT_Y; /* increase height for arrays */ - if(index == RNA_NO_INDEX && len > 0) { - if(!name[0] && icon == ICON_NONE) + if (index == RNA_NO_INDEX && len > 0) { + if (!name[0] && icon == ICON_NONE) h= 0; - if(ELEM(subtype, PROP_LAYER, PROP_LAYER_MEMBER)) + if (ELEM(subtype, PROP_LAYER, PROP_LAYER_MEMBER)) h += 2*UI_UNIT_Y; - else if(subtype == PROP_MATRIX) + else if (subtype == PROP_MATRIX) h += ceil(sqrt(len))*UI_UNIT_Y; else h += len*UI_UNIT_Y; } - else if(ui_layout_vary_direction(layout) == UI_ITEM_VARY_X) { - if(type == PROP_BOOLEAN && name[0]) + else if (ui_layout_vary_direction(layout) == UI_ITEM_VARY_X) { + if (type == PROP_BOOLEAN && name[0]) w += UI_UNIT_X/5; - else if(type == PROP_ENUM) + else if (type == PROP_ENUM) w += UI_UNIT_X/4; - else if(type == PROP_FLOAT || type == PROP_INT) + else if (type == PROP_FLOAT || type == PROP_INT) w += UI_UNIT_X*3; } @@ -1040,26 +1040,26 @@ void uiItemFullR(uiLayout *layout, PointerRNA *ptr, PropertyRNA *prop, int index len= (is_array) ? RNA_property_array_length(ptr, prop) : 0; /* set name and icon */ - if(!name) + if (!name) name= RNA_property_ui_name(prop); - if(icon == ICON_NONE) + if (icon == ICON_NONE) icon= RNA_property_ui_icon(prop); - if(ELEM4(type, PROP_INT, PROP_FLOAT, PROP_STRING, PROP_POINTER)) + if (ELEM4(type, PROP_INT, PROP_FLOAT, PROP_STRING, PROP_POINTER)) name= ui_item_name_add_colon(name, namestr); - else if(type == PROP_BOOLEAN && is_array && index == RNA_NO_INDEX) + else if (type == PROP_BOOLEAN && is_array && index == RNA_NO_INDEX) name= ui_item_name_add_colon(name, namestr); - else if(type == PROP_ENUM && index != RNA_ENUM_VALUE) + else if (type == PROP_ENUM && index != RNA_ENUM_VALUE) name= ui_item_name_add_colon(name, namestr); - if(layout->root->type == UI_LAYOUT_MENU) { - if(type == PROP_BOOLEAN && ((is_array == FALSE) || (index != RNA_NO_INDEX))) { - if(is_array) icon= (RNA_property_boolean_get_index(ptr, prop, index)) ? ICON_CHECKBOX_HLT: ICON_CHECKBOX_DEHLT; + if (layout->root->type == UI_LAYOUT_MENU) { + if (type == PROP_BOOLEAN && ((is_array == FALSE) || (index != RNA_NO_INDEX))) { + if (is_array) icon= (RNA_property_boolean_get_index(ptr, prop, index)) ? ICON_CHECKBOX_HLT: ICON_CHECKBOX_DEHLT; else icon= (RNA_property_boolean_get(ptr, prop)) ? ICON_CHECKBOX_HLT: ICON_CHECKBOX_DEHLT; } - else if(type == PROP_ENUM && index == RNA_ENUM_VALUE) { + else if (type == PROP_ENUM && index == RNA_ENUM_VALUE) { int enum_value= RNA_property_enum_get(ptr, prop); - if(RNA_property_flag(prop) & PROP_ENUM_FLAG) { + if (RNA_property_flag(prop) & PROP_ENUM_FLAG) { icon= (enum_value & value)? ICON_CHECKBOX_HLT: ICON_CHECKBOX_DEHLT; } else { @@ -1081,39 +1081,39 @@ void uiItemFullR(uiLayout *layout, PointerRNA *ptr, PropertyRNA *prop, int index uiBlockSetEmboss(block, UI_EMBOSSN); /* array property */ - if(index == RNA_NO_INDEX && is_array) + if (index == RNA_NO_INDEX && is_array) ui_item_array(layout, block, name, icon, ptr, prop, len, 0, 0, w, h, expand, slider, toggle, icon_only); /* enum item */ - else if(type == PROP_ENUM && index == RNA_ENUM_VALUE) { - if(icon && name[0] && !icon_only) + else if (type == PROP_ENUM && index == RNA_ENUM_VALUE) { + if (icon && name[0] && !icon_only) uiDefIconTextButR_prop(block, ROW, 0, icon, name, 0, 0, w, h, ptr, prop, -1, 0, value, -1, -1, NULL); - else if(icon) + else if (icon) uiDefIconButR_prop(block, ROW, 0, icon, 0, 0, w, h, ptr, prop, -1, 0, value, -1, -1, NULL); else uiDefButR_prop(block, ROW, 0, name, 0, 0, w, h, ptr, prop, -1, 0, value, -1, -1, NULL); } /* expanded enum */ - else if(type == PROP_ENUM && (expand || RNA_property_flag(prop) & PROP_ENUM_FLAG)) + else if (type == PROP_ENUM && (expand || RNA_property_flag(prop) & PROP_ENUM_FLAG)) ui_item_enum_expand(layout, block, ptr, prop, name, h, icon_only); /* property with separate label */ - else if(type == PROP_ENUM || type == PROP_STRING || type == PROP_POINTER) { + else if (type == PROP_ENUM || type == PROP_STRING || type == PROP_POINTER) { but= ui_item_with_label(layout, block, name, icon, ptr, prop, index, 0, 0, w, h, flag); ui_but_add_search(but, ptr, prop, NULL, NULL); - if(layout->redalert) + if (layout->redalert) uiButSetFlag(but, UI_BUT_REDALERT); } /* single button */ else { but = uiDefAutoButR(block, ptr, prop, index, name, icon, 0, 0, w, h); - if(slider && but->type==NUM) + if (slider && but->type==NUM) but->type= NUMSLI; - if(toggle && but->type==OPTION) + if (toggle && but->type==OPTION) but->type= TOG; - if(layout->redalert) + if (layout->redalert) uiButSetFlag(but, UI_BUT_REDALERT); } @@ -1125,7 +1125,7 @@ void uiItemR(uiLayout *layout, PointerRNA *ptr, const char *propname, int flag, { PropertyRNA *prop= RNA_struct_find_property(ptr, propname); - if(!prop) { + if (!prop) { ui_item_disabled(layout, propname); RNA_warning("property not found: %s.%s", RNA_struct_identifier(ptr->type), propname); return; @@ -1138,7 +1138,7 @@ void uiItemEnumR(uiLayout *layout, const char *name, int icon, struct PointerRNA { PropertyRNA *prop= RNA_struct_find_property(ptr, propname); - if(!prop || RNA_property_type(prop) != PROP_ENUM) { + if (!prop || RNA_property_type(prop) != PROP_ENUM) { ui_item_disabled(layout, propname); RNA_warning("property not found: %s.%s", RNA_struct_identifier(ptr->type), propname); return; @@ -1153,7 +1153,7 @@ void uiItemEnumR_string(uiLayout *layout, struct PointerRNA *ptr, const char *pr EnumPropertyItem *item; int ivalue, a, free; - if(!prop || RNA_property_type(prop) != PROP_ENUM) { + if (!prop || RNA_property_type(prop) != PROP_ENUM) { ui_item_disabled(layout, propname); RNA_warning("enum property not found: %s.%s", RNA_struct_identifier(ptr->type), propname); return; @@ -1161,7 +1161,7 @@ void uiItemEnumR_string(uiLayout *layout, struct PointerRNA *ptr, const char *pr RNA_property_enum_items_gettexted(layout->root->block->evil_C, ptr, prop, &item, NULL, &free); - if(!RNA_enum_value_from_id(item, value, &ivalue)) { + if (!RNA_enum_value_from_id(item, value, &ivalue)) { if (free) { MEM_freeN(item); } @@ -1170,8 +1170,8 @@ void uiItemEnumR_string(uiLayout *layout, struct PointerRNA *ptr, const char *pr return; } - for(a=0; item[a].identifier; a++) { - if(item[a].value == ivalue) { + for (a=0; item[a].identifier; a++) { + if (item[a].value == ivalue) { uiItemFullR(layout, ptr, prop, RNA_ENUM_VALUE, ivalue, 0, name ? name : item[a].name, icon ? icon : item[a].icon); break; } @@ -1190,13 +1190,13 @@ void uiItemsEnumR(uiLayout *layout, struct PointerRNA *ptr, const char *propname prop= RNA_struct_find_property(ptr, propname); - if(!prop) { + if (!prop) { ui_item_disabled(layout, propname); RNA_warning("enum property not found: %s.%s", RNA_struct_identifier(ptr->type), propname); return; } - if(RNA_property_type(prop) != PROP_ENUM) { + if (RNA_property_type(prop) != PROP_ENUM) { RNA_warning("not an enum property: %s.%s", RNA_struct_identifier(ptr->type), propname); return; } @@ -1208,13 +1208,13 @@ void uiItemsEnumR(uiLayout *layout, struct PointerRNA *ptr, const char *propname RNA_property_enum_items_gettexted(block->evil_C, ptr, prop, &item, &totitem, &free); - for(i=0; iflag |= UI_BLOCK_NO_FLIP; @@ -1266,17 +1266,17 @@ static void rna_search_cb(const struct bContext *C, void *arg_but, const char *s /* build a temporary list of relevant items first */ RNA_PROP_BEGIN(&but->rnasearchpoin, itemptr, but->rnasearchprop) { - if(flag & PROP_ID_SELF_CHECK) - if(itemptr.data == but->rnapoin.id.data) + if (flag & PROP_ID_SELF_CHECK) + if (itemptr.data == but->rnapoin.id.data) continue; /* use filter */ - if(RNA_property_type(but->rnaprop)==PROP_POINTER) { - if(RNA_property_pointer_poll(&but->rnapoin, but->rnaprop, &itemptr)==0) + if (RNA_property_type(but->rnaprop)==PROP_POINTER) { + if (RNA_property_pointer_poll(&but->rnapoin, but->rnaprop, &itemptr)==0) continue; } - if(itemptr.type && RNA_struct_is_ID(itemptr.type)) { + if (itemptr.type && RNA_struct_is_ID(itemptr.type)) { ID *id= itemptr.data; char name_ui[MAX_ID_NAME]; @@ -1293,8 +1293,8 @@ static void rna_search_cb(const struct bContext *C, void *arg_but, const char *s iconid = 0; } - if(name) { - if(skip_filter || BLI_strcasestr(name, str)) { + if (name) { + if (skip_filter || BLI_strcasestr(name, str)) { cis = MEM_callocN(sizeof(CollItemSearch), "CollectionItemSearch"); cis->name = MEM_dupallocN(name); cis->index = i; @@ -1335,10 +1335,10 @@ static void search_id_collection(StructRNA *ptype, PointerRNA *ptr, PropertyRNA RNA_STRUCT_BEGIN(ptr, iprop) { /* if it's a collection and has same pointer type, we've got it */ - if(RNA_property_type(iprop) == PROP_COLLECTION) { + if (RNA_property_type(iprop) == PROP_COLLECTION) { srna= RNA_property_pointer_type(ptr, iprop); - if(ptype == srna) { + if (ptype == srna) { *prop= iprop; break; } @@ -1353,8 +1353,8 @@ void ui_but_add_search(uiBut *but, PointerRNA *ptr, PropertyRNA *prop, PointerRN PointerRNA sptr; /* for ID's we do automatic lookup */ - if(!searchprop) { - if(RNA_property_type(prop) == PROP_POINTER) { + if (!searchprop) { + if (RNA_property_type(prop) == PROP_POINTER) { ptype= RNA_property_pointer_type(ptr, prop); search_id_collection(ptype, &sptr, &searchprop); searchptr= &sptr; @@ -1362,7 +1362,7 @@ void ui_but_add_search(uiBut *but, PointerRNA *ptr, PropertyRNA *prop, PointerRN } /* turn button into search button */ - if(searchprop) { + if (searchprop) { but->type= SEARCH_MENU; but->hardmax= MAX2(but->hardmax, 256); but->rnasearchpoin= *searchptr; @@ -1385,13 +1385,13 @@ void uiItemPointerR(uiLayout *layout, struct PointerRNA *ptr, const char *propna /* validate arguments */ prop= RNA_struct_find_property(ptr, propname); - if(!prop) { + if (!prop) { RNA_warning("property not found: %s.%s", RNA_struct_identifier(ptr->type), propname); return; } type= RNA_property_type(prop); - if(!ELEM(type, PROP_POINTER, PROP_STRING)) { + if (!ELEM(type, PROP_POINTER, PROP_STRING)) { RNA_warning("Property %s must be a pointer or string", propname); return; } @@ -1399,7 +1399,7 @@ void uiItemPointerR(uiLayout *layout, struct PointerRNA *ptr, const char *propna searchprop= RNA_struct_find_property(searchptr, searchpropname); - if(!searchprop) { + if (!searchprop) { RNA_warning("search collection property not found: %s.%s", RNA_struct_identifier(ptr->type), searchpropname); return; } @@ -1409,15 +1409,15 @@ void uiItemPointerR(uiLayout *layout, struct PointerRNA *ptr, const char *propna } /* get icon & name */ - if(icon==ICON_NONE) { - if(type == PROP_POINTER) + if (icon==ICON_NONE) { + if (type == PROP_POINTER) icontype= RNA_property_pointer_type(ptr, prop); else icontype= RNA_property_pointer_type(searchptr, searchprop); icon= RNA_struct_ui_icon(icontype); } - if(!name) + if (!name) name= RNA_property_ui_name(prop); /* create button */ @@ -1448,35 +1448,35 @@ static void ui_item_menu(uiLayout *layout, const char *name, int icon, uiMenuCre uiBlockSetCurLayout(block, layout); - if(layout->root->type == UI_LAYOUT_HEADER) + if (layout->root->type == UI_LAYOUT_HEADER) uiBlockSetEmboss(block, UI_EMBOSS); - if(!name) + if (!name) name= ""; - if(layout->root->type == UI_LAYOUT_MENU && !icon) + if (layout->root->type == UI_LAYOUT_MENU && !icon) icon= ICON_BLANK1; w= ui_text_icon_width(layout, name, icon, 1); h= UI_UNIT_Y; - if(layout->root->type == UI_LAYOUT_HEADER) /* ugly .. */ + if (layout->root->type == UI_LAYOUT_HEADER) /* ugly .. */ w -= 10; - if(name[0] && icon) + if (name[0] && icon) but = uiDefIconTextMenuBut(block, func, arg, icon, name, 0, 0, w, h, tip); - else if(icon) + else if (icon) but = uiDefIconMenuBut(block, func, arg, icon, 0, 0, w, h, tip); else but = uiDefMenuBut(block, func, arg, name, 0, 0, w, h, tip); - if(argN) { /* ugly .. */ + if (argN) { /* ugly .. */ but->poin= (char*)but; but->func_argN= argN; } - if(layout->root->type == UI_LAYOUT_HEADER) + if (layout->root->type == UI_LAYOUT_HEADER) uiBlockSetEmboss(block, UI_EMBOSS); - else if(ELEM(layout->root->type, UI_LAYOUT_PANEL, UI_LAYOUT_TOOLBAR)) { + else if (ELEM(layout->root->type, UI_LAYOUT_PANEL, UI_LAYOUT_TOOLBAR)) { but->type= MENU; but->flag |= UI_TEXT_LEFT; } @@ -1488,16 +1488,16 @@ void uiItemM(uiLayout *layout, bContext *UNUSED(C), const char *menuname, const mt = WM_menutype_find(menuname, FALSE); - if(mt==NULL) { + if (mt==NULL) { RNA_warning("not found %s", menuname); return; } - if(!name) { + if (!name) { name = IFACE_(mt->label); } - if(layout->root->type == UI_LAYOUT_MENU && !icon) + if (layout->root->type == UI_LAYOUT_MENU && !icon) icon= ICON_BLANK1; ui_item_menu(layout, name, icon, ui_item_menutype_func, mt, NULL, mt->description); @@ -1512,16 +1512,16 @@ static uiBut *uiItemL_(uiLayout *layout, const char *name, int icon) uiBlockSetCurLayout(block, layout); - if(!name) + if (!name) name= ""; - if(layout->root->type == UI_LAYOUT_MENU && !icon) + if (layout->root->type == UI_LAYOUT_MENU && !icon) icon= ICON_BLANK1; w= ui_text_icon_width(layout, name, icon, 0); - if(icon && name[0]) + if (icon && name[0]) but = uiDefIconTextBut(block, LABEL, 0, icon, name, 0, 0, w, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, ""); - else if(icon) + else if (icon) but = uiDefIconBut(block, LABEL, 0, icon, 0, 0, w, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, ""); else but = uiDefBut(block, LABEL, 0, name, 0, 0, w, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, ""); @@ -1538,8 +1538,8 @@ void uiItemLDrag(uiLayout *layout, PointerRNA *ptr, const char *name, int icon) { uiBut *but= uiItemL_(layout, name, icon); - if(ptr && ptr->type) - if(RNA_struct_is_ID(ptr->type)) + if (ptr && ptr->type) + if (RNA_struct_is_ID(ptr->type)) uiButSetDragID(but, ptr->id.data); } @@ -1554,16 +1554,16 @@ void uiItemV(uiLayout *layout, const char *name, int icon, int argval) uiBlockSetCurLayout(block, layout); - if(!name) + if (!name) name= ""; - if(layout->root->type == UI_LAYOUT_MENU && !icon) + if (layout->root->type == UI_LAYOUT_MENU && !icon) icon= ICON_BLANK1; w= ui_text_icon_width(layout, name, icon, 0); - if(icon && name[0]) + if (icon && name[0]) uiDefIconTextButF(block, BUT, argval, icon, name, 0, 0, w, UI_UNIT_Y, retvalue, 0.0, 0.0, 0, 0, ""); - else if(icon) + else if (icon) uiDefIconButF(block, BUT, argval, icon, 0, 0, w, UI_UNIT_Y, retvalue, 0.0, 0.0, 0, 0, ""); else uiDefButF(block, BUT, argval, name, 0, 0, w, UI_UNIT_Y, retvalue, 0.0, 0.0, 0, 0, ""); @@ -1581,7 +1581,7 @@ void uiItemS(uiLayout *layout) /* level items */ void uiItemMenuF(uiLayout *layout, const char *name, int icon, uiMenuCreateFunc func, void *arg) { - if(!func) + if (!func) return; ui_item_menu(layout, name, icon, func, arg, NULL, ""); @@ -1611,15 +1611,15 @@ void uiItemMenuEnumO(uiLayout *layout, const char *opname, const char *propname, UI_OPERATOR_ERROR_RET(ot, opname, return); - if(!ot->srna) { + if (!ot->srna) { ui_item_disabled(layout, opname); RNA_warning("operator missing srna '%s'", opname); return; } - if(!name) + if (!name) name= ot->name; - if(layout->root->type == UI_LAYOUT_MENU && !icon) + if (layout->root->type == UI_LAYOUT_MENU && !icon) icon= ICON_BLANK1; lvl= MEM_callocN(sizeof(MenuItemLevel), "MenuItemLevel"); @@ -1644,15 +1644,15 @@ void uiItemMenuEnumR(uiLayout *layout, struct PointerRNA *ptr, const char *propn PropertyRNA *prop; prop= RNA_struct_find_property(ptr, propname); - if(!prop) { + if (!prop) { ui_item_disabled(layout, propname); RNA_warning("property not found: %s.%s", RNA_struct_identifier(ptr->type), propname); return; } - if(!name) + if (!name) name= RNA_property_ui_name(prop); - if(layout->root->type == UI_LAYOUT_MENU && !icon) + if (layout->root->type == UI_LAYOUT_MENU && !icon) icon= ICON_BLANK1; lvl= MEM_callocN(sizeof(MenuItemLevel), "MenuItemLevel"); @@ -1674,13 +1674,13 @@ static void ui_litem_estimate_row(uiLayout *litem) litem->w= 0; litem->h= 0; - for(item=litem->items.first; item; item=item->next) { + for (item=litem->items.first; item; item=item->next) { ui_item_size(item, &itemw, &itemh); litem->w += itemw; litem->h= MAX2(itemh, litem->h); - if(item->next) + if (item->next) litem->w += litem->space; } } @@ -1702,16 +1702,16 @@ static void ui_litem_layout_row(uiLayout *litem) totw= 0; tot= 0; - for(item=litem->items.first; item; item=item->next) { + for (item=litem->items.first; item; item=item->next) { ui_item_size(item, &itemw, &itemh); totw += itemw; tot++; } - if(totw == 0) + if (totw == 0) return; - if(w != 0) + if (w != 0) w -= (tot-1)*litem->space; fixedw= 0; @@ -1721,21 +1721,21 @@ static void ui_litem_layout_row(uiLayout *litem) x= 0; flag= 0; - for(item=litem->items.first; item; item=item->next) { - if(item->flag) + for (item=litem->items.first; item; item=item->next) { + if (item->flag) continue; ui_item_size(item, &itemw, &itemh); minw= ui_litem_min_width(itemw); - if(w - lastw > 0) + if (w - lastw > 0) neww= ui_item_fit(itemw, x, totw, w-lastw, !item->next, litem->alignment, NULL); else neww= 0; /* no space left, all will need clamping to minimum size */ x += neww; - if((neww < minw || itemw == minw) && w != 0) { + if ((neww < minw || itemw == minw) && w != 0) { /* fixed size */ item->flag= 1; fixedw += minw; @@ -1750,17 +1750,17 @@ static void ui_litem_layout_row(uiLayout *litem) } lastw= fixedw; - } while(flag); + } while (flag); freex= 0; fixedx= 0; x= litem->x; - for(item=litem->items.first; item; item=item->next) { + for (item=litem->items.first; item; item=item->next) { ui_item_size(item, &itemw, &itemh); minw= ui_litem_min_width(itemw); - if(item->flag) { + if (item->flag) { /* fixed minimum size items */ itemw= ui_item_fit(minw, fixedx, fixedw, MIN2(w, fixedw), !item->next, litem->alignment, NULL); fixedx += itemw; @@ -1773,12 +1773,12 @@ static void ui_litem_layout_row(uiLayout *litem) /* align right/center */ offset= 0; - if(litem->alignment == UI_LAYOUT_ALIGN_RIGHT) { - if(freew > 0 && freew < w-fixedw) + if (litem->alignment == UI_LAYOUT_ALIGN_RIGHT) { + if (freew > 0 && freew < w-fixedw) offset= (w - fixedw) - freew; } - else if(litem->alignment == UI_LAYOUT_ALIGN_CENTER) { - if(freew > 0 && freew < w-fixedw) + else if (litem->alignment == UI_LAYOUT_ALIGN_CENTER) { + if (freew > 0 && freew < w-fixedw) offset= ((w - fixedw) - freew)/2; } @@ -1786,7 +1786,7 @@ static void ui_litem_layout_row(uiLayout *litem) ui_item_position(item, x+offset, y-itemh, itemw, itemh); x += itemw; - if(item->next) + if (item->next) x += litem->space; } @@ -1805,13 +1805,13 @@ static void ui_litem_estimate_column(uiLayout *litem) litem->w= 0; litem->h= 0; - for(item=litem->items.first; item; item=item->next) { + for (item=litem->items.first; item; item=item->next) { ui_item_size(item, &itemw, &itemh); litem->w= MAX2(litem->w, itemw); litem->h += itemh; - if(item->next) + if (item->next) litem->h += litem->space; } } @@ -1824,13 +1824,13 @@ static void ui_litem_layout_column(uiLayout *litem) x= litem->x; y= litem->y; - for(item=litem->items.first; item; item=item->next) { + for (item=litem->items.first; item; item=item->next) { ui_item_size(item, NULL, &itemh); y -= itemh; ui_item_position(item, x, y, litem->w, itemh); - if(item->next) + if (item->next) y -= litem->space; } @@ -1847,7 +1847,7 @@ static void ui_litem_estimate_root(uiLayout *UNUSED(litem)) static void ui_litem_layout_root(uiLayout *litem) { - if(litem->root->type == UI_LAYOUT_HEADER) + if (litem->root->type == UI_LAYOUT_HEADER) ui_litem_layout_row(litem); else ui_litem_layout_column(litem); @@ -1875,16 +1875,16 @@ static void ui_litem_layout_box(uiLayout *litem) litem->x += style->boxspace; - if(w != 0) litem->w -= 2*style->boxspace; - if(h != 0) litem->h -= 2*style->boxspace; + if (w != 0) litem->w -= 2*style->boxspace; + if (h != 0) litem->h -= 2*style->boxspace; ui_litem_layout_column(litem); litem->x -= style->boxspace; litem->y -= style->boxspace; - if(w != 0) litem->w += 2*style->boxspace; - if(h != 0) litem->h += style->boxspace; + if (w != 0) litem->w += 2*style->boxspace; + if (h != 0) litem->h += style->boxspace; /* roundbox around the sublayout */ but= box->roundbox; @@ -1906,16 +1906,16 @@ static void ui_litem_estimate_column_flow(uiLayout *litem) /* compute max needed width and total height */ toth= 0; totitem= 0; - for(item=litem->items.first; item; item=item->next) { + for (item=litem->items.first; item; item=item->next) { ui_item_size(item, &itemw, &itemh); maxw= MAX2(maxw, itemw); toth += itemh; totitem++; } - if(flow->number <= 0) { + if (flow->number <= 0) { /* auto compute number of columns, not very good */ - if(maxw == 0) { + if (maxw == 0) { flow->totcol= 1; return; } @@ -1937,7 +1937,7 @@ static void ui_litem_estimate_column_flow(uiLayout *litem) /* create column per column */ col= 0; - for(item=litem->items.first; item; item=item->next) { + for (item=litem->items.first; item; item=item->next) { ui_item_size(item, &itemw, &itemh); y -= itemh + style->buttonspacey; @@ -1946,7 +1946,7 @@ static void ui_litem_estimate_column_flow(uiLayout *litem) maxw= MAX2(itemw, maxw); /* decide to go to next one */ - if(col < flow->totcol-1 && emy <= -emh) { + if (col < flow->totcol-1 && emy <= -emh) { x += maxw + litem->space; maxw= 0; y= 0; @@ -1969,7 +1969,7 @@ static void ui_litem_layout_column_flow(uiLayout *litem) /* compute max needed width and total height */ toth= 0; totitem= 0; - for(item=litem->items.first; item; item=item->next) { + for (item=litem->items.first; item; item=item->next) { ui_item_size(item, &itemw, &itemh); toth += itemh; totitem++; @@ -1986,7 +1986,7 @@ static void ui_litem_layout_column_flow(uiLayout *litem) /* create column per column */ col= 0; - for(item=litem->items.first; item; item=item->next) { + for (item=litem->items.first; item; item=item->next) { ui_item_size(item, NULL, &itemh); itemw= ui_item_fit(1, x-litem->x, flow->totcol, w, col == flow->totcol-1, litem->alignment, &offset); @@ -1997,7 +1997,7 @@ static void ui_litem_layout_column_flow(uiLayout *litem) miny= MIN2(miny, y); /* decide to go to next one */ - if(col < flow->totcol-1 && emy <= -emh) { + if (col < flow->totcol-1 && emy <= -emh) { x += itemw + style->columnspace; y= litem->y; col++; @@ -2020,7 +2020,7 @@ static void ui_litem_estimate_absolute(uiLayout *litem) litem->w= 0; litem->h= 0; - for(item=litem->items.first; item; item=item->next) { + for (item=litem->items.first; item; item=item->next) { ui_item_offset(item, &itemx, &itemy); ui_item_size(item, &itemw, &itemh); @@ -2046,7 +2046,7 @@ static void ui_litem_layout_absolute(uiLayout *litem) totw= 0; toth= 0; - for(item=litem->items.first; item; item=item->next) { + for (item=litem->items.first; item; item=item->next) { ui_item_offset(item, &itemx, &itemy); ui_item_size(item, &itemw, &itemh); @@ -2060,25 +2060,25 @@ static void ui_litem_layout_absolute(uiLayout *litem) totw -= minx; toth -= miny; - if(litem->w && totw > 0) + if (litem->w && totw > 0) scalex= (float)litem->w/(float)totw; - if(litem->h && toth > 0) + if (litem->h && toth > 0) scaley= (float)litem->h/(float)toth; x= litem->x; y= litem->y - scaley*toth; - for(item=litem->items.first; item; item=item->next) { + for (item=litem->items.first; item; item=item->next) { ui_item_offset(item, &itemx, &itemy); ui_item_size(item, &itemw, &itemh); - if(scalex != 1.0f) { + if (scalex != 1.0f) { newx= (itemx - minx)*scalex; itemw= (itemx - minx + itemw)*scalex - newx; itemx= minx + newx; } - if(scaley != 1.0f) { + if (scaley != 1.0f) { newy= (itemy - miny)*scaley; itemh= (itemy - miny + itemh)*scaley - newy; itemy= miny + newy; @@ -2107,7 +2107,7 @@ static void ui_litem_layout_split(uiLayout *litem) const int tot= BLI_countlist(&litem->items); int itemh, x, y, w, colw=0; - if(tot == 0) + if (tot == 0) return; x= litem->x; @@ -2119,13 +2119,13 @@ static void ui_litem_layout_split(uiLayout *litem) colw= w*percentage; colw= MAX2(colw, 0); - for(item=litem->items.first; item; item=item->next) { + for (item=litem->items.first; item; item=item->next) { ui_item_size(item, NULL, &itemh); ui_item_position(item, x, y-itemh, colw, itemh); x += colw; - if(item->next) { + if (item->next) { colw= (w - (int)(w*percentage))/(tot-1); colw= MAX2(colw, 0); @@ -2148,7 +2148,7 @@ static void ui_litem_estimate_overlap(uiLayout *litem) litem->w= 0; litem->h= 0; - for(item=litem->items.first; item; item=item->next) { + for (item=litem->items.first; item; item=item->next) { ui_item_size(item, &itemw, &itemh); litem->w= MAX2(itemw, litem->w); @@ -2164,7 +2164,7 @@ static void ui_litem_layout_overlap(uiLayout *litem) x= litem->x; y= litem->y; - for(item=litem->items.first; item; item=item->next) { + for (item=litem->items.first; item; item=item->next) { ui_item_size(item, &itemw, &itemh); ui_item_position(item, x, y-itemh, litem->w, itemh); @@ -2424,16 +2424,16 @@ static void ui_item_scale(uiLayout *litem, float scale[2]) uiItem *item; int x, y, w, h; - for(item=litem->items.last; item; item=item->prev) { + for (item=litem->items.last; item; item=item->prev) { ui_item_size(item, &w, &h); ui_item_offset(item, &x, &y); - if(scale[0] != 0.0f) { + if (scale[0] != 0.0f) { x *= scale[0]; w *= scale[0]; } - if(scale[1] != 0.0f) { + if (scale[1] != 0.0f) { y *= scale[1]; h *= scale[1]; } @@ -2446,16 +2446,16 @@ static void ui_item_estimate(uiItem *item) { uiItem *subitem; - if(item->type != ITEM_BUTTON) { + if (item->type != ITEM_BUTTON) { uiLayout *litem= (uiLayout*)item; - for(subitem=litem->items.first; subitem; subitem=subitem->next) + for (subitem=litem->items.first; subitem; subitem=subitem->next) ui_item_estimate(subitem); - if(litem->items.first == NULL) + if (litem->items.first == NULL) return; - if(litem->scale[0] != 0.0f || litem->scale[1] != 0.0f) + if (litem->scale[0] != 0.0f || litem->scale[1] != 0.0f) ui_item_scale(litem, litem->scale); switch(litem->item.type) { @@ -2495,16 +2495,16 @@ static void ui_item_align(uiLayout *litem, short nr) uiButtonItem *bitem; uiLayoutItemBx *box; - for(item=litem->items.last; item; item=item->prev) { - if(item->type == ITEM_BUTTON) { + for (item=litem->items.last; item; item=item->prev) { + if (item->type == ITEM_BUTTON) { bitem= (uiButtonItem*)item; - if(ui_but_can_align(bitem->but)) - if(!bitem->but->alignnr) + if (ui_but_can_align(bitem->but)) + if (!bitem->but->alignnr) bitem->but->alignnr= nr; } - else if(item->type == ITEM_LAYOUT_ABSOLUTE); - else if(item->type == ITEM_LAYOUT_OVERLAP); - else if(item->type == ITEM_LAYOUT_BOX) { + else if (item->type == ITEM_LAYOUT_ABSOLUTE); + else if (item->type == ITEM_LAYOUT_OVERLAP); + else if (item->type == ITEM_LAYOUT_BOX) { box= (uiLayoutItemBx*)item; box->roundbox->alignnr= nr; BLI_remlink(&litem->root->block->buttons, box->roundbox); @@ -2520,8 +2520,8 @@ static void ui_item_flag(uiLayout *litem, int flag) uiItem *item; uiButtonItem *bitem; - for(item=litem->items.last; item; item=item->prev) { - if(item->type == ITEM_BUTTON) { + for (item=litem->items.last; item; item=item->prev) { + if (item->type == ITEM_BUTTON) { bitem= (uiButtonItem*)item; bitem->but->flag |= flag; } @@ -2534,17 +2534,17 @@ static void ui_item_layout(uiItem *item) { uiItem *subitem; - if(item->type != ITEM_BUTTON) { + if (item->type != ITEM_BUTTON) { uiLayout *litem= (uiLayout*)item; - if(litem->items.first == NULL) + if (litem->items.first == NULL) return; - if(litem->align) + if (litem->align) ui_item_align(litem, ++litem->root->block->alignnr); - if(!litem->active) + if (!litem->active) ui_item_flag(litem, UI_BUT_INACTIVE); - if(!litem->enabled) + if (!litem->enabled) ui_item_flag(litem, UI_BUT_DISABLED); switch(litem->item.type) { @@ -2576,31 +2576,31 @@ static void ui_item_layout(uiItem *item) break; } - for(subitem=litem->items.first; subitem; subitem=subitem->next) + for (subitem=litem->items.first; subitem; subitem=subitem->next) ui_item_layout(subitem); } } static void ui_layout_end(uiBlock *block, uiLayout *layout, int *x, int *y) { - if(layout->root->handlefunc) + if (layout->root->handlefunc) uiBlockSetHandleFunc(block, layout->root->handlefunc, layout->root->argv); ui_item_estimate(&layout->item); ui_item_layout(&layout->item); - if(x) *x= layout->x; - if(y) *y= layout->y; + if (x) *x= layout->x; + if (y) *y= layout->y; } static void ui_layout_free(uiLayout *layout) { uiItem *item, *next; - for(item=layout->items.first; item; item=next) { + for (item=layout->items.first; item; item=next) { next= item->next; - if(item->type == ITEM_BUTTON) + if (item->type == ITEM_BUTTON) MEM_freeN(item); else ui_layout_free((uiLayout*)item); @@ -2631,10 +2631,10 @@ uiLayout *uiBlockLayout(uiBlock *block, int dir, int type, int x, int y, int siz layout->enabled= 1; layout->context= NULL; - if(type == UI_LAYOUT_MENU) + if (type == UI_LAYOUT_MENU) layout->space= 0; - if(dir == UI_LAYOUT_HORIZONTAL) { + if (dir == UI_LAYOUT_HORIZONTAL) { layout->h= size; layout->root->emh= em*UI_UNIT_Y; } @@ -2675,7 +2675,7 @@ void ui_layout_add_but(uiLayout *layout, uiBut *but) bitem->but= but; BLI_addtail(&layout->items, bitem); - if(layout->context) { + if (layout->context) { but->context= layout->context; but->context->used= 1; } @@ -2696,12 +2696,12 @@ void uiBlockLayoutResolve(uiBlock *block, int *x, int *y) { uiLayoutRoot *root; - if(x) *x= 0; - if(y) *y= 0; + if (x) *x= 0; + if (y) *y= 0; block->curlayout= NULL; - for(root=block->layouts.first; root; root=root->next) { + for (root=block->layouts.first; root; root=root->next) { /* NULL in advance so we don't interfere when adding button */ ui_layout_end(block, root->layout, x, y); ui_layout_free(root->layout); @@ -2733,13 +2733,13 @@ static void ui_intro_button(DynStr *ds, uiButtonItem *bitem) BLI_dynstr_appendf(ds, "'draw_string':'''%s''', ", but->drawstr); BLI_dynstr_appendf(ds, "'tip':'''%s''', ", but->tip ? but->tip : ""); // not exactly needed, rna has this - if(but->optype) { + if (but->optype) { char *opstr = WM_operator_pystring(but->block->evil_C, but->optype, but->opptr, 0); BLI_dynstr_appendf(ds, "'operator':'''%s''', ", opstr ? opstr : ""); MEM_freeN(opstr); } - if(but->rnaprop) { + if (but->rnaprop) { BLI_dynstr_appendf(ds, "'rna':'%s.%s[%d]', ", RNA_struct_identifier(but->rnapoin.type), RNA_property_identifier(but->rnaprop), but->rnaindex); } @@ -2751,7 +2751,7 @@ static void ui_intro_items(DynStr *ds, ListBase *lb) BLI_dynstr_append(ds, "["); - for(item=lb->first; item; item=item->next) { + for (item=lb->first; item; item=item->next) { BLI_dynstr_append(ds, "{"); @@ -2782,7 +2782,7 @@ static void ui_intro_items(DynStr *ds, ListBase *lb) BLI_dynstr_append(ds, "}"); - if(item != lb->last) + if (item != lb->last) BLI_dynstr_append(ds, ", "); } BLI_dynstr_append(ds, "], "); @@ -2818,24 +2818,24 @@ static void ui_layout_operator_buts__reset_cb(bContext *UNUSED(C), void *op_pt, /* this function does not initialize the layout, functions can be called on the layout before and after */ void uiLayoutOperatorButs(const bContext *C, uiLayout *layout, wmOperator *op,int (*check_prop)(struct PointerRNA *, struct PropertyRNA *), const char label_align, const short flag) { - if(!op->properties) { + if (!op->properties) { IDPropertyTemplate val = {0}; op->properties= IDP_New(IDP_GROUP, &val, "wmOperatorProperties"); } - if(flag & UI_LAYOUT_OP_SHOW_TITLE) { + if (flag & UI_LAYOUT_OP_SHOW_TITLE) { uiItemL(layout, op->type->name, ICON_NONE); } /* poll() on this operator may still fail, at the moment there is no nice feedback when this happens * just fails silently */ - if(!WM_operator_repeat_check(C, op)) { + if (!WM_operator_repeat_check(C, op)) { uiBlockSetButLock(uiLayoutGetBlock(layout), TRUE, "Operator cannot redo"); uiItemL(layout, "* Redo Unsupported *", ICON_NONE); // XXX, could give some nicer feedback or not show redo panel at all? } /* menu */ - if(op->type->flag & OPTYPE_PRESET) { + if (op->type->flag & OPTYPE_PRESET) { /* XXX, no simple way to get WM_MT_operator_presets.bl_label from python! Label remains the same always! */ PointerRNA op_ptr; uiLayout *row; @@ -2855,7 +2855,7 @@ void uiLayoutOperatorButs(const bContext *C, uiLayout *layout, wmOperator *op,in op_ptr= uiItemFullO(row, "WM_OT_operator_preset_add", "", ICON_ZOOMOUT, op_ptr.data, WM_OP_INVOKE_DEFAULT, 0); } - if(op->type->ui) { + if (op->type->ui) { op->layout= layout; op->type->ui((bContext*)C, op); op->layout= NULL; @@ -2872,7 +2872,7 @@ void uiLayoutOperatorButs(const bContext *C, uiLayout *layout, wmOperator *op,in /* main draw call */ empty= uiDefAutoButsRNA(layout, &ptr, check_prop, label_align) == 0; - if(empty && (flag & UI_LAYOUT_OP_SHOW_EMPTY)) { + if (empty && (flag & UI_LAYOUT_OP_SHOW_EMPTY)) { uiItemL(layout, IFACE_("No Properties"), ICON_NONE); } } @@ -2896,7 +2896,7 @@ void uiLayoutOperatorButs(const bContext *C, uiLayout *layout, wmOperator *op,in { uiBut *but; - for(but= uiLayoutGetBlock(layout)->buttons.first; but; but= but->next) { + for (but= uiLayoutGetBlock(layout)->buttons.first; but; but= but->next) { /* no undo for buttons for operator redo panels */ uiButClearFlag(but, UI_BUT_UNDO); @@ -2913,7 +2913,7 @@ void uiLayoutOperatorButs(const bContext *C, uiLayout *layout, wmOperator *op,in /* this is a bit of a hack but best keep it in one place at least */ MenuType *uiButGetMenuType(uiBut *but) { - if(but->menu_create_func == ui_item_menutype_func) { + if (but->menu_create_func == ui_item_menutype_func) { return (MenuType *)but->poin; } else { diff --git a/source/blender/editors/interface/interface_ops.c b/source/blender/editors/interface/interface_ops.c index e389612507d..4e97a38fe25 100644 --- a/source/blender/editors/interface/interface_ops.c +++ b/source/blender/editors/interface/interface_ops.c @@ -89,7 +89,7 @@ static void eyedropper_exit(bContext *C, wmOperator *op) { WM_cursor_restore(CTX_wm_window(C)); - if(op->customdata) + if (op->customdata) MEM_freeN(op->customdata); op->customdata= NULL; } @@ -102,7 +102,7 @@ static int eyedropper_cancel(bContext *C, wmOperator *op) static void eyedropper_sample(bContext *C, Eyedropper *eye, int mx, int my) { - if(RNA_property_type(eye->prop) == PROP_FLOAT) { + if (RNA_property_type(eye->prop) == PROP_FLOAT) { Scene *scene = CTX_data_scene(C); const int color_manage = scene->r.color_mgt_flag & R_COLOR_MANAGEMENT; float col[4]; @@ -135,7 +135,7 @@ static int eyedropper_modal(bContext *C, wmOperator *op, wmEvent *event) case RIGHTMOUSE: return eyedropper_cancel(C, op); case LEFTMOUSE: - if(event->val==KM_RELEASE) { + if (event->val==KM_RELEASE) { eyedropper_sample(C, eye, event->x, event->y); eyedropper_exit(C, op); return OPERATOR_FINISHED; @@ -157,7 +157,8 @@ static int eyedropper_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event) WM_event_add_modal_handler(C, op); return OPERATOR_RUNNING_MODAL; - } else { + } + else { eyedropper_exit(C, op); return OPERATOR_CANCELLED; } @@ -175,7 +176,8 @@ static int eyedropper_exec (bContext *C, wmOperator *op) eyedropper_exit(C, op); return OPERATOR_FINISHED; - } else { + } + else { return OPERATOR_CANCELLED; } } @@ -296,7 +298,7 @@ static int reset_default_button_exec(bContext *C, wmOperator *op) /* if there is a valid property that is editable... */ if (ptr.data && prop && RNA_property_editable(&ptr, prop)) { - if(RNA_property_reset(&ptr, prop, (all)? -1: index)) { + if (RNA_property_reset(&ptr, prop, (all)? -1: index)) { /* perform updates required for this property */ RNA_property_update(C, &ptr, prop); @@ -310,9 +312,9 @@ static int reset_default_button_exec(bContext *C, wmOperator *op) /* Since we don't want to undo _all_ edits to settings, eg window * edits on the screen or on operator settings. * it might be better to move undo's inline - campbell */ - if(success) { + if (success) { ID *id= ptr.id.data; - if(id && ID_CHECK_UNDO(id)) { + if (id && ID_CHECK_UNDO(id)) { /* do nothing, go ahead with undo */ } else { @@ -346,13 +348,13 @@ static void UI_OT_reset_default_button(wmOperatorType *ot) static int copy_to_selected_list(bContext *C, PointerRNA *ptr, ListBase *lb) { - if(RNA_struct_is_a(ptr->type, &RNA_Object)) + if (RNA_struct_is_a(ptr->type, &RNA_Object)) *lb = CTX_data_collection_get(C, "selected_editable_objects"); - else if(RNA_struct_is_a(ptr->type, &RNA_EditBone)) + else if (RNA_struct_is_a(ptr->type, &RNA_EditBone)) *lb = CTX_data_collection_get(C, "selected_editable_bones"); - else if(RNA_struct_is_a(ptr->type, &RNA_PoseBone)) + else if (RNA_struct_is_a(ptr->type, &RNA_PoseBone)) *lb = CTX_data_collection_get(C, "selected_pose_bones"); - else if(RNA_struct_is_a(ptr->type, &RNA_Sequence)) + else if (RNA_struct_is_a(ptr->type, &RNA_Sequence)) *lb = CTX_data_collection_get(C, "selected_editable_sequences"); else return 0; @@ -372,9 +374,9 @@ static int copy_to_selected_button_poll(bContext *C) CollectionPointerLink *link; ListBase lb; - if(copy_to_selected_list(C, &ptr, &lb)) { - for(link= lb.first; link; link=link->next) - if(link->ptr.data != ptr.data && RNA_property_editable(&link->ptr, prop)) + if (copy_to_selected_list(C, &ptr, &lb)) { + for (link= lb.first; link; link=link->next) + if (link->ptr.data != ptr.data && RNA_property_editable(&link->ptr, prop)) success= 1; BLI_freelistN(&lb); @@ -399,10 +401,10 @@ static int copy_to_selected_button_exec(bContext *C, wmOperator *op) CollectionPointerLink *link; ListBase lb; - if(copy_to_selected_list(C, &ptr, &lb)) { - for(link= lb.first; link; link=link->next) { - if(link->ptr.data != ptr.data && RNA_property_editable(&link->ptr, prop)) { - if(RNA_property_copy(&link->ptr, &ptr, prop, (all)? -1: index)) { + if (copy_to_selected_list(C, &ptr, &lb)) { + for (link= lb.first; link; link=link->next) { + if (link->ptr.data != ptr.data && RNA_property_editable(&link->ptr, prop)) { + if (RNA_property_copy(&link->ptr, &ptr, prop, (all)? -1: index)) { RNA_property_update(C, &link->ptr, prop); success= 1; } @@ -536,7 +538,7 @@ static int ui_editsource_uibut_match(uiBut *but_a, uiBut *but_b) /* this just needs to be a 'good-enough' comparison so we can know beyond * reasonable doubt that these buttons are the same between redraws. * if this fails it only means edit-source fails - campbell */ - if( (but_a->x1 == but_b->x1) && + if ( (but_a->x1 == but_b->x1) && (but_a->x2 == but_b->x2) && (but_a->y1 == but_b->y1) && (but_a->y2 == but_b->y2) && @@ -609,7 +611,7 @@ static int editsource_text_edit(bContext *C, wmOperator *op, /* naughty!, find text area to set, not good behavior * but since this is a dev tool lets allow it - campbell */ ScrArea *sa= BKE_screen_find_big_area(CTX_wm_screen(C), SPACE_TEXT, 0); - if(sa) { + if (sa) { SpaceText *st= sa->spacedata.first; st->text= text; } @@ -647,7 +649,7 @@ static int editsource_exec(bContext *C, wmOperator *op) /* redraw and get active button python info */ ED_region_do_draw(C, ar); - for(BLI_ghashIterator_init(&ghi, ui_editsource_info->hash); + for (BLI_ghashIterator_init(&ghi, ui_editsource_info->hash); !BLI_ghashIterator_isDone(&ghi); BLI_ghashIterator_step(&ghi)) { diff --git a/source/blender/editors/interface/interface_panel.c b/source/blender/editors/interface/interface_panel.c index ffb8b0acf37..08c96aaf0fb 100644 --- a/source/blender/editors/interface/interface_panel.c +++ b/source/blender/editors/interface/interface_panel.c @@ -103,17 +103,17 @@ static void panel_activate_state(const bContext *C, Panel *pa, uiHandlePanelStat static int panel_aligned(ScrArea *sa, ARegion *ar) { - if(sa->spacetype==SPACE_BUTS && ar->regiontype == RGN_TYPE_WINDOW) { + if (sa->spacetype==SPACE_BUTS && ar->regiontype == RGN_TYPE_WINDOW) { SpaceButs *sbuts= sa->spacedata.first; return sbuts->align; } - else if(sa->spacetype==SPACE_USERPREF && ar->regiontype == RGN_TYPE_WINDOW) + else if (sa->spacetype==SPACE_USERPREF && ar->regiontype == RGN_TYPE_WINDOW) return BUT_VERTICAL; - else if(sa->spacetype==SPACE_FILE && ar->regiontype == RGN_TYPE_CHANNELS) + else if (sa->spacetype==SPACE_FILE && ar->regiontype == RGN_TYPE_CHANNELS) return BUT_VERTICAL; - else if(sa->spacetype==SPACE_IMAGE && ar->regiontype == RGN_TYPE_PREVIEW) + else if (sa->spacetype==SPACE_IMAGE && ar->regiontype == RGN_TYPE_PREVIEW) return BUT_VERTICAL; - else if(ELEM3(ar->regiontype, RGN_TYPE_UI, RGN_TYPE_TOOLS, RGN_TYPE_TOOL_PROPS)) + else if (ELEM3(ar->regiontype, RGN_TYPE_UI, RGN_TYPE_TOOLS, RGN_TYPE_TOOL_PROPS)) return BUT_VERTICAL; return 0; @@ -126,34 +126,34 @@ static int panels_re_align(ScrArea *sa, ARegion *ar, Panel **r_pa) *r_pa= NULL; - if(sa->spacetype==SPACE_BUTS && ar->regiontype == RGN_TYPE_WINDOW) { + if (sa->spacetype==SPACE_BUTS && ar->regiontype == RGN_TYPE_WINDOW) { SpaceButs *sbuts= sa->spacedata.first; - if(sbuts->align) - if(sbuts->re_align || sbuts->mainbo!=sbuts->mainb) + if (sbuts->align) + if (sbuts->re_align || sbuts->mainbo!=sbuts->mainb) return 1; } - else if(ar->regiontype==RGN_TYPE_UI) + else if (ar->regiontype==RGN_TYPE_UI) return 1; - else if(sa->spacetype==SPACE_IMAGE && ar->regiontype == RGN_TYPE_PREVIEW) + else if (sa->spacetype==SPACE_IMAGE && ar->regiontype == RGN_TYPE_PREVIEW) return 1; - else if(sa->spacetype==SPACE_FILE && ar->regiontype == RGN_TYPE_CHANNELS) + else if (sa->spacetype==SPACE_FILE && ar->regiontype == RGN_TYPE_CHANNELS) return 1; /* in case panel is added or disappears */ - for(pa=ar->panels.first; pa; pa=pa->next) { - if((pa->runtime_flag & PNL_WAS_ACTIVE) && !(pa->runtime_flag & PNL_ACTIVE)) + for (pa=ar->panels.first; pa; pa=pa->next) { + if ((pa->runtime_flag & PNL_WAS_ACTIVE) && !(pa->runtime_flag & PNL_ACTIVE)) return 1; - if(!(pa->runtime_flag & PNL_WAS_ACTIVE) && (pa->runtime_flag & PNL_ACTIVE)) + if (!(pa->runtime_flag & PNL_WAS_ACTIVE) && (pa->runtime_flag & PNL_ACTIVE)) return 1; - if(pa->activedata) + if (pa->activedata) active= 1; } /* in case we need to do an animation (size changes) */ - for(pa=ar->panels.first; pa; pa=pa->next) { - if(pa->runtime_flag & PNL_ANIM_ALIGN) { - if(!active) + for (pa=ar->panels.first; pa; pa=pa->next) { + if (pa->runtime_flag & PNL_ANIM_ALIGN) { + if (!active) *r_pa= pa; return 1; } @@ -183,14 +183,14 @@ Panel *uiBeginPanel(ScrArea *sa, ARegion *ar, uiBlock *block, PanelType *pt, int int align= panel_aligned(sa, ar); /* check if Panel exists, then use that one */ - for(pa=ar->panels.first; pa; pa=pa->next) - if(strncmp(pa->panelname, idname, UI_MAX_NAME_STR)==0) - if(strncmp(pa->tabname, tabname, UI_MAX_NAME_STR)==0) + for (pa=ar->panels.first; pa; pa=pa->next) + if (strncmp(pa->panelname, idname, UI_MAX_NAME_STR)==0) + if (strncmp(pa->tabname, tabname, UI_MAX_NAME_STR)==0) break; newpanel= (pa == NULL); - if(!newpanel) { + if (!newpanel) { pa->type= pt; } else { @@ -200,8 +200,8 @@ Panel *uiBeginPanel(ScrArea *sa, ARegion *ar, uiBlock *block, PanelType *pt, int BLI_strncpy(pa->panelname, idname, UI_MAX_NAME_STR); BLI_strncpy(pa->tabname, tabname, UI_MAX_NAME_STR); - if(pt->flag & PNL_DEFAULT_CLOSED) { - if(align == BUT_VERTICAL) + if (pt->flag & PNL_DEFAULT_CLOSED) { + if (align == BUT_VERTICAL) pa->flag |= PNL_CLOSEDY; else pa->flag |= PNL_CLOSEDX; @@ -216,11 +216,11 @@ Panel *uiBeginPanel(ScrArea *sa, ARegion *ar, uiBlock *block, PanelType *pt, int BLI_addtail(&ar->panels, pa); /* make new Panel tabbed? */ - if(hookname) { - for(patab= ar->panels.first; patab; patab= patab->next) { - if((patab->runtime_flag & PNL_ACTIVE) && patab->paneltab==NULL) { - if(strncmp(hookname, patab->panelname, UI_MAX_NAME_STR)==0) { - if(strncmp(tabname, patab->tabname, UI_MAX_NAME_STR)==0) { + if (hookname) { + for (patab= ar->panels.first; patab; patab= patab->next) { + if ((patab->runtime_flag & PNL_ACTIVE) && patab->paneltab==NULL) { + if (strncmp(hookname, patab->panelname, UI_MAX_NAME_STR)==0) { + if (strncmp(tabname, patab->tabname, UI_MAX_NAME_STR)==0) { pa->paneltab= patab; ui_panel_copy_offset(pa, patab); break; @@ -236,19 +236,19 @@ Panel *uiBeginPanel(ScrArea *sa, ARegion *ar, uiBlock *block, PanelType *pt, int /* if a new panel is added, we insert it right after the panel * that was last added. this way new panels are inserted in the * right place between versions */ - for(palast=ar->panels.first; palast; palast=palast->next) - if(palast->runtime_flag & PNL_LAST_ADDED) + for (palast=ar->panels.first; palast; palast=palast->next) + if (palast->runtime_flag & PNL_LAST_ADDED) break; - if(newpanel) { + if (newpanel) { pa->sortorder= (palast)? palast->sortorder+1: 0; - for(panext=ar->panels.first; panext; panext=panext->next) - if(panext != pa && panext->sortorder >= pa->sortorder) + for (panext=ar->panels.first; panext; panext=panext->next) + if (panext != pa && panext->sortorder >= pa->sortorder) panext->sortorder++; } - if(palast) + if (palast) palast->runtime_flag &= ~PNL_LAST_ADDED; /* assign to block */ @@ -257,8 +257,8 @@ Panel *uiBeginPanel(ScrArea *sa, ARegion *ar, uiBlock *block, PanelType *pt, int *open= 0; - if(pa->paneltab) return pa; - if(pa->flag & PNL_CLOSED) return pa; + if (pa->paneltab) return pa; + if (pa->flag & PNL_CLOSED) return pa; *open= 1; @@ -269,23 +269,23 @@ void uiEndPanel(uiBlock *block, int width, int height) { Panel *pa= block->panel; - if(pa->runtime_flag & PNL_NEW_ADDED) { + if (pa->runtime_flag & PNL_NEW_ADDED) { pa->runtime_flag &= ~PNL_NEW_ADDED; pa->sizex= width; pa->sizey= height; } else { /* check if we need to do an animation */ - if(!ELEM(width, 0, pa->sizex) || !ELEM(height, 0, pa->sizey)) { + if (!ELEM(width, 0, pa->sizex) || !ELEM(height, 0, pa->sizey)) { pa->runtime_flag |= PNL_ANIM_ALIGN; - if(height != 0) + if (height != 0) pa->ofsy += pa->sizey-height; } /* update width/height if non-zero */ - if(width != 0) + if (width != 0) pa->sizex= width; - if(height != 0) + if (height != 0) pa->sizey= height; } } @@ -301,7 +301,7 @@ static void ui_offset_panel_block(uiBlock *block) ofsy= block->panel->sizey - style->panelspace; - for(but= block->buttons.first; but; but=but->next) { + for (but= block->buttons.first; but; but=but->next) { but->y1 += ofsy; but->y2 += ofsy; } @@ -319,7 +319,7 @@ static void uiPanelPush(uiBlock *block) { glPushMatrix(); - if(block->panel) + if (block->panel) glTranslatef((float)block->panel->ofsx, (float)block->panel->ofsy, 0.0); } @@ -332,10 +332,10 @@ static void uiPanelPop(uiBlock *UNUSED(block)) /* triangle 'icon' for panel header */ void UI_DrawTriIcon(float x, float y, char dir) { - if(dir=='h') { + if (dir=='h') { ui_draw_anti_tria( x-3, y-5, x-3, y+5, x+7,y ); } - else if(dir=='t') { + else if (dir=='t') { ui_draw_anti_tria( x-5, y-7, x+5, y-7, x, y+3); } else { /* 'v' = vertical, down */ @@ -346,7 +346,7 @@ void UI_DrawTriIcon(float x, float y, char dir) /* triangle 'icon' inside rect */ static void ui_draw_tria_rect(rctf *rect, char dir) { - if(dir=='h') { + if (dir=='h') { float half= 0.5f*(rect->ymax - rect->ymin); ui_draw_anti_tria(rect->xmin, rect->ymin, rect->xmin, rect->ymax, rect->xmax, rect->ymin+half); } @@ -444,7 +444,7 @@ static void ui_draw_aligned_panel_header(uiStyle *style, uiBlock *block, rcti *r const char *activename = IFACE_(panel->drawname[0] ? panel->drawname : panel->panelname); /* + 0.001f to avoid flirting with float inaccuracy */ - if(panel->control & UI_PNL_CLOSE) pnl_icons=(panel->labelofs+2*PNL_ICON+5)/block->aspect + 0.001f; + if (panel->control & UI_PNL_CLOSE) pnl_icons=(panel->labelofs+2*PNL_ICON+5)/block->aspect + 0.001f; else pnl_icons= (panel->labelofs+PNL_ICON+5)/block->aspect + 0.001f; /* active tab */ @@ -452,7 +452,7 @@ static void ui_draw_aligned_panel_header(uiStyle *style, uiBlock *block, rcti *r UI_ThemeColor(TH_TITLE); hrect= *rect; - if(dir == 'h') { + if (dir == 'h') { hrect.xmin = rect->xmin+pnl_icons; hrect.ymin += 2.0f/block->aspect; uiStyleFontDraw(&style->paneltitle, &hrect, activename); @@ -488,8 +488,8 @@ void ui_draw_aligned_panel(uiStyle *style, uiBlock *block, rcti *rect) rctf itemrect; int ofsx; - if(panel->paneltab) return; - if(panel->type && (panel->type->flag & PNL_NO_HEADER)) return; + if (panel->paneltab) return; + if (panel->type && (panel->type->flag & PNL_NO_HEADER)) return; /* calculate header rect */ /* + 0.001f to prevent flicker due to float inaccuracy */ @@ -504,7 +504,7 @@ void ui_draw_aligned_panel(uiStyle *style, uiBlock *block, rcti *rect) glEnable(GL_BLEND); - if(btheme->tui.panel.show_header) { + if (btheme->tui.panel.show_header) { /* draw with background color */ glEnable(GL_BLEND); glColor4ubv((unsigned char*)btheme->tui.panel.header); @@ -513,7 +513,7 @@ void ui_draw_aligned_panel(uiStyle *style, uiBlock *block, rcti *rect) fdrawline(minx, y, maxx, y); fdrawline(minx, y, maxx, y); } - else if(!(panel->runtime_flag & PNL_FIRST)) { + else if (!(panel->runtime_flag & PNL_FIRST)) { /* draw embossed separator */ minx += 5.0f/block->aspect; maxx -= 5.0f/block->aspect; @@ -529,7 +529,7 @@ void ui_draw_aligned_panel(uiStyle *style, uiBlock *block, rcti *rect) } /* horizontal title */ - if(!(panel->flag & PNL_CLOSEDX)) { + if (!(panel->flag & PNL_CLOSEDX)) { ui_draw_aligned_panel_header(style, block, &headrect, 'h'); /* itemrect smaller */ @@ -545,10 +545,10 @@ void ui_draw_aligned_panel(uiStyle *style, uiBlock *block, rcti *rect) /* if the panel is minimized vertically: * (------) */ - if(panel->flag & PNL_CLOSEDY) { + if (panel->flag & PNL_CLOSEDY) { } - else if(panel->flag & PNL_CLOSEDX) { + else if (panel->flag & PNL_CLOSEDX) { /* draw vertical title */ ui_draw_aligned_panel_header(style, block, &headrect, 'v'); } @@ -556,22 +556,22 @@ void ui_draw_aligned_panel(uiStyle *style, uiBlock *block, rcti *rect) else { /* in some occasions, draw a border */ - if(panel->flag & PNL_SELECT) { - if(panel->control & UI_PNL_SOLID) uiSetRoundBox(UI_CNR_ALL); + if (panel->flag & PNL_SELECT) { + if (panel->control & UI_PNL_SOLID) uiSetRoundBox(UI_CNR_ALL); else uiSetRoundBox(UI_CNR_NONE); UI_ThemeColorShade(TH_BACK, -120); uiRoundRect(0.5f + rect->xmin, 0.5f + rect->ymin, 0.5f + rect->xmax, 0.5f + headrect.ymax+1, 8); } - if(panel->control & UI_PNL_SCALE) + if (panel->control & UI_PNL_SCALE) ui_draw_panel_scalewidget(rect); } /* draw optional close icon */ ofsx= 6; - if(panel->control & UI_PNL_CLOSE) { + if (panel->control & UI_PNL_CLOSE) { UI_ThemeColor(TH_TEXT); ui_draw_x_icon(rect->xmin+2+ofsx, rect->ymax+2); @@ -589,9 +589,9 @@ void ui_draw_aligned_panel(uiStyle *style, uiBlock *block, rcti *rect) rectf_scale(&itemrect, 0.35f); - if(panel->flag & PNL_CLOSEDY) + if (panel->flag & PNL_CLOSEDY) ui_draw_tria_rect(&itemrect, 'h'); - else if(panel->flag & PNL_CLOSEDX) + else if (panel->flag & PNL_CLOSEDX) ui_draw_tria_rect(&itemrect, 'h'); else ui_draw_tria_rect(&itemrect, 'v'); @@ -603,7 +603,7 @@ void ui_draw_aligned_panel(uiStyle *style, uiBlock *block, rcti *rect) static int get_panel_header(Panel *pa) { - if(pa->type && (pa->type->flag & PNL_NO_HEADER)) + if (pa->type && (pa->type->flag & PNL_NO_HEADER)) return 0; return PNL_HEADER; @@ -611,7 +611,7 @@ static int get_panel_header(Panel *pa) static int get_panel_size_y(Panel *pa) { - if(pa->type && (pa->type->flag & PNL_NO_HEADER)) + if (pa->type && (pa->type->flag & PNL_NO_HEADER)) return pa->sizey; return PNL_HEADER + pa->sizey; @@ -621,16 +621,16 @@ static int get_panel_size_y(Panel *pa) * change sizey or location when closed */ static int get_panel_real_ofsy(Panel *pa) { - if(pa->flag & PNL_CLOSEDY) return pa->ofsy+pa->sizey; - else if(pa->paneltab && (pa->paneltab->flag & PNL_CLOSEDY)) return pa->ofsy+pa->sizey; - else if(pa->paneltab) return pa->paneltab->ofsy; + if (pa->flag & PNL_CLOSEDY) return pa->ofsy+pa->sizey; + else if (pa->paneltab && (pa->paneltab->flag & PNL_CLOSEDY)) return pa->ofsy+pa->sizey; + else if (pa->paneltab) return pa->paneltab->ofsy; else return pa->ofsy; } static int get_panel_real_ofsx(Panel *pa) { - if(pa->flag & PNL_CLOSEDX) return pa->ofsx+get_panel_header(pa); - else if(pa->paneltab && (pa->paneltab->flag & PNL_CLOSEDX)) return pa->ofsx+get_panel_header(pa); + if (pa->flag & PNL_CLOSEDX) return pa->ofsx+get_panel_header(pa); + else if (pa->paneltab && (pa->paneltab->flag & PNL_CLOSEDX)) return pa->ofsx+get_panel_header(pa); else return pa->ofsx+pa->sizex; } @@ -648,10 +648,10 @@ static int find_leftmost_panel(const void *a1, const void *a2) { const PanelSort *ps1=a1, *ps2=a2; - if(ps1->pa->ofsx > ps2->pa->ofsx) return 1; - else if(ps1->pa->ofsx < ps2->pa->ofsx) return -1; - else if(ps1->pa->sortorder > ps2->pa->sortorder) return 1; - else if(ps1->pa->sortorder < ps2->pa->sortorder) return -1; + if (ps1->pa->ofsx > ps2->pa->ofsx) return 1; + else if (ps1->pa->ofsx < ps2->pa->ofsx) return -1; + else if (ps1->pa->sortorder > ps2->pa->sortorder) return 1; + else if (ps1->pa->sortorder < ps2->pa->sortorder) return -1; return 0; } @@ -665,10 +665,10 @@ static int find_highest_panel(const void *a1, const void *a2) * prevent them from being sorted */ if (ps1->pa->sortorder < ps2->pa->sortorder && ps1->pa->type->flag & PNL_NO_HEADER) return -1; - if(ps1->pa->ofsy+ps1->pa->sizey < ps2->pa->ofsy+ps2->pa->sizey) return 1; - else if(ps1->pa->ofsy+ps1->pa->sizey > ps2->pa->ofsy+ps2->pa->sizey) return -1; - else if(ps1->pa->sortorder > ps2->pa->sortorder) return 1; - else if(ps1->pa->sortorder < ps2->pa->sortorder) return -1; + if (ps1->pa->ofsy+ps1->pa->sizey < ps2->pa->ofsy+ps2->pa->sizey) return 1; + else if (ps1->pa->ofsy+ps1->pa->sizey > ps2->pa->ofsy+ps2->pa->sizey) return -1; + else if (ps1->pa->sortorder > ps2->pa->sortorder) return 1; + else if (ps1->pa->sortorder < ps2->pa->sortorder) return -1; return 0; } @@ -677,8 +677,8 @@ static int compare_panel(const void *a1, const void *a2) { const PanelSort *ps1=a1, *ps2=a2; - if(ps1->pa->sortorder > ps2->pa->sortorder) return 1; - else if(ps1->pa->sortorder < ps2->pa->sortorder) return -1; + if (ps1->pa->sortorder > ps2->pa->sortorder) return 1; + else if (ps1->pa->sortorder < ps2->pa->sortorder) return -1; return 0; } @@ -693,18 +693,18 @@ static int uiAlignPanelStep(ScrArea *sa, ARegion *ar, float fac, int drag) int align= panel_aligned(sa, ar); /* count active, not tabbed panels */ - for(pa= ar->panels.first; pa; pa= pa->next) - if((pa->runtime_flag & PNL_ACTIVE) && pa->paneltab==NULL) + for (pa= ar->panels.first; pa; pa= pa->next) + if ((pa->runtime_flag & PNL_ACTIVE) && pa->paneltab==NULL) tot++; - if(tot==0) return 0; + if (tot==0) return 0; /* extra; change close direction? */ - for(pa= ar->panels.first; pa; pa= pa->next) { - if((pa->runtime_flag & PNL_ACTIVE) && pa->paneltab==NULL) { - if((pa->flag & PNL_CLOSEDX) && (align==BUT_VERTICAL)) + for (pa= ar->panels.first; pa; pa= pa->next) { + if ((pa->runtime_flag & PNL_ACTIVE) && pa->paneltab==NULL) { + if ((pa->flag & PNL_CLOSEDX) && (align==BUT_VERTICAL)) pa->flag ^= PNL_CLOSED; - else if((pa->flag & PNL_CLOSEDY) && (align==BUT_HORIZONTAL)) + else if ((pa->flag & PNL_CLOSEDY) && (align==BUT_HORIZONTAL)) pa->flag ^= PNL_CLOSED; } } @@ -713,22 +713,22 @@ static int uiAlignPanelStep(ScrArea *sa, ARegion *ar, float fac, int drag) panelsort= MEM_callocN(tot*sizeof(PanelSort), "panelsort"); ps= panelsort; - for(pa= ar->panels.first; pa; pa= pa->next) { - if((pa->runtime_flag & PNL_ACTIVE) && pa->paneltab==NULL) { + for (pa= ar->panels.first; pa; pa= pa->next) { + if ((pa->runtime_flag & PNL_ACTIVE) && pa->paneltab==NULL) { ps->pa= MEM_dupallocN(pa); ps->orig= pa; ps++; } } - if(drag) { + if (drag) { /* while we are dragging, we sort on location and update sortorder */ - if(align==BUT_VERTICAL) + if (align==BUT_VERTICAL) qsort(panelsort, tot, sizeof(PanelSort), find_highest_panel); else qsort(panelsort, tot, sizeof(PanelSort), find_leftmost_panel); - for(ps=panelsort, a=0; aorig->sortorder= a; } else @@ -740,10 +740,10 @@ static int uiAlignPanelStep(ScrArea *sa, ARegion *ar, float fac, int drag) ps->pa->ofsx= 0; ps->pa->ofsy= -get_panel_size_y(ps->pa); - for(a=0; apa->ofsx= ps->pa->ofsx; psnext->pa->ofsy= get_panel_real_ofsy(ps->pa) - get_panel_size_y(psnext->pa); } @@ -756,9 +756,9 @@ static int uiAlignPanelStep(ScrArea *sa, ARegion *ar, float fac, int drag) /* we interpolate */ done= 0; ps= panelsort; - for(a=0; apa->flag & PNL_SELECT)==0) { - if((ps->orig->ofsx != ps->pa->ofsx) || (ps->orig->ofsy != ps->pa->ofsy)) { + for (a=0; apa->flag & PNL_SELECT)==0) { + if ((ps->orig->ofsx != ps->pa->ofsx) || (ps->orig->ofsy != ps->pa->ofsy)) { ps->orig->ofsx= floorf(0.5f + fac*(float)ps->pa->ofsx + (1.0f-fac)*(float)ps->orig->ofsx); ps->orig->ofsy= floorf(0.5f + fac*(float)ps->pa->ofsy + (1.0f-fac)*(float)ps->orig->ofsy); done= 1; @@ -767,8 +767,8 @@ static int uiAlignPanelStep(ScrArea *sa, ARegion *ar, float fac, int drag) } /* copy locations to tabs */ - for(pa= ar->panels.first; pa; pa= pa->next) - if(pa->paneltab && (pa->runtime_flag & PNL_ACTIVE)) + for (pa= ar->panels.first; pa; pa= pa->next) + if (pa->paneltab && (pa->runtime_flag & PNL_ACTIVE)) ui_panel_copy_offset(pa, pa->paneltab); /* free panelsort array */ @@ -788,11 +788,11 @@ static void ui_panels_size(ScrArea *sa, ARegion *ar, int *x, int *y) int sizey = UI_PANEL_WIDTH; /* compute size taken up by panels, for setting in view2d */ - for(pa= ar->panels.first; pa; pa= pa->next) { - if(pa->runtime_flag & PNL_ACTIVE) { + for (pa= ar->panels.first; pa; pa= pa->next) { + if (pa->runtime_flag & PNL_ACTIVE) { int pa_sizex, pa_sizey; - if(align==BUT_VERTICAL) { + if (align==BUT_VERTICAL) { pa_sizex= pa->ofsx + pa->sizex; pa_sizey= get_panel_real_ofsy(pa); } @@ -822,12 +822,12 @@ static void ui_do_animate(const bContext *C, Panel *panel) fac= MIN2(fac, 1.0f); /* for max 1 second, interpolate positions */ - if(uiAlignPanelStep(sa, ar, fac, 0)) + if (uiAlignPanelStep(sa, ar, fac, 0)) ED_region_tag_redraw(ar); else fac= 1.0f; - if(fac >= 1.0f) { + if (fac >= 1.0f) { panel_activate_state(C, panel, PANEL_STATE_EXIT); return; } @@ -839,8 +839,8 @@ void uiBeginPanels(const bContext *UNUSED(C), ARegion *ar) /* set all panels as inactive, so that at the end we know * which ones were used */ - for(pa=ar->panels.first; pa; pa=pa->next) { - if(pa->runtime_flag & PNL_ACTIVE) + for (pa=ar->panels.first; pa; pa=pa->next) { + if (pa->runtime_flag & PNL_ACTIVE) pa->runtime_flag= PNL_WAS_ACTIVE; else pa->runtime_flag= 0; @@ -855,25 +855,25 @@ void uiEndPanels(const bContext *C, ARegion *ar, int *x, int *y) Panel *panot, *panew, *patest, *pa, *firstpa; /* offset contents */ - for(block= ar->uiblocks.first; block; block= block->next) - if(block->active && block->panel) + for (block= ar->uiblocks.first; block; block= block->next) + if (block->active && block->panel) ui_offset_panel_block(block); /* consistency; are panels not made, whilst they have tabs */ - for(panot= ar->panels.first; panot; panot= panot->next) { - if((panot->runtime_flag & PNL_ACTIVE)==0) { // not made + for (panot= ar->panels.first; panot; panot= panot->next) { + if ((panot->runtime_flag & PNL_ACTIVE)==0) { // not made - for(panew= ar->panels.first; panew; panew= panew->next) { - if((panew->runtime_flag & PNL_ACTIVE)) { - if(panew->paneltab==panot) { // panew is tab in notmade pa + for (panew= ar->panels.first; panew; panew= panew->next) { + if ((panew->runtime_flag & PNL_ACTIVE)) { + if (panew->paneltab==panot) { // panew is tab in notmade pa break; } } } /* now panew can become the new parent, check all other tabs */ - if(panew) { - for(patest= ar->panels.first; patest; patest= patest->next) { - if(patest->paneltab == panot) { + if (panew) { + for (patest= ar->panels.first; patest; patest= patest->next) { + if (patest->paneltab == panot) { patest->paneltab= panew; } } @@ -885,8 +885,8 @@ void uiEndPanels(const bContext *C, ARegion *ar, int *x, int *y) } /* re-align, possibly with animation */ - if(panels_re_align(sa, ar, &pa)) { - if(pa) + if (panels_re_align(sa, ar, &pa)) { + if (pa) panel_activate_state(C, pa, PANEL_STATE_ANIMATION); else uiAlignPanelStep(sa, ar, 1.0, 0); @@ -894,12 +894,12 @@ void uiEndPanels(const bContext *C, ARegion *ar, int *x, int *y) /* tag first panel */ firstpa= NULL; - for(block= ar->uiblocks.first; block; block=block->next) - if(block->active && block->panel) - if(!firstpa || block->panel->sortorder < firstpa->sortorder) + for (block= ar->uiblocks.first; block; block=block->next) + if (block->active && block->panel) + if (!firstpa || block->panel->sortorder < firstpa->sortorder) firstpa= block->panel; - if(firstpa) + if (firstpa) firstpa->runtime_flag |= PNL_FIRST; /* compute size taken up by panel */ @@ -913,14 +913,14 @@ void uiDrawPanels(const bContext *C, ARegion *ar) UI_ThemeClearColor(TH_BACK); /* draw panels, selected on top */ - for(block= ar->uiblocks.first; block; block=block->next) { - if(block->active && block->panel && !(block->panel->flag & PNL_SELECT)) { + for (block= ar->uiblocks.first; block; block=block->next) { + if (block->active && block->panel && !(block->panel->flag & PNL_SELECT)) { uiDrawBlock(C, block); } } - for(block= ar->uiblocks.first; block; block=block->next) { - if(block->active && block->panel && (block->panel->flag & PNL_SELECT)) { + for (block= ar->uiblocks.first; block; block=block->next) { + if (block->active && block->panel && (block->panel->flag & PNL_SELECT)) { uiDrawBlock(C, block); } } @@ -934,21 +934,21 @@ static void check_panel_overlap(ARegion *ar, Panel *panel) /* also called with panel==NULL for clear */ - for(pa=ar->panels.first; pa; pa=pa->next) { + for (pa=ar->panels.first; pa; pa=pa->next) { pa->flag &= ~PNL_OVERLAP; - if(panel && (pa != panel)) { - if(pa->paneltab==NULL && (pa->runtime_flag & PNL_ACTIVE)) { + if (panel && (pa != panel)) { + if (pa->paneltab==NULL && (pa->runtime_flag & PNL_ACTIVE)) { float safex= 0.2, safey= 0.2; - if(pa->flag & PNL_CLOSEDX) safex= 0.05; - else if(pa->flag & PNL_CLOSEDY) safey= 0.05; - else if(panel->flag & PNL_CLOSEDX) safex= 0.05; - else if(panel->flag & PNL_CLOSEDY) safey= 0.05; + if (pa->flag & PNL_CLOSEDX) safex= 0.05; + else if (pa->flag & PNL_CLOSEDY) safey= 0.05; + else if (panel->flag & PNL_CLOSEDX) safex= 0.05; + else if (panel->flag & PNL_CLOSEDY) safey= 0.05; - if(pa->ofsx > panel->ofsx- safex*panel->sizex) - if(pa->ofsx+pa->sizex < panel->ofsx+ (1.0f+safex)*panel->sizex) - if(pa->ofsy > panel->ofsy- safey*panel->sizey) - if(pa->ofsy+pa->sizey < panel->ofsy+ (1.0f+safey)*panel->sizey) + if (pa->ofsx > panel->ofsx- safex*panel->sizex) + if (pa->ofsx+pa->sizex < panel->ofsx+ (1.0f+safex)*panel->sizex) + if (pa->ofsy > panel->ofsy- safey*panel->sizey) + if (pa->ofsy+pa->sizey < panel->ofsy+ (1.0f+safey)*panel->sizey) pa->flag |= PNL_OVERLAP; } } @@ -965,7 +965,7 @@ static void ui_do_drag(const bContext *C, wmEvent *event, Panel *panel) short align= panel_aligned(sa, ar), dx=0, dy=0; /* first clip for window, no dragging outside */ - if(!BLI_in_rcti(&ar->winrct, event->x, event->y)) + if (!BLI_in_rcti(&ar->winrct, event->x, event->y)) return; dx= (event->x-data->startx) & ~(PNL_GRID-1); @@ -974,10 +974,10 @@ static void ui_do_drag(const bContext *C, wmEvent *event, Panel *panel) dx *= (float)(ar->v2d.cur.xmax - ar->v2d.cur.xmin)/(float)(ar->winrct.xmax - ar->winrct.xmin); dy *= (float)(ar->v2d.cur.ymax - ar->v2d.cur.ymin)/(float)(ar->winrct.ymax - ar->winrct.ymin); - if(data->state == PANEL_STATE_DRAG_SCALE) { + if (data->state == PANEL_STATE_DRAG_SCALE) { panel->sizex = MAX2(data->startsizex+dx, UI_PANEL_MINX); - if(data->startsizey-dy < UI_PANEL_MINY) + if (data->startsizey-dy < UI_PANEL_MINY) dy= -UI_PANEL_MINY+data->startsizey; panel->sizey= data->startsizey-dy; @@ -991,7 +991,7 @@ static void ui_do_drag(const bContext *C, wmEvent *event, Panel *panel) panel->ofsy = data->startofsy+dy; check_panel_overlap(ar, panel); - if(align) uiAlignPanelStep(sa, ar, 0.2, 1); + if (align) uiAlignPanelStep(sa, ar, 0.2, 1); } ED_region_tag_redraw(ar); @@ -1014,34 +1014,34 @@ static void ui_handle_panel_header(const bContext *C, uiBlock *block, int mx, in /* XXX weak code, currently it assumes layout style for location of widgets */ /* check open/collapsed button */ - if(event==RETKEY) + if (event==RETKEY) button= 1; - else if(event==AKEY) + else if (event==AKEY) button= 1; - else if(block->panel->flag & PNL_CLOSEDX) { - if(my >= block->maxy) button= 1; + else if (block->panel->flag & PNL_CLOSEDX) { + if (my >= block->maxy) button= 1; } - else if(block->panel->control & UI_PNL_CLOSE) { + else if (block->panel->control & UI_PNL_CLOSE) { /* whole of header can be used to collapse panel (except top-right corner) */ - if(mx <= block->maxx-8-PNL_ICON) button= 2; - //else if(mx <= block->minx+10+2*PNL_ICON+2) button= 1; + if (mx <= block->maxx-8-PNL_ICON) button= 2; + //else if (mx <= block->minx+10+2*PNL_ICON+2) button= 1; } - else if(mx <= block->maxx-PNL_ICON-12) { + else if (mx <= block->maxx-PNL_ICON-12) { button= 1; } - if(button) { - if(button==2) { // close + if (button) { + if (button==2) { // close ED_region_tag_redraw(ar); } else { // collapse - if(block->panel->flag & PNL_CLOSED) { + if (block->panel->flag & PNL_CLOSED) { block->panel->flag &= ~PNL_CLOSED; /* snap back up so full panel aligns with screen edge */ if (block->panel->snap & PNL_SNAP_BOTTOM) block->panel->ofsy= 0; } - else if(align==BUT_HORIZONTAL) { + else if (align==BUT_HORIZONTAL) { block->panel->flag |= PNL_CLOSEDX; } else { @@ -1051,20 +1051,20 @@ static void ui_handle_panel_header(const bContext *C, uiBlock *block, int mx, in block->panel->ofsy= -block->panel->sizey; } - for(pa= ar->panels.first; pa; pa= pa->next) { - if(pa->paneltab==block->panel) { - if(block->panel->flag & PNL_CLOSED) pa->flag |= PNL_CLOSED; + for (pa= ar->panels.first; pa; pa= pa->next) { + if (pa->paneltab==block->panel) { + if (block->panel->flag & PNL_CLOSED) pa->flag |= PNL_CLOSED; else pa->flag &= ~PNL_CLOSED; } } } - if(align) + if (align) panel_activate_state(C, block->panel, PANEL_STATE_ANIMATION); else ED_region_tag_redraw(ar); } - else if(mx <= (block->maxx-PNL_ICON-12)+PNL_ICON+2) { + else if (mx <= (block->maxx-PNL_ICON-12)+PNL_ICON+2) { panel_activate_state(C, block->panel, PANEL_STATE_DRAG); } } @@ -1080,7 +1080,7 @@ int ui_handler_panel_region(bContext *C, wmEvent *event) int retval, mx, my, inside_header= 0, inside_scale= 0, inside; retval= WM_UI_HANDLER_CONTINUE; - for(block=ar->uiblocks.last; block; block=block->prev) { + for (block=ar->uiblocks.last; block; block=block->prev) { mx= event->x; my= event->y; ui_window_to_block(ar, block, &mx, &my); @@ -1089,20 +1089,20 @@ int ui_handler_panel_region(bContext *C, wmEvent *event) inside= 0; pa= block->panel; - if(!pa || pa->paneltab!=NULL) + if (!pa || pa->paneltab!=NULL) continue; - if(pa->type && pa->type->flag & PNL_NO_HEADER) // XXX - accessed freed panels when scripts reload, need to fix. + if (pa->type && pa->type->flag & PNL_NO_HEADER) // XXX - accessed freed panels when scripts reload, need to fix. continue; - if(block->minx <= mx && block->maxx >= mx) - if(block->miny <= my && block->maxy+PNL_HEADER >= my) + if (block->minx <= mx && block->maxx >= mx) + if (block->miny <= my && block->maxy+PNL_HEADER >= my) inside= 1; - if(inside && event->val==KM_PRESS) { - if(event->type == AKEY && !ELEM4(KM_MOD_FIRST, event->ctrl, event->oskey, event->shift, event->alt)) { + if (inside && event->val==KM_PRESS) { + if (event->type == AKEY && !ELEM4(KM_MOD_FIRST, event->ctrl, event->oskey, event->shift, event->alt)) { - if(pa->flag & PNL_CLOSEDY) { - if((block->maxy <= my) && (block->maxy+PNL_HEADER >= my)) + if (pa->flag & PNL_CLOSEDY) { + if ((block->maxy <= my) && (block->maxy+PNL_HEADER >= my)) ui_handle_panel_header(C, block, mx, my, event->type); } else @@ -1113,53 +1113,53 @@ int ui_handler_panel_region(bContext *C, wmEvent *event) } /* on active button, do not handle panels */ - if(ui_button_is_active(ar)) + if (ui_button_is_active(ar)) continue; - if(inside) { + if (inside) { /* clicked at panel header? */ - if(pa->flag & PNL_CLOSEDX) { - if(block->minx <= mx && block->minx+PNL_HEADER >= mx) + if (pa->flag & PNL_CLOSEDX) { + if (block->minx <= mx && block->minx+PNL_HEADER >= mx) inside_header= 1; } - else if((block->maxy <= my) && (block->maxy+PNL_HEADER >= my)) { + else if ((block->maxy <= my) && (block->maxy+PNL_HEADER >= my)) { inside_header= 1; } - else if(pa->control & UI_PNL_SCALE) { - if(block->maxx-PNL_HEADER <= mx) - if(block->miny+PNL_HEADER >= my) + else if (pa->control & UI_PNL_SCALE) { + if (block->maxx-PNL_HEADER <= mx) + if (block->miny+PNL_HEADER >= my) inside_scale= 1; } - if(event->val==KM_PRESS) { + if (event->val==KM_PRESS) { /* open close on header */ - if(ELEM(event->type, RETKEY, PADENTER)) { - if(inside_header) { + if (ELEM(event->type, RETKEY, PADENTER)) { + if (inside_header) { ui_handle_panel_header(C, block, mx, my, RETKEY); break; } } - else if(event->type == LEFTMOUSE) { - if(inside_header) { + else if (event->type == LEFTMOUSE) { + if (inside_header) { ui_handle_panel_header(C, block, mx, my, 0); break; } - else if(inside_scale && !(pa->flag & PNL_CLOSED)) { + else if (inside_scale && !(pa->flag & PNL_CLOSED)) { panel_activate_state(C, pa, PANEL_STATE_DRAG_SCALE); break; } } - else if(event->type == ESCKEY) { + else if (event->type == ESCKEY) { /*XXX 2.50*/ #if 0 - if(block->handler) { + if (block->handler) { rem_blockhandler(sa, block->handler); ED_region_tag_redraw(ar); retval= WM_UI_HANDLER_BREAK; } #endif } - else if(event->type==PADPLUSKEY || event->type==PADMINUS) { + else if (event->type==PADPLUSKEY || event->type==PADMINUS) { #if 0 // XXX make float panel exception? int zoom=0; @@ -1171,13 +1171,13 @@ int ui_handler_panel_region(bContext *C, wmEvent *event) else zoom=1; - if(zoom) { + if (zoom) { ScrArea *sa= CTX_wm_area(C); SpaceLink *sl= sa->spacedata.first; - if(sa->spacetype!=SPACE_BUTS) { - if(!(pa->control & UI_PNL_SCALE)) { - if(event->type==PADPLUSKEY) sl->blockscale+= 0.1; + if (sa->spacetype!=SPACE_BUTS) { + if (!(pa->control & UI_PNL_SCALE)) { + if (event->type==PADPLUSKEY) sl->blockscale+= 0.1; else sl->blockscale-= 0.1; CLAMP(sl->blockscale, 0.6, 1.0); @@ -1204,30 +1204,30 @@ static int ui_handler_panel(bContext *C, wmEvent *event, void *userdata) uiHandlePanelData *data= panel->activedata; /* verify if we can stop */ - if(event->type == LEFTMOUSE && event->val!=KM_PRESS) { + if (event->type == LEFTMOUSE && event->val!=KM_PRESS) { ScrArea *sa= CTX_wm_area(C); ARegion *ar= CTX_wm_region(C); int align= panel_aligned(sa, ar); - if(align) + if (align) panel_activate_state(C, panel, PANEL_STATE_ANIMATION); else panel_activate_state(C, panel, PANEL_STATE_EXIT); } - else if(event->type == MOUSEMOVE) { - if(data->state == PANEL_STATE_DRAG) + else if (event->type == MOUSEMOVE) { + if (data->state == PANEL_STATE_DRAG) ui_do_drag(C, event, panel); } - else if(event->type == TIMER && event->customdata == data->animtimer) { - if(data->state == PANEL_STATE_ANIMATION) + else if (event->type == TIMER && event->customdata == data->animtimer) { + if (data->state == PANEL_STATE_ANIMATION) ui_do_animate(C, panel); - else if(data->state == PANEL_STATE_DRAG) + else if (data->state == PANEL_STATE_DRAG) ui_do_drag(C, event, panel); } data= panel->activedata; - if(data && data->state == PANEL_STATE_ANIMATION) + if (data && data->state == PANEL_STATE_ANIMATION) return WM_UI_HANDLER_CONTINUE; else return WM_UI_HANDLER_BREAK; @@ -1246,11 +1246,11 @@ static void panel_activate_state(const bContext *C, Panel *pa, uiHandlePanelStat wmWindow *win= CTX_wm_window(C); ARegion *ar= CTX_wm_region(C); - if(data && data->state == state) + if (data && data->state == state) return; - if(state == PANEL_STATE_EXIT || state == PANEL_STATE_ANIMATION) { - if(data && data->state != PANEL_STATE_ANIMATION) { + if (state == PANEL_STATE_EXIT || state == PANEL_STATE_ANIMATION) { + if (data && data->state != PANEL_STATE_ANIMATION) { /* XXX: * - the panel tabbing function call below (test_add_new_tabs()) has been commented out * "It is too easy to do by accident when reordering panels, is very hard to control and use, and has no real benefit." - BillRey @@ -1265,26 +1265,26 @@ static void panel_activate_state(const bContext *C, Panel *pa, uiHandlePanelStat else pa->flag |= PNL_SELECT; - if(data && data->animtimer) { + if (data && data->animtimer) { WM_event_remove_timer(CTX_wm_manager(C), win, data->animtimer); data->animtimer= NULL; } - if(state == PANEL_STATE_EXIT) { + if (state == PANEL_STATE_EXIT) { MEM_freeN(data); pa->activedata= NULL; WM_event_remove_ui_handler(&win->modalhandlers, ui_handler_panel, ui_handler_remove_panel, pa, 0); } else { - if(!data) { + if (!data) { data= MEM_callocN(sizeof(uiHandlePanelData), "uiHandlePanelData"); pa->activedata= data; WM_event_add_ui_handler(C, &win->modalhandlers, ui_handler_panel, ui_handler_remove_panel, pa); } - if(ELEM(state, PANEL_STATE_ANIMATION, PANEL_STATE_DRAG)) + if (ELEM(state, PANEL_STATE_ANIMATION, PANEL_STATE_DRAG)) data->animtimer= WM_event_add_timer(CTX_wm_manager(C), win, TIMER, ANIMATION_INTERVAL); data->state= state; @@ -1301,15 +1301,15 @@ static void panel_activate_state(const bContext *C, Panel *pa, uiHandlePanelStat /* XXX exception handling, 3d window preview panel */ #if 0 - if(block->drawextra==BIF_view3d_previewdraw) + if (block->drawextra==BIF_view3d_previewdraw) BIF_view3d_previewrender_clear(curarea); #endif /* XXX exception handling, 3d window preview panel */ #if 0 - if(block->drawextra==BIF_view3d_previewdraw) + if (block->drawextra==BIF_view3d_previewdraw) BIF_view3d_previewrender_signal(curarea, PR_DISPRECT); - else if(strcmp(block->name, "image_panel_preview")==0) + else if (strcmp(block->name, "image_panel_preview")==0) image_preview_event(2); #endif } diff --git a/source/blender/editors/interface/interface_regions.c b/source/blender/editors/interface/interface_regions.c index b375b8d154f..ef6cbc9ae48 100644 --- a/source/blender/editors/interface/interface_regions.c +++ b/source/blender/editors/interface/interface_regions.c @@ -174,32 +174,36 @@ static MenuData *decompose_menu_string(const char *str) *s= '\0'; s++; - } else if (s[1]=='t') { + } + else if (s[1]=='t') { nitem_is_title= (s != instr); /* check for empty title */ *s= '\0'; s++; - } else if (s[1]=='l') { + } + else if (s[1]=='l') { nitem_is_sepr= 1; - if(!nitem) nitem= ""; + if (!nitem) nitem= ""; *s= '\0'; s++; - } else if (s[1]=='i') { + } + else if (s[1]=='i') { nicon= atoi(s+2); *s= '\0'; s++; } - } else if (c=='|' || c == '\n' || c=='\0') { + } + else if (c=='|' || c == '\n' || c=='\0') { if (nitem) { *s= '\0'; - if(nitem_is_title) { + if (nitem_is_title) { menudata_set_title(md, nitem, nicon); nitem_is_title= 0; } - else if(nitem_is_sepr) { + else if (nitem_is_sepr) { /* prevent separator to get a value */ menudata_add_item(md, nitem, -1, nicon, 1); nretval= md->nitems+1; @@ -217,7 +221,8 @@ static MenuData *decompose_menu_string(const char *str) if (c=='\0') { break; } - } else if (!nitem) { + } + else if (!nitem) { nitem= s; } @@ -254,20 +259,20 @@ int ui_step_name_menu(uiBut *but, int step) if (md->items[i].retval==value) break; - if(step==1) { + if (step==1) { /* skip separators */ - for(; initems-1; i++) { - if(md->items[i+1].retval != -1) { + for (; initems-1; i++) { + if (md->items[i+1].retval != -1) { value= md->items[i+1].retval; break; } } } else { - if(i>0) { + if (i>0) { /* skip separators */ - for(; i>0; i--) { - if(md->items[i-1].retval != -1) { + for (; i>0; i--) { + if (md->items[i-1].retval != -1) { value= md->items[i-1].retval; break; } @@ -298,7 +303,7 @@ static ARegion *ui_add_temporary_region(bScreen *sc) static void ui_remove_temporary_region(bContext *C, bScreen *sc, ARegion *ar) { - if(CTX_wm_window(C)) + if (CTX_wm_window(C)) wm_draw_region_clear(CTX_wm_window(C), ar); ED_region_exit(C, ar); @@ -418,31 +423,31 @@ ARegion *ui_tooltip_create(bContext *C, ARegion *butregion, uiBut *but) float x1f, x2f, y1f, y2f; int x1, x2, y1, y2, winx, winy, ofsx, ofsy, w, h, a; - if(but->flag & UI_BUT_NO_TOOLTIP) + if (but->flag & UI_BUT_NO_TOOLTIP) return NULL; /* create tooltip data */ data= MEM_callocN(sizeof(uiTooltipData), "uiTooltipData"); /* special case, enum rna buttons only have enum item description, use general enum description too before the specific one */ - if(but->rnaprop && RNA_property_type(but->rnaprop) == PROP_ENUM) { + if (but->rnaprop && RNA_property_type(but->rnaprop) == PROP_ENUM) { const char *descr= RNA_property_description(but->rnaprop); - if(descr && descr[0]) { + if (descr && descr[0]) { BLI_strncpy(data->lines[data->totline], descr, sizeof(data->lines[0])); data->color_id[data->totline] = UI_TIP_LC_MAIN; data->totline++; } - if(ELEM(but->type, ROW, MENU)) { + if (ELEM(but->type, ROW, MENU)) { EnumPropertyItem *item; int i, totitem, free; int value = (but->type == ROW)? but->hardmax: ui_get_but_val(but); RNA_property_enum_items_gettexted(C, &but->rnapoin, but->rnaprop, &item, &totitem, &free); - for(i=0; ilines[data->totline], sizeof(data->lines[0]), "%s: %s", item[i].name, item[i].description); data->color_id[data->totline] = UI_TIP_LC_SUBMENU; data->totline++; @@ -457,17 +462,17 @@ ARegion *ui_tooltip_create(bContext *C, ARegion *butregion, uiBut *but) } } - if(but->tip && but->tip[0] != '\0') { + if (but->tip && but->tip[0] != '\0') { BLI_strncpy(data->lines[data->totline], but->tip, sizeof(data->lines[0])); data->color_id[data->totline] = UI_TIP_LC_MAIN; data->totline++; } - if(but->optype && !(but->block->flag & UI_BLOCK_LOOP)) { + if (but->optype && !(but->block->flag & UI_BLOCK_LOOP)) { /* operator keymap (not menus, they already have it) */ prop= (but->opptr)? but->opptr->data: NULL; - if(WM_key_event_operator_string(C, but->optype->idname, but->opcontext, prop, TRUE, + if (WM_key_event_operator_string(C, but->optype->idname, but->opcontext, prop, TRUE, buf, sizeof(buf))) { BLI_snprintf(data->lines[data->totline], sizeof(data->lines[0]), TIP_("Shortcut: %s"), buf); @@ -476,17 +481,17 @@ ARegion *ui_tooltip_create(bContext *C, ARegion *butregion, uiBut *but) } } - if(ELEM3(but->type, TEX, IDPOIN, SEARCH_MENU)) { + if (ELEM3(but->type, TEX, IDPOIN, SEARCH_MENU)) { /* full string */ ui_get_but_string(but, buf, sizeof(buf)); - if(buf[0]) { + if (buf[0]) { BLI_snprintf(data->lines[data->totline], sizeof(data->lines[0]), TIP_("Value: %s"), buf); data->color_id[data->totline] = UI_TIP_LC_NORMAL; data->totline++; } } - if(but->rnaprop) { + if (but->rnaprop) { int unit_type= uiButGetUnitType(but); if (unit_type == PROP_UNIT_ROTATION) { @@ -498,8 +503,8 @@ ARegion *ui_tooltip_create(bContext *C, ARegion *butregion, uiBut *but) } } - if(but->flag & UI_BUT_DRIVEN) { - if(ui_but_anim_expression_get(but, buf, sizeof(buf))) { + if (but->flag & UI_BUT_DRIVEN) { + if (ui_but_anim_expression_get(but, buf, sizeof(buf))) { /* expression */ BLI_snprintf(data->lines[data->totline], sizeof(data->lines[0]), TIP_("Expression: %s"), buf); data->color_id[data->totline] = UI_TIP_LC_NORMAL; @@ -514,9 +519,9 @@ ARegion *ui_tooltip_create(bContext *C, ARegion *butregion, uiBut *but) data->totline++; } - if(but->rnapoin.id.data) { + if (but->rnapoin.id.data) { ID *id= but->rnapoin.id.data; - if(id->lib && id->lib->name) { + if (id->lib && id->lib->name) { BLI_snprintf(data->lines[data->totline], sizeof(data->lines[0]), TIP_("Library: %s"), id->lib->name); data->color_id[data->totline] = UI_TIP_LC_NORMAL; data->totline++; @@ -540,12 +545,12 @@ ARegion *ui_tooltip_create(bContext *C, ARegion *butregion, uiBut *but) MEM_freeN(str); /* second check if we are disabled - why */ - if(but->flag & UI_BUT_DISABLED) { + if (but->flag & UI_BUT_DISABLED) { const char *poll_msg; CTX_wm_operator_poll_msg_set(C, NULL); WM_operator_poll_context(C, but->optype, but->opcontext); poll_msg= CTX_wm_operator_poll_msg_get(C); - if(poll_msg) { + if (poll_msg) { BLI_snprintf(data->lines[data->totline], sizeof(data->lines[0]), TIP_("Disabled: %s"), poll_msg); data->color_id[data->totline] = UI_TIP_LC_ALERT; /* alert */ data->totline++; @@ -566,7 +571,7 @@ ARegion *ui_tooltip_create(bContext *C, ARegion *butregion, uiBut *but) assert(data->totline < MAX_TOOLTIP_LINES); - if(data->totline == 0) { + if (data->totline == 0) { MEM_freeN(data); return NULL; } @@ -591,7 +596,7 @@ ARegion *ui_tooltip_create(bContext *C, ARegion *butregion, uiBut *but) h= BLF_height_max(data->fstyle.uifont_id); - for(a=0, fontw=0, fonth=0; atotline; a++) { + for (a=0, fontw=0, fonth=0; atotline; a++) { w= BLF_width(data->fstyle.uifont_id, data->lines[a]); fontw= MAX2(fontw, w); fonth += (a == 0)? h: h+TIP_MARGIN_Y; @@ -622,9 +627,9 @@ ARegion *ui_tooltip_create(bContext *C, ARegion *butregion, uiBut *but) /* copy to int, gets projected if possible too */ x1= x1f; y1= y1f; x2= x2f; y2= y2f; - if(butregion) { + if (butregion) { /* XXX temp, region v2ds can be empty still */ - if(butregion->v2d.cur.xmin != butregion->v2d.cur.xmax) { + if (butregion->v2d.cur.xmin != butregion->v2d.cur.xmax) { UI_view2d_to_region_no_clip(&butregion->v2d, x1f, y1f, &x1, &y1); UI_view2d_to_region_no_clip(&butregion->v2d, x2f, y2f, &x2, &y2); } @@ -637,9 +642,9 @@ ARegion *ui_tooltip_create(bContext *C, ARegion *butregion, uiBut *but) wm_window_get_size(CTX_wm_window(C), &winx, &winy); - if(x2 > winx) { + if (x2 > winx) { /* super size */ - if(x2 > winx + x1) { + if (x2 > winx + x1) { x2= winx; x1= 0; } @@ -650,7 +655,7 @@ ARegion *ui_tooltip_create(bContext *C, ARegion *butregion, uiBut *but) } /* ensure at least 5 px above screen bounds * 25 is just a guess to be above the menu item */ - if(y1 < 5) { + if (y1 < 5) { y2 += (-y1) + 30; y1 = 30; } @@ -715,35 +720,35 @@ typedef struct uiSearchboxData { int uiSearchItemAdd(uiSearchItems *items, const char *name, void *poin, int iconid) { /* hijack for autocomplete */ - if(items->autocpl) { + if (items->autocpl) { autocomplete_do_name(items->autocpl, name); return 1; } /* hijack for finding active item */ - if(items->active) { - if(poin==items->active) + if (items->active) { + if (poin==items->active) items->offset_i= items->totitem; items->totitem++; return 1; } - if(items->totitem>=items->maxitem) { + if (items->totitem>=items->maxitem) { items->more= 1; return 0; } /* skip first items in list */ - if(items->offset_i > 0) { + if (items->offset_i > 0) { items->offset_i--; return 1; } - if(items->names) + if (items->names) BLI_strncpy(items->names[items->totitem], name, items->maxstrlen); - if(items->pointers) + if (items->pointers) items->pointers[items->totitem]= poin; - if(items->icons) + if (items->icons) items->icons[items->totitem]= iconid; items->totitem++; @@ -764,10 +769,10 @@ static void ui_searchbox_select(bContext *C, ARegion *ar, uiBut *but, int step) /* apply step */ data->active+= step; - if(data->items.totitem==0) + if (data->items.totitem==0) data->active= 0; - else if(data->active > data->items.totitem) { - if(data->items.more) { + else if (data->active > data->items.totitem) { + if (data->items.more) { data->items.offset++; data->active= data->items.totitem; ui_searchbox_update(C, ar, but, 0); @@ -775,13 +780,13 @@ static void ui_searchbox_select(bContext *C, ARegion *ar, uiBut *but, int step) else data->active= data->items.totitem; } - else if(data->active < 1) { - if(data->items.offset) { + else if (data->active < 1) { + if (data->items.offset) { data->items.offset--; data->active= 1; ui_searchbox_update(C, ar, but, 0); } - else if(data->active < 0) + else if (data->active < 0) data->active= 0; } @@ -836,13 +841,13 @@ void ui_searchbox_apply(uiBut *but, ARegion *ar) but->func_arg2= NULL; - if(data->active) { + if (data->active) { char *name= data->items.names[data->active-1]; char *cpoin= strchr(name, '|'); - if(cpoin) cpoin[0]= 0; + if (cpoin) cpoin[0]= 0; BLI_strncpy(but->editstr, name, data->items.maxstrlen); - if(cpoin) cpoin[0]= '|'; + if (cpoin) cpoin[0]= '|'; but->func_arg2= data->items.pointers[data->active-1]; } @@ -862,14 +867,14 @@ void ui_searchbox_event(bContext *C, ARegion *ar, uiBut *but, wmEvent *event) ui_searchbox_select(C, ar, but, 1); break; case MOUSEMOVE: - if(BLI_in_rcti(&ar->winrct, event->x, event->y)) { + if (BLI_in_rcti(&ar->winrct, event->x, event->y)) { rcti rect; int a; - for(a=0; aitems.totitem; a++) { + for (a=0; aitems.totitem; a++) { ui_searchbox_butrect(&rect, data, a); - if(BLI_in_rcti(&rect, event->x - ar->winrct.xmin, event->y - ar->winrct.ymin)) { - if( data->active!= a+1) { + if (BLI_in_rcti(&rect, event->x - ar->winrct.xmin, event->y - ar->winrct.ymin)) { + if ( data->active!= a+1) { data->active= a+1; ui_searchbox_select(C, ar, but, 0); break; @@ -889,7 +894,7 @@ void ui_searchbox_update(bContext *C, ARegion *ar, uiBut *but, int reset) /* reset vars */ data->items.totitem= 0; data->items.more= 0; - if(reset==0) { + if (reset==0) { data->items.offset_i= data->items.offset; } else { @@ -897,21 +902,21 @@ void ui_searchbox_update(bContext *C, ARegion *ar, uiBut *but, int reset) data->active= 0; /* handle active */ - if(but->search_func && but->func_arg2) { + if (but->search_func && but->func_arg2) { data->items.active= but->func_arg2; but->search_func(C, but->search_arg, but->editstr, &data->items); data->items.active= NULL; /* found active item, calculate real offset by centering it */ - if(data->items.totitem) { + if (data->items.totitem) { /* first case, begin of list */ - if(data->items.offset_i < data->items.maxitem) { + if (data->items.offset_i < data->items.maxitem) { data->active= data->items.offset_i+1; data->items.offset_i= 0; } else { /* second case, end of list */ - if(data->items.totitem - data->items.offset_i <= data->items.maxitem) { + if (data->items.totitem - data->items.offset_i <= data->items.maxitem) { data->active= 1 + data->items.offset_i - data->items.totitem + data->items.maxitem; data->items.offset_i= data->items.totitem - data->items.maxitem; } @@ -928,22 +933,22 @@ void ui_searchbox_update(bContext *C, ARegion *ar, uiBut *but, int reset) } /* callback */ - if(but->search_func) + if (but->search_func) but->search_func(C, but->search_arg, but->editstr, &data->items); /* handle case where editstr is equal to one of items */ - if(reset && data->active==0) { + if (reset && data->active==0) { int a; - for(a=0; aitems.totitem; a++) { + for (a=0; aitems.totitem; a++) { char *cpoin= strchr(data->items.names[a], '|'); - if(cpoin) cpoin[0]= 0; - if(0==strcmp(but->editstr, data->items.names[a])) + if (cpoin) cpoin[0]= 0; + if (0==strcmp(but->editstr, data->items.names[a])) data->active= a+1; - if(cpoin) cpoin[0]= '|'; + if (cpoin) cpoin[0]= '|'; } - if(data->items.totitem==1 && but->editstr[0]) + if (data->items.totitem==1 && but->editstr[0]) data->active= 1; } @@ -957,7 +962,7 @@ void ui_searchbox_autocomplete(bContext *C, ARegion *ar, uiBut *but, char *str) { uiSearchboxData *data= ar->regiondata; - if(str[0]) { + if (str[0]) { data->items.autocpl= autocomplete_begin(str, ui_get_but_string_max_length(but)); but->search_func(C, but->search_arg, but->editstr, &data->items); @@ -974,17 +979,17 @@ static void ui_searchbox_region_draw_cb(const bContext *UNUSED(C), ARegion *ar) /* pixel space */ wmOrtho2(-0.01f, ar->winx-0.01f, -0.01f, ar->winy-0.01f); - if(!data->noback) + if (!data->noback) ui_draw_search_back(NULL, NULL, &data->bbox); /* style not used yet */ /* draw text */ - if(data->items.totitem) { + if (data->items.totitem) { rcti rect; int a; if (data->preview) { /* draw items */ - for(a=0; aitems.totitem; a++) { + for (a=0; aitems.totitem; a++) { ui_searchbox_butrect(&rect, data, a); /* widget itself */ @@ -995,22 +1000,23 @@ static void ui_searchbox_region_draw_cb(const bContext *UNUSED(C), ARegion *ar) } /* indicate more */ - if(data->items.more) { + if (data->items.more) { ui_searchbox_butrect(&rect, data, data->items.maxitem-1); glEnable(GL_BLEND); UI_icon_draw(rect.xmax-18, rect.ymin-7, ICON_TRIA_DOWN); glDisable(GL_BLEND); } - if(data->items.offset) { + if (data->items.offset) { ui_searchbox_butrect(&rect, data, 0); glEnable(GL_BLEND); UI_icon_draw(rect.xmin, rect.ymax-9, ICON_TRIA_UP); glDisable(GL_BLEND); } - } else { + } + else { /* draw items */ - for(a=0; aitems.totitem; a++) { + for (a=0; aitems.totitem; a++) { ui_searchbox_butrect(&rect, data, a); /* widget itself */ @@ -1018,13 +1024,13 @@ static void ui_searchbox_region_draw_cb(const bContext *UNUSED(C), ARegion *ar) } /* indicate more */ - if(data->items.more) { + if (data->items.more) { ui_searchbox_butrect(&rect, data, data->items.maxitem-1); glEnable(GL_BLEND); UI_icon_draw((rect.xmax-rect.xmin)/2, rect.ymin-9, ICON_TRIA_DOWN); glDisable(GL_BLEND); } - if(data->items.offset) { + if (data->items.offset) { ui_searchbox_butrect(&rect, data, 0); glEnable(GL_BLEND); UI_icon_draw((rect.xmax-rect.xmin)/2, rect.ymax-7, ICON_TRIA_UP); @@ -1082,7 +1088,7 @@ ARegion *ui_searchbox_create(bContext *C, ARegion *butregion, uiBut *but) /* special case, hardcoded feature, not draw backdrop when called from menus, * assume for design that popup already added it */ - if(but->block->flag & UI_BLOCK_LOOP) + if (but->block->flag & UI_BLOCK_LOOP) data->noback= 1; if (but->a1 > 0 && but->a2 > 0) { @@ -1092,7 +1098,7 @@ ARegion *ui_searchbox_create(bContext *C, ARegion *butregion, uiBut *but) } /* compute position */ - if(but->block->flag & UI_BLOCK_LOOP) { + if (but->block->flag & UI_BLOCK_LOOP) { /* this case is search menu inside other menu */ /* we copy region size */ @@ -1105,7 +1111,7 @@ ARegion *ui_searchbox_create(bContext *C, ARegion *butregion, uiBut *but) data->bbox.ymax = (ar->winrct.ymax-ar->winrct.ymin) - MENU_SHADOW_BOTTOM; /* check if button is lower half */ - if( but->y2 < (but->block->miny+but->block->maxy)/2 ) { + if ( but->y2 < (but->block->miny+but->block->maxy)/2 ) { data->bbox.ymin += (but->y2-but->y1); } else { @@ -1127,12 +1133,12 @@ ARegion *ui_searchbox_create(bContext *C, ARegion *butregion, uiBut *but) y2f += ofsy; /* minimal width */ - if(x2f - x1f < 150) x2f= x1f+150; // XXX arbitrary + if (x2f - x1f < 150) x2f= x1f+150; // XXX arbitrary /* copy to int, gets projected if possible too */ x1= x1f; y1= y1f; x2= x2f; y2= y2f; - if(butregion->v2d.cur.xmin != butregion->v2d.cur.xmax) { + if (butregion->v2d.cur.xmin != butregion->v2d.cur.xmax) { UI_view2d_to_region_no_clip(&butregion->v2d, x1f, y1f, &x1, &y1); UI_view2d_to_region_no_clip(&butregion->v2d, x2f, y2f, &x2, &y2); } @@ -1144,9 +1150,9 @@ ARegion *ui_searchbox_create(bContext *C, ARegion *butregion, uiBut *but) wm_window_get_size(CTX_wm_window(C), &winx, &winy); - if(x2 > winx) { + if (x2 > winx) { /* super size */ - if(x2 > winx + x1) { + if (x2 > winx + x1) { x2= winx; x1= 0; } @@ -1156,7 +1162,7 @@ ARegion *ui_searchbox_create(bContext *C, ARegion *butregion, uiBut *but) } } - if(y1 < 0) { + if (y1 < 0) { int newy1; UI_view2d_to_region_no_clip(&butregion->v2d, 0, but->y2 + ofsy, NULL, &newy1); newy1 += butregion->winrct.ymin; @@ -1187,7 +1193,8 @@ ARegion *ui_searchbox_create(bContext *C, ARegion *butregion, uiBut *but) /* prepare search data */ if (data->preview) { data->items.maxitem= data->prv_rows * data->prv_cols; - } else { + } + else { data->items.maxitem= SEARCH_ITEMS; } data->items.maxstrlen= but->hardmax; @@ -1195,7 +1202,7 @@ ARegion *ui_searchbox_create(bContext *C, ARegion *butregion, uiBut *but) data->items.names= MEM_callocN(data->items.maxitem*sizeof(void *), "search names"); data->items.pointers= MEM_callocN(data->items.maxitem*sizeof(void *), "search pointers"); data->items.icons= MEM_callocN(data->items.maxitem*sizeof(int), "search icons"); - for(x1=0; x1items.maxitem; x1++) + for (x1=0; x1items.maxitem; x1++) data->items.names[x1]= MEM_callocN(but->hardmax+1, "search pointers"); return ar; @@ -1215,7 +1222,7 @@ void ui_but_search_test(uiBut *but) /* possibly very large lists (such as ID datablocks) only * only validate string RNA buts (not pointers) */ - if(but->rnaprop && RNA_property_type(but->rnaprop) != PROP_STRING) { + if (but->rnaprop && RNA_property_type(but->rnaprop) != PROP_STRING) { return; } @@ -1225,19 +1232,19 @@ void ui_but_search_test(uiBut *but) items->maxitem= 10; items->maxstrlen= 256; items->names= MEM_callocN(items->maxitem*sizeof(void *), "search names"); - for(x1=0; x1maxitem; x1++) + for (x1=0; x1maxitem; x1++) items->names[x1]= MEM_callocN(but->hardmax+1, "search names"); but->search_func(but->block->evil_C, but->search_arg, but->drawstr, items); /* only redalert when we are sure of it, this can miss cases when >10 matches */ - if(items->totitem==0) + if (items->totitem==0) uiButSetFlag(but, UI_BUT_REDALERT); - else if(items->more==0) { - for(x1= 0; x1totitem; x1++) - if(strcmp(but->drawstr, items->names[x1])==0) + else if (items->more==0) { + for (x1= 0; x1totitem; x1++) + if (strcmp(but->drawstr, items->names[x1])==0) break; - if(x1==items->totitem) + if (x1==items->totitem) uiButSetFlag(but, UI_BUT_REDALERT); } @@ -1269,18 +1276,18 @@ static void ui_block_position(wmWindow *window, ARegion *butregion, uiBut *but, ui_block_to_window_fl(butregion, but->block, &butrct.xmax, &butrct.ymax); /* calc block rect */ - if(block->minx == 0.0f && block->maxx == 0.0f) { - if(block->buttons.first) { + if (block->minx == 0.0f && block->maxx == 0.0f) { + if (block->buttons.first) { block->minx= block->miny= 10000; block->maxx= block->maxy= -10000; bt= block->buttons.first; - while(bt) { - if(bt->x1 < block->minx) block->minx= bt->x1; - if(bt->y1 < block->miny) block->miny= bt->y1; + while (bt) { + if (bt->x1 < block->minx) block->minx= bt->x1; + if (bt->y1 < block->miny) block->miny= bt->y1; - if(bt->x2 > block->maxx) block->maxx= bt->x2; - if(bt->y2 > block->maxy) block->maxy= bt->y2; + if (bt->x2 > block->maxx) block->maxx= bt->x2; + if (bt->y2 > block->maxy) block->maxy= bt->y2; bt= bt->next; } @@ -1310,16 +1317,16 @@ static void ui_block_position(wmWindow *window, ARegion *butregion, uiBut *but, wm_window_get_size(window, &winx, &winy); - if(block->direction & UI_CENTER) center= ysize/2; + if (block->direction & UI_CENTER) center= ysize/2; else center= 0; /* check if there's space at all */ - if( butrct.xmin-xsize > 0.0f) left= 1; - if( butrct.xmax+xsize < winx) right= 1; - if( butrct.ymin-ysize+center > 0.0f) down= 1; - if( butrct.ymax+ysize-center < winy) top= 1; + if ( butrct.xmin-xsize > 0.0f) left= 1; + if ( butrct.xmax+xsize < winx) right= 1; + if ( butrct.ymin-ysize+center > 0.0f) down= 1; + if ( butrct.ymax+ysize-center < winy) top= 1; - if(top==0 && down==0) { + if (top==0 && down==0) { if (butrct.ymin-ysize < winy-butrct.ymax-ysize) top= 1; else @@ -1329,74 +1336,74 @@ static void ui_block_position(wmWindow *window, ARegion *butregion, uiBut *but, dir1= block->direction & UI_DIRECTION; /* secundary directions */ - if(dir1 & (UI_TOP|UI_DOWN)) { - if(dir1 & UI_LEFT) dir2= UI_LEFT; - else if(dir1 & UI_RIGHT) dir2= UI_RIGHT; + if (dir1 & (UI_TOP|UI_DOWN)) { + if (dir1 & UI_LEFT) dir2= UI_LEFT; + else if (dir1 & UI_RIGHT) dir2= UI_RIGHT; dir1 &= (UI_TOP|UI_DOWN); } - if(dir2==0) if(dir1==UI_LEFT || dir1==UI_RIGHT) dir2= UI_DOWN; - if(dir2==0) if(dir1==UI_TOP || dir1==UI_DOWN) dir2= UI_LEFT; + if (dir2==0) if(dir1==UI_LEFT || dir1==UI_RIGHT) dir2= UI_DOWN; + if (dir2==0) if(dir1==UI_TOP || dir1==UI_DOWN) dir2= UI_LEFT; /* no space at all? don't change */ - if(left || right) { - if(dir1==UI_LEFT && left==0) dir1= UI_RIGHT; - if(dir1==UI_RIGHT && right==0) dir1= UI_LEFT; + if (left || right) { + if (dir1==UI_LEFT && left==0) dir1= UI_RIGHT; + if (dir1==UI_RIGHT && right==0) dir1= UI_LEFT; /* this is aligning, not append! */ - if(dir2==UI_LEFT && right==0) dir2= UI_RIGHT; - if(dir2==UI_RIGHT && left==0) dir2= UI_LEFT; + if (dir2==UI_LEFT && right==0) dir2= UI_RIGHT; + if (dir2==UI_RIGHT && left==0) dir2= UI_LEFT; } - if(down || top) { - if(dir1==UI_TOP && top==0) dir1= UI_DOWN; - if(dir1==UI_DOWN && down==0) dir1= UI_TOP; - if(dir2==UI_TOP && top==0) dir2= UI_DOWN; - if(dir2==UI_DOWN && down==0) dir2= UI_TOP; + if (down || top) { + if (dir1==UI_TOP && top==0) dir1= UI_DOWN; + if (dir1==UI_DOWN && down==0) dir1= UI_TOP; + if (dir2==UI_TOP && top==0) dir2= UI_DOWN; + if (dir2==UI_DOWN && down==0) dir2= UI_TOP; } - if(dir1==UI_LEFT) { + if (dir1==UI_LEFT) { xof= butrct.xmin - block->maxx; - if(dir2==UI_TOP) yof= butrct.ymin - block->miny-center; + if (dir2==UI_TOP) yof= butrct.ymin - block->miny-center; else yof= butrct.ymax - block->maxy+center; } - else if(dir1==UI_RIGHT) { + else if (dir1==UI_RIGHT) { xof= butrct.xmax - block->minx; - if(dir2==UI_TOP) yof= butrct.ymin - block->miny-center; + if (dir2==UI_TOP) yof= butrct.ymin - block->miny-center; else yof= butrct.ymax - block->maxy+center; } - else if(dir1==UI_TOP) { + else if (dir1==UI_TOP) { yof= butrct.ymax - block->miny; - if(dir2==UI_RIGHT) xof= butrct.xmax - block->maxx; + if (dir2==UI_RIGHT) xof= butrct.xmax - block->maxx; else xof= butrct.xmin - block->minx; // changed direction? - if((dir1 & block->direction)==0) { - if(block->direction & UI_SHIFT_FLIPPED) + if ((dir1 & block->direction)==0) { + if (block->direction & UI_SHIFT_FLIPPED) xof+= dir2==UI_LEFT?25:-25; uiBlockFlipOrder(block); } } - else if(dir1==UI_DOWN) { + else if (dir1==UI_DOWN) { yof= butrct.ymin - block->maxy; - if(dir2==UI_RIGHT) xof= butrct.xmax - block->maxx; + if (dir2==UI_RIGHT) xof= butrct.xmax - block->maxx; else xof= butrct.xmin - block->minx; // changed direction? - if((dir1 & block->direction)==0) { - if(block->direction & UI_SHIFT_FLIPPED) + if ((dir1 & block->direction)==0) { + if (block->direction & UI_SHIFT_FLIPPED) xof+= dir2==UI_LEFT?25:-25; uiBlockFlipOrder(block); } } /* and now we handle the exception; no space below or to top */ - if(top==0 && down==0) { - if(dir1==UI_LEFT || dir1==UI_RIGHT) { + if (top==0 && down==0) { + if (dir1==UI_LEFT || dir1==UI_RIGHT) { // align with bottom of screen // yof= ysize; (not with menu scrolls) } } /* or no space left or right */ - if(left==0 && right==0) { - if(dir1==UI_TOP || dir1==UI_DOWN) { + if (left==0 && right==0) { + if (dir1==UI_TOP || dir1==UI_DOWN) { // align with left size of screen xof= -block->minx+5; } @@ -1407,16 +1414,16 @@ static void ui_block_position(wmWindow *window, ARegion *butregion, uiBut *but, yof += block->yofs/block->aspect; #if 0 /* clamp to window bounds, could be made into an option if its ever annoying */ - if( (offscreen= (block->miny+yof)) < 0) yof -= offscreen; /* bottom */ - else if((offscreen= (block->maxy+yof)-winy) > 0) yof -= offscreen; /* top */ - if( (offscreen= (block->minx+xof)) < 0) xof -= offscreen; /* left */ - else if((offscreen= (block->maxx+xof)-winx) > 0) xof -= offscreen; /* right */ + if ( (offscreen= (block->miny+yof)) < 0) yof -= offscreen; /* bottom */ + else if ((offscreen= (block->maxy+yof)-winy) > 0) yof -= offscreen; /* top */ + if ( (offscreen= (block->minx+xof)) < 0) xof -= offscreen; /* left */ + else if ((offscreen= (block->maxx+xof)-winx) > 0) xof -= offscreen; /* right */ #endif } /* apply offset, buttons in window coords */ - for(bt= block->buttons.first; bt; bt= bt->next) { + for (bt= block->buttons.first; bt; bt= bt->next) { ui_block_to_window_fl(butregion, but->block, &bt->x1, &bt->y1); ui_block_to_window_fl(butregion, but->block, &bt->x2, &bt->y2); @@ -1436,30 +1443,30 @@ static void ui_block_position(wmWindow *window, ARegion *butregion, uiBut *but, block->maxy += yof; /* safety calculus */ - if(but) { + if (but) { float midx= (butrct.xmin+butrct.xmax)/2.0f; float midy= (butrct.ymin+butrct.ymax)/2.0f; /* when you are outside parent button, safety there should be smaller */ // parent button to left - if( midx < block->minx ) block->safety.xmin = block->minx-3; + if ( midx < block->minx ) block->safety.xmin = block->minx-3; else block->safety.xmin = block->minx-40; // parent button to right - if( midx > block->maxx ) block->safety.xmax = block->maxx+3; + if ( midx > block->maxx ) block->safety.xmax = block->maxx+3; else block->safety.xmax = block->maxx+40; // parent button on bottom - if( midy < block->miny ) block->safety.ymin = block->miny-3; + if ( midy < block->miny ) block->safety.ymin = block->miny-3; else block->safety.ymin = block->miny-40; // parent button on top - if( midy > block->maxy ) block->safety.ymax = block->maxy+3; + if ( midy > block->maxy ) block->safety.ymax = block->maxy+3; else block->safety.ymax = block->maxy+40; // exception for switched pulldowns... - if(dir1 && (dir1 & block->direction)==0) { - if(dir2==UI_RIGHT) block->safety.xmax = block->maxx+3; - if(dir2==UI_LEFT) block->safety.xmin = block->minx-3; + if (dir1 && (dir1 & block->direction)==0) { + if (dir2==UI_RIGHT) block->safety.xmax = block->maxx+3; + if (dir2==UI_LEFT) block->safety.xmin = block->minx-3; } block->direction= dir1; } @@ -1475,7 +1482,7 @@ static void ui_block_position(wmWindow *window, ARegion *butregion, uiBut *but, saferct->parent= butrct; saferct->safety= block->safety; BLI_freelistN(&block->saferct); - if(but) + if (but) BLI_duplicatelist(&block->saferct, &but->block->saferct); BLI_addhead(&block->saferct, saferct); } @@ -1484,7 +1491,7 @@ static void ui_block_region_draw(const bContext *C, ARegion *ar) { uiBlock *block; - for(block=ar->uiblocks.first; block; block=block->next) + for (block=ar->uiblocks.first; block; block=block->next) uiDrawBlock(C, block); } @@ -1494,14 +1501,14 @@ static void ui_popup_block_clip(wmWindow *window, uiBlock *block) wm_window_get_size(window, &winx, &winy); - if(block->minx < MENU_SHADOW_SIDE) + if (block->minx < MENU_SHADOW_SIDE) block->minx= MENU_SHADOW_SIDE; - if(block->maxx > winx-MENU_SHADOW_SIDE) + if (block->maxx > winx-MENU_SHADOW_SIDE) block->maxx= winx-MENU_SHADOW_SIDE; - if(block->miny < MENU_SHADOW_BOTTOM) + if (block->miny < MENU_SHADOW_BOTTOM) block->miny= MENU_SHADOW_BOTTOM; - if(block->maxy > winy-MENU_TOP) + if (block->maxy > winy-MENU_TOP) block->maxy= winy-MENU_TOP; } @@ -1513,33 +1520,33 @@ void ui_popup_block_scrolltest(uiBlock *block) block->flag &= ~(UI_BLOCK_CLIPBOTTOM|UI_BLOCK_CLIPTOP); - for(bt= block->buttons.first; bt; bt= bt->next) + for (bt= block->buttons.first; bt; bt= bt->next) bt->flag &= ~UI_SCROLLED; - if(block->buttons.first==block->buttons.last) + if (block->buttons.first==block->buttons.last) return; /* mark buttons that are outside boundary and the ones next to it for arrow(s) */ - for(bt= block->buttons.first; bt; bt= bt->next) { - if(bt->y1 < block->miny) { + for (bt= block->buttons.first; bt; bt= bt->next) { + if (bt->y1 < block->miny) { bt->flag |= UI_SCROLLED; block->flag |= UI_BLOCK_CLIPBOTTOM; /* make space for arrow */ - if(bt->y2 < block->miny +10) { - if(is_flip && bt->next && bt->next->y1 > bt->y1) + if (bt->y2 < block->miny +10) { + if (is_flip && bt->next && bt->next->y1 > bt->y1) bt->next->flag |= UI_SCROLLED; - else if(!is_flip && bt->prev && bt->prev->y1 > bt->y1) + else if (!is_flip && bt->prev && bt->prev->y1 > bt->y1) bt->prev->flag |= UI_SCROLLED; } } - if(bt->y2 > block->maxy) { + if (bt->y2 > block->maxy) { bt->flag |= UI_SCROLLED; block->flag |= UI_BLOCK_CLIPTOP; /* make space for arrow */ - if(bt->y1 > block->maxy -10) { - if(!is_flip && bt->next && bt->next->y2 < bt->y2) + if (bt->y1 > block->maxy -10) { + if (!is_flip && bt->next && bt->next->y2 < bt->y2) bt->next->flag |= UI_SCROLLED; - else if(is_flip && bt->prev && bt->prev->y2 < bt->y2) + else if (is_flip && bt->prev && bt->prev->y2 < bt->y2) bt->prev->flag |= UI_SCROLLED; } } @@ -1574,12 +1581,12 @@ uiPopupBlockHandle *ui_popup_block_create(bContext *C, ARegion *butregion, uiBut UI_add_region_handlers(&ar->handlers); /* create ui block */ - if(create_func) + if (create_func) block= create_func(C, handle->region, arg); else block= handle_create_func(C, handle, arg); - if(block->handle) { + if (block->handle) { memcpy(block->handle, handle, sizeof(uiPopupBlockHandle)); MEM_freeN(handle); handle= block->handle; @@ -1589,12 +1596,12 @@ uiPopupBlockHandle *ui_popup_block_create(bContext *C, ARegion *butregion, uiBut ar->regiondata= handle; - if(!block->endblock) + if (!block->endblock) uiEndBlock(C, block); /* if this is being created from a button */ - if(but) { - if(ELEM(but->type, BLOCK, PULLDOWN)) + if (but) { + if (ELEM(but->type, BLOCK, PULLDOWN)) block->xofs = -2; /* for proper alignment */ block->aspect = but->block->aspect; @@ -1625,7 +1632,7 @@ uiPopupBlockHandle *ui_popup_block_create(bContext *C, ARegion *butregion, uiBut block->miny -= ar->winrct.ymin; block->maxy -= ar->winrct.ymin; - for(bt= block->buttons.first; bt; bt= bt->next) { + for (bt= block->buttons.first; bt; bt= bt->next) { bt->x1 -= ar->winrct.xmin; bt->x2 -= ar->winrct.xmin; bt->y1 -= ar->winrct.ymin; @@ -1655,7 +1662,7 @@ void ui_popup_block_free(bContext *C, uiPopupBlockHandle *handle) { ui_remove_temporary_region(C, CTX_wm_screen(C), handle->region); - if(handle->scrolltimer) + if (handle->scrolltimer) WM_event_remove_timer(CTX_wm_manager(C), CTX_wm_window(C), handle->scrolltimer); MEM_freeN(handle); @@ -1682,20 +1689,20 @@ static void ui_block_func_MENUSTR(bContext *UNUSED(C), uiLayout *layout, void *a /* columns and row estimation */ columns= (md->nitems+20)/20; - if(columns<1) + if (columns<1) columns= 1; - if(columns>8) + if (columns>8) columns= (md->nitems+25)/25; rows= md->nitems/columns; - if(rows<1) + if (rows<1) rows= 1; - while(rows*columnsnitems) + while (rows*columnsnitems) rows++; /* create title */ - if(md->title) { - if(md->titleicon) { + if (md->title) { + if (md->titleicon) { uiItemL(layout, md->title, md->titleicon); } else { @@ -1707,8 +1714,8 @@ static void ui_block_func_MENUSTR(bContext *UNUSED(C), uiLayout *layout, void *a /* inconsistent, but menus with labels do not look good flipped */ entry= md->items; - for(a=0; anitems; a++, entry++) { - if(entry->sepr && entry->str[0]) { + for (a=0; anitems; a++, entry++) { + if (entry->sepr && entry->str[0]) { block->flag |= UI_BLOCK_NO_FLIP; break; } @@ -1717,18 +1724,18 @@ static void ui_block_func_MENUSTR(bContext *UNUSED(C), uiLayout *layout, void *a /* create items */ split= uiLayoutSplit(layout, 0, 0); - for(a=0; anitems; a++) { - if(a == column_end) { + for (a=0; anitems; a++) { + if (a == column_end) { /* start new column, and find out where it ends in advance, so we * can flip the order of items properly per column */ column_start= a; column_end= md->nitems; - for(b=a+1; bnitems; b++) { + for (b=a+1; bnitems; b++) { entry= &md->items[b]; /* new column on N rows or on separation label */ - if(((b-a) % rows == 0) || (entry->sepr && entry->str[0])) { + if (((b-a) % rows == 0) || (entry->sepr && entry->str[0])) { column_end = b; break; } @@ -1737,17 +1744,17 @@ static void ui_block_func_MENUSTR(bContext *UNUSED(C), uiLayout *layout, void *a column= uiLayoutColumn(split, 0); } - if(block->flag & UI_BLOCK_NO_FLIP) + if (block->flag & UI_BLOCK_NO_FLIP) entry= &md->items[a]; else entry= &md->items[column_start + column_end-1-a]; - if(entry->sepr) { + if (entry->sepr) { uiItemL(column, entry->str, entry->icon); bt= block->buttons.last; bt->flag= UI_TEXT_LEFT; } - else if(entry->icon) { + else if (entry->icon) { uiDefIconTextButF(block, BUTM|FLO, B_NOP, entry->icon, entry->str, 0, 0, UI_UNIT_X*5, UI_UNIT_Y, &handle->retvalue, (float) entry->retval, 0.0, 0, 0, ""); } @@ -1769,7 +1776,7 @@ void ui_block_func_ICONROW(bContext *UNUSED(C), uiLayout *layout, void *arg_but) uiBlockSetFlag(block, UI_BLOCK_MOVEMOUSE_QUIT); - for(a=(int)but->hardmin; a<=(int)but->hardmax; a++) + for (a=(int)but->hardmin; a<=(int)but->hardmax; a++) uiDefIconButF(block, BUTM|FLO, B_NOP, but->icon+(a-but->hardmin), 0, 0, UI_UNIT_X*5, UI_UNIT_Y, &handle->retvalue, (float)a, 0.0, 0, 0, ""); } @@ -1788,16 +1795,16 @@ void ui_block_func_ICONTEXTROW(bContext *UNUSED(C), uiLayout *layout, void *arg_ md= decompose_menu_string(but->str); /* title */ - if(md->title) { + if (md->title) { bt= uiDefBut(block, LABEL, 0, md->title, 0, 0, UI_UNIT_X*5, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, ""); bt->flag= UI_TEXT_LEFT; } /* loop through the menu options and draw them out with icons & text labels */ - for(a=0; anitems; a++) { + for (a=0; anitems; a++) { entry= &md->items[md->nitems-a-1]; - if(entry->sepr) + if (entry->sepr) uiItemS(layout); else uiDefIconTextButF(block, BUTM|FLO, B_NOP, (short)((but->icon)+(entry->retval-but->hardmin)), entry->str, @@ -1849,13 +1856,13 @@ static void ui_update_block_buts_rgb(uiBlock *block, float *rgb) rgb_to_hsv_compat(rgb[0], rgb[1], rgb[2], hsv, hsv+1, hsv+2); // this updates button strings, is hackish... but button pointers are on stack of caller function - for(bt= block->buttons.first; bt; bt= bt->next) { + for (bt= block->buttons.first; bt; bt= bt->next) { if (bt->rnaprop) { ui_set_but_vectorf(bt, rgb); } - else if(strcmp(bt->str, "Hex: ")==0) { + else if (strcmp(bt->str, "Hex: ")==0) { float rgb_gamma[3]; double intpart; char col[16]; @@ -1864,7 +1871,8 @@ static void ui_update_block_buts_rgb(uiBlock *block, float *rgb) if (block->color_profile == BLI_PR_NONE) { copy_v3_v3(rgb_gamma, rgb); - } else { + } + else { /* make an sRGB version, for Hex code */ linearrgb_to_srgb_v3_v3(rgb_gamma, rgb); } @@ -1877,23 +1885,23 @@ static void ui_update_block_buts_rgb(uiBlock *block, float *rgb) strcpy(bt->poin, col); } - else if(bt->str[1]==' ') { - if(bt->str[0]=='R') { + else if (bt->str[1]==' ') { + if (bt->str[0]=='R') { ui_set_but_val(bt, rgb[0]); } - else if(bt->str[0]=='G') { + else if (bt->str[0]=='G') { ui_set_but_val(bt, rgb[1]); } - else if(bt->str[0]=='B') { + else if (bt->str[0]=='B') { ui_set_but_val(bt, rgb[2]); } - else if(bt->str[0]=='H') { + else if (bt->str[0]=='H') { ui_set_but_val(bt, hsv[0]); } - else if(bt->str[0]=='S') { + else if (bt->str[0]=='S') { ui_set_but_val(bt, hsv[1]); } - else if(bt->str[0]=='V') { + else if (bt->str[0]=='V') { ui_set_but_val(bt, hsv[2]); } } @@ -1915,7 +1923,7 @@ static void do_picker_rna_cb(bContext *UNUSED(C), void *bt1, void *UNUSED(arg)) ui_update_block_buts_rgb(but->block, rgb); } - if(popup) + if (popup) popup->menuretval= UI_RETURN_UPDATE; } @@ -1930,7 +1938,7 @@ static void do_hsv_rna_cb(bContext *UNUSED(C), void *bt1, void *UNUSED(arg)) ui_update_block_buts_rgb(but->block, rgb); - if(popup) + if (popup) popup->menuretval= UI_RETURN_UPDATE; } @@ -1951,7 +1959,7 @@ static void do_hex_rna_cb(bContext *UNUSED(C), void *bt1, void *hexcl) ui_update_block_buts_rgb(but->block, rgb); - if(popup) + if (popup) popup->menuretval= UI_RETURN_UPDATE; } @@ -1960,7 +1968,7 @@ static void close_popup_cb(bContext *UNUSED(C), void *bt1, void *UNUSED(arg)) uiBut *but= (uiBut *)bt1; uiPopupBlockHandle *popup= but->block->handle; - if(popup) + if (popup) popup->menuretval= UI_RETURN_OK; } @@ -1969,26 +1977,26 @@ static void picker_new_hide_reveal(uiBlock *block, short colormode) uiBut *bt; /* tag buttons */ - for(bt= block->buttons.first; bt; bt= bt->next) { + for (bt= block->buttons.first; bt; bt= bt->next) { if (bt->type == LABEL) { - if( bt->str[1]=='G') { - if(colormode==2) bt->flag &= ~UI_HIDDEN; + if ( bt->str[1]=='G') { + if (colormode==2) bt->flag &= ~UI_HIDDEN; else bt->flag |= UI_HIDDEN; } } - if(bt->type==NUMSLI || bt->type==TEX) { - if( bt->str[1]=='e') { - if(colormode==2) bt->flag &= ~UI_HIDDEN; + if (bt->type==NUMSLI || bt->type==TEX) { + if ( bt->str[1]=='e') { + if (colormode==2) bt->flag &= ~UI_HIDDEN; else bt->flag |= UI_HIDDEN; } - else if( ELEM3(bt->str[0], 'R', 'G', 'B')) { - if(colormode==0) bt->flag &= ~UI_HIDDEN; + else if ( ELEM3(bt->str[0], 'R', 'G', 'B')) { + if (colormode==0) bt->flag &= ~UI_HIDDEN; else bt->flag |= UI_HIDDEN; } - else if( ELEM3(bt->str[0], 'H', 'S', 'V')) { - if(colormode==1) bt->flag &= ~UI_HIDDEN; + else if ( ELEM3(bt->str[0], 'H', 'S', 'V')) { + if (colormode==1) bt->flag &= ~UI_HIDDEN; else bt->flag |= UI_HIDDEN; } } @@ -2063,7 +2071,8 @@ static void uiBlockPicker(uiBlock *block, float *rgb, PointerRNA *ptr, PropertyR if (block->color_profile == BLI_PR_NONE) { BLI_strncpy(tip, "Value in Display Color Space", sizeof(tip)); copy_v3_v3(rgb_gamma, rgb); - } else { + } + else { BLI_strncpy(tip, "Value in Linear RGB Color Space", sizeof(tip)); /* make an sRGB version, for Hex code */ linearrgb_to_srgb_v3_v3(rgb_gamma, rgb); @@ -2125,7 +2134,7 @@ static void uiBlockPicker(uiBlock *block, float *rgb, PointerRNA *ptr, PropertyR uiButSetFunc(bt, do_hsv_rna_cb, bt, hsv); uiBlockEndAlign(block); - if(rgb[3] != FLT_MAX) { + if (rgb[3] != FLT_MAX) { bt= uiDefButR_prop(block, NUMSLI, 0, "A ", 0, -120, butwidth, UI_UNIT_Y, ptr, prop, 3, 0.0, 0.0, 0, 0, "Alpha"); uiButSetFunc(bt, do_picker_rna_cb, bt, NULL); } @@ -2149,16 +2158,16 @@ static int ui_picker_small_wheel_cb(const bContext *UNUSED(C), uiBlock *block, w { float add= 0.0f; - if(event->type==WHEELUPMOUSE) + if (event->type==WHEELUPMOUSE) add= 0.05f; - else if(event->type==WHEELDOWNMOUSE) + else if (event->type==WHEELDOWNMOUSE) add= -0.05f; - if(add!=0.0f) { + if (add!=0.0f) { uiBut *but; - for(but= block->buttons.first; but; but= but->next) { - if(but->type==HSVCUBE && but->active==NULL) { + for (but= block->buttons.first; but; but= but->next) { + if (but->type==HSVCUBE && but->active==NULL) { uiPopupBlockHandle *popup= block->handle; float col[3]; float *hsv= ui_block_hsv_get(block); @@ -2172,7 +2181,7 @@ static int ui_picker_small_wheel_cb(const bContext *UNUSED(C), uiBlock *block, w ui_set_but_vectorf(but, col); ui_update_block_buts_rgb(block, col); - if(popup) + if (popup) popup->menuretval= UI_RETURN_UPDATE; return 1; @@ -2220,9 +2229,9 @@ static int ui_popup_string_hash(char *str) int hash; char *delimit= strchr(str, '|'); - if(delimit) *delimit= 0; + if (delimit) *delimit= 0; hash= BLI_ghashutil_strhash(str); - if(delimit) *delimit= '|'; + if (delimit) *delimit= '|'; return hash; } @@ -2238,21 +2247,21 @@ uiBut *ui_popup_menu_memory(uiBlock *block, uiBut *but) static int mem[256], first=1; int hash= block->puphash; - if(first) { + if (first) { /* init */ memset(mem, -1, sizeof(mem)); first= 0; } - if(but) { + if (but) { /* set */ mem[hash & 255 ]= ui_popup_string_hash(but->str); return NULL; } else { /* get */ - for(but=block->buttons.first; but; but=but->next) - if(ui_popup_string_hash(but->str) == mem[hash & 255]) + for (but=block->buttons.first; but; but=but->next) + if (ui_popup_string_hash(but->str) == mem[hash & 255]) return but; return NULL; @@ -2280,17 +2289,17 @@ static uiBlock *ui_block_func_POPUP(bContext *C, uiPopupBlockHandle *handle, voi uiPopupMenu *pup= arg_pup; int offset[2], direction, minwidth, width, height, flip; - if(pup->menu_func) { + if (pup->menu_func) { pup->block->handle= handle; pup->menu_func(C, pup->layout, pup->menu_arg); pup->block->handle= NULL; } - if(pup->but) { + if (pup->but) { /* minimum width to enforece */ minwidth= pup->but->x2 - pup->but->x1; - if(pup->but->type == PULLDOWN || pup->but->menu_create_func) { + if (pup->but->type == PULLDOWN || pup->but->menu_create_func) { direction= UI_DOWN; flip= 1; } @@ -2309,7 +2318,7 @@ static uiBlock *ui_block_func_POPUP(bContext *C, uiPopupBlockHandle *handle, voi /* in some cases we create the block before the region, * so we set it delayed here if necessary */ - if(BLI_findindex(&handle->region->uiblocks, block) == -1) + if (BLI_findindex(&handle->region->uiblocks, block) == -1) uiBlockSetRegion(block, handle->region); block->direction= direction; @@ -2318,12 +2327,12 @@ static uiBlock *ui_block_func_POPUP(bContext *C, uiPopupBlockHandle *handle, voi uiBlockSetFlag(block, UI_BLOCK_MOVEMOUSE_QUIT); - if(pup->popup) { + if (pup->popup) { uiBlockSetFlag(block, UI_BLOCK_LOOP|UI_BLOCK_REDRAW|UI_BLOCK_NUMSELECT|UI_BLOCK_RET_1); uiBlockSetDirection(block, direction); /* offset the mouse position, possibly based on earlier selection */ - if((block->flag & UI_BLOCK_POPUP_MEMORY) && + if ((block->flag & UI_BLOCK_POPUP_MEMORY) && (bt= ui_popup_menu_memory(block, NULL))) { /* position mouse on last clicked item, at 0.8*width of the * button, so it doesn't overlap the text too much, also note @@ -2336,7 +2345,7 @@ static uiBlock *ui_block_func_POPUP(bContext *C, uiPopupBlockHandle *handle, voi /* position mouse at 0.8*width of the button and below the tile * on the first item */ offset[0]= 0; - for(bt=block->buttons.first; bt; bt=bt->next) + for (bt=block->buttons.first; bt; bt=bt->next) offset[0]= MIN2(offset[0], -(bt->x1 + 0.8f*(bt->x2 - bt->x1))); offset[1]= 1.5*UI_UNIT_Y; @@ -2347,11 +2356,11 @@ static uiBlock *ui_block_func_POPUP(bContext *C, uiPopupBlockHandle *handle, voi } else { /* for a header menu we set the direction automatic */ - if(!pup->slideout && flip) { + if (!pup->slideout && flip) { ScrArea *sa= CTX_wm_area(C); - if(sa && sa->headertype==HEADERDOWN) { + if (sa && sa->headertype==HEADERDOWN) { ARegion *ar= CTX_wm_region(C); - if(ar && ar->regiontype == RGN_TYPE_HEADER) { + if (ar && ar->regiontype == RGN_TYPE_HEADER) { uiBlockSetDirection(block, UI_TOP); uiBlockFlipOrder(block); } @@ -2363,7 +2372,7 @@ static uiBlock *ui_block_func_POPUP(bContext *C, uiPopupBlockHandle *handle, voi } /* if menu slides out of other menu, override direction */ - if(pup->slideout) + if (pup->slideout) uiBlockSetDirection(block, UI_RIGHT); uiEndBlock(C, block); @@ -2384,7 +2393,7 @@ uiPopupBlockHandle *ui_popup_menu_create(bContext *C, ARegion *butregion, uiBut pup->but= but; uiLayoutSetOperatorContext(pup->layout, WM_OP_INVOKE_REGION_WIN); - if(!but) { + if (!but) { /* no button to start from, means we are a popup */ pup->mx= window->eventstate->x; pup->my= window->eventstate->y; @@ -2399,13 +2408,13 @@ uiPopupBlockHandle *ui_popup_menu_create(bContext *C, ARegion *butregion, uiBut /* if this is an rna button then we can assume its an enum * flipping enums is generally not good since the order can be * important [#28786] */ - if(but->rnaprop && RNA_property_type(but->rnaprop) == PROP_ENUM) { + if (but->rnaprop && RNA_property_type(but->rnaprop) == PROP_ENUM) { pup->block->flag |= UI_BLOCK_NO_FLIP; } } #endif - if(str) { + if (str) { /* menu is created from a string */ pup->menu_func= ui_block_func_MENUSTR; pup->menu_arg= str; @@ -2418,7 +2427,7 @@ uiPopupBlockHandle *ui_popup_menu_create(bContext *C, ARegion *butregion, uiBut handle= ui_popup_block_create(C, butregion, but, NULL, ui_block_func_POPUP, pup); - if(!but) { + if (!but) { handle->popup= 1; UI_add_popup_handlers(C, &window->modalhandlers, handle); @@ -2449,10 +2458,10 @@ uiPopupMenu *uiPupMenuBegin(bContext *C, const char *title, int icon) pup->block->handle= MEM_callocN(sizeof(uiPopupBlockHandle), "uiPopupBlockHandle"); /* create title button */ - if(title && title[0]) { + if (title && title[0]) { char titlestr[256]; - if(icon) { + if (icon) { BLI_snprintf(titlestr, sizeof(titlestr), " %s", title); uiDefIconTextBut(pup->block, LABEL, 0, icon, titlestr, 0, 0, 200, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, ""); } @@ -2495,7 +2504,7 @@ static void operator_name_cb(bContext *C, void *arg, int retval) { const char *opname= arg; - if(opname && retval > 0) + if (opname && retval > 0) WM_operator_name_call(C, opname, WM_OP_EXEC_DEFAULT, NULL); } @@ -2503,7 +2512,7 @@ static void operator_cb(bContext *C, void *arg, int retval) { wmOperator *op= arg; - if(op && retval > 0) + if (op && retval > 0) WM_operator_call(C, op); else WM_operator_free(op); @@ -2598,26 +2607,26 @@ void uiPupMenuReports(bContext *C, ReportList *reports) DynStr *ds; char *str; - if(!reports || !reports->list.first) + if (!reports || !reports->list.first) return; - if(!CTX_wm_window(C)) + if (!CTX_wm_window(C)) return; ds= BLI_dynstr_new(); - for(report=reports->list.first; report; report=report->next) { - if(report->type < reports->printlevel) + for (report=reports->list.first; report; report=report->next) { + if (report->type < reports->printlevel) ; /* pass */ - else if(report->type >= RPT_ERROR) + else if (report->type >= RPT_ERROR) BLI_dynstr_appendf(ds, "Error %%i%d%%t|%s", ICON_ERROR, report->message); - else if(report->type >= RPT_WARNING) + else if (report->type >= RPT_WARNING) BLI_dynstr_appendf(ds, "Warning %%i%d%%t|%s", ICON_ERROR, report->message); - else if(report->type >= RPT_INFO) + else if (report->type >= RPT_INFO) BLI_dynstr_appendf(ds, "Info %%i%d%%t|%s", ICON_INFO, report->message); } str= BLI_dynstr_get_cstring(ds); - if(str[0] != '\0') + if (str[0] != '\0') ui_popup_menu_create(C, NULL, NULL, NULL, NULL, str); MEM_freeN(str); @@ -2631,12 +2640,12 @@ void uiPupMenuInvoke(bContext *C, const char *idname) Menu menu; MenuType *mt = WM_menutype_find(idname, TRUE); - if(mt==NULL) { + if (mt==NULL) { printf("%s: named menu \"%s\" not found\n", __func__, idname); return; } - if(mt->poll && mt->poll(C, mt)==0) + if (mt->poll && mt->poll(C, mt)==0) return; pup= uiPupMenuBegin(C, mt->label, ICON_NONE); @@ -2712,11 +2721,11 @@ void uiPupBlockOperator(bContext *C, uiBlockCreateFunc func, wmOperator *op, int void uiPupBlockClose(bContext *C, uiBlock *block) { - if(block->handle) { + if (block->handle) { wmWindow *win = CTX_wm_window(C); /* if loading new .blend while popup is open, window will be NULL */ - if(win) { + if (win) { UI_remove_popup_handlers(&win->modalhandlers, block->handle); ui_popup_block_free(C, block->handle); } diff --git a/source/blender/editors/interface/interface_style.c b/source/blender/editors/interface/interface_style.c index 580b0ff05dc..6a2038b18bc 100644 --- a/source/blender/editors/interface/interface_style.c +++ b/source/blender/editors/interface/interface_style.c @@ -132,8 +132,8 @@ static uiFont *uifont_to_blfont(int id) { uiFont *font= U.uifonts.first; - for(; font; font= font->next) { - if(font->uifont_id==id) { + for (; font; font= font->next) { + if (font->uifont_id==id) { return font; } } @@ -154,14 +154,14 @@ void uiStyleFontDrawExt(uiFontStyle *fs, rcti *rect, const char *str, height= BLF_ascender(fs->uifont_id); yofs= ceil( 0.5f*(rect->ymax - rect->ymin - height)); - if(fs->align==UI_STYLE_TEXT_CENTER) { + if (fs->align==UI_STYLE_TEXT_CENTER) { xofs= floor( 0.5f*(rect->xmax - rect->xmin - BLF_width(fs->uifont_id, str))); /* don't center text if it chops off the start of the text, 2 gives some margin */ - if(xofs < 2) { + if (xofs < 2) { xofs= 2; } } - else if(fs->align==UI_STYLE_TEXT_RIGHT) { + else if (fs->align==UI_STYLE_TEXT_RIGHT) { xofs= rect->xmax - rect->xmin - BLF_width(fs->uifont_id, str) - 1; } @@ -306,12 +306,12 @@ void uiStyleInit(void) uiStyle *style= U.uistyles.first; /* recover from uninitialized dpi */ - if(U.dpi == 0) + if (U.dpi == 0) U.dpi= 72; CLAMP(U.dpi, 48, 128); /* default builtin */ - if(font==NULL) { + if (font==NULL) { font= MEM_callocN(sizeof(uiFont), "ui font"); BLI_addtail(&U.uifonts, font); @@ -319,19 +319,19 @@ void uiStyleInit(void) font->uifont_id= UIFONT_DEFAULT; } - for(font= U.uifonts.first; font; font= font->next) { + for (font= U.uifonts.first; font; font= font->next) { - if(font->uifont_id==UIFONT_DEFAULT) { + if (font->uifont_id==UIFONT_DEFAULT) { #ifdef WITH_INTERNATIONAL int font_size= datatoc_bfont_ttf_size; unsigned char *font_ttf= (unsigned char*)datatoc_bfont_ttf; static int last_font_size = 0; /* use unicode font for translation */ - if(U.transopts & USER_DOTRANSLATE) { + if (U.transopts & USER_DOTRANSLATE) { font_ttf= BLF_get_unifont(&font_size); - if(!font_ttf) { + if (!font_ttf) { /* fall back if not found */ font_size= datatoc_bfont_ttf_size; font_ttf= (unsigned char*)datatoc_bfont_ttf; @@ -339,7 +339,7 @@ void uiStyleInit(void) } /* relload only if needed */ - if(last_font_size != font_size) { + if (last_font_size != font_size) { BLF_unload("default"); last_font_size = font_size; } @@ -351,7 +351,7 @@ void uiStyleInit(void) } else { font->blf_id= BLF_load(font->filename); - if(font->blf_id == -1) + if (font->blf_id == -1) font->blf_id= BLF_load_mem("default", (unsigned char*)datatoc_bfont_ttf, datatoc_bfont_ttf_size); } @@ -370,7 +370,7 @@ void uiStyleInit(void) } } - if(style==NULL) { + if (style==NULL) { ui_style_new(&U.uistyles, "Default Style", UIFONT_DEFAULT ); } diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index ca6b37f9013..d47bd44d8f7 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -84,7 +84,7 @@ void uiTemplateHeader(uiLayout *layout, bContext *C, int menus) uiBlock *block; block= uiLayoutAbsoluteBlock(layout); - if(menus) ED_area_header_standardbuttons(C, block, 0); + if (menus) ED_area_header_standardbuttons(C, block, 0); else ED_area_header_switchbutton(C, block, 0); } @@ -105,7 +105,7 @@ static void id_search_call_cb(bContext *C, void *arg_template, void *item) TemplateID *template= (TemplateID*)arg_template; /* ID */ - if(item) { + if (item) { PointerRNA idptr; RNA_id_pointer_create(item, &idptr); @@ -124,29 +124,29 @@ static void id_search_cb(const bContext *C, void *arg_template, const char *str, int flag= RNA_property_flag(template->prop); /* ID listbase */ - for(id= lb->first; id; id= id->next) { - if(!((flag & PROP_ID_SELF_CHECK) && id == id_from)) { + for (id= lb->first; id; id= id->next) { + if (!((flag & PROP_ID_SELF_CHECK) && id == id_from)) { /* use filter */ - if(RNA_property_type(template->prop)==PROP_POINTER) { + if (RNA_property_type(template->prop)==PROP_POINTER) { PointerRNA ptr; RNA_id_pointer_create(id, &ptr); - if(RNA_property_pointer_poll(&template->ptr, template->prop, &ptr)==0) + if (RNA_property_pointer_poll(&template->ptr, template->prop, &ptr)==0) continue; } /* hide dot-datablocks, but only if filter does not force it visible */ - if(U.uiflag & USER_HIDE_DOT) + if (U.uiflag & USER_HIDE_DOT) if ((id->name[2]=='.') && (str[0] != '.')) continue; - if(BLI_strcasestr(id->name+2, str)) { + if (BLI_strcasestr(id->name+2, str)) { char name_ui[MAX_ID_NAME]; name_uiprefix_id(name_ui, id); iconid= ui_id_icon_get((bContext*)C, id, template->preview); - if(!uiSearchItemAdd(items, name_ui, id, iconid)) + if (!uiSearchItemAdd(items, name_ui, id, iconid)) break; } } @@ -221,14 +221,14 @@ void uiIDContextProperty(bContext *C, PointerRNA *ptr, PropertyRNA **prop) memset(ptr, 0, sizeof(*ptr)); *prop= NULL; - if(!ar) + if (!ar) return; - for(block=ar->uiblocks.first; block; block=block->next) { - for(but=block->buttons.first; but; but= but->next) { + for (block=ar->uiblocks.first; block; block=block->next) { + for (but=block->buttons.first; but; but= but->next) { /* find the button before the active one */ - if((but->flag & (UI_BUT_LAST_ACTIVE|UI_ACTIVE))) { - if(but->func_argN) { + if ((but->flag & (UI_BUT_LAST_ACTIVE|UI_ACTIVE))) { + if (but->func_argN) { template= but->func_argN; *ptr= template->ptr; *prop= template->prop; @@ -261,20 +261,20 @@ static void template_id_cb(bContext *C, void *arg_litem, void *arg_event) RNA_property_pointer_set(&template->ptr, template->prop, idptr); RNA_property_update(C, &template->ptr, template->prop); - if(id && CTX_wm_window(C)->eventstate->shift) /* useful hidden functionality, */ + if (id && CTX_wm_window(C)->eventstate->shift) /* useful hidden functionality, */ id->us= 0; break; case UI_ID_FAKE_USER: - if(id) { - if(id->flag & LIB_FAKEUSER) id_us_plus(id); + if (id) { + if (id->flag & LIB_FAKEUSER) id_us_plus(id); else id_us_min(id); } else return; break; case UI_ID_LOCAL: - if(id) { - if(id_make_local(id, 0)) { + if (id) { + if (id_make_local(id, 0)) { /* reassign to get get proper updates/notifiers */ idptr= RNA_property_pointer_get(&template->ptr, template->prop); RNA_property_pointer_set(&template->ptr, template->prop, idptr); @@ -283,18 +283,18 @@ static void template_id_cb(bContext *C, void *arg_litem, void *arg_event) } break; case UI_ID_ALONE: - if(id) { + if (id) { const int do_scene_obj= (GS(id->name) == ID_OB) && (template->ptr.type == &RNA_SceneObjects); /* make copy */ - if(do_scene_obj) { + if (do_scene_obj) { Scene *scene= CTX_data_scene(C); ED_object_single_user(scene, (struct Object *)id); WM_event_add_notifier(C, NC_SCENE|ND_OB_ACTIVE, scene); } else { - if(id) { + if (id) { id_single_user(C, id, &template->ptr, template->prop); } } @@ -309,7 +309,7 @@ static void template_id_cb(bContext *C, void *arg_litem, void *arg_event) static const char *template_id_browse_tip(StructRNA *type) { - if(type) { + if (type) { switch(RNA_type_to_ID_code(type)) { case ID_SCE: return N_("Browse Scene to be linked"); case ID_OB: return N_("Browse Object to be linked"); @@ -355,40 +355,40 @@ static void template_ID(bContext *C, uiLayout *layout, TemplateID *template, Str block= uiLayoutGetBlock(layout); uiBlockBeginAlign(block); - if(idptr.type) + if (idptr.type) type= idptr.type; - if(flag & UI_ID_PREVIEWS) { + if (flag & UI_ID_PREVIEWS) { but = uiDefBlockButN(block, id_search_menu, MEM_dupallocN(template), "", 0, 0, UI_UNIT_X*6, UI_UNIT_Y*6, TIP_(template_id_browse_tip(type))); - if(type) { + if (type) { but->icon= RNA_struct_ui_icon(type); if (id) but->icon = ui_id_icon_get(C, id, 1); uiButSetFlag(but, UI_HAS_ICON|UI_ICON_PREVIEW); } - if((idfrom && idfrom->lib) || !editable) + if ((idfrom && idfrom->lib) || !editable) uiButSetFlag(but, UI_BUT_DISABLED); uiLayoutRow(layout, 1); template->preview= 1; } - else if(flag & UI_ID_BROWSE) { + else if (flag & UI_ID_BROWSE) { but = uiDefBlockButN(block, id_search_menu, MEM_dupallocN(template), "", 0, 0, UI_UNIT_X*1.6, UI_UNIT_Y, TIP_(template_id_browse_tip(type))); - if(type) { + if (type) { but->icon= RNA_struct_ui_icon(type); /* default dragging of icon for id browse buttons */ uiButSetDragID(but, id); uiButSetFlag(but, UI_HAS_ICON|UI_ICON_LEFT); } - if((idfrom && idfrom->lib) || !editable) + if ((idfrom && idfrom->lib) || !editable) uiButSetFlag(but, UI_BUT_DISABLED); } /* text button with name */ - if(id) { + if (id) { char name[UI_MAX_NAME_STR]; const short user_alert= (id->us <= 0); @@ -396,10 +396,10 @@ static void template_ID(bContext *C, uiLayout *layout, TemplateID *template, Str name[0]= '\0'; but = uiDefButR(block, TEX, 0, name, 0, 0, UI_UNIT_X*6, UI_UNIT_Y, &idptr, "name", -1, 0, 0, -1, -1, NULL); uiButSetNFunc(but, template_id_cb, MEM_dupallocN(template), SET_INT_IN_POINTER(UI_ID_RENAME)); - if(user_alert) uiButSetFlag(but, UI_BUT_REDALERT); + if (user_alert) uiButSetFlag(but, UI_BUT_REDALERT); - if(id->lib) { - if(id->flag & LIB_INDIRECT) { + if (id->lib) { + if (id->flag & LIB_INDIRECT) { but = uiDefIconBut(block, BUT, 0, ICON_LIBRARY_DATA_INDIRECT, 0,0,UI_UNIT_X,UI_UNIT_Y, NULL, 0, 0, 0, 0, TIP_("Indirect library datablock, cannot change")); uiButSetFlag(but, UI_BUT_DISABLED); @@ -407,14 +407,14 @@ static void template_ID(bContext *C, uiLayout *layout, TemplateID *template, Str else { but = uiDefIconBut(block, BUT, 0, ICON_LIBRARY_DATA_DIRECT, 0,0,UI_UNIT_X,UI_UNIT_Y, NULL, 0, 0, 0, 0, TIP_("Direct linked library datablock, click to make local")); - if(!id_make_local(id, 1 /* test */) || (idfrom && idfrom->lib)) + if (!id_make_local(id, 1 /* test */) || (idfrom && idfrom->lib)) uiButSetFlag(but, UI_BUT_DISABLED); } uiButSetNFunc(but, template_id_cb, MEM_dupallocN(template), SET_INT_IN_POINTER(UI_ID_LOCAL)); } - if(id->us > 1) { + if (id->us > 1) { char numstr[32]; BLI_snprintf(numstr, sizeof(numstr), "%d", id->us); @@ -423,21 +423,21 @@ static void template_ID(bContext *C, uiLayout *layout, TemplateID *template, Str TIP_("Display number of users of this data (click to make a single-user copy)")); uiButSetNFunc(but, template_id_cb, MEM_dupallocN(template), SET_INT_IN_POINTER(UI_ID_ALONE)); - if(!id_copy(id, NULL, 1 /* test only */) || (idfrom && idfrom->lib) || !editable) + if (!id_copy(id, NULL, 1 /* test only */) || (idfrom && idfrom->lib) || !editable) uiButSetFlag(but, UI_BUT_DISABLED); } - if(user_alert) uiButSetFlag(but, UI_BUT_REDALERT); + if (user_alert) uiButSetFlag(but, UI_BUT_REDALERT); - if(id->lib == NULL && !(ELEM5(GS(id->name), ID_GR, ID_SCE, ID_SCR, ID_TXT, ID_OB))) { + if (id->lib == NULL && !(ELEM5(GS(id->name), ID_GR, ID_SCE, ID_SCR, ID_TXT, ID_OB))) { uiDefButR(block, TOG, 0, "F", 0, 0, UI_UNIT_X, UI_UNIT_Y, &idptr, "use_fake_user", -1, 0, 0, -1, -1, NULL); } } - if(flag & UI_ID_ADD_NEW) { + if (flag & UI_ID_ADD_NEW) { int w= id?UI_UNIT_X: (flag & UI_ID_OPEN)? UI_UNIT_X*3: UI_UNIT_X*6; - if(newop) { + if (newop) { but = uiDefIconTextButO(block, BUT, newop, WM_OP_INVOKE_DEFAULT, ICON_ZOOMIN, (id)? "": IFACE_("New"), 0, 0, w, UI_UNIT_Y, NULL); uiButSetNFunc(but, template_id_cb, MEM_dupallocN(template), SET_INT_IN_POINTER(UI_ID_ADD_NEW)); } @@ -446,14 +446,14 @@ static void template_ID(bContext *C, uiLayout *layout, TemplateID *template, Str uiButSetNFunc(but, template_id_cb, MEM_dupallocN(template), SET_INT_IN_POINTER(UI_ID_ADD_NEW)); } - if((idfrom && idfrom->lib) || !editable) + if ((idfrom && idfrom->lib) || !editable) uiButSetFlag(but, UI_BUT_DISABLED); } - if(flag & UI_ID_OPEN) { + if (flag & UI_ID_OPEN) { int w= id?UI_UNIT_X: (flag & UI_ID_ADD_NEW)? UI_UNIT_X*3: UI_UNIT_X*6; - if(openop) { + if (openop) { but = uiDefIconTextButO(block, BUT, openop, WM_OP_INVOKE_DEFAULT, ICON_FILESEL, (id)? "": IFACE_("Open"), 0, 0, w, UI_UNIT_Y, NULL); uiButSetNFunc(but, template_id_cb, MEM_dupallocN(template), SET_INT_IN_POINTER(UI_ID_OPEN)); } @@ -462,13 +462,13 @@ static void template_ID(bContext *C, uiLayout *layout, TemplateID *template, Str uiButSetNFunc(but, template_id_cb, MEM_dupallocN(template), SET_INT_IN_POINTER(UI_ID_OPEN)); } - if((idfrom && idfrom->lib) || !editable) + if ((idfrom && idfrom->lib) || !editable) uiButSetFlag(but, UI_BUT_DISABLED); } /* delete button */ - if(id && (flag & UI_ID_DELETE) && (RNA_property_flag(template->prop) & PROP_NEVER_UNLINK)==0) { - if(unlinkop) { + if (id && (flag & UI_ID_DELETE) && (RNA_property_flag(template->prop) & PROP_NEVER_UNLINK)==0) { + if (unlinkop) { but = uiDefIconButO(block, BUT, unlinkop, WM_OP_INVOKE_REGION_WIN, ICON_X, 0, 0, UI_UNIT_X, UI_UNIT_Y, NULL); /* so we can access the template from operators, font unlinking needs this */ uiButSetNFunc(but, NULL, MEM_dupallocN(template), NULL); @@ -478,15 +478,15 @@ static void template_ID(bContext *C, uiLayout *layout, TemplateID *template, Str TIP_("Unlink datablock. Shift + Click to set users to zero, data will then not be saved")); uiButSetNFunc(but, template_id_cb, MEM_dupallocN(template), SET_INT_IN_POINTER(UI_ID_DELETE)); - if(RNA_property_flag(template->prop) & PROP_NEVER_NULL) + if (RNA_property_flag(template->prop) & PROP_NEVER_NULL) uiButSetFlag(but, UI_BUT_DISABLED); } - if((idfrom && idfrom->lib) || !editable) + if ((idfrom && idfrom->lib) || !editable) uiButSetFlag(but, UI_BUT_DISABLED); } - if(idcode == ID_TE) + if (idcode == ID_TE) uiTemplateTextureShow(layout, C, &template->ptr, template->prop); uiBlockEndAlign(block); @@ -501,7 +501,7 @@ static void ui_template_id(uiLayout *layout, bContext *C, PointerRNA *ptr, const prop= RNA_struct_find_property(ptr, propname); - if(!prop || RNA_property_type(prop) != PROP_POINTER) { + if (!prop || RNA_property_type(prop) != PROP_POINTER) { RNA_warning("pointer property not found: %s.%s", RNA_struct_identifier(ptr->type), propname); return; } @@ -512,9 +512,9 @@ static void ui_template_id(uiLayout *layout, bContext *C, PointerRNA *ptr, const template->prv_rows = prv_rows; template->prv_cols = prv_cols; - if(newop) + if (newop) flag |= UI_ID_ADD_NEW; - if(openop) + if (openop) flag |= UI_ID_OPEN; type= RNA_property_pointer_type(ptr, prop); @@ -524,7 +524,7 @@ static void ui_template_id(uiLayout *layout, bContext *C, PointerRNA *ptr, const /* create UI elements for this template * - template_ID makes a copy of the template data and assigns it to the relevant buttons */ - if(template->idlb) { + if (template->idlb) { uiLayoutRow(layout, 1); template_ID(C, layout, template, type, idcode, flag, newop, openop, unlinkop); } @@ -649,9 +649,9 @@ static void modifiers_setOnCage(bContext *C, void *ob_v, void *md_v) /* undo button operation */ md->mode ^= eModifierMode_OnCage; - for(i = 0, md=ob->modifiers.first; md; ++i, md=md->next) { - if(md == md_v) { - if(i >= cageIndex) + for (i = 0, md=ob->modifiers.first; md; ++i, md=md->next) { + if (md == md_v) { + if (i >= cageIndex) md->mode ^= eModifierMode_OnCage; break; } @@ -685,8 +685,8 @@ static void modifiers_convertToReal(bContext *C, void *ob_v, void *md_v) static int modifier_can_delete(ModifierData *md) { /* fluid particle modifier can't be deleted here */ - if(md->type == eModifierType_ParticleSystem) - if(((ParticleSystemModifierData *)md)->psys->part->type == PART_FLUID) + if (md->type == eModifierType_ParticleSystem) + if (((ParticleSystemModifierData *)md)->psys->part->type == PART_FLUID) return 0; return 1; @@ -800,7 +800,8 @@ static uiLayout *draw_modifier(uiLayout *layout, Scene *scene, Object *ob, but = uiDefIconButBitI(block, TOG, eModifierMode_ApplyOnSpline, 0, ICON_SURFACE_DATA, 0, 0, UI_UNIT_X-2, UI_UNIT_Y, &md->mode, 0.0, 0.0, 0.0, 0.0, TIP_("This modifier could be applied on splines' points only")); uiButSetFlag(but, UI_BUT_DISABLED); - } else if (mti->type != eModifierTypeType_Constructive) { + } + else if (mti->type != eModifierTypeType_Constructive) { /* constructive modifiers tessellates curve before applying */ uiItemR(row, &ptr, "use_apply_on_spline", 0, "", ICON_NONE); } @@ -840,9 +841,9 @@ static uiLayout *draw_modifier(uiLayout *layout, Scene *scene, Object *ob, ParticleSystem *psys= ((ParticleSystemModifierData *)md)->psys; if (!(ob->mode & OB_MODE_PARTICLE_EDIT) && psys->pathcache) { - if(ELEM(psys->part->ren_as, PART_DRAW_GR, PART_DRAW_OB)) + if (ELEM(psys->part->ren_as, PART_DRAW_GR, PART_DRAW_OB)) uiItemO(row, "Convert", ICON_NONE, "OBJECT_OT_duplicates_make_real"); - else if(psys->part->ren_as == PART_DRAW_PATH) + else if (psys->part->ren_as == PART_DRAW_PATH) uiItemO(row, "Convert", ICON_NONE, "OBJECT_OT_modifier_convert"); } } @@ -867,7 +868,7 @@ static uiLayout *draw_modifier(uiLayout *layout, Scene *scene, Object *ob, } /* error messages */ - if(md->error) { + if (md->error) { box = uiLayoutBox(column); row = uiLayoutRow(box, 0); uiItemL(row, md->error, ICON_ERROR); @@ -884,7 +885,7 @@ uiLayout *uiTemplateModifier(uiLayout *layout, bContext *C, PointerRNA *ptr) int i, lastCageIndex, cageIndex; /* verify we have valid data */ - if(!RNA_struct_is_a(ptr->type, &RNA_Modifier)) { + if (!RNA_struct_is_a(ptr->type, &RNA_Modifier)) { RNA_warning("Expected modifier on object"); return NULL; } @@ -892,7 +893,7 @@ uiLayout *uiTemplateModifier(uiLayout *layout, bContext *C, PointerRNA *ptr) ob= ptr->id.data; md= ptr->data; - if(!ob || !(GS(ob->id.name) == ID_OB)) { + if (!ob || !(GS(ob->id.name) == ID_OB)) { RNA_warning("Expected modifier on object"); return NULL; } @@ -905,10 +906,10 @@ uiLayout *uiTemplateModifier(uiLayout *layout, bContext *C, PointerRNA *ptr) // XXX virtual modifiers are not accesible for python vmd = modifiers_getVirtualModifierList(ob); - for(i=0; vmd; i++, vmd=vmd->next) { - if(md == vmd) + for (i=0; vmd; i++, vmd=vmd->next) { + if (md == vmd) return draw_modifier(layout, scene, ob, md, i, cageIndex, lastCageIndex); - else if(vmd->mode & eModifierMode_Virtual) + else if (vmd->mode & eModifierMode_Virtual) i--; } @@ -954,7 +955,7 @@ static void do_constraint_panels(bContext *C, void *ob_pt, int event) // object_test_constraints(ob); // if(ob->pose) update_pose_constraint_flags(ob->pose); - if(ob->type==OB_ARMATURE) DAG_id_tag_update(&ob->id, OB_RECALC_DATA|OB_RECALC_OB); + if (ob->type==OB_ARMATURE) DAG_id_tag_update(&ob->id, OB_RECALC_DATA|OB_RECALC_OB); else DAG_id_tag_update(&ob->id, OB_RECALC_OB); WM_event_add_notifier(C, NC_OBJECT|ND_CONSTRAINT, ob); @@ -1019,7 +1020,7 @@ static uiLayout *draw_constraint(uiLayout *layout, Object *ob, bConstraint *con) if (con->flag & CONSTRAINT_DISABLE) uiLayoutSetRedAlert(row, 1); - if(proxy_protected == 0) { + if (proxy_protected == 0) { uiItemR(row, &ptr, "name", 0, "", ICON_NONE); } else @@ -1110,7 +1111,7 @@ uiLayout *uiTemplateConstraint(uiLayout *layout, PointerRNA *ptr) bConstraint *con; /* verify we have valid data */ - if(!RNA_struct_is_a(ptr->type, &RNA_Constraint)) { + if (!RNA_struct_is_a(ptr->type, &RNA_Constraint)) { RNA_warning("Expected constraint on object"); return NULL; } @@ -1118,7 +1119,7 @@ uiLayout *uiTemplateConstraint(uiLayout *layout, PointerRNA *ptr) ob= ptr->id.data; con= ptr->data; - if(!ob || !(GS(ob->id.name) == ID_OB)) { + if (!ob || !(GS(ob->id.name) == ID_OB)) { RNA_warning("Expected constraint on object"); return NULL; } @@ -1126,9 +1127,9 @@ uiLayout *uiTemplateConstraint(uiLayout *layout, PointerRNA *ptr) uiBlockSetButLock(uiLayoutGetBlock(layout), (ob && ob->id.lib), ERROR_LIBDATA_MESSAGE); /* hrms, the temporal constraint should not draw! */ - if(con->type==CONSTRAINT_TYPE_KINEMATIC) { + if (con->type==CONSTRAINT_TYPE_KINEMATIC) { bKinematicConstraint *data= con->data; - if(data->flag & CONSTRAINT_IK_TEMP) + if (data->flag & CONSTRAINT_IK_TEMP) return NULL; } @@ -1164,7 +1165,7 @@ void uiTemplatePreview(uiLayout *layout, ID *id, int show_buttons, ID *parent, M PointerRNA material_ptr; PointerRNA texture_ptr; - if(id && !ELEM4(GS(id->name), ID_MA, ID_TE, ID_WO, ID_LA)) { + if (id && !ELEM4(GS(id->name), ID_MA, ID_TE, ID_WO, ID_LA)) { RNA_warning("Expected ID of type material, texture, lamp or world"); return; } @@ -1173,18 +1174,18 @@ void uiTemplatePreview(uiLayout *layout, ID *id, int show_buttons, ID *parent, M pid= id; pparent= NULL; - if(id && (GS(id->name) == ID_TE)) { - if(parent && (GS(parent->name) == ID_MA)) + if (id && (GS(id->name) == ID_TE)) { + if (parent && (GS(parent->name) == ID_MA)) pr_texture= &((Material*)parent)->pr_texture; - else if(parent && (GS(parent->name) == ID_WO)) + else if (parent && (GS(parent->name) == ID_WO)) pr_texture= &((World*)parent)->pr_texture; - else if(parent && (GS(parent->name) == ID_LA)) + else if (parent && (GS(parent->name) == ID_LA)) pr_texture= &((Lamp*)parent)->pr_texture; - if(pr_texture) { - if(*pr_texture == TEX_PR_OTHER) + if (pr_texture) { + if (*pr_texture == TEX_PR_OTHER) pid= parent; - else if(*pr_texture == TEX_PR_BOTH) + else if (*pr_texture == TEX_PR_BOTH) pparent= parent; } } @@ -1202,8 +1203,8 @@ void uiTemplatePreview(uiLayout *layout, ID *id, int show_buttons, ID *parent, M /* add buttons */ if (pid && show_buttons) { - if(GS(pid->name) == ID_MA || (pparent && GS(pparent->name) == ID_MA)) { - if(GS(pid->name) == ID_MA) ma= (Material*)pid; + if (GS(pid->name) == ID_MA || (pparent && GS(pparent->name) == ID_MA)) { + if (GS(pid->name) == ID_MA) ma= (Material*)pid; else ma= (Material*)pparent; /* Create RNA Pointer */ @@ -1214,22 +1215,22 @@ void uiTemplatePreview(uiLayout *layout, ID *id, int show_buttons, ID *parent, M uiItemR(col, &material_ptr, "preview_render_type", UI_ITEM_R_EXPAND, "", ICON_NONE); } - if(pr_texture) { + if (pr_texture) { /* Create RNA Pointer */ RNA_pointer_create(id, &RNA_Texture, tex, &texture_ptr); uiLayoutRow(layout, 1); uiDefButS(block, ROW, B_MATPRV, IFACE_("Texture"), 0, 0,UI_UNIT_X*10,UI_UNIT_Y, pr_texture, 10, TEX_PR_TEXTURE, 0, 0, ""); - if(GS(parent->name) == ID_MA) + if (GS(parent->name) == ID_MA) uiDefButS(block, ROW, B_MATPRV, IFACE_("Material"), 0, 0,UI_UNIT_X*10,UI_UNIT_Y, pr_texture, 10, TEX_PR_OTHER, 0, 0, ""); - else if(GS(parent->name) == ID_LA) + else if (GS(parent->name) == ID_LA) uiDefButS(block, ROW, B_MATPRV, IFACE_("Lamp"), 0, 0,UI_UNIT_X*10,UI_UNIT_Y, pr_texture, 10, TEX_PR_OTHER, 0, 0, ""); - else if(GS(parent->name) == ID_WO) + else if (GS(parent->name) == ID_WO) uiDefButS(block, ROW, B_MATPRV, IFACE_("World"), 0, 0,UI_UNIT_X*10,UI_UNIT_Y, pr_texture, 10, TEX_PR_OTHER, 0, 0, ""); uiDefButS(block, ROW, B_MATPRV, IFACE_("Both"), 0, 0,UI_UNIT_X*10,UI_UNIT_Y, pr_texture, 10, TEX_PR_BOTH, 0, 0, ""); /* Alpha button for texture preview */ - if(*pr_texture!=TEX_PR_OTHER) { + if (*pr_texture!=TEX_PR_OTHER) { row = uiLayoutRow(layout, 0); uiItemR(row, &texture_ptr, "use_preview_alpha", 0, NULL, ICON_NONE); } @@ -1262,12 +1263,12 @@ static void colorband_add_cb(bContext *C, void *cb_v, void *coba_v) ColorBand *coba= coba_v; float pos= 0.5f; - if(coba->tot > 1) { - if(coba->cur > 0) pos= (coba->data[coba->cur-1].pos + coba->data[coba->cur].pos) * 0.5f; + if (coba->tot > 1) { + if (coba->cur > 0) pos= (coba->data[coba->cur-1].pos + coba->data[coba->cur].pos) * 0.5f; else pos= (coba->data[coba->cur+1].pos + coba->data[coba->cur].pos) * 0.5f; } - if(colorband_element_add(coba, pos)) { + if (colorband_element_add(coba, pos)) { rna_update_cb(C, cb_v, NULL); ED_undo_push(C, "Add colorband"); } @@ -1277,7 +1278,7 @@ static void colorband_del_cb(bContext *C, void *cb_v, void *coba_v) { ColorBand *coba= coba_v; - if(colorband_element_remove(coba, coba->cur)) { + if (colorband_element_remove(coba, coba->cur)) { ED_undo_push(C, "Delete colorband"); rna_update_cb(C, cb_v, NULL); } @@ -1290,10 +1291,10 @@ static void colorband_flip_cb(bContext *C, void *cb_v, void *coba_v) ColorBand *coba= coba_v; int a; - for(a=0; atot; a++) { + for (a=0; atot; a++) { data_tmp[a]= coba->data[coba->tot - (a + 1)]; } - for(a=0; atot; a++) { + for (a=0; atot; a++) { data_tmp[a].pos = 1.0f - data_tmp[a].pos; coba->data[a]= data_tmp[a]; } @@ -1325,7 +1326,7 @@ static void colorband_buttons_large(uiLayout *layout, uiBlock *block, ColorBand const int line1_y= yoffs + 65 + UI_UNIT_Y + 2; /* 2 for some space between the buttons */ const int line2_y= yoffs + 65; - if(coba==NULL) return; + if (coba==NULL) return; bt= uiDefBut(block, BUT, 0, IFACE_("Add"), 0+xoffs,line1_y,40,UI_UNIT_Y, NULL, 0, 0, 0, 0, TIP_("Add a new color stop to the colorband")); @@ -1352,7 +1353,7 @@ static void colorband_buttons_large(uiLayout *layout, uiBlock *block, ColorBand - if(coba->tot) { + if (coba->tot) { CBData *cbd= coba->data + coba->cur; /* better to use rna so we can animate them */ @@ -1386,7 +1387,7 @@ static void colorband_buttons_small(uiLayout *layout, uiBlock *block, ColorBand uiButSetNFunc(bt, colorband_flip_cb, MEM_dupallocN(cb), coba); uiBlockEndAlign(block); - if(coba->tot) { + if (coba->tot) { CBData *cbd= coba->data + coba->cur; PointerRNA ptr; RNA_pointer_create(cb->ptr.id.data, &RNA_ColorRampElement, cbd, &ptr); @@ -1406,7 +1407,7 @@ static void colorband_buttons_small(uiLayout *layout, uiBlock *block, ColorBand static void colorband_buttons_layout(uiLayout *layout, uiBlock *block, ColorBand *coba, rctf *butr, int small, RNAUpdateCb *cb) { - if(small) + if (small) colorband_buttons_small(layout, block, coba, butr, cb); else colorband_buttons_large(layout, block, coba, 0, 0, cb); @@ -1420,11 +1421,11 @@ void uiTemplateColorRamp(uiLayout *layout, PointerRNA *ptr, const char *propname uiBlock *block; rctf rect; - if(!prop || RNA_property_type(prop) != PROP_POINTER) + if (!prop || RNA_property_type(prop) != PROP_POINTER) return; cptr= RNA_property_pointer_get(ptr, prop); - if(!cptr.data || !RNA_struct_is_a(cptr.type, &RNA_ColorRamp)) + if (!cptr.data || !RNA_struct_is_a(cptr.type, &RNA_ColorRamp)) return; cb= MEM_callocN(sizeof(RNAUpdateCb), "RNAUpdateCb"); @@ -1452,11 +1453,11 @@ void uiTemplateHistogram(uiLayout *layout, PointerRNA *ptr, const char *propname Histogram *hist; rctf rect; - if(!prop || RNA_property_type(prop) != PROP_POINTER) + if (!prop || RNA_property_type(prop) != PROP_POINTER) return; cptr= RNA_property_pointer_get(ptr, prop); - if(!cptr.data || !RNA_struct_is_a(cptr.type, &RNA_Histogram)) + if (!cptr.data || !RNA_struct_is_a(cptr.type, &RNA_Histogram)) return; cb= MEM_callocN(sizeof(RNAUpdateCb), "RNAUpdateCb"); @@ -1491,11 +1492,11 @@ void uiTemplateWaveform(uiLayout *layout, PointerRNA *ptr, const char *propname) Scopes *scopes; rctf rect; - if(!prop || RNA_property_type(prop) != PROP_POINTER) + if (!prop || RNA_property_type(prop) != PROP_POINTER) return; cptr= RNA_property_pointer_get(ptr, prop); - if(!cptr.data || !RNA_struct_is_a(cptr.type, &RNA_Scopes)) + if (!cptr.data || !RNA_struct_is_a(cptr.type, &RNA_Scopes)) return; scopes = (Scopes *)cptr.data; @@ -1528,11 +1529,11 @@ void uiTemplateVectorscope(uiLayout *layout, PointerRNA *ptr, const char *propna Scopes *scopes; rctf rect; - if(!prop || RNA_property_type(prop) != PROP_POINTER) + if (!prop || RNA_property_type(prop) != PROP_POINTER) return; cptr= RNA_property_pointer_get(ptr, prop); - if(!cptr.data || !RNA_struct_is_a(cptr.type, &RNA_Scopes)) + if (!cptr.data || !RNA_struct_is_a(cptr.type, &RNA_Scopes)) return; scopes = (Scopes *)cptr.data; @@ -1562,7 +1563,7 @@ static void curvemap_buttons_zoom_in(bContext *C, void *cumap_v, void *UNUSED(ar float d; /* we allow 20 times zoom */ - if( (cumap->curr.xmax - cumap->curr.xmin) > 0.04f*(cumap->clipr.xmax - cumap->clipr.xmin) ) { + if ( (cumap->curr.xmax - cumap->curr.xmin) > 0.04f*(cumap->clipr.xmax - cumap->clipr.xmin) ) { d= 0.1154f*(cumap->curr.xmax - cumap->curr.xmin); cumap->curr.xmin+= d; cumap->curr.xmax-= d; @@ -1580,30 +1581,30 @@ static void curvemap_buttons_zoom_out(bContext *C, void *cumap_v, void *UNUSED(u float d, d1; /* we allow 20 times zoom, but don't view outside clip */ - if( (cumap->curr.xmax - cumap->curr.xmin) < 20.0f*(cumap->clipr.xmax - cumap->clipr.xmin) ) { + if ( (cumap->curr.xmax - cumap->curr.xmin) < 20.0f*(cumap->clipr.xmax - cumap->clipr.xmin) ) { d= d1= 0.15f*(cumap->curr.xmax - cumap->curr.xmin); - if(cumap->flag & CUMA_DO_CLIP) - if(cumap->curr.xmin-d < cumap->clipr.xmin) + if (cumap->flag & CUMA_DO_CLIP) + if (cumap->curr.xmin-d < cumap->clipr.xmin) d1= cumap->curr.xmin - cumap->clipr.xmin; cumap->curr.xmin-= d1; d1= d; - if(cumap->flag & CUMA_DO_CLIP) - if(cumap->curr.xmax+d > cumap->clipr.xmax) + if (cumap->flag & CUMA_DO_CLIP) + if (cumap->curr.xmax+d > cumap->clipr.xmax) d1= -cumap->curr.xmax + cumap->clipr.xmax; cumap->curr.xmax+= d1; d= d1= 0.15f*(cumap->curr.ymax - cumap->curr.ymin); - if(cumap->flag & CUMA_DO_CLIP) - if(cumap->curr.ymin-d < cumap->clipr.ymin) + if (cumap->flag & CUMA_DO_CLIP) + if (cumap->curr.ymin-d < cumap->clipr.ymin) d1= cumap->curr.ymin - cumap->clipr.ymin; cumap->curr.ymin-= d1; d1= d; - if(cumap->flag & CUMA_DO_CLIP) - if(cumap->curr.ymax+d > cumap->clipr.ymax) + if (cumap->flag & CUMA_DO_CLIP) + if (cumap->curr.ymax+d > cumap->clipr.ymax) d1= -cumap->curr.ymax + cumap->clipr.ymax; cumap->curr.ymax+= d1; } @@ -1743,7 +1744,7 @@ static void curvemap_buttons_reset(bContext *C, void *cb_v, void *cumap_v) int a; cumap->preset = CURVE_PRESET_LINE; - for(a=0; acm+a, &cumap->clipr, cumap->preset, CURVEMAP_SLOPE_POSITIVE); cumap->black[0]=cumap->black[1]=cumap->black[2]= 0.0f; @@ -1771,42 +1772,42 @@ static void curvemap_buttons_layout(uiLayout *layout, PointerRNA *ptr, char labe /* curve chooser */ row= uiLayoutRow(layout, 0); - if(labeltype=='v') { + if (labeltype=='v') { /* vector */ sub= uiLayoutRow(row, 1); uiLayoutSetAlignment(sub, UI_LAYOUT_ALIGN_LEFT); - if(cumap->cm[0].curve) { + if (cumap->cm[0].curve) { bt= uiDefButI(block, ROW, 0, "X", 0, 0, dx, dx, &cumap->cur, 0.0, 0.0, 0.0, 0.0, ""); uiButSetFunc(bt, curvemap_buttons_redraw, NULL, NULL); } - if(cumap->cm[1].curve) { + if (cumap->cm[1].curve) { bt= uiDefButI(block, ROW, 0, "Y", 0, 0, dx, dx, &cumap->cur, 0.0, 1.0, 0.0, 0.0, ""); uiButSetFunc(bt, curvemap_buttons_redraw, NULL, NULL); } - if(cumap->cm[2].curve) { + if (cumap->cm[2].curve) { bt= uiDefButI(block, ROW, 0, "Z", 0, 0, dx, dx, &cumap->cur, 0.0, 2.0, 0.0, 0.0, ""); uiButSetFunc(bt, curvemap_buttons_redraw, NULL, NULL); } } - else if(labeltype=='c') { + else if (labeltype=='c') { /* color */ sub= uiLayoutRow(row, 1); uiLayoutSetAlignment(sub, UI_LAYOUT_ALIGN_LEFT); - if(cumap->cm[3].curve) { + if (cumap->cm[3].curve) { bt= uiDefButI(block, ROW, 0, "C", 0, 0, dx, dx, &cumap->cur, 0.0, 3.0, 0.0, 0.0, ""); uiButSetFunc(bt, curvemap_buttons_redraw, NULL, NULL); } - if(cumap->cm[0].curve) { + if (cumap->cm[0].curve) { bt= uiDefButI(block, ROW, 0, "R", 0, 0, dx, dx, &cumap->cur, 0.0, 0.0, 0.0, 0.0, ""); uiButSetFunc(bt, curvemap_buttons_redraw, NULL, NULL); } - if(cumap->cm[1].curve) { + if (cumap->cm[1].curve) { bt= uiDefButI(block, ROW, 0, "G", 0, 0, dx, dx, &cumap->cur, 0.0, 1.0, 0.0, 0.0, ""); uiButSetFunc(bt, curvemap_buttons_redraw, NULL, NULL); } - if(cumap->cm[2].curve) { + if (cumap->cm[2].curve) { bt= uiDefButI(block, ROW, 0, "B", 0, 0, dx, dx, &cumap->cur, 0.0, 2.0, 0.0, 0.0, ""); uiButSetFunc(bt, curvemap_buttons_redraw, NULL, NULL); } @@ -1816,15 +1817,15 @@ static void curvemap_buttons_layout(uiLayout *layout, PointerRNA *ptr, char labe sub= uiLayoutRow(row, 1); uiLayoutSetAlignment(sub, UI_LAYOUT_ALIGN_LEFT); - if(cumap->cm[0].curve) { + if (cumap->cm[0].curve) { bt= uiDefButI(block, ROW, 0, "H", 0, 0, dx, dx, &cumap->cur, 0.0, 0.0, 0.0, 0.0, ""); uiButSetFunc(bt, curvemap_buttons_redraw, NULL, NULL); } - if(cumap->cm[1].curve) { + if (cumap->cm[1].curve) { bt= uiDefButI(block, ROW, 0, "S", 0, 0, dx, dx, &cumap->cur, 0.0, 1.0, 0.0, 0.0, ""); uiButSetFunc(bt, curvemap_buttons_redraw, NULL, NULL); } - if(cumap->cm[2].curve) { + if (cumap->cm[2].curve) { bt= uiDefButI(block, ROW, 0, "V", 0, 0, dx, dx, &cumap->cur, 0.0, 2.0, 0.0, 0.0, ""); uiButSetFunc(bt, curvemap_buttons_redraw, NULL, NULL); } @@ -1846,14 +1847,14 @@ static void curvemap_buttons_layout(uiLayout *layout, PointerRNA *ptr, char labe bt= uiDefIconBut(block, BUT, 0, ICON_ZOOMOUT, 0, 0, dx, dx, NULL, 0.0, 0.0, 0.0, 0.0, TIP_("Zoom out")); uiButSetFunc(bt, curvemap_buttons_zoom_out, cumap, NULL); - if(brush) + if (brush) bt= uiDefIconBlockBut(block, curvemap_brush_tools_func, cumap, 0, ICON_MODIFIER, 0, 0, dx, dx, TIP_("Tools")); else bt= uiDefIconBlockBut(block, curvemap_tools_func, cumap, 0, ICON_MODIFIER, 0, 0, dx, dx, TIP_("Tools")); uiButSetNFunc(bt, rna_update_cb, MEM_dupallocN(cb), NULL); - if(cumap->flag & CUMA_DO_CLIP) icon= ICON_CLIPUV_HLT; else icon= ICON_CLIPUV_DEHLT; + if (cumap->flag & CUMA_DO_CLIP) icon= ICON_CLIPUV_HLT; else icon= ICON_CLIPUV_DEHLT; bt= uiDefIconBlockBut(block, curvemap_clipping_func, cumap, 0, icon, 0, 0, dx, dx, TIP_("Clipping Options")); uiButSetNFunc(bt, rna_update_cb, MEM_dupallocN(cb), NULL); @@ -1870,7 +1871,7 @@ static void curvemap_buttons_layout(uiLayout *layout, PointerRNA *ptr, char labe uiDefBut(block, BUT_CURVE, 0, "", 0, 0, size, MIN2(size, 200), cumap, 0.0f, 1.0f, bg, 0, ""); /* black/white levels */ - if(levels) { + if (levels) { split= uiLayoutSplit(layout, 0, 0); uiItemR(uiLayoutColumn(split, 0), ptr, "black_level", UI_ITEM_R_EXPAND, NULL, ICON_NONE); uiItemR(uiLayoutColumn(split, 0), ptr, "white_level", UI_ITEM_R_EXPAND, NULL, ICON_NONE); @@ -1890,20 +1891,20 @@ void uiTemplateCurveMapping(uiLayout *layout, PointerRNA *ptr, const char *propn PropertyRNA *prop= RNA_struct_find_property(ptr, propname); PointerRNA cptr; - if(!prop) { + if (!prop) { RNA_warning("curve property not found: %s.%s", RNA_struct_identifier(ptr->type), propname); return; } - if(RNA_property_type(prop) != PROP_POINTER) { + if (RNA_property_type(prop) != PROP_POINTER) { RNA_warning("curve is not a pointer: %s.%s", RNA_struct_identifier(ptr->type), propname); return; } cptr= RNA_property_pointer_get(ptr, prop); - if(!cptr.data || !RNA_struct_is_a(cptr.type, &RNA_CurveMapping)) + if (!cptr.data || !RNA_struct_is_a(cptr.type, &RNA_CurveMapping)) return; cb= MEM_callocN(sizeof(RNAUpdateCb), "RNAUpdateCb"); @@ -1939,18 +1940,18 @@ void uiTemplateColorWheel(uiLayout *layout, PointerRNA *ptr, const char *propnam but = uiDefButR_prop(block, HSVCIRCLE, 0, "", 0, 0, WHEEL_SIZE, WHEEL_SIZE, ptr, prop, -1, 0.0, 0.0, 0, 0, ""); - if(lock) { + if (lock) { but->flag |= UI_BUT_COLOR_LOCK; } - if(lock_luminosity) { + if (lock_luminosity) { float color[4]; /* in case of alpha */ but->flag |= UI_BUT_VEC_SIZE_LOCK; RNA_property_float_get_array(ptr, prop, color); but->a2= len_v3(color); } - if(cubic) + if (cubic) but->flag |= UI_BUT_COLOR_CUBIC; uiItemS(row); @@ -1968,13 +1969,13 @@ static void handle_layer_buttons(bContext *C, void *arg1, void *arg2) wmWindow *win= CTX_wm_window(C); int i, tot, shift= win->eventstate->shift; - if(!shift) { + if (!shift) { tot= RNA_property_array_length(&but->rnapoin, but->rnaprop); /* Normally clicking only selects one layer */ RNA_property_boolean_set_index(&but->rnapoin, but->rnaprop, cur, TRUE); - for(i = 0; i < tot; ++i) { - if(i != cur) + for (i = 0; i < tot; ++i) { + if (i != cur) RNA_property_boolean_set_index(&but->rnapoin, but->rnaprop, i, FALSE); } } @@ -2012,14 +2013,14 @@ void uiTemplateLayers(uiLayout *layout, PointerRNA *ptr, const char *propname, cols= (layers / 2) + (layers % 2); groups= ((cols / 2) < cols_per_group) ? (1) : (cols / cols_per_group); - if(used_ptr && used_propname) { + if (used_ptr && used_propname) { used_prop= RNA_struct_find_property(used_ptr, used_propname); if (!used_prop) { RNA_warning("used layers property not found: %s.%s", RNA_struct_identifier(ptr->type), used_propname); return; } - if(RNA_property_array_length(used_ptr, used_prop) < layers) + if (RNA_property_array_length(used_ptr, used_prop) < layers) used_prop = NULL; } @@ -2041,9 +2042,9 @@ void uiTemplateLayers(uiLayout *layout, PointerRNA *ptr, const char *propname, int icon = 0; int butlay = 1 << layer; - if(active_layer & butlay) + if (active_layer & butlay) icon = ICON_LAYER_ACTIVE; - else if(used_prop && RNA_property_boolean_get_index(used_ptr, used_prop, layer)) + else if (used_prop && RNA_property_boolean_get_index(used_ptr, used_prop, layer)) icon = ICON_LAYER_USED; but = uiDefAutoButR(block, ptr, prop, layer, "", icon, 0, 0, UI_UNIT_X/2, UI_UNIT_Y/2); @@ -2062,20 +2063,20 @@ static int list_item_icon_get(bContext *C, PointerRNA *itemptr, int rnaicon, int ID *id= NULL; int icon; - if(!itemptr->data) + if (!itemptr->data) return rnaicon; /* try ID, material or texture slot */ - if(RNA_struct_is_ID(itemptr->type)) { + if (RNA_struct_is_ID(itemptr->type)) { id= itemptr->id.data; } - else if(RNA_struct_is_a(itemptr->type, &RNA_MaterialSlot)) { + else if (RNA_struct_is_a(itemptr->type, &RNA_MaterialSlot)) { id= RNA_pointer_get(itemptr, "material").data; } - else if(RNA_struct_is_a(itemptr->type, &RNA_TextureSlot)) { + else if (RNA_struct_is_a(itemptr->type, &RNA_TextureSlot)) { id= RNA_pointer_get(itemptr, "texture").data; } - else if(RNA_struct_is_a(itemptr->type, &RNA_DynamicPaintSurface)) { + else if (RNA_struct_is_a(itemptr->type, &RNA_DynamicPaintSurface)) { DynamicPaintSurface *surface= (DynamicPaintSurface*)itemptr->data; if (surface->format == MOD_DPAINT_SURFACE_F_PTEX) return ICON_TEXTURE_SHADED; @@ -2084,10 +2085,10 @@ static int list_item_icon_get(bContext *C, PointerRNA *itemptr, int rnaicon, int } /* get icon from ID */ - if(id) { + if (id) { icon= ui_id_icon_get(C, id, big); - if(icon) + if (icon) return icon; } @@ -2115,30 +2116,30 @@ static void list_item_row(bContext *C, uiLayout *layout, PointerRNA *ptr, Pointe /* retrieve icon and name */ icon= list_item_icon_get(C, itemptr, rnaicon, 0); - if(icon == ICON_NONE || icon == ICON_DOT) + if (icon == ICON_NONE || icon == ICON_DOT) icon= 0; namebuf= RNA_struct_name_get_alloc(itemptr, NULL, 0, NULL); name= (namebuf)? namebuf: ""; /* hardcoded types */ - if(itemptr->type == &RNA_MeshTexturePolyLayer || itemptr->type == &RNA_MeshLoopColorLayer) { + if (itemptr->type == &RNA_MeshTexturePolyLayer || itemptr->type == &RNA_MeshLoopColorLayer) { uiItemL(sub, name, icon); uiBlockSetEmboss(block, UI_EMBOSSN); uiDefIconButR(block, TOG, 0, ICON_SCENE, 0, 0, UI_UNIT_X, UI_UNIT_Y, itemptr, "active_render", 0, 0, 0, 0, 0, NULL); uiBlockSetEmboss(block, UI_EMBOSS); } - else if(RNA_struct_is_a(itemptr->type, &RNA_MaterialTextureSlot)) { + else if (RNA_struct_is_a(itemptr->type, &RNA_MaterialTextureSlot)) { uiItemL(sub, name, icon); uiBlockSetEmboss(block, UI_EMBOSS); uiDefButR(block, OPTION, 0, "", 0, 0, UI_UNIT_X, UI_UNIT_Y, ptr, "use_textures", i, 0, 0, 0, 0, NULL); } - else if(RNA_struct_is_a(itemptr->type, &RNA_SceneRenderLayer)) { + else if (RNA_struct_is_a(itemptr->type, &RNA_SceneRenderLayer)) { uiItemL(sub, name, icon); uiBlockSetEmboss(block, UI_EMBOSS); uiDefButR(block, OPTION, 0, "", 0, 0, UI_UNIT_X, UI_UNIT_Y, itemptr, "use", 0, 0, 0, 0, 0, NULL); } - else if(RNA_struct_is_a(itemptr->type, &RNA_MaterialSlot)) { + else if (RNA_struct_is_a(itemptr->type, &RNA_MaterialSlot)) { /* provision to draw active node name */ Material *ma, *manode; Scene *scene= CTX_data_scene(C); @@ -2149,19 +2150,19 @@ static void list_item_row(bContext *C, uiLayout *layout, PointerRNA *ptr, Pointe uiItemL(sub, name, icon); ma= give_current_material(ob, index+1); - if (ma && !scene_use_new_shading_nodes(scene)){ + if (ma && !scene_use_new_shading_nodes(scene)) { manode= give_node_material(ma); - if(manode) { + if (manode) { char str[MAX_ID_NAME + 12]; BLI_snprintf(str, sizeof(str), "Node %s", manode->id.name+2); uiItemL(sub, str, ui_id_icon_get(C, &manode->id, 1)); } - else if(ma->use_nodes) { + else if (ma->use_nodes) { uiItemL(sub, "Node ", ICON_NONE); } } } - else if(itemptr->type == &RNA_ShapeKey) { + else if (itemptr->type == &RNA_ShapeKey) { Object *ob= (Object*)activeptr->data; Key *key= (Key*)itemptr->id.data; @@ -2171,18 +2172,18 @@ static void list_item_row(bContext *C, uiLayout *layout, PointerRNA *ptr, Pointe uiBlockSetEmboss(block, UI_EMBOSSN); row= uiLayoutRow(split, 1); - if(i == 0 || (key->type != KEY_RELATIVE)) uiItemL(row, "", ICON_NONE); + if (i == 0 || (key->type != KEY_RELATIVE)) uiItemL(row, "", ICON_NONE); else uiItemR(row, itemptr, "value", 0, "", ICON_NONE); uiItemR(row, itemptr, "mute", 0, "", 0); - if( (key->flag & KEYBLOCK_MUTE) || + if ( (key->flag & KEYBLOCK_MUTE) || (ob->mode == OB_MODE_EDIT && !((ob->shapeflag & OB_SHAPE_EDIT_MODE) && ob->type == OB_MESH)) ) { uiLayoutSetActive(row, 0); } uiBlockSetEmboss(block, UI_EMBOSS); } - else if(itemptr->type == &RNA_VertexGroup) { + else if (itemptr->type == &RNA_VertexGroup) { bDeformGroup *dg= (bDeformGroup *)itemptr->data; uiItemL(sub, name, icon); /* RNA does not allow nice lock icons, use lower level buttons */ @@ -2194,7 +2195,7 @@ static void list_item_row(bContext *C, uiLayout *layout, PointerRNA *ptr, Pointe uiBlockSetEmboss(block, UI_EMBOSS); #endif } - else if(itemptr->type == &RNA_KeyingSetPath) { + else if (itemptr->type == &RNA_KeyingSetPath) { KS_Path *ksp = (KS_Path*)itemptr->data; /* icon needs to be the type of ID which is currently active */ @@ -2203,7 +2204,7 @@ static void list_item_row(bContext *C, uiLayout *layout, PointerRNA *ptr, Pointe /* nothing else special to do... */ uiItemL(sub, name, icon); /* fails, backdrop LISTROW... */ } - else if(itemptr->type == &RNA_DynamicPaintSurface) { + else if (itemptr->type == &RNA_DynamicPaintSurface) { char name_final[96]; const char *enum_name; PropertyRNA *prop = RNA_struct_find_property(itemptr, "surface_type"); @@ -2221,11 +2222,11 @@ static void list_item_row(bContext *C, uiLayout *layout, PointerRNA *ptr, Pointe } uiDefButR(block, OPTION, 0, "", 0, 0, UI_UNIT_X, UI_UNIT_Y, itemptr, "is_active", i, 0, 0, 0, 0, NULL); } - else if(itemptr->type == &RNA_MovieTrackingObject) { + else if (itemptr->type == &RNA_MovieTrackingObject) { MovieTrackingObject *tracking_object= (MovieTrackingObject*)itemptr->data; split= uiLayoutSplit(sub, 0.75f, 0); - if(tracking_object->flag&TRACKING_OBJECT_CAMERA) { + if (tracking_object->flag&TRACKING_OBJECT_CAMERA) { uiItemL(split, name, ICON_CAMERA_DATA); } else { @@ -2264,7 +2265,7 @@ static void list_item_row(bContext *C, uiLayout *layout, PointerRNA *ptr, Pointe /* If the special property is set for the item, and it is a collection... */ PropertyRNA *prop_list= RNA_struct_find_property(itemptr, prop_list_id); - if(prop_list && RNA_property_type(prop_list) == PROP_STRING) { + if (prop_list && RNA_property_type(prop_list) == PROP_STRING) { int prop_names_len; char *prop_names = RNA_property_string_get_alloc(itemptr, prop_list, NULL, 0, &prop_names_len); char *prop_names_end= prop_names + prop_names_len; @@ -2308,44 +2309,44 @@ void uiTemplateList(uiLayout *layout, bContext *C, PointerRNA *ptr, const char * block= uiLayoutGetBlock(layout); pa= block->panel; - if(!pa) { + if (!pa) { RNA_warning("Only works inside a panel"); return; } - if(!activeptr->data) + if (!activeptr->data) return; - if(ptr->data) { + if (ptr->data) { prop= RNA_struct_find_property(ptr, propname); - if(!prop) { + if (!prop) { RNA_warning("Property not found: %s.%s", RNA_struct_identifier(ptr->type), propname); return; } } activeprop= RNA_struct_find_property(activeptr, activepropname); - if(!activeprop) { + if (!activeprop) { RNA_warning("Property not found: %s.%s", RNA_struct_identifier(ptr->type), activepropname); return; } - if(prop) { + if (prop) { type= RNA_property_type(prop); - if(type != PROP_COLLECTION) { + if (type != PROP_COLLECTION) { RNA_warning("uiExpected collection property"); return; } } activetype= RNA_property_type(activeprop); - if(activetype != PROP_INT) { + if (activetype != PROP_INT) { RNA_warning("Expected integer property"); return; } /* get icon */ - if(ptr->data && prop) { + if (ptr->data && prop) { ptype= RNA_property_pointer_type(ptr, prop); rnaicon= RNA_struct_ui_icon(ptype); } @@ -2353,16 +2354,16 @@ void uiTemplateList(uiLayout *layout, bContext *C, PointerRNA *ptr, const char * /* get active data */ activei= RNA_property_int_get(activeptr, activeprop); - if(listtype == 'i') { + if (listtype == 'i') { box= uiLayoutListBox(layout, ptr, prop, activeptr, activeprop); col= uiLayoutColumn(box, 1); row= uiLayoutRow(col, 0); - if(ptr->data && prop) { + if (ptr->data && prop) { /* create list items */ RNA_PROP_BEGIN(ptr, itemptr, prop) { /* create button */ - if(!(i % 9)) + if (!(i % 9)) row= uiLayoutRow(col, 0); icon= list_item_icon_get(C, &itemptr, rnaicon, 1); @@ -2375,17 +2376,17 @@ void uiTemplateList(uiLayout *layout, bContext *C, PointerRNA *ptr, const char * RNA_PROP_END; } } - else if(listtype == 'c') { + else if (listtype == 'c') { /* compact layout */ row= uiLayoutRow(layout, 1); - if(ptr->data && prop) { + if (ptr->data && prop) { /* create list items */ RNA_PROP_BEGIN(ptr, itemptr, prop) { found= (activei == i); - if(found) { + if (found) { /* create button */ name= RNA_struct_name_get_alloc(&itemptr, NULL, 0, NULL); icon= list_item_icon_get(C, &itemptr, rnaicon, 0); @@ -2402,22 +2403,22 @@ void uiTemplateList(uiLayout *layout, bContext *C, PointerRNA *ptr, const char * } /* if not found, add in dummy button */ - if(i == 0) + if (i == 0) uiItemL(row, "", ICON_NONE); /* next/prev button */ BLI_snprintf(numstr, sizeof(numstr), "%d :", i); but = uiDefIconTextButR_prop(block, NUM, 0, 0, numstr, 0,0,UI_UNIT_X*5,UI_UNIT_Y, activeptr, activeprop, 0, 0, 0, 0, 0, ""); - if(i == 0) + if (i == 0) uiButSetFlag(but, UI_BUT_DISABLED); } else { /* default rows */ - if(rows == 0) + if (rows == 0) rows= 5; if (maxrows == 0) maxrows = 5; - if(pa->list_grip_size != 0) + if (pa->list_grip_size != 0) rows= pa->list_grip_size; /* layout */ @@ -2428,13 +2429,13 @@ void uiTemplateList(uiLayout *layout, bContext *C, PointerRNA *ptr, const char * /* init numbers */ RNA_property_int_range(activeptr, activeprop, &min, &max); - if(prop) + if (prop) len= RNA_property_collection_length(ptr, prop); items= CLAMPIS(len, rows, MAX2(rows, maxrows)); /* if list length changes and active is out of view, scroll to it */ - if(pa->list_last_len != len) - if((activei < pa->list_scroll || activei >= pa->list_scroll+items)) + if (pa->list_last_len != len) + if ((activei < pa->list_scroll || activei >= pa->list_scroll+items)) pa->list_scroll= activei; pa->list_scroll= MIN2(pa->list_scroll, len-items); @@ -2442,10 +2443,10 @@ void uiTemplateList(uiLayout *layout, bContext *C, PointerRNA *ptr, const char * pa->list_size= items; pa->list_last_len= len; - if(ptr->data && prop) { + if (ptr->data && prop) { /* create list items */ RNA_PROP_BEGIN(ptr, itemptr, prop) { - if(i >= pa->list_scroll && ilist_scroll+items) + if (i >= pa->list_scroll && ilist_scroll+items) list_item_row(C, col, ptr, &itemptr, i, rnaicon, activeptr, activeprop, prop_list); i++; @@ -2454,14 +2455,14 @@ void uiTemplateList(uiLayout *layout, bContext *C, PointerRNA *ptr, const char * } /* add dummy buttons to fill space */ - while(i < pa->list_scroll+items) { - if(i >= pa->list_scroll) + while (i < pa->list_scroll+items) { + if (i >= pa->list_scroll) uiItemL(col, "", ICON_NONE); i++; } /* add scrollbar */ - if(len > items) { + if (len > items) { col= uiLayoutColumn(row, 0); uiDefButI(block, SCROLL, 0, "", 0,0,UI_UNIT_X*0.75,UI_UNIT_Y*items, &pa->list_scroll, 0, len-items, items, 0, ""); } @@ -2474,7 +2475,7 @@ static void operator_call_cb(bContext *C, void *UNUSED(arg1), void *arg2) { wmOperatorType *ot= arg2; - if(ot) + if (ot) WM_operator_name_call(C, ot->idname, WM_OP_INVOKE_DEFAULT, NULL); } @@ -2482,11 +2483,11 @@ static void operator_search_cb(const bContext *C, void *UNUSED(arg), const char { GHashIterator *iter= WM_operatortype_iter(); - for( ; !BLI_ghashIterator_isDone(iter); BLI_ghashIterator_step(iter)) { + for ( ; !BLI_ghashIterator_isDone(iter); BLI_ghashIterator_step(iter)) { wmOperatorType *ot= BLI_ghashIterator_getValue(iter); - if(BLI_strcasestr(ot->name, str)) { - if(WM_operator_poll((bContext*)C, ot)) { + if (BLI_strcasestr(ot->name, str)) { + if (WM_operator_poll((bContext*)C, ot)) { char name[256]; int len= strlen(ot->name); @@ -2494,7 +2495,7 @@ static void operator_search_cb(const bContext *C, void *UNUSED(arg), const char BLI_strncpy(name, ot->name, sizeof(name)); /* check for hotkey */ - if(len < sizeof(name)-6) { + if (len < sizeof(name)-6) { if (WM_key_event_operator_string(C, ot->idname, WM_OP_EXEC_DEFAULT, NULL, TRUE, &name[len+1], sizeof(name)-len-1)) { @@ -2502,7 +2503,7 @@ static void operator_search_cb(const bContext *C, void *UNUSED(arg), const char } } - if(0==uiSearchItemAdd(items, name, ot, 0)) + if (0==uiSearchItemAdd(items, name, ot, 0)) break; } } @@ -2570,29 +2571,32 @@ void uiTemplateRunningJobs(uiLayout *layout, bContext *C) uiBlockSetHandleFunc(block, do_running_jobs, NULL); - if(sa->spacetype==SPACE_NODE) { - if(WM_jobs_test(wm, sa)) + if (sa->spacetype==SPACE_NODE) { + if (WM_jobs_test(wm, sa)) owner = sa; handle_event= B_STOPCOMPO; - } else if (sa->spacetype==SPACE_SEQ) { - if(WM_jobs_test(wm, sa)) + } + else if (sa->spacetype==SPACE_SEQ) { + if (WM_jobs_test(wm, sa)) owner = sa; handle_event = B_STOPSEQ; - } else if(sa->spacetype==SPACE_CLIP) { - if(WM_jobs_test(wm, sa)) + } + else if (sa->spacetype==SPACE_CLIP) { + if (WM_jobs_test(wm, sa)) owner = sa; handle_event= B_STOPCLIP; - } else { + } + else { Scene *scene; /* another scene can be rendering too, for example via compositor */ - for(scene= CTX_data_main(C)->scene.first; scene; scene= scene->id.next) - if(WM_jobs_test(wm, scene)) + for (scene= CTX_data_main(C)->scene.first; scene; scene= scene->id.next) + if (WM_jobs_test(wm, scene)) break; owner = scene; handle_event= B_STOPRENDER; } - if(owner) { + if (owner) { uiLayout *ui_abs; ui_abs= uiLayoutAbsolute(layout, 0); @@ -2605,10 +2609,10 @@ void uiTemplateRunningJobs(uiLayout *layout, bContext *C) uiLayoutRow(layout, 0); } - if(WM_jobs_test(wm, screen)) + if (WM_jobs_test(wm, screen)) uiDefIconTextBut(block, BUT, B_STOPCAST, ICON_CANCEL, IFACE_("Capture"), 0,0,85,UI_UNIT_Y, NULL, 0.0f, 0.0f, 0, 0, TIP_("Stop screencast")); - if(screen->animtimer) + if (screen->animtimer) uiDefIconTextBut(block, BUT, B_STOPANIM, ICON_CANCEL, TIP_("Anim Player"), 0,0,100,UI_UNIT_Y, NULL, 0.0f, 0.0f, 0, 0, TIP_("Stop animation playback")); } @@ -2657,11 +2661,11 @@ void uiTemplateReportsBanner(uiLayout *layout, bContext *C) /* icon and report message on top */ - if(report->type & RPT_ERROR_ALL) + if (report->type & RPT_ERROR_ALL) icon = ICON_ERROR; - else if(report->type & RPT_WARNING_ALL) + else if (report->type & RPT_WARNING_ALL) icon = ICON_ERROR; - else if(report->type & RPT_INFO_ALL) + else if (report->type & RPT_INFO_ALL) icon = ICON_INFO; /* XXX: temporary operator to dump all reports to a text block, but only if more than 1 report @@ -2693,7 +2697,7 @@ static void template_keymap_item_properties(uiLayout *layout, const char *title, uiItemS(layout); - if(title) + if (title) uiItemL(layout, title, ICON_NONE); flow= uiLayoutColumnFlow(layout, 2, 0); @@ -2701,15 +2705,15 @@ static void template_keymap_item_properties(uiLayout *layout, const char *title, RNA_STRUCT_BEGIN(ptr, prop) { int flag= RNA_property_flag(prop); - if(flag & PROP_HIDDEN) + if (flag & PROP_HIDDEN) continue; /* recurse for nested properties */ - if(RNA_property_type(prop) == PROP_POINTER) { + if (RNA_property_type(prop) == PROP_POINTER) { PointerRNA propptr= RNA_property_pointer_get(ptr, prop); const char *name= RNA_property_ui_name(prop); - if(propptr.data && RNA_struct_is_a(propptr.type, &RNA_OperatorProperties)) { + if (propptr.data && RNA_struct_is_a(propptr.type, &RNA_OperatorProperties)) { template_keymap_item_properties(layout, name, &propptr); continue; } @@ -2725,14 +2729,14 @@ void uiTemplateKeymapItemProperties(uiLayout *layout, PointerRNA *ptr) { PointerRNA propptr= RNA_pointer_get(ptr, "properties"); - if(propptr.data) { + if (propptr.data) { uiBut *but= uiLayoutGetBlock(layout)->buttons.last; template_keymap_item_properties(layout, NULL, &propptr); /* attach callbacks to compensate for missing properties update, * we don't know which keymap (item) is being modified there */ - for(; but; but=but->next) + for (; but; but=but->next) uiButSetFunc(but, keymap_item_modified, ptr->data, NULL); } } diff --git a/source/blender/editors/interface/interface_utils.c b/source/blender/editors/interface/interface_utils.c index 6692bd7bea8..91b37896e66 100644 --- a/source/blender/editors/interface/interface_utils.c +++ b/source/blender/editors/interface/interface_utils.c @@ -60,12 +60,12 @@ uiBut *uiDefAutoButR(uiBlock *block, PointerRNA *ptr, PropertyRNA *prop, int ind { int arraylen= RNA_property_array_length(ptr, prop); - if(arraylen && index == -1) + if (arraylen && index == -1) return NULL; - if(icon && name && name[0] == '\0') + if (icon && name && name[0] == '\0') but = uiDefIconButR_prop(block, ICONTOG, 0, icon, x1, y1, x2, y2, ptr, prop, index, 0, 0, -1, -1, NULL); - else if(icon) + else if (icon) but = uiDefIconTextButR_prop(block, ICONTOG, 0, icon, name, x1, y1, x2, y2, ptr, prop, index, 0, 0, -1, -1, NULL); else but = uiDefButR_prop(block, OPTION, 0, name, x1, y1, x2, y2, ptr, prop, index, 0, 0, -1, -1, NULL); @@ -76,28 +76,28 @@ uiBut *uiDefAutoButR(uiBlock *block, PointerRNA *ptr, PropertyRNA *prop, int ind { int arraylen= RNA_property_array_length(ptr, prop); - if(arraylen && index == -1) { - if(ELEM(RNA_property_subtype(prop), PROP_COLOR, PROP_COLOR_GAMMA)) + if (arraylen && index == -1) { + if (ELEM(RNA_property_subtype(prop), PROP_COLOR, PROP_COLOR_GAMMA)) but = uiDefButR_prop(block, COL, 0, name, x1, y1, x2, y2, ptr, prop, 0, 0, 0, -1, -1, NULL); } - else if(RNA_property_subtype(prop) == PROP_PERCENTAGE || RNA_property_subtype(prop) == PROP_FACTOR) + else if (RNA_property_subtype(prop) == PROP_PERCENTAGE || RNA_property_subtype(prop) == PROP_FACTOR) but = uiDefButR_prop(block, NUMSLI, 0, name, x1, y1, x2, y2, ptr, prop, index, 0, 0, -1, -1, NULL); else but = uiDefButR_prop(block, NUM, 0, name, x1, y1, x2, y2, ptr, prop, index, 0, 0, -1, -1, NULL); break; } case PROP_ENUM: - if(icon && name && name[0] == '\0') + if (icon && name && name[0] == '\0') but = uiDefIconButR_prop(block, MENU, 0, icon, x1, y1, x2, y2, ptr, prop, index, 0, 0, -1, -1, NULL); - else if(icon) + else if (icon) but = uiDefIconTextButR_prop(block, MENU, 0, icon, NULL, x1, y1, x2, y2, ptr, prop, index, 0, 0, -1, -1, NULL); else but = uiDefButR_prop(block, MENU, 0, NULL, x1, y1, x2, y2, ptr, prop, index, 0, 0, -1, -1, NULL); break; case PROP_STRING: - if(icon && name && name[0] == '\0') + if (icon && name && name[0] == '\0') but = uiDefIconButR_prop(block, TEX, 0, icon, x1, y1, x2, y2, ptr, prop, index, 0, 0, -1, -1, NULL); - else if(icon) + else if (icon) but = uiDefIconTextButR_prop(block, TEX, 0, icon, name, x1, y1, x2, y2, ptr, prop, index, 0, 0, -1, -1, NULL); else but = uiDefButR_prop(block, TEX, 0, name, x1, y1, x2, y2, ptr, prop, index, 0, 0, -1, -1, NULL); @@ -106,10 +106,10 @@ uiBut *uiDefAutoButR(uiBlock *block, PointerRNA *ptr, PropertyRNA *prop, int ind PointerRNA pptr; pptr= RNA_property_pointer_get(ptr, prop); - if(!pptr.type) + if (!pptr.type) pptr.type= RNA_property_pointer_type(ptr, prop); icon= RNA_struct_ui_icon(pptr.type); - if(icon == ICON_DOT) + if (icon == ICON_DOT) icon= 0; but = uiDefIconTextButR_prop(block, IDPOIN, 0, icon, name, x1, y1, x2, y2, ptr, prop, index, 0, 0, -1, -1, NULL); @@ -141,22 +141,22 @@ int uiDefAutoButsRNA(uiLayout *layout, PointerRNA *ptr, int (*check_prop)(Pointe RNA_STRUCT_BEGIN(ptr, prop) { flag= RNA_property_flag(prop); - if(flag & PROP_HIDDEN || (check_prop && check_prop(ptr, prop)==FALSE)) + if (flag & PROP_HIDDEN || (check_prop && check_prop(ptr, prop)==FALSE)) continue; - if(label_align != '\0') { + if (label_align != '\0') { PropertyType type = RNA_property_type(prop); int is_boolean = (type == PROP_BOOLEAN && !RNA_property_array_check(prop)); name= RNA_property_ui_name(prop); - if(label_align=='V') { + if (label_align=='V') { col= uiLayoutColumn(layout, 1); - if(!is_boolean) + if (!is_boolean) uiItemL(col, name, ICON_NONE); } - else if(label_align=='H') { + else if (label_align=='H') { split = uiLayoutSplit(layout, 0.5f, 0); col= uiLayoutColumn(split, 0); @@ -194,16 +194,16 @@ int uiIconFromID(ID *id) PointerRNA ptr; short idcode; - if(id==NULL) + if (id==NULL) return ICON_NONE; idcode= GS(id->name); /* exception for objects */ - if(idcode == ID_OB) { + if (idcode == ID_OB) { ob= (Object*)id; - if(ob->type == OB_EMPTY) + if (ob->type == OB_EMPTY) return ICON_EMPTY_DATA; else return uiIconFromID(ob->data); diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c index 32cb3f94ee7..3baa672e42d 100644 --- a/source/blender/editors/interface/interface_widgets.c +++ b/source/blender/editors/interface/interface_widgets.c @@ -246,7 +246,7 @@ static int round_box_shadow_edges(float (*vert)[2], rcti *rect, float rad, int r rad+= step; - if(2.0f*rad > rect->ymax-rect->ymin) + if (2.0f*rad > rect->ymax-rect->ymin) rad= 0.5f*(rect->ymax-rect->ymin); minx= rect->xmin-step; @@ -255,59 +255,59 @@ static int round_box_shadow_edges(float (*vert)[2], rcti *rect, float rad, int r maxy= rect->ymax+step; /* mult */ - for(a=0; a < WIDGET_CURVE_RESOLU; a++) { + for (a=0; a < WIDGET_CURVE_RESOLU; a++) { vec[a][0]= rad*cornervec[a][0]; vec[a][1]= rad*cornervec[a][1]; } /* start with left-top, anti clockwise */ - if(roundboxalign & UI_CNR_TOP_LEFT) { - for(a=0; a < WIDGET_CURVE_RESOLU; a++, tot++) { + if (roundboxalign & UI_CNR_TOP_LEFT) { + for (a=0; a < WIDGET_CURVE_RESOLU; a++, tot++) { vert[tot][0]= minx+rad-vec[a][0]; vert[tot][1]= maxy-vec[a][1]; } } else { - for(a=0; a < WIDGET_CURVE_RESOLU; a++, tot++) { + for (a=0; a < WIDGET_CURVE_RESOLU; a++, tot++) { vert[tot][0]= minx; vert[tot][1]= maxy; } } - if(roundboxalign & UI_CNR_BOTTOM_LEFT) { - for(a=0; a < WIDGET_CURVE_RESOLU; a++, tot++) { + if (roundboxalign & UI_CNR_BOTTOM_LEFT) { + for (a=0; a < WIDGET_CURVE_RESOLU; a++, tot++) { vert[tot][0]= minx+vec[a][1]; vert[tot][1]= miny+rad-vec[a][0]; } } else { - for(a=0; a < WIDGET_CURVE_RESOLU; a++, tot++) { + for (a=0; a < WIDGET_CURVE_RESOLU; a++, tot++) { vert[tot][0]= minx; vert[tot][1]= miny; } } - if(roundboxalign & UI_CNR_BOTTOM_RIGHT) { - for(a=0; a < WIDGET_CURVE_RESOLU; a++, tot++) { + if (roundboxalign & UI_CNR_BOTTOM_RIGHT) { + for (a=0; a < WIDGET_CURVE_RESOLU; a++, tot++) { vert[tot][0]= maxx-rad+vec[a][0]; vert[tot][1]= miny+vec[a][1]; } } else { - for(a=0; a < WIDGET_CURVE_RESOLU; a++, tot++) { + for (a=0; a < WIDGET_CURVE_RESOLU; a++, tot++) { vert[tot][0]= maxx; vert[tot][1]= miny; } } - if(roundboxalign & UI_CNR_TOP_RIGHT) { - for(a=0; a < WIDGET_CURVE_RESOLU; a++, tot++) { + if (roundboxalign & UI_CNR_TOP_RIGHT) { + for (a=0; a < WIDGET_CURVE_RESOLU; a++, tot++) { vert[tot][0]= maxx-vec[a][1]; vert[tot][1]= maxy-rad+vec[a][0]; } } else { - for(a=0; a < WIDGET_CURVE_RESOLU; a++, tot++) { + for (a=0; a < WIDGET_CURVE_RESOLU; a++, tot++) { vert[tot][0]= maxx; vert[tot][1]= maxy; } @@ -334,14 +334,14 @@ static void round_box__edges(uiWidgetBase *wt, int roundboxalign, rcti *rect, fl minsize= MIN2((rect->xmax-rect->xmin)*hnum, (rect->ymax-rect->ymin)*vnum); - if(2.0f*rad > minsize) + if (2.0f*rad > minsize) rad= 0.5f*minsize; - if(2.0f*(radi+1.0f) > minsize) + if (2.0f*(radi+1.0f) > minsize) radi= 0.5f*minsize - 1.0f; /* mult */ - for(a=0; a < WIDGET_CURVE_RESOLU; a++) { + for (a=0; a < WIDGET_CURVE_RESOLU; a++) { veci[a][0]= radi*cornervec[a][0]; veci[a][1]= radi*cornervec[a][1]; vec[a][0]= rad*cornervec[a][0]; @@ -349,9 +349,9 @@ static void round_box__edges(uiWidgetBase *wt, int roundboxalign, rcti *rect, fl } /* corner left-bottom */ - if(roundboxalign & UI_CNR_BOTTOM_LEFT) { + if (roundboxalign & UI_CNR_BOTTOM_LEFT) { - for(a=0; a < WIDGET_CURVE_RESOLU; a++, tot++) { + for (a=0; a < WIDGET_CURVE_RESOLU; a++, tot++) { wt->inner_v[tot][0]= minxi+veci[a][1]; wt->inner_v[tot][1]= minyi+radi-veci[a][0]; @@ -376,9 +376,9 @@ static void round_box__edges(uiWidgetBase *wt, int roundboxalign, rcti *rect, fl } /* corner right-bottom */ - if(roundboxalign & UI_CNR_BOTTOM_RIGHT) { + if (roundboxalign & UI_CNR_BOTTOM_RIGHT) { - for(a=0; a < WIDGET_CURVE_RESOLU; a++, tot++) { + for (a=0; a < WIDGET_CURVE_RESOLU; a++, tot++) { wt->inner_v[tot][0]= maxxi-radi+veci[a][0]; wt->inner_v[tot][1]= minyi+veci[a][1]; @@ -405,9 +405,9 @@ static void round_box__edges(uiWidgetBase *wt, int roundboxalign, rcti *rect, fl wt->halfwayvert= tot; /* corner right-top */ - if(roundboxalign & UI_CNR_TOP_RIGHT) { + if (roundboxalign & UI_CNR_TOP_RIGHT) { - for(a=0; a < WIDGET_CURVE_RESOLU; a++, tot++) { + for (a=0; a < WIDGET_CURVE_RESOLU; a++, tot++) { wt->inner_v[tot][0]= maxxi-veci[a][1]; wt->inner_v[tot][1]= maxyi-radi+veci[a][0]; @@ -432,9 +432,9 @@ static void round_box__edges(uiWidgetBase *wt, int roundboxalign, rcti *rect, fl } /* corner left-top */ - if(roundboxalign & UI_CNR_TOP_LEFT) { + if (roundboxalign & UI_CNR_TOP_LEFT) { - for(a=0; a < WIDGET_CURVE_RESOLU; a++, tot++) { + for (a=0; a < WIDGET_CURVE_RESOLU; a++, tot++) { wt->inner_v[tot][0]= minxi+radi-veci[a][0]; wt->inner_v[tot][1]= maxyi-veci[a][1]; @@ -484,21 +484,21 @@ static void widget_num_tria(uiWidgetTrias *tria, rcti *rect, float triasize, cha centy= (float)rect->ymin + 0.5f*minsize; sizex= sizey= -0.5f*triasize*minsize; - if(where=='r') { + if (where=='r') { centx= (float)rect->xmax - 0.5f*minsize; sizex= -sizex; } - else if(where=='t') { + else if (where=='t') { centy= (float)rect->ymax - 0.5f*minsize; sizey= -sizey; i2=0; i1= 1; } - else if(where=='b') { + else if (where=='b') { sizex= -sizex; i2=0; i1= 1; } - for(a=0; a<3; a++) { + for (a=0; a<3; a++) { tria->vec[a][0]= sizex*num_tria_vert[a][i1] + centx; tria->vec[a][1]= sizey*num_tria_vert[a][i2] + centy; } @@ -519,21 +519,21 @@ static void widget_scroll_circle(uiWidgetTrias *tria, rcti *rect, float triasize centy= (float)rect->ymin + 0.5f*minsize; sizex= sizey= -0.5f*triasize*minsize; - if(where=='r') { + if (where=='r') { centx= (float)rect->xmax - 0.5f*minsize; sizex= -sizex; } - else if(where=='t') { + else if (where=='t') { centy= (float)rect->ymax - 0.5f*minsize; sizey= -sizey; i2=0; i1= 1; } - else if(where=='b') { + else if (where=='b') { sizex= -sizex; i2=0; i1= 1; } - for(a=0; a<16; a++) { + for (a=0; a<16; a++) { tria->vec[a][0]= sizex*scroll_circle_vert[a][i1] + centx; tria->vec[a][1]= sizey*scroll_circle_vert[a][i2] + centy; } @@ -562,10 +562,10 @@ static void widget_menu_trias(uiWidgetTrias *tria, rcti *rect) /* XXX exception */ asp= ((float)rect->xmax-rect->xmin)/((float)rect->ymax-rect->ymin); - if(asp > 1.2f && asp < 2.6f) + if (asp > 1.2f && asp < 2.6f) centx= rect->xmax - 0.3f*(rect->ymax-rect->ymin); - for(a=0; a<6; a++) { + for (a=0; a<6; a++) { tria->vec[a][0]= size*menu_tria_vert[a][0] + centx; tria->vec[a][1]= size*menu_tria_vert[a][1] + centy; } @@ -584,7 +584,7 @@ static void widget_check_trias(uiWidgetTrias *tria, rcti *rect) centy= rect->ymin + 0.5f*(rect->ymax-rect->ymin); size= 0.5f*(rect->ymax-rect->ymin); - for(a=0; a<6; a++) { + for (a=0; a<6; a++) { tria->vec[a][0]= size*check_tria_vert[a][0] + centx; tria->vec[a][1]= size*check_tria_vert[a][1] + centy; } @@ -623,7 +623,7 @@ static void round_box_shade_col4_r(unsigned char col_r[4], const char col1[4], c static void widget_verts_to_quad_strip(uiWidgetBase *wtb, const int totvert, float quad_strip[WIDGET_SIZE_MAX*2+2][2]) { int a; - for(a=0; aouter_v[a]); copy_v2_v2(quad_strip[a*2+1], wtb->inner_v[a]); } @@ -634,7 +634,7 @@ static void widget_verts_to_quad_strip(uiWidgetBase *wtb, const int totvert, flo static void widget_verts_to_quad_strip_open(uiWidgetBase *wtb, const int totvert, float quad_strip[WIDGET_SIZE_MAX*2][2]) { int a; - for(a=0; aouter_v[a][0]; quad_strip[a*2][1]= wtb->outer_v[a][1]; quad_strip[a*2+1][0]= wtb->outer_v[a][0]; @@ -660,8 +660,8 @@ static void widgetbase_draw(uiWidgetBase *wtb, uiWidgetColors *wcol) glEnable(GL_BLEND); /* backdrop non AA */ - if(wtb->inner) { - if(wcol->shaded==0) { + if (wtb->inner) { + if (wcol->shaded==0) { if (wcol->alpha_check) { float inner_v_half[WIDGET_SIZE_MAX][2]; float x_mid= 0.0f; /* used for dumb clamping of values */ @@ -691,7 +691,7 @@ static void widgetbase_draw(uiWidgetBase *wtb, uiWidgetColors *wcol) glColor4ubv((unsigned char*)wcol->inner); glEnableClientState(GL_VERTEX_ARRAY); - for(a=0; atotvert; a++) { + for (a=0; atotvert; a++) { x_mid += wtb->inner_v[a][0]; } x_mid /= wtb->totvert; @@ -703,7 +703,7 @@ static void widgetbase_draw(uiWidgetBase *wtb, uiWidgetColors *wcol) /* 1/2 solid color */ glColor4ub(wcol->inner[0], wcol->inner[1], wcol->inner[2], 255); - for(a=0; atotvert; a++) { + for (a=0; atotvert; a++) { inner_v_half[a][0]= MIN2(wtb->inner_v[a][0], x_mid); inner_v_half[a][1]= wtb->inner_v[a][1]; } @@ -731,7 +731,7 @@ static void widgetbase_draw(uiWidgetBase *wtb, uiWidgetColors *wcol) shadecolors4(col1, col2, wcol->inner, wcol->shadetop, wcol->shadedown); glShadeModel(GL_SMOOTH); - for(a=0; atotvert; a++, col_pt += 4) { + for (a=0; atotvert; a++, col_pt += 4) { round_box_shade_col4_r(col_pt, col1, col2, wtb->inner_uv[a][wtb->shadedir]); } @@ -748,7 +748,7 @@ static void widgetbase_draw(uiWidgetBase *wtb, uiWidgetColors *wcol) } /* for each AA step */ - if(wtb->outline) { + if (wtb->outline) { float quad_strip[WIDGET_SIZE_MAX*2+2][2]; /* + 2 because the last pair is wrapped */ float quad_strip_emboss[WIDGET_SIZE_MAX*2][2]; /* only for emboss */ @@ -759,7 +759,7 @@ static void widgetbase_draw(uiWidgetBase *wtb, uiWidgetColors *wcol) widget_verts_to_quad_strip(wtb, wtb->totvert, quad_strip); - if(wtb->emboss) { + if (wtb->emboss) { widget_verts_to_quad_strip_open(wtb, wtb->halfwayvert, quad_strip_emboss); } @@ -775,7 +775,7 @@ static void widgetbase_draw(uiWidgetBase *wtb, uiWidgetColors *wcol) glDrawArrays(GL_QUAD_STRIP, 0, wtb->totvert*2 + 2); /* emboss bottom shadow */ - if(wtb->emboss) { + if (wtb->emboss) { glColor4f(1.0f, 1.0f, 1.0f, 0.02f); glVertexPointer(2, GL_FLOAT, 0, quad_strip_emboss); @@ -789,7 +789,7 @@ static void widgetbase_draw(uiWidgetBase *wtb, uiWidgetColors *wcol) } /* decoration */ - if(wtb->tria1.tot || wtb->tria2.tot) { + if (wtb->tria1.tot || wtb->tria2.tot) { const unsigned char tcol[4] = {wcol->item[0], wcol->item[1], wcol->item[2], @@ -798,11 +798,11 @@ static void widgetbase_draw(uiWidgetBase *wtb, uiWidgetColors *wcol) for (j = 0; j < WIDGET_AA_JITTER; j++) { glTranslatef(1.0f * jit[j][0], 1.0f * jit[j][1], 0.0f); - if(wtb->tria1.tot) { + if (wtb->tria1.tot) { glColor4ubv(tcol); widget_trias_draw(&wtb->tria1); } - if(wtb->tria2.tot) { + if (wtb->tria2.tot) { glColor4ubv(tcol); widget_trias_draw(&wtb->tria2); } @@ -823,7 +823,7 @@ static void widget_draw_preview(BIFIconID icon, float UNUSED(alpha), rcti *rect) { int w, h, size; - if(icon==ICON_NONE) + if (icon==ICON_NONE) return; w = rect->xmax - rect->xmin; @@ -831,7 +831,7 @@ static void widget_draw_preview(BIFIconID icon, float UNUSED(alpha), rcti *rect) size = MIN2(w, h); size -= PREVIEW_PAD*2; /* padding */ - if(size > 0) { + if (size > 0) { int x = rect->xmin + w/2 - size/2; int y = rect->ymin + h/2 - size/2; @@ -858,11 +858,11 @@ static void widget_draw_icon(uiBut *but, BIFIconID icon, float alpha, rcti *rect } /* this icon doesn't need draw... */ - if(icon==ICON_BLANK1 && (but->flag & UI_ICON_SUBMENU)==0) return; + if (icon==ICON_BLANK1 && (but->flag & UI_ICON_SUBMENU)==0) return; /* we need aspect from block, for menus... these buttons are scaled in uiPositionBlock() */ aspect= but->block->aspect; - if(aspect != but->aspect) { + if (aspect != but->aspect) { /* prevent scaling up icon in pupmenu */ if (aspect < 1.0f) { height= UI_DPI_ICON_SIZE; @@ -877,27 +877,28 @@ static void widget_draw_icon(uiBut *but, BIFIconID icon, float alpha, rcti *rect /* calculate blend color */ if ELEM4(but->type, TOG, ROW, TOGN, LISTROW) { - if(but->flag & UI_SELECT); - else if(but->flag & UI_ACTIVE); + if (but->flag & UI_SELECT); + else if (but->flag & UI_ACTIVE); else alpha= 0.5f; } /* extra feature allows more alpha blending */ - if(but->type==LABEL && but->a1==1.0f) alpha *= but->a2; + if (but->type==LABEL && but->a1==1.0f) alpha *= but->a2; glEnable(GL_BLEND); - if(icon && icon!=ICON_BLANK1) { - if(but->flag & UI_ICON_LEFT) { + if (icon && icon!=ICON_BLANK1) { + if (but->flag & UI_ICON_LEFT) { if (but->type==BUT_TOGDUAL) { if (but->drawstr[0]) { xs= rect->xmin-1; - } else { + } + else { xs= (rect->xmin+rect->xmax- height)/2; } } else if (but->block->flag & UI_BLOCK_LOOP) { - if(but->type==SEARCH_MENU) + if (but->type==SEARCH_MENU) xs= rect->xmin+4; else xs= rect->xmin+1; @@ -916,7 +917,7 @@ static void widget_draw_icon(uiBut *but, BIFIconID icon, float alpha, rcti *rect } /* to indicate draggable */ - if(but->dragpoin && (but->flag & UI_ACTIVE)) { + if (but->dragpoin && (but->flag & UI_ACTIVE)) { float rgb[3]= {1.25f, 1.25f, 1.25f}; UI_icon_draw_aspect_color(xs, ys, icon, aspect, rgb); } @@ -965,21 +966,21 @@ static void ui_text_leftclip(uiFontStyle *fstyle, uiBut *but, rcti *rect) BLF_enable(fstyle->uifont_id, BLF_KERNING_DEFAULT); /* if text editing we define ofs dynamically */ - if(but->editstr && but->pos >= 0) { - if(but->ofs > but->pos) + if (but->editstr && but->pos >= 0) { + if (but->ofs > but->pos) but->ofs= but->pos; - if(BLF_width(fstyle->uifont_id, but->drawstr) <= okwidth) + if (BLF_width(fstyle->uifont_id, but->drawstr) <= okwidth) but->ofs = 0; } else but->ofs= 0; but->strwidth= BLF_width(fstyle->uifont_id, but->drawstr + but->ofs); - while(but->strwidth > okwidth) { + while (but->strwidth > okwidth) { /* textbut exception, clip right when... */ - if(but->editstr && but->pos >= 0) { + if (but->editstr && but->pos >= 0) { float width; char buf[UI_MAX_DRAW_STR]; @@ -990,12 +991,12 @@ static void ui_text_leftclip(uiFontStyle *fstyle, uiBut *but, rcti *rect) width= BLF_width(fstyle->uifont_id, buf+but->ofs); /* if cursor is at 20 pixels of right side button we clip left */ - if(width > okwidth-20) + if (width > okwidth-20) ui_text_clip_give_next_off(but); else { int len, bytes; /* shift string to the left */ - if(width < 20 && but->ofs > 0) + if (width < 20 && but->ofs > 0) ui_text_clip_give_prev_off(but); len= strlen(but->drawstr); bytes= BLI_str_utf8_size(BLI_str_find_prev_char_utf8(but->drawstr, but->drawstr + len)); @@ -1007,7 +1008,7 @@ static void ui_text_leftclip(uiFontStyle *fstyle, uiBut *but, rcti *rect) but->strwidth= BLF_width(fstyle->uifont_id, but->drawstr+but->ofs); - if(but->strwidth < 10) break; + if (but->strwidth < 10) break; } if (fstyle->kerning==1) @@ -1047,7 +1048,7 @@ static void ui_text_label_rightclip(uiFontStyle *fstyle, uiBut *but, rcti *rect) cp2-=bytes; but->strwidth= BLF_width(fstyle->uifont_id, but->drawstr+but->ofs); - if(but->strwidth < 10) break; + if (but->strwidth < 10) break; } @@ -1056,13 +1057,13 @@ static void ui_text_label_rightclip(uiFontStyle *fstyle, uiBut *but, rcti *rect) { ui_text_clip_give_next_off(but); but->strwidth= BLF_width(fstyle->uifont_id, but->drawstr+but->ofs); - if(but->strwidth < 10) break; + if (but->strwidth < 10) break; } } /* once the label's gone, chop off the least significant digits */ - while(but->strwidth > okwidth ) { + while (but->strwidth > okwidth ) { int len= strlen(but->drawstr); int bytes= BLI_str_utf8_size(BLI_str_find_prev_char_utf8(but->drawstr, but->drawstr + len)); if (bytes < 0) @@ -1071,7 +1072,7 @@ static void ui_text_label_rightclip(uiFontStyle *fstyle, uiBut *but, rcti *rect) but->drawstr[ len-bytes ]= 0; but->strwidth= BLF_width(fstyle->uifont_id, but->drawstr+but->ofs); - if(but->strwidth < 10) break; + if (but->strwidth < 10) break; } if (fstyle->kerning==1) @@ -1089,7 +1090,7 @@ static void widget_draw_text(uiFontStyle *fstyle, uiWidgetColors *wcol, uiBut *b uiStyleFontSet(fstyle); - if(but->editstr || (but->flag & UI_TEXT_LEFT)) + if (but->editstr || (but->flag & UI_TEXT_LEFT)) fstyle->align= UI_STYLE_TEXT_LEFT; else fstyle->align= UI_STYLE_TEXT_CENTER; @@ -1098,7 +1099,7 @@ static void widget_draw_text(uiFontStyle *fstyle, uiWidgetColors *wcol, uiBut *b BLF_enable(fstyle->uifont_id, BLF_KERNING_DEFAULT); /* text button selection and cursor */ - if(but->editstr && but->pos != -1) { + if (but->editstr && but->pos != -1) { short t=0, pos=0, ch; short selsta_tmp, selend_tmp, selsta_draw, selwidth_draw; @@ -1107,7 +1108,7 @@ static void widget_draw_text(uiFontStyle *fstyle, uiWidgetColors *wcol, uiBut *b selsta_tmp = but->selsta; selend_tmp = but->selend; - if(but->drawstr[0]!=0) { + if (but->drawstr[0]!=0) { if (but->selsta >= but->ofs) { ch= but->drawstr[selsta_tmp]; @@ -1116,8 +1117,10 @@ static void widget_draw_text(uiFontStyle *fstyle, uiWidgetColors *wcol, uiBut *b selsta_draw = BLF_width(fstyle->uifont_id, but->drawstr+but->ofs); but->drawstr[selsta_tmp]= ch; - } else + } + else { selsta_draw = 0; + } ch= but->drawstr[selend_tmp]; but->drawstr[selend_tmp]= 0; @@ -1129,11 +1132,12 @@ static void widget_draw_text(uiFontStyle *fstyle, uiWidgetColors *wcol, uiBut *b glColor3ubv((unsigned char*)wcol->item); glRects(rect->xmin+selsta_draw, rect->ymin+2, rect->xmin+selwidth_draw, rect->ymax-2); } - } else { + } + else { /* text cursor */ pos= but->pos; - if(pos >= but->ofs) { - if(but->drawstr[0]!=0) { + if (pos >= but->ofs) { + if (but->drawstr[0]!=0) { ch= but->drawstr[pos]; but->drawstr[pos]= 0; @@ -1152,14 +1156,14 @@ static void widget_draw_text(uiFontStyle *fstyle, uiWidgetColors *wcol, uiBut *b BLF_disable(fstyle->uifont_id, BLF_KERNING_DEFAULT); // ui_rasterpos_safe(x, y, but->aspect); -// if(but->type==IDPOIN) transopts= 0; // no translation, of course! +// if (but->type==IDPOIN) transopts= 0; // no translation, of course! // else transopts= ui_translate_buttons(); /* cut string in 2 parts - only for menu entries */ - if((but->block->flag & UI_BLOCK_LOOP)) { - if(ELEM5(but->type, SLI, NUM, TEX, NUMSLI, NUMABS)==0) { + if ((but->block->flag & UI_BLOCK_LOOP)) { + if (ELEM5(but->type, SLI, NUM, TEX, NUMSLI, NUMABS)==0) { cpoin= strchr(but->drawstr, '|'); - if(cpoin) *cpoin= 0; + if (cpoin) *cpoin= 0; } } @@ -1167,17 +1171,17 @@ static void widget_draw_text(uiFontStyle *fstyle, uiWidgetColors *wcol, uiBut *b uiStyleFontDrawExt(fstyle, rect, but->drawstr+but->ofs, &font_xofs, &font_yofs); - if(but->menu_key != '\0') { + if (but->menu_key != '\0') { char fixedbuf[128]; char *str; BLI_strncpy(fixedbuf, but->drawstr + but->ofs, sizeof(fixedbuf)); str= strchr(fixedbuf, but->menu_key-32); /* upper case */ - if(str==NULL) + if (str==NULL) str= strchr(fixedbuf, but->menu_key); - if(str) { + if (str) { int ul_index= -1; float ul_advance; @@ -1200,7 +1204,7 @@ static void widget_draw_text(uiFontStyle *fstyle, uiWidgetColors *wcol, uiBut *b } /* part text right aligned */ - if(cpoin) { + if (cpoin) { fstyle->align= UI_STYLE_TEXT_RIGHT; rect->xmax -= ui_but_draw_menu_icon(but) ? UI_DPI_ICON_SIZE : 5; uiStyleFontDraw(fstyle, rect, cpoin+1); @@ -1212,7 +1216,7 @@ static void widget_draw_text(uiFontStyle *fstyle, uiWidgetColors *wcol, uiBut *b static void widget_draw_text_icon(uiFontStyle *fstyle, uiWidgetColors *wcol, uiBut *but, rcti *rect) { - if(but==NULL) return; + if (but==NULL) return; /* clip but->drawstr to fit in available space */ if (but->editstr && but->pos >= 0) { @@ -1235,16 +1239,16 @@ static void widget_draw_text_icon(uiFontStyle *fstyle, uiWidgetColors *wcol, uiB } else { - if(but->type==BUT_TOGDUAL) { + if (but->type==BUT_TOGDUAL) { int dualset= 0; - if(but->pointype==SHO) + if (but->pointype==SHO) dualset= BTST( *(((short *)but->poin)+1), but->bitnr); - else if(but->pointype==INT) + else if (but->pointype==INT) dualset= BTST( *(((int *)but->poin)+1), but->bitnr); widget_draw_icon(but, ICON_DOT, dualset?1.0f:0.25f, rect); } - else if(but->type==MENU && (but->flag & UI_BUT_NODE_LINK)) { + else if (but->type==MENU && (but->flag & UI_BUT_NODE_LINK)) { int tmp = rect->xmin; rect->xmin = rect->xmax - (rect->ymax - rect->ymin) - 1; widget_draw_icon(but, ICON_LAYER_USED, 1.0f, rect); @@ -1259,10 +1263,10 @@ static void widget_draw_text_icon(uiFontStyle *fstyle, uiWidgetColors *wcol, uiB rect->xmin += (int)((float)UI_icon_get_width(but->icon+but->iconadd) * UI_DPI_ICON_FAC); - if(but->editstr || (but->flag & UI_TEXT_LEFT)) + if (but->editstr || (but->flag & UI_TEXT_LEFT)) rect->xmin += 5; } - else if((but->flag & UI_TEXT_LEFT)) + else if ((but->flag & UI_TEXT_LEFT)) rect->xmin += 5; /* always draw text for textbutton cursor */ @@ -1577,7 +1581,7 @@ void ui_widget_color_init(ThemeUI *tui) static void widget_state_blend(char cp[3], const char cpstate[3], const float fac) { - if(fac != 0.0f) { + if (fac != 0.0f) { cp[0]= (int)((1.0f-fac)*cp[0] + fac*cpstate[0]); cp[1]= (int)((1.0f-fac)*cp[1] + fac*cpstate[1]); cp[2]= (int)((1.0f-fac)*cp[2] + fac*cpstate[2]); @@ -1591,41 +1595,41 @@ static void widget_state(uiWidgetType *wt, int state) wt->wcol= *(wt->wcol_theme); - if(state & UI_SELECT) { + if (state & UI_SELECT) { copy_v4_v4_char(wt->wcol.inner, wt->wcol.inner_sel); - if(state & UI_BUT_ANIMATED_KEY) + if (state & UI_BUT_ANIMATED_KEY) widget_state_blend(wt->wcol.inner, wcol_state->inner_key_sel, wcol_state->blend); - else if(state & UI_BUT_ANIMATED) + else if (state & UI_BUT_ANIMATED) widget_state_blend(wt->wcol.inner, wcol_state->inner_anim_sel, wcol_state->blend); - else if(state & UI_BUT_DRIVEN) + else if (state & UI_BUT_DRIVEN) widget_state_blend(wt->wcol.inner, wcol_state->inner_driven_sel, wcol_state->blend); copy_v3_v3_char(wt->wcol.text, wt->wcol.text_sel); - if(state & UI_SELECT) + if (state & UI_SELECT) SWAP(short, wt->wcol.shadetop, wt->wcol.shadedown); } else { - if(state & UI_BUT_ANIMATED_KEY) + if (state & UI_BUT_ANIMATED_KEY) widget_state_blend(wt->wcol.inner, wcol_state->inner_key, wcol_state->blend); - else if(state & UI_BUT_ANIMATED) + else if (state & UI_BUT_ANIMATED) widget_state_blend(wt->wcol.inner, wcol_state->inner_anim, wcol_state->blend); - else if(state & UI_BUT_DRIVEN) + else if (state & UI_BUT_DRIVEN) widget_state_blend(wt->wcol.inner, wcol_state->inner_driven, wcol_state->blend); - if(state & UI_ACTIVE) { /* mouse over? */ + if (state & UI_ACTIVE) { /* mouse over? */ wt->wcol.inner[0]= wt->wcol.inner[0]>=240? 255 : wt->wcol.inner[0]+15; wt->wcol.inner[1]= wt->wcol.inner[1]>=240? 255 : wt->wcol.inner[1]+15; wt->wcol.inner[2]= wt->wcol.inner[2]>=240? 255 : wt->wcol.inner[2]+15; } } - if(state & UI_BUT_REDALERT) { + if (state & UI_BUT_REDALERT) { char red[4]= {255, 0, 0}; widget_state_blend(wt->wcol.inner, red, 0.4f); } - if(state & UI_BUT_NODE_ACTIVE) { + if (state & UI_BUT_NODE_ACTIVE) { char blue[4]= {86, 128, 194}; widget_state_blend(wt->wcol.inner, blue, 0.3f); } @@ -1642,24 +1646,24 @@ static void widget_state_numslider(uiWidgetType *wt, int state) /* now, set the inner-part so that it reflects state settings too */ // TODO: maybe we should have separate settings for the blending colors used for this case? - if(state & UI_SELECT) { + if (state & UI_SELECT) { - if(state & UI_BUT_ANIMATED_KEY) + if (state & UI_BUT_ANIMATED_KEY) widget_state_blend(wt->wcol.item, wcol_state->inner_key_sel, blend); - else if(state & UI_BUT_ANIMATED) + else if (state & UI_BUT_ANIMATED) widget_state_blend(wt->wcol.item, wcol_state->inner_anim_sel, blend); - else if(state & UI_BUT_DRIVEN) + else if (state & UI_BUT_DRIVEN) widget_state_blend(wt->wcol.item, wcol_state->inner_driven_sel, blend); - if(state & UI_SELECT) + if (state & UI_SELECT) SWAP(short, wt->wcol.shadetop, wt->wcol.shadedown); } else { - if(state & UI_BUT_ANIMATED_KEY) + if (state & UI_BUT_ANIMATED_KEY) widget_state_blend(wt->wcol.item, wcol_state->inner_key, blend); - else if(state & UI_BUT_ANIMATED) + else if (state & UI_BUT_ANIMATED) widget_state_blend(wt->wcol.item, wcol_state->inner_anim, blend); - else if(state & UI_BUT_DRIVEN) + else if (state & UI_BUT_DRIVEN) widget_state_blend(wt->wcol.item, wcol_state->inner_driven, blend); } } @@ -1670,7 +1674,7 @@ static void widget_state_label(uiWidgetType *wt, int state) /* call this for option button */ widget_state(wt, state); - if(state & UI_SELECT) + if (state & UI_SELECT) UI_GetThemeColor4ubv(TH_TEXT_HI, (unsigned char *)wt->wcol.text); else UI_GetThemeColor4ubv(TH_TEXT, (unsigned char *)wt->wcol.text); @@ -1685,7 +1689,7 @@ static void widget_state_option_menu(uiWidgetType *wt, int state) widget_state(wt, state); /* if not selected we get theme from menu back */ - if(state & UI_SELECT) + if (state & UI_SELECT) UI_GetThemeColor4ubv(TH_TEXT_HI, (unsigned char *)wt->wcol.text); else { bTheme *btheme= UI_GetTheme(); /* XXX */ @@ -1708,7 +1712,7 @@ static void widget_state_pulldown(uiWidgetType *wt, int state) copy_v4_v4_char(wt->wcol.inner, wt->wcol.inner_sel); copy_v3_v3_char(wt->wcol.outline, wt->wcol.inner); - if(state & UI_ACTIVE) + if (state & UI_ACTIVE) copy_v3_v3_char(wt->wcol.text, wt->wcol.text_sel); } @@ -1717,12 +1721,12 @@ static void widget_state_menu_item(uiWidgetType *wt, int state) { wt->wcol= *(wt->wcol_theme); - if(state & (UI_BUT_DISABLED|UI_BUT_INACTIVE)) { + if (state & (UI_BUT_DISABLED|UI_BUT_INACTIVE)) { wt->wcol.text[0]= 0.5f*(wt->wcol.text[0]+wt->wcol.text_sel[0]); wt->wcol.text[1]= 0.5f*(wt->wcol.text[1]+wt->wcol.text_sel[1]); wt->wcol.text[2]= 0.5f*(wt->wcol.text[2]+wt->wcol.text_sel[2]); } - else if(state & UI_ACTIVE) { + else if (state & UI_ACTIVE) { copy_v4_v4_char(wt->wcol.inner, wt->wcol.inner_sel); copy_v3_v3_char(wt->wcol.text, wt->wcol.text_sel); } @@ -1741,7 +1745,7 @@ static void widget_softshadow(rcti *rect, int roundboxalign, float radin, float float quad_strip[WIDGET_SIZE_MAX*2][2]; /* prevent tooltips to not show round shadow */ - if( 2.0f*radout > 0.2f*(rect1.ymax-rect1.ymin) ) + if ( 2.0f*radout > 0.2f*(rect1.ymax-rect1.ymin) ) rect1.ymax -= 0.2f*(rect1.ymax-rect1.ymin); else rect1.ymax -= 2.0f*radout; @@ -1755,7 +1759,7 @@ static void widget_softshadow(rcti *rect, int roundboxalign, float radin, float glEnableClientState(GL_VERTEX_ARRAY); - for(step= 1; step<=radout; step++, alpha*=alphastep) { + for (step= 1; step<=radout; step++, alpha*=alphastep) { round_box_shadow_edges(wtb.outer_v, &rect1, radin, UI_CNR_ALL, (float)step); glColor4f(0.0f, 0.0f, 0.0f, alpha); @@ -1828,7 +1832,7 @@ void ui_hsvcircle_vals_from_pos(float *valrad, float *valdist, rcti *rect, float float centy= (float)(rect->ymin + rect->ymax)/2; float radius, dist; - if( rect->xmax-rect->xmin > rect->ymax-rect->ymin ) + if ( rect->xmax-rect->xmin > rect->ymax-rect->ymin ) radius= (float)(rect->ymax - rect->ymin)/2; else radius= (float)(rect->xmax - rect->xmin)/2; @@ -1836,7 +1840,7 @@ void ui_hsvcircle_vals_from_pos(float *valrad, float *valdist, rcti *rect, float mx-= centx; my-= centy; dist= sqrt( mx*mx + my*my); - if(dist < radius) + if (dist < radius) *valdist= dist/radius; else *valdist= 1.0f; @@ -1860,7 +1864,7 @@ static void ui_draw_but_HSVCIRCLE(uiBut *but, uiWidgetColors *wcol, rcti *rect) centx= (float)(rect->xmin + rect->xmax)/2; centy= (float)(rect->ymin + rect->ymax)/2; - if( rect->xmax-rect->xmin > rect->ymax-rect->ymin ) + if ( rect->xmax-rect->xmin > rect->ymax-rect->ymin ) radius= (float)(rect->ymax - rect->ymin)/2; else radius= (float)(rect->xmax - rect->xmin)/2; @@ -1887,7 +1891,7 @@ static void ui_draw_but_HSVCIRCLE(uiBut *but, uiWidgetColors *wcol, rcti *rect) glColor3fv(colcent); glVertex2f( centx, centy); - for(a=0; a<=tot; a++, ang+=radstep) { + for (a=0; a<=tot; a++, ang+=radstep) { float si= sin(ang); float co= cos(ang); @@ -1916,7 +1920,7 @@ static void ui_draw_but_HSVCIRCLE(uiBut *but, uiWidgetColors *wcol, rcti *rect) /* cursor */ ang= 2.0f*(float)M_PI*hsvo[0] + 0.5f*(float)M_PI; - if(but->flag & UI_BUT_COLOR_CUBIC) + if (but->flag & UI_BUT_COLOR_CUBIC) cursor_radius = (1.0f - powf(1.0f - hsvo[1], 3.0f)); else cursor_radius = hsvo[1]; @@ -1986,7 +1990,7 @@ void ui_draw_gradient(rcti *rect, const float hsv[3], int type, float alpha) /* old below */ - for(dx=0.0f; dx<1.0f; dx+= 0.05f) { + for (dx=0.0f; dx<1.0f; dx+= 0.05f) { // previous color copy_v3_v3(col0[0], col1[0]); copy_v3_v3(col0[1], col1[1]); @@ -2040,7 +2044,7 @@ void ui_draw_gradient(rcti *rect, const float hsv[3], int type, float alpha) dy= (rect->ymax-rect->ymin)/3.0; glBegin(GL_QUADS); - for(a=0; a<3; a++, sy+=dy) { + for (a=0; a<3; a++, sy+=dy) { glColor4f(col0[a][0], col0[a][1], col0[a][2], alpha); glVertex2f(sx1, sy); @@ -2182,7 +2186,7 @@ static void widget_numbut(uiWidgetColors *wcol, rcti *rect, int state, int round float rad= 0.5f*(rect->ymax - rect->ymin); float textofs = rad*0.75f; - if(state & UI_SELECT) + if (state & UI_SELECT) SWAP(short, wcol->shadetop, wcol->shadedown); widget_init(&wtb); @@ -2191,7 +2195,7 @@ static void widget_numbut(uiWidgetColors *wcol, rcti *rect, int state, int round round_box_edges(&wtb, roundboxalign, rect, rad); /* decoration */ - if(!(state & UI_TEXTINPUT)) { + if (!(state & UI_TEXTINPUT)) { widget_num_tria(&wtb.tria1, rect, 0.6f, 'l'); widget_num_tria(&wtb.tria2, rect, 0.6f, 'r'); } @@ -2232,7 +2236,7 @@ void ui_draw_link_bezier(rcti *rect) { float coord_array[LINK_RESOL+1][2]; - if(ui_link_bezier_points(rect, coord_array, LINK_RESOL)) { + if (ui_link_bezier_points(rect, coord_array, LINK_RESOL)) { /* we can reuse the dist variable here to increment the GL curve eval amount*/ // const float dist= 1.0f/(float)LINK_RESOL; // UNUSED @@ -2263,7 +2267,7 @@ void uiWidgetScrollDraw(uiWidgetColors *wcol, rcti *rect, rcti *slider, int stat /* determine horizontal/vertical */ horizontal= (rect->xmax - rect->xmin > rect->ymax - rect->ymin); - if(horizontal) + if (horizontal) rad= 0.5f*(rect->ymax - rect->ymin); else rad= 0.5f*(rect->xmax - rect->xmin); @@ -2271,25 +2275,25 @@ void uiWidgetScrollDraw(uiWidgetColors *wcol, rcti *rect, rcti *slider, int stat wtb.shadedir= (horizontal)? 1: 0; /* draw back part, colors swapped and shading inverted */ - if(horizontal) + if (horizontal) SWAP(short, wcol->shadetop, wcol->shadedown); round_box_edges(&wtb, UI_CNR_ALL, rect, rad); widgetbase_draw(&wtb, wcol); /* slider */ - if(slider->xmax-slider->xmin<2 || slider->ymax-slider->ymin<2); + if (slider->xmax-slider->xmin<2 || slider->ymax-slider->ymin<2); else { SWAP(short, wcol->shadetop, wcol->shadedown); copy_v4_v4_char(wcol->inner, wcol->item); - if(wcol->shadetop>wcol->shadedown) + if (wcol->shadetop>wcol->shadedown) wcol->shadetop+= 20; /* XXX violates themes... */ else wcol->shadedown+= 20; - if(state & UI_SCROLL_PRESSED) { + if (state & UI_SCROLL_PRESSED) { wcol->inner[0]= wcol->inner[0]>=250? 255 : wcol->inner[0]+5; wcol->inner[1]= wcol->inner[1]>=250? 255 : wcol->inner[1]+5; wcol->inner[2]= wcol->inner[2]>=250? 255 : wcol->inner[2]+5; @@ -2304,13 +2308,13 @@ void uiWidgetScrollDraw(uiWidgetColors *wcol, rcti *rect, rcti *slider, int stat round_box_edges(&wtb, UI_CNR_ALL, slider, rad); - if(state & UI_SCROLL_ARROWS) { - if(wcol->item[0] > 48) wcol->item[0]-= 48; - if(wcol->item[1] > 48) wcol->item[1]-= 48; - if(wcol->item[2] > 48) wcol->item[2]-= 48; + if (state & UI_SCROLL_ARROWS) { + if (wcol->item[0] > 48) wcol->item[0]-= 48; + if (wcol->item[1] > 48) wcol->item[1]-= 48; + if (wcol->item[2] > 48) wcol->item[2]-= 48; wcol->item[3]= 255; - if(horizontal) { + if (horizontal) { widget_scroll_circle(&wtb.tria1, slider, 0.6f, 'l'); widget_scroll_circle(&wtb.tria2, slider, 0.6f, 'r'); } @@ -2345,7 +2349,7 @@ static void widget_scroll(uiBut *but, uiWidgetColors *wcol, rcti *rect, int stat /* determine horizontal/vertical */ horizontal= (rect->xmax - rect->xmin > rect->ymax - rect->ymin); - if(horizontal) { + if (horizontal) { fac= (rect->xmax - rect->xmin)/(size); rect1.xmin = rect1.xmin + ceilf(fac*((float)value - but->softmin)); rect1.xmax = rect1.xmin + ceilf(fac*(but->a1 - but->softmin)); @@ -2353,10 +2357,10 @@ static void widget_scroll(uiBut *but, uiWidgetColors *wcol, rcti *rect, int stat /* ensure minimium size */ min= rect->ymax - rect->ymin; - if(rect1.xmax - rect1.xmin < min) { + if (rect1.xmax - rect1.xmin < min) { rect1.xmax = rect1.xmin + min; - if(rect1.xmax > rect->xmax) { + if (rect1.xmax > rect->xmax) { rect1.xmax = rect->xmax; rect1.xmin = MAX2(rect1.xmax - min, rect->xmin); } @@ -2370,17 +2374,17 @@ static void widget_scroll(uiBut *but, uiWidgetColors *wcol, rcti *rect, int stat /* ensure minimium size */ min= rect->xmax - rect->xmin; - if(rect1.ymax - rect1.ymin < min) { + if (rect1.ymax - rect1.ymin < min) { rect1.ymax = rect1.ymin + min; - if(rect1.ymax > rect->ymax) { + if (rect1.ymax > rect->ymax) { rect1.ymax = rect->ymax; rect1.ymin = MAX2(rect1.ymax - min, rect->ymin); } } } - if(state & UI_SELECT) + if (state & UI_SELECT) state= UI_SCROLL_PRESSED; else state= 0; @@ -2416,7 +2420,7 @@ static void widget_progressbar(uiBut *but, uiWidgetColors *wcol, rcti *rect, int static void widget_link(uiBut *but, uiWidgetColors *UNUSED(wcol), rcti *rect, int UNUSED(state), int UNUSED(roundboxalign)) { - if(but->flag & UI_SELECT) { + if (but->flag & UI_SELECT) { rcti rectlink; UI_ThemeColor(TH_TEXT_HI); @@ -2452,14 +2456,14 @@ static void widget_numslider(uiBut *but, uiWidgetColors *wcol, rcti *rect, int s widgetbase_draw(&wtb, wcol); /* draw left/right parts only when not in text editing */ - if(!(state & UI_TEXTINPUT)) { + if (!(state & UI_TEXTINPUT)) { /* slider part */ copy_v3_v3_char(outline, wcol->outline); copy_v3_v3_char(wcol->outline, wcol->item); copy_v3_v3_char(wcol->inner, wcol->item); - if(!(state & UI_SELECT)) + if (!(state & UI_SELECT)) SWAP(short, wcol->shadetop, wcol->shadedown); rect1= *rect; @@ -2476,7 +2480,7 @@ static void widget_numslider(uiBut *but, uiWidgetColors *wcol, rcti *rect, int s /* right part of slider, interpolate roundness */ rect1.xmax = rect1.xmin + fac + offs; rect1.xmin+= floor(offs-1.0f); - if(rect1.xmax + offs > rect->xmax) + if (rect1.xmax + offs > rect->xmax) offs*= (rect1.xmax + offs - rect->xmax)/offs; else offs= 0.0f; @@ -2485,7 +2489,7 @@ static void widget_numslider(uiBut *but, uiWidgetColors *wcol, rcti *rect, int s widgetbase_draw(&wtb1, wcol); copy_v3_v3_char(wcol->outline, outline); - if(!(state & UI_SELECT)) + if (!(state & UI_SELECT)) SWAP(short, wcol->shadetop, wcol->shadedown); } @@ -2514,7 +2518,7 @@ static void widget_swatch(uiBut *but, uiWidgetColors *wcol, rcti *rect, int stat if (RNA_property_subtype(but->rnaprop) == PROP_COLOR_GAMMA) color_profile = BLI_PR_NONE; - if(RNA_property_array_length(&but->rnapoin, but->rnaprop)==4) { + if (RNA_property_array_length(&but->rnapoin, but->rnaprop)==4) { col[3]= RNA_property_float_get_index(&but->rnapoin, but->rnaprop, 3); } } @@ -2526,7 +2530,7 @@ static void widget_swatch(uiBut *but, uiWidgetColors *wcol, rcti *rect, int stat ui_get_but_vectorf(but, col); - if(state & (UI_BUT_ANIMATED|UI_BUT_ANIMATED_KEY|UI_BUT_DRIVEN|UI_BUT_REDALERT)) { + if (state & (UI_BUT_ANIMATED|UI_BUT_ANIMATED_KEY|UI_BUT_DRIVEN|UI_BUT_REDALERT)) { // draw based on state - color for keyed etc widgetbase_draw(&wtb, wcol); @@ -2553,7 +2557,7 @@ static void widget_swatch(uiBut *but, uiWidgetColors *wcol, rcti *rect, int stat static void widget_icon_has_anim(uiBut *UNUSED(but), uiWidgetColors *wcol, rcti *rect, int state, int UNUSED(roundboxalign)) { - if(state & (UI_BUT_ANIMATED|UI_BUT_ANIMATED_KEY|UI_BUT_DRIVEN|UI_BUT_REDALERT)) { + if (state & (UI_BUT_ANIMATED|UI_BUT_ANIMATED_KEY|UI_BUT_DRIVEN|UI_BUT_REDALERT)) { uiWidgetBase wtb; widget_init(&wtb); @@ -2570,7 +2574,7 @@ static void widget_textbut(uiWidgetColors *wcol, rcti *rect, int state, int roun { uiWidgetBase wtb; - if(state & UI_SELECT) + if (state & UI_SELECT) SWAP(short, wcol->shadetop, wcol->shadedown); widget_init(&wtb); @@ -2639,7 +2643,7 @@ static void widget_menunodebut(uiWidgetColors *wcol, rcti *rect, int UNUSED(stat static void widget_pulldownbut(uiWidgetColors *wcol, rcti *rect, int state, int UNUSED(roundboxalign)) { - if(state & UI_ACTIVE) { + if (state & UI_ACTIVE) { uiWidgetBase wtb; float rad= 0.5f*(rect->ymax - rect->ymin); // 4.0f @@ -2700,7 +2704,7 @@ static void widget_optionbut(uiWidgetColors *wcol, rcti *rect, int state, int UN round_box_edges(&wtb, UI_CNR_ALL, &recttemp, 4.0f); /* decoration */ - if(state & UI_SELECT) { + if (state & UI_SELECT) { widget_check_trias(&wtb.tria1, &recttemp); } @@ -2789,7 +2793,7 @@ static void widget_draw_extra_mask(const bContext *C, uiBut *but, uiWidgetType * widget_init(&wtb); - if(but->block->drawextra) { + if (but->block->drawextra) { /* note: drawextra can change rect +1 or -1, to match round errors of existing previews */ but->block->drawextra(C, but->poin, but->block->drawextra_arg1, but->block->drawextra_arg2, rect); @@ -2984,11 +2988,11 @@ static uiWidgetType *widget_type(uiWidgetTypeEnum type) static int widget_roundbox_set(uiBut *but, rcti *rect) { /* alignment */ - if(but->flag & UI_BUT_ALIGN) { + if (but->flag & UI_BUT_ALIGN) { - if(but->flag & UI_BUT_ALIGN_TOP) + if (but->flag & UI_BUT_ALIGN_TOP) rect->ymax+= 1; - if(but->flag & UI_BUT_ALIGN_LEFT) + if (but->flag & UI_BUT_ALIGN_LEFT) rect->xmin-= 1; switch(but->flag & UI_BUT_ALIGN) { @@ -3025,7 +3029,7 @@ void ui_draw_but(const bContext *C, ARegion *ar, uiStyle *style, uiBut *but, rct uiWidgetType *wt= NULL; /* handle menus separately */ - if(but->dt==UI_EMBOSSP) { + if (but->dt==UI_EMBOSSP) { switch (but->type) { case LABEL: widget_draw_text_icon(&style->widgetlabel, &tui->wcol_menu_back, but, rect); @@ -3038,7 +3042,7 @@ void ui_draw_but(const bContext *C, ARegion *ar, uiStyle *style, uiBut *but, rct wt= widget_type(UI_WTYPE_MENU_ITEM); } } - else if(but->dt==UI_EMBOSSN) { + else if (but->dt==UI_EMBOSSN) { /* "nothing" */ wt= widget_type(UI_WTYPE_ICON); } @@ -3046,7 +3050,7 @@ void ui_draw_but(const bContext *C, ARegion *ar, uiStyle *style, uiBut *but, rct switch (but->type) { case LABEL: - if(but->block->flag & UI_BLOCK_LOOP) + if (but->block->flag & UI_BLOCK_LOOP) widget_draw_text_icon(&style->widgetlabel, &tui->wcol_menu_back, but, rect); else { wt= widget_type(UI_WTYPE_LABEL); @@ -3084,7 +3088,7 @@ void ui_draw_but(const bContext *C, ARegion *ar, uiStyle *style, uiBut *but, rct case SEARCH_MENU: wt= widget_type(UI_WTYPE_NAME); - if(but->block->flag & UI_BLOCK_LOOP) + if (but->block->flag & UI_BLOCK_LOOP) wt->wcol_theme= &btheme->tui.wcol_menu_back; break; @@ -3105,7 +3109,7 @@ void ui_draw_but(const bContext *C, ARegion *ar, uiStyle *style, uiBut *but, rct wt= widget_type(UI_WTYPE_TOGGLE); /* option buttons have strings outside, on menus use different colors */ - if(but->block->flag & UI_BLOCK_LOOP) + if (but->block->flag & UI_BLOCK_LOOP) wt->state= widget_state_option_menu; break; @@ -3113,9 +3117,9 @@ void ui_draw_but(const bContext *C, ARegion *ar, uiStyle *style, uiBut *but, rct case MENU: case BLOCK: case ICONTEXTROW: - if(but->flag & UI_BUT_NODE_LINK) + if (but->flag & UI_BUT_NODE_LINK) wt= widget_type(UI_WTYPE_MENU_NODE_LINK); - else if(!but->str[0] && but->icon) + else if (!but->str[0] && but->icon) wt= widget_type(UI_WTYPE_MENU_ICON_RADIO); else wt= widget_type(UI_WTYPE_MENU_RADIO); @@ -3150,7 +3154,7 @@ void ui_draw_but(const bContext *C, ARegion *ar, uiStyle *style, uiBut *but, rct break; case HSVCUBE: - if(but->a1 == UI_GRAD_V_ALT) // vertical V slider, uses new widget draw now + if (but->a1 == UI_GRAD_V_ALT) // vertical V slider, uses new widget draw now ui_draw_but_HSV_v(but, rect); else // other HSV pickers... ui_draw_but_HSVCUBE(but, rect); @@ -3206,24 +3210,24 @@ void ui_draw_but(const bContext *C, ARegion *ar, uiStyle *style, uiBut *but, rct } } - if(wt) { + if (wt) { rcti disablerect= *rect; /* rect gets clipped smaller for text */ int roundboxalign, state; roundboxalign= widget_roundbox_set(but, rect); state= but->flag; - if(but->editstr) state |= UI_TEXTINPUT; + if (but->editstr) state |= UI_TEXTINPUT; wt->state(wt, state); - if(wt->custom) + if (wt->custom) wt->custom(but, &wt->wcol, rect, state, roundboxalign); - else if(wt->draw) + else if (wt->draw) wt->draw(&wt->wcol, rect, state, roundboxalign); wt->text(fstyle, &wt->wcol, but, rect); - if(state & (UI_BUT_DISABLED|UI_BUT_INACTIVE)) - if(but->dt!=UI_EMBOSSP) + if (state & (UI_BUT_DISABLED|UI_BUT_INACTIVE)) + if (but->dt!=UI_EMBOSSP) widget_disabled(&disablerect); } } @@ -3233,18 +3237,18 @@ void ui_draw_menu_back(uiStyle *UNUSED(style), uiBlock *block, rcti *rect) uiWidgetType *wt= widget_type(UI_WTYPE_MENU_BACK); wt->state(wt, 0); - if(block) + if (block) wt->draw(&wt->wcol, rect, block->flag, block->direction); else wt->draw(&wt->wcol, rect, 0, 0); - if(block) { - if(block->flag & UI_BLOCK_CLIPTOP) { + if (block) { + if (block->flag & UI_BLOCK_CLIPTOP) { /* XXX no scaling for UI here yet */ glColor3ubv((unsigned char*)wt->wcol.text); UI_DrawTriIcon((rect->xmax+rect->xmin)/2, rect->ymax-8, 't'); } - if(block->flag & UI_BLOCK_CLIPBOTTOM) { + if (block->flag & UI_BLOCK_CLIPBOTTOM) { /* XXX no scaling for UI here yet */ glColor3ubv((unsigned char*)wt->wcol.text); UI_DrawTriIcon((rect->xmax+rect->xmin)/2, rect->ymin+10, 'v'); @@ -3252,7 +3256,7 @@ void ui_draw_menu_back(uiStyle *UNUSED(style), uiBlock *block, rcti *rect) } } -uiWidgetColors* ui_tooltip_get_theme(void){ +uiWidgetColors* ui_tooltip_get_theme(void) { uiWidgetType *wt = widget_type(UI_WTYPE_TOOLTIP); return wt->wcol_theme; } @@ -3274,7 +3278,7 @@ void ui_draw_search_back(uiStyle *UNUSED(style), uiBlock *block, rcti *rect) glDisable(GL_BLEND); wt->state(wt, 0); - if(block) + if (block) wt->draw(&wt->wcol, rect, block->flag, UI_CNR_ALL); else wt->draw(&wt->wcol, rect, 0, UI_CNR_ALL); @@ -3298,11 +3302,11 @@ void ui_draw_menu_item(uiFontStyle *fstyle, rcti *rect, const char *name, int ic /* text location offset */ rect->xmin+=5; - if(iconid) rect->xmin+= UI_DPI_ICON_SIZE; + if (iconid) rect->xmin+= UI_DPI_ICON_SIZE; /* cut string in 2 parts? */ cpoin= strchr(name, '|'); - if(cpoin) { + if (cpoin) { *cpoin= 0; rect->xmax -= BLF_width(fstyle->uifont_id, cpoin+1) + 10; } @@ -3311,7 +3315,7 @@ void ui_draw_menu_item(uiFontStyle *fstyle, rcti *rect, const char *name, int ic uiStyleFontDraw(fstyle, rect, name); /* part text right aligned */ - if(cpoin) { + if (cpoin) { fstyle->align= UI_STYLE_TEXT_RIGHT; rect->xmax = _rect.xmax - 5; uiStyleFontDraw(fstyle, rect, cpoin+1); @@ -3321,7 +3325,7 @@ void ui_draw_menu_item(uiFontStyle *fstyle, rcti *rect, const char *name, int ic /* restore rect, was messed with */ *rect= _rect; - if(iconid) { + if (iconid) { int xs= rect->xmin+4; int ys= 1 + (rect->ymin+rect->ymax- UI_DPI_ICON_SIZE)/2; glEnable(GL_BLEND); @@ -3349,7 +3353,7 @@ void ui_draw_preview_item(uiFontStyle *fstyle, rcti *rect, const char *name, int trect.xmax = trect.xmin + font_dims[0] + 10; trect.ymin += 10; trect.ymax = trect.ymin + font_dims[1]; - if(trect.xmax > rect->xmax - PREVIEW_PAD) + if (trect.xmax > rect->xmax - PREVIEW_PAD) trect.xmax = rect->xmax - PREVIEW_PAD; bg_rect = trect; @@ -3358,7 +3362,7 @@ void ui_draw_preview_item(uiFontStyle *fstyle, rcti *rect, const char *name, int bg_rect.xmax = rect->xmax - PREVIEW_PAD; bg_rect.ymax += PREVIEW_PAD / 2; - if(bg_rect.xmax > rect->xmax - PREVIEW_PAD) + if (bg_rect.xmax > rect->xmax - PREVIEW_PAD) bg_rect.xmax = rect->xmax - PREVIEW_PAD; UI_GetThemeColor3ubv(TH_BUTBACK, bg_col); diff --git a/source/blender/editors/interface/resources.c b/source/blender/editors/interface/resources.c index a534fe11856..3cfb429383a 100644 --- a/source/blender/editors/interface/resources.c +++ b/source/blender/editors/interface/resources.c @@ -89,10 +89,10 @@ const unsigned char *UI_ThemeGetColorPtr(bTheme *btheme, int spacetype, int colo const char *cp= error; - if(btheme) { + if (btheme) { // first check for ui buttons theme - if(colorid < TH_THEMEUI) { + if (colorid < TH_THEMEUI) { switch(colorid) { @@ -161,41 +161,41 @@ const unsigned char *UI_ThemeGetColorPtr(bTheme *btheme, int spacetype, int colo switch(colorid) { case TH_BACK: - if(theme_regionid==RGN_TYPE_WINDOW) + if (theme_regionid==RGN_TYPE_WINDOW) cp= ts->back; - else if(theme_regionid==RGN_TYPE_CHANNELS) + else if (theme_regionid==RGN_TYPE_CHANNELS) cp= ts->list; - else if(theme_regionid==RGN_TYPE_HEADER) + else if (theme_regionid==RGN_TYPE_HEADER) cp= ts->header; else cp= ts->button; break; case TH_TEXT: - if(theme_regionid==RGN_TYPE_WINDOW) + if (theme_regionid==RGN_TYPE_WINDOW) cp= ts->text; - else if(theme_regionid==RGN_TYPE_CHANNELS) + else if (theme_regionid==RGN_TYPE_CHANNELS) cp= ts->list_text; - else if(theme_regionid==RGN_TYPE_HEADER) + else if (theme_regionid==RGN_TYPE_HEADER) cp= ts->header_text; else cp= ts->button_text; break; case TH_TEXT_HI: - if(theme_regionid==RGN_TYPE_WINDOW) + if (theme_regionid==RGN_TYPE_WINDOW) cp= ts->text_hi; - else if(theme_regionid==RGN_TYPE_CHANNELS) + else if (theme_regionid==RGN_TYPE_CHANNELS) cp= ts->list_text_hi; - else if(theme_regionid==RGN_TYPE_HEADER) + else if (theme_regionid==RGN_TYPE_HEADER) cp= ts->header_text_hi; else cp= ts->button_text_hi; break; case TH_TITLE: - if(theme_regionid==RGN_TYPE_WINDOW) + if (theme_regionid==RGN_TYPE_WINDOW) cp= ts->title; - else if(theme_regionid==RGN_TYPE_CHANNELS) + else if (theme_regionid==RGN_TYPE_CHANNELS) cp= ts->list_title; - else if(theme_regionid==RGN_TYPE_HEADER) + else if (theme_regionid==RGN_TYPE_HEADER) cp= ts->header_title; else cp= ts->button_title; @@ -602,11 +602,11 @@ void ui_theme_init_default(void) bTheme *btheme; /* we search for the theme with name Default */ - for(btheme= U.themes.first; btheme; btheme= btheme->next) { - if(strcmp("Default", btheme->name)==0) break; + for (btheme= U.themes.first; btheme; btheme= btheme->next) { + if (strcmp("Default", btheme->name)==0) break; } - if(btheme==NULL) { + if (btheme==NULL) { btheme= MEM_callocN(sizeof(bTheme), "theme"); BLI_addtail(&U.themes, btheme); strcpy(btheme->name, "Default"); @@ -870,7 +870,7 @@ void ui_theme_init_default(void) void UI_SetTheme(int spacetype, int regionid) { - if(spacetype==0) { // called for safety, when delete themes + if (spacetype==0) { // called for safety, when delete themes theme_active= U.themes.first; theme_spacetype= SPACE_VIEW3D; theme_regionid= RGN_TYPE_WINDOW; @@ -1182,16 +1182,16 @@ void init_userdef_do_versions(void) // countall(); /* the UserDef struct is not corrected with do_versions() .... ugh! */ - if(U.wheellinescroll == 0) U.wheellinescroll = 3; - if(U.menuthreshold1==0) { + if (U.wheellinescroll == 0) U.wheellinescroll = 3; + if (U.menuthreshold1==0) { U.menuthreshold1= 5; U.menuthreshold2= 2; } - if(U.tb_leftmouse==0) { + if (U.tb_leftmouse==0) { U.tb_leftmouse= 5; U.tb_rightmouse= 5; } - if(U.mixbufsize==0) U.mixbufsize= 2048; + if (U.mixbufsize==0) U.mixbufsize= 2048; if (strcmp(U.tempdir, "/") == 0) { BLI_system_temporary_dir(U.tempdir); } @@ -1204,12 +1204,12 @@ void init_userdef_do_versions(void) // XXX error(STRINGIFY(BLENDER_STARTUP_FILE)" is buggy, please consider removing it.\n"); } /* transform widget settings */ - if(U.tw_hotspot==0) { + if (U.tw_hotspot==0) { U.tw_hotspot= 14; U.tw_size= 20; // percentage of window size U.tw_handlesize= 16; // percentage of widget radius } - if(U.pad_rot_angle==0) + if (U.pad_rot_angle==0) U.pad_rot_angle= 15; /* graph editor - unselected F-Curve visibility */ if (U.fcu_inactive_alpha == 0) { @@ -1237,18 +1237,18 @@ void init_userdef_do_versions(void) U.uiflag |= USER_GLOBALUNDO; if (U.undosteps==0) U.undosteps=32; - for(btheme= U.themes.first; btheme; btheme= btheme->next) { + for (btheme= U.themes.first; btheme; btheme= btheme->next) { /* check for alpha==0 is safe, then color was never set */ - if(btheme->tv3d.edge_seam[3]==0) { + if (btheme->tv3d.edge_seam[3]==0) { rgba_char_args_set(btheme->tv3d.edge_seam, 230, 150, 50, 255); } - if(btheme->tv3d.normal[3]==0) { + if (btheme->tv3d.normal[3]==0) { rgba_char_args_set(btheme->tv3d.normal, 0x22, 0xDD, 0xDD, 255); } - if(btheme->tv3d.vertex_normal[3]==0) { + if (btheme->tv3d.vertex_normal[3]==0) { rgba_char_args_set(btheme->tv3d.vertex_normal, 0x23, 0x61, 0xDD, 255); } - if(btheme->tv3d.face_dot[3]==0) { + if (btheme->tv3d.face_dot[3]==0) { rgba_char_args_set(btheme->tv3d.face_dot, 255, 138, 48, 255); btheme->tv3d.facedot_size= 4; } @@ -1262,16 +1262,16 @@ void init_userdef_do_versions(void) if (bmain->versionfile <= 236) { bTheme *btheme; /* new space type */ - for(btheme= U.themes.first; btheme; btheme= btheme->next) { + for (btheme= U.themes.first; btheme; btheme= btheme->next) { /* check for alpha==0 is safe, then color was never set */ - if(btheme->ttime.back[3]==0) { + if (btheme->ttime.back[3]==0) { // copied from ui_theme_init_default btheme->ttime= btheme->tv3d; rgba_char_args_set_fl(btheme->ttime.back, 0.45, 0.45, 0.45, 1.0); rgba_char_args_set_fl(btheme->ttime.grid, 0.36, 0.36, 0.36, 1.0); rgba_char_args_set(btheme->ttime.shade1, 173, 173, 173, 255); // sliders } - if(btheme->text.syntaxn[3]==0) { + if (btheme->text.syntaxn[3]==0) { rgba_char_args_set(btheme->text.syntaxn, 0, 0, 200, 255); /* Numbers Blue*/ rgba_char_args_set(btheme->text.syntaxl, 100, 0, 0, 255); /* Strings red */ rgba_char_args_set(btheme->text.syntaxc, 0, 100, 50, 255); /* Comments greenish */ @@ -1283,9 +1283,9 @@ void init_userdef_do_versions(void) if (bmain->versionfile <= 237) { bTheme *btheme; /* bone colors */ - for(btheme= U.themes.first; btheme; btheme= btheme->next) { + for (btheme= U.themes.first; btheme; btheme= btheme->next) { /* check for alpha==0 is safe, then color was never set */ - if(btheme->tv3d.bone_solid[3]==0) { + if (btheme->tv3d.bone_solid[3]==0) { rgba_char_args_set(btheme->tv3d.bone_solid, 200, 200, 200, 255); rgba_char_args_set(btheme->tv3d.bone_pose, 80, 200, 255, 80); } @@ -1294,9 +1294,9 @@ void init_userdef_do_versions(void) if (bmain->versionfile <= 238) { bTheme *btheme; /* bone colors */ - for(btheme= U.themes.first; btheme; btheme= btheme->next) { + for (btheme= U.themes.first; btheme; btheme= btheme->next) { /* check for alpha==0 is safe, then color was never set */ - if(btheme->tnla.strip[3]==0) { + if (btheme->tnla.strip[3]==0) { rgba_char_args_set(btheme->tnla.strip_select, 0xff, 0xff, 0xaa, 255); rgba_char_args_set(btheme->tnla.strip, 0xe4, 0x9c, 0xc6, 255); } @@ -1305,22 +1305,22 @@ void init_userdef_do_versions(void) if (bmain->versionfile <= 239) { bTheme *btheme; - for(btheme= U.themes.first; btheme; btheme= btheme->next) { + for (btheme= U.themes.first; btheme; btheme= btheme->next) { /* Lamp theme, check for alpha==0 is safe, then color was never set */ - if(btheme->tv3d.lamp[3]==0) { + if (btheme->tv3d.lamp[3]==0) { rgba_char_args_set(btheme->tv3d.lamp, 0, 0, 0, 40); /* TEMPORAL, remove me! (ton) */ U.uiflag |= USER_PLAINMENUS; } } - if(U.obcenter_dia==0) U.obcenter_dia= 6; + if (U.obcenter_dia==0) U.obcenter_dia= 6; } if (bmain->versionfile <= 241) { bTheme *btheme; - for(btheme= U.themes.first; btheme; btheme= btheme->next) { + for (btheme= U.themes.first; btheme; btheme= btheme->next) { /* Node editor theme, check for alpha==0 is safe, then color was never set */ - if(btheme->tnode.syntaxn[3]==0) { + if (btheme->tnode.syntaxn[3]==0) { /* re-uses syntax color storage */ btheme->tnode= btheme->tv3d; rgba_char_args_set(btheme->tnode.edge_select, 255, 255, 255, 255); @@ -1331,12 +1331,12 @@ void init_userdef_do_versions(void) rgba_char_args_set(btheme->tnode.syntaxc, 120, 145, 120, 255); /* group */ } /* Group theme colors */ - if(btheme->tv3d.group[3]==0) { + if (btheme->tv3d.group[3]==0) { rgba_char_args_set(btheme->tv3d.group, 0x0C, 0x30, 0x0C, 255); rgba_char_args_set(btheme->tv3d.group_active, 0x66, 0xFF, 0x66, 255); } /* Sequence editor theme*/ - if(btheme->tseq.movie[3]==0) { + if (btheme->tseq.movie[3]==0) { rgba_char_args_set(btheme->tseq.movie, 81, 105, 135, 255); rgba_char_args_set(btheme->tseq.image, 109, 88, 129, 255); rgba_char_args_set(btheme->tseq.scene, 78, 152, 62, 255); @@ -1360,17 +1360,17 @@ void init_userdef_do_versions(void) if (bmain->versionfile <= 242) { bTheme *btheme; - for(btheme= U.themes.first; btheme; btheme= btheme->next) { + for (btheme= U.themes.first; btheme; btheme= btheme->next) { /* long keyframe color */ /* check for alpha==0 is safe, then color was never set */ - if(btheme->tact.strip[3]==0) { + if (btheme->tact.strip[3]==0) { rgba_char_args_set(btheme->tv3d.edge_sharp, 255, 32, 32, 255); rgba_char_args_set(btheme->tact.strip_select, 0xff, 0xff, 0xaa, 204); rgba_char_args_set(btheme->tact.strip, 0xe4, 0x9c, 0xc6, 204); } /* IPO-Editor - Vertex Size*/ - if(btheme->tipo.vertex_size == 0) { + if (btheme->tipo.vertex_size == 0) { btheme->tipo.vertex_size= 3; } } @@ -1381,10 +1381,10 @@ void init_userdef_do_versions(void) } if (bmain->versionfile < 245 || (bmain->versionfile == 245 && bmain->subversionfile < 3)) { bTheme *btheme; - for(btheme= U.themes.first; btheme; btheme= btheme->next) { + for (btheme= U.themes.first; btheme; btheme= btheme->next) { rgba_char_args_set(btheme->tv3d.editmesh_active, 255, 255, 255, 128); } - if(U.coba_weight.tot==0) + if (U.coba_weight.tot==0) init_colorband(&U.coba_weight, 1); } if ((bmain->versionfile < 245) || (bmain->versionfile == 245 && bmain->subversionfile < 11)) { @@ -1440,9 +1440,9 @@ void init_userdef_do_versions(void) if (bmain->versionfile < 250) { bTheme *btheme; - for(btheme= U.themes.first; btheme; btheme= btheme->next) { + for (btheme= U.themes.first; btheme; btheme= btheme->next) { /* this was not properly initialized in 2.45 */ - if(btheme->tima.face_dot[3]==0) { + if (btheme->tima.face_dot[3]==0) { rgba_char_args_set(btheme->tima.editmesh_active, 255, 255, 255, 128); rgba_char_args_set(btheme->tima.face_dot, 255, 133, 0, 255); btheme->tima.facedot_size= 2; @@ -1481,16 +1481,16 @@ void init_userdef_do_versions(void) if (bmain->versionfile < 250 || (bmain->versionfile == 250 && bmain->subversionfile < 1)) { bTheme *btheme; - for(btheme= U.themes.first; btheme; btheme= btheme->next) { + for (btheme= U.themes.first; btheme; btheme= btheme->next) { /* common (new) variables, it checks for alpha==0 */ ui_theme_init_new(btheme); - if(btheme->tui.wcol_num.outline[3]==0) + if (btheme->tui.wcol_num.outline[3]==0) ui_widget_color_init(&btheme->tui); /* Logic editor theme, check for alpha==0 is safe, then color was never set */ - if(btheme->tlogic.syntaxn[3]==0) { + if (btheme->tlogic.syntaxn[3]==0) { /* re-uses syntax color storage */ btheme->tlogic= btheme->tv3d; rgba_char_args_set(btheme->tlogic.back, 100, 100, 100, 255); @@ -1503,9 +1503,9 @@ void init_userdef_do_versions(void) if (bmain->versionfile < 250 || (bmain->versionfile == 250 && bmain->subversionfile < 3)) { /* new audio system */ - if(U.audiochannels == 0) + if (U.audiochannels == 0) U.audiochannels = 2; - if(U.audiodevice == 0) { + if (U.audiodevice == 0) { #ifdef WITH_OPENAL U.audiodevice = 2; #endif @@ -1513,9 +1513,9 @@ void init_userdef_do_versions(void) U.audiodevice = 1; #endif } - if(U.audioformat == 0) + if (U.audioformat == 0) U.audioformat = 0x24; - if(U.audiorate == 0) + if (U.audiorate == 0) U.audiorate = 44100; } @@ -1525,7 +1525,7 @@ void init_userdef_do_versions(void) if (bmain->versionfile < 250 || (bmain->versionfile == 250 && bmain->subversionfile < 8)) { wmKeyMap *km; - for(km=U.user_keymaps.first; km; km=km->next) { + for (km=U.user_keymaps.first; km; km=km->next) { if (strcmp(km->idname, "Armature_Sketch")==0) strcpy(km->idname, "Armature Sketch"); else if (strcmp(km->idname, "View3D")==0) @@ -1563,7 +1563,7 @@ void init_userdef_do_versions(void) } } if (bmain->versionfile < 250 || (bmain->versionfile == 250 && bmain->subversionfile < 16)) { - if(U.wmdrawmethod == USER_DRAW_TRIPLE) + if (U.wmdrawmethod == USER_DRAW_TRIPLE) U.wmdrawmethod = USER_DRAW_AUTOMATIC; } @@ -1578,7 +1578,7 @@ void init_userdef_do_versions(void) U.keyhandles_new = HD_AUTO; /* init new curve colors */ - for(btheme= U.themes.first; btheme; btheme= btheme->next) { + for (btheme= U.themes.first; btheme; btheme= btheme->next) { /* init colors used for handles in 3D-View */ rgba_char_args_set(btheme->tv3d.handle_free, 0, 0, 0, 255); rgba_char_args_set(btheme->tv3d.handle_auto, 0x90, 0x90, 0x00, 255); @@ -1608,7 +1608,7 @@ void init_userdef_do_versions(void) bTheme *btheme; /* init new curve colors */ - for(btheme= U.themes.first; btheme; btheme= btheme->next) { + for (btheme= U.themes.first; btheme; btheme= btheme->next) { if (btheme->tv3d.lastsel_point[3] == 0) rgba_char_args_set(btheme->tv3d.lastsel_point, 0xff, 0xff, 0xff, 255); } @@ -1630,7 +1630,7 @@ void init_userdef_do_versions(void) 5, -5 }; - for(btheme= U.themes.first; btheme; btheme= btheme->next) { + for (btheme= U.themes.first; btheme; btheme= btheme->next) { /* init progress bar theme */ btheme->tui.wcol_progress= wcol_progress; } @@ -1638,7 +1638,7 @@ void init_userdef_do_versions(void) if (bmain->versionfile < 255 || (bmain->versionfile == 255 && bmain->subversionfile < 2)) { bTheme *btheme; - for(btheme= U.themes.first; btheme; btheme= btheme->next) { + for (btheme= U.themes.first; btheme; btheme= btheme->next) { rgba_char_args_set(btheme->tv3d.extra_edge_len, 32, 0, 0, 255); rgba_char_args_set(btheme->tv3d.extra_face_angle, 0, 32, 0, 255); rgba_char_args_set(btheme->tv3d.extra_face_area, 0, 0, 128, 255); @@ -1647,8 +1647,8 @@ void init_userdef_do_versions(void) if (bmain->versionfile < 256 || (bmain->versionfile == 256 && bmain->subversionfile < 4)) { bTheme *btheme; - for(btheme= U.themes.first; btheme; btheme= btheme->next) { - if((btheme->tv3d.outline_width) == 0) btheme->tv3d.outline_width= 1; + for (btheme= U.themes.first; btheme; btheme= btheme->next) { + if ((btheme->tv3d.outline_width) == 0) btheme->tv3d.outline_width= 1; } } @@ -1659,7 +1659,7 @@ void init_userdef_do_versions(void) if (bmain->versionfile < 258 || (bmain->versionfile == 258 && bmain->subversionfile < 2)) { bTheme *btheme; - for(btheme= U.themes.first; btheme; btheme= btheme->next) { + for (btheme= U.themes.first; btheme; btheme= btheme->next) { btheme->tnode.noodle_curving = 5; } } @@ -1667,7 +1667,7 @@ void init_userdef_do_versions(void) if (bmain->versionfile < 259 || (bmain->versionfile == 259 && bmain->subversionfile < 1)) { bTheme *btheme; - for(btheme= U.themes.first; btheme; btheme= btheme->next) { + for (btheme= U.themes.first; btheme; btheme= btheme->next) { btheme->tv3d.speaker[3] = 255; } } @@ -1681,14 +1681,14 @@ void init_userdef_do_versions(void) if (U.keyhandles_new == HD_AUTO) U.keyhandles_new = HD_AUTO_ANIM; - for(btheme= U.themes.first; btheme; btheme= btheme->next) { - if(btheme->tv3d.bundle_solid[3] == 0) + for (btheme= U.themes.first; btheme; btheme= btheme->next) { + if (btheme->tv3d.bundle_solid[3] == 0) rgba_char_args_set(btheme->tv3d.bundle_solid, 200, 200, 200, 255); - if(btheme->tv3d.camera_path[3] == 0) + if (btheme->tv3d.camera_path[3] == 0) rgba_char_args_set(btheme->tv3d.camera_path, 0x00, 0x00, 0x00, 255); - if((btheme->tclip.back[3]) == 0) { + if ((btheme->tclip.back[3]) == 0) { btheme->tclip= btheme->tv3d; rgba_char_args_set(btheme->tclip.marker_outline, 0x00, 0x00, 0x00, 255); @@ -1707,14 +1707,14 @@ void init_userdef_do_versions(void) } /* auto-clamped handles -> based on auto */ - if(btheme->tipo.handle_auto_clamped[3] == 0) + if (btheme->tipo.handle_auto_clamped[3] == 0) rgba_char_args_set(btheme->tipo.handle_auto_clamped, 0x99, 0x40, 0x30, 255); - if(btheme->tipo.handle_sel_auto_clamped[3] == 0) + if (btheme->tipo.handle_sel_auto_clamped[3] == 0) rgba_char_args_set(btheme->tipo.handle_sel_auto_clamped, 0xf0, 0xaf, 0x90, 255); } /* enable (Cycles) addon by default */ - if(!BLI_findstring(&U.addons, "cycles", offsetof(bAddon, module))) { + if (!BLI_findstring(&U.addons, "cycles", offsetof(bAddon, module))) { bAddon *baddon= MEM_callocN(sizeof(bAddon), "bAddon"); BLI_strncpy(baddon->module, "cycles", sizeof(baddon->module)); BLI_addtail(&U.addons, baddon); @@ -1724,7 +1724,7 @@ void init_userdef_do_versions(void) if (bmain->versionfile < 260 || (bmain->versionfile == 260 && bmain->subversionfile < 5)) { bTheme *btheme; - for(btheme= U.themes.first; btheme; btheme= btheme->next) { + for (btheme= U.themes.first; btheme; btheme= btheme->next) { rgba_char_args_set(btheme->tui.panel.header, 0, 0, 0, 25); btheme->tui.icon_alpha= 1.0; } @@ -1732,7 +1732,7 @@ void init_userdef_do_versions(void) if (bmain->versionfile < 261 || (bmain->versionfile == 261 && bmain->subversionfile < 4)) { bTheme *btheme; - for(btheme= U.themes.first; btheme; btheme= btheme->next) { + for (btheme= U.themes.first; btheme; btheme= btheme->next) { rgba_char_args_set_fl(btheme->tima.preview_stitch_face, 0.071, 0.259, 0.694, 0.150); rgba_char_args_set_fl(btheme->tima.preview_stitch_edge, 1.0, 0.522, 0.0, 0.7); rgba_char_args_set_fl(btheme->tima.preview_stitch_vert, 1.0, 0.522, 0.0, 0.5); @@ -1749,7 +1749,7 @@ void init_userdef_do_versions(void) if (bmain->versionfile < 262 || (bmain->versionfile == 262 && bmain->subversionfile < 2)) { bTheme *btheme; - for(btheme= U.themes.first; btheme; btheme= btheme->next) { + for (btheme= U.themes.first; btheme; btheme= btheme->next) { if (btheme->tui.wcol_menu_item.item[3] == 255) rgba_char_args_set(btheme->tui.wcol_menu_item.item, 172, 172, 172, 128); } @@ -1757,7 +1757,7 @@ void init_userdef_do_versions(void) if (bmain->versionfile < 262 || (bmain->versionfile == 262 && bmain->subversionfile < 3)) { bTheme *btheme; - for(btheme= U.themes.first; btheme; btheme= btheme->next) { + for (btheme= U.themes.first; btheme; btheme= btheme->next) { if (btheme->tui.wcol_tooltip.inner[3] == 0) { btheme->tui.wcol_tooltip = btheme->tui.wcol_menu_back; } diff --git a/source/blender/editors/interface/view2d.c b/source/blender/editors/interface/view2d.c index 8c67502978a..9072db77b6f 100644 --- a/source/blender/editors/interface/view2d.c +++ b/source/blender/editors/interface/view2d.c @@ -73,9 +73,9 @@ */ static int view2d_scroll_mapped(int scroll) { - if(scroll & V2D_SCROLL_HORIZONTAL_HIDE) + if (scroll & V2D_SCROLL_HORIZONTAL_HIDE) scroll &= ~(V2D_SCROLL_HORIZONTAL); - if(scroll & V2D_SCROLL_VERTICAL_HIDE) + if (scroll & V2D_SCROLL_VERTICAL_HIDE) scroll &= ~(V2D_SCROLL_VERTICAL); return scroll; } @@ -95,11 +95,11 @@ static void view2d_masks(View2D *v2d) v2d->scroll &= ~(V2D_SCROLL_HORIZONTAL_HIDE|V2D_SCROLL_VERTICAL_HIDE); /* check size if: */ if (v2d->scroll & V2D_SCROLL_HORIZONTAL) - if(!(v2d->scroll & V2D_SCROLL_SCALE_HORIZONTAL)) + if (!(v2d->scroll & V2D_SCROLL_SCALE_HORIZONTAL)) if (v2d->tot.xmax-v2d->tot.xmin <= v2d->cur.xmax-v2d->cur.xmin) v2d->scroll |= V2D_SCROLL_HORIZONTAL_HIDE; if (v2d->scroll & V2D_SCROLL_VERTICAL) - if(!(v2d->scroll & V2D_SCROLL_SCALE_VERTICAL)) + if (!(v2d->scroll & V2D_SCROLL_SCALE_VERTICAL)) if (v2d->tot.ymax-v2d->tot.ymin <= v2d->cur.ymax-v2d->cur.ymin) v2d->scroll |= V2D_SCROLL_VERTICAL_HIDE; #endif @@ -362,10 +362,10 @@ void UI_view2d_curRect_validate_resize(View2D *v2d, int resize) * NOTE: width and height must use FLT_MIN instead of 1, otherwise it is impossible to * get enough resolution in Graph Editor for editing some curves */ - if(width < FLT_MIN) width= 1; - if(height < FLT_MIN) height= 1; - if(winx < 1) winx= 1; - if(winy < 1) winy= 1; + if (width < FLT_MIN) width= 1; + if (height < FLT_MIN) height= 1; + if (winx < 1) winx= 1; + if (winy < 1) winy= 1; /* V2D_LIMITZOOM indicates that zoom level should be preserved when the window size changes */ if (resize && (v2d->keepzoom & V2D_KEEPZOOM)) { @@ -375,7 +375,7 @@ void UI_view2d_curRect_validate_resize(View2D *v2d, int resize) zoom= winx / width; oldzoom= v2d->oldwinx / curwidth; - if(oldzoom != zoom) + if (oldzoom != zoom) width *= zoom/oldzoom; } @@ -383,7 +383,7 @@ void UI_view2d_curRect_validate_resize(View2D *v2d, int resize) zoom= winy / height; oldzoom= v2d->oldwiny / curheight; - if(oldzoom != zoom) + if (oldzoom != zoom) height *= zoom/oldzoom; } } @@ -502,7 +502,7 @@ void UI_view2d_curRect_validate_resize(View2D *v2d, int resize) cur->xmax += width - (cur->xmax - cur->xmin); } else if (v2d->keepofs & V2D_KEEPOFS_X) { - if(v2d->align & V2D_ALIGN_NO_POS_X) + if (v2d->align & V2D_ALIGN_NO_POS_X) cur->xmin -= width - (cur->xmax - cur->xmin); else cur->xmax += width - (cur->xmax - cur->xmin); @@ -520,7 +520,7 @@ void UI_view2d_curRect_validate_resize(View2D *v2d, int resize) cur->ymax += height - (cur->ymax - cur->ymin); } else if (v2d->keepofs & V2D_KEEPOFS_Y) { - if(v2d->align & V2D_ALIGN_NO_POS_Y) + if (v2d->align & V2D_ALIGN_NO_POS_Y) cur->ymin -= height - (cur->ymax - cur->ymin); else cur->ymax += height - (cur->ymax - cur->ymin); @@ -846,9 +846,9 @@ void UI_view2d_totRect_set_resize (View2D *v2d, int width, int height, int resiz /* hrumf! */ /* XXX: there are work arounds for this in the panel and file browse code. */ - if(scroll & V2D_SCROLL_HORIZONTAL) + if (scroll & V2D_SCROLL_HORIZONTAL) width -= V2D_SCROLL_WIDTH; - if(scroll & V2D_SCROLL_VERTICAL) + if (scroll & V2D_SCROLL_VERTICAL) height -= V2D_SCROLL_HEIGHT; if (ELEM3(0, v2d, width, height)) { @@ -911,8 +911,8 @@ int UI_view2d_tab_set(View2D *v2d, int tab) int changed= 0; /* if tab changed, change offset */ - if(tab != v2d->tab_cur && v2d->tab_offset) { - if(tab < v2d->tab_num) + if (tab != v2d->tab_cur && v2d->tab_offset) { + if (tab < v2d->tab_num) offset= &v2d->tab_offset[tab*2]; else offset= default_offset; @@ -929,10 +929,10 @@ int UI_view2d_tab_set(View2D *v2d, int tab) } /* resize array if needed */ - if(tab >= v2d->tab_num) { + if (tab >= v2d->tab_num) { new_offset= MEM_callocN(sizeof(float)*(tab+1)*2, "view2d tab offset"); - if(v2d->tab_offset) { + if (v2d->tab_offset) { memcpy(new_offset, v2d->tab_offset, sizeof(float)*v2d->tab_num*2); MEM_freeN(v2d->tab_offset); } @@ -995,11 +995,11 @@ void UI_view2d_view_ortho(View2D *v2d) curmasked.ymin-= yofs; curmasked.ymax-=yofs; /* XXX ton: this flag set by outliner, for icons */ - if(v2d->flag & V2D_PIXELOFS_X) { + if (v2d->flag & V2D_PIXELOFS_X) { curmasked.xmin = floorf(curmasked.xmin) - 0.001f; curmasked.xmax = floorf(curmasked.xmax) - 0.001f; } - if(v2d->flag & V2D_PIXELOFS_Y) { + if (v2d->flag & V2D_PIXELOFS_Y) { curmasked.ymin = floorf(curmasked.ymin) - 0.001f; curmasked.ymax = floorf(curmasked.ymax) - 0.001f; } @@ -1078,7 +1078,7 @@ static void step_to_grid(float *step, int *power, int unit) if (loga < 0.0f) { if (rem < 0.2f) rem= 0.2f; - else if(rem < 0.5f) rem= 0.5f; + else if (rem < 0.5f) rem= 0.5f; else rem= 1.0f; *step= rem * (float)pow(10.0, (*power)); @@ -1094,7 +1094,7 @@ static void step_to_grid(float *step, int *power, int unit) } else { if (rem < 2.0f) rem= 2.0f; - else if(rem < 5.0f) rem= 5.0f; + else if (rem < 5.0f) rem= 5.0f; else rem= 10.0f; *step= rem * (float)pow(10.0, (*power)); @@ -1143,7 +1143,7 @@ View2DGrid *UI_view2d_grid_calc(Scene *scene, View2D *v2d, short xunits, short x space= v2d->cur.xmax - v2d->cur.xmin; pixels= (float)(v2d->mask.xmax - v2d->mask.xmin); - if(pixels!=0.0f) { + if (pixels!=0.0f) { grid->dx= (U.v2d_min_gridsize * space) / (seconddiv * pixels); step_to_grid(&grid->dx, &grid->powerx, xunits); grid->dx *= seconddiv; @@ -1307,13 +1307,13 @@ void UI_view2d_constant_grid_draw(View2D *v2d) start= v2d->cur.xmin - (float)fmod(v2d->cur.xmin, step); glBegin(GL_LINES); - for(; startcur.xmax; start+=step) { + for (; startcur.xmax; start+=step) { glVertex2f(start, v2d->cur.ymin); glVertex2f(start, v2d->cur.ymax); } start= v2d->cur.ymin - (float)fmod(v2d->cur.ymin, step); - for(; startcur.ymax; start+=step) { + for (; startcur.ymax; start+=step) { glVertex2f(v2d->cur.xmin, start); glVertex2f(v2d->cur.xmax, start); } @@ -1411,16 +1411,16 @@ View2DScrollers *UI_view2d_scrollers_calc(const bContext *C, View2D *v2d, short /* scroller 'button' extents */ totsize= v2d->tot.xmax - v2d->tot.xmin; scrollsize= (float)(hor.xmax - hor.xmin); - if(totsize==0.0f) totsize = 1.0f; /* avoid divide by zero */ + if (totsize==0.0f) totsize = 1.0f; /* avoid divide by zero */ fac1= (v2d->cur.xmin - v2d->tot.xmin) / totsize; - if(fac1<=0.0f) + if (fac1<=0.0f) scrollers->hor_min= hor.xmin; else scrollers->hor_min= (int)(hor.xmin + (fac1 * scrollsize)); fac2= (v2d->cur.xmax - v2d->tot.xmin) / totsize; - if(fac2>=1.0f) + if (fac2>=1.0f) scrollers->hor_max= hor.xmax; else scrollers->hor_max= (int)(hor.xmin + (fac2 * scrollsize)); @@ -1437,7 +1437,7 @@ View2DScrollers *UI_view2d_scrollers_calc(const bContext *C, View2D *v2d, short } /* check whether sliders can disappear due to the full-range being used */ - if(v2d->keeptot) { + if (v2d->keeptot) { if ((fac1 <= 0.0f) && (fac2 >= 1.0f)) { v2d->scroll |= V2D_SCROLL_HORIZONTAL_FULLR; scrollers->horfull= 1; @@ -1452,16 +1452,16 @@ View2DScrollers *UI_view2d_scrollers_calc(const bContext *C, View2D *v2d, short /* scroller 'button' extents */ totsize= v2d->tot.ymax - v2d->tot.ymin; scrollsize= (float)(vert.ymax - vert.ymin); - if(totsize==0.0f) totsize = 1.0f; /* avoid divide by zero */ + if (totsize==0.0f) totsize = 1.0f; /* avoid divide by zero */ fac1= (v2d->cur.ymin- v2d->tot.ymin) / totsize; - if(fac1<=0.0f) + if (fac1<=0.0f) scrollers->vert_min= vert.ymin; else scrollers->vert_min= (int)(vert.ymin + (fac1 * scrollsize)); fac2= (v2d->cur.ymax - v2d->tot.ymin) / totsize; - if(fac2>=1.0f) + if (fac2>=1.0f) scrollers->vert_max= vert.ymax; else scrollers->vert_max= (int)(vert.ymin + (fac2 * scrollsize)); @@ -1479,7 +1479,7 @@ View2DScrollers *UI_view2d_scrollers_calc(const bContext *C, View2D *v2d, short } /* check whether sliders can disappear due to the full-range being used */ - if(v2d->keeptot) { + if (v2d->keeptot) { if ((fac1 <= 0.0f) && (fac2 >= 1.0f)) { v2d->scroll |= V2D_SCROLL_VERTICAL_FULLR; scrollers->vertfull= 1; @@ -1559,7 +1559,7 @@ void UI_view2d_scrollers_draw(const bContext *C, View2D *v2d, View2DScrollers *v /* horizontal scrollbar */ if (scroll & V2D_SCROLL_HORIZONTAL) { /* only draw scrollbar when it doesn't fill the entire space */ - if(vs->horfull==0) { + if (vs->horfull==0) { bTheme *btheme= UI_GetTheme(); uiWidgetColors wcol= btheme->tui.wcol_scroll; rcti slider; @@ -1628,7 +1628,7 @@ void UI_view2d_scrollers_draw(const bContext *C, View2D *v2d, View2DScrollers *v for (; fac < hor.xmax-10; fac+=dfac, val+=grid->dx) { /* make prints look nicer for scrollers */ - if(fac < hor.xmin+10) + if (fac < hor.xmin+10) continue; switch (vs->xunits) { @@ -1670,7 +1670,7 @@ void UI_view2d_scrollers_draw(const bContext *C, View2D *v2d, View2DScrollers *v /* vertical scrollbar */ if (scroll & V2D_SCROLL_VERTICAL) { /* only draw scrollbar when it doesn't fill the entire space */ - if(vs->vertfull==0) { + if (vs->vertfull==0) { bTheme *btheme= UI_GetTheme(); uiWidgetColors wcol= btheme->tui.wcol_scroll; rcti slider; @@ -1738,7 +1738,7 @@ void UI_view2d_scrollers_draw(const bContext *C, View2D *v2d, View2DScrollers *v for (; fac < vert.ymax-10; fac+= dfac, val += grid->dy) { /* make prints look nicer for scrollers */ - if(fac < vert.ymin+10) + if (fac < vert.ymin+10) continue; scroll_printstr(scene, (float)(vert.xmax)-2.0f, fac, val, grid->powery, vs->yunits, 'v'); @@ -1935,12 +1935,12 @@ void UI_view2d_to_region_no_clip(View2D *v2d, float x, float y, int *regionx, in /* although we don't clamp to lie within region bounds, we must avoid exceeding size of ints */ if (regionx) { if (x < INT_MIN) *regionx= INT_MIN; - else if(x > INT_MAX) *regionx= INT_MAX; + else if (x > INT_MAX) *regionx= INT_MAX; else *regionx= (int)x; } if (regiony) { if (y < INT_MIN) *regiony= INT_MIN; - else if(y > INT_MAX) *regiony= INT_MAX; + else if (y > INT_MAX) *regiony= INT_MAX; else *regiony= (int)y; } } @@ -2039,7 +2039,7 @@ void UI_view2d_text_cache_add(View2D *v2d, float x, float y, const char *str, co UI_view2d_view_to_region(v2d, x, y, mval, mval+1); - if(mval[0]!=V2D_IS_CLIPPED && mval[1]!=V2D_IS_CLIPPED) { + if (mval[0]!=V2D_IS_CLIPPED && mval[1]!=V2D_IS_CLIPPED) { int len= strlen(str)+1; /* use calloc, rect has to be zeroe'd */ View2DString *v2s= MEM_callocN(sizeof(View2DString)+len, "View2DString"); @@ -2083,19 +2083,19 @@ void UI_view2d_text_cache_draw(ARegion *ar) // glPushMatrix(); ED_region_pixelspace(ar); - for(v2s= strings.first; v2s; v2s= v2s->next) { + for (v2s= strings.first; v2s; v2s= v2s->next) { const char *str= (const char *)(v2s+1); int xofs=0, yofs; yofs= ceil( 0.5f*(v2s->rect.ymax - v2s->rect.ymin - BLF_height_default("28"))); - if(yofs<1) yofs= 1; + if (yofs<1) yofs= 1; - if(col_pack_prev != v2s->col.pack) { + if (col_pack_prev != v2s->col.pack) { glColor3ubv(v2s->col.ub); col_pack_prev= v2s->col.pack; } - if(v2s->rect.xmin >= v2s->rect.xmax) + if (v2s->rect.xmin >= v2s->rect.xmax) BLF_draw_default((float)v2s->mval[0]+xofs, (float)v2s->mval[1]+yofs, 0.0, str, BLF_DRAW_STR_DUMMY_MAX); else { BLF_clipping_default(v2s->rect.xmin-4, v2s->rect.ymin-4, v2s->rect.xmax+4, v2s->rect.ymax+4); @@ -2110,7 +2110,7 @@ void UI_view2d_text_cache_draw(ARegion *ar) // glMatrixMode(GL_MODELVIEW); // glPopMatrix(); - if(strings.first) + if (strings.first) BLI_freelistN(&strings); } diff --git a/source/blender/editors/interface/view2d_ops.c b/source/blender/editors/interface/view2d_ops.c index 29850c91480..c729e944c62 100644 --- a/source/blender/editors/interface/view2d_ops.c +++ b/source/blender/editors/interface/view2d_ops.c @@ -418,7 +418,7 @@ static int view_scrolldown_exec(bContext *C, wmOperator *op) RNA_int_set(op->ptr, "deltax", 0); RNA_int_set(op->ptr, "deltay", -40); - if(RNA_boolean_get(op->ptr, "page")) { + if (RNA_boolean_get(op->ptr, "page")) { ARegion *ar= CTX_wm_region(C); RNA_int_set(op->ptr, "deltay", ar->v2d.mask.ymin - ar->v2d.mask.ymax); } @@ -468,7 +468,7 @@ static int view_scrollup_exec(bContext *C, wmOperator *op) RNA_int_set(op->ptr, "deltax", 0); RNA_int_set(op->ptr, "deltay", 40); - if(RNA_boolean_get(op->ptr, "page")) { + if (RNA_boolean_get(op->ptr, "page")) { ARegion *ar= CTX_wm_region(C); RNA_int_set(op->ptr, "deltay", ar->v2d.mask.ymax - ar->v2d.mask.ymin); } @@ -753,7 +753,7 @@ static int view_zoomout_invoke(bContext *C, wmOperator *op, wmEvent *event) vzd= op->customdata; - if(U.uiflag & USER_ZOOM_TO_MOUSEPOS) { + if (U.uiflag & USER_ZOOM_TO_MOUSEPOS) { ARegion *ar= CTX_wm_region(C); /* store initial mouse position (in view space) */ @@ -867,7 +867,7 @@ static void view_zoomdrag_exit(bContext *C, wmOperator *op) if (op->customdata) { v2dViewZoomData *vzd= op->customdata; - if(vzd->timer) + if (vzd->timer) WM_event_remove_timer(CTX_wm_manager(C), CTX_wm_window(C), vzd->timer); MEM_freeN(op->customdata); @@ -975,7 +975,7 @@ static int view_zoomdrag_modal(bContext *C, wmOperator *op, wmEvent *event) if (event->type == TIMER && event->customdata == vzd->timer) { view_zoomdrag_apply(C, op); } - else if(event->type == MOUSEMOVE) { + else if (event->type == MOUSEMOVE) { float dx, dy; /* calculate new delta transform, based on zooming mode */ diff --git a/source/blender/editors/mesh/editface.c b/source/blender/editors/mesh/editface.c index a7f72481456..efa5ce0395c 100644 --- a/source/blender/editors/mesh/editface.c +++ b/source/blender/editors/mesh/editface.c @@ -77,7 +77,7 @@ void paintface_flush_flags(Object *ob) int totface, totpoly; int i; - if(me==NULL || dm==NULL) + if (me==NULL || dm==NULL) return; /* @@ -169,20 +169,20 @@ void paintface_hide(Object *ob, const int unselected) int a; me= get_mesh(ob); - if(me==NULL || me->totpoly==0) return; + if (me==NULL || me->totpoly==0) return; mface= me->mpoly; a= me->totpoly; - while(a--) { - if((mface->flag & ME_HIDE) == 0) { - if(unselected) { - if( (mface->flag & ME_FACE_SEL)==0) mface->flag |= ME_HIDE; + while (a--) { + if ((mface->flag & ME_HIDE) == 0) { + if (unselected) { + if ( (mface->flag & ME_FACE_SEL)==0) mface->flag |= ME_HIDE; } else { - if( (mface->flag & ME_FACE_SEL)) mface->flag |= ME_HIDE; + if ( (mface->flag & ME_FACE_SEL)) mface->flag |= ME_HIDE; } } - if(mface->flag & ME_HIDE) mface->flag &= ~ME_FACE_SEL; + if (mface->flag & ME_HIDE) mface->flag &= ~ME_FACE_SEL; mface++; } @@ -198,12 +198,12 @@ void paintface_reveal(Object *ob) int a; me= get_mesh(ob); - if(me==NULL || me->totpoly==0) return; + if (me==NULL || me->totpoly==0) return; mface= me->mpoly; a= me->totpoly; - while(a--) { - if(mface->flag & ME_HIDE) { + while (a--) { + if (mface->flag & ME_HIDE) { mface->flag |= ME_FACE_SEL; mface->flag -= ME_HIDE; } @@ -239,8 +239,8 @@ static void select_linked_tfaces_with_seams(int mode, Mesh *me, unsigned int ind seamhash = BLI_edgehash_new(); linkflag= MEM_callocN(sizeof(char)*me->totpoly, "linkflaguv"); - for(med=me->medge, a=0; a < me->totedge; a++, med++) - if(med->flag & ME_SEAM) + for (med=me->medge, a=0; a < me->totedge; a++, med++) + if (med->flag & ME_SEAM) BLI_edgehash_insert(seamhash, med->v1, med->v2, NULL); if (mode==0 || mode==1) { @@ -252,25 +252,25 @@ static void select_linked_tfaces_with_seams(int mode, Mesh *me, unsigned int ind else { /* fill array by selection */ mf= me->mpoly; - for(a=0; atotpoly; a++, mf++) { - if(mf->flag & ME_HIDE); - else if(mf->flag & ME_FACE_SEL) { + for (a=0; atotpoly; a++, mf++) { + if (mf->flag & ME_HIDE); + else if (mf->flag & ME_FACE_SEL) { hash_add_face(ehash, mf, me->mloop + mf->loopstart); linkflag[a]= 1; } } } - while(doit) { + while (doit) { doit= 0; /* expand selection */ mf= me->mpoly; - for(a=0; atotpoly; a++, mf++) { - if(mf->flag & ME_HIDE) + for (a=0; atotpoly; a++, mf++) { + if (mf->flag & ME_HIDE) continue; - if(!linkflag[a]) { + if (!linkflag[a]) { MLoop *mnextl; mark= 0; @@ -282,7 +282,7 @@ static void select_linked_tfaces_with_seams(int mode, Mesh *me, unsigned int ind mark = 1; } - if(mark) { + if (mark) { linkflag[a]= 1; hash_add_face(ehash, mf, me->mloop + mf->loopstart); doit= 1; @@ -295,26 +295,26 @@ static void select_linked_tfaces_with_seams(int mode, Mesh *me, unsigned int ind BLI_edgehash_free(ehash, NULL); BLI_edgehash_free(seamhash, NULL); - if(mode==0 || mode==2) { - for(a=0, mf=me->mpoly; atotpoly; a++, mf++) - if(linkflag[a]) + if (mode==0 || mode==2) { + for (a=0, mf=me->mpoly; atotpoly; a++, mf++) + if (linkflag[a]) mf->flag |= ME_FACE_SEL; else mf->flag &= ~ME_FACE_SEL; } - else if(mode==1) { - for(a=0, mf=me->mpoly; atotpoly; a++, mf++) - if(linkflag[a] && (mf->flag & ME_FACE_SEL)) + else if (mode==1) { + for (a=0, mf=me->mpoly; atotpoly; a++, mf++) + if (linkflag[a] && (mf->flag & ME_FACE_SEL)) break; if (atotpoly) { - for(a=0, mf=me->mpoly; atotpoly; a++, mf++) - if(linkflag[a]) + for (a=0, mf=me->mpoly; atotpoly; a++, mf++) + if (linkflag[a]) mf->flag &= ~ME_FACE_SEL; } else { - for(a=0, mf=me->mpoly; atotpoly; a++, mf++) - if(linkflag[a]) + for (a=0, mf=me->mpoly; atotpoly; a++, mf++) + if (linkflag[a]) mf->flag |= ME_FACE_SEL; } } @@ -328,7 +328,7 @@ void paintface_select_linked(bContext *UNUSED(C), Object *ob, int UNUSED(mval[2] unsigned int index=0; me = get_mesh(ob); - if(me==NULL || me->totpoly==0) return; + if (me==NULL || me->totpoly==0) return; if (mode==0 || mode==1) { // XXX - Causes glitches, not sure why @@ -350,13 +350,13 @@ void paintface_deselect_all_visible(Object *ob, int action, short flush_flags) int a; me= get_mesh(ob); - if(me==NULL) return; + if (me==NULL) return; - if(action == SEL_INVERT) { + if (action == SEL_INVERT) { mface= me->mpoly; a= me->totpoly; - while(a--) { - if((mface->flag & ME_HIDE) == 0) { + while (a--) { + if ((mface->flag & ME_HIDE) == 0) { mface->flag ^= ME_FACE_SEL; } mface++; @@ -368,8 +368,8 @@ void paintface_deselect_all_visible(Object *ob, int action, short flush_flags) mface= me->mpoly; a= me->totpoly; - while(a--) { - if((mface->flag & ME_HIDE) == 0 && mface->flag & ME_FACE_SEL) { + while (a--) { + if ((mface->flag & ME_HIDE) == 0 && mface->flag & ME_FACE_SEL) { action = SEL_DESELECT; break; } @@ -379,8 +379,8 @@ void paintface_deselect_all_visible(Object *ob, int action, short flush_flags) mface= me->mpoly; a= me->totpoly; - while(a--) { - if((mface->flag & ME_HIDE) == 0) { + while (a--) { + if ((mface->flag & ME_HIDE) == 0) { switch (action) { case SEL_SELECT: mface->flag |= ME_FACE_SEL; @@ -397,7 +397,7 @@ void paintface_deselect_all_visible(Object *ob, int action, short flush_flags) } } - if(flush_flags) { + if (flush_flags) { paintface_flush_flags(ob); } } @@ -413,7 +413,7 @@ int paintface_minmax(Object *ob, float *min, float *max) float vec[3], bmat[3][3]; me= get_mesh(ob); - if(!me || !me->mtpoly) return ok; + if (!me || !me->mtpoly) return ok; copy_m3_m4(bmat, ob->obmat); @@ -462,7 +462,7 @@ void seam_mark_clear_tface(Scene *scene, short mode) int a, b; me= get_mesh(OBACT); - if(me==0 || me->totpoly==0) return; + if (me==0 || me->totpoly==0) return; if (mode == 0) mode = pupmenu("Seams%t|Mark Border Seam %x1|Clear Seam %x2"); @@ -571,7 +571,7 @@ int do_paintface_box_select(ViewContext *vc, rcti *rect, int select, int extend) me= get_mesh(ob); - if(me==NULL || me->totpoly==0 || sx*sy <= 0) + if (me==NULL || me->totpoly==0 || sx*sy <= 0) return OPERATOR_CANCELLED; selar= MEM_callocN(me->totpoly+1, "selar"); @@ -580,8 +580,8 @@ int do_paintface_box_select(ViewContext *vc, rcti *rect, int select, int extend) paintface_deselect_all_visible(vc->obact, SEL_DESELECT, FALSE); mface= me->mpoly; - for(a=1; a<=me->totpoly; a++, mface++) { - if((mface->flag & ME_HIDE) == 0) + for (a=1; a<=me->totpoly; a++, mface++) { + if ((mface->flag & ME_HIDE) == 0) mface->flag &= ~ME_FACE_SEL; } } @@ -591,23 +591,23 @@ int do_paintface_box_select(ViewContext *vc, rcti *rect, int select, int extend) ibuf = IMB_allocImBuf(sx,sy,32,IB_rect); rt = ibuf->rect; glReadPixels(rect->xmin+vc->ar->winrct.xmin, rect->ymin+vc->ar->winrct.ymin, sx, sy, GL_RGBA, GL_UNSIGNED_BYTE, ibuf->rect); - if(ENDIAN_ORDER==B_ENDIAN) IMB_convert_rgba_to_abgr(ibuf); + if (ENDIAN_ORDER==B_ENDIAN) IMB_convert_rgba_to_abgr(ibuf); a= sx*sy; - while(a--) { - if(*rt) { + while (a--) { + if (*rt) { index= WM_framebuffer_to_index(*rt); - if(index<=me->totpoly) selar[index]= 1; + if (index<=me->totpoly) selar[index]= 1; } rt++; } mface= me->mpoly; - for(a=1; a<=me->totpoly; a++, mface++) { - if(selar[a]) { - if(mface->flag & ME_HIDE); + for (a=1; a<=me->totpoly; a++, mface++) { + if (selar[a]) { + if (mface->flag & ME_HIDE); else { - if(select) mface->flag |= ME_FACE_SEL; + if (select) mface->flag |= ME_FACE_SEL; else mface->flag &= ~ME_FACE_SEL; } } @@ -638,7 +638,7 @@ void paintvert_flush_flags(Object *ob) int totvert; int i; - if(me==NULL || dm==NULL) + if (me==NULL || dm==NULL) return; index_array = dm->getVertDataArray(dm, CD_ORIGINDEX); @@ -648,11 +648,11 @@ void paintvert_flush_flags(Object *ob) dm_mv= dm_mvert; - if(index_array) { + if (index_array) { int orig_index; for (i= 0; iflag= me->mvert[index_array[i]].flag; } } @@ -671,13 +671,13 @@ void paintvert_deselect_all_visible(Object *ob, int action, short flush_flags) int a; me= get_mesh(ob); - if(me==NULL) return; + if (me==NULL) return; - if(action == SEL_INVERT) { + if (action == SEL_INVERT) { mvert= me->mvert; a= me->totvert; - while(a--) { - if((mvert->flag & ME_HIDE) == 0) { + while (a--) { + if ((mvert->flag & ME_HIDE) == 0) { mvert->flag ^= SELECT; } mvert++; @@ -689,8 +689,8 @@ void paintvert_deselect_all_visible(Object *ob, int action, short flush_flags) mvert= me->mvert; a= me->totvert; - while(a--) { - if((mvert->flag & ME_HIDE) == 0 && mvert->flag & SELECT) { + while (a--) { + if ((mvert->flag & ME_HIDE) == 0 && mvert->flag & SELECT) { action = SEL_DESELECT; break; } @@ -700,8 +700,8 @@ void paintvert_deselect_all_visible(Object *ob, int action, short flush_flags) mvert= me->mvert; a= me->totvert; - while(a--) { - if((mvert->flag & ME_HIDE) == 0) { + while (a--) { + if ((mvert->flag & ME_HIDE) == 0) { switch (action) { case SEL_SELECT: mvert->flag |= SELECT; @@ -718,7 +718,7 @@ void paintvert_deselect_all_visible(Object *ob, int action, short flush_flags) } } - if(flush_flags) { + if (flush_flags) { paintvert_flush_flags(ob); } } @@ -763,7 +763,7 @@ int ED_mesh_mirrtopo_recalc_check(Mesh *me, const int ob_mode, MirrTopoStore_t * totedge = me->totedge; } - if( (mesh_topo_store->index_lookup==NULL) || + if ( (mesh_topo_store->index_lookup==NULL) || (mesh_topo_store->prev_ob_mode != ob_mode) || (totvert != mesh_topo_store->prev_vert_tot) || (totedge != mesh_topo_store->prev_edge_tot)) @@ -801,7 +801,7 @@ void ED_mesh_mirrtopo_init(Mesh *me, const int ob_mode, MirrTopoStore_t *mesh_to mesh_topo_store->prev_ob_mode = ob_mode; - if(em) { + if (em) { BM_mesh_elem_index_ensure(em->bm, BM_VERT); totvert = em->bm->totvert; @@ -813,7 +813,7 @@ void ED_mesh_mirrtopo_init(Mesh *me, const int ob_mode, MirrTopoStore_t *mesh_to topo_hash = MEM_callocN(totvert * sizeof(MirrTopoHash_t), "TopoMirr"); /* Initialize the vert-edge-user counts used to detect unique topology */ - if(em) { + if (em) { totedge = me->edit_btmesh->bm->totedge; BM_ITER(eed, &iter, em->bm, BM_EDGES_OF_MESH, NULL) { @@ -824,7 +824,7 @@ void ED_mesh_mirrtopo_init(Mesh *me, const int ob_mode, MirrTopoStore_t *mesh_to else { totedge = me->totedge; - for(a=0, medge=me->medge; a < me->totedge; a++, medge++) { + for (a=0, medge=me->medge; a < me->totedge; a++, medge++) { topo_hash[medge->v1]++; topo_hash[medge->v2]++; } @@ -833,17 +833,17 @@ void ED_mesh_mirrtopo_init(Mesh *me, const int ob_mode, MirrTopoStore_t *mesh_to topo_hash_prev = MEM_dupallocN(topo_hash); tot_unique_prev = -1; - while(1) { + while (1) { /* use the number of edges per vert to give verts unique topology IDs */ - if(em) { + if (em) { BM_ITER(eed, &iter, em->bm, BM_EDGES_OF_MESH, NULL) { topo_hash[BM_elem_index_get(eed->v1)] += topo_hash_prev[BM_elem_index_get(eed->v2)]; topo_hash[BM_elem_index_get(eed->v2)] += topo_hash_prev[BM_elem_index_get(eed->v1)]; } } else { - for(a=0, medge=me->medge; atotedge; a++, medge++) { + for (a=0, medge=me->medge; atotedge; a++, medge++) { /* This can make really big numbers, wrapping around here is fine */ topo_hash[medge->v1] += topo_hash_prev[medge->v2]; topo_hash[medge->v2] += topo_hash_prev[medge->v1]; @@ -855,7 +855,7 @@ void ED_mesh_mirrtopo_init(Mesh *me, const int ob_mode, MirrTopoStore_t *mesh_to qsort(topo_hash_prev, totvert, sizeof(MirrTopoHash_t), mirrtopo_hash_sort); tot_unique = 1; /* account for skiping the first value */ - for(a=1; aid, OB_RECALC_DATA); + else { + DAG_id_tag_update(&obedit->id, OB_RECALC_DATA); + } *dia *= new_primitive_matrix(C, loc, rot, mat); } diff --git a/source/blender/editors/mesh/editmesh_bvh.c b/source/blender/editors/mesh/editmesh_bvh.c index 3716949cb46..6571af11af5 100644 --- a/source/blender/editors/mesh/editmesh_bvh.c +++ b/source/blender/editors/mesh/editmesh_bvh.c @@ -229,7 +229,8 @@ BMFace *BMBVH_RayCast(BMBVHTree *tree, float *co, float *dir, float *hitout, flo ((v3->co[i] - v1->co[i]) * tree->uv[1]); } copy_v3_v3(hitout, co); - } else { + } + else { copy_v3_v3(hitout, hit.co); } diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c index 3448ac608e1..d26d6f2cbfe 100644 --- a/source/blender/editors/mesh/editmesh_tools.c +++ b/source/blender/editors/mesh/editmesh_tools.c @@ -3767,11 +3767,14 @@ static int edbm_select_by_number_vertices_exec(bContext *C, wmOperator *op) if (type == 0 && efa->len < numverts) { select = 1; - }else if (type == 1 && efa->len == numverts) { + } + else if (type == 1 && efa->len == numverts) { select = 1; - }else if (type == 2 && efa->len > numverts) { + } + else if (type == 2 && efa->len > numverts) { select = 1; - }else if (type == 3 && efa->len != numverts) { + } + else if (type == 3 && efa->len != numverts) { select = 1; } diff --git a/source/blender/editors/mesh/mesh_data.c b/source/blender/editors/mesh/mesh_data.c index 10fdd31db3e..a8836b466a8 100644 --- a/source/blender/editors/mesh/mesh_data.c +++ b/source/blender/editors/mesh/mesh_data.c @@ -87,7 +87,8 @@ static void delete_customdata_layer(bContext *C, Object *ob, CustomDataLayer *la if (layer->type == CD_MLOOPCOL || layer->type == CD_MLOOPUV) { data = (me->edit_btmesh)? &me->edit_btmesh->bm->ldata: &me->ldata; tot = me->totloop; - } else { + } + else { data = (me->edit_btmesh)? &me->edit_btmesh->bm->pdata: &me->pdata; tot = me->totpoly; } @@ -107,7 +108,7 @@ static void delete_customdata_layer(bContext *C, Object *ob, CustomDataLayer *la stencillayerdata = data->layers[CustomData_get_stencil_layer_index(data, type)].data; CustomData_set_layer_active(data, type, layer - &data->layers[index]); - if(me->edit_btmesh) { + if (me->edit_btmesh) { BM_data_layer_free(me->edit_btmesh->bm, data, type); } else { @@ -115,7 +116,7 @@ static void delete_customdata_layer(bContext *C, Object *ob, CustomDataLayer *la mesh_update_customdata_pointers(me, TRUE); } - if(!CustomData_has_layer(data, type) && (type == CD_MLOOPCOL && (ob->mode & OB_MODE_VERTEX_PAINT))) + if (!CustomData_has_layer(data, type) && (type == CD_MLOOPCOL && (ob->mode & OB_MODE_VERTEX_PAINT))) ED_object_toggle_modes(C, OB_MODE_VERTEX_PAINT); /* reconstruct active layer */ @@ -186,7 +187,7 @@ static void copy_editface_active_customdata(BMEditMesh *em, int type, int index) EditFace *efa; int n= CustomData_get_active_layer(&em->fdata, type); - for(efa= em->faces.first; efa; efa= efa->next) { + for (efa= em->faces.first; efa; efa= efa->next) { void *data= CustomData_em_get_n(&em->fdata, efa->data, type, n); CustomData_em_set_n(&em->fdata, efa->data, type, index, data); } @@ -259,7 +260,8 @@ int ED_mesh_uv_loop_reset(struct bContext *C, struct Mesh *me) fuvs[2][0] = 1.0; fuvs[2][1] = 1.0; - } else if (len == 4) { + } + else if (len == 4) { fuvs[0][0] = 0.0; fuvs[0][1] = 0.0; @@ -272,7 +274,8 @@ int ED_mesh_uv_loop_reset(struct bContext *C, struct Mesh *me) fuvs[3][0] = 0.0; fuvs[3][1] = 1.0; /*make sure we ignore 2-sided faces*/ - } else if (len > 2) { + } + else if (len > 2) { float fac = 0.0f, dfac = 1.0f / (float)len; dfac *= M_PI*2; @@ -327,7 +330,7 @@ int ED_mesh_uv_texture_add(bContext *C, Mesh *me, const char *name, int active_s CustomData_set_layer_name(&em->bm->ldata, CD_MLOOPUV, layernum, name); CustomData_set_layer_active(&em->bm->ldata, CD_MLOOPUV, layernum); - if(active_set || layernum == 0) { + if (active_set || layernum == 0) { CustomData_set_layer_active(&em->bm->ldata, CD_MLOOPUV, layernum); } } @@ -340,7 +343,8 @@ int ED_mesh_uv_texture_add(bContext *C, Mesh *me, const char *name, int active_s CustomData_add_layer_named(&me->pdata, CD_MTEXPOLY, CD_DUPLICATE, me->mtpoly, me->totpoly, name); CustomData_add_layer_named(&me->ldata, CD_MLOOPUV, CD_DUPLICATE, me->mloopuv, me->totloop, name); CustomData_add_layer_named(&me->fdata, CD_MTFACE, CD_DUPLICATE, me->mtface, me->totface, name); - } else { + } + else { CustomData_add_layer_named(&me->pdata, CD_MTEXPOLY, CD_DEFAULT, NULL, me->totpoly, name); CustomData_add_layer_named(&me->ldata, CD_MLOOPUV, CD_DEFAULT, NULL, me->totloop, name); CustomData_add_layer_named(&me->fdata, CD_MTFACE, CD_DEFAULT, NULL, me->totface, name); @@ -419,7 +423,7 @@ int ED_mesh_color_add(bContext *C, Scene *UNUSED(scene), Object *UNUSED(ob), Mes return -1; } - if(me->mloopcol) { + if (me->mloopcol) { CustomData_add_layer_named(&me->ldata, CD_MLOOPCOL, CD_DUPLICATE, me->mloopcol, me->totloop, name); CustomData_add_layer_named(&me->fdata, CD_MCOL, CD_DUPLICATE, me->mcol, me->totface, name); } @@ -428,7 +432,7 @@ int ED_mesh_color_add(bContext *C, Scene *UNUSED(scene), Object *UNUSED(ob), Mes CustomData_add_layer_named(&me->fdata, CD_MCOL, CD_DEFAULT, NULL, me->totface, name); } - if(active_set || layernum==0) { + if (active_set || layernum==0) { CustomData_set_layer_active(&me->ldata, CD_MLOOPCOL, layernum); CustomData_set_layer_active(&me->fdata, CD_MCOL, layernum); } @@ -450,7 +454,7 @@ int ED_mesh_color_remove(bContext *C, Object *ob, Mesh *me) index= CustomData_get_active_layer_index(&me->ldata, CD_MLOOPCOL); cdl= (index == -1)? NULL: &me->ldata.layers[index]; - if(!cdl) + if (!cdl) return 0; delete_customdata_layer(C, ob, cdl); @@ -468,7 +472,7 @@ int ED_mesh_color_remove_named(bContext *C, Object *ob, Mesh *me, const char *na index= CustomData_get_named_layer_index(&me->ldata, CD_MLOOPCOL, name); cdl= (index == -1)? NULL: &me->ldata.layers[index]; - if(!cdl) + if (!cdl) return 0; delete_customdata_layer(C, ob, cdl); @@ -492,7 +496,7 @@ static int mesh_uv_texture_add_exec(bContext *C, wmOperator *UNUSED(op)) Object *ob= ED_object_context(C); Mesh *me= ob->data; - if(ED_mesh_uv_texture_add(C, me, NULL, TRUE) == -1) + if (ED_mesh_uv_texture_add(C, me, NULL, TRUE) == -1) return OPERATOR_CANCELLED; return OPERATOR_FINISHED; @@ -526,13 +530,13 @@ static int drop_named_image_invoke(bContext *C, wmOperator *op, wmEvent *event) char name[MAX_ID_NAME-2]; /* Check context */ - if(base==NULL || base->object->type!=OB_MESH) { + if (base==NULL || base->object->type!=OB_MESH) { BKE_report(op->reports, RPT_ERROR, "Not an Object or Mesh"); return OPERATOR_CANCELLED; } /* check input variables */ - if(RNA_struct_property_is_set(op->ptr, "filepath")) { + if (RNA_struct_property_is_set(op->ptr, "filepath")) { char path[FILE_MAX]; RNA_string_get(op->ptr, "filepath", path); @@ -543,7 +547,7 @@ static int drop_named_image_invoke(bContext *C, wmOperator *op, wmEvent *event) ima= (Image *)find_id("IM", name); } - if(!ima) { + if (!ima) { BKE_report(op->reports, RPT_ERROR, "Not an Image"); return OPERATOR_CANCELLED; } @@ -552,16 +556,16 @@ static int drop_named_image_invoke(bContext *C, wmOperator *op, wmEvent *event) obedit= base->object; me= obedit->data; - if(me->edit_btmesh==NULL) { + if (me->edit_btmesh==NULL) { EDBM_MakeEditBMesh(scene->toolsettings, scene, obedit); exitmode= 1; } - if(me->edit_btmesh==NULL) + if (me->edit_btmesh==NULL) return OPERATOR_CANCELLED; ED_uvedit_assign_image(bmain, scene, obedit, ima, NULL); - if(exitmode) { + if (exitmode) { EDBM_LoadEditBMesh(scene, obedit); EDBM_FreeEditBMesh(me->edit_btmesh); MEM_freeN(me->edit_btmesh); @@ -573,7 +577,7 @@ static int drop_named_image_invoke(bContext *C, wmOperator *op, wmEvent *event) } /* dummie drop support; ensure view shows a result :) */ - if(v3d) + if (v3d) v3d->flag2 |= V3D_SOLID_TEX; WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data); @@ -605,7 +609,7 @@ static int mesh_uv_texture_remove_exec(bContext *C, wmOperator *UNUSED(op)) Object *ob= ED_object_context(C); Mesh *me= ob->data; - if(!ED_mesh_uv_texture_remove(C, ob, me)) + if (!ED_mesh_uv_texture_remove(C, ob, me)) return OPERATOR_CANCELLED; return OPERATOR_FINISHED; @@ -634,7 +638,7 @@ static int mesh_vertex_color_add_exec(bContext *C, wmOperator *UNUSED(op)) Object *ob= ED_object_context(C); Mesh *me= ob->data; - if(ED_mesh_color_add(C, scene, ob, me, NULL, TRUE) == -1) + if (ED_mesh_color_add(C, scene, ob, me, NULL, TRUE) == -1) return OPERATOR_CANCELLED; return OPERATOR_FINISHED; @@ -660,7 +664,7 @@ static int mesh_vertex_color_remove_exec(bContext *C, wmOperator *UNUSED(op)) Object *ob= ED_object_context(C); Mesh *me= ob->data; - if(!ED_mesh_color_remove(C, ob, me)) + if (!ED_mesh_color_remove(C, ob, me)) return OPERATOR_CANCELLED; return OPERATOR_FINISHED; @@ -692,7 +696,7 @@ static int mesh_sticky_add_exec(bContext *C, wmOperator *UNUSED(op)) /* why is this commented out? */ #if 0 - if(me->msticky) + if (me->msticky) return OPERATOR_CANCELLED; #endif @@ -724,7 +728,7 @@ static int mesh_sticky_remove_exec(bContext *C, wmOperator *UNUSED(op)) Object *ob= ED_object_context(C); Mesh *me= ob->data; - if(!me->msticky) + if (!me->msticky) return OPERATOR_CANCELLED; CustomData_free_layer_active(&me->vdata, CD_MSTICKY, me->totvert); @@ -759,7 +763,7 @@ void ED_mesh_update(Mesh *mesh, bContext *C, int calc_edges, int calc_tessface) float (*face_nors)[3]; int tessface_input = FALSE; - if(mesh->totface > 0 && mesh->totpoly == 0) { + if (mesh->totface > 0 && mesh->totpoly == 0) { convert_mfaces_to_mpolys(mesh); /* would only be converting back again, don't bother */ @@ -769,7 +773,7 @@ void ED_mesh_update(Mesh *mesh, bContext *C, int calc_edges, int calc_tessface) calc_edges = FALSE; } - if(calc_edges || (mesh->totpoly && mesh->totedge == 0)) + if (calc_edges || (mesh->totpoly && mesh->totedge == 0)) BKE_mesh_calc_edges(mesh, calc_edges); if (calc_tessface) { @@ -815,14 +819,14 @@ static void mesh_add_verts(Mesh *mesh, int len) MVert *mvert; int i, totvert; - if(len == 0) + if (len == 0) return; totvert= mesh->totvert + len; CustomData_copy(&mesh->vdata, &vdata, CD_MASK_MESH, CD_DEFAULT, totvert); CustomData_copy_data(&mesh->vdata, &vdata, 0, 0, mesh->totvert); - if(!CustomData_has_layer(&vdata, CD_MVERT)) + if (!CustomData_has_layer(&vdata, CD_MVERT)) CustomData_add_layer(&vdata, CD_MVERT, CD_CALLOC, NULL, totvert); CustomData_free(&mesh->vdata, mesh->totvert); @@ -832,7 +836,7 @@ static void mesh_add_verts(Mesh *mesh, int len) /* scan the input list and insert the new vertices */ mvert= &mesh->mvert[mesh->totvert]; - for(i=0; iflag |= SELECT; /* set final vertex list size */ @@ -844,7 +848,7 @@ void ED_mesh_transform(Mesh *me, float *mat) int i; MVert *mvert= me->mvert; - for(i= 0; i < me->totvert; i++, mvert++) + for (i= 0; i < me->totvert; i++, mvert++) mul_m4_v3((float (*)[4])mat, mvert->co); mesh_calc_normals_mapping(me->mvert, me->totvert, me->mloop, me->mpoly, me->totloop, me->totpoly, NULL, NULL, 0, NULL, NULL); @@ -856,7 +860,7 @@ static void mesh_add_edges(Mesh *mesh, int len) MEdge *medge; int i, totedge; - if(len == 0) + if (len == 0) return; totedge= mesh->totedge+len; @@ -865,7 +869,7 @@ static void mesh_add_edges(Mesh *mesh, int len) CustomData_copy(&mesh->edata, &edata, CD_MASK_MESH, CD_DEFAULT, totedge); CustomData_copy_data(&mesh->edata, &edata, 0, 0, mesh->totedge); - if(!CustomData_has_layer(&edata, CD_MEDGE)) + if (!CustomData_has_layer(&edata, CD_MEDGE)) CustomData_add_layer(&edata, CD_MEDGE, CD_CALLOC, NULL, totedge); CustomData_free(&mesh->edata, mesh->totedge); @@ -874,7 +878,7 @@ static void mesh_add_edges(Mesh *mesh, int len) /* set default flags */ medge= &mesh->medge[mesh->totedge]; - for(i=0; iflag= ME_EDGEDRAW|ME_EDGERENDER|SELECT; mesh->totedge= totedge; @@ -886,7 +890,7 @@ static void mesh_add_faces(Mesh *mesh, int len) MFace *mface; int i, totface; - if(len == 0) + if (len == 0) return; totface= mesh->totface + len; /* new face count */ @@ -895,7 +899,7 @@ static void mesh_add_faces(Mesh *mesh, int len) CustomData_copy(&mesh->fdata, &fdata, CD_MASK_MESH, CD_DEFAULT, totface); CustomData_copy_data(&mesh->fdata, &fdata, 0, 0, mesh->totface); - if(!CustomData_has_layer(&fdata, CD_MFACE)) + if (!CustomData_has_layer(&fdata, CD_MFACE)) CustomData_add_layer(&fdata, CD_MFACE, CD_CALLOC, NULL, totface); CustomData_free(&mesh->fdata, mesh->totface); @@ -904,7 +908,7 @@ static void mesh_add_faces(Mesh *mesh, int len) /* set default flags */ mface= &mesh->mface[mesh->totface]; - for(i=0; iflag= ME_FACE_SEL; mesh->totface= totface; @@ -915,7 +919,7 @@ static void mesh_add_loops(Mesh *mesh, int len) CustomData ldata; int totloop; - if(len == 0) + if (len == 0) return; totloop= mesh->totloop + len; /* new face count */ @@ -924,7 +928,7 @@ static void mesh_add_loops(Mesh *mesh, int len) CustomData_copy(&mesh->ldata, &ldata, CD_MASK_MESH, CD_DEFAULT, totloop); CustomData_copy_data(&mesh->ldata, &ldata, 0, 0, mesh->totloop); - if(!CustomData_has_layer(&ldata, CD_MLOOP)) + if (!CustomData_has_layer(&ldata, CD_MLOOP)) CustomData_add_layer(&ldata, CD_MLOOP, CD_CALLOC, NULL, totloop); CustomData_free(&mesh->ldata, mesh->totloop); @@ -940,7 +944,7 @@ static void mesh_add_polys(Mesh *mesh, int len) MPoly *mpoly; int i, totpoly; - if(len == 0) + if (len == 0) return; totpoly= mesh->totpoly + len; /* new face count */ @@ -949,7 +953,7 @@ static void mesh_add_polys(Mesh *mesh, int len) CustomData_copy(&mesh->pdata, &pdata, CD_MASK_MESH, CD_DEFAULT, totpoly); CustomData_copy_data(&mesh->pdata, &pdata, 0, 0, mesh->totpoly); - if(!CustomData_has_layer(&pdata, CD_MPOLY)) + if (!CustomData_has_layer(&pdata, CD_MPOLY)) CustomData_add_layer(&pdata, CD_MPOLY, CD_CALLOC, NULL, totpoly); CustomData_free(&mesh->pdata, mesh->totpoly); @@ -958,7 +962,7 @@ static void mesh_add_polys(Mesh *mesh, int len) /* set default flags */ mpoly= &mesh->mpoly[mesh->totpoly]; - for(i=0; iflag= ME_FACE_SEL; mesh->totpoly= totpoly; @@ -968,7 +972,7 @@ static void mesh_remove_verts(Mesh *mesh, int len) { int totvert; - if(len == 0) + if (len == 0) return; totvert= mesh->totvert - len; @@ -982,7 +986,7 @@ static void mesh_remove_edges(Mesh *mesh, int len) { int totedge; - if(len == 0) + if (len == 0) return; totedge= mesh->totedge - len; @@ -995,7 +999,7 @@ static void mesh_remove_faces(Mesh *mesh, int len) { int totface; - if(len == 0) + if (len == 0) return; totface= mesh->totface - len; /* new face count */ @@ -1007,23 +1011,23 @@ static void mesh_remove_faces(Mesh *mesh, int len) #if 0 void ED_mesh_geometry_add(Mesh *mesh, ReportList *reports, int verts, int edges, int faces) { - if(mesh->edit_btmesh) { + if (mesh->edit_btmesh) { BKE_report(reports, RPT_ERROR, "Can't add geometry in edit mode"); return; } - if(verts) + if (verts) mesh_add_verts(mesh, verts); - if(edges) + if (edges) mesh_add_edges(mesh, edges); - if(faces) + if (faces) mesh_add_faces(mesh, faces); } #endif void ED_mesh_faces_add(Mesh *mesh, ReportList *reports, int count) { - if(mesh->edit_btmesh) { + if (mesh->edit_btmesh) { BKE_report(reports, RPT_ERROR, "Can't add faces in edit mode"); return; } @@ -1033,7 +1037,7 @@ void ED_mesh_faces_add(Mesh *mesh, ReportList *reports, int count) void ED_mesh_edges_add(Mesh *mesh, ReportList *reports, int count) { - if(mesh->edit_btmesh) { + if (mesh->edit_btmesh) { BKE_report(reports, RPT_ERROR, "Can't add edges in edit mode"); return; } @@ -1043,7 +1047,7 @@ void ED_mesh_edges_add(Mesh *mesh, ReportList *reports, int count) void ED_mesh_vertices_add(Mesh *mesh, ReportList *reports, int count) { - if(mesh->edit_btmesh) { + if (mesh->edit_btmesh) { BKE_report(reports, RPT_ERROR, "Can't add vertices in edit mode"); return; } @@ -1053,11 +1057,11 @@ void ED_mesh_vertices_add(Mesh *mesh, ReportList *reports, int count) void ED_mesh_faces_remove(Mesh *mesh, ReportList *reports, int count) { - if(mesh->edit_btmesh) { + if (mesh->edit_btmesh) { BKE_report(reports, RPT_ERROR, "Can't remove faces in edit mode"); return; } - else if(count > mesh->totface) { + else if (count > mesh->totface) { BKE_report(reports, RPT_ERROR, "Can't remove more faces than the mesh contains"); return; } @@ -1067,11 +1071,11 @@ void ED_mesh_faces_remove(Mesh *mesh, ReportList *reports, int count) void ED_mesh_edges_remove(Mesh *mesh, ReportList *reports, int count) { - if(mesh->edit_btmesh) { + if (mesh->edit_btmesh) { BKE_report(reports, RPT_ERROR, "Can't remove edges in edit mode"); return; } - else if(count > mesh->totedge) { + else if (count > mesh->totedge) { BKE_report(reports, RPT_ERROR, "Can't remove more edges than the mesh contains"); return; } @@ -1081,11 +1085,11 @@ void ED_mesh_edges_remove(Mesh *mesh, ReportList *reports, int count) void ED_mesh_vertices_remove(Mesh *mesh, ReportList *reports, int count) { - if(mesh->edit_btmesh) { + if (mesh->edit_btmesh) { BKE_report(reports, RPT_ERROR, "Can't remove vertices in edit mode"); return; } - else if(count > mesh->totvert) { + else if (count > mesh->totvert) { BKE_report(reports, RPT_ERROR, "Can't remove more vertices than the mesh contains"); return; } @@ -1095,7 +1099,7 @@ void ED_mesh_vertices_remove(Mesh *mesh, ReportList *reports, int count) void ED_mesh_loops_add(Mesh *mesh, ReportList *reports, int count) { - if(mesh->edit_btmesh) { + if (mesh->edit_btmesh) { BKE_report(reports, RPT_ERROR, "Can't add loops in edit mode."); return; } @@ -1105,7 +1109,7 @@ void ED_mesh_loops_add(Mesh *mesh, ReportList *reports, int count) void ED_mesh_polys_add(Mesh *mesh, ReportList *reports, int count) { - if(mesh->edit_btmesh) { + if (mesh->edit_btmesh) { BKE_report(reports, RPT_ERROR, "Can't add polys in edit mode."); return; } diff --git a/source/blender/editors/mesh/mesh_navmesh.c b/source/blender/editors/mesh/mesh_navmesh.c index 58899acff9b..02ef1540cc1 100644 --- a/source/blender/editors/mesh/mesh_navmesh.c +++ b/source/blender/editors/mesh/mesh_navmesh.c @@ -85,7 +85,7 @@ static void createVertsTrisData(bContext *C, LinkNode *obs, int *nverts_r, float ntris = 0; /* calculate number of verts and tris */ - for(oblink = obs; oblink; oblink= oblink->next) { + for (oblink = obs; oblink; oblink= oblink->next) { ob= (Object*) oblink->link; dm= mesh_create_derived_no_virtual(scene, ob, NULL, CD_MASK_MESH); BLI_linklist_append(&dms, (void*)dm); @@ -96,9 +96,9 @@ static void createVertsTrisData(bContext *C, LinkNode *obs, int *nverts_r, float /* resolve quad faces */ mface= dm->getTessFaceArray(dm); - for(i= 0; iv4) + if (mf->v4) ntris+=1; } } @@ -109,7 +109,7 @@ static void createVertsTrisData(bContext *C, LinkNode *obs, int *nverts_r, float basenverts= 0; tri= tris; - for(oblink= obs, dmlink= dms; oblink && dmlink; + for (oblink= obs, dmlink= dms; oblink && dmlink; oblink= oblink->next, dmlink= dmlink->next) { ob= (Object*) oblink->link; dm= (DerivedMesh*) dmlink->link; @@ -118,7 +118,7 @@ static void createVertsTrisData(bContext *C, LinkNode *obs, int *nverts_r, float mvert= dm->getVertArray(dm); /* copy verts */ - for(i= 0; ico); @@ -133,7 +133,7 @@ static void createVertsTrisData(bContext *C, LinkNode *obs, int *nverts_r, float curnfaces= dm->getNumTessFaces(dm); mface= dm->getTessFaceArray(dm); - for(i= 0; iv1; @@ -141,7 +141,7 @@ static void createVertsTrisData(bContext *C, LinkNode *obs, int *nverts_r, float tri[2]= basenverts + mf->v2; tri += 3; - if(mf->v4) { + if (mf->v4) { tri[0]= basenverts + mf->v1; tri[1]= basenverts + mf->v4; tri[2]= basenverts + mf->v3; @@ -153,7 +153,7 @@ static void createVertsTrisData(bContext *C, LinkNode *obs, int *nverts_r, float } /* release derived mesh */ - for(dmlink= dms; dmlink; dmlink= dmlink->next) { + for (dmlink= dms; dmlink; dmlink= dmlink->next) { dm= (DerivedMesh*) dmlink->link; dm->release(dm); } @@ -198,7 +198,7 @@ static int buildNavMesh(const RecastData *recastParams, int nverts, float *verts /* Allocate voxel heightfield where we rasterize our input data to */ solid= recast_newHeightfield(); - if(!recast_createHeightfield(solid, width, height, bmin, bmax, recastParams->cellsize, recastParams->cellheight)) { + if (!recast_createHeightfield(solid, width, height, bmin, bmax, recastParams->cellsize, recastParams->cellheight)) { recast_destroyHeightfield(solid); return 0; @@ -220,7 +220,7 @@ static int buildNavMesh(const RecastData *recastParams, int nverts, float *verts /* ** Step 4: Partition walkable surface to simple regions ** */ chf= recast_newCompactHeightfield(); - if(!recast_buildCompactHeightfield(walkableHeight, walkableClimb, solid, chf)) { + if (!recast_buildCompactHeightfield(walkableHeight, walkableClimb, solid, chf)) { recast_destroyHeightfield(solid); recast_destroyCompactHeightfield(chf); @@ -237,14 +237,14 @@ static int buildNavMesh(const RecastData *recastParams, int nverts, float *verts } /* Prepare for region partitioning, by calculating distance field along the walkable surface */ - if(!recast_buildDistanceField(chf)) { + if (!recast_buildDistanceField(chf)) { recast_destroyCompactHeightfield(chf); return 0; } /* Partition the walkable surface into simple regions without holes */ - if(!recast_buildRegions(chf, 0, minRegionArea, mergeRegionArea)) { + if (!recast_buildRegions(chf, 0, minRegionArea, mergeRegionArea)) { recast_destroyCompactHeightfield(chf); return 0; @@ -254,7 +254,7 @@ static int buildNavMesh(const RecastData *recastParams, int nverts, float *verts /* Create contours */ cset= recast_newContourSet(); - if(!recast_buildContours(chf, recastParams->edgemaxerror, maxEdgeLen, cset)) { + if (!recast_buildContours(chf, recastParams->edgemaxerror, maxEdgeLen, cset)) { recast_destroyCompactHeightfield(chf); recast_destroyContourSet(cset); @@ -263,7 +263,7 @@ static int buildNavMesh(const RecastData *recastParams, int nverts, float *verts /* ** Step 6: Build polygons mesh from contours ** */ *pmesh= recast_newPolyMesh(); - if(!recast_buildPolyMesh(cset, recastParams->vertsperpoly, *pmesh)) { + if (!recast_buildPolyMesh(cset, recastParams->vertsperpoly, *pmesh)) { recast_destroyCompactHeightfield(chf); recast_destroyContourSet(cset); recast_destroyPolyMesh(*pmesh); @@ -275,7 +275,7 @@ static int buildNavMesh(const RecastData *recastParams, int nverts, float *verts /* ** Step 7: Create detail mesh which allows to access approximate height on each polygon ** */ *dmesh= recast_newPolyMeshDetail(); - if(!recast_buildPolyMeshDetail(*pmesh, chf, detailSampleDist, detailSampleMaxError, *dmesh)) { + if (!recast_buildPolyMeshDetail(*pmesh, chf, detailSampleDist, detailSampleMaxError, *dmesh)) { recast_destroyCompactHeightfield(chf); recast_destroyContourSet(cset); recast_destroyPolyMesh(*pmesh); @@ -309,7 +309,7 @@ static Object *createRepresentation(bContext *C, struct recast_polyMesh *pmesh, zero_v3(co); zero_v3(rot); - if(createob) { + if (createob) { /* create new object */ obedit= ED_object_add_type(C, OB_MESH, co, rot, FALSE, 1); } @@ -323,7 +323,7 @@ static Object *createRepresentation(bContext *C, struct recast_polyMesh *pmesh, ED_object_enter_editmode(C, EM_DO_UNDO|EM_IGNORE_LAYER); em = BMEdit_FromObject(obedit); - if(!createob) { + if (!createob) { /* clear */ EDBM_ClearMesh(em); } @@ -333,7 +333,7 @@ static Object *createRepresentation(bContext *C, struct recast_polyMesh *pmesh, recast_polyMeshGetBoundbox(pmesh, bmin, NULL); recast_polyMeshGetCell(pmesh, &cs, &ch); - for(i= 0; ibm->totvert; unsigned int vbase= meshes[4*i+0]; unsigned short ndv= meshes[4*i+1]; @@ -360,13 +360,13 @@ static Object *createRepresentation(bContext *C, struct recast_polyMesh *pmesh, const unsigned short *p= &polys[i*nvp*2]; int nv= 0; - for(j= 0; j < nvp; ++j) { - if(p[j]==0xffff) break; + for (j= 0; j < nvp; ++j) { + if (p[j]==0xffff) break; nv++; } /* create unique verts */ - for(j= nv; jbm, co, NULL); @@ -375,13 +375,13 @@ static Object *createRepresentation(bContext *C, struct recast_polyMesh *pmesh, EDBM_init_index_arrays(em, 1, 0, 0); /* create faces */ - for(j= 0; jgameflag&= ~OB_COLLISION; obedit->gameflag|= OB_NAVMESH; obedit->body_type= OB_BODY_TYPE_NAVMESH; @@ -489,17 +489,17 @@ static int navmesh_face_copy_exec(bContext *C, wmOperator *op) /* do work here */ BMFace *efa_act= BM_active_face_get(em->bm, FALSE); - if(efa_act) { - if(CustomData_has_layer(&em->bm->pdata, CD_RECAST)) { + if (efa_act) { + if (CustomData_has_layer(&em->bm->pdata, CD_RECAST)) { BMFace *efa; BMIter iter; int targetPolyIdx= *(int*)CustomData_bmesh_get(&em->bm->pdata, efa_act->head.data, CD_RECAST); targetPolyIdx= targetPolyIdx>=0? targetPolyIdx : -targetPolyIdx; - if(targetPolyIdx > 0) { + if (targetPolyIdx > 0) { /* set target poly idx to other selected faces */ BM_ITER(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL) { - if(BM_elem_flag_test(efa, BM_ELEM_SELECT) && efa != efa_act) { + if (BM_elem_flag_test(efa, BM_ELEM_SELECT) && efa != efa_act) { int *recastDataBlock = (int*)CustomData_bmesh_get(&em->bm->pdata, efa->head.data, CD_RECAST); *recastDataBlock = targetPolyIdx; } @@ -557,10 +557,10 @@ static int findFreeNavPolyIndex(BMEditMesh *em) /* search first free index */ freeIdx = 1; - for(i = 0; ifreeIdx) + else if (indices[i]>freeIdx) break; } @@ -576,15 +576,15 @@ static int navmesh_face_add_exec(bContext *C, wmOperator *UNUSED(op)) BMFace *ef; BMIter iter; - if(CustomData_has_layer(&em->bm->pdata, CD_RECAST)) { + if (CustomData_has_layer(&em->bm->pdata, CD_RECAST)) { int targetPolyIdx = findFreeNavPolyIndex(em); - if(targetPolyIdx>0) { + if (targetPolyIdx>0) { /* set target poly idx to selected faces */ /*XXX this originally went last to first, but that isn't possible anymore*/ BM_ITER(ef, &iter, em->bm, BM_FACES_OF_MESH, NULL) { - if(BM_elem_flag_test(ef, BM_ELEM_SELECT)) { + if (BM_elem_flag_test(ef, BM_ELEM_SELECT)) { int *recastDataBlock = (int*)CustomData_bmesh_get(&em->bm->pdata, ef->head.data, CD_RECAST); *recastDataBlock = targetPolyIdx; } diff --git a/source/blender/editors/mesh/mesh_ops.c b/source/blender/editors/mesh/mesh_ops.c index 29face0efc2..ccc6fa01735 100644 --- a/source/blender/editors/mesh/mesh_ops.c +++ b/source/blender/editors/mesh/mesh_ops.c @@ -178,7 +178,7 @@ void ED_operatortypes_mesh(void) static int ED_operator_editmesh_face_select(bContext *C) { Object *obedit= CTX_data_edit_object(C); - if(obedit && obedit->type==OB_MESH) { + if (obedit && obedit->type==OB_MESH) { BMEditMesh *em = BMEdit_FromObject(obedit); if (em && em->selectmode & SCE_SELECT_FACE) { return 1; diff --git a/source/blender/editors/mesh/meshtools.c b/source/blender/editors/mesh/meshtools.c index 919e2b03583..7d0172b3c15 100644 --- a/source/blender/editors/mesh/meshtools.c +++ b/source/blender/editors/mesh/meshtools.c @@ -110,20 +110,20 @@ int join_mesh_exec(bContext *C, wmOperator *op) MDeformVert *dvert; CustomData vdata, edata, fdata, ldata, pdata; - if(scene->obedit) { + if (scene->obedit) { BKE_report(op->reports, RPT_WARNING, "Cant join while in editmode"); return OPERATOR_CANCELLED; } /* ob is the object we are adding geometry to */ - if(!ob || ob->type!=OB_MESH) { + if (!ob || ob->type!=OB_MESH) { BKE_report(op->reports, RPT_WARNING, "Active object is not a mesh"); return OPERATOR_CANCELLED; } /* count & check */ CTX_DATA_BEGIN(C, Base*, base, selected_editable_bases) { - if(base->object->type==OB_MESH) { + if (base->object->type==OB_MESH) { me= base->object->data; totvert+= me->totvert; @@ -132,18 +132,18 @@ int join_mesh_exec(bContext *C, wmOperator *op) totpoly+= me->totpoly; totmat+= base->object->totcol; - if(base->object == ob) + if (base->object == ob) ok= 1; /* check for shapekeys */ - if(me->key) + if (me->key) haskey++; } } CTX_DATA_END; /* that way the active object is always selected */ - if(ok==0) { + if (ok==0) { BKE_report(op->reports, RPT_WARNING, "Active object is not a selected mesh"); return OPERATOR_CANCELLED; } @@ -152,12 +152,12 @@ int join_mesh_exec(bContext *C, wmOperator *op) me= (Mesh *)ob->data; key= me->key; - if(totvert==0 || totvert==me->totvert) { + if (totvert==0 || totvert==me->totvert) { BKE_report(op->reports, RPT_WARNING, "No mesh data to join"); return OPERATOR_CANCELLED; } - if(totvert > MESH_MAX_VERTS) { + if (totvert > MESH_MAX_VERTS) { BKE_reportf(op->reports, RPT_WARNING, "Joining results in %d vertices, limit is " STRINGIFY(MESH_MAX_VERTS), totvert); return OPERATOR_CANCELLED; } @@ -168,7 +168,7 @@ int join_mesh_exec(bContext *C, wmOperator *op) totcol= ob->totcol; /* obact materials in new main array, is nicer start! */ - for(a=0; atotcol; a++) { + for (a=0; atotcol; a++) { matar[a]= give_current_material(ob, a+1); id_us_plus((ID *)matar[a]); /* increase id->us : will be lowered later */ @@ -179,19 +179,19 @@ int join_mesh_exec(bContext *C, wmOperator *op) * - if destination mesh didn't have shapekeys, but we encountered some in the meshes we're * joining, set up a new keyblock and assign to the mesh */ - if(key) { + if (key) { /* make a duplicate copy that will only be used here... (must remember to free it!) */ nkey= copy_key(key); /* for all keys in old block, clear data-arrays */ - for(kb= key->block.first; kb; kb= kb->next) { - if(kb->data) MEM_freeN(kb->data); + for (kb= key->block.first; kb; kb= kb->next) { + if (kb->data) MEM_freeN(kb->data); kb->data= MEM_callocN(sizeof(float)*3*totvert, "join_shapekey"); kb->totelem= totvert; kb->weights= NULL; } } - else if(haskey) { + else if (haskey) { /* add a new key-block and add to the mesh */ key= me->key= add_key((ID *)me); key->type = KEY_RELATIVE; @@ -200,48 +200,48 @@ int join_mesh_exec(bContext *C, wmOperator *op) /* first pass over objects - copying materials and vertexgroups across */ CTX_DATA_BEGIN(C, Base*, base, selected_editable_bases) { /* only act if a mesh, and not the one we're joining to */ - if((ob!=base->object) && (base->object->type==OB_MESH)) { + if ((ob!=base->object) && (base->object->type==OB_MESH)) { me= base->object->data; /* Join this object's vertex groups to the base one's */ - for(dg=base->object->defbase.first; dg; dg=dg->next) { + for (dg=base->object->defbase.first; dg; dg=dg->next) { /* See if this group exists in the object (if it doesn't, add it to the end) */ - if(!defgroup_find_name(ob, dg->name)) { + if (!defgroup_find_name(ob, dg->name)) { odg = MEM_callocN(sizeof(bDeformGroup), "join deformGroup"); memcpy(odg, dg, sizeof(bDeformGroup)); BLI_addtail(&ob->defbase, odg); } } - if(ob->defbase.first && ob->actdef==0) + if (ob->defbase.first && ob->actdef==0) ob->actdef=1; - if(me->totvert) { + if (me->totvert) { /* Add this object's materials to the base one's if they don't exist already (but only if limits not exceeded yet) */ - if(totcol < MAXMAT) { - for(a=1; a<=base->object->totcol; a++) { + if (totcol < MAXMAT) { + for (a=1; a<=base->object->totcol; a++) { ma= give_current_material(base->object, a); - for(b=0; bid); } totcol++; } - if(totcol >= MAXMAT) + if (totcol >= MAXMAT) break; } } /* if this mesh has shapekeys, check if destination mesh already has matching entries too */ - if(me->key && key) { - for(kb= me->key->block.first; kb; kb= kb->next) { + if (me->key && key) { + for (kb= me->key->block.first; kb; kb= kb->next) { /* if key doesn't exist in destination mesh, add it */ - if(key_get_named_keyblock(key, kb->name) == NULL) { + if (key_get_named_keyblock(key, kb->name) == NULL) { /* copy this existing one over to the new shapekey block */ kbn= MEM_dupallocN(kb); kbn->prev= kbn->next= NULL; @@ -253,7 +253,7 @@ int join_mesh_exec(bContext *C, wmOperator *op) okb= key->block.last; curpos= (okb) ? okb->pos : -0.1f; - if(key->type == KEY_RELATIVE) + if (key->type == KEY_RELATIVE) kbn->pos= curpos + 0.1f; else kbn->pos= curpos; @@ -261,12 +261,12 @@ int join_mesh_exec(bContext *C, wmOperator *op) BLI_addtail(&key->block, kbn); kbn->adrcode= key->totkey; key->totkey++; - if(key->totkey==1) key->refkey= kbn; + if (key->totkey==1) key->refkey= kbn; // XXX 2.5 Animato #if 0 /* also, copy corresponding ipo-curve to ipo-block if applicable */ - if(me->key->ipo && key->ipo) { + if (me->key->ipo && key->ipo) { // FIXME... this is a luxury item! puts("FIXME: ignoring IPO's when joining shapekeys on Meshes for now..."); } @@ -301,10 +301,10 @@ int join_mesh_exec(bContext *C, wmOperator *op) CTX_DATA_BEGIN(C, Base*, base, selected_editable_bases) { /* only join if this is a mesh */ - if(base->object->type==OB_MESH) { + if (base->object->type==OB_MESH) { me= base->object->data; - if(me->totvert) { + if (me->totvert) { /* standard data */ CustomData_merge(&me->vdata, &vdata, CD_MASK_MESH, CD_DEFAULT, totvert); CustomData_copy_data(&me->vdata, &vdata, 0, vertofs, me->totvert); @@ -313,15 +313,15 @@ int join_mesh_exec(bContext *C, wmOperator *op) dvert= CustomData_get(&vdata, vertofs, CD_MDEFORMVERT); /* NB: vertex groups here are new version */ - if(dvert) { - for(i=0; itotvert; i++) { - for(j=0; jtotvert; i++) { + for (j=0; jobject->defbase, dvert[i].dw[j].def_nr); - if(odg) { + if (odg) { /* Search for a match in the new object, and set new index */ - for(dg=ob->defbase.first, index=0; dg; dg=dg->next, index++) { - if(!strcmp(dg->name, odg->name)) { + for (dg=ob->defbase.first, index=0; dg; dg=dg->next, index++) { + if (!strcmp(dg->name, odg->name)) { dvert[i].dw[j].def_nr = index; break; } @@ -332,12 +332,12 @@ int join_mesh_exec(bContext *C, wmOperator *op) } /* if this is the object we're merging into, no need to do anything */ - if(base->object != ob) { + if (base->object != ob) { /* watch this: switch matmul order really goes wrong */ mult_m4_m4m4(cmat, imat, base->object->obmat); /* transform vertex coordinates into new space */ - for(a=0, mv=mvert; a < me->totvert; a++, mv++) { + for (a=0, mv=mvert; a < me->totvert; a++, mv++) { mul_m4_v3(cmat, mv->co); } @@ -345,18 +345,18 @@ int join_mesh_exec(bContext *C, wmOperator *op) * - if there's a matching one, copy it across (will need to transform vertices into new space...) * - otherwise, just copy own coordinates of mesh (no need to transform vertex coordinates into new space) */ - if(key) { + if (key) { /* if this mesh has any shapekeys, check first, otherwise just copy coordinates */ - for(kb= key->block.first; kb; kb= kb->next) { + for (kb= key->block.first; kb; kb= kb->next) { /* get pointer to where to write data for this mesh in shapekey's data array */ fp1= ((float *)kb->data) + (vertofs*3); /* check if this mesh has such a shapekey */ okb= key_get_named_keyblock(me->key, kb->name); - if(okb) { + if (okb) { /* copy this mesh's shapekey to the destination shapekey (need to transform first) */ fp2= ((float *)(okb->data)); - for(a=0; a < me->totvert; a++, fp1+=3, fp2+=3) { + for (a=0; a < me->totvert; a++, fp1+=3, fp2+=3) { copy_v3_v3(fp1, fp2); mul_m4_v3(cmat, fp1); } @@ -364,7 +364,7 @@ int join_mesh_exec(bContext *C, wmOperator *op) else { /* copy this mesh's vertex coordinates to the destination shapekey */ mv= mvert; - for(a=0; a < me->totvert; a++, fp1+=3, mv++) { + for (a=0; a < me->totvert; a++, fp1+=3, mv++) { copy_v3_v3(fp1, mv->co); } } @@ -376,24 +376,24 @@ int join_mesh_exec(bContext *C, wmOperator *op) * - if it was an 'original', copy the appropriate data from nkey * - otherwise, copy across plain coordinates (no need to transform coordinates) */ - if(key) { - for(kb= key->block.first; kb; kb= kb->next) { + if (key) { + for (kb= key->block.first; kb; kb= kb->next) { /* get pointer to where to write data for this mesh in shapekey's data array */ fp1= ((float *)kb->data) + (vertofs*3); /* check if this was one of the original shapekeys */ okb= key_get_named_keyblock(nkey, kb->name); - if(okb) { + if (okb) { /* copy this mesh's shapekey to the destination shapekey */ fp2= ((float *)(okb->data)); - for(a=0; a < me->totvert; a++, fp1+=3, fp2+=3) { + for (a=0; a < me->totvert; a++, fp1+=3, fp2+=3) { copy_v3_v3(fp1, fp2); } } else { /* copy base-coordinates to the destination shapekey */ mv= mvert; - for(a=0; a < me->totvert; a++, fp1+=3, mv++) { + for (a=0; a < me->totvert; a++, fp1+=3, mv++) { copy_v3_v3(fp1, mv->co); } } @@ -405,36 +405,36 @@ int join_mesh_exec(bContext *C, wmOperator *op) mvert+= me->totvert; } - if(me->totedge) { + if (me->totedge) { CustomData_merge(&me->edata, &edata, CD_MASK_MESH, CD_DEFAULT, totedge); CustomData_copy_data(&me->edata, &edata, 0, edgeofs, me->totedge); - for(a=0; atotedge; a++, medge++) { + for (a=0; atotedge; a++, medge++) { medge->v1+= vertofs; medge->v2+= vertofs; } } if (me->totloop) { - if(base->object!=ob) + if (base->object!=ob) multiresModifier_prepare_join(scene, base->object, ob); CustomData_merge(&me->ldata, &ldata, CD_MASK_MESH, CD_DEFAULT, totloop); CustomData_copy_data(&me->ldata, &ldata, 0, loopofs, me->totloop); - for(a=0; atotloop; a++, mloop++) { + for (a=0; atotloop; a++, mloop++) { mloop->v += vertofs; mloop->e += edgeofs; } } - if(me->totpoly) { + if (me->totpoly) { /* make mapping for materials */ - for(a=1; a<=base->object->totcol; a++) { + for (a=1; a<=base->object->totcol; a++) { ma= give_current_material(base->object, a); - for(b=0; bpdata, &pdata, CD_MASK_MESH, CD_DEFAULT, totpoly); CustomData_copy_data(&me->pdata, &pdata, 0, polyofs, me->totpoly); - for(a=0; atotpoly; a++, mpoly++) { + for (a=0; atotpoly; a++, mpoly++) { mpoly->loopstart += loopofs; mpoly->mat_nr= matmap ? matmap[(int)mpoly->mat_nr] : 0; } @@ -460,7 +460,7 @@ int join_mesh_exec(bContext *C, wmOperator *op) loopofs += me->totloop; /* free base, now that data is merged */ - if(base->object != ob) + if (base->object != ob) ED_base_object_free_and_unlink(bmain, scene, base); } } @@ -487,21 +487,21 @@ int join_mesh_exec(bContext *C, wmOperator *op) mesh_update_customdata_pointers(me, TRUE); /* BMESH_TODO, check if this arg can be failse, non urgent - campbell */ /* old material array */ - for(a=1; a<=ob->totcol; a++) { + for (a=1; a<=ob->totcol; a++) { ma= ob->mat[a-1]; - if(ma) ma->id.us--; + if (ma) ma->id.us--; } - for(a=1; a<=me->totcol; a++) { + for (a=1; a<=me->totcol; a++) { ma= me->mat[a-1]; - if(ma) ma->id.us--; + if (ma) ma->id.us--; } - if(ob->mat) MEM_freeN(ob->mat); - if(ob->matbits) MEM_freeN(ob->matbits); - if(me->mat) MEM_freeN(me->mat); + if (ob->mat) MEM_freeN(ob->mat); + if (ob->matbits) MEM_freeN(ob->matbits); + if (me->mat) MEM_freeN(me->mat); ob->mat= me->mat= NULL; ob->matbits= NULL; - if(totcol) { + if (totcol) { me->mat= matar; ob->mat= MEM_callocN(sizeof(void *)*totcol, "join obmatar"); ob->matbits= MEM_callocN(sizeof(char)*totcol, "join obmatbits"); @@ -517,11 +517,11 @@ int join_mesh_exec(bContext *C, wmOperator *op) test_object_materials((ID *)me); /* free temp copy of destination shapekeys (if applicable) */ - if(nkey) { + if (nkey) { // XXX 2.5 Animato #if 0 /* free it's ipo too - both are not actually freed from memory yet as ID-blocks */ - if(nkey->ipo) { + if (nkey->ipo) { free_ipo(nkey->ipo); BLI_remlink(&bmain->ipo, nkey->ipo); MEM_freeN(nkey->ipo); @@ -590,7 +590,7 @@ int join_mesh_shapes_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } - if(key == NULL) { + if (key == NULL) { key= me->key= add_key((ID *)me); key->type= KEY_RELATIVE; @@ -603,7 +603,7 @@ int join_mesh_shapes_exec(bContext *C, wmOperator *op) CTX_DATA_BEGIN(C, Base*, base, selected_editable_bases) { if (base->object == ob) continue; - if(base->object->type==OB_MESH) { + if (base->object->type==OB_MESH) { selme = (Mesh *)base->object->data; if (selme->totvert==me->totvert) { @@ -656,16 +656,16 @@ static int mesh_octree_get_base_offs(float *co, float *offs, float *div) static void mesh_octree_add_node(MocNode **bt, intptr_t index) { - if(*bt==NULL) { + if (*bt==NULL) { *bt= MEM_callocN(sizeof(MocNode), "MocNode"); (*bt)->index[0]= index; } else { int a; - for(a=0; aindex[a]==index) + for (a=0; aindex[a]==index) return; - else if((*bt)->index[a]==0) { + else if ((*bt)->index[a]==0) { (*bt)->index[a]= index; return; } @@ -676,7 +676,7 @@ static void mesh_octree_add_node(MocNode **bt, intptr_t index) static void mesh_octree_free_node(MocNode **bt) { - if( (*bt)->next ) { + if ( (*bt)->next ) { mesh_octree_free_node(&(*bt)->next); } MEM_freeN(*bt); @@ -739,26 +739,26 @@ static intptr_t mesh_octree_find_index(MocNode **bt, MVert *mvert, float *co) float *vec; int a; - if(*bt==NULL) + if (*bt==NULL) return -1; - for(a=0; aindex[a]) { + for (a=0; aindex[a]) { /* does mesh verts and editmode, code looks potential dangerous, octree should really be filled OK! */ - if(mvert) { + if (mvert) { vec= (mvert+(*bt)->index[a]-1)->co; - if(compare_v3v3(vec, co, MOC_THRESH)) + if (compare_v3v3(vec, co, MOC_THRESH)) return (*bt)->index[a]-1; } else { BMVert *eve= (BMVert *)((*bt)->index[a]); - if(compare_v3v3(eve->co, co, MOC_THRESH)) + if (compare_v3v3(eve->co, co, MOC_THRESH)) return (*bt)->index[a]; } } else return -1; } - if( (*bt)->next) + if ( (*bt)->next) return mesh_octree_find_index(&(*bt)->next, mvert, co); return -1; @@ -775,21 +775,21 @@ intptr_t mesh_octree_table(Object *ob, BMEditMesh *em, float *co, char mode) { MocNode **bt; - if(mode=='u') { /* use table */ - if(MeshOctree.table==NULL) + if (mode=='u') { /* use table */ + if (MeshOctree.table==NULL) mesh_octree_table(ob, em, NULL, 's'); - if(MeshOctree.table) { + if (MeshOctree.table) { Mesh *me= ob->data; bt= MeshOctree.table + mesh_octree_get_base_offs(co, MeshOctree.offs, MeshOctree.div); - if(em) + if (em) return mesh_octree_find_index(bt, NULL, co); else return mesh_octree_find_index(bt, me->mvert, co); } return -1; } - else if(mode=='s') { /* start table */ + else if (mode=='s') { /* start table */ Mesh *me= ob->data; float min[3], max[3]; @@ -797,7 +797,7 @@ intptr_t mesh_octree_table(Object *ob, BMEditMesh *em, float *co, char mode) * we are using the undeformed coordinates*/ INIT_MINMAX(min, max); - if(em && me->edit_btmesh==em) { + if (em && me->edit_btmesh==em) { BMIter iter; BMVert *eve; @@ -809,7 +809,7 @@ intptr_t mesh_octree_table(Object *ob, BMEditMesh *em, float *co, char mode) MVert *mvert; int a; - for(a=0, mvert= me->mvert; atotvert; a++, mvert++) + for (a=0, mvert= me->mvert; atotvert; a++, mvert++) DO_MINMAX(mvert->co, min, max); } @@ -825,16 +825,16 @@ intptr_t mesh_octree_table(Object *ob, BMEditMesh *em, float *co, char mode) MeshOctree.div[2]+= 2*MOC_THRESH; mul_v3_fl(MeshOctree.div, 1.0f/MOC_RES); - if(MeshOctree.div[0]==0.0f) MeshOctree.div[0]= 1.0f; - if(MeshOctree.div[1]==0.0f) MeshOctree.div[1]= 1.0f; - if(MeshOctree.div[2]==0.0f) MeshOctree.div[2]= 1.0f; + if (MeshOctree.div[0]==0.0f) MeshOctree.div[0]= 1.0f; + if (MeshOctree.div[1]==0.0f) MeshOctree.div[1]= 1.0f; + if (MeshOctree.div[2]==0.0f) MeshOctree.div[2]= 1.0f; - if(MeshOctree.table) /* happens when entering this call without ending it */ + if (MeshOctree.table) /* happens when entering this call without ending it */ mesh_octree_table(ob, em, co, 'e'); MeshOctree.table= MEM_callocN(MOC_RES*MOC_RES*MOC_RES*sizeof(void *), "sym table"); - if(em && me->edit_btmesh==em) { + if (em && me->edit_btmesh==em) { BMVert *eve; BMIter iter; @@ -846,16 +846,16 @@ intptr_t mesh_octree_table(Object *ob, BMEditMesh *em, float *co, char mode) MVert *mvert; int a; - for(a=0, mvert= me->mvert; atotvert; a++, mvert++) + for (a=0, mvert= me->mvert; atotvert; a++, mvert++) mesh_octree_add_nodes(MeshOctree.table, mvert->co, MeshOctree.offs, MeshOctree.div, a+1); } } - else if(mode=='e') { /* end table */ - if(MeshOctree.table) { + else if (mode=='e') { /* end table */ + if (MeshOctree.table) { int a; - for(a=0, bt=MeshOctree.table; adata, ob->mode, &mesh_topo_store)) { mesh_mirrtopo_table(ob, 's'); } } - else if(mode=='s') { /* start table */ + else if (mode=='s') { /* start table */ ED_mesh_mirrtopo_init(ob->data, ob->mode, &mesh_topo_store, FALSE); } - else if(mode=='e') { /* end table */ + else if (mode=='e') { /* end table */ ED_mesh_mirrtopo_free(&mesh_topo_store); } return 0; @@ -911,7 +911,8 @@ int mesh_get_x_mirror_vert(Object *ob, int index) { if (((Mesh *)ob->data)->editflag & ME_EDIT_MIRROR_TOPO) { return mesh_get_x_mirror_vert_topo(ob, index); - } else { + } + else { return mesh_get_x_mirror_vert_spacial(ob, index); } return 0; @@ -934,7 +935,7 @@ static BMVert *editbmesh_get_x_mirror_vert_spacial(Object *ob, BMEditMesh *em, f vec[2]= co[2]; poinval= mesh_octree_table(ob, em, vec, 'u'); - if(poinval != -1) + if (poinval != -1) return (BMVert *)(poinval); return NULL; } @@ -963,7 +964,7 @@ static BMVert *editbmesh_get_x_mirror_vert_topo(Object *ob, struct BMEditMesh *e poinval= mesh_topo_store.index_lookup[index]; - if(poinval != -1) + if (poinval != -1) return (BMVert *)(poinval); return NULL; } @@ -998,7 +999,8 @@ static float *editmesh_get_mirror_uv(BMEditMesh *em, int axis, float *uv, float cent_vec[0] = face_cent[0]; cent_vec[1]= -((face_cent[1])-mirrCent[1]) + mirrCent[1]; - } else { + } + else { vec[0]= -((uv[0])-mirrCent[0]) + mirrCent[0]; vec[1]= uv[1]; @@ -1039,7 +1041,7 @@ static unsigned int mirror_facehash(const void *ptr) const MFace *mf= ptr; int v0, v1; - if(mf->v4) { + if (mf->v4) { v0= MIN4(mf->v1, mf->v2, mf->v3, mf->v4); v1= MAX4(mf->v1, mf->v2, mf->v3, mf->v4); } @@ -1053,22 +1055,22 @@ static unsigned int mirror_facehash(const void *ptr) static int mirror_facerotation(MFace *a, MFace *b) { - if(b->v4) { - if(a->v1==b->v1 && a->v2==b->v2 && a->v3==b->v3 && a->v4==b->v4) + if (b->v4) { + if (a->v1==b->v1 && a->v2==b->v2 && a->v3==b->v3 && a->v4==b->v4) return 0; - else if(a->v4==b->v1 && a->v1==b->v2 && a->v2==b->v3 && a->v3==b->v4) + else if (a->v4==b->v1 && a->v1==b->v2 && a->v2==b->v3 && a->v3==b->v4) return 1; - else if(a->v3==b->v1 && a->v4==b->v2 && a->v1==b->v3 && a->v2==b->v4) + else if (a->v3==b->v1 && a->v4==b->v2 && a->v1==b->v3 && a->v2==b->v4) return 2; - else if(a->v2==b->v1 && a->v3==b->v2 && a->v4==b->v3 && a->v1==b->v4) + else if (a->v2==b->v1 && a->v3==b->v2 && a->v4==b->v3 && a->v1==b->v4) return 3; } else { - if(a->v1==b->v1 && a->v2==b->v2 && a->v3==b->v3) + if (a->v1==b->v1 && a->v2==b->v2 && a->v3==b->v3) return 0; - else if(a->v3==b->v1 && a->v1==b->v2 && a->v2==b->v3) + else if (a->v3==b->v1 && a->v1==b->v2 && a->v2==b->v3) return 1; - else if(a->v2==b->v1 && a->v3==b->v2 && a->v1==b->v3) + else if (a->v2==b->v1 && a->v3==b->v2 && a->v1==b->v3) return 2; } @@ -1095,29 +1097,29 @@ int *mesh_get_x_mirror_faces(Object *ob, BMEditMesh *em) mesh_octree_table(ob, em, NULL, 's'); - for(a=0, mv=mvert; atotvert; a++, mv++) + for (a=0, mv=mvert; atotvert; a++, mv++) mirrorverts[a]= mesh_get_x_mirror_vert(ob, a); mesh_octree_table(ob, em, NULL, 'e'); fhash= BLI_ghash_new(mirror_facehash, mirror_facecmp, "mirror_facehash gh"); - for(a=0, mf=mface; atotface; a++, mf++) + for (a=0, mf=mface; atotface; a++, mf++) BLI_ghash_insert(fhash, mf, mf); - for(a=0, mf=mface; atotface; a++, mf++) { + for (a=0, mf=mface; atotface; a++, mf++) { mirrormf.v1= mirrorverts[mf->v3]; mirrormf.v2= mirrorverts[mf->v2]; mirrormf.v3= mirrorverts[mf->v1]; mirrormf.v4= (mf->v4)? mirrorverts[mf->v4]: 0; /* make sure v4 is not 0 if a quad */ - if(mf->v4 && mirrormf.v4==0) { + if (mf->v4 && mirrormf.v4==0) { SWAP(unsigned int, mirrormf.v1, mirrormf.v3); SWAP(unsigned int, mirrormf.v2, mirrormf.v4); } hashmf= BLI_ghash_lookup(fhash, &mirrormf); - if(hashmf) { + if (hashmf) { mirrorfaces[a*2]= hashmf - mface; mirrorfaces[a*2+1]= mirror_facerotation(&mirrormf, hashmf); } diff --git a/source/blender/editors/metaball/mball_edit.c b/source/blender/editors/metaball/mball_edit.c index 7e1be0dae5c..713009d2a19 100644 --- a/source/blender/editors/metaball/mball_edit.c +++ b/source/blender/editors/metaball/mball_edit.c @@ -82,8 +82,8 @@ void make_editMball(Object *obedit) ml= mb->elems.first; - while(ml) { - if(ml->flag & SELECT) mb->lastelem = ml; + while (ml) { + if (ml->flag & SELECT) mb->lastelem = ml; ml= ml->next; } @@ -106,7 +106,7 @@ MetaElem *add_metaball_primitive(bContext *C, float mat[4][4], int type, int UNU /* Deselect all existing metaelems */ ml= mball->editelems->first; - while(ml) { + while (ml) { ml->flag &= ~SELECT; ml= ml->next; } @@ -131,11 +131,11 @@ static int mball_select_all_exec(bContext *C, wmOperator *op) int action = RNA_enum_get(op->ptr, "action"); ml= mb->editelems->first; - if(ml) { + if (ml) { if (action == SEL_TOGGLE) { action = SEL_SELECT; - while(ml) { - if(ml->flag & SELECT) { + while (ml) { + if (ml->flag & SELECT) { action = SEL_DESELECT; break; } @@ -144,7 +144,7 @@ static int mball_select_all_exec(bContext *C, wmOperator *op) } ml= mb->editelems->first; - while(ml) { + while (ml) { switch (action) { case SEL_SELECT: ml->flag |= SELECT; @@ -191,15 +191,15 @@ static int select_random_metaelems_exec(bContext *C, wmOperator *op) MetaElem *ml; float percent= RNA_float_get(op->ptr, "percent"); - if(percent == 0.0f) + if (percent == 0.0f) return OPERATOR_CANCELLED; ml= mb->editelems->first; BLI_srand( BLI_rand() ); /* Random seed */ /* Stupid version of random selection. Should be improved. */ - while(ml) { - if(BLI_frand() < percent) + while (ml) { + if (BLI_frand() < percent) ml->flag |= SELECT; else ml->flag &= ~SELECT; @@ -241,9 +241,9 @@ static int duplicate_metaelems_exec(bContext *C, wmOperator *UNUSED(op)) MetaElem *ml, *newml; ml= mb->editelems->last; - if(ml) { - while(ml) { - if(ml->flag & SELECT) { + if (ml) { + while (ml) { + if (ml->flag & SELECT) { newml= MEM_dupallocN(ml); BLI_addtail(mb->editelems, newml); mb->lastelem= newml; @@ -300,11 +300,11 @@ static int delete_metaelems_exec(bContext *C, wmOperator *UNUSED(op)) MetaElem *ml, *next; ml= mb->editelems->first; - if(ml) { - while(ml) { + if (ml) { + while (ml) { next= ml->next; - if(ml->flag & SELECT) { - if(mb->lastelem==ml) mb->lastelem= NULL; + if (ml->flag & SELECT) { + if (mb->lastelem==ml) mb->lastelem= NULL; BLI_remlink(mb->editelems, ml); MEM_freeN(ml); } @@ -344,9 +344,9 @@ static int hide_metaelems_exec(bContext *C, wmOperator *op) ml= mb->editelems->first; - if(ml) { - while(ml) { - if((ml->flag & SELECT) != invert) + if (ml) { + while (ml) { + if ((ml->flag & SELECT) != invert) ml->flag |= MB_HIDE; ml= ml->next; } @@ -386,8 +386,8 @@ static int reveal_metaelems_exec(bContext *C, wmOperator *UNUSED(op)) ml= mb->editelems->first; - if(ml) { - while(ml) { + if (ml) { + while (ml) { ml->flag &= ~MB_HIDE; ml= ml->next; } @@ -437,40 +437,40 @@ int mouse_mball(bContext *C, const int mval[2], int extend) /* does startelem exist? */ ml= mb->editelems->first; - while(ml) { - if(ml==startelem) break; + while (ml) { + if (ml==startelem) break; ml= ml->next; } - if(ml==NULL) startelem= mb->editelems->first; + if (ml==NULL) startelem= mb->editelems->first; - if(hits>0) { + if (hits>0) { ml= startelem; - while(ml) { - for(a=0; aselcol1==buffer[ 4 * a + 3 ]) { + if (ml->selcol1==buffer[ 4 * a + 3 ]) { ml->flag |= MB_SCALE_RAD; act= ml; } - if(ml->selcol2==buffer[ 4 * a + 3 ]) { + if (ml->selcol2==buffer[ 4 * a + 3 ]) { ml->flag &= ~MB_SCALE_RAD; act= ml; } } - if(act) break; + if (act) break; ml= ml->next; - if(ml==NULL) ml= mb->editelems->first; - if(ml==startelem) break; + if (ml==NULL) ml= mb->editelems->first; + if (ml==startelem) break; } /* When some metaelem was found, then it is necessary to select or * deselect it. */ - if(act) { - if(extend==0) { + if (act) { + if (extend==0) { /* Deselect all existing metaelems */ ml= mb->editelems->first; - while(ml) { + while (ml) { ml->flag &= ~SELECT; ml= ml->next; } @@ -478,7 +478,7 @@ int mouse_mball(bContext *C, const int mval[2], int extend) act->flag |= SELECT; } else { - if(act->flag & SELECT) + if (act->flag & SELECT) act->flag &= ~SELECT; else act->flag |= SELECT; @@ -502,10 +502,10 @@ static void freeMetaElemlist(ListBase *lb) { MetaElem *ml, *next; - if(lb==NULL) return; + if (lb==NULL) return; ml= lb->first; - while(ml) { + while (ml) { next= ml->next; BLI_remlink(lb, ml); MEM_freeN(ml); @@ -526,7 +526,7 @@ static void undoMball_to_editMball(void *lbu, void *lbe, void *UNUSED(obe)) /* copy 'undo' MetaElems to 'edit' MetaElems */ ml= lb->first; - while(ml) { + while (ml) { newml= MEM_dupallocN(ml); BLI_addtail(editelems, newml); ml= ml->next; @@ -546,7 +546,7 @@ static void *editMball_to_undoMball(void *lbe, void *UNUSED(obe)) /* copy contents of current ListBase to the undo ListBase */ ml= editelems->first; - while(ml) { + while (ml) { newml= MEM_dupallocN(ml); BLI_addtail(lb, newml); ml= ml->next; @@ -566,7 +566,7 @@ static void free_undoMball(void *lbv) static ListBase *metaball_get_editelems(Object *ob) { - if(ob && ob->type==OB_MBALL) { + if (ob && ob->type==OB_MBALL) { struct MetaBall *mb= (struct MetaBall*)ob->data; return mb->editelems; } diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c index 8a8ce53c1d5..22ecf6198d7 100644 --- a/source/blender/editors/object/object_add.c +++ b/source/blender/editors/object/object_add.c @@ -123,7 +123,7 @@ void ED_object_location_from_view(bContext *C, float *loc) void ED_object_rotation_from_view(bContext *C, float *rot) { RegionView3D *rv3d= CTX_wm_region_view3d(C); - if(rv3d) { + if (rv3d) { float quat[4]; copy_qt_qt(quat, rv3d->viewquat); quat[0]= -quat[0]; @@ -174,7 +174,7 @@ float ED_object_new_primitive_matrix(bContext *C, Object *obedit, float *loc, fl invert_m3_m3(imat, mat); mul_m3_v3(imat, primmat[3]); - if(v3d) return v3d->grid; + if (v3d) return v3d->grid; return 1.0f; } @@ -193,7 +193,7 @@ void ED_object_add_generic_props(wmOperatorType *ot, int do_editmode) prop = RNA_def_boolean(ot->srna, "view_align", 0, "Align to View", "Align the new object to the view"); RNA_def_property_update_runtime(prop, view_align_update); - if(do_editmode) { + if (do_editmode) { prop = RNA_def_boolean(ot->srna, "enter_editmode", 0, "Enter Editmode", "Enter editmode when adding this object"); RNA_def_property_flag(prop, PROP_HIDDEN|PROP_SKIP_SAVE); @@ -212,23 +212,23 @@ void ED_object_add_generic_props(wmOperatorType *ot, int do_editmode) static void object_add_generic_invoke_options(bContext *C, wmOperator *op) { - if(RNA_struct_find_property(op->ptr, "enter_editmode")) /* optional */ + if (RNA_struct_find_property(op->ptr, "enter_editmode")) /* optional */ if (!RNA_struct_property_is_set(op->ptr, "enter_editmode")) RNA_boolean_set(op->ptr, "enter_editmode", U.flag & USER_ADD_EDITMODE); - if(!RNA_struct_property_is_set(op->ptr, "location")) { + if (!RNA_struct_property_is_set(op->ptr, "location")) { float loc[3]; ED_object_location_from_view(C, loc); RNA_float_set_array(op->ptr, "location", loc); } - if(!RNA_struct_property_is_set(op->ptr, "layers")) { + if (!RNA_struct_property_is_set(op->ptr, "layers")) { View3D *v3d = CTX_wm_view3d(C); Scene *scene = CTX_data_scene(C); int a, values[20], layer; - if(v3d) { + if (v3d) { layer = (v3d->scenelock && !v3d->localvd)? scene->layact: v3d->layact; } else { @@ -257,15 +257,15 @@ int ED_object_add_generic_get_opts(bContext *C, wmOperator *op, float *loc, int view_align; *enter_editmode = FALSE; - if(RNA_struct_find_property(op->ptr, "enter_editmode") && RNA_boolean_get(op->ptr, "enter_editmode")) { + if (RNA_struct_find_property(op->ptr, "enter_editmode") && RNA_boolean_get(op->ptr, "enter_editmode")) { *enter_editmode = TRUE; } - if(RNA_struct_property_is_set(op->ptr, "layers")) { + if (RNA_struct_property_is_set(op->ptr, "layers")) { RNA_boolean_get_array(op->ptr, "layers", layer_values); *layer= 0; - for(a=0; a<20; a++) { - if(layer_values[a]) + for (a=0; a<20; a++) { + if (layer_values[a]) *layer |= (1 << a); else *layer &= ~(1 << a); @@ -279,10 +279,10 @@ int ED_object_add_generic_get_opts(bContext *C, wmOperator *op, float *loc, /* in local view we additionally add local view layers, * not part of operator properties */ - if(v3d && v3d->localvd) + if (v3d && v3d->localvd) *layer |= v3d->lay; - if(RNA_struct_property_is_set(op->ptr, "rotation")) + if (RNA_struct_property_is_set(op->ptr, "rotation")) view_align = FALSE; else if (RNA_struct_property_is_set(op->ptr, "view_align")) view_align = RNA_boolean_get(op->ptr, "view_align"); @@ -303,7 +303,7 @@ int ED_object_add_generic_get_opts(bContext *C, wmOperator *op, float *loc, RNA_float_get_array(op->ptr, "location", loc); - if(*layer == 0) { + if (*layer == 0) { BKE_report(op->reports, RPT_ERROR, "Property 'layer' has no values set"); return 0; } @@ -339,7 +339,7 @@ Object *ED_object_add_type(bContext *C, int type, float *loc, float *rot, ED_render_id_flush_update(bmain, ob->data); } - if(enter_editmode) + if (enter_editmode) ED_object_enter_editmode(C, EM_IGNORE_LAYER); WM_event_add_notifier(C, NC_SCENE|ND_LAYER_CONTENT, scene); @@ -354,7 +354,7 @@ static int object_add_exec(bContext *C, wmOperator *op) unsigned int layer; float loc[3], rot[3]; - if(!ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer, NULL)) + if (!ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer, NULL)) return OPERATOR_CANCELLED; ED_object_add_type(C, RNA_enum_get(op->ptr, "type"), loc, rot, enter_editmode, layer); @@ -411,10 +411,10 @@ static Object *effector_add_type(bContext *C, wmOperator *op, int type) object_add_generic_invoke_options(C, op); - if(!ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer, NULL)) + if (!ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer, NULL)) return NULL; - if(type==PFIELD_GUIDE) { + if (type==PFIELD_GUIDE) { ob= ED_object_add_type(C, OB_CURVE, loc, rot, FALSE, layer); rename_id(&ob->id, "CurveGuide"); @@ -423,7 +423,7 @@ static Object *effector_add_type(bContext *C, wmOperator *op, int type) ED_object_new_primitive_matrix(C, ob, loc, rot, mat); BLI_addtail(object_editcurve_get(ob), add_nurbs_primitive(C, mat, CU_NURBS|CU_PRIM_PATH, 1)); - if(!enter_editmode) + if (!enter_editmode) ED_object_exit_editmode(C, EM_FREEDATA); } else { @@ -448,7 +448,7 @@ static Object *effector_add_type(bContext *C, wmOperator *op, int type) /* for object add operator */ static int effector_add_exec(bContext *C, wmOperator *op) { - if(effector_add_type(C, op, RNA_enum_get(op->ptr, "type")) == NULL) + if (effector_add_type(C, op, RNA_enum_get(op->ptr, "type")) == NULL) return OPERATOR_CANCELLED; return OPERATOR_FINISHED; @@ -491,7 +491,7 @@ static int object_camera_add_exec(bContext *C, wmOperator *op) object_add_generic_invoke_options(C, op); - if(!ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer, NULL)) + if (!ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer, NULL)) return OPERATOR_CANCELLED; ob= ED_object_add_type(C, OB_CAMERA, loc, rot, FALSE, layer); @@ -545,10 +545,10 @@ static int object_metaball_add_exec(bContext *C, wmOperator *op) object_add_generic_invoke_options(C, op); // XXX these props don't get set right when only exec() is called - if(!ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer, NULL)) + if (!ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer, NULL)) return OPERATOR_CANCELLED; - if(obedit==NULL || obedit->type!=OB_MBALL) { + if (obedit==NULL || obedit->type!=OB_MBALL) { obedit= ED_object_add_type(C, OB_MBALL, loc, rot, TRUE, layer); newob = 1; } @@ -578,7 +578,7 @@ static int object_metaball_add_invoke(bContext *C, wmOperator *op, wmEvent *UNUS pup= uiPupMenuBegin(C, op->type->name, ICON_NONE); layout= uiPupMenuLayout(pup); - if(!obedit || obedit->type == OB_MBALL) + if (!obedit || obedit->type == OB_MBALL) uiItemsEnumO(layout, op->type->idname, "type"); else uiItemsEnumO(layout, "OBJECT_OT_metaball_add", "type"); @@ -614,10 +614,10 @@ static int object_add_text_exec(bContext *C, wmOperator *op) float loc[3], rot[3]; object_add_generic_invoke_options(C, op); // XXX these props don't get set right when only exec() is called - if(!ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer, NULL)) + if (!ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer, NULL)) return OPERATOR_CANCELLED; - if(obedit && obedit->type==OB_FONT) + if (obedit && obedit->type==OB_FONT) return OPERATOR_CANCELLED; obedit= ED_object_add_type(C, OB_FONT, loc, rot, enter_editmode, layer); @@ -655,7 +655,7 @@ static int object_armature_add_exec(bContext *C, wmOperator *op) float loc[3], rot[3]; object_add_generic_invoke_options(C, op); // XXX these props don't get set right when only exec() is called - if(!ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer, NULL)) + if (!ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer, NULL)) return OPERATOR_CANCELLED; if ((obedit==NULL) || (obedit->type != OB_ARMATURE)) { @@ -665,7 +665,7 @@ static int object_armature_add_exec(bContext *C, wmOperator *op) } else DAG_id_tag_update(&obedit->id, OB_RECALC_DATA); - if(obedit==NULL) { + if (obedit==NULL) { BKE_report(op->reports, RPT_ERROR, "Cannot create editmode armature"); return OPERATOR_CANCELLED; } @@ -723,7 +723,7 @@ static int object_lamp_add_exec(bContext *C, wmOperator *op) float loc[3], rot[3]; object_add_generic_invoke_options(C, op); - if(!ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer, NULL)) + if (!ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer, NULL)) return OPERATOR_CANCELLED; ob= ED_object_add_type(C, OB_LAMP, loc, rot, FALSE, layer); @@ -733,7 +733,7 @@ static int object_lamp_add_exec(bContext *C, wmOperator *op) rename_id(&ob->id, get_lamp_defname(type)); rename_id(&la->id, get_lamp_defname(type)); - if(scene_use_new_shading_nodes(scene)) { + if (scene_use_new_shading_nodes(scene)) { ED_node_shader_default(scene, &la->id); la->use_nodes= 1; } @@ -779,10 +779,10 @@ static int group_instance_add_exec(bContext *C, wmOperator *op) float loc[3], rot[3]; object_add_generic_invoke_options(C, op); - if(!ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer, NULL)) + if (!ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer, NULL)) return OPERATOR_CANCELLED; - if(group) { + if (group) { Main *bmain= CTX_data_main(C); Scene *scene= CTX_data_scene(C); Object *ob= ED_object_add_type(C, OB_EMPTY, loc, rot, FALSE, layer); @@ -811,7 +811,7 @@ static int object_speaker_add_exec(bContext *C, wmOperator *op) Scene *scene = CTX_data_scene(C); object_add_generic_invoke_options(C, op); - if(!ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer, NULL)) + if (!ED_object_add_generic_get_opts(C, op, loc, rot, &enter_editmode, &layer, NULL)) return OPERATOR_CANCELLED; ob= ED_object_add_type(C, OB_SPEAKER, loc, rot, FALSE, layer); @@ -892,7 +892,7 @@ void ED_base_object_free_and_unlink(Main *bmain, Scene *scene, Base *base) DAG_id_type_tag(bmain, ID_OB); BLI_remlink(&scene->base, base); free_libblock_us(&bmain->object, base->object); - if(scene->basact==base) scene->basact= NULL; + if (scene->basact==base) scene->basact= NULL; MEM_freeN(base); } @@ -903,7 +903,7 @@ static int object_delete_exec(bContext *C, wmOperator *op) const short use_global= RNA_boolean_get(op->ptr, "use_global"); /* int islamp= 0; */ /* UNUSED */ - if(CTX_data_edit_object(C)) + if (CTX_data_edit_object(C)) return OPERATOR_CANCELLED; CTX_DATA_BEGIN(C, Base*, base, selected_bases) { @@ -978,18 +978,18 @@ static void copy_object_set_idnew(bContext *C, int dupflag) CTX_DATA_END; /* materials */ - if( dupflag & USER_DUP_MAT) { + if ( dupflag & USER_DUP_MAT) { mao= bmain->mat.first; - while(mao) { - if(mao->id.newid) { + while (mao) { + if (mao->id.newid) { ma= (Material *)mao->id.newid; - if(dupflag & USER_DUP_TEX) { - for(a=0; amtex[a]) { + if (dupflag & USER_DUP_TEX) { + for (a=0; amtex[a]) { id= (ID *)ma->mtex[a]->tex; - if(id) { + if (id) { ID_NEW_US(ma->mtex[a]->tex) else ma->mtex[a]->tex= copy_texture(ma->mtex[a]->tex); id->us--; @@ -999,7 +999,7 @@ static void copy_object_set_idnew(bContext *C, int dupflag) } #if 0 // XXX old animation system id= (ID *)ma->ipo; - if(id) { + if (id) { ID_NEW_US(ma->ipo) else ma->ipo= copy_ipo(ma->ipo); id->us--; @@ -1012,13 +1012,13 @@ static void copy_object_set_idnew(bContext *C, int dupflag) #if 0 // XXX old animation system /* lamps */ - if( dupflag & USER_DUP_IPO) { + if ( dupflag & USER_DUP_IPO) { Lamp *la= bmain->lamp.first; - while(la) { - if(la->id.newid) { + while (la) { + if (la->id.newid) { Lamp *lan= (Lamp *)la->id.newid; id= (ID *)lan->ipo; - if(id) { + if (id) { ID_NEW_US(lan->ipo) else lan->ipo= copy_ipo(lan->ipo); id->us--; @@ -1030,12 +1030,12 @@ static void copy_object_set_idnew(bContext *C, int dupflag) /* ipos */ ipo= bmain->ipo.first; - while(ipo) { - if(ipo->id.lib==NULL && ipo->id.newid) { + while (ipo) { + if (ipo->id.lib==NULL && ipo->id.newid) { Ipo *ipon= (Ipo *)ipo->id.newid; IpoCurve *icu; - for(icu= ipon->curve.first; icu; icu= icu->next) { - if(icu->driver) { + for (icu= ipon->curve.first; icu; icu= icu->next) { + if (icu->driver) { ID_NEW(icu->driver->ob); } } @@ -1059,23 +1059,23 @@ static void make_object_duplilist_real(bContext *C, Scene *scene, Base *base, DupliObject *dob; GHash *dupli_gh= NULL, *parent_gh= NULL; - if(!(base->object->transflag & OB_DUPLI)) + if (!(base->object->transflag & OB_DUPLI)) return; lb= object_duplilist(scene, base->object); - if(use_hierarchy || use_base_parent) { + if (use_hierarchy || use_base_parent) { dupli_gh= BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, "make_object_duplilist_real dupli_gh"); parent_gh= BLI_ghash_new(BLI_ghashutil_pairhash, BLI_ghashutil_paircmp, "make_object_duplilist_real parent_gh"); } - for(dob= lb->first; dob; dob= dob->next) { + for (dob= lb->first; dob; dob= dob->next) { Base *basen; Object *ob= copy_object(dob->ob); /* font duplis can have a totcol without material, we get them from parent * should be implemented better... */ - if(ob->mat==NULL) ob->totcol= 0; + if (ob->mat==NULL) ob->totcol= 0; basen= MEM_dupallocN(base); basen->flag &= ~(OB_FROMDUPLI|OB_FROMGROUP); @@ -1097,14 +1097,14 @@ static void make_object_duplilist_real(bContext *C, Scene *scene, Base *base, copy_m4_m4(ob->obmat, dob->mat); object_apply_mat4(ob, ob->obmat, FALSE, FALSE); - if(dupli_gh) + if (dupli_gh) BLI_ghash_insert(dupli_gh, dob, ob); - if(parent_gh) + if (parent_gh) BLI_ghash_insert(parent_gh, BLI_ghashutil_pairalloc(dob->ob, dob->index), ob); } if (use_hierarchy) { - for(dob= lb->first; dob; dob= dob->next) { + for (dob= lb->first; dob; dob= dob->next) { /* original parents */ Object *ob_src= dob->ob; Object *ob_src_par= ob_src->parent; @@ -1113,7 +1113,7 @@ static void make_object_duplilist_real(bContext *C, Scene *scene, Base *base, Object *ob_dst_par= NULL; /* find parent that was also made real */ - if(ob_src_par) { + if (ob_src_par) { GHashPair *pair = BLI_ghashutil_pairalloc(ob_src_par, dob->index); ob_dst_par = BLI_ghash_lookup(parent_gh, pair); BLI_ghashutil_pairfree(pair); @@ -1151,7 +1151,7 @@ static void make_object_duplilist_real(bContext *C, Scene *scene, Base *base, else if (use_base_parent) { /* since we are ignoring the internal hierarchy - parent all to the * base object */ - for(dob= lb->first; dob; dob= dob->next) { + for (dob= lb->first; dob; dob= dob->next) { /* original parents */ Object *ob_dst= BLI_ghash_lookup(dupli_gh, dob); @@ -1167,9 +1167,9 @@ static void make_object_duplilist_real(bContext *C, Scene *scene, Base *base, } } - if(dupli_gh) + if (dupli_gh) BLI_ghash_free(dupli_gh, NULL, NULL); - if(parent_gh) + if (parent_gh) BLI_ghash_free(parent_gh, BLI_ghashutil_pairfree, NULL); copy_object_set_idnew(C, 0); @@ -1234,12 +1234,12 @@ static EnumPropertyItem convert_target_items[]= { static void curvetomesh(Scene *scene, Object *ob) { - if(ob->disp.first == NULL) + if (ob->disp.first == NULL) makeDispListCurveTypes(scene, ob, 0); /* force creation */ nurbs_to_mesh(ob); /* also does users */ - if(ob->type == OB_MESH) + if (ob->type == OB_MESH) object_free_modifiers(ob); } @@ -1299,7 +1299,7 @@ static int convert_exec(bContext *C, wmOperator *op) ob->flag &= ~OB_DONE; /* flag data thats not been edited (only needed for !keep_original) */ - if(ob->data) { + if (ob->data) { ((ID *)ob->data)->flag |= LIB_DOIT; } } @@ -1308,17 +1308,17 @@ static int convert_exec(bContext *C, wmOperator *op) CTX_DATA_BEGIN(C, Base*, base, selected_editable_bases) { ob= base->object; - if(ob->flag & OB_DONE || !IS_TAGGED(ob->data)) { + if (ob->flag & OB_DONE || !IS_TAGGED(ob->data)) { if (ob->type != target) { base->flag &= ~SELECT; ob->flag &= ~SELECT; } /* obdata already modified */ - if(!IS_TAGGED(ob->data)) { + if (!IS_TAGGED(ob->data)) { /* When 2 objects with linked data are selected, converting both * would keep modifiers on all but the converted object [#26003] */ - if(ob->type == OB_MESH) { + if (ob->type == OB_MESH) { object_free_modifiers(ob); /* after derivedmesh calls! */ } } @@ -1336,16 +1336,17 @@ static int convert_exec(bContext *C, wmOperator *op) /* make a new copy of the mesh */ newob->data= copy_mesh(me); - } else { + } + else { newob = ob; } mesh_to_curve(scene, newob); - if(newob->type==OB_CURVE) + if (newob->type==OB_CURVE) object_free_modifiers(newob); /* after derivedmesh calls! */ } - else if(ob->type==OB_MESH && ob->modifiers.first) { /* converting a mesh with no modifiers causes a segfault */ + else if (ob->type==OB_MESH && ob->modifiers.first) { /* converting a mesh with no modifiers causes a segfault */ ob->flag |= OB_DONE; if (keep_original) { @@ -1358,7 +1359,8 @@ static int convert_exec(bContext *C, wmOperator *op) /* make a new copy of the mesh */ newob->data= copy_mesh(me); - } else { + } + else { newob = ob; ob->recalc |= OB_RECALC_OB|OB_RECALC_DATA|OB_RECALC_TIME; } @@ -1377,7 +1379,7 @@ static int convert_exec(bContext *C, wmOperator *op) dm->release(dm); object_free_modifiers(newob); /* after derivedmesh calls! */ } - else if(ob->type==OB_FONT) { + else if (ob->type==OB_FONT) { ob->flag |= OB_DONE; if (keep_original) { @@ -1389,7 +1391,8 @@ static int convert_exec(bContext *C, wmOperator *op) /* make a new copy of the curve */ newob->data= copy_curve(ob->data); - } else { + } + else { newob= ob; } @@ -1401,28 +1404,28 @@ static int convert_exec(bContext *C, wmOperator *op) newob->type= OB_CURVE; cu->type= OB_CURVE; - if(cu->vfont) { + if (cu->vfont) { cu->vfont->id.us--; cu->vfont= NULL; } - if(cu->vfontb) { + if (cu->vfontb) { cu->vfontb->id.us--; cu->vfontb= NULL; } - if(cu->vfonti) { + if (cu->vfonti) { cu->vfonti->id.us--; cu->vfonti= NULL; } - if(cu->vfontbi) { + if (cu->vfontbi) { cu->vfontbi->id.us--; cu->vfontbi= NULL; } if (!keep_original) { /* other users */ - if(cu->id.us>1) { - for(ob1= bmain->object.first; ob1; ob1=ob1->id.next) { - if(ob1->data==ob->data) { + if (cu->id.us>1) { + for (ob1= bmain->object.first; ob1; ob1=ob1->id.next) { + if (ob1->data==ob->data) { ob1->type= OB_CURVE; ob1->recalc |= OB_RECALC_OB|OB_RECALC_DATA|OB_RECALC_TIME; } @@ -1430,20 +1433,20 @@ static int convert_exec(bContext *C, wmOperator *op) } } - for(nu=cu->nurb.first; nu; nu=nu->next) + for (nu=cu->nurb.first; nu; nu=nu->next) nu->charidx= 0; - if(target == OB_MESH) { + if (target == OB_MESH) { curvetomesh(scene, newob); /* meshes doesn't use displist */ freedisplist(&newob->disp); } } - else if(ELEM(ob->type, OB_CURVE, OB_SURF)) { + else if (ELEM(ob->type, OB_CURVE, OB_SURF)) { ob->flag |= OB_DONE; - if(target == OB_MESH) { + if (target == OB_MESH) { if (keep_original) { basen= duplibase_for_convert(scene, base, NULL); newob= basen->object; @@ -1453,7 +1456,8 @@ static int convert_exec(bContext *C, wmOperator *op) /* make a new copy of the curve */ newob->data= copy_curve(ob->data); - } else { + } + else { newob= ob; /* meshes doesn't use displist */ @@ -1463,7 +1467,7 @@ static int convert_exec(bContext *C, wmOperator *op) curvetomesh(scene, newob); } } - else if(ob->type==OB_MBALL && target == OB_MESH) { + else if (ob->type==OB_MBALL && target == OB_MESH) { Object *baseob; base->flag &= ~SELECT; @@ -1480,7 +1484,7 @@ static int convert_exec(bContext *C, wmOperator *op) makeDispListMBall(scene, baseob); } - if(!(baseob->flag & OB_DONE)) { + if (!(baseob->flag & OB_DONE)) { baseob->flag |= OB_DONE; basen= duplibase_for_convert(scene, base, baseob); @@ -1494,9 +1498,9 @@ static int convert_exec(bContext *C, wmOperator *op) me= newob->data; me->totcol= mb->totcol; - if(newob->totcol) { + if (newob->totcol) { me->mat= MEM_dupallocN(mb->mat); - for(a=0; atotcol; a++) id_us_plus((ID *)me->mat[a]); + for (a=0; atotcol; a++) id_us_plus((ID *)me->mat[a]); } mball_to_mesh(&baseob->disp, newob->data); @@ -1515,8 +1519,8 @@ static int convert_exec(bContext *C, wmOperator *op) /* tag obdata if it was been changed */ /* If the original object is active then make this object active */ - if(basen) { - if(ob == obact) { + if (basen) { + if (ob == obact) { /* store new active base to update BASACT */ basact= basen; } @@ -1530,8 +1534,8 @@ static int convert_exec(bContext *C, wmOperator *op) } /* delete original if needed */ - if(basedel) { - if(!keep_original) + if (basedel) { + if (!keep_original) ED_base_object_free_and_unlink(bmain, scene, basedel); basedel = NULL; @@ -1539,7 +1543,7 @@ static int convert_exec(bContext *C, wmOperator *op) } CTX_DATA_END; - if(!keep_original) { + if (!keep_original) { if (mballConverted) { Base *base= scene->base.first, *tmpbase; while (base) { @@ -1564,7 +1568,8 @@ static int convert_exec(bContext *C, wmOperator *op) /* active base was changed */ ED_base_object_activate(C, basact); BASACT= basact; - } else if (BASACT->object->flag & OB_DONE) { + } + else if (BASACT->object->flag & OB_DONE) { WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, BASACT->object); WM_event_add_notifier(C, NC_OBJECT|ND_DATA, BASACT->object); } @@ -1616,7 +1621,7 @@ static Base *object_add_duplicate_internal(Main *bmain, Scene *scene, Base *base int a, didit; ob= base->object; - if(ob->mode & OB_MODE_POSE) { + if (ob->mode & OB_MODE_POSE) { ; /* nothing? */ } else { @@ -1628,42 +1633,42 @@ static Base *object_add_duplicate_internal(Main *bmain, Scene *scene, Base *base BLI_addhead(&scene->base, basen); /* addhead: prevent eternal loop */ basen->object= obn; - if(basen->flag & OB_FROMGROUP) { + if (basen->flag & OB_FROMGROUP) { Group *group; - for(group= bmain->group.first; group; group= group->id.next) { - if(object_in_group(ob, group)) + for (group= bmain->group.first; group; group= group->id.next) { + if (object_in_group(ob, group)) add_to_group(group, obn, scene, basen); } } /* duplicates using userflags */ - if(dupflag & USER_DUP_ACT) { + if (dupflag & USER_DUP_ACT) { BKE_copy_animdata_id_action(&obn->id); } - if(dupflag & USER_DUP_MAT) { - for(a=0; atotcol; a++) { + if (dupflag & USER_DUP_MAT) { + for (a=0; atotcol; a++) { id= (ID *)obn->mat[a]; - if(id) { + if (id) { ID_NEW_US(obn->mat[a]) else obn->mat[a]= copy_material(obn->mat[a]); id->us--; - if(dupflag & USER_DUP_ACT) { + if (dupflag & USER_DUP_ACT) { BKE_copy_animdata_id_action(&obn->mat[a]->id); } } } } - if(dupflag & USER_DUP_PSYS) { + if (dupflag & USER_DUP_PSYS) { ParticleSystem *psys; - for(psys=obn->particlesystem.first; psys; psys=psys->next) { + for (psys=obn->particlesystem.first; psys; psys=psys->next) { id= (ID*) psys->part; - if(id) { + if (id) { ID_NEW_US(psys->part) else psys->part= psys_copy_settings(psys->part); - if(dupflag & USER_DUP_ACT) { + if (dupflag & USER_DUP_ACT) { BKE_copy_animdata_id_action(&psys->part->id); } @@ -1677,12 +1682,12 @@ static Base *object_add_duplicate_internal(Main *bmain, Scene *scene, Base *base switch(obn->type) { case OB_MESH: - if(dupflag & USER_DUP_MESH) { + if (dupflag & USER_DUP_MESH) { ID_NEW_US2( obn->data ) else { obn->data= copy_mesh(obn->data); - if(obn->fluidsimSettings) { + if (obn->fluidsimSettings) { obn->fluidsimSettings->orgMesh = (Mesh *)obn->data; } @@ -1692,7 +1697,7 @@ static Base *object_add_duplicate_internal(Main *bmain, Scene *scene, Base *base } break; case OB_CURVE: - if(dupflag & USER_DUP_CURVE) { + if (dupflag & USER_DUP_CURVE) { ID_NEW_US2(obn->data ) else { obn->data= copy_curve(obn->data); @@ -1702,7 +1707,7 @@ static Base *object_add_duplicate_internal(Main *bmain, Scene *scene, Base *base } break; case OB_SURF: - if(dupflag & USER_DUP_SURF) { + if (dupflag & USER_DUP_SURF) { ID_NEW_US2( obn->data ) else { obn->data= copy_curve(obn->data); @@ -1712,7 +1717,7 @@ static Base *object_add_duplicate_internal(Main *bmain, Scene *scene, Base *base } break; case OB_FONT: - if(dupflag & USER_DUP_FONT) { + if (dupflag & USER_DUP_FONT) { ID_NEW_US2( obn->data ) else { obn->data= copy_curve(obn->data); @@ -1722,7 +1727,7 @@ static Base *object_add_duplicate_internal(Main *bmain, Scene *scene, Base *base } break; case OB_MBALL: - if(dupflag & USER_DUP_MBALL) { + if (dupflag & USER_DUP_MBALL) { ID_NEW_US2(obn->data ) else { obn->data= copy_mball(obn->data); @@ -1732,7 +1737,7 @@ static Base *object_add_duplicate_internal(Main *bmain, Scene *scene, Base *base } break; case OB_LAMP: - if(dupflag & USER_DUP_LAMP) { + if (dupflag & USER_DUP_LAMP) { ID_NEW_US2(obn->data ) else { obn->data= copy_lamp(obn->data); @@ -1744,9 +1749,9 @@ static Base *object_add_duplicate_internal(Main *bmain, Scene *scene, Base *base case OB_ARMATURE: obn->recalc |= OB_RECALC_DATA; - if(obn->pose) obn->pose->flag |= POSE_RECALC; + if (obn->pose) obn->pose->flag |= POSE_RECALC; - if(dupflag & USER_DUP_ARM) { + if (dupflag & USER_DUP_ARM) { ID_NEW_US2(obn->data ) else { obn->data= copy_armature(obn->data); @@ -1759,7 +1764,7 @@ static Base *object_add_duplicate_internal(Main *bmain, Scene *scene, Base *base break; case OB_LATTICE: - if(dupflag!=0) { + if (dupflag!=0) { ID_NEW_US2(obn->data ) else { obn->data= copy_lattice(obn->data); @@ -1769,7 +1774,7 @@ static Base *object_add_duplicate_internal(Main *bmain, Scene *scene, Base *base } break; case OB_CAMERA: - if(dupflag!=0) { + if (dupflag!=0) { ID_NEW_US2(obn->data ) else { obn->data= copy_camera(obn->data); @@ -1779,7 +1784,7 @@ static Base *object_add_duplicate_internal(Main *bmain, Scene *scene, Base *base } break; case OB_SPEAKER: - if(dupflag!=0) { + if (dupflag!=0) { ID_NEW_US2(obn->data ) else { obn->data= copy_speaker(obn->data); @@ -1792,34 +1797,34 @@ static Base *object_add_duplicate_internal(Main *bmain, Scene *scene, Base *base } /* check if obdata is copied */ - if(didit) { + if (didit) { Key *key = ob_get_key(obn); - if(dupflag & USER_DUP_ACT) { + if (dupflag & USER_DUP_ACT) { bActuator *act; BKE_copy_animdata_id_action((ID *)obn->data); - if(key) { + if (key) { BKE_copy_animdata_id_action((ID*)key); } /* Update the duplicated action in the action actuators */ for (act = obn->actuators.first; act; act = act->next) { - if(act->type == ACT_ACTION) { + if (act->type == ACT_ACTION) { bActionActuator* actact = (bActionActuator*) act->data; - if(ob->adt && actact->act == ob->adt->action) { + if (ob->adt && actact->act == ob->adt->action) { actact->act = obn->adt->action; } } } } - if(dupflag & USER_DUP_MAT) { + if (dupflag & USER_DUP_MAT) { matarar= give_matarar(obn); - if(matarar) { - for(a=0; atotcol; a++) { + if (matarar) { + for (a=0; atotcol; a++) { id= (ID *)(*matarar)[a]; - if(id) { + if (id) { ID_NEW_US( (*matarar)[a] ) else (*matarar)[a]= copy_material((*matarar)[a]); @@ -1886,10 +1891,10 @@ static int duplicate_exec(bContext *C, wmOperator *op) } /* new object becomes active */ - if(BASACT==base) + if (BASACT==base) ED_base_object_activate(C, basen); - if(basen->object->data) { + if (basen->object->data) { DAG_id_tag_update(basen->object->data, 0); } } @@ -1943,7 +1948,7 @@ static int add_named_exec(bContext *C, wmOperator *op) /* find object, create fake base */ RNA_string_get(op->ptr, "name", name); ob= (Object *)find_id("OB", name); - if(ob==NULL) + if (ob==NULL) return OPERATOR_CANCELLED; base= MEM_callocN(sizeof(Base), "duplibase"); @@ -2017,20 +2022,20 @@ static int join_exec(bContext *C, wmOperator *op) Scene *scene= CTX_data_scene(C); Object *ob= CTX_data_active_object(C); - if(scene->obedit) { + if (scene->obedit) { BKE_report(op->reports, RPT_ERROR, "This data does not support joining in editmode"); return OPERATOR_CANCELLED; } - else if(object_data_is_libdata(ob)) { + else if (object_data_is_libdata(ob)) { BKE_report(op->reports, RPT_ERROR, "Can't edit external libdata"); return OPERATOR_CANCELLED; } - if(ob->type == OB_MESH) + if (ob->type == OB_MESH) return join_mesh_exec(C, op); - else if(ELEM(ob->type, OB_CURVE, OB_SURF)) + else if (ELEM(ob->type, OB_CURVE, OB_SURF)) return join_curve_exec(C, op); - else if(ob->type == OB_ARMATURE) + else if (ob->type == OB_ARMATURE) return join_armature_exec(C, op); return OPERATOR_CANCELLED; @@ -2070,16 +2075,16 @@ static int join_shapes_exec(bContext *C, wmOperator *op) Scene *scene= CTX_data_scene(C); Object *ob= CTX_data_active_object(C); - if(scene->obedit) { + if (scene->obedit) { BKE_report(op->reports, RPT_ERROR, "This data does not support joining in editmode"); return OPERATOR_CANCELLED; } - else if(object_data_is_libdata(ob)) { + else if (object_data_is_libdata(ob)) { BKE_report(op->reports, RPT_ERROR, "Can't edit external libdata"); return OPERATOR_CANCELLED; } - if(ob->type == OB_MESH) + if (ob->type == OB_MESH) return join_mesh_shapes_exec(C, op); return OPERATOR_CANCELLED; diff --git a/source/blender/editors/object/object_bake.c b/source/blender/editors/object/object_bake.c index 4f64a64607e..deefcfd6989 100644 --- a/source/blender/editors/object/object_bake.c +++ b/source/blender/editors/object/object_bake.c @@ -161,10 +161,11 @@ static void multiresbake_get_normal(const MResolvePixelData *data, float norm[], data->mface[face_num].v3, data->mface[face_num].v4}; const int smoothnormal= (data->mface[face_num].flag & ME_SMOOTH); - if(!smoothnormal) { /* flat */ - if(data->precomputed_normals) { + if (!smoothnormal) { /* flat */ + if (data->precomputed_normals) { copy_v3_v3(norm, &data->precomputed_normals[3*face_num]); - } else { + } + else { float nor[3]; float *p0, *p1, *p2; const int iGetNrVerts= data->mface[face_num].v4!=0 ? 4 : 3; @@ -173,16 +174,18 @@ static void multiresbake_get_normal(const MResolvePixelData *data, float norm[], p1= data->mvert[indices[1]].co; p2= data->mvert[indices[2]].co; - if(iGetNrVerts==4) { + if (iGetNrVerts==4) { float *p3= data->mvert[indices[3]].co; normal_quad_v3(nor, p0, p1, p2, p3); - } else { + } + else { normal_tri_v3(nor, p0, p1, p2); } copy_v3_v3(norm, nor); } - } else { + } + else { short *no= data->mvert[indices[vert_index]].no; normal_short_to_float_v3(norm, no); @@ -239,7 +242,7 @@ static void flush_pixel(const MResolvePixelData *data, const int x, const int y) /* this sequence of math is designed specifically as is with great care * to be compatible with our shader. Please don't change without good reason. */ - for(r= 0; r<3; r++) { + for (r= 0; r<3; r++) { from_tang[0][r]= tang0[r]*u + tang1[r]*v + tang2[r]*w; from_tang[2][r]= no0[r]*u + no1[r]*v + no2[r]*w; } @@ -258,8 +261,8 @@ static void set_rast_triangle(const MBakeRast *bake_rast, const int x, const int const int w= bake_rast->w; const int h= bake_rast->h; - if(x>=0 && x=0 && ytexels[y*w+x])==0) { + if (x>=0 && x=0 && ytexels[y*w+x])==0) { flush_pixel(bake_rast->data, x, y); bake_rast->texels[y*w+x]= FILTER_MASK_USED; } @@ -277,29 +280,29 @@ static void rasterize_half(const MBakeRast *bake_rast, const int h= bake_rast->h; int y, y0, y1; - if(y1_in<=0 || y0_in>=h) + if (y1_in<=0 || y0_in>=h) return; y0= y0_in<0 ? 0 : y0_in; y1= y1_in>=h ? h : y1_in; - for(y= y0; y0 && iXl0 && iXl=w?w:iXr; - for(x= iXl; xtmi && tlo>thi) { + if (tlo>tmi && tlo>thi) { SWAP(float, shi, slo); SWAP(float, thi, tlo); - } else if(tmi>thi) { + } + else if (tmi>thi) { SWAP(float, shi, smi); SWAP(float, thi, tmi); } - if(tlo>tmi) { + if (tlo>tmi) { SWAP(float, slo, smi); SWAP(float, tlo, tmi); } @@ -348,7 +352,7 @@ static void bake_rasterize(const MBakeRast *bake_rast, const float st0_in[2], co static int multiresbake_test_break(MultiresBakeRender *bkr) { - if(!bkr->stop) { + if (!bkr->stop) { /* this means baker is executed outside from job system */ return 0; } @@ -368,12 +372,12 @@ static void do_multires_bake(MultiresBakeRender *bkr, Image* ima, MPassKnownData MTFace *mtface= dm->getTessFaceDataArray(dm, CD_MTFACE); float *pvtangent= NULL; - if(CustomData_get_layer_index(&dm->faceData, CD_TANGENT) == -1) + if (CustomData_get_layer_index(&dm->faceData, CD_TANGENT) == -1) DM_add_tangent_layer(dm); pvtangent= DM_get_tessface_data_layer(dm, CD_TANGENT); - if(tot_face > 0) { /* sanity check */ + if (tot_face > 0) { /* sanity check */ int f= 0; MBakeRast bake_rast; MResolvePixelData data={NULL}; @@ -390,19 +394,19 @@ static void do_multires_bake(MultiresBakeRender *bkr, Image* ima, MPassKnownData data.lvl= lvl; data.pass_data= passKnownData; - if(initBakeData) + if (initBakeData) data.bake_data= initBakeData(bkr, ima); init_bake_rast(&bake_rast, ibuf, &data, flush_pixel); - for(f= 0; ftpage!=ima) + if (mtfate->tpage!=ima) continue; data.face_index= f; @@ -418,7 +422,7 @@ static void do_multires_bake(MultiresBakeRender *bkr, Image* ima, MPassKnownData verts[2][1]=3; nr_tris= mface[f].v4!=0 ? 2 : 1; - for(t= 0; tbaked_faces++; - if(bkr->do_update) + if (bkr->do_update) *bkr->do_update= 1; - if(bkr->progress) + if (bkr->progress) *bkr->progress= ((float)bkr->baked_objects + (float)bkr->baked_faces / tot_face) / bkr->tot_obj; } - if(applyBakeData) + if (applyBakeData) applyBakeData(data.bake_data); - if(freeBakeData) + if (freeBakeData) freeBakeData(data.bake_data); } } @@ -486,12 +490,13 @@ static void interp_bilinear_grid(DMGridData *grid, int grid_size, float crn_x, f u= crn_x-x0; v= crn_y-y0; - if(mode == 0) { + if (mode == 0) { copy_v3_v3(data[0], grid[y0 * grid_size + x0].no); copy_v3_v3(data[1], grid[y0 * grid_size + x1].no); copy_v3_v3(data[2], grid[y1 * grid_size + x1].no); copy_v3_v3(data[3], grid[y1 * grid_size + x0].no); - } else { + } + else { copy_v3_v3(data[0], grid[y0 * grid_size + x0].co); copy_v3_v3(data[1], grid[y0 * grid_size + x1].co); copy_v3_v3(data[2], grid[y1 * grid_size + x1].co); @@ -517,10 +522,11 @@ static void get_ccgdm_data(DerivedMesh *lodm, DerivedMesh *hidm, const int *orig face_side= (grid_size<<1)-1; - if(lvl==0) { + if (lvl==0) { g_index= grid_offset[face_index]; S= mdisp_rot_face_to_crn(mface.v4 ? 4 : 3, face_side, u*(face_side-1), v*(face_side-1), &crn_x, &crn_y); - } else { + } + else { int side= (1 << (lvl-1)) + 1; int grid_index= origindex[face_index]; int loc_offs= face_index % (1<<(2*lvl)); @@ -539,10 +545,10 @@ static void get_ccgdm_data(DerivedMesh *lodm, DerivedMesh *hidm, const int *orig CLAMP(crn_x, 0.0f, grid_size); CLAMP(crn_y, 0.0f, grid_size); - if(n != NULL) + if (n != NULL) interp_bilinear_grid(grid_data[g_index + S], grid_size, crn_x, crn_y, 0, n); - if(co != NULL) + if (co != NULL) interp_bilinear_grid(grid_data[g_index + S], grid_size, crn_x, crn_y, 1, co); } @@ -552,12 +558,13 @@ static void interp_bilinear_mface(DerivedMesh *dm, MFace *mface, const float u, { float data[4][3]; - if(mode == 0) { + if (mode == 0) { dm->getVertNo(dm, mface->v1, data[0]); dm->getVertNo(dm, mface->v2, data[1]); dm->getVertNo(dm, mface->v3, data[2]); dm->getVertNo(dm, mface->v4, data[3]); - } else { + } + else { dm->getVertCo(dm, mface->v1, data[0]); dm->getVertCo(dm, mface->v2, data[1]); dm->getVertCo(dm, mface->v3, data[2]); @@ -573,11 +580,12 @@ static void interp_barycentric_mface(DerivedMesh *dm, MFace *mface, const float { float data[3][3]; - if(mode == 0) { + if (mode == 0) { dm->getVertNo(dm, mface->v1, data[0]); dm->getVertNo(dm, mface->v2, data[1]); dm->getVertNo(dm, mface->v3, data[2]); - } else { + } + else { dm->getVertCo(dm, mface->v1, data[0]); dm->getVertCo(dm, mface->v2, data[1]); dm->getVertCo(dm, mface->v3, data[2]); @@ -599,7 +607,7 @@ static void *init_heights_data(MultiresBakeRender *bkr, Image *ima) height_data->height_max= -FLT_MAX; height_data->height_min= FLT_MAX; - if(!bkr->use_lores_mesh) { + if (!bkr->use_lores_mesh) { SubsurfModifierData smd= {{NULL}}; int ss_lvl= bkr->tot_lvl - bkr->lvl; @@ -608,7 +616,7 @@ static void *init_heights_data(MultiresBakeRender *bkr, Image *ima) smd.levels= smd.renderLevels= ss_lvl; smd.flags|= eSubsurfModifierFlag_SubsurfUv; - if(bkr->simple) + if (bkr->simple) smd.subdivType= ME_SIMPLE_SUBSURF; height_data->ssdm= subsurf_make_derived_from_derived(bkr->lores_dm, &smd, 0, NULL, 0, 0, 0); @@ -646,24 +654,25 @@ static void apply_heights_data(void *bake_data) float height, *heights= height_data->heights; float min= height_data->height_min, max= height_data->height_max; - for(x= 0; xx; x++) { - for(y =0; yy; y++) { + for (x= 0; xx; x++) { + for (y =0; yy; y++) { i= ibuf->x*y + x; - if(((char*)ibuf->userdata)[i] != FILTER_MASK_USED) + if (((char*)ibuf->userdata)[i] != FILTER_MASK_USED) continue; - if(ibuf->rect_float) { + if (ibuf->rect_float) { float *rrgbf= ibuf->rect_float + i*4; - if(max-min > 1e-5f) height= (heights[i]-min)/(max-min); + if (max-min > 1e-5f) height= (heights[i]-min)/(max-min); else height= 0; rrgbf[0]=rrgbf[1]=rrgbf[2]= height; - } else { + } + else { char *rrgb= (char*)ibuf->rect + i*4; - if(max-min > 1e-5f) height= (heights[i]-min)/(max-min); + if (max-min > 1e-5f) height= (heights[i]-min)/(max-min); else height= 0; rrgb[0]=rrgb[1]=rrgb[2]= FTOCHAR(height); @@ -678,7 +687,7 @@ static void free_heights_data(void *bake_data) { MHeightBakeData *height_data= (MHeightBakeData*)bake_data; - if(height_data->ssdm) + if (height_data->ssdm) height_data->ssdm->release(height_data->ssdm); MEM_freeN(height_data->heights); @@ -710,10 +719,11 @@ static void apply_heights_callback(DerivedMesh *lores_dm, DerivedMesh *hires_dm, st1= mtface[face_index].uv[1]; st2= mtface[face_index].uv[2]; - if(mface.v4) { + if (mface.v4) { st3= mtface[face_index].uv[3]; resolve_quad_uv(uv, st, st0, st1, st2, st3); - } else + } + else resolve_tri_uv(uv, st, st0, st1, st2); CLAMP(uv[0], 0.0f, 1.0f); @@ -721,15 +731,17 @@ static void apply_heights_callback(DerivedMesh *lores_dm, DerivedMesh *hires_dm, get_ccgdm_data(lores_dm, hires_dm, height_data->origindex, lvl, face_index, uv[0], uv[1], p1, 0); - if(height_data->ssdm) { + if (height_data->ssdm) { get_ccgdm_data(lores_dm, height_data->ssdm, height_data->origindex, 0, face_index, uv[0], uv[1], p0, n); - } else { + } + else { lores_dm->getTessFace(lores_dm, face_index, &mface); - if(mface.v4) { + if (mface.v4) { interp_bilinear_mface(lores_dm, &mface, uv[0], uv[1], 1, p0); interp_bilinear_mface(lores_dm, &mface, uv[0], uv[1], 0, n); - } else { + } + else { interp_barycentric_mface(lores_dm, &mface, uv[0], uv[1], 1, p0); interp_barycentric_mface(lores_dm, &mface, uv[0], uv[1], 0, n); } @@ -739,15 +751,16 @@ static void apply_heights_callback(DerivedMesh *lores_dm, DerivedMesh *hires_dm, len= dot_v3v3(n, vec); height_data->heights[pixel]= len; - if(lenheight_min) height_data->height_min= len; - if(len>height_data->height_max) height_data->height_max= len; + if (lenheight_min) height_data->height_min= len; + if (len>height_data->height_max) height_data->height_max= len; - if(ibuf->rect_float) { + if (ibuf->rect_float) { float *rrgbf= ibuf->rect_float + pixel*4; rrgbf[3]= 1.0f; ibuf->userflags= IB_RECT_INVALID; - } else { + } + else { char *rrgb= (char*)ibuf->rect + pixel*4; rrgb[3]= 255; } @@ -777,10 +790,11 @@ static void apply_tangmat_callback(DerivedMesh *lores_dm, DerivedMesh *hires_dm, st1= mtface[face_index].uv[1]; st2= mtface[face_index].uv[2]; - if(mface.v4) { + if (mface.v4) { st3= mtface[face_index].uv[3]; resolve_quad_uv(uv, st, st0, st1, st2, st3); - } else + } + else resolve_tri_uv(uv, st, st0, st1, st2); CLAMP(uv[0], 0.0f, 1.0f); @@ -793,7 +807,7 @@ static void apply_tangmat_callback(DerivedMesh *lores_dm, DerivedMesh *hires_dm, mul_v3_fl(vec, 0.5); add_v3_v3(vec, tmp); - if(ibuf->rect_float) { + if (ibuf->rect_float) { float *rrgbf= ibuf->rect_float + pixel*4; rrgbf[0]= vec[0]; rrgbf[1]= vec[1]; @@ -801,7 +815,8 @@ static void apply_tangmat_callback(DerivedMesh *lores_dm, DerivedMesh *hires_dm, rrgbf[3]= 1.0f; ibuf->userflags= IB_RECT_INVALID; - } else { + } + else { unsigned char *rrgb= (unsigned char *)ibuf->rect + pixel*4; rgb_float_to_uchar(rrgb, vec); rrgb[3]= 255; @@ -819,12 +834,12 @@ static void count_images(MultiresBakeRender *bkr) totface= dm->getNumTessFaces(dm); - for(a= 0; aid.flag&= ~LIB_DOIT; - for(a= 0; aid.flag&LIB_DOIT)==0) { + if ((ima->id.flag&LIB_DOIT)==0) { LinkData *data= BLI_genericNodeN(ima); BLI_addtail(&bkr->image, data); bkr->tot_image++; @@ -832,7 +847,7 @@ static void count_images(MultiresBakeRender *bkr) } } - for(a= 0; aid.flag&= ~LIB_DOIT; } @@ -840,11 +855,11 @@ static void bake_images(MultiresBakeRender *bkr) { LinkData *link; - for(link= bkr->image.first; link; link= link->next) { + for (link= bkr->image.first; link; link= link->next) { Image *ima= (Image*)link->data; ImBuf *ibuf= BKE_image_get_ibuf(ima, NULL); - if(ibuf->x>0 && ibuf->y>0) { + if (ibuf->x>0 && ibuf->y>0) { ibuf->userdata= MEM_callocN(ibuf->y*ibuf->x, "MultiresBake imbuf mask"); switch(bkr->mode) { @@ -866,26 +881,26 @@ static void finish_images(MultiresBakeRender *bkr) { LinkData *link; - for(link= bkr->image.first; link; link= link->next) { + for (link= bkr->image.first; link; link= link->next) { Image *ima= (Image*)link->data; ImBuf *ibuf= BKE_image_get_ibuf(ima, NULL); - if(ibuf->x<=0 || ibuf->y<=0) + if (ibuf->x<=0 || ibuf->y<=0) continue; RE_bake_ibuf_filter(ibuf, (char *)ibuf->userdata, bkr->bake_filter); ibuf->userflags|= IB_BITMAPDIRTY; - if(ibuf->rect_float) + if (ibuf->rect_float) ibuf->userflags|= IB_RECT_INVALID; - if(ibuf->mipmap[0]) { + if (ibuf->mipmap[0]) { ibuf->userflags|= IB_MIPMAP_INVALID; imb_freemipmapImBuf(ibuf); } - if(ibuf->userdata) { + if (ibuf->userdata) { MEM_freeN(ibuf->userdata); ibuf->userdata= NULL; } @@ -910,7 +925,7 @@ static int multiresbake_check(bContext *C, wmOperator *op) CTX_DATA_BEGIN(C, Base*, base, selected_editable_bases) { ob= base->object; - if(ob->type != OB_MESH) { + if (ob->type != OB_MESH) { BKE_report(op->reports, RPT_ERROR, "Basking of multires data only works with active object which is a mesh"); ok= 0; @@ -921,25 +936,26 @@ static int multiresbake_check(bContext *C, wmOperator *op) mmd= get_multires_modifier(scene, ob, 0); /* Multi-resolution should be and be last in the stack */ - if(ok && mmd) { + if (ok && mmd) { ModifierData *md; ok= mmd->totlvl>0; - for(md = (ModifierData*)mmd->modifier.next; md && ok; md = md->next) { + for (md = (ModifierData*)mmd->modifier.next; md && ok; md = md->next) { if (modifier_isEnabled(scene, md, eModifierMode_Realtime)) { ok= 0; } } - } else ok= 0; + } + else ok= 0; - if(!ok) { + if (!ok) { BKE_report(op->reports, RPT_ERROR, "Multires data baking requires multi-resolution object"); break; } - if(!me->mtpoly) { + if (!me->mtpoly) { BKE_report(op->reports, RPT_ERROR, "Mesh should be unwrapped before multires data baking"); ok= 0; @@ -949,7 +965,7 @@ static int multiresbake_check(bContext *C, wmOperator *op) while (ok && a--) { Image *ima = me->mtpoly[a].tpage; - if(!ima) { + if (!ima) { BKE_report(op->reports, RPT_ERROR, "You should have active texture to use multires baker"); ok= 0; @@ -957,25 +973,26 @@ static int multiresbake_check(bContext *C, wmOperator *op) else { ImBuf *ibuf= BKE_image_get_ibuf(ima, NULL); - if(!ibuf) { + if (!ibuf) { BKE_report(op->reports, RPT_ERROR, "Baking should happend to image with image buffer"); ok= 0; - } else { - if(ibuf->rect==NULL && ibuf->rect_float==NULL) + } + else { + if (ibuf->rect==NULL && ibuf->rect_float==NULL) ok= 0; - if(ibuf->rect_float && !(ibuf->channels==0 || ibuf->channels==4)) + if (ibuf->rect_float && !(ibuf->channels==0 || ibuf->channels==4)) ok= 0; - if(!ok) + if (!ok) BKE_report(op->reports, RPT_ERROR, "Baking to unsupported image type"); } } } } - if(!ok) + if (!ok) break; } CTX_DATA_END; @@ -991,11 +1008,12 @@ static DerivedMesh *multiresbake_create_loresdm(Scene *scene, Object *ob, int *l *lvl= mmd->lvl; - if(*lvl==0) { + if (*lvl==0) { DerivedMesh *tmp_dm= CDDM_from_mesh(me, ob); dm= CDDM_copy(tmp_dm); tmp_dm->release(tmp_dm); - } else { + } + else { MultiresModifierData tmp_mmd= *mmd; DerivedMesh *cddm= CDDM_from_mesh(me, ob); @@ -1033,13 +1051,13 @@ static void clear_images(MTFace *mtface, int totface) const float vec_alpha[4]= {0.0f, 0.0f, 0.0f, 0.0f}; const float vec_solid[4]= {0.0f, 0.0f, 0.0f, 1.0f}; - for(a= 0; aid.flag&= ~LIB_DOIT; - for(a= 0; aid.flag&LIB_DOIT)==0) { + if ((ima->id.flag&LIB_DOIT)==0) { ImBuf *ibuf= BKE_image_get_ibuf(ima, NULL); IMB_rectfill(ibuf, (ibuf->planes == R_IMF_PLANES_RGBA) ? vec_alpha : vec_solid); @@ -1047,7 +1065,7 @@ static void clear_images(MTFace *mtface, int totface) } } - for(a= 0; aid.flag&= ~LIB_DOIT; } @@ -1057,10 +1075,10 @@ static int multiresbake_image_exec_locked(bContext *C, wmOperator *op) Scene *scene= CTX_data_scene(C); int objects_baked= 0; - if(!multiresbake_check(C, op)) + if (!multiresbake_check(C, op)) return OPERATOR_CANCELLED; - if(scene->r.bake_flag&R_BAKE_CLEAR) { /* clear images */ + if (scene->r.bake_flag&R_BAKE_CLEAR) { /* clear images */ CTX_DATA_BEGIN(C, Base*, base, selected_editable_bases) { Mesh *me; @@ -1087,7 +1105,7 @@ static int multiresbake_image_exec_locked(bContext *C, wmOperator *op) /* create low-resolution DM (to bake to) and hi-resolution DM (to bake from) */ bkr.lores_dm= multiresbake_create_loresdm(scene, ob, &bkr.lvl); - if(!bkr.lores_dm) + if (!bkr.lores_dm) continue; bkr.hires_dm= multiresbake_create_hiresdm(scene, ob, &bkr.tot_lvl, &bkr.simple); @@ -1103,7 +1121,7 @@ static int multiresbake_image_exec_locked(bContext *C, wmOperator *op) } CTX_DATA_END; - if(!objects_baked) + if (!objects_baked) BKE_report(op->reports, RPT_ERROR, "No objects found to bake from"); return OPERATOR_FINISHED; @@ -1130,7 +1148,7 @@ static void init_multiresbake_job(bContext *C, MultiresBakeJob *bkj) multires_force_update(ob); lores_dm = multiresbake_create_loresdm(scene, ob, &lvl); - if(!lores_dm) + if (!lores_dm) continue; data= MEM_callocN(sizeof(MultiresBakerJobData), "multiresBaker derivedMesh_data"); @@ -1151,8 +1169,8 @@ static void multiresbake_startjob(void *bkv, short *stop, short *do_update, floa tot_obj= BLI_countlist(&bkj->data); - if(bkj->bake_clear) { /* clear images */ - for(data= bkj->data.first; data; data= data->next) { + if (bkj->bake_clear) { /* clear images */ + for (data= bkj->data.first; data; data= data->next) { DerivedMesh *dm= data->lores_dm; MTFace *mtface= CustomData_get_layer(&dm->faceData, CD_MTFACE); @@ -1160,7 +1178,7 @@ static void multiresbake_startjob(void *bkv, short *stop, short *do_update, floa } } - for(data= bkj->data.first; data; data= data->next) { + for (data= bkj->data.first; data; data= data->next) { MultiresBakeRender bkr= {0}; /* copy data stored in job descriptor */ @@ -1214,13 +1232,13 @@ static int multiresbake_image_exec(bContext *C, wmOperator *op) MultiresBakeJob *bkr; wmJob *steve; - if(!multiresbake_check(C, op)) + if (!multiresbake_check(C, op)) return OPERATOR_CANCELLED; bkr= MEM_callocN(sizeof(MultiresBakeJob), "MultiresBakeJob data"); init_multiresbake_job(C, bkr); - if(!bkr->data.first) { + if (!bkr->data.first) { BKE_report(op->reports, RPT_ERROR, "No objects found to bake from"); return OPERATOR_CANCELLED; } @@ -1278,10 +1296,10 @@ static int test_bake_internal(bContext *C, ReportList *reports) { Scene *scene= CTX_data_scene(C); - if((scene->r.bake_flag & R_BAKE_TO_ACTIVE) && CTX_data_active_object(C)==NULL) { + if ((scene->r.bake_flag & R_BAKE_TO_ACTIVE) && CTX_data_active_object(C)==NULL) { BKE_report(reports, RPT_ERROR, "No active object"); } - else if(scene->r.bake_mode==RE_BAKE_AO && scene->world==NULL) { + else if (scene->r.bake_mode==RE_BAKE_AO && scene->world==NULL) { BKE_report(reports, RPT_ERROR, "No world set up"); } else { @@ -1304,12 +1322,12 @@ static void init_bake_internal(BakeRender *bkr, bContext *C) bkr->actob= (scene->r.bake_flag & R_BAKE_TO_ACTIVE) ? OBACT : NULL; bkr->re= RE_NewRender("_Bake View_"); - if(scene->r.bake_mode==RE_BAKE_AO) { + if (scene->r.bake_mode==RE_BAKE_AO) { /* If raytracing or AO is disabled, switch it on temporarily for baking. */ bkr->prev_wo_amb_occ = (scene->world->mode & WO_AMB_OCC) != 0; scene->world->mode |= WO_AMB_OCC; } - if(scene->r.bake_mode==RE_BAKE_AO || bkr->actob) { + if (scene->r.bake_mode==RE_BAKE_AO || bkr->actob) { bkr->prev_r_raytrace = (scene->r.mode & R_RAYTRACE) != 0; scene->r.mode |= R_RAYTRACE; } @@ -1320,22 +1338,22 @@ static void finish_bake_internal(BakeRender *bkr) RE_Database_Free(bkr->re); /* restore raytrace and AO */ - if(bkr->scene->r.bake_mode==RE_BAKE_AO) - if(bkr->prev_wo_amb_occ == 0) + if (bkr->scene->r.bake_mode==RE_BAKE_AO) + if (bkr->prev_wo_amb_occ == 0) bkr->scene->world->mode &= ~WO_AMB_OCC; - if(bkr->scene->r.bake_mode==RE_BAKE_AO || bkr->actob) - if(bkr->prev_r_raytrace == 0) + if (bkr->scene->r.bake_mode==RE_BAKE_AO || bkr->actob) + if (bkr->prev_r_raytrace == 0) bkr->scene->r.mode &= ~R_RAYTRACE; - if(bkr->result==BAKE_RESULT_OK) { + if (bkr->result==BAKE_RESULT_OK) { Image *ima; /* force OpenGL reload and mipmap recalc */ - for(ima= G.main->image.first; ima; ima= ima->id.next) { - if(ima->ok==IMA_OK_LOADED) { + for (ima= G.main->image.first; ima; ima= ima->id.next) { + if (ima->ok==IMA_OK_LOADED) { ImBuf *ibuf= BKE_image_get_ibuf(ima, NULL); - if(ibuf) { - if(ibuf->userflags & IB_BITMAPDIRTY) { + if (ibuf) { + if (ibuf->userflags & IB_BITMAPDIRTY) { GPU_free_image(ima); imb_freemipmapImBuf(ibuf); } @@ -1384,9 +1402,9 @@ static void bake_update(void *bkv) { BakeRender *bkr= bkv; - if(bkr->sa && bkr->sa->spacetype==SPACE_IMAGE) { /* in case the user changed while baking */ + if (bkr->sa && bkr->sa->spacetype==SPACE_IMAGE) { /* in case the user changed while baking */ SpaceImage *sima= bkr->sa->spacedata.first; - if(sima) + if (sima) sima->image= RE_bake_shade_get_image(); } } @@ -1396,9 +1414,9 @@ static void bake_freejob(void *bkv) BakeRender *bkr= bkv; finish_bake_internal(bkr); - if(bkr->result==BAKE_RESULT_NO_OBJECTS) + if (bkr->result==BAKE_RESULT_NO_OBJECTS) BKE_report(bkr->reports, RPT_ERROR, "No objects or images found to bake to"); - else if(bkr->result==BAKE_RESULT_FEEDBACK_LOOP) + else if (bkr->result==BAKE_RESULT_FEEDBACK_LOOP) BKE_report(bkr->reports, RPT_WARNING, "Feedback loop detected"); MEM_freeN(bkr); @@ -1409,7 +1427,7 @@ static void bake_freejob(void *bkv) static int objects_bake_render_modal(bContext *C, wmOperator *UNUSED(op), wmEvent *event) { /* no running blender, remove handler and pass through */ - if(0==WM_jobs_test(CTX_wm_manager(C), CTX_data_scene(C))) + if (0==WM_jobs_test(CTX_wm_manager(C), CTX_data_scene(C))) return OPERATOR_FINISHED|OPERATOR_PASS_THROUGH; /* running render */ @@ -1434,14 +1452,15 @@ static int objects_bake_render_invoke(bContext *C, wmOperator *op, wmEvent *UNUS Scene *scene= CTX_data_scene(C); int result= OPERATOR_CANCELLED; - if(is_multires_bake(scene)) { + if (is_multires_bake(scene)) { result= multiresbake_image_exec(C, op); - } else { + } + else { /* only one render job at a time */ - if(WM_jobs_test(CTX_wm_manager(C), scene)) + if (WM_jobs_test(CTX_wm_manager(C), scene)) return OPERATOR_CANCELLED; - if(test_bake_internal(C, op->reports)==0) { + if (test_bake_internal(C, op->reports)==0) { return OPERATOR_CANCELLED; } else { @@ -1483,10 +1502,11 @@ static int bake_image_exec(bContext *C, wmOperator *op) Scene *scene= CTX_data_scene(C); int result= OPERATOR_CANCELLED; - if(is_multires_bake(scene)) { + if (is_multires_bake(scene)) { result= multiresbake_image_exec_locked(C, op); - } else { - if(test_bake_internal(C, op->reports)==0) { + } + else { + if (test_bake_internal(C, op->reports)==0) { return OPERATOR_CANCELLED; } else { @@ -1506,9 +1526,9 @@ static int bake_image_exec(bContext *C, wmOperator *op) bkr.ready= 0; BLI_insert_thread(&threads, &bkr); - while(bkr.ready==0) { + while (bkr.ready==0) { PIL_sleep_ms(50); - if(bkr.ready) + if (bkr.ready) break; /* used to redraw in 2.4x but this is just for exec in 2.5 */ @@ -1517,9 +1537,9 @@ static int bake_image_exec(bContext *C, wmOperator *op) } BLI_end_threads(&threads); - if(bkr.result==BAKE_RESULT_NO_OBJECTS) + if (bkr.result==BAKE_RESULT_NO_OBJECTS) BKE_report(op->reports, RPT_ERROR, "No valid images found to bake to"); - else if(bkr.result==BAKE_RESULT_FEEDBACK_LOOP) + else if (bkr.result==BAKE_RESULT_FEEDBACK_LOOP) BKE_report(op->reports, RPT_ERROR, "Feedback loop detected"); finish_bake_internal(&bkr); diff --git a/source/blender/editors/object/object_constraint.c b/source/blender/editors/object/object_constraint.c index e1dca0278f4..5b2aaf30897 100644 --- a/source/blender/editors/object/object_constraint.c +++ b/source/blender/editors/object/object_constraint.c @@ -405,17 +405,17 @@ static void test_constraints (Object *owner, bPoseChannel *pchan) else if (curcon->type == CONSTRAINT_TYPE_FOLLOWTRACK) { bFollowTrackConstraint *data = curcon->data; - if((data->flag&CAMERASOLVER_ACTIVECLIP)==0) { - if(data->clip != NULL && data->track[0]) { + if ((data->flag&CAMERASOLVER_ACTIVECLIP)==0) { + if (data->clip != NULL && data->track[0]) { MovieTracking *tracking= &data->clip->tracking; MovieTrackingObject *tracking_object; - if(data->object[0]) + if (data->object[0]) tracking_object= BKE_tracking_named_object(tracking, data->object); else tracking_object= BKE_tracking_get_camera_object(tracking); - if(!tracking_object) { + if (!tracking_object) { curcon->flag |= CONSTRAINT_DISABLE; } else { @@ -429,13 +429,13 @@ static void test_constraints (Object *owner, bPoseChannel *pchan) else if (curcon->type == CONSTRAINT_TYPE_CAMERASOLVER) { bCameraSolverConstraint *data = curcon->data; - if((data->flag&CAMERASOLVER_ACTIVECLIP)==0 && data->clip == NULL) + if ((data->flag&CAMERASOLVER_ACTIVECLIP)==0 && data->clip == NULL) curcon->flag |= CONSTRAINT_DISABLE; } else if (curcon->type == CONSTRAINT_TYPE_OBJECTSOLVER) { bObjectSolverConstraint *data = curcon->data; - if((data->flag&CAMERASOLVER_ACTIVECLIP)==0 && data->clip == NULL) + if ((data->flag&CAMERASOLVER_ACTIVECLIP)==0 && data->clip == NULL) curcon->flag |= CONSTRAINT_DISABLE; } @@ -833,7 +833,7 @@ static int childof_clear_inverse_exec (bContext *C, wmOperator *op) bConstraint *con = edit_constraint_property_get(op, ob, CONSTRAINT_TYPE_CHILDOF); bChildOfConstraint *data= (con) ? (bChildOfConstraint *)con->data : NULL; - if(data==NULL) { + if (data==NULL) { BKE_report(op->reports, RPT_ERROR, "Childof constraint not found"); return OPERATOR_CANCELLED; } @@ -923,7 +923,7 @@ static int objectsolver_clear_inverse_exec (bContext *C, wmOperator *op) bConstraint *con = edit_constraint_property_get(op, ob, CONSTRAINT_TYPE_OBJECTSOLVER); bObjectSolverConstraint *data= (con) ? (bObjectSolverConstraint *)con->data : NULL; - if(data==NULL) { + if (data==NULL) { BKE_report(op->reports, RPT_ERROR, "Childof constraint not found"); return OPERATOR_CANCELLED; } @@ -977,11 +977,11 @@ void ED_object_constraint_set_active(Object *ob, bConstraint *con) void ED_object_constraint_update(Object *ob) { - if(ob->pose) update_pose_constraint_flags(ob->pose); + if (ob->pose) update_pose_constraint_flags(ob->pose); object_test_constraints(ob); - if(ob->type==OB_ARMATURE) DAG_id_tag_update(&ob->id, OB_RECALC_DATA|OB_RECALC_OB); + if (ob->type==OB_ARMATURE) DAG_id_tag_update(&ob->id, OB_RECALC_DATA|OB_RECALC_OB); else DAG_id_tag_update(&ob->id, OB_RECALC_OB); } @@ -989,7 +989,7 @@ void ED_object_constraint_dependency_update(Main *bmain, Scene *scene, Object *o { ED_object_constraint_update(ob); - if(ob->pose) ob->pose->flag |= POSE_RECALC; // checks & sorts pose channels + if (ob->pose) ob->pose->flag |= POSE_RECALC; // checks & sorts pose channels DAG_scene_sort(bmain, scene); } @@ -1015,7 +1015,7 @@ static int constraint_delete_exec (bContext *C, wmOperator *UNUSED(op)) ED_object_constraint_update(ob); /* needed to set the flags on posebones correctly */ /* ITASC needs to be rebuilt once a constraint is removed [#26920] */ - if(is_ik) { + if (is_ik) { BIK_clear_data(ob->pose); } diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c index 10f30818931..09625e30eaf 100644 --- a/source/blender/editors/object/object_edit.c +++ b/source/blender/editors/object/object_edit.c @@ -121,7 +121,7 @@ Object *ED_object_context(bContext *C) Object *ED_object_active_context(bContext *C) { Object *ob= NULL; - if(C) { + if (C) { ob= ED_object_context(C); if (!ob) ob= CTX_data_active_object(C); } @@ -140,8 +140,8 @@ static int object_hide_view_clear_exec(bContext *C, wmOperator *UNUSED(op)) int changed = 0; /* XXX need a context loop to handle such cases */ - for(base = FIRSTBASE; base; base=base->next) { - if((base->lay & v3d->lay) && base->object->restrictflag & OB_RESTRICT_VIEW) { + for (base = FIRSTBASE; base; base=base->next) { + if ((base->lay & v3d->lay) && base->object->restrictflag & OB_RESTRICT_VIEW) { base->flag |= SELECT; base->object->flag = base->flag; base->object->restrictflag &= ~OB_RESTRICT_VIEW; @@ -181,7 +181,7 @@ static int object_hide_view_set_exec(bContext *C, wmOperator *op) const int unselected= RNA_boolean_get(op->ptr, "unselected"); CTX_DATA_BEGIN(C, Base*, base, visible_bases) { - if(!unselected) { + if (!unselected) { if (base->flag & SELECT) { base->flag &= ~SELECT; base->object->flag = base->flag; @@ -237,14 +237,14 @@ static int object_hide_render_clear_exec(bContext *C, wmOperator *UNUSED(op)) /* XXX need a context loop to handle such cases */ CTX_DATA_BEGIN(C, Object*, ob, selected_editable_objects) { - if(ob->restrictflag & OB_RESTRICT_RENDER) { + if (ob->restrictflag & OB_RESTRICT_RENDER) { ob->restrictflag &= ~OB_RESTRICT_RENDER; changed= 1; } } CTX_DATA_END; - if(changed) + if (changed) WM_event_add_notifier(C, NC_SPACE|ND_SPACE_OUTLINER, NULL); return OPERATOR_FINISHED; @@ -271,7 +271,7 @@ static int object_hide_render_set_exec(bContext *C, wmOperator *op) const int unselected= RNA_boolean_get(op->ptr, "unselected"); CTX_DATA_BEGIN(C, Base*, base, visible_bases) { - if(!unselected) { + if (!unselected) { if (base->flag & SELECT) { base->object->restrictflag |= OB_RESTRICT_RENDER; } @@ -314,55 +314,55 @@ void ED_object_exit_editmode(bContext *C, int flag) Object *obedit= CTX_data_edit_object(C); int freedata = flag & EM_FREEDATA; - if(obedit==NULL) return; + if (obedit==NULL) return; - if(flag & EM_WAITCURSOR) waitcursor(1); - if(obedit->type==OB_MESH) { + if (flag & EM_WAITCURSOR) waitcursor(1); + if (obedit->type==OB_MESH) { Mesh *me= obedit->data; -// if(EM_texFaceCheck()) +// if (EM_texFaceCheck()) - if(me->edit_btmesh->bm->totvert>MESH_MAX_VERTS) { + if (me->edit_btmesh->bm->totvert>MESH_MAX_VERTS) { error("Too many vertices"); return; } EDBM_LoadEditBMesh(scene, obedit); - if(freedata) { + if (freedata) { EDBM_FreeEditBMesh(me->edit_btmesh); MEM_freeN(me->edit_btmesh); me->edit_btmesh= NULL; } - if(obedit->restore_mode & OB_MODE_WEIGHT_PAINT) { + if (obedit->restore_mode & OB_MODE_WEIGHT_PAINT) { mesh_octree_table(NULL, NULL, NULL, 'e'); mesh_mirrtopo_table(NULL, 'e'); } } else if (obedit->type==OB_ARMATURE) { ED_armature_from_edit(obedit); - if(freedata) + if (freedata) ED_armature_edit_free(obedit); } - else if(ELEM(obedit->type, OB_CURVE, OB_SURF)) { + else if (ELEM(obedit->type, OB_CURVE, OB_SURF)) { load_editNurb(obedit); - if(freedata) free_editNurb(obedit); + if (freedata) free_editNurb(obedit); } - else if(obedit->type==OB_FONT && freedata) { + else if (obedit->type==OB_FONT && freedata) { load_editText(obedit); - if(freedata) free_editText(obedit); + if (freedata) free_editText(obedit); } - else if(obedit->type==OB_LATTICE) { + else if (obedit->type==OB_LATTICE) { load_editLatt(obedit); - if(freedata) free_editLatt(obedit); + if (freedata) free_editLatt(obedit); } - else if(obedit->type==OB_MBALL) { + else if (obedit->type==OB_MBALL) { load_editMball(obedit); - if(freedata) free_editMball(obedit); + if (freedata) free_editMball(obedit); } /* freedata only 0 now on file saves and render */ - if(freedata) { + if (freedata) { ListBase pidlist; PTCacheID *pid; @@ -371,8 +371,8 @@ void ED_object_exit_editmode(bContext *C, int flag) /* flag object caches as outdated */ BKE_ptcache_ids_from_object(&pidlist, obedit, NULL, 0); - for(pid=pidlist.first; pid; pid=pid->next) { - if(pid->type != PTCACHE_TYPE_PARTICLES) /* particles don't need reset on geometry change */ + for (pid=pidlist.first; pid; pid=pid->next) { + if (pid->type != PTCACHE_TYPE_PARTICLES) /* particles don't need reset on geometry change */ pid->cache->flag |= PTCACHE_OUTDATED; } BLI_freelistN(&pidlist); @@ -382,10 +382,10 @@ void ED_object_exit_editmode(bContext *C, int flag) /* also flush ob recalc, doesn't take much overhead, but used for particles */ DAG_id_tag_update(&obedit->id, OB_RECALC_OB|OB_RECALC_DATA); - if(flag & EM_DO_UNDO) + if (flag & EM_DO_UNDO) ED_undo_push(C, "Editmode"); - if(flag & EM_WAITCURSOR) waitcursor(0); + if (flag & EM_WAITCURSOR) waitcursor(0); WM_event_add_notifier(C, NC_SCENE|ND_MODE|NS_MODE_OBJECT, scene); @@ -403,17 +403,17 @@ void ED_object_enter_editmode(bContext *C, int flag) View3D *v3d= NULL; int ok= 0; - if(scene->id.lib) return; + if (scene->id.lib) return; - if(sa && sa->spacetype==SPACE_VIEW3D) + if (sa && sa->spacetype==SPACE_VIEW3D) v3d= sa->spacedata.first; - if((flag & EM_IGNORE_LAYER)==0) { + if ((flag & EM_IGNORE_LAYER)==0) { base= CTX_data_active_base(C); /* active layer checked here for view3d */ - if(base==NULL) return; - else if(v3d && (base->lay & v3d->lay)==0) return; - else if(!v3d && (base->lay & scene->lay)==0) return; + if (base==NULL) return; + else if (v3d && (base->lay & v3d->lay)==0) return; + else if (!v3d && (base->lay & scene->lay)==0) return; } else { base= scene->basact; @@ -428,18 +428,18 @@ void ED_object_enter_editmode(bContext *C, int flag) return; } - if(flag & EM_WAITCURSOR) waitcursor(1); + if (flag & EM_WAITCURSOR) waitcursor(1); ob->restore_mode = ob->mode; /* note, when switching scenes the object can have editmode data but * not be scene->obedit: bug 22954, this avoids calling self eternally */ - if((ob->restore_mode & OB_MODE_EDIT)==0) + if ((ob->restore_mode & OB_MODE_EDIT)==0) ED_object_toggle_modes(C, ob->mode); ob->mode= OB_MODE_EDIT; - if(ob->type==OB_MESH) { + if (ob->type==OB_MESH) { ok= 1; scene->obedit= ob; // context sees this @@ -458,7 +458,7 @@ void ED_object_enter_editmode(bContext *C, int flag) * object_data_is_libdata that prevent the bugfix #6614, so * i add this little hack here. */ - if(arm->id.lib) { + if (arm->id.lib) { error_libdata(); return; } @@ -470,28 +470,28 @@ void ED_object_enter_editmode(bContext *C, int flag) WM_event_add_notifier(C, NC_SCENE|ND_MODE|NS_EDITMODE_ARMATURE, scene); } - else if(ob->type==OB_FONT) { + else if (ob->type==OB_FONT) { scene->obedit= ob; // XXX for context ok= 1; make_editText(ob); WM_event_add_notifier(C, NC_SCENE|ND_MODE|NS_EDITMODE_TEXT, scene); } - else if(ob->type==OB_MBALL) { + else if (ob->type==OB_MBALL) { scene->obedit= ob; // XXX for context ok= 1; make_editMball(ob); WM_event_add_notifier(C, NC_SCENE|ND_MODE|NS_EDITMODE_MBALL, scene); } - else if(ob->type==OB_LATTICE) { + else if (ob->type==OB_LATTICE) { scene->obedit= ob; // XXX for context ok= 1; make_editLatt(ob); WM_event_add_notifier(C, NC_SCENE|ND_MODE|NS_EDITMODE_LATTICE, scene); } - else if(ob->type==OB_SURF || ob->type==OB_CURVE) { + else if (ob->type==OB_SURF || ob->type==OB_CURVE) { ok= 1; scene->obedit= ob; // XXX for context make_editNurb(ob); @@ -499,7 +499,7 @@ void ED_object_enter_editmode(bContext *C, int flag) WM_event_add_notifier(C, NC_SCENE|ND_MODE|NS_EDITMODE_CURVE, scene); } - if(ok) { + if (ok) { DAG_id_tag_update(&ob->id, OB_RECALC_DATA); } else { @@ -508,15 +508,15 @@ void ED_object_enter_editmode(bContext *C, int flag) WM_event_add_notifier(C, NC_SCENE|ND_MODE|NS_MODE_OBJECT, scene); } - if(flag & EM_DO_UNDO) ED_undo_push(C, "Enter Editmode"); - if(flag & EM_WAITCURSOR) waitcursor(0); + if (flag & EM_DO_UNDO) ED_undo_push(C, "Enter Editmode"); + if (flag & EM_WAITCURSOR) waitcursor(0); } static int editmode_toggle_exec(bContext *C, wmOperator *UNUSED(op)) { ToolSettings *toolsettings = CTX_data_tool_settings(C); - if(!CTX_data_edit_object(C)) + if (!CTX_data_edit_object(C)) ED_object_enter_editmode(C, EM_WAITCURSOR); else ED_object_exit_editmode(C, EM_FREEDATA|EM_FREEUNDO|EM_WAITCURSOR); /* had EM_DO_UNDO but op flag calls undo too [#24685] */ @@ -531,7 +531,7 @@ static int editmode_toggle_poll(bContext *C) Object *ob = CTX_data_active_object(C); /* covers proxies too */ - if(ELEM(NULL, ob, ob->data) || ((ID *)ob->data)->lib) + if (ELEM(NULL, ob, ob->data) || ((ID *)ob->data)->lib) return 0; if (ob->restrictflag & OB_RESTRICT_VIEW) @@ -566,12 +566,12 @@ static int posemode_exec(bContext *C, wmOperator *UNUSED(op)) { Base *base= CTX_data_active_base(C); - if(base->object->type==OB_ARMATURE) { - if(base->object==CTX_data_edit_object(C)) { + if (base->object->type==OB_ARMATURE) { + if (base->object==CTX_data_edit_object(C)) { ED_object_exit_editmode(C, EM_FREEDATA|EM_DO_UNDO); ED_armature_enter_posemode(C, base); } - else if(base->object->mode & OB_MODE_POSE) + else if (base->object->mode & OB_MODE_POSE) ED_armature_exit_posemode(C, base); else ED_armature_enter_posemode(C, base); @@ -606,7 +606,7 @@ static void copymenu_properties(Scene *scene, View3D *v3d, Object *ob) char *str; prop= ob->prop.first; - while(prop) { + while (prop) { tot++; prop= prop->next; } @@ -620,7 +620,7 @@ static void copymenu_properties(Scene *scene, View3D *v3d, Object *ob) tot= 0; prop= ob->prop.first; - while(prop) { + while (prop) { tot++; strcat(str, "|"); strcat(str, prop->name); @@ -630,23 +630,25 @@ static void copymenu_properties(Scene *scene, View3D *v3d, Object *ob) nr= pupmenu(str); if ( nr==1 || nr==2 ) { - for(base= FIRSTBASE; base; base= base->next) { - if((base != BASACT) &&(TESTBASELIB(v3d, base))) { + for (base= FIRSTBASE; base; base= base->next) { + if ((base != BASACT) &&(TESTBASELIB(v3d, base))) { if (nr==1) { /* replace */ copy_properties( &base->object->prop, &ob->prop ); - } else { - for(prop = ob->prop.first; prop; prop= prop->next ) { + } + else { + for (prop = ob->prop.first; prop; prop= prop->next ) { set_ob_property(base->object, prop); } } } } - } else if(nr>0) { + } + else if (nr>0) { prop = BLI_findlink(&ob->prop, nr-4); /* account for first 3 menu items & menu index starting at 1*/ - if(prop) { - for(base= FIRSTBASE; base; base= base->next) { - if((base != BASACT) &&(TESTBASELIB(v3d, base))) { + if (prop) { + for (base= FIRSTBASE; base; base= base->next) { + if ((base != BASACT) &&(TESTBASELIB(v3d, base))) { set_ob_property(base->object, prop); } } @@ -661,9 +663,9 @@ static void copymenu_logicbricks(Scene *scene, View3D *v3d, Object *ob) //XXX no longer used - to be removed - replaced by logicbricks_copy_exec Base *base; - for(base= FIRSTBASE; base; base= base->next) { - if(base->object != ob) { - if(TESTBASELIB(v3d, base)) { + for (base= FIRSTBASE; base; base= base->next) { + if (base->object != ob) { + if (TESTBASELIB(v3d, base)) { /* first: free all logic */ free_sensors(&base->object->sensors); @@ -697,7 +699,7 @@ static void copy_texture_space(Object *to, Object *ob) float *poin1= NULL, *poin2= NULL; short texflag= 0; - if(ob->type==OB_MESH) { + if (ob->type==OB_MESH) { texflag= ((Mesh *)ob->data)->texflag; poin2= ((Mesh *)ob->data)->loc; } @@ -705,14 +707,14 @@ static void copy_texture_space(Object *to, Object *ob) texflag= ((Curve *)ob->data)->texflag; poin2= ((Curve *)ob->data)->loc; } - else if(ob->type==OB_MBALL) { + else if (ob->type==OB_MBALL) { texflag= ((MetaBall *)ob->data)->texflag; poin2= ((MetaBall *)ob->data)->loc; } else return; - if(to->type==OB_MESH) { + if (to->type==OB_MESH) { ((Mesh *)to->data)->texflag= texflag; poin1= ((Mesh *)to->data)->loc; } @@ -720,7 +722,7 @@ static void copy_texture_space(Object *to, Object *ob) ((Curve *)to->data)->texflag= texflag; poin1= ((Curve *)to->data)->loc; } - else if(to->type==OB_MBALL) { + else if (to->type==OB_MBALL) { ((MetaBall *)to->data)->texflag= texflag; poin1= ((MetaBall *)to->data)->loc; } @@ -729,7 +731,7 @@ static void copy_texture_space(Object *to, Object *ob) memcpy(poin1, poin2, 9*sizeof(float)); /* this was noted in DNA_mesh, curve, mball */ - if(to->type==OB_MESH) { + if (to->type==OB_MESH) { /* pass */ } else if (to->type == OB_MBALL) { @@ -750,58 +752,58 @@ static void copy_attr(Main *bmain, Scene *scene, View3D *v3d, short event) Nurb *nu; int do_scene_sort= 0; - if(scene->id.lib) return; + if (scene->id.lib) return; - if(!(ob=OBACT)) return; + if (!(ob=OBACT)) return; - if(scene->obedit) { // XXX get from context + if (scene->obedit) { // XXX get from context /* obedit_copymenu(); */ return; } - if(event==9) { + if (event==9) { copymenu_properties(scene, v3d, ob); return; } - else if(event==10) { + else if (event==10) { copymenu_logicbricks(scene, v3d, ob); return; } - else if(event==24) { + else if (event==24) { /* moved to object_link_modifiers */ /* copymenu_modifiers(bmain, scene, v3d, ob); */ return; } - for(base= FIRSTBASE; base; base= base->next) { - if(base != BASACT) { - if(TESTBASELIB(v3d, base)) { + for (base= FIRSTBASE; base; base= base->next) { + if (base != BASACT) { + if (TESTBASELIB(v3d, base)) { base->object->recalc |= OB_RECALC_OB; - if(event==1) { /* loc */ + if (event==1) { /* loc */ copy_v3_v3(base->object->loc, ob->loc); copy_v3_v3(base->object->dloc, ob->dloc); } - else if(event==2) { /* rot */ + else if (event==2) { /* rot */ copy_v3_v3(base->object->rot, ob->rot); copy_v3_v3(base->object->drot, ob->drot); copy_qt_qt(base->object->quat, ob->quat); copy_qt_qt(base->object->dquat, ob->dquat); } - else if(event==3) { /* size */ + else if (event==3) { /* size */ copy_v3_v3(base->object->size, ob->size); copy_v3_v3(base->object->dscale, ob->dscale); } - else if(event==4) { /* drawtype */ + else if (event==4) { /* drawtype */ base->object->dt= ob->dt; base->object->dtx= ob->dtx; base->object->empty_drawtype= ob->empty_drawtype; base->object->empty_drawsize= ob->empty_drawsize; } - else if(event==5) { /* time offs */ + else if (event==5) { /* time offs */ base->object->sf= ob->sf; } - else if(event==6) { /* dupli */ + else if (event==6) { /* dupli */ base->object->dupon= ob->dupon; base->object->dupoff= ob->dupoff; base->object->dupsta= ob->dupsta; @@ -811,17 +813,17 @@ static void copy_attr(Main *bmain, Scene *scene, View3D *v3d, short event) base->object->transflag |= (ob->transflag & OB_DUPLI); base->object->dup_group= ob->dup_group; - if(ob->dup_group) + if (ob->dup_group) id_lib_extern(&ob->dup_group->id); } - else if(event==7) { /* mass */ + else if (event==7) { /* mass */ base->object->mass= ob->mass; } - else if(event==8) { /* damping */ + else if (event==8) { /* damping */ base->object->damping= ob->damping; base->object->rdamping= ob->rdamping; } - else if(event==11) { /* all physical attributes */ + else if (event==11) { /* all physical attributes */ base->object->gameflag = ob->gameflag; base->object->inertia = ob->inertia; base->object->formfactor = ob->formfactor; @@ -836,12 +838,12 @@ static void copy_attr(Main *bmain, Scene *scene, View3D *v3d, short event) base->object->bsoft= copy_bulletsoftbody(ob->bsoft); } - else if(event==17) { /* tex space */ + else if (event==17) { /* tex space */ copy_texture_space(base->object, ob); } - else if(event==18) { /* font settings */ + else if (event==18) { /* font settings */ - if(base->object->type==ob->type) { + if (base->object->type==ob->type) { cu= ob->data; cu1= base->object->data; @@ -856,16 +858,16 @@ static void copy_attr(Main *bmain, Scene *scene, View3D *v3d, short event) cu1->wordspace= cu->wordspace; cu1->ulpos= cu->ulpos; cu1->ulheight= cu->ulheight; - if(cu1->vfont) cu1->vfont->id.us--; + if (cu1->vfont) cu1->vfont->id.us--; cu1->vfont= cu->vfont; id_us_plus((ID *)cu1->vfont); - if(cu1->vfontb) cu1->vfontb->id.us--; + if (cu1->vfontb) cu1->vfontb->id.us--; cu1->vfontb= cu->vfontb; id_us_plus((ID *)cu1->vfontb); - if(cu1->vfonti) cu1->vfonti->id.us--; + if (cu1->vfonti) cu1->vfonti->id.us--; cu1->vfonti= cu->vfonti; id_us_plus((ID *)cu1->vfonti); - if(cu1->vfontbi) cu1->vfontbi->id.us--; + if (cu1->vfontbi) cu1->vfontbi->id.us--; cu1->vfontbi= cu->vfontbi; id_us_plus((ID *)cu1->vfontbi); @@ -877,9 +879,9 @@ static void copy_attr(Main *bmain, Scene *scene, View3D *v3d, short event) base->object->recalc |= OB_RECALC_DATA; } } - else if(event==19) { /* bevel settings */ + else if (event==19) { /* bevel settings */ - if(ELEM(base->object->type, OB_CURVE, OB_FONT)) { + if (ELEM(base->object->type, OB_CURVE, OB_FONT)) { cu= ob->data; cu1= base->object->data; @@ -893,9 +895,9 @@ static void copy_attr(Main *bmain, Scene *scene, View3D *v3d, short event) base->object->recalc |= OB_RECALC_DATA; } } - else if(event==25) { /* curve resolution */ + else if (event==25) { /* curve resolution */ - if(ELEM(base->object->type, OB_CURVE, OB_FONT)) { + if (ELEM(base->object->type, OB_CURVE, OB_FONT)) { cu= ob->data; cu1= base->object->data; @@ -904,7 +906,7 @@ static void copy_attr(Main *bmain, Scene *scene, View3D *v3d, short event) nu= cu1->nurb.first; - while(nu) { + while (nu) { nu->resolu= cu1->resolu; nu= nu->next; } @@ -912,7 +914,7 @@ static void copy_attr(Main *bmain, Scene *scene, View3D *v3d, short event) base->object->recalc |= OB_RECALC_DATA; } } - else if(event==21) { + else if (event==21) { if (base->object->type==OB_MESH) { ModifierData *md = modifiers_findByType(ob, eModifierType_Subsurf); @@ -929,15 +931,15 @@ static void copy_attr(Main *bmain, Scene *scene, View3D *v3d, short event) } } } - else if(event==22) { + else if (event==22) { /* Copy the constraint channels over */ copy_constraints(&base->object->constraints, &ob->constraints, TRUE); do_scene_sort= 1; } - else if(event==23) { + else if (event==23) { base->object->softflag= ob->softflag; - if(base->object->soft) sbFree(base->object->soft); + if (base->object->soft) sbFree(base->object->soft); base->object->soft= copy_softbody(ob->soft); @@ -945,47 +947,47 @@ static void copy_attr(Main *bmain, Scene *scene, View3D *v3d, short event) BLI_addhead(&base->object->modifiers, modifier_new(eModifierType_Softbody)); } } - else if(event==26) { + else if (event==26) { #if 0 // XXX old animation system copy_nlastrips(&base->object->nlastrips, &ob->nlastrips); #endif // XXX old animation system } - else if(event==27) { /* autosmooth */ + else if (event==27) { /* autosmooth */ if (base->object->type==OB_MESH) { Mesh *me= ob->data; Mesh *cme= base->object->data; cme->smoothresh= me->smoothresh; - if(me->flag & ME_AUTOSMOOTH) + if (me->flag & ME_AUTOSMOOTH) cme->flag |= ME_AUTOSMOOTH; else cme->flag &= ~ME_AUTOSMOOTH; } } - else if(event==28) { /* UV orco */ - if(ELEM(base->object->type, OB_CURVE, OB_SURF)) { + else if (event==28) { /* UV orco */ + if (ELEM(base->object->type, OB_CURVE, OB_SURF)) { cu= ob->data; cu1= base->object->data; - if(cu->flag & CU_UV_ORCO) + if (cu->flag & CU_UV_ORCO) cu1->flag |= CU_UV_ORCO; else cu1->flag &= ~CU_UV_ORCO; } } - else if(event==29) { /* protected bits */ + else if (event==29) { /* protected bits */ base->object->protectflag= ob->protectflag; } - else if(event==30) { /* index object */ + else if (event==30) { /* index object */ base->object->index= ob->index; } - else if(event==31) { /* object color */ + else if (event==31) { /* object color */ copy_v4_v4(base->object->col, ob->col); } } } } - if(do_scene_sort) + if (do_scene_sort) DAG_scene_sort(bmain, scene); DAG_ids_flush_update(bmain, 0); @@ -997,7 +999,7 @@ static void UNUSED_FUNCTION(copy_attr_menu)(Main *bmain, Scene *scene, View3D *v short event; char str[512]; - if(!(ob=OBACT)) return; + if (!(ob=OBACT)) return; if (scene->obedit) { // XXX get from context // if (ob->type == OB_MESH) @@ -1023,27 +1025,27 @@ static void UNUSED_FUNCTION(copy_attr_menu)(Main *bmain, Scene *scene, View3D *v // strcat(str, "|Texture Space%x17"); // } - if(ob->type == OB_FONT) strcat(str, "|Font Settings%x18|Bevel Settings%x19"); - if(ob->type == OB_CURVE) strcat(str, "|Bevel Settings%x19|UV Orco%x28"); + if (ob->type == OB_FONT) strcat(str, "|Font Settings%x18|Bevel Settings%x19"); + if (ob->type == OB_CURVE) strcat(str, "|Bevel Settings%x19|UV Orco%x28"); - if((ob->type == OB_FONT) || (ob->type == OB_CURVE)) { + if ((ob->type == OB_FONT) || (ob->type == OB_CURVE)) { strcat(str, "|Curve Resolution%x25"); } - if(ob->type==OB_MESH) { + if (ob->type==OB_MESH) { strcat(str, "|Subsurf Settings%x21|AutoSmooth%x27"); } - if(ob->soft) strcat(str, "|Soft Body Settings%x23"); + if (ob->soft) strcat(str, "|Soft Body Settings%x23"); strcat(str, "|Pass Index%x30"); - if(ob->type==OB_MESH || ob->type==OB_CURVE || ob->type==OB_LATTICE || ob->type==OB_SURF) { + if (ob->type==OB_MESH || ob->type==OB_CURVE || ob->type==OB_LATTICE || ob->type==OB_SURF) { strcat(str, "|Modifiers ...%x24"); } event= pupmenu(str); - if(event<= 0) return; + if (event<= 0) return; copy_attr(bmain, scene, v3d, event); } @@ -1054,10 +1056,10 @@ static int forcefield_toggle_exec(bContext *C, wmOperator *UNUSED(op)) { Object *ob = CTX_data_active_object(C); - if(ob->pd == NULL) + if (ob->pd == NULL) ob->pd = object_add_collision_fields(PFIELD_FORCE); - if(ob->pd->forcefield == 0) + if (ob->pd->forcefield == 0) ob->pd->forcefield = PFIELD_FORCE; else ob->pd->forcefield = 0; @@ -1205,7 +1207,7 @@ static int shade_smooth_exec(bContext *C, wmOperator *op) CTX_DATA_BEGIN(C, Object*, ob, selected_editable_objects) { - if(ob->type==OB_MESH) { + if (ob->type==OB_MESH) { mesh_set_smooth_flag(ob, !clear); DAG_id_tag_update(&ob->id, OB_RECALC_DATA); @@ -1216,8 +1218,8 @@ static int shade_smooth_exec(bContext *C, wmOperator *op) else if ELEM(ob->type, OB_SURF, OB_CURVE) { cu= ob->data; - for(nu=cu->nurb.first; nu; nu=nu->next) { - if(!clear) nu->flag |= ME_SMOOTH; + for (nu=cu->nurb.first; nu; nu=nu->next) { + if (!clear) nu->flag |= ME_SMOOTH; else nu->flag &= ~ME_SMOOTH; } @@ -1279,31 +1281,31 @@ static void UNUSED_FUNCTION(image_aspect)(Scene *scene, View3D *v3d) float x, y, space; int a, b, done; - if(scene->obedit) return; // XXX get from context - if(scene->id.lib) return; + if (scene->obedit) return; // XXX get from context + if (scene->id.lib) return; - for(base= FIRSTBASE; base; base= base->next) { - if(TESTBASELIB(v3d, base)) { + for (base= FIRSTBASE; base; base= base->next) { + if (TESTBASELIB(v3d, base)) { ob= base->object; done= 0; - for(a=1; a<=ob->totcol; a++) { + for (a=1; a<=ob->totcol; a++) { ma= give_current_material(ob, a); - if(ma) { - for(b=0; bmtex[b] && ma->mtex[b]->tex) { + if (ma) { + for (b=0; bmtex[b] && ma->mtex[b]->tex) { tex= ma->mtex[b]->tex; - if(tex->type==TEX_IMAGE && tex->ima) { + if (tex->type==TEX_IMAGE && tex->ima) { ImBuf *ibuf= BKE_image_get_ibuf(tex->ima, NULL); /* texturespace */ space= 1.0; - if(ob->type==OB_MESH) { + if (ob->type==OB_MESH) { float size[3]; mesh_get_texspace(ob->data, NULL, NULL, size); space= size[0]/size[1]; } - else if(ELEM3(ob->type, OB_CURVE, OB_FONT, OB_SURF)) { + else if (ELEM3(ob->type, OB_CURVE, OB_FONT, OB_SURF)) { Curve *cu= ob->data; space= cu->size[0]/cu->size[1]; } @@ -1311,17 +1313,17 @@ static void UNUSED_FUNCTION(image_aspect)(Scene *scene, View3D *v3d) x= ibuf->x/space; y= ibuf->y; - if(x>y) ob->size[0]= ob->size[1]*x/y; + if (x>y) ob->size[0]= ob->size[1]*x/y; else ob->size[1]= ob->size[0]*y/x; done= 1; DAG_id_tag_update(&ob->id, OB_RECALC_OB); } } - if(done) break; + if (done) break; } } - if(done) break; + if (done) break; } } } @@ -1336,12 +1338,12 @@ static EnumPropertyItem *object_mode_set_itemsf(bContext *C, PointerRNA *UNUSED( Object *ob; int totitem= 0; - if(!C) /* needed for docs */ + if (!C) /* needed for docs */ return object_mode_items; ob = CTX_data_active_object(C); - while(ob && input->identifier) { - if((input->value == OB_MODE_EDIT && ((ob->type == OB_MESH) || (ob->type == OB_ARMATURE) || + while (ob && input->identifier) { + if ((input->value == OB_MODE_EDIT && ((ob->type == OB_MESH) || (ob->type == OB_ARMATURE) || (ob->type == OB_CURVE) || (ob->type == OB_SURF) || (ob->type == OB_FONT) || (ob->type == OB_MBALL) || (ob->type == OB_LATTICE))) || (input->value == OB_MODE_POSE && (ob->type == OB_ARMATURE)) || @@ -1362,19 +1364,19 @@ static EnumPropertyItem *object_mode_set_itemsf(bContext *C, PointerRNA *UNUSED( static const char *object_mode_op_string(int mode) { - if(mode & OB_MODE_EDIT) + if (mode & OB_MODE_EDIT) return "OBJECT_OT_editmode_toggle"; - if(mode == OB_MODE_SCULPT) + if (mode == OB_MODE_SCULPT) return "SCULPT_OT_sculptmode_toggle"; - if(mode == OB_MODE_VERTEX_PAINT) + if (mode == OB_MODE_VERTEX_PAINT) return "PAINT_OT_vertex_paint_toggle"; - if(mode == OB_MODE_WEIGHT_PAINT) + if (mode == OB_MODE_WEIGHT_PAINT) return "PAINT_OT_weight_paint_toggle"; - if(mode == OB_MODE_TEXTURE_PAINT) + if (mode == OB_MODE_TEXTURE_PAINT) return "PAINT_OT_texture_paint_toggle"; - if(mode == OB_MODE_PARTICLE_EDIT) + if (mode == OB_MODE_PARTICLE_EDIT) return "PARTICLE_OT_particle_edit_toggle"; - if(mode == OB_MODE_POSE) + if (mode == OB_MODE_POSE) return "OBJECT_OT_posemode_toggle"; return NULL; } @@ -1385,27 +1387,27 @@ static int object_mode_set_compat(bContext *UNUSED(C), wmOperator *op, Object *o { ObjectMode mode = RNA_enum_get(op->ptr, "mode"); - if(ob) { - if(mode == OB_MODE_OBJECT) + if (ob) { + if (mode == OB_MODE_OBJECT) return 1; switch(ob->type) { case OB_MESH: - if(mode & (OB_MODE_EDIT|OB_MODE_SCULPT|OB_MODE_VERTEX_PAINT|OB_MODE_WEIGHT_PAINT|OB_MODE_TEXTURE_PAINT|OB_MODE_PARTICLE_EDIT)) + if (mode & (OB_MODE_EDIT|OB_MODE_SCULPT|OB_MODE_VERTEX_PAINT|OB_MODE_WEIGHT_PAINT|OB_MODE_TEXTURE_PAINT|OB_MODE_PARTICLE_EDIT)) return 1; return 0; case OB_CURVE: case OB_SURF: case OB_FONT: case OB_MBALL: - if(mode & (OB_MODE_EDIT)) + if (mode & (OB_MODE_EDIT)) return 1; return 0; case OB_LATTICE: - if(mode & (OB_MODE_EDIT|OB_MODE_WEIGHT_PAINT)) + if (mode & (OB_MODE_EDIT|OB_MODE_WEIGHT_PAINT)) return 1; case OB_ARMATURE: - if(mode & (OB_MODE_EDIT|OB_MODE_POSE)) + if (mode & (OB_MODE_EDIT|OB_MODE_POSE)) return 1; } } @@ -1420,23 +1422,23 @@ static int object_mode_set_exec(bContext *C, wmOperator *op) ObjectMode restore_mode = (ob) ? ob->mode : OB_MODE_OBJECT; int toggle = RNA_boolean_get(op->ptr, "toggle"); - if(!ob || !object_mode_set_compat(C, op, ob)) + if (!ob || !object_mode_set_compat(C, op, ob)) return OPERATOR_PASS_THROUGH; /* Exit current mode if it's not the mode we're setting */ - if(ob->mode != OB_MODE_OBJECT && ob->mode != mode) + if (ob->mode != OB_MODE_OBJECT && ob->mode != mode) WM_operator_name_call(C, object_mode_op_string(ob->mode), WM_OP_EXEC_REGION_WIN, NULL); - if(mode != OB_MODE_OBJECT) { + if (mode != OB_MODE_OBJECT) { /* Enter new mode */ - if(ob->mode != mode || toggle) + if (ob->mode != mode || toggle) WM_operator_name_call(C, object_mode_op_string(mode), WM_OP_EXEC_REGION_WIN, NULL); - if(toggle) { - if(ob->mode == mode) + if (toggle) { + if (ob->mode == mode) /* For toggling, store old mode so we know what to go back to */ ob->restore_mode = restore_mode; - else if(ob->restore_mode != OB_MODE_OBJECT && ob->restore_mode != mode) { + else if (ob->restore_mode != OB_MODE_OBJECT && ob->restore_mode != mode) { WM_operator_name_call(C, object_mode_op_string(ob->restore_mode), WM_OP_EXEC_REGION_WIN, NULL); } } @@ -1472,19 +1474,19 @@ void OBJECT_OT_mode_set(wmOperatorType *ot) void ED_object_toggle_modes(bContext *C, int mode) { - if(mode & OB_MODE_SCULPT) + if (mode & OB_MODE_SCULPT) WM_operator_name_call(C, "SCULPT_OT_sculptmode_toggle", WM_OP_EXEC_REGION_WIN, NULL); - if(mode & OB_MODE_VERTEX_PAINT) + if (mode & OB_MODE_VERTEX_PAINT) WM_operator_name_call(C, "PAINT_OT_vertex_paint_toggle", WM_OP_EXEC_REGION_WIN, NULL); - if(mode & OB_MODE_WEIGHT_PAINT) + if (mode & OB_MODE_WEIGHT_PAINT) WM_operator_name_call(C, "PAINT_OT_weight_paint_toggle", WM_OP_EXEC_REGION_WIN, NULL); - if(mode & OB_MODE_TEXTURE_PAINT) + if (mode & OB_MODE_TEXTURE_PAINT) WM_operator_name_call(C, "PAINT_OT_texture_paint_toggle", WM_OP_EXEC_REGION_WIN, NULL); - if(mode & OB_MODE_PARTICLE_EDIT) + if (mode & OB_MODE_PARTICLE_EDIT) WM_operator_name_call(C, "PARTICLE_OT_particle_edit_toggle", WM_OP_EXEC_REGION_WIN, NULL); - if(mode & OB_MODE_POSE) + if (mode & OB_MODE_POSE) WM_operator_name_call(C, "OBJECT_OT_posemode_toggle", WM_OP_EXEC_REGION_WIN, NULL); - if(mode & OB_MODE_EDIT) + if (mode & OB_MODE_EDIT) WM_operator_name_call(C, "OBJECT_OT_editmode_toggle", WM_OP_EXEC_REGION_WIN, NULL); } @@ -1536,12 +1538,12 @@ static int game_property_remove(bContext *C, wmOperator *op) bProperty *prop; int index= RNA_int_get(op->ptr, "index"); - if(!ob) + if (!ob) return OPERATOR_CANCELLED; prop= BLI_findlink(&ob->prop, index); - if(prop) { + if (prop) { BLI_remlink(&ob->prop, prop); free_property(prop); @@ -1591,10 +1593,10 @@ static EnumPropertyItem *gameprops_itemf(bContext *C, PointerRNA *UNUSED(ptr), P bProperty *prop; int a, totitem= 0; - if(!ob) + if (!ob) return gameprops_items; - for(a=1, prop= ob->prop.first; prop; prop=prop->next, a++) { + for (a=1, prop= ob->prop.first; prop; prop=prop->next, a++) { tmp.value= a; tmp.identifier= prop->name; tmp.name= prop->name; @@ -1614,10 +1616,10 @@ static int game_property_copy_exec(bContext *C, wmOperator *op) int type = RNA_enum_get(op->ptr, "operation"); int propid= RNA_enum_get(op->ptr, "property"); - if(propid > 0) { /* copy */ + if (propid > 0) { /* copy */ prop = BLI_findlink(&ob->prop, propid-1); - if(prop) { + if (prop) { CTX_DATA_BEGIN(C, Object*, ob_iter, selected_editable_objects) { if (ob != ob_iter) set_ob_property(ob_iter, prop); @@ -1633,7 +1635,7 @@ static int game_property_copy_exec(bContext *C, wmOperator *op) /* merge - the default when calling with no argument */ else - for(prop = ob->prop.first; prop; prop= prop->next) + for (prop = ob->prop.first; prop; prop= prop->next) set_ob_property(ob_iter, prop); } } @@ -1694,7 +1696,7 @@ static int logicbricks_copy_exec(bContext *C, wmOperator *UNUSED(op)) Object *ob=ED_object_active_context(C); CTX_DATA_BEGIN(C, Object*, ob_iter, selected_editable_objects) { - if(ob != ob_iter) { + if (ob != ob_iter) { /* first: free all logic */ free_sensors(&ob_iter->sensors); unlink_controllers(&ob_iter->controllers); @@ -1717,7 +1719,7 @@ static int logicbricks_copy_exec(bContext *C, wmOperator *UNUSED(op)) ob_iter->state= ob->state; ob_iter->init_state= ob->init_state; - if(ob_iter->totcol==ob->totcol) { + if (ob_iter->totcol==ob->totcol) { ob_iter->actcol= ob->actcol; WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob_iter); } @@ -1750,7 +1752,7 @@ static int game_physics_copy_exec(bContext *C, wmOperator *UNUSED(op)) Object *ob=ED_object_active_context(C); CTX_DATA_BEGIN(C, Object*, ob_iter, selected_editable_objects) { - if(ob != ob_iter) { + if (ob != ob_iter) { ob_iter->gameflag = ob->gameflag; ob_iter->gameflag2 = ob->gameflag2; ob_iter->inertia = ob->inertia; @@ -1767,7 +1769,7 @@ static int game_physics_copy_exec(bContext *C, wmOperator *UNUSED(op)) ob_iter->collision_boundtype = ob->collision_boundtype; ob_iter->margin = ob->margin; ob_iter->bsoft = copy_bulletsoftbody(ob->bsoft); - if(ob->restrictflag & OB_RESTRICT_RENDER) + if (ob->restrictflag & OB_RESTRICT_RENDER) ob_iter->restrictflag |= OB_RESTRICT_RENDER; else ob_iter->restrictflag &= ~OB_RESTRICT_RENDER; diff --git a/source/blender/editors/object/object_group.c b/source/blender/editors/object/object_group.c index fd664275259..34410b87e79 100644 --- a/source/blender/editors/object/object_group.c +++ b/source/blender/editors/object/object_group.c @@ -67,13 +67,13 @@ static int objects_add_active_exec(bContext *C, wmOperator *op) Group *group; int ok = 0; - if(!ob) return OPERATOR_CANCELLED; + if (!ob) return OPERATOR_CANCELLED; /* linking to same group requires its own loop so we can avoid * looking up the active objects groups each time */ - for(group= bmain->group.first; group; group=group->id.next) { - if(object_in_group(ob, group)) { + for (group= bmain->group.first; group; group=group->id.next) { + if (object_in_group(ob, group)) { /* Assign groups to selected objects */ CTX_DATA_BEGIN(C, Base*, base, selected_editable_bases) { add_to_group(group, base->object, scene, base); @@ -83,7 +83,7 @@ static int objects_add_active_exec(bContext *C, wmOperator *op) } } - if(!ok) BKE_report(op->reports, RPT_ERROR, "Active Object contains no groups"); + if (!ok) BKE_report(op->reports, RPT_ERROR, "Active Object contains no groups"); DAG_scene_sort(bmain, scene); WM_event_add_notifier(C, NC_GROUP|NA_EDITED, NULL); @@ -114,13 +114,13 @@ static int objects_remove_active_exec(bContext *C, wmOperator *op) Group *group; int ok = 0; - if(!ob) return OPERATOR_CANCELLED; + if (!ob) return OPERATOR_CANCELLED; /* linking to same group requires its own loop so we can avoid * looking up the active objects groups each time */ - for(group= bmain->group.first; group; group=group->id.next) { - if(object_in_group(ob, group)) { + for (group= bmain->group.first; group; group=group->id.next) { + if (object_in_group(ob, group)) { /* Assign groups to selected objects */ CTX_DATA_BEGIN(C, Base*, base, selected_editable_bases) { rem_from_group(group, base->object, scene, base); @@ -130,7 +130,7 @@ static int objects_remove_active_exec(bContext *C, wmOperator *op) } } - if(!ok) BKE_report(op->reports, RPT_ERROR, "Active Object contains no groups"); + if (!ok) BKE_report(op->reports, RPT_ERROR, "Active Object contains no groups"); DAG_scene_sort(bmain, scene); WM_event_add_notifier(C, NC_GROUP|NA_EDITED, NULL); @@ -161,7 +161,7 @@ static int group_objects_remove_exec(bContext *C, wmOperator *UNUSED(op)) CTX_DATA_BEGIN(C, Base*, base, selected_editable_bases) { group = NULL; - while((group = find_group(base->object, group))) + while ((group = find_group(base->object, group))) rem_from_group(group, base->object, scene, base); } CTX_DATA_END; @@ -234,7 +234,7 @@ static int group_add_exec(bContext *C, wmOperator *UNUSED(op)) Object *ob= ED_object_context(C); Group *group; - if(ob == NULL) + if (ob == NULL) return OPERATOR_CANCELLED; group= add_group("Group"); @@ -265,7 +265,7 @@ static int group_link_exec(bContext *C, wmOperator *op) Object *ob= ED_object_context(C); Group *group= BLI_findlink(&CTX_data_main(C)->group, RNA_enum_get(op->ptr, "group")); - if(ELEM(NULL, ob, group)) + if (ELEM(NULL, ob, group)) return OPERATOR_CANCELLED; add_to_group(group, ob, scene, NULL); @@ -303,7 +303,7 @@ static int group_remove_exec(bContext *C, wmOperator *UNUSED(op)) Object *ob= ED_object_context(C); Group *group= CTX_data_pointer_get_type(C, "group", &RNA_Group).data; - if(!ob || !group) + if (!ob || !group) return OPERATOR_CANCELLED; rem_from_group(group, ob, scene, NULL); /* base will be used if found */ diff --git a/source/blender/editors/object/object_hook.c b/source/blender/editors/object/object_hook.c index 6c0df7a2076..7bb2be8e248 100644 --- a/source/blender/editors/object/object_hook.c +++ b/source/blender/editors/object/object_hook.c @@ -79,9 +79,9 @@ static int return_editmesh_indexar(BMEditMesh *em, int *tot, int **indexar, floa int *index, nr, totvert=0; BM_ITER(eve, &iter, em->bm, BM_VERTS_OF_MESH, NULL) { - if(BM_elem_flag_test(eve, BM_ELEM_SELECT)) totvert++; + if (BM_elem_flag_test(eve, BM_ELEM_SELECT)) totvert++; } - if(totvert==0) return 0; + if (totvert==0) return 0; *indexar= index= MEM_mallocN(4*totvert, "hook indexar"); *tot= totvert; @@ -89,7 +89,7 @@ static int return_editmesh_indexar(BMEditMesh *em, int *tot, int **indexar, floa zero_v3(cent); BM_ITER(eve, &iter, em->bm, BM_VERTS_OF_MESH, NULL) { - if(BM_elem_flag_test(eve, BM_ELEM_SELECT)) { + if (BM_elem_flag_test(eve, BM_ELEM_SELECT)) { *index= nr; index++; add_v3_v3(cent, eve->co); } @@ -105,7 +105,7 @@ static int return_editmesh_vgroup(Object *obedit, BMEditMesh *em, char *name, fl { zero_v3(cent); - if(obedit->actdef) { + if (obedit->actdef) { const int defgrp_index= obedit->actdef-1; int totvert=0; @@ -117,14 +117,14 @@ static int return_editmesh_vgroup(Object *obedit, BMEditMesh *em, char *name, fl BM_ITER(eve, &iter, em->bm, BM_VERTS_OF_MESH, NULL) { dvert= CustomData_bmesh_get(&em->bm->vdata, eve->head.data, CD_MDEFORMVERT); - if(dvert) { - if(defvert_find_weight(dvert, defgrp_index) > 0.0f) { + if (dvert) { + if (defvert_find_weight(dvert, defgrp_index) > 0.0f) { add_v3_v3(cent, eve->co); totvert++; } } } - if(totvert) { + if (totvert) { bDeformGroup *dg = BLI_findlink(&obedit->defbase, defgrp_index); BLI_strncpy(name, dg->name, sizeof(dg->name)); mul_v3_fl(cent, 1.0f/(float)totvert); @@ -147,9 +147,9 @@ static void select_editbmesh_hook(Object *ob, HookModifierData *hmd) return; BM_ITER(eve, &iter, em->bm, BM_VERTS_OF_MESH, NULL) { - if(nr==hmd->indexar[index]) { + if (nr==hmd->indexar[index]) { BM_elem_select_set(em->bm, eve, TRUE); - if(index < hmd->totindex-1) index++; + if (index < hmd->totindex-1) index++; } nr++; @@ -166,14 +166,14 @@ static int return_editlattice_indexar(Lattice *editlatt, int *tot, int **indexar /* count */ a= editlatt->pntsu*editlatt->pntsv*editlatt->pntsw; bp= editlatt->def; - while(a--) { - if(bp->f1 & SELECT) { - if(bp->hide==0) totvert++; + while (a--) { + if (bp->f1 & SELECT) { + if (bp->hide==0) totvert++; } bp++; } - if(totvert==0) return 0; + if (totvert==0) return 0; *indexar= index= MEM_mallocN(4*totvert, "hook indexar"); *tot= totvert; @@ -182,9 +182,9 @@ static int return_editlattice_indexar(Lattice *editlatt, int *tot, int **indexar a= editlatt->pntsu*editlatt->pntsv*editlatt->pntsw; bp= editlatt->def; - while(a--) { - if(bp->f1 & SELECT) { - if(bp->hide==0) { + while (a--) { + if (bp->f1 & SELECT) { + if (bp->hide==0) { *index= nr; index++; add_v3_v3(cent, bp->vec); } @@ -208,10 +208,10 @@ static void select_editlattice_hook(Object *obedit, HookModifierData *hmd) /* count */ a= editlt->pntsu*editlt->pntsv*editlt->pntsw; bp= editlt->def; - while(a--) { - if(hmd->indexar[index]==nr) { + while (a--) { + if (hmd->indexar[index]==nr) { bp->f1 |= SELECT; - if(index < hmd->totindex-1) index++; + if (index < hmd->totindex-1) index++; } nr++; bp++; @@ -226,49 +226,49 @@ static int return_editcurve_indexar(Object *obedit, int *tot, int **indexar, flo BezTriple *bezt; int *index, a, nr, totvert=0; - for(nu= editnurb->first; nu; nu= nu->next) { - if(nu->type == CU_BEZIER) { + for (nu= editnurb->first; nu; nu= nu->next) { + if (nu->type == CU_BEZIER) { bezt= nu->bezt; a= nu->pntsu; - while(a--) { - if(bezt->f1 & SELECT) totvert++; - if(bezt->f2 & SELECT) totvert++; - if(bezt->f3 & SELECT) totvert++; + while (a--) { + if (bezt->f1 & SELECT) totvert++; + if (bezt->f2 & SELECT) totvert++; + if (bezt->f3 & SELECT) totvert++; bezt++; } } else { bp= nu->bp; a= nu->pntsu*nu->pntsv; - while(a--) { - if(bp->f1 & SELECT) totvert++; + while (a--) { + if (bp->f1 & SELECT) totvert++; bp++; } } } - if(totvert==0) return 0; + if (totvert==0) return 0; *indexar= index= MEM_mallocN(4*totvert, "hook indexar"); *tot= totvert; nr= 0; zero_v3(cent); - for(nu= editnurb->first; nu; nu= nu->next) { - if(nu->type == CU_BEZIER) { + for (nu= editnurb->first; nu; nu= nu->next) { + if (nu->type == CU_BEZIER) { bezt= nu->bezt; a= nu->pntsu; - while(a--) { - if(bezt->f1 & SELECT) { + while (a--) { + if (bezt->f1 & SELECT) { *index= nr; index++; add_v3_v3(cent, bezt->vec[0]); } nr++; - if(bezt->f2 & SELECT) { + if (bezt->f2 & SELECT) { *index= nr; index++; add_v3_v3(cent, bezt->vec[1]); } nr++; - if(bezt->f3 & SELECT) { + if (bezt->f3 & SELECT) { *index= nr; index++; add_v3_v3(cent, bezt->vec[2]); } @@ -279,8 +279,8 @@ static int return_editcurve_indexar(Object *obedit, int *tot, int **indexar, flo else { bp= nu->bp; a= nu->pntsu*nu->pntsv; - while(a--) { - if(bp->f1 & SELECT) { + while (a--) { + if (bp->f1 & SELECT) { *index= nr; index++; add_v3_v3(cent, bp->vec); } @@ -314,9 +314,10 @@ static int object_hook_index_array(Scene *scene, Object *obedit, int *tot, int * em = me->edit_btmesh; /* check selected vertices first */ - if( return_editmesh_indexar(em, tot, indexar, cent_r)) { + if ( return_editmesh_indexar(em, tot, indexar, cent_r)) { return 1; - } else { + } + else { int ret = return_editmesh_vgroup(obedit, em, name, cent_r); return ret; } @@ -342,24 +343,24 @@ static void select_editcurve_hook(Object *obedit, HookModifierData *hmd) BezTriple *bezt; int index=0, a, nr=0; - for(nu= editnurb->first; nu; nu= nu->next) { - if(nu->type == CU_BEZIER) { + for (nu= editnurb->first; nu; nu= nu->next) { + if (nu->type == CU_BEZIER) { bezt= nu->bezt; a= nu->pntsu; - while(a--) { - if(nr == hmd->indexar[index]) { + while (a--) { + if (nr == hmd->indexar[index]) { bezt->f1 |= SELECT; - if(indextotindex-1) index++; + if (indextotindex-1) index++; } nr++; - if(nr == hmd->indexar[index]) { + if (nr == hmd->indexar[index]) { bezt->f2 |= SELECT; - if(indextotindex-1) index++; + if (indextotindex-1) index++; } nr++; - if(nr == hmd->indexar[index]) { + if (nr == hmd->indexar[index]) { bezt->f3 |= SELECT; - if(indextotindex-1) index++; + if (indextotindex-1) index++; } nr++; @@ -369,10 +370,10 @@ static void select_editcurve_hook(Object *obedit, HookModifierData *hmd) else { bp= nu->bp; a= nu->pntsu*nu->pntsv; - while(a--) { - if(nr == hmd->indexar[index]) { + while (a--) { + if (nr == hmd->indexar[index]) { bp->f1 |= SELECT; - if(indextotindex-1) index++; + if (indextotindex-1) index++; } nr++; bp++; @@ -386,10 +387,10 @@ static void object_hook_select(Object *ob, HookModifierData *hmd) if (hmd->indexar == NULL) return; - if(ob->type==OB_MESH) select_editbmesh_hook(ob, hmd); - else if(ob->type==OB_LATTICE) select_editlattice_hook(ob, hmd); - else if(ob->type==OB_CURVE) select_editcurve_hook(ob, hmd); - else if(ob->type==OB_SURF) select_editcurve_hook(ob, hmd); + if (ob->type==OB_MESH) select_editbmesh_hook(ob, hmd); + else if (ob->type==OB_LATTICE) select_editlattice_hook(ob, hmd); + else if (ob->type==OB_CURVE) select_editcurve_hook(ob, hmd); + else if (ob->type==OB_SURF) select_editcurve_hook(ob, hmd); } /* special poll operators for hook operators */ @@ -578,10 +579,10 @@ static EnumPropertyItem *hook_mod_itemf(bContext *C, PointerRNA *UNUSED(ptr), Pr ModifierData *md = NULL; int a, totitem= 0; - if(!ob) + if (!ob) return DummyRNA_NULL_items; - for(a=0, md=ob->modifiers.first; md; md= md->next, a++) { + for (a=0, md=ob->modifiers.first; md; md= md->next, a++) { if (md->type==eModifierType_Hook) { tmp.value= a; tmp.icon = ICON_HOOK; @@ -643,10 +644,10 @@ static int object_hook_reset_exec(bContext *C, wmOperator *op) } /* reset functionality */ - if(hmd->object) { + if (hmd->object) { bPoseChannel *pchan= get_pose_channel(hmd->object->pose, hmd->subtarget); - if(hmd->subtarget[0] && pchan) { + if (hmd->subtarget[0] && pchan) { float imat[4][4], mat[4][4]; /* calculate the world-space matrix for the pose-channel target first, then carry on as usual */ @@ -770,11 +771,11 @@ static int object_hook_assign_exec(bContext *C, wmOperator *op) /* assign functionality */ - if(!object_hook_index_array(scene, ob, &tot, &indexar, name, cent)) { + if (!object_hook_index_array(scene, ob, &tot, &indexar, name, cent)) { BKE_report(op->reports, RPT_WARNING, "Requires selected vertices or active vertex group"); return OPERATOR_CANCELLED; } - if(hmd->indexar) + if (hmd->indexar) MEM_freeN(hmd->indexar); copy_v3_v3(hmd->cent, cent); diff --git a/source/blender/editors/object/object_lattice.c b/source/blender/editors/object/object_lattice.c index 8d83bd6f9be..4ba62541c60 100644 --- a/source/blender/editors/object/object_lattice.c +++ b/source/blender/editors/object/object_lattice.c @@ -70,12 +70,12 @@ void free_editLatt(Object *ob) { Lattice *lt= ob->data; - if(lt->editlatt) { + if (lt->editlatt) { Lattice *editlt= lt->editlatt->latt; - if(editlt->def) + if (editlt->def) MEM_freeN(editlt->def); - if(editlt->dvert) + if (editlt->dvert) free_dverts(editlt->dvert, editlt->pntsu*editlt->pntsv*editlt->pntsw); MEM_freeN(editlt); @@ -93,20 +93,20 @@ void make_editLatt(Object *obedit) free_editLatt(obedit); actkey= ob_get_keyblock(obedit); - if(actkey) + if (actkey) key_to_latt(actkey, lt); lt->editlatt= MEM_callocN(sizeof(EditLatt), "editlatt"); lt->editlatt->latt= MEM_dupallocN(lt); lt->editlatt->latt->def= MEM_dupallocN(lt->def); - if(lt->dvert) { + if (lt->dvert) { int tot= lt->pntsu*lt->pntsv*lt->pntsw; lt->editlatt->latt->dvert = MEM_mallocN (sizeof (MDeformVert)*tot, "Lattice MDeformVert"); copy_dverts(lt->editlatt->latt->dvert, lt->dvert, tot); } - if(lt->key) lt->editlatt->shapenr= obedit->shapenr; + if (lt->key) lt->editlatt->shapenr= obedit->shapenr; } void load_editLatt(Object *obedit) @@ -120,19 +120,19 @@ void load_editLatt(Object *obedit) lt= obedit->data; editlt= lt->editlatt->latt; - if(lt->editlatt->shapenr) { + if (lt->editlatt->shapenr) { actkey= BLI_findlink(<->key->block, lt->editlatt->shapenr-1); /* active key: vertices */ tot= editlt->pntsu*editlt->pntsv*editlt->pntsw; - if(actkey->data) MEM_freeN(actkey->data); + if (actkey->data) MEM_freeN(actkey->data); fp=actkey->data= MEM_callocN(lt->key->elemsize*tot, "actkey->data"); actkey->totelem= tot; bp= editlt->def; - while(tot--) { + while (tot--) { copy_v3_v3(fp, bp->vec); fp+= 3; bp++; @@ -154,12 +154,12 @@ void load_editLatt(Object *obedit) lt->typew= editlt->typew; } - if(lt->dvert) { + if (lt->dvert) { free_dverts(lt->dvert, lt->pntsu*lt->pntsv*lt->pntsw); lt->dvert= NULL; } - if(editlt->dvert) { + if (editlt->dvert) { tot= lt->pntsu*lt->pntsv*lt->pntsw; lt->dvert = MEM_mallocN (sizeof (MDeformVert)*tot, "Lattice MDeformVert"); @@ -179,8 +179,8 @@ void ED_setflagsLatt(Object *obedit, int flag) a= lt->editlatt->latt->pntsu*lt->editlatt->latt->pntsv*lt->editlatt->latt->pntsw; - while(a--) { - if(bp->hide==0) { + while (a--) { + if (bp->hide==0) { bp->f1= flag; } bp++; @@ -201,9 +201,9 @@ static int lattice_select_all_exec(bContext *C, wmOperator *op) bp= lt->editlatt->latt->def; a= lt->editlatt->latt->pntsu*lt->editlatt->latt->pntsv*lt->editlatt->latt->pntsw; - while(a--) { - if(bp->hide==0) { - if(bp->f1) { + while (a--) { + if (bp->hide==0) { + if (bp->f1) { action = SEL_DESELECT; break; } @@ -223,8 +223,8 @@ static int lattice_select_all_exec(bContext *C, wmOperator *op) bp= lt->editlatt->latt->def; a= lt->editlatt->latt->pntsu*lt->editlatt->latt->pntsv*lt->editlatt->latt->pntsw; - while(a--) { - if(bp->hide==0) { + while (a--) { + if (bp->hide==0) { bp->f1 ^= 1; } bp++; @@ -258,7 +258,7 @@ static int make_regular_poll(bContext *C) { Object *ob; - if(ED_operator_editlattice(C)) return 1; + if (ED_operator_editlattice(C)) return 1; ob= CTX_data_active_object(C); return (ob && ob->type==OB_LATTICE); @@ -269,7 +269,7 @@ static int make_regular_exec(bContext *C, wmOperator *UNUSED(op)) Object *ob= CTX_data_edit_object(C); Lattice *lt; - if(ob) { + if (ob) { lt= ob->data; resizelattice(lt->editlatt->latt, lt->pntsu, lt->pntsv, lt->pntsw, NULL); } @@ -307,10 +307,10 @@ static void findnearestLattvert__doClosest(void *userData, BPoint *bp, int x, in struct { BPoint *bp; short dist, select; int mval[2]; } *data = userData; float temp = abs(data->mval[0]-x) + abs(data->mval[1]-y); - if((bp->f1 & SELECT)==data->select) + if ((bp->f1 & SELECT)==data->select) temp += 5; - if(tempdist) { + if (tempdist) { data->dist = temp; data->bp = bp; @@ -343,8 +343,8 @@ int mouse_lattice(bContext *C, const int mval[2], int extend) view3d_set_viewcontext(C, &vc); bp= findnearestLattvert(&vc, mval, 1); - if(bp) { - if(extend==0) { + if (bp) { + if (extend==0) { ED_setflagsLatt(vc.obedit, 0); bp->f1 |= SELECT; } @@ -392,7 +392,7 @@ static void free_undoLatt(void *data) { UndoLattice *ult= (UndoLattice*)data; - if(ult->def) MEM_freeN(ult->def); + if (ult->def) MEM_freeN(ult->def); MEM_freeN(ult); } @@ -410,7 +410,7 @@ static void *get_editlatt(bContext *C) { Object *obedit= CTX_data_edit_object(C); - if(obedit && obedit->type==OB_LATTICE) { + if (obedit && obedit->type==OB_LATTICE) { Lattice *lt= obedit->data; return lt->editlatt; } diff --git a/source/blender/editors/object/object_modifier.c b/source/blender/editors/object/object_modifier.c index 56c150bc662..cd2fa4f93b6 100644 --- a/source/blender/editors/object/object_modifier.c +++ b/source/blender/editors/object/object_modifier.c @@ -91,19 +91,19 @@ ModifierData *ED_object_modifier_add(ReportList *reports, Main *bmain, Scene *sc ModifierTypeInfo *mti = modifierType_getInfo(type); /* only geometry objects should be able to get modifiers [#25291] */ - if(!ELEM5(ob->type, OB_MESH, OB_CURVE, OB_SURF, OB_FONT, OB_LATTICE)) { + if (!ELEM5(ob->type, OB_MESH, OB_CURVE, OB_SURF, OB_FONT, OB_LATTICE)) { BKE_reportf(reports, RPT_WARNING, "Modifiers cannot be added to Object '%s'", ob->id.name+2); return NULL; } - if(mti->flags&eModifierTypeFlag_Single) { - if(modifiers_findByType(ob, type)) { + if (mti->flags&eModifierTypeFlag_Single) { + if (modifiers_findByType(ob, type)) { BKE_report(reports, RPT_WARNING, "Only one modifier of this type allowed"); return NULL; } } - if(type == eModifierType_ParticleSystem) { + if (type == eModifierType_ParticleSystem) { /* don't need to worry about the new modifier's name, since that is set to the number * of particle systems which shouldn't have too many duplicates */ @@ -113,10 +113,10 @@ ModifierData *ED_object_modifier_add(ReportList *reports, Main *bmain, Scene *sc /* get new modifier data to add */ new_md= modifier_new(type); - if(mti->flags&eModifierTypeFlag_RequiresOriginalData) { + if (mti->flags&eModifierTypeFlag_RequiresOriginalData) { md = ob->modifiers.first; - while(md && modifierType_getInfo(md->type)->type==eModifierTypeType_OnlyDeform) + while (md && modifierType_getInfo(md->type)->type==eModifierTypeType_OnlyDeform) md = md->next; BLI_insertlinkbefore(&ob->modifiers, md, new_md); @@ -124,7 +124,7 @@ ModifierData *ED_object_modifier_add(ReportList *reports, Main *bmain, Scene *sc else BLI_addtail(&ob->modifiers, new_md); - if(name) + if (name) BLI_strncpy(new_md->name, name, sizeof(new_md->name)); /* make sure modifier data has unique name */ @@ -132,22 +132,22 @@ ModifierData *ED_object_modifier_add(ReportList *reports, Main *bmain, Scene *sc modifier_unique_name(&ob->modifiers, new_md); /* special cases */ - if(type == eModifierType_Softbody) { - if(!ob->soft) { + if (type == eModifierType_Softbody) { + if (!ob->soft) { ob->soft= sbNew(scene); ob->softflag |= OB_SB_GOAL|OB_SB_EDGES; } } - else if(type == eModifierType_Collision) { - if(!ob->pd) + else if (type == eModifierType_Collision) { + if (!ob->pd) ob->pd= object_add_collision_fields(0); ob->pd->deflect= 1; DAG_scene_sort(bmain, scene); } - else if(type == eModifierType_Surface) + else if (type == eModifierType_Surface) DAG_scene_sort(bmain, scene); - else if(type == eModifierType_Multires) + else if (type == eModifierType_Multires) /* set totlvl from existing MDISPS layer if object already had it */ multiresModifier_set_levels_from_disps((MultiresModifierData *)new_md, ob); } @@ -164,60 +164,60 @@ static int object_modifier_remove(Object *ob, ModifierData *md, int *sort_depsgr /* It seems on rapid delete it is possible to * get called twice on same modifier, so make * sure it is in list. */ - for(obmd=ob->modifiers.first; obmd; obmd=obmd->next) - if(obmd==md) + for (obmd=ob->modifiers.first; obmd; obmd=obmd->next) + if (obmd==md) break; - if(!obmd) + if (!obmd) return 0; /* special cases */ - if(md->type == eModifierType_ParticleSystem) { + if (md->type == eModifierType_ParticleSystem) { ParticleSystemModifierData *psmd=(ParticleSystemModifierData*)md; BLI_remlink(&ob->particlesystem, psmd->psys); psys_free(ob, psmd->psys); psmd->psys= NULL; } - else if(md->type == eModifierType_Softbody) { - if(ob->soft) { + else if (md->type == eModifierType_Softbody) { + if (ob->soft) { sbFree(ob->soft); ob->soft= NULL; ob->softflag= 0; } } - else if(md->type == eModifierType_Collision) { - if(ob->pd) + else if (md->type == eModifierType_Collision) { + if (ob->pd) ob->pd->deflect= 0; *sort_depsgraph = 1; } - else if(md->type == eModifierType_Surface) { - if(ob->pd && ob->pd->shape == PFIELD_SHAPE_SURFACE) + else if (md->type == eModifierType_Surface) { + if (ob->pd && ob->pd->shape == PFIELD_SHAPE_SURFACE) ob->pd->shape = PFIELD_SHAPE_PLANE; *sort_depsgraph = 1; } - else if(md->type == eModifierType_Smoke) { + else if (md->type == eModifierType_Smoke) { ob->dt = OB_TEXTURE; } - else if(md->type == eModifierType_Multires) { + else if (md->type == eModifierType_Multires) { int ok= 1; ModifierData *tmpmd; /* ensure MDISPS CustomData layer isn't used by another multires modifiers */ - for(tmpmd= ob->modifiers.first; tmpmd; tmpmd= tmpmd->next) - if(tmpmd!=md && tmpmd->type == eModifierType_Multires) { + for (tmpmd= ob->modifiers.first; tmpmd; tmpmd= tmpmd->next) + if (tmpmd!=md && tmpmd->type == eModifierType_Multires) { ok= 0; break; } - if(ok) { + if (ok) { multires_customdata_delete(ob->data); } } - if(ELEM(md->type, eModifierType_Softbody, eModifierType_Cloth) && + if (ELEM(md->type, eModifierType_Softbody, eModifierType_Cloth) && ob->particlesystem.first == NULL) { ob->mode &= ~OB_MODE_PARTICLE_EDIT; } @@ -235,7 +235,7 @@ int ED_object_modifier_remove(ReportList *reports, Main *bmain, Scene *scene, Ob ok= object_modifier_remove(ob, md, &sort_depsgraph); - if(!ok) { + if (!ok) { BKE_reportf(reports, RPT_ERROR, "Modifier '%s' not in object '%s'", ob->id.name, md->name); return 0; } @@ -243,7 +243,7 @@ int ED_object_modifier_remove(ReportList *reports, Main *bmain, Scene *scene, Ob DAG_id_tag_update(&ob->id, OB_RECALC_DATA); /* sorting has to be done after the update so that dynamic systems can react properly */ - if(sort_depsgraph) + if (sort_depsgraph) DAG_scene_sort(bmain, scene); return 1; @@ -254,10 +254,10 @@ void ED_object_modifier_clear(Main *bmain, Scene *scene, Object *ob) ModifierData *md = ob->modifiers.first; int sort_depsgraph = 0; - if(!md) + if (!md) return; - while(md) { + while (md) { ModifierData *next_md; next_md= md->next; @@ -270,19 +270,19 @@ void ED_object_modifier_clear(Main *bmain, Scene *scene, Object *ob) DAG_id_tag_update(&ob->id, OB_RECALC_DATA); /* sorting has to be done after the update so that dynamic systems can react properly */ - if(sort_depsgraph) + if (sort_depsgraph) DAG_scene_sort(bmain, scene); } int ED_object_modifier_move_up(ReportList *reports, Object *ob, ModifierData *md) { - if(md->prev) { + if (md->prev) { ModifierTypeInfo *mti = modifierType_getInfo(md->type); - if(mti->type!=eModifierTypeType_OnlyDeform) { + if (mti->type!=eModifierTypeType_OnlyDeform) { ModifierTypeInfo *nmti = modifierType_getInfo(md->prev->type); - if(nmti->flags&eModifierTypeFlag_RequiresOriginalData) { + if (nmti->flags&eModifierTypeFlag_RequiresOriginalData) { BKE_report(reports, RPT_WARNING, "Cannot move above a modifier requiring original data"); return 0; } @@ -297,13 +297,13 @@ int ED_object_modifier_move_up(ReportList *reports, Object *ob, ModifierData *md int ED_object_modifier_move_down(ReportList *reports, Object *ob, ModifierData *md) { - if(md->next) { + if (md->next) { ModifierTypeInfo *mti = modifierType_getInfo(md->type); - if(mti->flags&eModifierTypeFlag_RequiresOriginalData) { + if (mti->flags&eModifierTypeFlag_RequiresOriginalData) { ModifierTypeInfo *nmti = modifierType_getInfo(md->next->type); - if(nmti->type!=eModifierTypeType_OnlyDeform) { + if (nmti->type!=eModifierTypeType_OnlyDeform) { BKE_report(reports, RPT_WARNING, "Cannot move beyond a non-deforming modifier"); return 0; } @@ -329,43 +329,43 @@ int ED_object_modifier_convert(ReportList *UNUSED(reports), Main *bmain, Scene * int totvert=0, totedge=0, cvert=0; int totpart=0, totchild=0; - if(md->type != eModifierType_ParticleSystem) return 0; - if(ob && ob->mode & OB_MODE_PARTICLE_EDIT) return 0; + if (md->type != eModifierType_ParticleSystem) return 0; + if (ob && ob->mode & OB_MODE_PARTICLE_EDIT) return 0; psys=((ParticleSystemModifierData *)md)->psys; part= psys->part; - if(part->ren_as != PART_DRAW_PATH || psys->pathcache == NULL) + if (part->ren_as != PART_DRAW_PATH || psys->pathcache == NULL) return 0; totpart= psys->totcached; totchild= psys->totchildcache; - if(totchild && (part->draw&PART_DRAW_PARENT)==0) + if (totchild && (part->draw&PART_DRAW_PARENT)==0) totpart= 0; /* count */ cache= psys->pathcache; - for(a=0; asteps > 0) { + if (key->steps > 0) { totvert+= key->steps+1; totedge+= key->steps; } } cache= psys->childcache; - for(a=0; asteps > 0) { + if (key->steps > 0) { totvert+= key->steps+1; totedge+= key->steps; } } - if(totvert==0) return 0; + if (totvert==0) return 0; /* add new mesh */ obn= add_object(scene, OB_MESH); @@ -383,12 +383,12 @@ int ED_object_modifier_convert(ReportList *UNUSED(reports), Main *bmain, Scene * /* copy coordinates */ cache= psys->pathcache; - for(a=0; asteps; - for(k=0; k<=kmax; k++,key++,cvert++,mvert++) { + for (k=0; k<=kmax; k++,key++,cvert++,mvert++) { copy_v3_v3(mvert->co,key->co); - if(k) { + if (k) { medge->v1= cvert-1; medge->v2= cvert; medge->flag= ME_EDGEDRAW|ME_EDGERENDER|ME_LOOSEEDGE; @@ -402,12 +402,12 @@ int ED_object_modifier_convert(ReportList *UNUSED(reports), Main *bmain, Scene * } cache=psys->childcache; - for(a=0; asteps; - for(k=0; k<=kmax; k++,key++,cvert++,mvert++) { + for (k=0; k<=kmax; k++,key++,cvert++,mvert++) { copy_v3_v3(mvert->co,key->co); - if(k) { + if (k) { medge->v1=cvert-1; medge->v2=cvert; medge->flag= ME_EDGEDRAW|ME_EDGERENDER|ME_LOOSEEDGE; @@ -453,7 +453,7 @@ static int modifier_apply_shape(ReportList *reports, Scene *scene, Object *ob, M Key *key=me->key; KeyBlock *kb; - if(!modifier_sameTopology(md) || mti->type == eModifierTypeType_NonGeometrical) { + if (!modifier_sameTopology(md) || mti->type == eModifierTypeType_NonGeometrical) { BKE_report(reports, RPT_ERROR, "Only deforming modifiers can be applied to Shapes"); return 0; } @@ -464,7 +464,7 @@ static int modifier_apply_shape(ReportList *reports, Scene *scene, Object *ob, M return 0; } - if(key == NULL) { + if (key == NULL) { key= me->key= add_key((ID *)me); key->type= KEY_RELATIVE; /* if that was the first key block added, then it was the basis. @@ -501,21 +501,22 @@ static int modifier_apply_obdata(ReportList *reports, Scene *scene, Object *ob, Mesh *me = ob->data; MultiresModifierData *mmd= find_multires_modifier_before(scene, md); - if(me->key && mti->type != eModifierTypeType_NonGeometrical) { + if (me->key && mti->type != eModifierTypeType_NonGeometrical) { BKE_report(reports, RPT_ERROR, "Modifier cannot be applied to Mesh with Shape Keys"); return 0; } /* Multires: ensure that recent sculpting is applied */ - if(md->type == eModifierType_Multires) + if (md->type == eModifierType_Multires) multires_force_update(ob); if (mmd && mmd->totlvl && mti->type==eModifierTypeType_OnlyDeform) { - if(!multiresModifier_reshapeFromDeformMod (scene, mmd, ob, md)) { + if (!multiresModifier_reshapeFromDeformMod (scene, mmd, ob, md)) { BKE_report(reports, RPT_ERROR, "Multires modifier returned error, skipping apply"); return 0; } - } else { + } + else { dm = mesh_create_derived_for_modifier(scene, ob, md, 1); if (!dm) { BKE_report(reports, RPT_ERROR, "Modifier returned error, skipping apply"); @@ -526,7 +527,7 @@ static int modifier_apply_obdata(ReportList *reports, Scene *scene, Object *ob, dm->release(dm); - if(md->type == eModifierType_Multires) + if (md->type == eModifierType_Multires) multires_customdata_delete(me); } } @@ -557,13 +558,13 @@ static int modifier_apply_obdata(ReportList *reports, Scene *scene, Object *ob, } /* lattice modifier can be applied to particle system too */ - if(ob->particlesystem.first) { + if (ob->particlesystem.first) { ParticleSystem *psys = ob->particlesystem.first; - for(; psys; psys=psys->next) { + for (; psys; psys=psys->next) { - if(psys->part->type != PART_HAIR) + if (psys->part->type != PART_HAIR) continue; psys_apply_hair_lattice(scene, ob, psys); @@ -580,7 +581,8 @@ int ED_object_modifier_apply(ReportList *reports, Scene *scene, Object *ob, Modi if (scene->obedit) { BKE_report(reports, RPT_ERROR, "Modifiers cannot be applied in editmode"); return 0; - } else if (((ID*) ob->data)->us>1) { + } + else if (((ID*) ob->data)->us>1) { BKE_report(reports, RPT_ERROR, "Modifiers cannot be applied to multi-user data"); return 0; } @@ -597,7 +599,8 @@ int ED_object_modifier_apply(ReportList *reports, Scene *scene, Object *ob, Modi md->mode= prev_mode; return 0; } - } else { + } + else { if (!modifier_apply_obdata(reports, scene, ob, md)) { md->mode= prev_mode; return 0; @@ -631,7 +634,7 @@ static int modifier_add_exec(bContext *C, wmOperator *op) Object *ob = ED_object_active_context(C); int type= RNA_enum_get(op->ptr, "type"); - if(!ED_object_modifier_add(op->reports, bmain, scene, ob, NULL, type)) + if (!ED_object_modifier_add(op->reports, bmain, scene, ob, NULL, type)) return OPERATOR_CANCELLED; WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, ob); @@ -646,19 +649,19 @@ static EnumPropertyItem *modifier_add_itemf(bContext *C, PointerRNA *UNUSED(ptr) ModifierTypeInfo *mti; int totitem= 0, a; - if(!ob) + if (!ob) return modifier_type_items; - for(a=0; modifier_type_items[a].identifier; a++) { + for (a=0; modifier_type_items[a].identifier; a++) { md_item= &modifier_type_items[a]; - if(md_item->identifier[0]) { + if (md_item->identifier[0]) { mti= modifierType_getInfo(md_item->value); - if(mti->flags & eModifierTypeFlag_NoUserAdd) + if (mti->flags & eModifierTypeFlag_NoUserAdd) continue; - if(!object_support_modifier_type(ob, md_item->value)) + if (!object_support_modifier_type(ob, md_item->value)) continue; } else { @@ -668,7 +671,7 @@ static EnumPropertyItem *modifier_add_itemf(bContext *C, PointerRNA *UNUSED(ptr) continue; } - if(group_item) { + if (group_item) { RNA_enum_item_add(&item, &totitem, group_item); group_item= NULL; } @@ -770,15 +773,15 @@ static int modifier_remove_exec(bContext *C, wmOperator *op) ModifierData *md = edit_modifier_property_get(op, ob, 0); int mode_orig = ob ? ob->mode : 0; - if(!ob || !md || !ED_object_modifier_remove(op->reports, bmain, scene, ob, md)) + if (!ob || !md || !ED_object_modifier_remove(op->reports, bmain, scene, ob, md)) return OPERATOR_CANCELLED; WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, ob); /* if cloth/softbody was removed, particle mode could be cleared */ - if(mode_orig & OB_MODE_PARTICLE_EDIT) - if((ob->mode & OB_MODE_PARTICLE_EDIT)==0) - if(scene->basact && scene->basact->object==ob) + if (mode_orig & OB_MODE_PARTICLE_EDIT) + if ((ob->mode & OB_MODE_PARTICLE_EDIT)==0) + if (scene->basact && scene->basact->object==ob) WM_event_add_notifier(C, NC_SCENE|ND_MODE|NS_MODE_OBJECT, NULL); return OPERATOR_FINISHED; @@ -814,7 +817,7 @@ static int modifier_move_up_exec(bContext *C, wmOperator *op) Object *ob = ED_object_active_context(C); ModifierData *md = edit_modifier_property_get(op, ob, 0); - if(!ob || !md || !ED_object_modifier_move_up(op->reports, ob, md)) + if (!ob || !md || !ED_object_modifier_move_up(op->reports, ob, md)) return OPERATOR_CANCELLED; DAG_id_tag_update(&ob->id, OB_RECALC_DATA); @@ -853,7 +856,7 @@ static int modifier_move_down_exec(bContext *C, wmOperator *op) Object *ob = ED_object_active_context(C); ModifierData *md = edit_modifier_property_get(op, ob, 0); - if(!ob || !md || !ED_object_modifier_move_down(op->reports, ob, md)) + if (!ob || !md || !ED_object_modifier_move_down(op->reports, ob, md)) return OPERATOR_CANCELLED; DAG_id_tag_update(&ob->id, OB_RECALC_DATA); @@ -894,7 +897,7 @@ static int modifier_apply_exec(bContext *C, wmOperator *op) ModifierData *md = edit_modifier_property_get(op, ob, 0); int apply_as= RNA_enum_get(op->ptr, "apply_as"); - if(!ob || !md || !ED_object_modifier_apply(op->reports, scene, ob, md, apply_as)) { + if (!ob || !md || !ED_object_modifier_apply(op->reports, scene, ob, md, apply_as)) { return OPERATOR_CANCELLED; } @@ -943,7 +946,7 @@ static int modifier_convert_exec(bContext *C, wmOperator *op) Object *ob = ED_object_active_context(C); ModifierData *md = edit_modifier_property_get(op, ob, 0); - if(!ob || !md || !ED_object_modifier_convert(op->reports, bmain, scene, ob, md)) + if (!ob || !md || !ED_object_modifier_convert(op->reports, bmain, scene, ob, md)) return OPERATOR_CANCELLED; DAG_id_tag_update(&ob->id, OB_RECALC_DATA); @@ -982,7 +985,7 @@ static int modifier_copy_exec(bContext *C, wmOperator *op) Object *ob = ED_object_active_context(C); ModifierData *md = edit_modifier_property_get(op, ob, 0); - if(!ob || !md || !ED_object_modifier_copy(op->reports, ob, md)) + if (!ob || !md || !ED_object_modifier_copy(op->reports, ob, md)) return OPERATOR_CANCELLED; DAG_id_tag_update(&ob->id, OB_RECALC_DATA); @@ -1111,25 +1114,25 @@ static int multires_reshape_exec(bContext *C, wmOperator *op) if (!mmd) return OPERATOR_CANCELLED; - if(mmd->lvl==0) { + if (mmd->lvl==0) { BKE_report(op->reports, RPT_ERROR, "Reshape can work only with higher levels of subdivisions"); return OPERATOR_CANCELLED; } CTX_DATA_BEGIN(C, Object*, selob, selected_editable_objects) { - if(selob->type == OB_MESH && selob != ob) { + if (selob->type == OB_MESH && selob != ob) { secondob= selob; break; } } CTX_DATA_END; - if(!secondob) { + if (!secondob) { BKE_report(op->reports, RPT_ERROR, "Second selected mesh object require to copy shape from"); return OPERATOR_CANCELLED; } - if(!multiresModifier_reshape(scene, mmd, ob, secondob)) { + if (!multiresModifier_reshape(scene, mmd, ob, secondob)) { BKE_report(op->reports, RPT_ERROR, "Objects do not have the same number of vertices"); return OPERATOR_CANCELLED; } @@ -1174,15 +1177,15 @@ static int multires_external_save_exec(bContext *C, wmOperator *op) char path[FILE_MAX]; int relative= RNA_boolean_get(op->ptr, "relative_path"); - if(!me) + if (!me) return OPERATOR_CANCELLED; - if(CustomData_external_test(&me->ldata, CD_MDISPS)) + if (CustomData_external_test(&me->ldata, CD_MDISPS)) return OPERATOR_CANCELLED; RNA_string_get(op->ptr, "filepath", path); - if(relative) + if (relative) BLI_path_rel(path, G.main->name); CustomData_external_add(&me->ldata, &me->id, CD_MDISPS, me->totloop, path); @@ -1206,10 +1209,10 @@ static int multires_external_save_invoke(bContext *C, wmOperator *op, wmEvent *U if (!mmd) return OPERATOR_CANCELLED; - if(CustomData_external_test(&me->ldata, CD_MDISPS)) + if (CustomData_external_test(&me->ldata, CD_MDISPS)) return OPERATOR_CANCELLED; - if(RNA_struct_property_is_set(op->ptr, "filepath")) + if (RNA_struct_property_is_set(op->ptr, "filepath")) return multires_external_save_exec(C, op); op->customdata= me; @@ -1247,7 +1250,7 @@ static int multires_external_pack_exec(bContext *C, wmOperator *UNUSED(op)) Object *ob = ED_object_active_context(C); Mesh *me= ob->data; - if(!CustomData_external_test(&me->ldata, CD_MDISPS)) + if (!CustomData_external_test(&me->ldata, CD_MDISPS)) return OPERATOR_CANCELLED; // XXX don't remove.. @@ -1327,15 +1330,15 @@ static int meshdeform_bind_exec(bContext *C, wmOperator *op) if (!mmd) return OPERATOR_CANCELLED; - if(mmd->bindcagecos) { + if (mmd->bindcagecos) { MEM_freeN(mmd->bindcagecos); - if(mmd->dyngrid) MEM_freeN(mmd->dyngrid); - if(mmd->dyninfluences) MEM_freeN(mmd->dyninfluences); - if(mmd->bindinfluences) MEM_freeN(mmd->bindinfluences); - if(mmd->bindoffsets) MEM_freeN(mmd->bindoffsets); - if(mmd->dynverts) MEM_freeN(mmd->dynverts); - if(mmd->bindweights) MEM_freeN(mmd->bindweights); /* deprecated */ - if(mmd->bindcos) MEM_freeN(mmd->bindcos); /* deprecated */ + if (mmd->dyngrid) MEM_freeN(mmd->dyngrid); + if (mmd->dyninfluences) MEM_freeN(mmd->dyninfluences); + if (mmd->bindinfluences) MEM_freeN(mmd->bindinfluences); + if (mmd->bindoffsets) MEM_freeN(mmd->bindoffsets); + if (mmd->dynverts) MEM_freeN(mmd->dynverts); + if (mmd->bindweights) MEM_freeN(mmd->bindweights); /* deprecated */ + if (mmd->bindcos) MEM_freeN(mmd->bindcos); /* deprecated */ mmd->bindcagecos= NULL; mmd->dyngrid= NULL; @@ -1359,17 +1362,17 @@ static int meshdeform_bind_exec(bContext *C, wmOperator *op) mmd->bindfunc= mesh_deform_bind; mmd->modifier.mode |= eModifierMode_Realtime; - if(ob->type == OB_MESH) { + if (ob->type == OB_MESH) { dm= mesh_create_derived_view(scene, ob, 0); dm->release(dm); } - else if(ob->type == OB_LATTICE) { + else if (ob->type == OB_LATTICE) { lattice_calc_modifiers(scene, ob); } - else if(ob->type==OB_MBALL) { + else if (ob->type==OB_MBALL) { makeDispListMBall(scene, ob); } - else if(ELEM3(ob->type, OB_CURVE, OB_SURF, OB_FONT)) { + else if (ELEM3(ob->type, OB_CURVE, OB_SURF, OB_FONT)) { makeDispListCurveTypes(scene, ob, 0); } diff --git a/source/blender/editors/object/object_ops.c b/source/blender/editors/object/object_ops.c index b8ff71c59a2..12387f36ca4 100644 --- a/source/blender/editors/object/object_ops.c +++ b/source/blender/editors/object/object_ops.c @@ -222,7 +222,7 @@ void ED_operatormacros_object(void) wmOperatorTypeMacro *otmacro; ot = WM_operatortype_append_macro("OBJECT_OT_duplicate_move", "Duplicate Objects", OPTYPE_UNDO|OPTYPE_REGISTER); - if(ot) { + if (ot) { ot->description = "Duplicate selected objects and move them"; WM_operatortype_macro_define(ot, "OBJECT_OT_duplicate"); otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate"); @@ -231,7 +231,7 @@ void ED_operatormacros_object(void) /* grr, should be able to pass options on... */ ot = WM_operatortype_append_macro("OBJECT_OT_duplicate_move_linked", "Duplicate Linked", OPTYPE_UNDO|OPTYPE_REGISTER); - if(ot) { + if (ot) { ot->description = "Duplicate selected objects and move them"; otmacro = WM_operatortype_macro_define(ot, "OBJECT_OT_duplicate"); RNA_boolean_set(otmacro->ptr, "linked", TRUE); @@ -241,7 +241,7 @@ void ED_operatormacros_object(void) /* XXX */ ot = WM_operatortype_append_macro("OBJECT_OT_add_named_cursor", "Add named object at cursor", OPTYPE_UNDO|OPTYPE_REGISTER); - if(ot) { + if (ot) { ot->description = "Add named object at cursor"; RNA_def_string(ot->srna, "name", "Cube", MAX_ID_NAME-2, "Name", "Object name to add"); @@ -391,7 +391,7 @@ void ED_keymap_object(wmKeyConfig *keyconf) WM_keymap_add_menu(keymap, "VIEW3D_MT_object_specials", WKEY, KM_PRESS, 0, 0); - for(i=0; i<=5; i++) { + for (i=0; i<=5; i++) { kmi = WM_keymap_add_item(keymap, "OBJECT_OT_subdivision_set", ZEROKEY+i, KM_PRESS, KM_CTRL, 0); RNA_int_set(kmi->ptr, "level", i); } @@ -421,7 +421,7 @@ void ED_object_generic_keymap(struct wmKeyConfig *UNUSED(keyconf), struct wmKeyM wmKeyMapItem *kmi; /* used by mesh, curve & lattice only */ - if(do_pet) { + if (do_pet) { /* context ops */ kmi = WM_keymap_add_item(keymap, "WM_OT_context_cycle_enum", OKEY, KM_PRESS, KM_SHIFT, 0); RNA_string_set(kmi->ptr, "data_path", "tool_settings.proportional_edit_falloff"); @@ -432,7 +432,8 @@ void ED_object_generic_keymap(struct wmKeyConfig *UNUSED(keyconf), struct wmKeyM kmi = WM_keymap_add_item(keymap, "WM_OT_context_toggle", OKEY, KM_PRESS, 0, 0); RNA_string_set(kmi->ptr, "data_path", "tool_settings.use_proportional_edit_objects"); - } else { // Edit mode + } + else { // Edit mode kmi = WM_keymap_add_item(keymap, "WM_OT_context_toggle_enum", OKEY, KM_PRESS, 0, 0); RNA_string_set(kmi->ptr, "data_path", "tool_settings.proportional_edit"); diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c index 8754aa2ca5a..906ee65b45d 100644 --- a/source/blender/editors/object/object_relations.c +++ b/source/blender/editors/object/object_relations.c @@ -124,7 +124,7 @@ static int vertex_parent_set_exec(bContext *C, wmOperator *op) /* we need 1 to 3 selected vertices */ - if(obedit->type==OB_MESH) { + if (obedit->type==OB_MESH) { Mesh *me= obedit->data; BMEditMesh *em; @@ -139,31 +139,31 @@ static int vertex_parent_set_exec(bContext *C, wmOperator *op) BM_ITER(eve, &iter, em->bm, BM_VERTS_OF_MESH, NULL) { if (BM_elem_flag_test(eve, BM_ELEM_SELECT)) { - if(v1==0) v1= nr; - else if(v2==0) v2= nr; - else if(v3==0) v3= nr; - else if(v4==0) v4= nr; + if (v1==0) v1= nr; + else if (v2==0) v2= nr; + else if (v3==0) v3= nr; + else if (v4==0) v4= nr; else break; } nr++; } } - else if(ELEM(obedit->type, OB_SURF, OB_CURVE)) { + else if (ELEM(obedit->type, OB_SURF, OB_CURVE)) { ListBase *editnurb= object_editcurve_get(obedit); cu= obedit->data; nu= editnurb->first; - while(nu) { - if(nu->type == CU_BEZIER) { + while (nu) { + if (nu->type == CU_BEZIER) { bezt= nu->bezt; a= nu->pntsu; - while(a--) { - if(BEZSELECTED_HIDDENHANDLES(cu, bezt)) { - if(v1==0) v1= nr; - else if(v2==0) v2= nr; - else if(v3==0) v3= nr; - else if(v4==0) v4= nr; + while (a--) { + if (BEZSELECTED_HIDDENHANDLES(cu, bezt)) { + if (v1==0) v1= nr; + else if (v2==0) v2= nr; + else if (v3==0) v3= nr; + else if (v4==0) v4= nr; else break; } nr++; @@ -173,12 +173,12 @@ static int vertex_parent_set_exec(bContext *C, wmOperator *op) else { bp= nu->bp; a= nu->pntsu*nu->pntsv; - while(a--) { - if(bp->f1 & SELECT) { - if(v1==0) v1= nr; - else if(v2==0) v2= nr; - else if(v3==0) v3= nr; - else if(v4==0) v4= nr; + while (a--) { + if (bp->f1 & SELECT) { + if (v1==0) v1= nr; + else if (v2==0) v2= nr; + else if (v3==0) v3= nr; + else if (v4==0) v4= nr; else break; } nr++; @@ -188,17 +188,17 @@ static int vertex_parent_set_exec(bContext *C, wmOperator *op) nu= nu->next; } } - else if(obedit->type==OB_LATTICE) { + else if (obedit->type==OB_LATTICE) { Lattice *lt= obedit->data; a= lt->editlatt->latt->pntsu*lt->editlatt->latt->pntsv*lt->editlatt->latt->pntsw; bp= lt->editlatt->latt->def; - while(a--) { - if(bp->f1 & SELECT) { - if(v1==0) v1= nr; - else if(v2==0) v2= nr; - else if(v3==0) v3= nr; - else if(v4==0) v4= nr; + while (a--) { + if (bp->f1 & SELECT) { + if (v1==0) v1= nr; + else if (v2==0) v2= nr; + else if (v3==0) v3= nr; + else if (v4==0) v4= nr; else break; } nr++; @@ -206,28 +206,28 @@ static int vertex_parent_set_exec(bContext *C, wmOperator *op) } } - if(v4 || !((v1 && v2==0 && v3==0) || (v1 && v2 && v3)) ) { + if (v4 || !((v1 && v2==0 && v3==0) || (v1 && v2 && v3)) ) { BKE_report(op->reports, RPT_ERROR, "Select either 1 or 3 vertices to parent to"); return OPERATOR_CANCELLED; } CTX_DATA_BEGIN(C, Object*, ob, selected_editable_objects) { - if(ob != obedit) { + if (ob != obedit) { ob->recalc |= OB_RECALC_OB|OB_RECALC_DATA|OB_RECALC_TIME; par= obedit->parent; - while(par) { - if(par==ob) break; + while (par) { + if (par==ob) break; par= par->parent; } - if(par) { + if (par) { BKE_report(op->reports, RPT_ERROR, "Loop in parents"); } else { Object workob; ob->parent= BASACT->object; - if(v3) { + if (v3) { ob->partype= PARVERT3; ob->par1= v1-1; ob->par2= v2-1; @@ -375,7 +375,7 @@ static EnumPropertyItem *proxy_group_object_itemf(bContext *C, PointerRNA *UNUSE Object *ob= ED_object_active_context(C); GroupObject *go; - if(!ob || !ob->dup_group) + if (!ob || !ob->dup_group) return DummyRNA_DEFAULT_items; /* find the object to affect */ @@ -430,17 +430,17 @@ void ED_object_parent_clear(bContext *C, int type) CTX_DATA_BEGIN(C, Object*, ob, selected_editable_objects) { - if(ob->parent == NULL) + if (ob->parent == NULL) continue; - if(type == 0) { + if (type == 0) { ob->parent= NULL; } - else if(type == 1) { + else if (type == 1) { ob->parent= NULL; object_apply_mat4(ob, ob->obmat, TRUE, FALSE); } - else if(type == 2) + else if (type == 2) unit_m4(ob->parentinv); ob->recalc |= OB_RECALC_OB|OB_RECALC_DATA|OB_RECALC_TIME; @@ -524,20 +524,20 @@ int ED_object_parent_set(ReportList *reports, Main *bmain, Scene *scene, Object par->recalc |= OB_RECALC_OB; /* preconditions */ - if(partype==PAR_FOLLOW || partype==PAR_PATH_CONST) { - if(par->type!=OB_CURVE) + if (partype==PAR_FOLLOW || partype==PAR_PATH_CONST) { + if (par->type!=OB_CURVE) return 0; else { Curve *cu= par->data; - if((cu->flag & CU_PATH)==0) { + if ((cu->flag & CU_PATH)==0) { cu->flag |= CU_PATH|CU_FOLLOW; makeDispListCurveTypes(scene, par, 0); /* force creation of path data */ } else cu->flag |= CU_FOLLOW; /* if follow, add F-Curve for ctime (i.e. "eval_time") so that path-follow works */ - if(partype == PAR_FOLLOW) { + if (partype == PAR_FOLLOW) { /* get or create F-Curve */ bAction *act = verify_adt_action(&cu->id, 1); FCurve *fcu = verify_fcurve(act, NULL, "eval_time", 0, 1); @@ -548,14 +548,14 @@ int ED_object_parent_set(ReportList *reports, Main *bmain, Scene *scene, Object } /* fall back on regular parenting now (for follow only) */ - if(partype == PAR_FOLLOW) + if (partype == PAR_FOLLOW) partype= PAR_OBJECT; } } - else if(partype==PAR_BONE) { + else if (partype==PAR_BONE) { pchan= get_active_posechannel(par); - if(pchan==NULL) { + if (pchan==NULL) { BKE_report(reports, RPT_ERROR, "No active Bone"); return 0; } @@ -620,7 +620,7 @@ int ED_object_parent_set(ReportList *reports, Main *bmain, Scene *scene, Object ob->partype= PAROBJECT; /* note, dna define, not operator property */ /* constraint */ - if(partype == PAR_PATH_CONST) { + if (partype == PAR_PATH_CONST) { bConstraint *con; bFollowPathConstraint *data; float cmat[4][4], vec[3]; @@ -637,12 +637,12 @@ int ED_object_parent_set(ReportList *reports, Main *bmain, Scene *scene, Object ob->loc[1] = vec[1]; ob->loc[2] = vec[2]; } - else if(pararm && ob->type==OB_MESH && par->type == OB_ARMATURE) { - if(partype == PAR_ARMATURE_NAME) + else if (pararm && ob->type==OB_MESH && par->type == OB_ARMATURE) { + if (partype == PAR_ARMATURE_NAME) create_vgroups_from_armature(reports, scene, ob, par, ARM_GROUPS_NAME, 0); - else if(partype == PAR_ARMATURE_ENVELOPE) + else if (partype == PAR_ARMATURE_ENVELOPE) create_vgroups_from_armature(reports, scene, ob, par, ARM_GROUPS_ENVELOPE, 0); - else if(partype == PAR_ARMATURE_AUTO) { + else if (partype == PAR_ARMATURE_AUTO) { WM_cursor_wait(1); create_vgroups_from_armature(reports, scene, ob, par, ARM_GROUPS_AUTO, 0); WM_cursor_wait(0); @@ -705,19 +705,19 @@ static int parent_set_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *UNUSE uiItemEnumO(layout, "OBJECT_OT_parent_set", NULL, 0, "type", PAR_OBJECT); /* ob becomes parent, make the associated menus */ - if(ob->type==OB_ARMATURE) { + if (ob->type==OB_ARMATURE) { uiItemEnumO(layout, "OBJECT_OT_parent_set", NULL, 0, "type", PAR_ARMATURE); uiItemEnumO(layout, "OBJECT_OT_parent_set", NULL, 0, "type", PAR_ARMATURE_NAME); uiItemEnumO(layout, "OBJECT_OT_parent_set", NULL, 0, "type", PAR_ARMATURE_ENVELOPE); uiItemEnumO(layout, "OBJECT_OT_parent_set", NULL, 0, "type", PAR_ARMATURE_AUTO); uiItemEnumO(layout, "OBJECT_OT_parent_set", NULL, 0, "type", PAR_BONE); } - else if(ob->type==OB_CURVE) { + else if (ob->type==OB_CURVE) { uiItemEnumO(layout, "OBJECT_OT_parent_set", NULL, 0, "type", PAR_CURVE); uiItemEnumO(layout, "OBJECT_OT_parent_set", NULL, 0, "type", PAR_FOLLOW); uiItemEnumO(layout, "OBJECT_OT_parent_set", NULL, 0, "type", PAR_PATH_CONST); } - else if(ob->type == OB_LATTICE) { + else if (ob->type == OB_LATTICE) { uiItemEnumO(layout, "OBJECT_OT_parent_set", NULL, 0, "type", PAR_LATTICE); } @@ -808,8 +808,8 @@ static int object_slow_parent_clear_exec(bContext *C, wmOperator *UNUSED(op)) Scene *scene= CTX_data_scene(C); CTX_DATA_BEGIN(C, Object*, ob, selected_editable_objects) { - if(ob->parent) { - if(ob->partype & PARSLOW) { + if (ob->parent) { + if (ob->partype & PARSLOW) { ob->partype -= PARSLOW; where_is_object(scene, ob); ob->partype |= PARSLOW; @@ -850,7 +850,7 @@ static int object_slow_parent_set_exec(bContext *C, wmOperator *UNUSED(op)) Scene *scene= CTX_data_scene(C); CTX_DATA_BEGIN(C, Object*, ob, selected_editable_objects) { - if(ob->parent) + if (ob->parent) ob->partype |= PARSLOW; ob->recalc |= OB_RECALC_OB; @@ -896,7 +896,7 @@ static int object_track_clear_exec(bContext *C, wmOperator *op) Scene *scene= CTX_data_scene(C); int type= RNA_enum_get(op->ptr, "type"); - if(CTX_data_edit_object(C)) { + if (CTX_data_edit_object(C)) { BKE_report(op->reports, RPT_ERROR, "Operation cannot be performed in EditMode"); return OPERATOR_CANCELLED; } @@ -914,7 +914,7 @@ static int object_track_clear_exec(bContext *C, wmOperator *op) remove_constraint(&ob->constraints, con); } - if(type == 1) + if (type == 1) object_apply_mat4(ob, ob->obmat, TRUE, TRUE); } CTX_DATA_END; @@ -962,12 +962,12 @@ static int track_set_exec(bContext *C, wmOperator *op) int type= RNA_enum_get(op->ptr, "type"); - if(type == 1) { + if (type == 1) { bConstraint *con; bDampTrackConstraint *data; CTX_DATA_BEGIN(C, Object*, ob, selected_editable_objects) { - if(ob!=obact) { + if (ob!=obact) { con = add_ob_constraint(ob, "AutoTrack", CONSTRAINT_TYPE_DAMPTRACK); data = con->data; @@ -981,12 +981,12 @@ static int track_set_exec(bContext *C, wmOperator *op) } CTX_DATA_END; } - else if(type == 2) { + else if (type == 2) { bConstraint *con; bTrackToConstraint *data; CTX_DATA_BEGIN(C, Object*, ob, selected_editable_objects) { - if(ob!=obact) { + if (ob!=obact) { con = add_ob_constraint(ob, "AutoTrack", CONSTRAINT_TYPE_TRACKTO); data = con->data; @@ -1002,12 +1002,12 @@ static int track_set_exec(bContext *C, wmOperator *op) } CTX_DATA_END; } - else if(type == 3) { + else if (type == 3) { bConstraint *con; bLockTrackConstraint *data; CTX_DATA_BEGIN(C, Object*, ob, selected_editable_objects) { - if(ob!=obact) { + if (ob!=obact) { con = add_ob_constraint(ob, "AutoTrack", CONSTRAINT_TYPE_LOCKTRACK); data = con->data; @@ -1058,14 +1058,14 @@ static unsigned int move_to_layer_init(bContext *C, wmOperator *op) int values[20], a; unsigned int lay= 0; - if(!RNA_struct_property_is_set(op->ptr, "layers")) { + if (!RNA_struct_property_is_set(op->ptr, "layers")) { /* note: layers are set in bases, library objects work for this */ CTX_DATA_BEGIN(C, Base*, base, selected_bases) { lay |= base->lay; } CTX_DATA_END; - for(a=0; a<20; a++) + for (a=0; a<20; a++) values[a]= (lay & (1<ptr, "layers", values); @@ -1073,8 +1073,8 @@ static unsigned int move_to_layer_init(bContext *C, wmOperator *op) else { RNA_boolean_get_array(op->ptr, "layers", values); - for(a=0; a<20; a++) - if(values[a]) + for (a=0; a<20; a++) + if (values[a]) lay |= (1 << a); } @@ -1084,7 +1084,7 @@ static unsigned int move_to_layer_init(bContext *C, wmOperator *op) static int move_to_layer_invoke(bContext *C, wmOperator *op, wmEvent *event) { View3D *v3d= CTX_wm_view3d(C); - if(v3d && v3d->localvd) { + if (v3d && v3d->localvd) { return WM_operator_confirm_message(C, op, "Move from localview"); } else { @@ -1104,9 +1104,9 @@ static int move_to_layer_exec(bContext *C, wmOperator *op) lay= move_to_layer_init(C, op); lay &= 0xFFFFFF; - if(lay==0) return OPERATOR_CANCELLED; + if (lay==0) return OPERATOR_CANCELLED; - if(v3d && v3d->localvd) { + if (v3d && v3d->localvd) { /* now we can move out of localview. */ /* note: layers are set in bases, library objects work for this */ CTX_DATA_BEGIN(C, Base*, base, selected_bases) { @@ -1169,11 +1169,11 @@ static void link_to_scene(Main *UNUSED(bmain), unsigned short UNUSED(nr)) Scene *sce= (Scene*) BLI_findlink(&bmain->scene, G.curscreen->scenenr-1); Base *base, *nbase; - if(sce==0) return; - if(sce->id.lib) return; + if (sce==0) return; + if (sce->id.lib) return; - for(base= FIRSTBASE; base; base= base->next) { - if(TESTBASE(v3d, base)) { + for (base= FIRSTBASE; base; base= base->next) { + if (TESTBASE(v3d, base)) { nbase= MEM_mallocN( sizeof(Base), "newbase"); *nbase= *base; @@ -1189,24 +1189,24 @@ static int make_links_scene_exec(bContext *C, wmOperator *op) Main *bmain= CTX_data_main(C); Scene *scene_to= BLI_findlink(&CTX_data_main(C)->scene, RNA_enum_get(op->ptr, "scene")); - if(scene_to==NULL) { + if (scene_to==NULL) { BKE_report(op->reports, RPT_ERROR, "Scene not found"); return OPERATOR_CANCELLED; } - if(scene_to == CTX_data_scene(C)) { + if (scene_to == CTX_data_scene(C)) { BKE_report(op->reports, RPT_ERROR, "Can't link objects into the same scene"); return OPERATOR_CANCELLED; } - if(scene_to->id.lib) { + if (scene_to->id.lib) { BKE_report(op->reports, RPT_ERROR, "Can't link objects into a linked scene"); return OPERATOR_CANCELLED; } CTX_DATA_BEGIN(C, Base*, base, selected_bases) { - if(!object_in_scene(base->object, scene_to)) { + if (!object_in_scene(base->object, scene_to)) { Base *nbase= MEM_mallocN( sizeof(Base), "newbase"); *nbase= *base; BLI_addhead( &(scene_to->base), nbase); @@ -1266,7 +1266,7 @@ static int make_links_data_exec(bContext *C, wmOperator *op) ob= ED_object_active_context(C); CTX_DATA_BEGIN(C, Object*, obt, selected_editable_objects) { - if(ob != obt) { + if (ob != obt) { if (allow_make_links_data(event, ob, obt)) { switch(event) { case MAKE_LINKS_OBDATA: /* obdata */ @@ -1284,7 +1284,7 @@ static int make_links_data_exec(bContext *C, wmOperator *op) break; case MAKE_LINKS_MATERIALS: /* new approach, using functions from kernel */ - for(a=0; atotcol; a++) { + for (a=0; atotcol; a++) { Material *ma= give_current_material(ob, a+1); assign_material(obt, ma, a+1); /* also works with ma==NULL */ } @@ -1295,7 +1295,7 @@ static int make_links_data_exec(bContext *C, wmOperator *op) break; case MAKE_LINKS_DUPLIGROUP: obt->dup_group= ob->dup_group; - if(obt->dup_group) { + if (obt->dup_group) { id_lib_extern(&obt->dup_group->id); obt->transflag |= OB_DUPLIGROUP; } @@ -1378,7 +1378,7 @@ static void single_object_users(Scene *scene, View3D *v3d, int flag) clear_sca_new_poins(); /* sensor/contr/act */ /* duplicate (must set newid) */ - for(base= FIRSTBASE; base; base= base->next) { + for (base= FIRSTBASE; base; base= base->next) { ob= base->object; /* newid may still have some trash from Outliner tree building, @@ -1386,8 +1386,8 @@ static void single_object_users(Scene *scene, View3D *v3d, int flag) */ ob->id.newid = NULL; - if( (base->flag & flag)==flag ) { - if(ob->id.lib==NULL && ob->id.us>1) { + if ( (base->flag & flag)==flag ) { + if (ob->id.lib==NULL && ob->id.us>1) { /* base gets copy of object */ obn= copy_object(ob); base->object= obn; @@ -1397,10 +1397,10 @@ static void single_object_users(Scene *scene, View3D *v3d, int flag) } ID_NEW(scene->camera); - if(v3d) ID_NEW(v3d->camera); + if (v3d) ID_NEW(v3d->camera); /* object pointers */ - for(base= FIRSTBASE; base; base= base->next) { + for (base= FIRSTBASE; base; base= base->next) { object_relink(base->object); } @@ -1413,8 +1413,8 @@ void ED_object_single_user(Scene *scene, Object *ob) { Base *base; - for(base= FIRSTBASE; base; base= base->next) { - if(base->object == ob) base->flag |= OB_DONE; + for (base= FIRSTBASE; base; base= base->next) { + if (base->object == ob) base->flag |= OB_DONE; else base->flag &= ~OB_DONE; } @@ -1426,15 +1426,15 @@ static void new_id_matar(Material **matar, int totcol) ID *id; int a; - for(a=0; alib == NULL) { - if(id->newid) { + if (id && id->lib == NULL) { + if (id->newid) { matar[a]= (Material *)id->newid; id_us_plus(id->newid); id->us--; } - else if(id->us>1) { + else if (id->us>1) { matar[a]= copy_material(matar[a]); id->us--; id->newid= (ID *)matar[a]; @@ -1454,12 +1454,12 @@ static void single_obdata_users(Main *bmain, Scene *scene, int flag) ID *id; int a; - for(base= FIRSTBASE; base; base= base->next) { + for (base= FIRSTBASE; base; base= base->next) { ob= base->object; - if(ob->id.lib==NULL && (base->flag & flag)==flag ) { + if (ob->id.lib==NULL && (base->flag & flag)==flag ) { id= ob->data; - if(id && id->us>1 && id->lib==NULL) { + if (id && id->us>1 && id->lib==NULL) { ob->recalc= OB_RECALC_DATA; BKE_copy_animdata_id_action(id); @@ -1467,8 +1467,8 @@ static void single_obdata_users(Main *bmain, Scene *scene, int flag) switch(ob->type) { case OB_LAMP: ob->data= la= copy_lamp(ob->data); - for(a=0; amtex[a]) { + for (a=0; amtex[a]) { ID_NEW(la->mtex[a]->object); } } @@ -1518,7 +1518,7 @@ static void single_obdata_users(Main *bmain, Scene *scene, int flag) } me= bmain->mesh.first; - while(me) { + while (me) { ID_NEW(me->texcomesh); me= me->id.next; } @@ -1529,9 +1529,9 @@ static void single_object_action_users(Scene *scene, int flag) Object *ob; Base *base; - for(base= FIRSTBASE; base; base= base->next) { + for (base= FIRSTBASE; base; base= base->next) { ob= base->object; - if(ob->id.lib==NULL && (flag==0 || (base->flag & SELECT)) ) { + if (ob->id.lib==NULL && (flag==0 || (base->flag & SELECT)) ) { ob->recalc= OB_RECALC_DATA; BKE_copy_animdata_id_action(&ob->id); } @@ -1546,26 +1546,26 @@ static void single_mat_users(Scene *scene, int flag, int do_textures) Tex *tex; int a, b; - for(base= FIRSTBASE; base; base= base->next) { + for (base= FIRSTBASE; base; base= base->next) { ob= base->object; - if(ob->id.lib==NULL && (flag==0 || (base->flag & SELECT)) ) { + if (ob->id.lib==NULL && (flag==0 || (base->flag & SELECT)) ) { - for(a=1; a<=ob->totcol; a++) { + for (a=1; a<=ob->totcol; a++) { ma= give_current_material(ob, a); - if(ma) { + if (ma) { /* do not test for LIB_NEW: this functions guaranteed delivers single_users! */ - if(ma->id.us>1) { + if (ma->id.us>1) { man= copy_material(ma); BKE_copy_animdata_id_action(&man->id); man->id.us= 0; assign_material(ob, man, a); - if(do_textures) { - for(b=0; bmtex[b] && (tex= ma->mtex[b]->tex)) { - if(tex->id.us>1) { + if (do_textures) { + for (b=0; bmtex[b] && (tex= ma->mtex[b]->tex)) { + if (tex->id.us>1) { tex->id.us--; tex= copy_texture(tex); BKE_copy_animdata_id_action(&tex->id); @@ -1586,14 +1586,14 @@ static void do_single_tex_user(Tex **from) Tex *tex, *texn; tex= *from; - if(tex==NULL) return; + if (tex==NULL) return; - if(tex->id.newid) { + if (tex->id.newid) { *from= (Tex *)tex->id.newid; id_us_plus(tex->id.newid); tex->id.us--; } - else if(tex->id.us>1) { + else if (tex->id.us>1) { texn= copy_texture(tex); BKE_copy_animdata_id_action(&texn->id); tex->id.newid= (ID *)texn; @@ -1610,30 +1610,30 @@ static void single_tex_users_expand(Main *bmain) World *wo; int b; - for(ma= bmain->mat.first; ma; ma=ma->id.next) { - if(ma->id.flag & LIB_NEW) { - for(b=0; bmtex[b] && ma->mtex[b]->tex) { + for (ma= bmain->mat.first; ma; ma=ma->id.next) { + if (ma->id.flag & LIB_NEW) { + for (b=0; bmtex[b] && ma->mtex[b]->tex) { do_single_tex_user( &(ma->mtex[b]->tex) ); } } } } - for(la= bmain->lamp.first; la; la=la->id.next) { - if(la->id.flag & LIB_NEW) { - for(b=0; bmtex[b] && la->mtex[b]->tex) { + for (la= bmain->lamp.first; la; la=la->id.next) { + if (la->id.flag & LIB_NEW) { + for (b=0; bmtex[b] && la->mtex[b]->tex) { do_single_tex_user( &(la->mtex[b]->tex) ); } } } } - for(wo= bmain->world.first; wo; wo=wo->id.next) { - if(wo->id.flag & LIB_NEW) { - for(b=0; bmtex[b] && wo->mtex[b]->tex) { + for (wo= bmain->world.first; wo; wo=wo->id.next) { + if (wo->id.flag & LIB_NEW) { + for (b=0; bmtex[b] && wo->mtex[b]->tex) { do_single_tex_user( &(wo->mtex[b]->tex) ); } } @@ -1651,27 +1651,27 @@ static void single_mat_users_expand(Main *bmain) Material *ma; int a; - for(ob=bmain->object.first; ob; ob=ob->id.next) - if(ob->id.flag & LIB_NEW) + for (ob=bmain->object.first; ob; ob=ob->id.next) + if (ob->id.flag & LIB_NEW) new_id_matar(ob->mat, ob->totcol); - for(me=bmain->mesh.first; me; me=me->id.next) - if(me->id.flag & LIB_NEW) + for (me=bmain->mesh.first; me; me=me->id.next) + if (me->id.flag & LIB_NEW) new_id_matar(me->mat, me->totcol); - for(cu=bmain->curve.first; cu; cu=cu->id.next) - if(cu->id.flag & LIB_NEW) + for (cu=bmain->curve.first; cu; cu=cu->id.next) + if (cu->id.flag & LIB_NEW) new_id_matar(cu->mat, cu->totcol); - for(mb=bmain->mball.first; mb; mb=mb->id.next) - if(mb->id.flag & LIB_NEW) + for (mb=bmain->mball.first; mb; mb=mb->id.next) + if (mb->id.flag & LIB_NEW) new_id_matar(mb->mat, mb->totcol); /* material imats */ - for(ma=bmain->mat.first; ma; ma=ma->id.next) - if(ma->id.flag & LIB_NEW) - for(a=0; amtex[a]) + for (ma=bmain->mat.first; ma; ma=ma->id.next) + if (ma->id.flag & LIB_NEW) + for (a=0; amtex[a]) ID_NEW(ma->mtex[a]->object); } @@ -1680,7 +1680,7 @@ void ED_object_single_users(Main *bmain, Scene *scene, int full) { single_object_users(scene, NULL, 0); - if(full) { + if (full) { single_obdata_users(bmain, scene, 0); single_object_action_users(scene, 0); single_mat_users_expand(bmain); @@ -1700,12 +1700,12 @@ static void make_local_makelocalmaterial(Material *ma) id_make_local(&ma->id, 0); - for(b=0; bmtex[b] && ma->mtex[b]->tex) + for (b=0; bmtex[b] && ma->mtex[b]->tex) id_make_local(&ma->mtex[b]->tex->id, 0); adt= BKE_animdata_from_id(&ma->id); - if(adt) BKE_animdata_make_local(adt); + if (adt) BKE_animdata_make_local(adt); /* nodetree? XXX */ } @@ -1720,7 +1720,7 @@ static int make_local_exec(bContext *C, wmOperator *op) ID *id; int a, b, mode= RNA_enum_get(op->ptr, "type"); - if(mode==3) { + if (mode==3) { BKE_library_make_local(bmain, NULL, 0); /* NULL is all libs */ WM_event_add_notifier(C, NC_WINDOW, NULL); return OPERATOR_FINISHED; @@ -1729,14 +1729,14 @@ static int make_local_exec(bContext *C, wmOperator *op) clear_id_newpoins(); CTX_DATA_BEGIN(C, Object*, ob, selected_objects) { - if(ob->id.lib) + if (ob->id.lib) id_make_local(&ob->id, 0); } CTX_DATA_END; /* maybe object pointers */ CTX_DATA_BEGIN(C, Object*, ob, selected_objects) { - if(ob->id.lib==NULL) { + if (ob->id.lib==NULL) { ID_NEW(ob->parent); } } @@ -1745,51 +1745,51 @@ static int make_local_exec(bContext *C, wmOperator *op) CTX_DATA_BEGIN(C, Object*, ob, selected_objects) { id= ob->data; - if(id && mode>1) { + if (id && mode>1) { id_make_local(id, 0); adt= BKE_animdata_from_id(id); - if(adt) BKE_animdata_make_local(adt); + if (adt) BKE_animdata_make_local(adt); /* tag indirect data direct */ matarar= (Material ***)give_matarar(ob); - if(matarar) { - for(a=0; atotcol; a++) { + if (matarar) { + for (a=0; atotcol; a++) { ma= (*matarar)[a]; - if(ma) + if (ma) id_lib_extern(&ma->id); } } } - for(psys=ob->particlesystem.first; psys; psys=psys->next) + for (psys=ob->particlesystem.first; psys; psys=psys->next) id_make_local(&psys->part->id, 0); adt= BKE_animdata_from_id(&ob->id); - if(adt) BKE_animdata_make_local(adt); + if (adt) BKE_animdata_make_local(adt); } CTX_DATA_END; - if(mode>1) { + if (mode>1) { CTX_DATA_BEGIN(C, Object*, ob, selected_objects) { - if(ob->type==OB_LAMP) { + if (ob->type==OB_LAMP) { la= ob->data; - for(b=0; bmtex[b] && la->mtex[b]->tex) + for (b=0; bmtex[b] && la->mtex[b]->tex) id_make_local(&la->mtex[b]->tex->id, 0); } else { - for(a=0; atotcol; a++) { + for (a=0; atotcol; a++) { ma= ob->mat[a]; - if(ma) + if (ma) make_local_makelocalmaterial(ma); } matarar= (Material ***)give_matarar(ob); - if(matarar) { - for(a=0; atotcol; a++) { + if (matarar) { + for (a=0; atotcol; a++) { ma= (*matarar)[a]; - if(ma) + if (ma) make_local_makelocalmaterial(ma); } } @@ -1835,20 +1835,20 @@ static int make_single_user_exec(bContext *C, wmOperator *op) View3D *v3d= CTX_wm_view3d(C); /* ok if this is NULL */ int flag= RNA_enum_get(op->ptr, "type"); /* 0==ALL, SELECTED==selected objecs */ - if(RNA_boolean_get(op->ptr, "object")) + if (RNA_boolean_get(op->ptr, "object")) single_object_users(scene, v3d, flag); - if(RNA_boolean_get(op->ptr, "obdata")) + if (RNA_boolean_get(op->ptr, "obdata")) single_obdata_users(bmain, scene, flag); - if(RNA_boolean_get(op->ptr, "material")) + if (RNA_boolean_get(op->ptr, "material")) single_mat_users(scene, flag, RNA_boolean_get(op->ptr, "texture")); #if 0 /* can't do this separate from materials */ - if(RNA_boolean_get(op->ptr, "texture")) + if (RNA_boolean_get(op->ptr, "texture")) single_mat_users(scene, flag, TRUE); #endif - if(RNA_boolean_get(op->ptr, "animation")) + if (RNA_boolean_get(op->ptr, "animation")) single_object_action_users(scene, flag); clear_id_newpoins(); @@ -1896,7 +1896,7 @@ static int drop_named_material_invoke(bContext *C, wmOperator *op, wmEvent *even RNA_string_get(op->ptr, "name", name); ma= (Material *)find_id("MA", name); - if(base==NULL || ma==NULL) + if (base==NULL || ma==NULL) return OPERATOR_CANCELLED; assign_material(base->object, ma, 1); diff --git a/source/blender/editors/object/object_select.c b/source/blender/editors/object/object_select.c index aff9fe1ac61..53726d70cf9 100644 --- a/source/blender/editors/object/object_select.c +++ b/source/blender/editors/object/object_select.c @@ -107,7 +107,7 @@ void ED_base_object_activate(bContext *C, Base *base) /* sets scene->basact */ BASACT= base; - if(base) { + if (base) { /* XXX old signals, remember to handle notifiers now! */ // select_actionchannel_by_name(base->object->action, "Object", 1); @@ -126,9 +126,9 @@ static int objects_selectable_poll(bContext *C) * still allowed then for inspection of scene */ Object *obact= CTX_data_active_object(C); - if(CTX_data_edit_object(C)) + if (CTX_data_edit_object(C)) return 0; - if(obact && obact->mode) + if (obact && obact->mode) return 0; return 1; @@ -151,7 +151,7 @@ static int object_select_by_type_exec(bContext *C, wmOperator *op) } CTX_DATA_BEGIN(C, Base*, base, visible_bases) { - if(base->object->type==obtype) { + if (base->object->type==obtype) { ED_base_object_select(base, BA_SELECT); } } @@ -225,67 +225,67 @@ static int object_select_linked_exec(bContext *C, wmOperator *op) } ob= OBACT; - if(ob==NULL){ + if (ob==NULL) { BKE_report(op->reports, RPT_ERROR, "No Active Object"); return OPERATOR_CANCELLED; } - if(nr==1) { + if (nr==1) { // XXX old animation system //ipo= ob->ipo; //if(ipo==0) return OPERATOR_CANCELLED; return OPERATOR_CANCELLED; } - else if(nr==2) { - if(ob->data==NULL) return OPERATOR_CANCELLED; + else if (nr==2) { + if (ob->data==NULL) return OPERATOR_CANCELLED; obdata= ob->data; } - else if(nr==3 || nr==4) { + else if (nr==3 || nr==4) { mat= give_current_material(ob, ob->actcol); - if(mat==NULL) return OPERATOR_CANCELLED; - if(nr==4) { - if(mat->mtex[ (int)mat->texact ]) tex= mat->mtex[ (int)mat->texact ]->tex; - if(tex==NULL) return OPERATOR_CANCELLED; + if (mat==NULL) return OPERATOR_CANCELLED; + if (nr==4) { + if (mat->mtex[ (int)mat->texact ]) tex= mat->mtex[ (int)mat->texact ]->tex; + if (tex==NULL) return OPERATOR_CANCELLED; } } - else if(nr==5) { - if(ob->dup_group==NULL) return OPERATOR_CANCELLED; + else if (nr==5) { + if (ob->dup_group==NULL) return OPERATOR_CANCELLED; } - else if(nr==6) { - if(ob->particlesystem.first==NULL) return OPERATOR_CANCELLED; + else if (nr==6) { + if (ob->particlesystem.first==NULL) return OPERATOR_CANCELLED; } - else if(nr==7) { + else if (nr==7) { /* do nothing */ } - else if(nr==8) { - if(ob->data==NULL) return OPERATOR_CANCELLED; + else if (nr==8) { + if (ob->data==NULL) return OPERATOR_CANCELLED; } else return OPERATOR_CANCELLED; CTX_DATA_BEGIN(C, Base*, base, visible_bases) { - if(nr==1) { + if (nr==1) { // XXX old animation system //if(base->object->ipo==ipo) base->flag |= SELECT; //changed = 1; } - else if(nr==2) { - if(base->object->data==obdata) base->flag |= SELECT; + else if (nr==2) { + if (base->object->data==obdata) base->flag |= SELECT; changed = 1; } - else if(nr==3 || nr==4) { + else if (nr==3 || nr==4) { ob= base->object; - for(a=1; a<=ob->totcol; a++) { + for (a=1; a<=ob->totcol; a++) { mat1= give_current_material(ob, a); - if(nr==3) { - if(mat1==mat) base->flag |= SELECT; + if (nr==3) { + if (mat1==mat) base->flag |= SELECT; changed = 1; } - else if(mat1 && nr==4) { - for(b=0; bmtex[b]) { - if(tex==mat1->mtex[b]->tex) { + else if (mat1 && nr==4) { + for (b=0; bmtex[b]) { + if (tex==mat1->mtex[b]->tex) { base->flag |= SELECT; changed = 1; break; @@ -295,19 +295,19 @@ static int object_select_linked_exec(bContext *C, wmOperator *op) } } } - else if(nr==5) { - if(base->object->dup_group==ob->dup_group) { + else if (nr==5) { + if (base->object->dup_group==ob->dup_group) { base->flag |= SELECT; changed = 1; } } - else if(nr==6) { + else if (nr==6) { /* loop through other, then actives particles*/ ParticleSystem *psys; ParticleSystem *psys_act; - for(psys=base->object->particlesystem.first; psys; psys=psys->next) { - for(psys_act=ob->particlesystem.first; psys_act; psys_act=psys_act->next) { + for (psys=base->object->particlesystem.first; psys; psys=psys->next) { + for (psys_act=ob->particlesystem.first; psys_act; psys_act=psys_act->next) { if (psys->part == psys_act->part) { base->flag |= SELECT; changed = 1; @@ -320,14 +320,14 @@ static int object_select_linked_exec(bContext *C, wmOperator *op) } } } - else if(nr==7) { - if(ob->id.lib == base->object->id.lib) { + else if (nr==7) { + if (ob->id.lib == base->object->id.lib) { base->flag |= SELECT; changed= 1; } } - else if(nr==8) { - if(base->object->data && ((ID *)ob->data)->lib == ((ID *)base->object->data)->lib) { + else if (nr==8) { + if (base->object->data && ((ID *)ob->data)->lib == ((ID *)base->object->data)->lib) { base->flag |= SELECT; changed= 1; } @@ -414,7 +414,7 @@ static short select_grouped_parent(bContext *C) /* Makes parent active and de-se baspar= object_in_scene(basact->object->parent, scene); /* can be NULL if parent in other scene */ - if(baspar && BASE_SELECTABLE(v3d, baspar)) { + if (baspar && BASE_SELECTABLE(v3d, baspar)) { ED_base_object_select(basact, BA_DESELECT); ED_base_object_select(baspar, BA_SELECT); ED_base_object_activate(C, baspar); @@ -569,7 +569,7 @@ static short objects_share_gameprop(Object *a, Object *b) bProperty *prop; /*make a copy of all its properties*/ - for( prop= a->prop.first; prop; prop = prop->next ) { + for ( prop= a->prop.first; prop; prop = prop->next ) { if ( get_ob_property(b, prop->name) ) return 1; } @@ -644,23 +644,23 @@ static int object_select_grouped_exec(bContext *C, wmOperator *op) } ob= OBACT; - if(ob==NULL) { + if (ob==NULL) { BKE_report(op->reports, RPT_ERROR, "No Active Object"); return OPERATOR_CANCELLED; } - if(nr==1) changed |= select_grouped_children(C, ob, 1); - else if(nr==2) changed |= select_grouped_children(C, ob, 0); - else if(nr==3) changed |= select_grouped_parent(C); - else if(nr==4) changed |= select_grouped_siblings(C, ob); - else if(nr==5) changed |= select_grouped_type(C, ob); - else if(nr==6) changed |= select_grouped_layer(C, ob); - else if(nr==7) changed |= select_grouped_group(C, ob); - else if(nr==8) changed |= select_grouped_object_hooks(C, ob); - else if(nr==9) changed |= select_grouped_index_object(C, ob); - else if(nr==10) changed |= select_grouped_color(C, ob); - else if(nr==11) changed |= select_grouped_gameprops(C, ob); - else if(nr==12) changed |= select_grouped_keyingset(C, ob); + if (nr==1) changed |= select_grouped_children(C, ob, 1); + else if (nr==2) changed |= select_grouped_children(C, ob, 0); + else if (nr==3) changed |= select_grouped_parent(C); + else if (nr==4) changed |= select_grouped_siblings(C, ob); + else if (nr==5) changed |= select_grouped_type(C, ob); + else if (nr==6) changed |= select_grouped_layer(C, ob); + else if (nr==7) changed |= select_grouped_group(C, ob); + else if (nr==8) changed |= select_grouped_object_hooks(C, ob); + else if (nr==9) changed |= select_grouped_index_object(C, ob); + else if (nr==10) changed |= select_grouped_color(C, ob); + else if (nr==11) changed |= select_grouped_gameprops(C, ob); + else if (nr==12) changed |= select_grouped_keyingset(C, ob); if (changed) { WM_event_add_notifier(C, NC_SCENE|ND_OB_SELECT, CTX_data_scene(C)); @@ -708,7 +708,7 @@ static int object_select_by_layer_exec(bContext *C, wmOperator *op) } CTX_DATA_BEGIN(C, Base*, base, visible_bases) { - if(base->lay == (1<< (layernum -1))) + if (base->lay == (1<< (layernum -1))) ED_base_object_select(base, BA_SELECT); } CTX_DATA_END; @@ -770,7 +770,8 @@ static int object_select_all_exec(bContext *C, wmOperator *op) case SEL_INVERT: if (base->flag & SELECT) { ED_base_object_select(base, BA_DESELECT); - } else { + } + else { ED_base_object_select(base, BA_SELECT); } break; @@ -863,12 +864,12 @@ static int object_select_mirror_exec(bContext *C, wmOperator *op) flip_side_name(tmpname, primbase->object->id.name+2, TRUE); - if(strcmp(tmpname, primbase->object->id.name+2)!=0) { /* names differ */ + if (strcmp(tmpname, primbase->object->id.name+2)!=0) { /* names differ */ Object *ob= (Object *)find_id("OB", tmpname); - if(ob) { + if (ob) { Base *secbase= object_in_scene(ob, scene); - if(secbase) { + if (secbase) { ED_base_object_select(secbase, BA_SELECT); } } diff --git a/source/blender/editors/object/object_shapekey.c b/source/blender/editors/object/object_shapekey.c index b6a775650d4..36571fc0ced 100644 --- a/source/blender/editors/object/object_shapekey.c +++ b/source/blender/editors/object/object_shapekey.c @@ -76,7 +76,7 @@ static void ED_object_shape_key_add(bContext *C, Scene *scene, Object *ob, int from_mix) { - if(object_insert_shape_key(scene, ob, NULL, from_mix)) { + if (object_insert_shape_key(scene, ob, NULL, from_mix)) { Key *key= ob_get_key(ob); ob->shapenr= BLI_countlist(&key->block); @@ -94,22 +94,22 @@ static int ED_object_shape_key_remove(bContext *C, Object *ob) //IpoCurve *icu; key= ob_get_key(ob); - if(key==NULL) + if (key==NULL) return 0; kb= BLI_findlink(&key->block, ob->shapenr-1); - if(kb) { - for(rkb= key->block.first; rkb; rkb= rkb->next) - if(rkb->relative == ob->shapenr-1) + if (kb) { + for (rkb= key->block.first; rkb; rkb= rkb->next) + if (rkb->relative == ob->shapenr-1) rkb->relative= 0; BLI_remlink(&key->block, kb); key->totkey--; - if(key->refkey== kb) { + if (key->refkey== kb) { key->refkey= key->block.first; - if(key->refkey) { + if (key->refkey) { /* apply new basis key on original data */ switch(ob->type) { case OB_MESH: @@ -126,36 +126,36 @@ static int ED_object_shape_key_remove(bContext *C, Object *ob) } } - if(kb->data) MEM_freeN(kb->data); + if (kb->data) MEM_freeN(kb->data); MEM_freeN(kb); - for(kb= key->block.first; kb; kb= kb->next) - if(kb->adrcode>=ob->shapenr) + for (kb= key->block.first; kb; kb= kb->next) + if (kb->adrcode>=ob->shapenr) kb->adrcode--; #if 0 // XXX old animation system - if(key->ipo) { + if (key->ipo) { - for(icu= key->ipo->curve.first; icu; icu= icu->next) { - if(icu->adrcode==ob->shapenr-1) { + for (icu= key->ipo->curve.first; icu; icu= icu->next) { + if (icu->adrcode==ob->shapenr-1) { BLI_remlink(&key->ipo->curve, icu); free_ipo_curve(icu); break; } } - for(icu= key->ipo->curve.first; icu; icu= icu->next) - if(icu->adrcode>=ob->shapenr) + for (icu= key->ipo->curve.first; icu; icu= icu->next) + if (icu->adrcode>=ob->shapenr) icu->adrcode--; } #endif // XXX old animation system - if(ob->shapenr>1) ob->shapenr--; + if (ob->shapenr>1) ob->shapenr--; } - if(key->totkey==0) { - if(GS(key->from->name)==ID_ME) ((Mesh *)key->from)->key= NULL; - else if(GS(key->from->name)==ID_CU) ((Curve *)key->from)->key= NULL; - else if(GS(key->from->name)==ID_LT) ((Lattice *)key->from)->key= NULL; + if (key->totkey==0) { + if (GS(key->from->name)==ID_ME) ((Mesh *)key->from)->key= NULL; + else if (GS(key->from->name)==ID_CU) ((Curve *)key->from)->key= NULL; + else if (GS(key->from->name)==ID_LT) ((Lattice *)key->from)->key= NULL; free_libblock_us(&(bmain->key), key); } @@ -172,33 +172,33 @@ static int object_shape_key_mirror(bContext *C, Object *ob) Key *key; key= ob_get_key(ob); - if(key==NULL) + if (key==NULL) return 0; kb= BLI_findlink(&key->block, ob->shapenr-1); - if(kb) { + if (kb) { int i1, i2; float *fp1, *fp2; float tvec[3]; char *tag_elem= MEM_callocN(sizeof(char) * kb->totelem, "shape_key_mirror"); - if(ob->type==OB_MESH) { + if (ob->type==OB_MESH) { Mesh *me= ob->data; MVert *mv; mesh_octree_table(ob, NULL, NULL, 's'); - for(i1=0, mv=me->mvert; i1totvert; i1++, mv++) { + for (i1=0, mv=me->mvert; i1totvert; i1++, mv++) { i2= mesh_get_x_mirror_vert(ob, i1); - if(i2==i1) { + if (i2==i1) { fp1= ((float *)kb->data) + i1*3; fp1[0] = -fp1[0]; tag_elem[i1]= 1; } - else if(i2 != -1) { - if(tag_elem[i1]==0 && tag_elem[i2]==0) { + else if (i2 != -1) { + if (tag_elem[i1]==0 && tag_elem[i2]==0) { fp1= ((float *)kb->data) + i1*3; fp2= ((float *)kb->data) + i2*3; @@ -229,12 +229,12 @@ static int object_shape_key_mirror(bContext *C, Object *ob) /* if(lt->editlatt) lt= lt->editlatt->latt; */ - for(w=0; wpntsw; w++) { - for(v=0; vpntsv; v++) { - for(u=0; upntsw; w++) { + for (v=0; vpntsv; v++) { + for (u=0; upntsu - 1) - u; float tvec[3]; - if(u == u_inv) { + if (u == u_inv) { i1= LT_INDEX(lt, u, v, w); fp1= ((float *)kb->data) + i1*3; fp1[0]= -fp1[0]; @@ -315,7 +315,7 @@ static int shape_key_remove_exec(bContext *C, wmOperator *UNUSED(op)) { Object *ob= ED_object_context(C); - if(!ED_object_shape_key_remove(C, ob)) + if (!ED_object_shape_key_remove(C, ob)) return OPERATOR_CANCELLED; return OPERATOR_FINISHED; @@ -342,10 +342,10 @@ static int shape_key_clear_exec(bContext *C, wmOperator *UNUSED(op)) Key *key= ob_get_key(ob); KeyBlock *kb= ob_get_keyblock(ob); - if(!key || !kb) + if (!key || !kb) return OPERATOR_CANCELLED; - for(kb=key->block.first; kb; kb=kb->next) + for (kb=key->block.first; kb; kb=kb->next) kb->curval= 0.0f; DAG_id_tag_update(&ob->id, OB_RECALC_DATA); @@ -373,7 +373,7 @@ static int shape_key_mirror_exec(bContext *C, wmOperator *UNUSED(op)) { Object *ob= ED_object_context(C); - if(!object_shape_key_mirror(C, ob)) + if (!object_shape_key_mirror(C, ob)) return OPERATOR_CANCELLED; return OPERATOR_FINISHED; @@ -401,26 +401,26 @@ static int shape_key_move_exec(bContext *C, wmOperator *op) int type= RNA_enum_get(op->ptr, "type"); Key *key= ob_get_key(ob); - if(key) { + if (key) { KeyBlock *kb, *kb_other; int shapenr_act= ob->shapenr-1; int shapenr_swap= shapenr_act + type; kb= BLI_findlink(&key->block, shapenr_act); - if((type==-1 && kb->prev==NULL) || (type==1 && kb->next==NULL)) { + if ((type==-1 && kb->prev==NULL) || (type==1 && kb->next==NULL)) { return OPERATOR_CANCELLED; } - for(kb_other= key->block.first; kb_other; kb_other= kb_other->next) { - if(kb_other->relative == shapenr_act) { + for (kb_other= key->block.first; kb_other; kb_other= kb_other->next) { + if (kb_other->relative == shapenr_act) { kb_other->relative += type; } - else if(kb_other->relative == shapenr_swap) { + else if (kb_other->relative == shapenr_swap) { kb_other->relative -= type; } } - if(type==-1) { + if (type==-1) { /* move back */ kb_other= kb->prev; BLI_remlink(&key->block, kb); diff --git a/source/blender/editors/object/object_transform.c b/source/blender/editors/object/object_transform.c index 93b1724308e..8200bbef2ee 100644 --- a/source/blender/editors/object/object_transform.c +++ b/source/blender/editors/object/object_transform.c @@ -368,8 +368,8 @@ static void ignore_parent_tx(Main *bmain, Scene *scene, Object *ob ) Object *ob_child; /* a change was made, adjust the children to compensate */ - for(ob_child=bmain->object.first; ob_child; ob_child=ob_child->id.next) { - if(ob_child->parent == ob) { + for (ob_child=bmain->object.first; ob_child; ob_child=ob_child->id.next) { + if (ob_child->parent == ob) { object_apply_mat4(ob_child, ob_child->obmat, TRUE, FALSE); what_does_parent(scene, ob_child, &workob); invert_m4_m4(ob_child->parentinv, workob.obmat); @@ -387,39 +387,39 @@ static int apply_objects_internal(bContext *C, ReportList *reports, int apply_lo /* first check if we can execute */ CTX_DATA_BEGIN(C, Object*, ob, selected_editable_objects) { - if(ob->type==OB_MESH) { - if(ID_REAL_USERS(ob->data) > 1) { + if (ob->type==OB_MESH) { + if (ID_REAL_USERS(ob->data) > 1) { BKE_report(reports, RPT_ERROR, "Can't apply to a multi user mesh, doing nothing"); return OPERATOR_CANCELLED; } } - else if(ob->type==OB_ARMATURE) { - if(ID_REAL_USERS(ob->data) > 1) { + else if (ob->type==OB_ARMATURE) { + if (ID_REAL_USERS(ob->data) > 1) { BKE_report(reports, RPT_ERROR, "Can't apply to a multi user armature, doing nothing"); return OPERATOR_CANCELLED; } } else if (ob->type == OB_LATTICE) { - if(ID_REAL_USERS(ob->data) > 1) { + if (ID_REAL_USERS(ob->data) > 1) { BKE_report(reports, RPT_ERROR, "Can't apply to a multi user lattice, doing nothing"); return OPERATOR_CANCELLED; } } - else if(ELEM(ob->type, OB_CURVE, OB_SURF)) { + else if (ELEM(ob->type, OB_CURVE, OB_SURF)) { Curve *cu; - if(ID_REAL_USERS(ob->data) > 1) { + if (ID_REAL_USERS(ob->data) > 1) { BKE_report(reports, RPT_ERROR, "Can't apply to a multi user curve, doing nothing"); return OPERATOR_CANCELLED; } cu= ob->data; - if(!(cu->flag & CU_3D) && (apply_rot || apply_loc)) { + if (!(cu->flag & CU_3D) && (apply_rot || apply_loc)) { BKE_report(reports, RPT_ERROR, "Neither rotation nor location could be applied to a 2d curve, doing nothing"); return OPERATOR_CANCELLED; } - if(cu->key) { + if (cu->key) { BKE_report(reports, RPT_ERROR, "Can't apply to a curve with vertex keys, doing nothing"); return OPERATOR_CANCELLED; } @@ -431,11 +431,11 @@ static int apply_objects_internal(bContext *C, ReportList *reports, int apply_lo CTX_DATA_BEGIN(C, Object*, ob, selected_editable_objects) { /* calculate rotation/scale matrix */ - if(apply_scale && apply_rot) + if (apply_scale && apply_rot) object_to_mat3(ob, rsmat); - else if(apply_scale) + else if (apply_scale) object_scale_to_mat3(ob, rsmat); - else if(apply_rot) { + else if (apply_rot) { float tmat[3][3], timat[3][3]; /* simple rotation matrix */ @@ -453,10 +453,10 @@ static int apply_objects_internal(bContext *C, ReportList *reports, int apply_lo copy_m4_m3(mat, rsmat); /* calculate translation */ - if(apply_loc) { + if (apply_loc) { copy_v3_v3(mat[3], ob->loc); - if(!(apply_scale && apply_rot)) { + if (!(apply_scale && apply_rot)) { /* correct for scale and rotation that is still applied */ object_to_mat3(ob, obmat); invert_m3_m3(iobmat, obmat); @@ -466,7 +466,7 @@ static int apply_objects_internal(bContext *C, ReportList *reports, int apply_lo } /* apply to object data */ - if(ob->type==OB_MESH) { + if (ob->type==OB_MESH) { Mesh *me= ob->data; MVert *mvert; @@ -474,16 +474,16 @@ static int apply_objects_internal(bContext *C, ReportList *reports, int apply_lo /* adjust data */ mvert= me->mvert; - for(a=0; atotvert; a++, mvert++) + for (a=0; atotvert; a++, mvert++) mul_m4_v3(mat, mvert->co); - if(me->key) { + if (me->key) { KeyBlock *kb; - for(kb=me->key->block.first; kb; kb=kb->next) { + for (kb=me->key->block.first; kb; kb=kb->next) { float *fp= kb->data; - for(a=0; atotelem; a++, fp+=3) + for (a=0; atotelem; a++, fp+=3) mul_m4_v3(mat, fp); } } @@ -504,7 +504,7 @@ static int apply_objects_internal(bContext *C, ReportList *reports, int apply_lo bp++; } } - else if(ELEM(ob->type, OB_CURVE, OB_SURF)) { + else if (ELEM(ob->type, OB_CURVE, OB_SURF)) { Curve *cu= ob->data; Nurb *nu; @@ -513,10 +513,10 @@ static int apply_objects_internal(bContext *C, ReportList *reports, int apply_lo scale = mat3_to_scale(rsmat); - for(nu=cu->nurb.first; nu; nu=nu->next) { - if(nu->type == CU_BEZIER) { + for (nu=cu->nurb.first; nu; nu=nu->next) { + if (nu->type == CU_BEZIER) { a= nu->pntsu; - for(bezt= nu->bezt; a--; bezt++) { + for (bezt= nu->bezt; a--; bezt++) { mul_m4_v3(mat, bezt->vec[0]); mul_m4_v3(mat, bezt->vec[1]); mul_m4_v3(mat, bezt->vec[2]); @@ -526,7 +526,7 @@ static int apply_objects_internal(bContext *C, ReportList *reports, int apply_lo } else { a= nu->pntsu*nu->pntsv; - for(bp= nu->bp; a--; bp++) + for (bp= nu->bp; a--; bp++) mul_m4_v3(mat, bp->vec); } } @@ -534,18 +534,18 @@ static int apply_objects_internal(bContext *C, ReportList *reports, int apply_lo else continue; - if(apply_loc) + if (apply_loc) zero_v3(ob->loc); - if(apply_scale) + if (apply_scale) ob->size[0]= ob->size[1]= ob->size[2]= 1.0f; - if(apply_rot) { + if (apply_rot) { zero_v3(ob->rot); unit_qt(ob->quat); unit_axis_angle(ob->rotAxis, &ob->rotAngle); } where_is_object(scene, ob); - if(ob->type==OB_ARMATURE) { + if (ob->type==OB_ARMATURE) { where_is_pose(scene, ob); /* needed for bone parents */ } @@ -557,7 +557,7 @@ static int apply_objects_internal(bContext *C, ReportList *reports, int apply_lo } CTX_DATA_END; - if(!change) + if (!change) return OPERATOR_CANCELLED; WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, NULL); @@ -581,7 +581,7 @@ static int visual_transform_apply_exec(bContext *C, wmOperator *UNUSED(op)) } CTX_DATA_END; - if(!change) + if (!change) return OPERATOR_CANCELLED; WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, NULL); @@ -609,7 +609,7 @@ static int object_transform_apply_exec(bContext *C, wmOperator *op) const int rot= RNA_boolean_get(op->ptr, "rotation"); const int sca= RNA_boolean_get(op->ptr, "scale"); - if(loc || rot || sca) { + if (loc || rot || sca) { return apply_objects_internal(C, op->reports, loc, rot, sca); } else { @@ -665,29 +665,30 @@ static int object_origin_set_exec(bContext *C, wmOperator *op) /* get the view settings if 'around' isn't set and the view is available */ View3D *v3d= CTX_wm_view3d(C); copy_v3_v3(cursor, give_cursor(scene, v3d)); - if(v3d && !RNA_struct_property_is_set(op->ptr, "center")) + if (v3d && !RNA_struct_property_is_set(op->ptr, "center")) around= v3d->around; } zero_v3(cent); - if(obedit) { + if (obedit) { INIT_MINMAX(min, max); - if(obedit->type==OB_MESH) { + if (obedit->type==OB_MESH) { Mesh *me= obedit->data; BMEditMesh *em = me->edit_btmesh; BMVert *eve; BMIter iter; int total = 0; - if(centermode == ORIGIN_TO_CURSOR) { + if (centermode == ORIGIN_TO_CURSOR) { copy_v3_v3(cent, cursor); invert_m4_m4(obedit->imat, obedit->obmat); mul_m4_v3(obedit->imat, cent); - } else { + } + else { BM_ITER(eve, &iter, em->bm, BM_VERTS_OF_MESH, NULL) { - if(around==V3D_CENTROID) { + if (around==V3D_CENTROID) { total++; add_v3_v3(cent, eve->co); mul_v3_fl(cent, 1.0f/(float)total); @@ -716,31 +717,31 @@ static int object_origin_set_exec(bContext *C, wmOperator *op) CTX_DATA_END; for (tob= bmain->object.first; tob; tob= tob->id.next) { - if(tob->data) + if (tob->data) ((ID *)tob->data)->flag &= ~LIB_DOIT; - if(tob->dup_group) + if (tob->dup_group) ((ID *)tob->dup_group)->flag &= ~LIB_DOIT; } CTX_DATA_BEGIN(C, Object*, ob, selected_editable_objects) { - if((ob->flag & OB_DONE)==0) { + if ((ob->flag & OB_DONE)==0) { int do_inverse_offset = FALSE; ob->flag |= OB_DONE; - if(centermode == ORIGIN_TO_CURSOR) { + if (centermode == ORIGIN_TO_CURSOR) { copy_v3_v3(cent, cursor); invert_m4_m4(ob->imat, ob->obmat); mul_m4_v3(ob->imat, cent); } - if(ob->data == NULL) { + if (ob->data == NULL) { /* special support for dupligroups */ - if((ob->transflag & OB_DUPLIGROUP) && ob->dup_group && (ob->dup_group->id.flag & LIB_DOIT)==0) { - if(ob->dup_group->id.lib) { + if ((ob->transflag & OB_DUPLIGROUP) && ob->dup_group && (ob->dup_group->id.flag & LIB_DOIT)==0) { + if (ob->dup_group->id.lib) { tot_lib_error++; } else { - if(centermode == ORIGIN_TO_CURSOR) { /* done */ } + if (centermode == ORIGIN_TO_CURSOR) { /* done */ } else { /* only bounds support */ INIT_MINMAX(min, max); @@ -762,11 +763,11 @@ static int object_origin_set_exec(bContext *C, wmOperator *op) tot_lib_error++; } - if(obedit==NULL && ob->type==OB_MESH) { + if (obedit==NULL && ob->type==OB_MESH) { Mesh *me= ob->data; - if(centermode == ORIGIN_TO_CURSOR) { /* done */ } - else if(around==V3D_CENTROID) { mesh_center_median(me, cent); } + if (centermode == ORIGIN_TO_CURSOR) { /* done */ } + else if (around==V3D_CENTROID) { mesh_center_median(me, cent); } else { mesh_center_bounds(me, cent); } negate_v3_v3(cent_neg, cent); @@ -779,12 +780,12 @@ static int object_origin_set_exec(bContext *C, wmOperator *op) else if (ELEM(ob->type, OB_CURVE, OB_SURF)) { Curve *cu= ob->data; - if(centermode == ORIGIN_TO_CURSOR) { /* done */ } - else if(around==V3D_CENTROID) { curve_center_median(cu, cent); } + if (centermode == ORIGIN_TO_CURSOR) { /* done */ } + else if (around==V3D_CENTROID) { curve_center_median(cu, cent); } else { curve_center_bounds(cu, cent); } /* don't allow Z change if curve is 2D */ - if((ob->type == OB_CURVE) && !(cu->flag & CU_3D)) + if ((ob->type == OB_CURVE) && !(cu->flag & CU_3D)) cent[2] = 0.0; negate_v3_v3(cent_neg, cent); @@ -794,23 +795,23 @@ static int object_origin_set_exec(bContext *C, wmOperator *op) cu->id.flag |= LIB_DOIT; do_inverse_offset= TRUE; - if(obedit) { + if (obedit) { if (centermode == GEOMETRY_TO_ORIGIN) { DAG_id_tag_update(&obedit->id, OB_RECALC_DATA); } break; } } - else if(ob->type==OB_FONT) { + else if (ob->type==OB_FONT) { /* get from bb */ Curve *cu= ob->data; - if(cu->bb==NULL && (centermode != ORIGIN_TO_CURSOR)) { + if (cu->bb==NULL && (centermode != ORIGIN_TO_CURSOR)) { /* do nothing*/ } else { - if(centermode == ORIGIN_TO_CURSOR) { + if (centermode == ORIGIN_TO_CURSOR) { /* done */ } else { @@ -828,10 +829,10 @@ static int object_origin_set_exec(bContext *C, wmOperator *op) do_inverse_offset= TRUE; } } - else if(ob->type==OB_ARMATURE) { + else if (ob->type==OB_ARMATURE) { bArmature *arm = ob->data; - if(ID_REAL_USERS(arm) > 1) { + if (ID_REAL_USERS(arm) > 1) { #if 0 BKE_report(op->reports, RPT_ERROR, "Can't apply to a multi user armature"); return; @@ -853,15 +854,15 @@ static int object_origin_set_exec(bContext *C, wmOperator *op) ignore_parent_tx(bmain, scene, ob); - if(obedit) + if (obedit) break; } } else if (ob->type == OB_MBALL) { MetaBall *mb = ob->data; - if(centermode == ORIGIN_TO_CURSOR) { /* done */ } - else if(around==V3D_CENTROID) { BKE_metaball_center_median(mb, cent); } + if (centermode == ORIGIN_TO_CURSOR) { /* done */ } + else if (around==V3D_CENTROID) { BKE_metaball_center_median(mb, cent); } else { BKE_metaball_center_bounds(mb, cent); } negate_v3_v3(cent_neg, cent); @@ -871,7 +872,7 @@ static int object_origin_set_exec(bContext *C, wmOperator *op) mb->id.flag |= LIB_DOIT; do_inverse_offset= TRUE; - if(obedit) { + if (obedit) { if (centermode == GEOMETRY_TO_ORIGIN) { DAG_id_tag_update(&obedit->id, OB_RECALC_DATA); } @@ -880,7 +881,7 @@ static int object_origin_set_exec(bContext *C, wmOperator *op) } /* offset other selected objects */ - if(do_inverse_offset && (centermode != GEOMETRY_TO_ORIGIN)) { + if (do_inverse_offset && (centermode != GEOMETRY_TO_ORIGIN)) { /* was the object data modified * note: the functions above must set 'cent' */ copy_v3_v3(centn, cent); @@ -888,7 +889,7 @@ static int object_origin_set_exec(bContext *C, wmOperator *op) add_v3_v3(ob->loc, centn); where_is_object(scene, ob); - if(ob->type==OB_ARMATURE) { + if (ob->type==OB_ARMATURE) { where_is_pose(scene, ob); /* needed for bone parents */ } @@ -896,7 +897,7 @@ static int object_origin_set_exec(bContext *C, wmOperator *op) /* other users? */ CTX_DATA_BEGIN(C, Object*, ob_other, selected_editable_objects) { - if( (ob_other->flag & OB_DONE)==0 && + if ( (ob_other->flag & OB_DONE)==0 && ( (ob->data && (ob->data == ob_other->data)) || (ob->dup_group==ob_other->dup_group && (ob->transflag|ob_other->transflag) & OB_DUPLIGROUP) ) ) { @@ -908,7 +909,7 @@ static int object_origin_set_exec(bContext *C, wmOperator *op) add_v3_v3(ob_other->loc, centn); where_is_object(scene, ob_other); - if(ob_other->type==OB_ARMATURE) { + if (ob_other->type==OB_ARMATURE) { where_is_pose(scene, ob_other); /* needed for bone parents */ } ignore_parent_tx(bmain, scene, ob_other); @@ -921,7 +922,7 @@ static int object_origin_set_exec(bContext *C, wmOperator *op) CTX_DATA_END; for (tob= bmain->object.first; tob; tob= tob->id.next) - if(tob->data && (((ID *)tob->data)->flag & LIB_DOIT)) + if (tob->data && (((ID *)tob->data)->flag & LIB_DOIT)) DAG_id_tag_update(&tob->id, OB_RECALC_OB|OB_RECALC_DATA); if (tot_change) { diff --git a/source/blender/editors/object/object_vgroup.c b/source/blender/editors/object/object_vgroup.c index 0555ddc69a8..cc8f91e4558 100644 --- a/source/blender/editors/object/object_vgroup.c +++ b/source/blender/editors/object/object_vgroup.c @@ -91,9 +91,9 @@ static Lattice *vgroup_edit_lattice(Object *ob) int ED_vgroup_object_is_edit_mode(Object *ob) { - if(ob->type == OB_MESH) + if (ob->type == OB_MESH) return (BMEdit_FromObject(ob) != NULL); - else if(ob->type == OB_LATTICE) + else if (ob->type == OB_LATTICE) return (((Lattice*)ob->data)->editlatt != NULL); return 0; @@ -103,7 +103,7 @@ bDeformGroup *ED_vgroup_add_name(Object *ob, const char *name) { bDeformGroup *defgroup; - if(!ob || !OB_TYPE_SUPPORT_VGROUP(ob->type)) + if (!ob || !OB_TYPE_SUPPORT_VGROUP(ob->type)) return NULL; defgroup = MEM_callocN(sizeof(bDeformGroup), "add deformGroup"); @@ -136,7 +136,7 @@ void ED_vgroup_delete(Object *ob, bDeformGroup *defgroup) if (dg == NULL) return; - if(ED_vgroup_object_is_edit_mode(ob)) + if (ED_vgroup_object_is_edit_mode(ob)) vgroup_delete_edit_mode(ob, dg); else vgroup_delete_object_mode(ob, dg); @@ -150,7 +150,7 @@ void ED_vgroup_clear(Object *ob) while (dg) { bDeformGroup *next_dg= dg->next; - if(edit_mode) + if (edit_mode) vgroup_delete_edit_mode(ob, dg); else vgroup_delete_object_mode(ob, dg); @@ -163,12 +163,12 @@ int ED_vgroup_data_create(ID *id) { /* create deform verts */ - if(GS(id->name)==ID_ME) { + if (GS(id->name)==ID_ME) { Mesh *me= (Mesh *)id; me->dvert= CustomData_add_layer(&me->vdata, CD_MDEFORMVERT, CD_CALLOC, NULL, me->totvert); return TRUE; } - else if(GS(id->name)==ID_LT) { + else if (GS(id->name)==ID_LT) { Lattice *lt= (Lattice *)id; lt->dvert= MEM_callocN(sizeof(MDeformVert)*lt->pntsu*lt->pntsv*lt->pntsw, "lattice deformVert"); return TRUE; @@ -183,13 +183,13 @@ static int ED_vgroup_give_parray(ID *id, MDeformVert ***dvert_arr, int *dvert_to *dvert_tot = 0; *dvert_arr = NULL; - if(id) { + if (id) { switch(GS(id->name)) { case ID_ME: { Mesh *me = (Mesh *)id; - if(me->edit_btmesh) { + if (me->edit_btmesh) { BMEditMesh *em = me->edit_btmesh; BMIter iter; BMVert *eve; @@ -221,7 +221,7 @@ static int ED_vgroup_give_parray(ID *id, MDeformVert ***dvert_arr, int *dvert_to return 1; } - else if(me->dvert) { + else if (me->dvert) { MVert *mvert= me->mvert; MDeformVert *dvert= me->dvert; int i; @@ -254,7 +254,7 @@ static int ED_vgroup_give_parray(ID *id, MDeformVert ***dvert_arr, int *dvert_to Lattice *lt= (Lattice *)id; lt= (lt->editlatt)? lt->editlatt->latt: lt; - if(lt->dvert) { + if (lt->dvert) { BPoint *def= lt->def; *dvert_tot= lt->pntsu*lt->pntsv*lt->pntsw; *dvert_arr= MEM_mallocN(sizeof(void*)*(*dvert_tot), "vgroup parray from me"); @@ -286,7 +286,7 @@ static int ED_vgroup_give_parray(ID *id, MDeformVert ***dvert_arr, int *dvert_to /* returns true if the id type supports weights */ int ED_vgroup_give_array(ID *id, MDeformVert **dvert_arr, int *dvert_tot) { - if(id) { + if (id) { switch(GS(id->name)) { case ID_ME: { @@ -326,16 +326,16 @@ int ED_vgroup_copy_array(Object *ob, Object *ob_from) ED_vgroup_give_parray(ob_from->data, &dvert_array_from, &dvert_tot_from, FALSE); ED_vgroup_give_parray(ob->data, &dvert_array, &dvert_tot, FALSE); - if((dvert_array == NULL) && (dvert_array_from != NULL) && ED_vgroup_data_create(ob->data)) { + if ((dvert_array == NULL) && (dvert_array_from != NULL) && ED_vgroup_data_create(ob->data)) { ED_vgroup_give_parray(ob->data, &dvert_array, &dvert_tot, FALSE); new_vgroup= TRUE; } - if(ob==ob_from || dvert_tot==0 || (dvert_tot != dvert_tot_from) || dvert_array_from==NULL || dvert_array==NULL) { + if (ob==ob_from || dvert_tot==0 || (dvert_tot != dvert_tot_from) || dvert_array_from==NULL || dvert_array==NULL) { if (dvert_array) MEM_freeN(dvert_array); if (dvert_array_from) MEM_freeN(dvert_array_from); - if(new_vgroup == TRUE) { + if (new_vgroup == TRUE) { /* free the newly added vgroup since it wasn't compatible */ vgroup_delete_all(ob); } @@ -347,11 +347,11 @@ int ED_vgroup_copy_array(Object *ob, Object *ob_from) BLI_duplicatelist(&ob->defbase, &ob_from->defbase); ob->actdef= ob_from->actdef; - if(defbase_tot_from < defbase_tot) { + if (defbase_tot_from < defbase_tot) { /* correct vgroup indices because the number of vgroups is being reduced. */ int *remap= MEM_mallocN(sizeof(int) * (defbase_tot + 1), __func__); - for(i=0; i<=defbase_tot_from; i++) remap[i]= i; - for(; i<=defbase_tot; i++) remap[i]= 0; /* can't use these, so disable */ + for (i=0; i<=defbase_tot_from; i++) remap[i]= i; + for (; i<=defbase_tot; i++) remap[i]= 0; /* can't use these, so disable */ vgroup_remap_update_users(ob, remap); MEM_freeN(remap); @@ -360,13 +360,13 @@ int ED_vgroup_copy_array(Object *ob, Object *ob_from) dvf= dvert_array_from; dv= dvert_array; - for(i=0; idw) + for (i=0; idw) MEM_freeN((*dv)->dw); *(*dv)= *(*dvf); - if((*dv)->dw) + if ((*dv)->dw) (*dv)->dw= MEM_dupallocN((*dv)->dw); } @@ -392,7 +392,7 @@ static void ED_vgroup_nr_vert_add(Object *ob, /* get the vert */ ED_vgroup_give_array(ob->data, &dvert, &tot); - if(dvert==NULL) + if (dvert==NULL) return; /* check that vertnum is valid before trying to get the relevant dvert */ @@ -418,7 +418,7 @@ static void ED_vgroup_nr_vert_add(Object *ob, break; case WEIGHT_ADD: dw->weight += weight; - if(dw->weight >= 1.0f) + if (dw->weight >= 1.0f) dw->weight = 1.0f; break; case WEIGHT_SUBTRACT: @@ -426,7 +426,7 @@ static void ED_vgroup_nr_vert_add(Object *ob, /* if the weight is zero or less then * remove the vert from the deform group */ - if(dw->weight <= 0.0f) { + if (dw->weight <= 0.0f) { defvert_remove_group(dv, dw); } break; @@ -471,11 +471,11 @@ void ED_vgroup_vert_add(Object *ob, bDeformGroup *dg, int vertnum, float weight, /* get the deform group number, exit if * it can't be found */ - if(def_nr < 0) return; + if (def_nr < 0) return; /* if there's no deform verts then create some, */ - if(ED_vgroup_give_array(ob->data, &dv, &tot) && dv==NULL) + if (ED_vgroup_give_array(ob->data, &dv, &tot) && dv==NULL) ED_vgroup_data_create(ob->data); /* call another function to do the work @@ -493,7 +493,7 @@ void ED_vgroup_vert_remove(Object *ob, bDeformGroup *dg, int vertnum) /* TODO, this is slow in a loop, better pass def_nr directly, but leave for later... - campbell */ const int def_nr= BLI_findindex(&ob->defbase, dg); - if(def_nr != -1) { + if (def_nr != -1) { MDeformVert *dvert= NULL; int tot; @@ -502,7 +502,7 @@ void ED_vgroup_vert_remove(Object *ob, bDeformGroup *dg, int vertnum) */ ED_vgroup_give_array(ob->data, &dvert, &tot); - if(dvert) { + if (dvert) { MDeformVert *dv= &dvert[vertnum]; MDeformWeight *dw; @@ -519,28 +519,28 @@ static float get_vert_def_nr(Object *ob, const int def_nr, const int vertnum) Mesh *me; /* get the deform vertices corresponding to the vertnum */ - if(ob->type==OB_MESH) { + if (ob->type==OB_MESH) { me= ob->data; - if(me->edit_btmesh) { + if (me->edit_btmesh) { eve= BM_vert_at_index(me->edit_btmesh->bm, vertnum); - if(!eve) { + if (!eve) { return 0.0f; } dv= CustomData_bmesh_get(&me->edit_btmesh->bm->vdata, eve->head.data, CD_MDEFORMVERT); } else { - if(vertnum >= me->totvert) { + if (vertnum >= me->totvert) { return 0.0f; } dv = &me->dvert[vertnum]; } } - else if(ob->type==OB_LATTICE) { + else if (ob->type==OB_LATTICE) { Lattice *lt= vgroup_edit_lattice(ob); - if(lt->dvert) { - if(vertnum >= lt->pntsu*lt->pntsv*lt->pntsw) { + if (lt->dvert) { + if (vertnum >= lt->pntsu*lt->pntsv*lt->pntsw) { return 0.0f; } dv = <->dvert[vertnum]; @@ -561,7 +561,7 @@ float ED_vgroup_vert_weight(Object *ob, bDeformGroup *dg, int vertnum) { const int def_nr= BLI_findindex(&ob->defbase, dg); - if(def_nr == -1) { + if (def_nr == -1) { return -1; } @@ -585,7 +585,7 @@ static void vgroup_select_verts(Object *ob, int select) return; } - if(ob->type == OB_MESH) { + if (ob->type == OB_MESH) { Mesh *me= ob->data; if (me->edit_btmesh) { @@ -603,7 +603,7 @@ static void vgroup_select_verts(Object *ob, int select) } /* this has to be called, because this function operates on vertices only */ - if(select) EDBM_select_flush(em); // vertices to edges/faces + if (select) EDBM_select_flush(em); // vertices to edges/faces else EDBM_deselect_flush(em); } else { @@ -628,17 +628,17 @@ static void vgroup_select_verts(Object *ob, int select) } } } - else if(ob->type == OB_LATTICE) { + else if (ob->type == OB_LATTICE) { Lattice *lt= vgroup_edit_lattice(ob); - if(lt->dvert) { + if (lt->dvert) { BPoint *bp; int a, tot; dv= lt->dvert; tot= lt->pntsu*lt->pntsv*lt->pntsw; - for(a=0, bp= lt->def; adef; af1 |= SELECT; else bp->f1 &= ~SELECT; @@ -657,10 +657,10 @@ static void vgroup_duplicate(Object *ob) int i, idg, icdg, dvert_tot=0; dg = BLI_findlink(&ob->defbase, (ob->actdef-1)); - if(!dg) + if (!dg) return; - if(!strstr(dg->name, "_copy")) { + if (!strstr(dg->name, "_copy")) { BLI_snprintf(name, sizeof(name), "%s_copy", dg->name); } else { @@ -681,10 +681,10 @@ static void vgroup_duplicate(Object *ob) ED_vgroup_give_parray(ob->data, &dvert_array, &dvert_tot, FALSE); if (dvert_array) { - for(i = 0; i < dvert_tot; i++) { + for (i = 0; i < dvert_tot; i++) { MDeformVert *dv= dvert_array[i]; dw_org = defvert_find_index(dv, idg); - if(dw_org) { + if (dw_org) { /* defvert_verify_index re-allocs org so need to store the weight first */ dw_cpy = defvert_verify_index(dv, icdg); dw_cpy->weight = dw_org->weight; @@ -713,7 +713,7 @@ static void vgroup_normalize(Object *ob) if (dvert_array) { float weight_max = 0.0f; - for(i = 0; i < dvert_tot; i++) { + for (i = 0; i < dvert_tot; i++) { /* in case its not selected */ if (!(dv = dvert_array[i])) { @@ -721,13 +721,13 @@ static void vgroup_normalize(Object *ob) } dw = defvert_find_index(dv, def_nr); - if(dw) { + if (dw) { weight_max = MAX2(dw->weight, weight_max); } } - if(weight_max > 0.0f) { - for(i = 0; i < dvert_tot; i++) { + if (weight_max > 0.0f) { + for (i = 0; i < dvert_tot; i++) { /* in case its not selected */ if (!(dv = dvert_array[i])) { @@ -735,7 +735,7 @@ static void vgroup_normalize(Object *ob) } dw = defvert_find_index(dv, def_nr); - if(dw) { + if (dw) { dw->weight /= weight_max; /* in case of division errors with very low weights */ @@ -762,21 +762,21 @@ static int* getSurroundingVerts(Mesh *me, int vert, int *count) BLI_array_declare(verts); BLI_array_reserve(verts, 8); - while(i--) { + while (i--) { int j = mp->totloop; int first_l = mp->totloop - 1; MLoop *ml = &me->mloop[mp->loopstart]; - while(j--) { + while (j--) { /* XXX This assume a vert can only be once in a poly, even though * it seems logical to me, not totally sure of that. */ if (ml->v == vert) { int a, b, k; - if(j == first_l) { + if (j == first_l) { /* We are on the first corner. */ a = ml[1].v; b = ml[j].v; } - else if(!j) { + else if (!j) { /* We are on the last corner. */ a = (ml-1)->v; b = me->mloop[mp->loopstart].v; @@ -789,15 +789,15 @@ static int* getSurroundingVerts(Mesh *me, int vert, int *count) /* Append a and b verts to array, if not yet present. */ k = BLI_array_count(verts); /* XXX Maybe a == b is enough? */ - while(k-- && !(a == b && a == -1)) { - if(verts[k] == a) + while (k-- && !(a == b && a == -1)) { + if (verts[k] == a) a = -1; - else if(verts[k] == b) + else if (verts[k] == b) b = -1; } - if(a != -1) + if (a != -1) BLI_array_append(verts, a); - if(b != -1) + if (b != -1) BLI_array_append(verts, b); /* Vert found in this poly, we can go to next one! */ @@ -820,7 +820,7 @@ static void getSingleCoordinate(MVert *points, int count, float coord[3]) { int i; zero_v3(coord); - for(i = 0; i < count; i++) { + for (i = 0; i < count; i++) { add_v3_v3(coord, points[i].co); } mul_v3_fl(coord, 1.0f/count); @@ -853,12 +853,12 @@ static void getVerticalAndHorizontalChange(const float norm[3], float d, const f // I need the derived mesh to be forgotten so the positions are recalculated with weight changes (see dm_deform_recalc) static void dm_deform_clear(DerivedMesh *dm, Object *ob) { - if(ob->derivedDeform && (ob->derivedDeform)==dm) { + if (ob->derivedDeform && (ob->derivedDeform)==dm) { ob->derivedDeform->needsFree = 1; ob->derivedDeform->release(ob->derivedDeform); ob->derivedDeform = NULL; } - else if(dm) { + else if (dm) { dm->needsFree = 1; dm->release(dm); } @@ -911,56 +911,59 @@ static void moveCloserToDistanceFromPlane(Scene *scene, Object *ob, Mesh *me, in copy_v3_v3(oldPos, m.co); distToStart = dot_v3v3(norm, oldPos) + d; - if(distToBe == originalDistToBe) { + if (distToBe == originalDistToBe) { distToBe += distToStart - distToStart*strength; } - for(i = 0; i < totweight; i++) { + for (i = 0; i < totweight; i++) { dwIndices[i] = i; dw = (dvert->dw+i); vc = hc = 0; - if(!dw->weight) { + if (!dw->weight) { changes[i][0] = 0; changes[i][1] = 0; dists[i] = distToStart; continue; } - for(k = 0; k < 2; k++) { - if(dm) { + for (k = 0; k < 2; k++) { + if (dm) { dm_deform_clear(dm, ob); dm = NULL; } oldw = dw->weight; - if(k) { + if (k) { dw->weight *= 1+cp; - } else { + } + else { dw->weight /= 1+cp; } - if(dw->weight == oldw) { + if (dw->weight == oldw) { changes[i][0] = 0; changes[i][1] = 0; dists[i] = distToStart; break; } - if(dw->weight > 1) { + if (dw->weight > 1) { dw->weight = 1; } dm = dm_deform_recalc(scene, ob); dm->getVert(dm, index, &m); getVerticalAndHorizontalChange(norm, d, coord, oldPos, distToStart, m.co, changes, dists, i); dw->weight = oldw; - if(!k) { + if (!k) { vc = changes[i][0]; hc = changes[i][1]; dist = dists[i]; - } else { - if(fabs(dist - distToBe) < fabs(dists[i] - distToBe)) { + } + else { + if (fabs(dist - distToBe) < fabs(dists[i] - distToBe)) { upDown[i] = 0; changes[i][0] = vc; changes[i][1] = hc; dists[i] = dist; - } else { + } + else { upDown[i] = 1; } - if(fabs(dists[i] - distToBe) > fabs(distToStart - distToBe)) { + if (fabs(dists[i] - distToBe) > fabs(distToStart - distToBe)) { changes[i][0] = 0; changes[i][1] = 0; dists[i] = distToStart; @@ -969,19 +972,19 @@ static void moveCloserToDistanceFromPlane(Scene *scene, Object *ob, Mesh *me, in } } // sort the changes by the vertical change - for(k = 0; k < totweight; k++) { + for (k = 0; k < totweight; k++) { float tf; int ti; bestIndex = k; - for(i = k+1; i < totweight; i++) { + for (i = k+1; i < totweight; i++) { dist = dists[i]; - if(fabs(dist) > fabs(dists[i])) { + if (fabs(dist) > fabs(dists[i])) { bestIndex = i; } } // switch with k - if(bestIndex != k) { + if (bestIndex != k) { ti = upDown[k]; upDown[k] = upDown[bestIndex]; upDown[bestIndex] = ti; @@ -1005,18 +1008,18 @@ static void moveCloserToDistanceFromPlane(Scene *scene, Object *ob, Mesh *me, in } bestIndex = -1; // find the best change with an acceptable horizontal change - for(i = 0; i < totweight; i++) { - if(fabs(changes[i][0]) > fabs(changes[i][1]*2.0f)) { + for (i = 0; i < totweight; i++) { + if (fabs(changes[i][0]) > fabs(changes[i][1]*2.0f)) { bestIndex = i; break; } } - if(bestIndex != -1) { + if (bestIndex != -1) { wasChange = TRUE; // it is a good place to stop if it tries to move the opposite direction // (relative to the plane) of last time - if(lastIndex != -1) { - if(wasUp != upDown[bestIndex]) { + if (lastIndex != -1) { + if (wasUp != upDown[bestIndex]) { wasChange = FALSE; } } @@ -1024,22 +1027,23 @@ static void moveCloserToDistanceFromPlane(Scene *scene, Object *ob, Mesh *me, in wasUp = upDown[bestIndex]; dw = (dvert->dw+dwIndices[bestIndex]); oldw = dw->weight; - if(upDown[bestIndex]) { + if (upDown[bestIndex]) { dw->weight *= 1+cp; - } else { + } + else { dw->weight /= 1+cp; } - if(dw->weight > 1) { + if (dw->weight > 1) { dw->weight = 1; } - if(oldw == dw->weight) { + if (oldw == dw->weight) { wasChange = FALSE; } - if(dm) { + if (dm) { dm_deform_clear(dm, ob); dm = NULL; } } - } while(wasChange && (distToStart-distToBe)/fabsf(distToStart-distToBe) == + } while (wasChange && (distToStart-distToBe)/fabsf(distToStart-distToBe) == (dists[bestIndex]-distToBe)/fabsf(dists[bestIndex]-distToBe)); MEM_freeN(upDown); MEM_freeN(changes); @@ -1056,24 +1060,24 @@ static void vgroup_fix(Scene *scene, Object *ob, float distToBe, float strength, Mesh *me = ob->data; MVert *mvert = me->mvert; int *verts = NULL; - if(!(me->editflag & ME_EDIT_VERT_SEL)) + if (!(me->editflag & ME_EDIT_VERT_SEL)) return; - for(i = 0; i < me->totvert && mvert; i++, mvert++) { - if(mvert->flag & SELECT) { + for (i = 0; i < me->totvert && mvert; i++, mvert++) { + if (mvert->flag & SELECT) { int count=0; - if((verts = getSurroundingVerts(me, i, &count))) { + if ((verts = getSurroundingVerts(me, i, &count))) { MVert m; MVert *p = MEM_callocN(sizeof(MVert)*(count), "deformedPoints"); int k; DerivedMesh *dm = mesh_get_derived_deform(scene, ob, CD_MASK_BAREMESH); k = count; - while(k--) { + while (k--) { dm->getVert(dm, verts[k], &m); p[k] = m; } - if(count >= 3) { + if (count >= 3) { float d /*, dist */ /* UNUSED */, mag; float coord[3]; float norm[3]; @@ -1081,7 +1085,7 @@ static void vgroup_fix(Scene *scene, Object *ob, float distToBe, float strength, dm->getVert(dm, i, &m); sub_v3_v3v3(norm, m.co, coord); mag= normalize_v3(norm); - if(mag) { /* zeros fix */ + if (mag) { /* zeros fix */ d = -dot_v3v3(norm, coord); /* dist = (dot_v3v3(norm, m.co) + d); */ /* UNUSED */ moveCloserToDistanceFromPlane(scene, ob, me, i, norm, coord, d, distToBe, strength, cp); @@ -1111,7 +1115,7 @@ static void vgroup_levels(Object *ob, float offset, float gain) ED_vgroup_give_parray(ob->data, &dvert_array, &dvert_tot, use_vert_sel); if (dvert_array) { - for(i = 0; i < dvert_tot; i++) { + for (i = 0; i < dvert_tot; i++) { /* in case its not selected */ if (!(dv = dvert_array[i])) { @@ -1119,7 +1123,7 @@ static void vgroup_levels(Object *ob, float offset, float gain) } dw = defvert_find_index(dv, def_nr); - if(dw) { + if (dw) { dw->weight = gain * (dw->weight + offset); CLAMP(dw->weight, 0.0f, 1.0f); @@ -1146,9 +1150,9 @@ static void vgroup_normalize_all(Object *ob, int lock_active) ED_vgroup_give_parray(ob->data, &dvert_array, &dvert_tot, use_vert_sel); if (dvert_array) { - if(lock_active) { + if (lock_active) { - for(i = 0; i < dvert_tot; i++) { + for (i = 0; i < dvert_tot; i++) { /* in case its not selected */ if (!(dv = dvert_array[i])) { continue; @@ -1158,7 +1162,7 @@ static void vgroup_normalize_all(Object *ob, int lock_active) } } else { - for(i = 0; i < dvert_tot; i++) { + for (i = 0; i < dvert_tot; i++) { /* in case its not selected */ if (!(dv = dvert_array[i])) { @@ -1178,17 +1182,17 @@ static void vgroup_lock_all(Object *ob, int action) { bDeformGroup *dg; - if(action == SEL_TOGGLE) { + if (action == SEL_TOGGLE) { action= SEL_SELECT; - for(dg= ob->defbase.first; dg; dg= dg->next) { - if(dg->flag & DG_LOCK_WEIGHT) { + for (dg= ob->defbase.first; dg; dg= dg->next) { + if (dg->flag & DG_LOCK_WEIGHT) { action= SEL_DESELECT; break; } } } - for(dg= ob->defbase.first; dg; dg= dg->next) { + for (dg= ob->defbase.first; dg; dg= dg->next) { switch(action) { case SEL_SELECT: dg->flag |= DG_LOCK_WEIGHT; @@ -1218,7 +1222,7 @@ static void vgroup_invert(Object *ob, const short auto_assign, const short auto_ ED_vgroup_give_parray(ob->data, &dvert_array, &dvert_tot, use_vert_sel); if (dvert_array) { - for(i = 0; i < dvert_tot; i++) { + for (i = 0; i < dvert_tot; i++) { /* in case its not selected */ if (!(dv = dvert_array[i])) { @@ -1232,10 +1236,10 @@ static void vgroup_invert(Object *ob, const short auto_assign, const short auto_ dw= defvert_find_index(dv, def_nr); } - if(dw) { + if (dw) { dw->weight = 1.0f - dw->weight; - if(auto_remove && dw->weight <= 0.0f) { + if (auto_remove && dw->weight <= 0.0f) { defvert_remove_group(dv, dw); } } @@ -1280,9 +1284,9 @@ static void vgroup_blend(Object *ob) sel1= BM_elem_flag_test(eed->v1, BM_ELEM_SELECT); sel2= BM_elem_flag_test(eed->v2, BM_ELEM_SELECT); - if(sel1 != sel2) { + if (sel1 != sel2) { /* i1 is always the selected one */ - if(sel1==TRUE && sel2==FALSE) { + if (sel1==TRUE && sel2==FALSE) { i1= BM_elem_index_get(eed->v1); i2= BM_elem_index_get(eed->v2); eve= eed->v2; @@ -1308,7 +1312,7 @@ static void vgroup_blend(Object *ob) dw = defvert_find_index(dvert, def_nr); - if(dw) { + if (dw) { vg_weights[i1] += dw->weight; } } @@ -1316,9 +1320,9 @@ static void vgroup_blend(Object *ob) i= 0; BM_ITER(eve, &iter, em->bm, BM_VERTS_OF_MESH, NULL) { - if(BM_elem_flag_test(eve, BM_ELEM_SELECT) && vg_users[i] > 0) { + if (BM_elem_flag_test(eve, BM_ELEM_SELECT) && vg_users[i] > 0) { /* TODO, we may want object mode blending */ - if(em) dvert= CustomData_bmesh_get(&em->bm->vdata, eve->head.data, CD_MDEFORMVERT); + if (em) dvert= CustomData_bmesh_get(&em->bm->vdata, eve->head.data, CD_MDEFORMVERT); else dvert= dvert_array+i; dw= defvert_verify_index(dvert, def_nr); @@ -1351,7 +1355,7 @@ static void vgroup_clean(Object *ob, const float epsilon, int keep_single) if (dvert_array) { /* only the active group */ - for(i = 0; i < dvert_tot; i++) { + for (i = 0; i < dvert_tot; i++) { /* in case its not selected */ if (!(dv = dvert_array[i])) { @@ -1362,7 +1366,7 @@ static void vgroup_clean(Object *ob, const float epsilon, int keep_single) if (dw) { if (dw->weight <= epsilon) { - if(keep_single==FALSE || dv->totweight > 1) { + if (keep_single==FALSE || dv->totweight > 1) { defvert_remove_group(dv, dw); /* dw can be NULL */ } } @@ -1385,7 +1389,7 @@ static void vgroup_clean_all(Object *ob, const float epsilon, const int keep_sin MDeformVert *dv; MDeformWeight *dw; - for(i = 0; i < dvert_tot; i++) { + for (i = 0; i < dvert_tot; i++) { int j; /* in case its not selected */ @@ -1395,14 +1399,14 @@ static void vgroup_clean_all(Object *ob, const float epsilon, const int keep_sin j= dv->totweight; - while(j--) { + while (j--) { - if(keep_single && dv->totweight == 1) + if (keep_single && dv->totweight == 1) break; dw= dv->dw + j; - if(dw->weight <= epsilon) { + if (dw->weight <= epsilon) { defvert_remove_group(dv, dw); } } @@ -1421,9 +1425,9 @@ static void dvert_mirror_op(MDeformVert *dvert, MDeformVert *dvert_mirr, { BLI_assert(sel || sel_mirr); - if(sel_mirr && sel) { + if (sel_mirr && sel) { /* swap */ - if(mirror_weights) { + if (mirror_weights) { if (all_vgroups) { SWAP(MDeformVert, *dvert, *dvert_mirr); } @@ -1442,18 +1446,18 @@ static void dvert_mirror_op(MDeformVert *dvert, MDeformVert *dvert_mirr, } } - if(flip_vgroups) { + if (flip_vgroups) { defvert_flip(dvert, flip_map, flip_map_len); defvert_flip(dvert_mirr, flip_map, flip_map_len); } } else { /* dvert should always be the target, only swaps pointer */ - if(sel_mirr) { + if (sel_mirr) { SWAP(MDeformVert *, dvert, dvert_mirr); } - if(mirror_weights) { + if (mirror_weights) { if (all_vgroups) { defvert_copy(dvert, dvert_mirr); } @@ -1463,7 +1467,7 @@ static void dvert_mirror_op(MDeformVert *dvert, MDeformVert *dvert_mirr, } /* flip map already modified for 'all_vgroups' */ - if(flip_vgroups) { + if (flip_vgroups) { defvert_flip(dvert, flip_map, flip_map_len); } } @@ -1512,14 +1516,14 @@ void ED_vgroup_mirror(Object *ob, const short mirror_weights, const short flip_v } /* only the active group */ - if(ob->type == OB_MESH) { + if (ob->type == OB_MESH) { Mesh *me= ob->data; BMEditMesh *em = me->edit_btmesh; if (em) { BMIter iter; - if(!CustomData_has_layer(&em->bm->vdata, CD_MDEFORMVERT)) { + if (!CustomData_has_layer(&em->bm->vdata, CD_MDEFORMVERT)) { goto cleanup; } @@ -1527,14 +1531,14 @@ void ED_vgroup_mirror(Object *ob, const short mirror_weights, const short flip_v /* Go through the list of editverts and assign them */ BM_ITER(eve, &iter, em->bm, BM_VERTS_OF_MESH, NULL) { - if((eve_mirr= EDBM_GetMirrorVert(em, eve))) { + if ((eve_mirr= EDBM_GetMirrorVert(em, eve))) { sel= BM_elem_flag_test(eve, BM_ELEM_SELECT); sel_mirr= BM_elem_flag_test(eve_mirr, BM_ELEM_SELECT); - if((sel || sel_mirr) && (eve != eve_mirr)) { + if ((sel || sel_mirr) && (eve != eve_mirr)) { dvert= CustomData_bmesh_get(&em->bm->vdata, eve->head.data, CD_MDEFORMVERT); dvert_mirr= CustomData_bmesh_get(&em->bm->vdata, eve_mirr->head.data, CD_MDEFORMVERT); - if(dvert && dvert_mirr) { + if (dvert && dvert_mirr) { VGROUP_MIRR_OP; } } @@ -1561,11 +1565,11 @@ void ED_vgroup_mirror(Object *ob, const short mirror_weights, const short flip_v } /* tag verts we have used */ - for(vidx= 0, mv= me->mvert; vidx < me->totvert; vidx++, mv++) { + for (vidx= 0, mv= me->mvert; vidx < me->totvert; vidx++, mv++) { mv->flag &= ~ME_VERT_TMP_TAG; } - for(vidx= 0, mv= me->mvert; vidx < me->totvert; vidx++, mv++) { + for (vidx= 0, mv= me->mvert; vidx < me->totvert; vidx++, mv++) { if ( ((mv->flag & ME_VERT_TMP_TAG) == 0) && ((vidx_mirr= mesh_get_x_mirror_vert(ob, vidx)) != -1) && (vidx != vidx_mirr) && @@ -1597,7 +1601,7 @@ void ED_vgroup_mirror(Object *ob, const short mirror_weights, const short flip_v int pntsu_half; /* half but found up odd value */ - if(lt->pntsu == 1 || lt->dvert == NULL) { + if (lt->pntsu == 1 || lt->dvert == NULL) { goto cleanup; } @@ -1606,11 +1610,11 @@ void ED_vgroup_mirror(Object *ob, const short mirror_weights, const short flip_v * ok in this case */ pntsu_half= lt->pntsu / 2; - for(w=0; wpntsw; w++) { - for(v=0; vpntsv; v++) { - for(u=0; upntsw; w++) { + for (v=0; vpntsv; v++) { + for (u=0; upntsu - 1) - u; - if(u != u_inv) { + if (u != u_inv) { BPoint *bp, *bp_mirr; i1= LT_INDEX(lt, u, v, w); @@ -1622,7 +1626,7 @@ void ED_vgroup_mirror(Object *ob, const short mirror_weights, const short flip_v sel= bp->f1 & SELECT; sel_mirr= bp_mirr->f1 & SELECT; - if(sel || sel_mirr) { + if (sel || sel_mirr) { dvert= <->dvert[i1]; dvert_mirr= <->dvert[i2]; @@ -1653,19 +1657,19 @@ static void vgroup_remap_update_users(Object *ob, int *map) /* these cases don't use names to refer to vertex groups, so when * they get deleted the numbers get out of sync, this corrects that */ - if(ob->soft) + if (ob->soft) ob->soft->vertgroup= map[ob->soft->vertgroup]; - for(md=ob->modifiers.first; md; md=md->next) { - if(md->type == eModifierType_Explode) { + for (md=ob->modifiers.first; md; md=md->next) { + if (md->type == eModifierType_Explode) { emd= (ExplodeModifierData*)md; emd->vgroup= map[emd->vgroup]; } - else if(md->type == eModifierType_Cloth) { + else if (md->type == eModifierType_Cloth) { clmd= (ClothModifierData*)md; clsim= clmd->sim_parms; - if(clsim) { + if (clsim) { clsim->vgroup_mass= map[clsim->vgroup_mass]; clsim->vgroup_bend= map[clsim->vgroup_bend]; clsim->vgroup_struct= map[clsim->vgroup_struct]; @@ -1673,8 +1677,8 @@ static void vgroup_remap_update_users(Object *ob, int *map) } } - for(psys=ob->particlesystem.first; psys; psys=psys->next) { - for(a=0; aparticlesystem.first; psys; psys=psys->next) { + for (a=0; avgroup[a]= map[psys->vgroup[a]]; } } @@ -1686,8 +1690,8 @@ static void vgroup_delete_update_users(Object *ob, int id) int *map= MEM_mallocN(sizeof(int) * defbase_tot, "vgroup del"); map[id]= map[0]= 0; - for(i=1; idata, &dvert_array, &dvert_tot); - if(dvert_array) { + if (dvert_array) { int i, j; MDeformVert *dv; - for(i= 0, dv= dvert_array; i < dvert_tot; i++, dv++) { + for (i= 0, dv= dvert_array; i < dvert_tot; i++, dv++) { MDeformWeight *dw; dw= defvert_find_index(dv, def_nr); defvert_remove_group(dv, dw); /* dw can be NULL */ /* inline, make into a function if anything else needs to do this */ - for(j = 0; j < dv->totweight; j++) { - if(dv->dw[j].def_nr > def_nr) { + for (j = 0; j < dv->totweight; j++) { + if (dv->dw[j].def_nr > def_nr) { dv->dw[j].def_nr--; } } @@ -1729,9 +1733,9 @@ static void vgroup_delete_object_mode(Object *ob, bDeformGroup *dg) BLI_freelinkN(&ob->defbase, dg); /* Update the active deform index if necessary */ - if(ob->actdef > def_nr) + if (ob->actdef > def_nr) ob->actdef--; - if(ob->actdef < 1 && ob->defbase.first) + if (ob->actdef < 1 && ob->defbase.first) ob->actdef= 1; } @@ -1743,7 +1747,7 @@ static void vgroup_active_remove_verts(Object *ob, const int allverts, bDeformGr MDeformVert *dv; const int def_nr= BLI_findindex(&ob->defbase, dg); - if(ob->type == OB_MESH) { + if (ob->type == OB_MESH) { Mesh *me= ob->data; if (me->edit_btmesh) { @@ -1754,7 +1758,7 @@ static void vgroup_active_remove_verts(Object *ob, const int allverts, bDeformGr BM_ITER(eve, &iter, em->bm, BM_VERTS_OF_MESH, NULL) { dv= CustomData_bmesh_get(&em->bm->vdata, eve->head.data, CD_MDEFORMVERT); - if(dv && dv->dw && (allverts || BM_elem_flag_test(eve, BM_ELEM_SELECT))) { + if (dv && dv->dw && (allverts || BM_elem_flag_test(eve, BM_ELEM_SELECT))) { MDeformWeight *dw = defvert_find_index(dv, def_nr); defvert_remove_group(dv, dw); /* dw can be NULL */ } @@ -1782,15 +1786,15 @@ static void vgroup_active_remove_verts(Object *ob, const int allverts, bDeformGr } } } - else if(ob->type == OB_LATTICE) { + else if (ob->type == OB_LATTICE) { Lattice *lt= vgroup_edit_lattice(ob); - if(lt->dvert) { + if (lt->dvert) { BPoint *bp; int i, tot= lt->pntsu*lt->pntsv*lt->pntsw; - for(i=0, bp= lt->def; if1 & SELECT)) { + for (i=0, bp= lt->def; if1 & SELECT)) { MDeformWeight *dw; dv= <->dvert[i]; @@ -1814,7 +1818,7 @@ static void vgroup_delete_edit_mode(Object *ob, bDeformGroup *dg) vgroup_active_remove_verts(ob, TRUE, dg); /* Make sure that any verts with higher indices are adjusted accordingly */ - if(ob->type==OB_MESH) { + if (ob->type==OB_MESH) { Mesh *me= ob->data; BMEditMesh *em = me->edit_btmesh; BMIter iter; @@ -1824,23 +1828,23 @@ static void vgroup_delete_edit_mode(Object *ob, bDeformGroup *dg) BM_ITER(eve, &iter, em->bm, BM_VERTS_OF_MESH, NULL) { dvert= CustomData_bmesh_get(&em->bm->vdata, eve->head.data, CD_MDEFORMVERT); - if(dvert) - for(i=0; itotweight; i++) - if(dvert->dw[i].def_nr > dg_index) + if (dvert) + for (i=0; itotweight; i++) + if (dvert->dw[i].def_nr > dg_index) dvert->dw[i].def_nr--; } } - else if(ob->type==OB_LATTICE) { + else if (ob->type==OB_LATTICE) { Lattice *lt= vgroup_edit_lattice(ob); BPoint *bp; MDeformVert *dvert= lt->dvert; int a, tot; - if(dvert) { + if (dvert) { tot= lt->pntsu*lt->pntsv*lt->pntsw; - for(a=0, bp= lt->def; atotweight; i++){ - if(dvert->dw[i].def_nr > dg_index) + for (a=0, bp= lt->def; atotweight; i++) { + if (dvert->dw[i].def_nr > dg_index) dvert->dw[i].def_nr--; } } @@ -1853,21 +1857,21 @@ static void vgroup_delete_edit_mode(Object *ob, bDeformGroup *dg) BLI_freelinkN (&ob->defbase, dg); /* Update the active deform index if necessary */ - if(ob->actdef > dg_index) + if (ob->actdef > dg_index) ob->actdef--; - if(ob->actdef < 1 && ob->defbase.first) + if (ob->actdef < 1 && ob->defbase.first) ob->actdef= 1; /* remove all dverts */ - if(ob->defbase.first == NULL) { - if(ob->type==OB_MESH) { + if (ob->defbase.first == NULL) { + if (ob->type==OB_MESH) { Mesh *me= ob->data; CustomData_free_layer_active(&me->vdata, CD_MDEFORMVERT, me->totvert); me->dvert= NULL; } - else if(ob->type==OB_LATTICE) { + else if (ob->type==OB_LATTICE) { Lattice *lt= vgroup_edit_lattice(ob); - if(lt->dvert) { + if (lt->dvert) { MEM_freeN(lt->dvert); lt->dvert= NULL; } @@ -1877,9 +1881,9 @@ static void vgroup_delete_edit_mode(Object *ob, bDeformGroup *dg) static int vgroup_object_in_edit_mode(Object *ob) { - if(ob->type == OB_MESH) + if (ob->type == OB_MESH) return (BMEdit_FromObject(ob) != NULL); - else if(ob->type == OB_LATTICE) + else if (ob->type == OB_LATTICE) return (((Lattice*)ob->data)->editlatt != NULL); return 0; @@ -1900,10 +1904,10 @@ static int vgroup_object_in_wpaint_vert_select(Object *ob) static void vgroup_delete(Object *ob) { bDeformGroup *dg = BLI_findlink(&ob->defbase, ob->actdef-1); - if(!dg) + if (!dg) return; - if(vgroup_object_in_edit_mode(ob)) + if (vgroup_object_in_edit_mode(ob)) vgroup_delete_edit_mode(ob, dg); else vgroup_delete_object_mode(ob, dg); @@ -1912,14 +1916,14 @@ static void vgroup_delete(Object *ob) static void vgroup_delete_all(Object *ob) { /* Remove all DVerts */ - if(ob->type==OB_MESH) { + if (ob->type==OB_MESH) { Mesh *me= ob->data; CustomData_free_layer_active(&me->vdata, CD_MDEFORMVERT, me->totvert); me->dvert= NULL; } - else if(ob->type==OB_LATTICE) { + else if (ob->type==OB_LATTICE) { Lattice *lt= vgroup_edit_lattice(ob); - if(lt->dvert) { + if (lt->dvert) { MEM_freeN(lt->dvert); lt->dvert= NULL; } @@ -1938,10 +1942,10 @@ static void vgroup_assign_verts(Object *ob, const float weight) MDeformVert *dv; const int def_nr= ob->actdef-1; - if(!BLI_findlink(&ob->defbase, def_nr)) + if (!BLI_findlink(&ob->defbase, def_nr)) return; - if(ob->type == OB_MESH) { + if (ob->type == OB_MESH) { Mesh *me= ob->data; if (me->edit_btmesh) { @@ -1949,7 +1953,7 @@ static void vgroup_assign_verts(Object *ob, const float weight) BMIter iter; BMVert *eve; - if(!CustomData_has_layer(&em->bm->vdata, CD_MDEFORMVERT)) + if (!CustomData_has_layer(&em->bm->vdata, CD_MDEFORMVERT)) BM_data_layer_add(em->bm, &em->bm->vdata, CD_MDEFORMVERT); /* Go through the list of editverts and assign them */ @@ -1987,19 +1991,19 @@ static void vgroup_assign_verts(Object *ob, const float weight) } } } - else if(ob->type == OB_LATTICE) { + else if (ob->type == OB_LATTICE) { Lattice *lt= vgroup_edit_lattice(ob); BPoint *bp; int a, tot; - if(lt->dvert==NULL) + if (lt->dvert==NULL) ED_vgroup_data_create(<->id); dv= lt->dvert; tot= lt->pntsu*lt->pntsv*lt->pntsw; - for(a=0, bp= lt->def; af1 & SELECT) { + for (a=0, bp= lt->def; af1 & SELECT) { MDeformWeight *dw; dw= defvert_verify_index(dv, def_nr); @@ -2020,7 +2024,7 @@ static void vgroup_remove_verts(Object *ob, int allverts) * active group index */ bDeformGroup *dg; - for(dg= ob->defbase.first; dg; dg= dg->next) { + for (dg= ob->defbase.first; dg; dg= dg->next) { vgroup_active_remove_verts(ob, allverts, dg); } } @@ -2039,7 +2043,7 @@ static int vertex_group_poll_edit(bContext *C) Object *ob= ED_object_context(C); ID *data= (ob)? ob->data: NULL; - if(!(ob && !ob->id.lib && data && !data->lib)) + if (!(ob && !ob->id.lib && data && !data->lib)) return 0; return vgroup_object_in_edit_mode(ob); @@ -2051,7 +2055,7 @@ static int vertex_group_poll_edit_or_wpaint_vert_select(bContext *C) Object *ob= ED_object_context(C); ID *data= (ob)? ob->data: NULL; - if(!(ob && !ob->id.lib && data && !data->lib)) + if (!(ob && !ob->id.lib && data && !data->lib)) return 0; return ( vgroup_object_in_edit_mode(ob) || @@ -2088,7 +2092,7 @@ static int vertex_group_remove_exec(bContext *C, wmOperator *op) { Object *ob= ED_object_context(C); - if(RNA_boolean_get(op->ptr, "all")) + if (RNA_boolean_get(op->ptr, "all")) vgroup_delete_all(ob); else vgroup_delete(ob); @@ -2125,7 +2129,7 @@ static int vertex_group_assign_exec(bContext *C, wmOperator *op) ToolSettings *ts= CTX_data_tool_settings(C); Object *ob= ED_object_context(C); - if(RNA_boolean_get(op->ptr, "new")) + if (RNA_boolean_get(op->ptr, "new")) ED_vgroup_add(ob); vgroup_assign_verts(ob, ts->vgroup_weight); @@ -2159,12 +2163,12 @@ static int vertex_group_remove_from_exec(bContext *C, wmOperator *op) { Object *ob= ED_object_context(C); - if(RNA_boolean_get(op->ptr, "all")) + if (RNA_boolean_get(op->ptr, "all")) vgroup_remove_verts(ob, 0); else { bDeformGroup *dg= BLI_findlink(&ob->defbase, ob->actdef - 1); - if(dg == NULL) { + if (dg == NULL) { return OPERATOR_CANCELLED; } @@ -2201,7 +2205,7 @@ static int vertex_group_select_exec(bContext *C, wmOperator *UNUSED(op)) { Object *ob= ED_object_context(C); - if(!ob || ob->id.lib) + if (!ob || ob->id.lib) return OPERATOR_CANCELLED; vgroup_select_verts(ob, 1); @@ -2375,14 +2379,14 @@ static int vertex_group_fix_exec(bContext *C, wmOperator *op) float cp= RNA_float_get(op->ptr, "accuracy"); ModifierData *md= ob->modifiers.first; - while(md) { - if(md->type == eModifierType_Mirror && (md->mode&eModifierMode_Realtime)) { + while (md) { + if (md->type == eModifierType_Mirror && (md->mode&eModifierMode_Realtime)) { break; } md = md->next; } - if(md && md->type == eModifierType_Mirror) { + if (md && md->type == eModifierType_Mirror) { BKE_report(op->reports, RPT_ERROR_INVALID_CONTEXT, "This operator does not support an active mirror modifier"); return OPERATOR_CANCELLED; } @@ -2515,7 +2519,7 @@ static int vertex_group_clean_exec(bContext *C, wmOperator *op) int all_groups= RNA_boolean_get(op->ptr,"all_groups"); int keep_single= RNA_boolean_get(op->ptr,"keep_single"); - if(all_groups) vgroup_clean_all(ob, limit, keep_single); + if (all_groups) vgroup_clean_all(ob, limit, keep_single); else vgroup_clean(ob, limit, keep_single); DAG_id_tag_update(&ob->id, OB_RECALC_DATA); @@ -2591,9 +2595,9 @@ static int vertex_group_copy_to_linked_exec(bContext *C, wmOperator *UNUSED(op)) Base *base; int retval= OPERATOR_CANCELLED; - for(base=scene->base.first; base; base= base->next) { - if(base->object->type==ob->type) { - if(base->object!=ob && base->object->data==ob->data) { + for (base=scene->base.first; base; base= base->next) { + if (base->object->type==ob->type) { + if (base->object!=ob && base->object->data==ob->data) { BLI_freelistN(&base->object->defbase); BLI_duplicatelist(&base->object->defbase, &ob->defbase); base->object->actdef= ob->actdef; @@ -2633,14 +2637,14 @@ static int vertex_group_copy_to_selected_exec(bContext *C, wmOperator *op) CTX_DATA_BEGIN(C, Object*, ob, selected_editable_objects) { - if(obact != ob) { - if(ED_vgroup_copy_array(ob, obact)) change++; + if (obact != ob) { + if (ED_vgroup_copy_array(ob, obact)) change++; else fail++; } } CTX_DATA_END; - if((change == 0 && fail == 0) || fail) { + if ((change == 0 && fail == 0) || fail) { BKE_reportf(op->reports, RPT_ERROR, "Copy to VGroups to Selected warning done %d, failed %d, object data must have matching indices", change, fail); @@ -2690,10 +2694,10 @@ static EnumPropertyItem *vgroup_itemf(bContext *C, PointerRNA *UNUSED(ptr), Prop bDeformGroup *def; int a, totitem= 0; - if(!ob) + if (!ob) return vgroup_items; - for(a=0, def=ob->defbase.first; def; def=def->next, a++) { + for (a=0, def=ob->defbase.first; def; def=def->next, a++) { tmp.value= a; tmp.icon= ICON_GROUP_VERTEX; tmp.identifier= def->name; @@ -2740,7 +2744,7 @@ static char *vgroup_init_remap(Object *ob) char *name; name= name_array; - for(def = ob->defbase.first; def; def=def->next) { + for (def = ob->defbase.first; def; def=def->next) { BLI_strncpy(name, def->name, MAX_VGROUP_NAME); name += MAX_VGROUP_NAME; } @@ -2762,22 +2766,22 @@ static int vgroup_do_remap(Object *ob, char *name_array, wmOperator *op) int i; name= name_array; - for(def= ob->defbase.first, i=0; def; def=def->next, i++){ + for (def= ob->defbase.first, i=0; def; def=def->next, i++) { sort_map[i]= BLI_findstringindex(&ob->defbase, name, offsetof(bDeformGroup, name)); name += MAX_VGROUP_NAME; BLI_assert(sort_map[i] != -1); } - if(ob->mode == OB_MODE_EDIT) { - if(ob->type==OB_MESH) { + if (ob->mode == OB_MODE_EDIT) { + if (ob->type==OB_MESH) { BMEditMesh *em = BMEdit_FromObject(ob); BMIter iter; BMVert *eve; BM_ITER(eve, &iter, em->bm, BM_VERTS_OF_MESH, NULL) { dvert= CustomData_bmesh_get(&em->bm->vdata, eve->head.data, CD_MDEFORMVERT); - if(dvert && dvert->totweight){ + if (dvert && dvert->totweight) { defvert_remap(dvert, sort_map, defbase_tot); } } @@ -2794,15 +2798,15 @@ static int vgroup_do_remap(Object *ob, char *name_array, wmOperator *op) ED_vgroup_give_array(ob->data, &dvert, &dvert_tot); /*create as necessary*/ - while(dvert && dvert_tot--) { - if(dvert->totweight) + while (dvert && dvert_tot--) { + if (dvert->totweight) defvert_remap(dvert, sort_map, defbase_tot); dvert++; } } /* update users */ - for(i=0; idefbase, def); BLI_insertlinkbefore(&ob->defbase, prev, def); - } else { /*down*/ + } + else { /*down*/ void *next = def->next; BLI_remlink(&ob->defbase, def); diff --git a/source/blender/editors/physics/dynamicpaint_ops.c b/source/blender/editors/physics/dynamicpaint_ops.c index 41600bdb728..417cddb74fe 100644 --- a/source/blender/editors/physics/dynamicpaint_ops.c +++ b/source/blender/editors/physics/dynamicpaint_ops.c @@ -73,7 +73,7 @@ static int surface_slot_add_exec(bContext *C, wmOperator *UNUSED(op)) /* set preview for this surface only and set active */ canvas->active_sur = 0; - for(surface=surface->prev; surface; surface=surface->prev) { + for (surface=surface->prev; surface; surface=surface->prev) { surface->flags &= ~MOD_DPAINT_PREVIEW; canvas->active_sur++; } @@ -113,8 +113,8 @@ static int surface_slot_remove_exec(bContext *C, wmOperator *UNUSED(op)) surface = canvas->surfaces.first; /* find active surface and remove it */ - for(; surface; surface=surface->next) { - if(id == canvas->active_sur) { + for (; surface; surface=surface->next) { + if (id == canvas->active_sur) { canvas->active_sur -= 1; dynamicPaint_freeSurface(surface); break; @@ -408,7 +408,7 @@ static int dynamicPaint_initBake(struct bContext *C, struct wmOperator *op) static int dynamicpaint_bake_exec(bContext *C, wmOperator *op) { /* Bake dynamic paint */ - if(!dynamicPaint_initBake(C, op)) { + if (!dynamicPaint_initBake(C, op)) { return OPERATOR_CANCELLED;} return OPERATOR_FINISHED; diff --git a/source/blender/editors/physics/particle_boids.c b/source/blender/editors/physics/particle_boids.c index 8440b7144a5..7a7c16b23ff 100644 --- a/source/blender/editors/physics/particle_boids.c +++ b/source/blender/editors/physics/particle_boids.c @@ -65,7 +65,7 @@ static int rule_add_exec(bContext *C, wmOperator *op) BoidRule *rule; BoidState *state; - if(!psys || !psys->part || psys->part->phystype != PART_PHYS_BOIDS) + if (!psys || !psys->part || psys->part->phystype != PART_PHYS_BOIDS) return OPERATOR_CANCELLED; part = psys->part; @@ -73,7 +73,7 @@ static int rule_add_exec(bContext *C, wmOperator *op) state = boid_get_current_state(part->boids); - for(rule=state->rules.first; rule; rule=rule->next) + for (rule=state->rules.first; rule; rule=rule->next) rule->flag &= ~BOIDRULE_CURRENT; rule = boid_new_rule(type); @@ -113,14 +113,14 @@ static int rule_del_exec(bContext *C, wmOperator *UNUSED(op)) BoidRule *rule; BoidState *state; - if(!psys || !psys->part || psys->part->phystype != PART_PHYS_BOIDS) + if (!psys || !psys->part || psys->part->phystype != PART_PHYS_BOIDS) return OPERATOR_CANCELLED; state = boid_get_current_state(psys->part->boids); - for(rule=state->rules.first; rule; rule=rule->next) { - if(rule->flag & BOIDRULE_CURRENT) { + for (rule=state->rules.first; rule; rule=rule->next) { + if (rule->flag & BOIDRULE_CURRENT) { BLI_remlink(&state->rules, rule); MEM_freeN(rule); break; @@ -129,7 +129,7 @@ static int rule_del_exec(bContext *C, wmOperator *UNUSED(op)) } rule = state->rules.first; - if(rule) + if (rule) rule->flag |= BOIDRULE_CURRENT; DAG_scene_sort(bmain, scene); @@ -162,12 +162,12 @@ static int rule_move_up_exec(bContext *C, wmOperator *UNUSED(op)) BoidRule *rule; BoidState *state; - if(!psys || !psys->part || psys->part->phystype != PART_PHYS_BOIDS) + if (!psys || !psys->part || psys->part->phystype != PART_PHYS_BOIDS) return OPERATOR_CANCELLED; state = boid_get_current_state(psys->part->boids); - for(rule = state->rules.first; rule; rule=rule->next) { - if(rule->flag & BOIDRULE_CURRENT && rule->prev) { + for (rule = state->rules.first; rule; rule=rule->next) { + if (rule->flag & BOIDRULE_CURRENT && rule->prev) { BLI_remlink(&state->rules, rule); BLI_insertlink(&state->rules, rule->prev->prev, rule); @@ -200,12 +200,12 @@ static int rule_move_down_exec(bContext *C, wmOperator *UNUSED(op)) BoidRule *rule; BoidState *state; - if(!psys || !psys->part || psys->part->phystype != PART_PHYS_BOIDS) + if (!psys || !psys->part || psys->part->phystype != PART_PHYS_BOIDS) return OPERATOR_CANCELLED; state = boid_get_current_state(psys->part->boids); - for(rule = state->rules.first; rule; rule=rule->next) { - if(rule->flag & BOIDRULE_CURRENT && rule->next) { + for (rule = state->rules.first; rule; rule=rule->next) { + if (rule->flag & BOIDRULE_CURRENT && rule->next) { BLI_remlink(&state->rules, rule); BLI_insertlink(&state->rules, rule->next, rule); @@ -240,12 +240,12 @@ static int state_add_exec(bContext *C, wmOperator *UNUSED(op)) ParticleSettings *part; BoidState *state; - if(!psys || !psys->part || psys->part->phystype != PART_PHYS_BOIDS) + if (!psys || !psys->part || psys->part->phystype != PART_PHYS_BOIDS) return OPERATOR_CANCELLED; part = psys->part; - for(state=part->boids->states.first; state; state=state->next) + for (state=part->boids->states.first; state; state=state->next) state->flag &= ~BOIDSTATE_CURRENT; state = boid_new_state(part->boids); @@ -281,13 +281,13 @@ static int state_del_exec(bContext *C, wmOperator *UNUSED(op)) ParticleSettings *part; BoidState *state; - if(!psys || !psys->part || psys->part->phystype != PART_PHYS_BOIDS) + if (!psys || !psys->part || psys->part->phystype != PART_PHYS_BOIDS) return OPERATOR_CANCELLED; part = psys->part; - for(state=part->boids->states.first; state; state=state->next) { - if(state->flag & BOIDSTATE_CURRENT) { + for (state=part->boids->states.first; state; state=state->next) { + if (state->flag & BOIDSTATE_CURRENT) { BLI_remlink(&part->boids->states, state); MEM_freeN(state); break; @@ -296,7 +296,7 @@ static int state_del_exec(bContext *C, wmOperator *UNUSED(op)) } /* there must be at least one state */ - if(!part->boids->states.first) { + if (!part->boids->states.first) { state = boid_new_state(part->boids); BLI_addtail(&part->boids->states, state); } @@ -335,13 +335,13 @@ static int state_move_up_exec(bContext *C, wmOperator *UNUSED(op)) BoidSettings *boids; BoidState *state; - if(!psys || !psys->part || psys->part->phystype != PART_PHYS_BOIDS) + if (!psys || !psys->part || psys->part->phystype != PART_PHYS_BOIDS) return OPERATOR_CANCELLED; boids = psys->part->boids; - for(state = boids->states.first; state; state=state->next) { - if(state->flag & BOIDSTATE_CURRENT && state->prev) { + for (state = boids->states.first; state; state=state->next) { + if (state->flag & BOIDSTATE_CURRENT && state->prev) { BLI_remlink(&boids->states, state); BLI_insertlink(&boids->states, state->prev->prev, state); WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob); @@ -371,13 +371,13 @@ static int state_move_down_exec(bContext *C, wmOperator *UNUSED(op)) BoidSettings *boids; BoidState *state; - if(!psys || !psys->part || psys->part->phystype != PART_PHYS_BOIDS) + if (!psys || !psys->part || psys->part->phystype != PART_PHYS_BOIDS) return OPERATOR_CANCELLED; boids = psys->part->boids; - for(state = boids->states.first; state; state=state->next) { - if(state->flag & BOIDSTATE_CURRENT && state->next) { + for (state = boids->states.first; state; state=state->next) { + if (state->flag & BOIDSTATE_CURRENT && state->next) { BLI_remlink(&boids->states, state); BLI_insertlink(&boids->states, state->next, state); DAG_id_tag_update(&psys->part->id, OB_RECALC_DATA|PSYS_RECALC_RESET); diff --git a/source/blender/editors/physics/particle_edit.c b/source/blender/editors/physics/particle_edit.c index 15f2006e2b8..68d464da261 100644 --- a/source/blender/editors/physics/particle_edit.c +++ b/source/blender/editors/physics/particle_edit.c @@ -89,16 +89,16 @@ static void recalc_emitter_field(Object *ob, ParticleSystem *psys); #define KEY_K PTCacheEditKey *key; int k #define POINT_P PTCacheEditPoint *point; int p -#define LOOP_POINTS for(p=0, point=edit->points; ptotpoint; p++, point++) -#define LOOP_VISIBLE_POINTS for(p=0, point=edit->points; ptotpoint; p++, point++) if(!(point->flag & PEP_HIDE)) -#define LOOP_SELECTED_POINTS for(p=0, point=edit->points; ptotpoint; p++, point++) if(point_is_selected(point)) -#define LOOP_UNSELECTED_POINTS for(p=0, point=edit->points; ptotpoint; p++, point++) if(!point_is_selected(point)) -#define LOOP_EDITED_POINTS for(p=0, point=edit->points; ptotpoint; p++, point++) if(point->flag & PEP_EDIT_RECALC) -#define LOOP_TAGGED_POINTS for(p=0, point=edit->points; ptotpoint; p++, point++) if(point->flag & PEP_TAG) -#define LOOP_KEYS for(k=0, key=point->keys; ktotkey; k++, key++) -#define LOOP_VISIBLE_KEYS for(k=0, key=point->keys; ktotkey; k++, key++) if(!(key->flag & PEK_HIDE)) -#define LOOP_SELECTED_KEYS for(k=0, key=point->keys; ktotkey; k++, key++) if((key->flag & PEK_SELECT) && !(key->flag & PEK_HIDE)) -#define LOOP_TAGGED_KEYS for(k=0, key=point->keys; ktotkey; k++, key++) if(key->flag & PEK_TAG) +#define LOOP_POINTS for (p=0, point=edit->points; ptotpoint; p++, point++) +#define LOOP_VISIBLE_POINTS for (p=0, point=edit->points; ptotpoint; p++, point++) if(!(point->flag & PEP_HIDE)) +#define LOOP_SELECTED_POINTS for (p=0, point=edit->points; ptotpoint; p++, point++) if(point_is_selected(point)) +#define LOOP_UNSELECTED_POINTS for (p=0, point=edit->points; ptotpoint; p++, point++) if(!point_is_selected(point)) +#define LOOP_EDITED_POINTS for (p=0, point=edit->points; ptotpoint; p++, point++) if(point->flag & PEP_EDIT_RECALC) +#define LOOP_TAGGED_POINTS for (p=0, point=edit->points; ptotpoint; p++, point++) if(point->flag & PEP_TAG) +#define LOOP_KEYS for (k=0, key=point->keys; ktotkey; k++, key++) +#define LOOP_VISIBLE_KEYS for (k=0, key=point->keys; ktotkey; k++, key++) if(!(key->flag & PEK_HIDE)) +#define LOOP_SELECTED_KEYS for (k=0, key=point->keys; ktotkey; k++, key++) if((key->flag & PEK_SELECT) && !(key->flag & PEK_HIDE)) +#define LOOP_TAGGED_KEYS for (k=0, key=point->keys; ktotkey; k++, key++) if(key->flag & PEK_TAG) #define KEY_WCO (key->flag & PEK_USE_WCO ? key->world_co : key->co) @@ -109,7 +109,7 @@ int PE_poll(bContext *C) Scene *scene= CTX_data_scene(C); Object *ob= CTX_data_active_object(C); - if(!scene || !ob || !(ob->mode & OB_MODE_PARTICLE_EDIT)) + if (!scene || !ob || !(ob->mode & OB_MODE_PARTICLE_EDIT)) return 0; return (PE_get_current(scene, ob) != NULL); @@ -121,7 +121,7 @@ int PE_hair_poll(bContext *C) Object *ob= CTX_data_active_object(C); PTCacheEdit *edit; - if(!scene || !ob || !(ob->mode & OB_MODE_PARTICLE_EDIT)) + if (!scene || !ob || !(ob->mode & OB_MODE_PARTICLE_EDIT)) return 0; edit= PE_get_current(scene, ob); @@ -139,28 +139,28 @@ void PE_free_ptcache_edit(PTCacheEdit *edit) { POINT_P; - if(edit==0) return; + if (edit==0) return; PTCacheUndo_clear(edit); - if(edit->points) { + if (edit->points) { LOOP_POINTS { - if(point->keys) + if (point->keys) MEM_freeN(point->keys); } MEM_freeN(edit->points); } - if(edit->mirror_cache) + if (edit->mirror_cache) MEM_freeN(edit->mirror_cache); - if(edit->emitter_cosnos) { + if (edit->emitter_cosnos) { MEM_freeN(edit->emitter_cosnos); edit->emitter_cosnos= 0; } - if(edit->emitter_field) { + if (edit->emitter_field) { BLI_kdtree_free(edit->emitter_field); edit->emitter_field= 0; } @@ -176,9 +176,9 @@ void PE_free_ptcache_edit(PTCacheEdit *edit) int PE_start_edit(PTCacheEdit *edit) { - if(edit) { + if (edit) { edit->edited = 1; - if(edit->psys) + if (edit->psys) edit->psys->flag |= PSYS_EDITED; return 1; } @@ -202,7 +202,7 @@ static PTCacheEdit *pe_get_current(Scene *scene, Object *ob, int create) ListBase pidlist; PTCacheID *pid; - if(pset==NULL || ob==NULL) + if (pset==NULL || ob==NULL) return NULL; pset->scene = scene; @@ -211,7 +211,7 @@ static PTCacheEdit *pe_get_current(Scene *scene, Object *ob, int create) BKE_ptcache_ids_from_object(&pidlist, ob, NULL, 0); /* in the case of only one editable thing, set pset->edittype accordingly */ - if(pidlist.first && pidlist.first == pidlist.last) { + if (pidlist.first && pidlist.first == pidlist.last) { pid = pidlist.first; switch(pid->type) { case PTCACHE_TYPE_PARTICLES: @@ -226,25 +226,25 @@ static PTCacheEdit *pe_get_current(Scene *scene, Object *ob, int create) } } - for(pid=pidlist.first; pid; pid=pid->next) { - if(pset->edittype == PE_TYPE_PARTICLES && pid->type == PTCACHE_TYPE_PARTICLES) { + for (pid=pidlist.first; pid; pid=pid->next) { + if (pset->edittype == PE_TYPE_PARTICLES && pid->type == PTCACHE_TYPE_PARTICLES) { ParticleSystem *psys = pid->calldata; - if(psys->flag & PSYS_CURRENT) { - if(psys->part && psys->part->type == PART_HAIR) { - if(psys->flag & PSYS_HAIR_DYNAMICS && psys->pointcache->flag & PTCACHE_BAKED) { - if(create && !psys->pointcache->edit) + if (psys->flag & PSYS_CURRENT) { + if (psys->part && psys->part->type == PART_HAIR) { + if (psys->flag & PSYS_HAIR_DYNAMICS && psys->pointcache->flag & PTCACHE_BAKED) { + if (create && !psys->pointcache->edit) PE_create_particle_edit(scene, ob, pid->cache, NULL); edit = pid->cache->edit; } else { - if(create && !psys->edit && psys->flag & PSYS_HAIR_DONE) + if (create && !psys->edit && psys->flag & PSYS_HAIR_DONE) PE_create_particle_edit(scene, ob, NULL, psys); edit = psys->edit; } } else { - if(create && pid->cache->flag & PTCACHE_BAKED && !pid->cache->edit) + if (create && pid->cache->flag & PTCACHE_BAKED && !pid->cache->edit) PE_create_particle_edit(scene, ob, pid->cache, psys); edit = pid->cache->edit; } @@ -272,7 +272,7 @@ static PTCacheEdit *pe_get_current(Scene *scene, Object *ob, int create) } } - if(edit) + if (edit) edit->pid = *pid; BLI_freelistN(&pidlist); @@ -292,7 +292,7 @@ PTCacheEdit *PE_create_current(Scene *scene, Object *ob) void PE_current_changed(Scene *scene, Object *ob) { - if(ob->mode == OB_MODE_PARTICLE_EDIT) + if (ob->mode == OB_MODE_PARTICLE_EDIT) PE_create_current(scene, ob); } @@ -302,10 +302,10 @@ void PE_hide_keys_time(Scene *scene, PTCacheEdit *edit, float cfra) POINT_P; KEY_K; - if(pset->flag & PE_FADE_TIME && pset->selectmode==SCE_SELECT_POINT) { + if (pset->flag & PE_FADE_TIME && pset->selectmode==SCE_SELECT_POINT) { LOOP_POINTS { LOOP_KEYS { - if(fabs(cfra-*key->time) < pset->fade_frames) + if (fabs(cfra-*key->time) < pset->fade_frames) key->flag &= ~PEK_HIDE; else { key->flag |= PEK_HIDE; @@ -325,7 +325,7 @@ void PE_hide_keys_time(Scene *scene, PTCacheEdit *edit, float cfra) static int pe_x_mirror(Object *ob) { - if(ob->type == OB_MESH) + if (ob->type == OB_MESH) return (((Mesh*)ob->data)->editflag & ME_EDIT_MIRROR_X); return 0; @@ -380,8 +380,8 @@ static void PE_set_view3d_data(bContext *C, PEData *data) /* note, the object argument means the modelview matrix does not account for the objects matrix, use viewmat rather than (obmat * viewmat) */ view3d_get_transformation(data->vc.ar, data->vc.rv3d, NULL, &data->mats); - if((data->vc.v3d->drawtype>OB_WIRE) && (data->vc.v3d->flag & V3D_ZBUF_SELECT)) { - if(data->vc.v3d->flag & V3D_INVALID_BACKBUF) { + if ((data->vc.v3d->drawtype>OB_WIRE) && (data->vc.v3d->flag & V3D_ZBUF_SELECT)) { + if (data->vc.v3d->flag & V3D_INVALID_BACKBUF) { /* needed or else the draw matrix can be incorrect */ view3d_operator_needs_opengl(C); @@ -404,12 +404,12 @@ static int key_test_depth(PEData *data, const float co[3]) short wco[3], x,y; /* nothing to do */ - if((v3d->drawtype<=OB_WIRE) || (v3d->flag & V3D_ZBUF_SELECT)==0) + if ((v3d->drawtype<=OB_WIRE) || (v3d->flag & V3D_ZBUF_SELECT)==0) return 1; project_short(data->vc.ar, co, wco); - if(wco[0] == IS_CLIPPED) + if (wco[0] == IS_CLIPPED) return 0; gluProject(co[0],co[1],co[2], data->mats.modelview, data->mats.projection, @@ -434,7 +434,7 @@ static int key_test_depth(PEData *data, const float co[3]) } #endif - if((float)uz - 0.00001f > depth) + if ((float)uz - 0.00001f > depth) return 0; else return 1; @@ -447,18 +447,18 @@ static int key_inside_circle(PEData *data, float rad, const float co[3], float * project_int(data->vc.ar, co, sco); - if(sco[0] == IS_CLIPPED) + if (sco[0] == IS_CLIPPED) return 0; dx= data->mval[0] - sco[0]; dy= data->mval[1] - sco[1]; dist= sqrt(dx*dx + dy*dy); - if(dist > rad) + if (dist > rad) return 0; - if(key_test_depth(data, co)) { - if(distance) + if (key_test_depth(data, co)) { + if (distance) *distance=dist; return 1; @@ -473,10 +473,10 @@ static int key_inside_rect(PEData *data, const float co[3]) project_int(data->vc.ar, co,sco); - if(sco[0] == IS_CLIPPED) + if (sco[0] == IS_CLIPPED) return 0; - if(sco[0] > data->rect->xmin && sco[0] < data->rect->xmax && + if (sco[0] > data->rect->xmin && sco[0] < data->rect->xmax && sco[1] > data->rect->ymin && sco[1] < data->rect->ymax) return key_test_depth(data, co); @@ -485,7 +485,7 @@ static int key_inside_rect(PEData *data, const float co[3]) static int key_inside_test(PEData *data, const float co[3]) { - if(data->mval) + if (data->mval) return key_inside_circle(data, data->rad, co, NULL); else return key_inside_rect(data, co); @@ -495,7 +495,7 @@ static int point_is_selected(PTCacheEditPoint *point) { KEY_K; - if(point->flag & PEP_HIDE) + if (point->flag & PEP_HIDE) return 0; LOOP_SELECTED_KEYS { @@ -520,43 +520,43 @@ static void for_mouse_hit_keys(PEData *data, ForKeyFunc func, int nearest) float dist= data->rad; /* in path select mode we have no keys */ - if(pset->selectmode==SCE_SELECT_PATH) + if (pset->selectmode==SCE_SELECT_PATH) return; nearest_point= -1; nearest_key= -1; LOOP_VISIBLE_POINTS { - if(pset->selectmode == SCE_SELECT_END) { + if (pset->selectmode == SCE_SELECT_END) { /* only do end keys */ key= point->keys + point->totkey-1; - if(nearest) { - if(key_inside_circle(data, dist, KEY_WCO, &dist)) { + if (nearest) { + if (key_inside_circle(data, dist, KEY_WCO, &dist)) { nearest_point= p; nearest_key= point->totkey-1; } } - else if(key_inside_test(data, KEY_WCO)) + else if (key_inside_test(data, KEY_WCO)) func(data, p, point->totkey-1); } else { /* do all keys */ LOOP_VISIBLE_KEYS { - if(nearest) { - if(key_inside_circle(data, dist, KEY_WCO, &dist)) { + if (nearest) { + if (key_inside_circle(data, dist, KEY_WCO, &dist)) { nearest_point= p; nearest_key= k; } } - else if(key_inside_test(data, KEY_WCO)) + else if (key_inside_test(data, KEY_WCO)) func(data, p, k); } } } /* do nearest only */ - if(nearest && nearest_point > -1) + if (nearest && nearest_point > -1) func(data, nearest_point, nearest_key); } @@ -567,23 +567,23 @@ static void foreach_mouse_hit_point(PEData *data, ForPointFunc func, int selecte POINT_P; KEY_K; /* all is selected in path mode */ - if(pset->selectmode==SCE_SELECT_PATH) + if (pset->selectmode==SCE_SELECT_PATH) selected=0; LOOP_VISIBLE_POINTS { - if(pset->selectmode==SCE_SELECT_END) { + if (pset->selectmode==SCE_SELECT_END) { /* only do end keys */ key= point->keys + point->totkey - 1; - if(selected==0 || key->flag & PEK_SELECT) - if(key_inside_circle(data, data->rad, KEY_WCO, &data->dist)) + if (selected==0 || key->flag & PEK_SELECT) + if (key_inside_circle(data, data->rad, KEY_WCO, &data->dist)) func(data, p); } else { /* do all keys */ LOOP_VISIBLE_KEYS { - if(selected==0 || key->flag & PEK_SELECT) { - if(key_inside_circle(data, data->rad, KEY_WCO, &data->dist)) { + if (selected==0 || key->flag & PEK_SELECT) { + if (key_inside_circle(data, data->rad, KEY_WCO, &data->dist)) { func(data, p); break; } @@ -602,21 +602,21 @@ static void foreach_mouse_hit_key(PEData *data, ForKeyMatFunc func, int selected POINT_P; KEY_K; float mat[4][4]= MAT4_UNITY, imat[4][4]= MAT4_UNITY; - if(edit->psys) + if (edit->psys) psmd= psys_get_modifier(data->ob, edit->psys); /* all is selected in path mode */ - if(pset->selectmode==SCE_SELECT_PATH) + if (pset->selectmode==SCE_SELECT_PATH) selected= 0; LOOP_VISIBLE_POINTS { - if(pset->selectmode==SCE_SELECT_END) { + if (pset->selectmode==SCE_SELECT_END) { /* only do end keys */ key= point->keys + point->totkey-1; - if(selected==0 || key->flag & PEK_SELECT) { - if(key_inside_circle(data, data->rad, KEY_WCO, &data->dist)) { - if(edit->psys && !(edit->psys->flag & PSYS_GLOBAL_HAIR)) { + if (selected==0 || key->flag & PEK_SELECT) { + if (key_inside_circle(data, data->rad, KEY_WCO, &data->dist)) { + if (edit->psys && !(edit->psys->flag & PSYS_GLOBAL_HAIR)) { psys_mat_hair_to_global(data->ob, psmd->dm, psys->part->from, psys->particles + p, mat); invert_m4_m4(imat,mat); } @@ -628,9 +628,9 @@ static void foreach_mouse_hit_key(PEData *data, ForKeyMatFunc func, int selected else { /* do all keys */ LOOP_VISIBLE_KEYS { - if(selected==0 || key->flag & PEK_SELECT) { - if(key_inside_circle(data, data->rad, KEY_WCO, &data->dist)) { - if(edit->psys && !(edit->psys->flag & PSYS_GLOBAL_HAIR)) { + if (selected==0 || key->flag & PEK_SELECT) { + if (key_inside_circle(data, data->rad, KEY_WCO, &data->dist)) { + if (edit->psys && !(edit->psys->flag & PSYS_GLOBAL_HAIR)) { psys_mat_hair_to_global(data->ob, psmd->dm, psys->part->from, psys->particles + p, mat); invert_m4_m4(imat,mat); } @@ -682,14 +682,14 @@ static int count_selected_keys(Scene *scene, PTCacheEdit *edit) int sel= 0; LOOP_VISIBLE_POINTS { - if(pset->selectmode==SCE_SELECT_POINT) { + if (pset->selectmode==SCE_SELECT_POINT) { LOOP_SELECTED_KEYS { sel++; } } - else if(pset->selectmode==SCE_SELECT_END) { + else if (pset->selectmode==SCE_SELECT_END) { key = point->keys + point->totkey - 1; - if(key->flag & PEK_SELECT) + if (key->flag & PEK_SELECT) sel++; } } @@ -716,7 +716,7 @@ static void PE_update_mirror_cache(Object *ob, ParticleSystem *psys) psmd= psys_get_modifier(ob, psys); totpart= psys->totpart; - if(!psmd->dm) + if (!psmd->dm) return; tree= BLI_kdtree_new(totpart); @@ -733,7 +733,7 @@ static void PE_update_mirror_cache(Object *ob, ParticleSystem *psys) BLI_kdtree_balance(tree); /* lookup particles and set in mirror cache */ - if(!edit->mirror_cache) + if (!edit->mirror_cache) edit->mirror_cache= MEM_callocN(sizeof(int)*totpart, "PE mirror cache"); LOOP_PARTICLES { @@ -746,7 +746,7 @@ static void PE_update_mirror_cache(Object *ob, ParticleSystem *psys) index= BLI_kdtree_find_nearest(tree, co, NULL, &nearest); /* this needs a custom threshold still, duplicated for editmode mirror */ - if(index != -1 && index != p && (nearest.dist <= 0.0002f)) + if (index != -1 && index != p && (nearest.dist <= 0.0002f)) edit->mirror_cache[p]= index; else edit->mirror_cache[p]= -1; @@ -754,9 +754,9 @@ static void PE_update_mirror_cache(Object *ob, ParticleSystem *psys) /* make sure mirrors are in two directions */ LOOP_PARTICLES { - if(edit->mirror_cache[p]) { + if (edit->mirror_cache[p]) { index= edit->mirror_cache[p]; - if(edit->mirror_cache[index] != p) + if (edit->mirror_cache[index] != p) edit->mirror_cache[p]= -1; } } @@ -777,15 +777,15 @@ static void PE_mirror_particle(Object *ob, DerivedMesh *dm, ParticleSystem *psys i= pa - psys->particles; /* find mirrored particle if needed */ - if(!mpa) { - if(!edit->mirror_cache) + if (!mpa) { + if (!edit->mirror_cache) PE_update_mirror_cache(ob, psys); - if(!edit->mirror_cache) + if (!edit->mirror_cache) return; /* something went wrong! */ mi= edit->mirror_cache[i]; - if(mi == -1) + if (mi == -1) return; mpa= psys->particles + mi; } @@ -796,9 +796,9 @@ static void PE_mirror_particle(Object *ob, DerivedMesh *dm, ParticleSystem *psys mpoint = edit->points + mi; /* make sure they have the same amount of keys */ - if(pa->totkey != mpa->totkey) { - if(mpa->hair) MEM_freeN(mpa->hair); - if(mpoint->keys) MEM_freeN(mpoint->keys); + if (pa->totkey != mpa->totkey) { + if (mpa->hair) MEM_freeN(mpa->hair); + if (mpoint->keys) MEM_freeN(mpoint->keys); mpa->hair= MEM_dupallocN(pa->hair); mpa->totkey= pa->totkey; @@ -807,7 +807,7 @@ static void PE_mirror_particle(Object *ob, DerivedMesh *dm, ParticleSystem *psys mhkey= mpa->hair; mkey= mpoint->keys; - for(k=0; ktotkey; k++, mkey++, mhkey++) { + for (k=0; ktotkey; k++, mkey++, mhkey++) { mkey->co= mhkey->co; mkey->time= &mhkey->time; mkey->flag &= ~PEK_SELECT; @@ -823,21 +823,21 @@ static void PE_mirror_particle(Object *ob, DerivedMesh *dm, ParticleSystem *psys mhkey=mpa->hair; key= point->keys; mkey= mpoint->keys; - for(k=0; ktotkey; k++, hkey++, mhkey++, key++, mkey++) { + for (k=0; ktotkey; k++, hkey++, mhkey++, key++, mkey++) { copy_v3_v3(mhkey->co, hkey->co); mul_m4_v3(mat, mhkey->co); mhkey->co[0]= -mhkey->co[0]; mul_m4_v3(immat, mhkey->co); - if(key->flag & PEK_TAG) + if (key->flag & PEK_TAG) mkey->flag |= PEK_TAG; mkey->length = key->length; } - if(point->flag & PEP_TAG) + if (point->flag & PEP_TAG) mpoint->flag |= PEP_TAG; - if(point->flag & PEP_EDIT_RECALC) + if (point->flag & PEP_EDIT_RECALC) mpoint->flag |= PEP_EDIT_RECALC; } @@ -847,35 +847,35 @@ static void PE_apply_mirror(Object *ob, ParticleSystem *psys) ParticleSystemModifierData *psmd; POINT_P; - if(!psys) + if (!psys) return; edit= psys->edit; psmd= psys_get_modifier(ob, psys); - if(!psmd->dm) + if (!psmd->dm) return; - if(!edit->mirror_cache) + if (!edit->mirror_cache) PE_update_mirror_cache(ob, psys); - if(!edit->mirror_cache) + if (!edit->mirror_cache) return; /* something went wrong */ /* we delay settings the PARS_EDIT_RECALC for mirrored particles * to avoid doing mirror twice */ LOOP_POINTS { - if(point->flag & PEP_EDIT_RECALC) { + if (point->flag & PEP_EDIT_RECALC) { PE_mirror_particle(ob, psmd->dm, psys, psys->particles + p, NULL); - if(edit->mirror_cache[p] != -1) + if (edit->mirror_cache[p] != -1) edit->points[edit->mirror_cache[p]].flag &= ~PEP_EDIT_RECALC; } } LOOP_POINTS { - if(point->flag & PEP_EDIT_RECALC) - if(edit->mirror_cache[p] != -1) + if (point->flag & PEP_EDIT_RECALC) + if (edit->mirror_cache[p] != -1) edit->points[edit->mirror_cache[p]].flag |= PEP_EDIT_RECALC; } } @@ -894,13 +894,13 @@ static void pe_deflect_emitter(Scene *scene, Object *ob, PTCacheEdit *edit) float *vec, *nor, dvec[3], dot, dist_1st=0.0f; float hairimat[4][4], hairmat[4][4]; - if(edit==NULL || edit->psys==NULL || (pset->flag & PE_DEFLECT_EMITTER)==0 || (edit->psys->flag & PSYS_GLOBAL_HAIR)) + if (edit==NULL || edit->psys==NULL || (pset->flag & PE_DEFLECT_EMITTER)==0 || (edit->psys->flag & PSYS_GLOBAL_HAIR)) return; psys = edit->psys; psmd = psys_get_modifier(ob,psys); - if(!psmd->dm) + if (!psmd->dm) return; LOOP_EDITED_POINTS { @@ -911,7 +911,7 @@ static void pe_deflect_emitter(Scene *scene, Object *ob, PTCacheEdit *edit) } LOOP_KEYS { - if(k==0) { + if (k==0) { dist_1st = len_v3v3((key+1)->co, key->co); dist_1st *= 0.75f * pset->emitterdist; } @@ -926,8 +926,8 @@ static void pe_deflect_emitter(Scene *scene, Object *ob, PTCacheEdit *edit) dot=dot_v3v3(dvec,nor); copy_v3_v3(dvec,nor); - if(dot>0.0f) { - if(dot0.0f) { + if (dotco, dvec); @@ -938,7 +938,7 @@ static void pe_deflect_emitter(Scene *scene, Object *ob, PTCacheEdit *edit) mul_v3_fl(dvec,dist_1st-dot); add_v3_v3(key->co, dvec); } - if(k==1) + if (k==1) dist_1st*=1.3333f; } } @@ -958,15 +958,15 @@ static void PE_apply_lengths(Scene *scene, PTCacheEdit *edit) POINT_P; KEY_K; float dv1[3]; - if(edit==0 || (pset->flag & PE_KEEP_LENGTHS)==0) + if (edit==0 || (pset->flag & PE_KEEP_LENGTHS)==0) return; - if(edit->psys && edit->psys->flag & PSYS_GLOBAL_HAIR) + if (edit->psys && edit->psys->flag & PSYS_GLOBAL_HAIR) return; LOOP_EDITED_POINTS { LOOP_KEYS { - if(k) { + if (k) { sub_v3_v3v3(dv1, key->co, (key - 1)->co); normalize_v3(dv1); mul_v3_fl(dv1, (key - 1)->length); @@ -987,17 +987,17 @@ static void pe_iterate_lengths(Scene *scene, PTCacheEdit *edit) float dv1[3]= {0.0f, 0.0f, 0.0f}; float dv2[3]= {0.0f, 0.0f, 0.0f}; - if(edit==0 || (pset->flag & PE_KEEP_LENGTHS)==0) + if (edit==0 || (pset->flag & PE_KEEP_LENGTHS)==0) return; - if(edit->psys && edit->psys->flag & PSYS_GLOBAL_HAIR) + if (edit->psys && edit->psys->flag & PSYS_GLOBAL_HAIR) return; LOOP_EDITED_POINTS { - for(j=1; jtotkey; j++) { + for (j=1; jtotkey; j++) { float mul= 1.0f / (float)point->totkey; - if(pset->flag & PE_LOCK_FIRST) { + if (pset->flag & PE_LOCK_FIRST) { key= point->keys + 1; k= 1; dv1[0]= dv1[1]= dv1[2]= 0.0; @@ -1008,20 +1008,20 @@ static void pe_iterate_lengths(Scene *scene, PTCacheEdit *edit) dv0[0]= dv0[1]= dv0[2]= 0.0; } - for(; ktotkey; k++, key++) { - if(k) { + for (; ktotkey; k++, key++) { + if (k) { sub_v3_v3v3(dv0, (key - 1)->co, key->co); tlen= normalize_v3(dv0); mul_v3_fl(dv0, (mul * (tlen - (key - 1)->length))); } - if(k < point->totkey - 1) { + if (k < point->totkey - 1) { sub_v3_v3v3(dv2, (key + 1)->co, key->co); tlen= normalize_v3(dv2); mul_v3_fl(dv2, mul * (tlen - key->length)); } - if(k) { + if (k) { add_v3_v3((key-1)->co, dv1); } @@ -1035,12 +1035,12 @@ static void recalc_lengths(PTCacheEdit *edit) { POINT_P; KEY_K; - if(edit==0) + if (edit==0) return; LOOP_EDITED_POINTS { key= point->keys; - for(k=0; ktotkey-1; k++, key++) { + for (k=0; ktotkey-1; k++, key++) { key->length= len_v3v3(key->co, (key + 1)->co); } } @@ -1054,10 +1054,10 @@ static void recalc_emitter_field(Object *ob, ParticleSystem *psys) float *vec, *nor; int i, totface /*, totvert*/; - if(!dm) + if (!dm) return; - if(edit->emitter_cosnos) + if (edit->emitter_cosnos) MEM_freeN(edit->emitter_cosnos); BLI_kdtree_free(edit->emitter_field); @@ -1072,7 +1072,7 @@ static void recalc_emitter_field(Object *ob, ParticleSystem *psys) vec=edit->emitter_cosnos; nor=vec+3; - for(i=0; igetTessFaceData(dm,i,CD_MFACE); MVert *mvert; @@ -1088,7 +1088,7 @@ static void recalc_emitter_field(Object *ob, ParticleSystem *psys) add_v3_v3v3(vec,vec,mvert->co); VECADD(nor,nor,mvert->no); - if(mface->v4) { + if (mface->v4) { mvert=dm->getVertData(dm,mface->v4,CD_MVERT); add_v3_v3v3(vec,vec,mvert->co); VECADD(nor,nor,mvert->no); @@ -1113,13 +1113,13 @@ static void PE_update_selection(Scene *scene, Object *ob, int useflag) POINT_P; KEY_K; /* flag all particles to be updated if not using flag */ - if(!useflag) + if (!useflag) LOOP_POINTS point->flag |= PEP_EDIT_RECALC; /* flush edit key flag to hair key flag to preserve selection * on save */ - if(edit->psys) LOOP_POINTS { + if (edit->psys) LOOP_POINTS { hkey = edit->psys->particles[p].hair; LOOP_KEYS { hkey->editflag= key->flag; @@ -1142,16 +1142,16 @@ static void update_world_cos(Object *ob, PTCacheEdit *edit) POINT_P; KEY_K; float hairmat[4][4]; - if(psys==0 || psys->edit==0 || psmd->dm==NULL) + if (psys==0 || psys->edit==0 || psmd->dm==NULL) return; LOOP_POINTS { - if(!(psys->flag & PSYS_GLOBAL_HAIR)) + if (!(psys->flag & PSYS_GLOBAL_HAIR)) psys_mat_hair_to_global(ob, psmd->dm, psys->part->from, psys->particles+p, hairmat); LOOP_KEYS { copy_v3_v3(key->world_co,key->co); - if(!(psys->flag & PSYS_GLOBAL_HAIR)) + if (!(psys->flag & PSYS_GLOBAL_HAIR)) mul_m4_v3(hairmat, key->world_co); } } @@ -1163,37 +1163,37 @@ static void update_velocities(PTCacheEdit *edit) POINT_P; KEY_K; /* hair doesn't use velocities */ - if(edit->psys || !edit->points || !edit->points->keys->vel) + if (edit->psys || !edit->points || !edit->points->keys->vel) return; frs_sec = edit->pid.flag & PTCACHE_VEL_PER_SEC ? 25.0f : 1.0f; LOOP_EDITED_POINTS { LOOP_KEYS { - if(k==0) { + if (k==0) { dfra = *(key+1)->time - *key->time; - if(dfra <= 0.0f) + if (dfra <= 0.0f) continue; sub_v3_v3v3(key->vel, (key+1)->co, key->co); - if(point->totkey>2) { + if (point->totkey>2) { sub_v3_v3v3(vec1, (key+1)->co, (key+2)->co); project_v3_v3v3(vec2, vec1, key->vel); sub_v3_v3v3(vec2, vec1, vec2); madd_v3_v3fl(key->vel, vec2, 0.5f); } } - else if(k==point->totkey-1) { + else if (k==point->totkey-1) { dfra = *key->time - *(key-1)->time; - if(dfra <= 0.0f) + if (dfra <= 0.0f) continue; sub_v3_v3v3(key->vel, key->co, (key-1)->co); - if(point->totkey>2) { + if (point->totkey>2) { sub_v3_v3v3(vec1, (key-2)->co, (key-1)->co); project_v3_v3v3(vec2, vec1, key->vel); sub_v3_v3v3(vec2, vec1, vec2); @@ -1203,7 +1203,7 @@ static void update_velocities(PTCacheEdit *edit) else { dfra = *(key+1)->time - *(key-1)->time; - if(dfra <= 0.0f) + if (dfra <= 0.0f) continue; sub_v3_v3v3(key->vel, (key+1)->co, (key-1)->co); @@ -1221,11 +1221,11 @@ void PE_update_object(Scene *scene, Object *ob, int useflag) PTCacheEdit *edit = PE_get_current(scene, ob); POINT_P; - if(!edit) + if (!edit) return; /* flag all particles to be updated if not using flag */ - if(!useflag) + if (!useflag) LOOP_POINTS { point->flag |= PEP_EDIT_RECALC; } @@ -1234,11 +1234,11 @@ void PE_update_object(Scene *scene, Object *ob, int useflag) pe_iterate_lengths(scene, edit); pe_deflect_emitter(scene, ob, edit); PE_apply_lengths(scene, edit); - if(pe_x_mirror(ob)) + if (pe_x_mirror(ob)) PE_apply_mirror(ob,edit->psys); - if(edit->psys) + if (edit->psys) update_world_cos(ob, edit); - if(pset->flag & PE_AUTO_VELOCITY) + if (pset->flag & PE_AUTO_VELOCITY) update_velocities(edit); PE_hide_keys_time(scene, edit, CFRA); @@ -1250,7 +1250,7 @@ void PE_update_object(Scene *scene, Object *ob, int useflag) point->flag &= ~PEP_EDIT_RECALC; } - if(edit->psys) + if (edit->psys) edit->psys->flag &= ~PSYS_HAIR_UPDATED; } @@ -1266,7 +1266,7 @@ static void select_key(PEData *data, int point_index, int key_index) PTCacheEditPoint *point = edit->points + point_index; PTCacheEditKey *key = point->keys + key_index; - if(data->select) + if (data->select) key->flag |= PEK_SELECT; else key->flag &= ~PEK_SELECT; @@ -1281,7 +1281,7 @@ static void select_keys(PEData *data, int point_index, int UNUSED(key_index)) KEY_K; LOOP_KEYS { - if(data->select) + if (data->select) key->flag |= PEK_SELECT; else key->flag &= ~PEK_SELECT; @@ -1342,7 +1342,8 @@ static int pe_select_all_exec(bContext *C, wmOperator *op) if ((key->flag & PEK_SELECT) == 0) { key->flag |= PEK_SELECT; point->flag |= PEP_EDIT_RECALC; - } else { + } + else { key->flag &= ~PEK_SELECT; point->flag |= PEP_EDIT_RECALC; } @@ -1383,10 +1384,10 @@ int PE_mouse_particles(bContext *C, const int mval[2], int extend) PTCacheEdit *edit= PE_get_current(scene, ob); POINT_P; KEY_K; - if(!PE_start_edit(edit)) + if (!PE_start_edit(edit)) return OPERATOR_CANCELLED; - if(!extend) { + if (!extend) { LOOP_VISIBLE_POINTS { LOOP_SELECTED_KEYS { key->flag &= ~PEK_SELECT; @@ -1554,7 +1555,7 @@ int PE_border_select(bContext *C, rcti *rect, int select, int extend) PTCacheEdit *edit= PE_get_current(scene, ob); PEData data; - if(!PE_start_edit(edit)) + if (!PE_start_edit(edit)) return OPERATOR_CANCELLED; if (extend == 0 && select) @@ -1581,7 +1582,7 @@ int PE_circle_select(bContext *C, int selecting, const int mval[2], float rad) PTCacheEdit *edit= PE_get_current(scene, ob); PEData data; - if(!PE_start_edit(edit)) + if (!PE_start_edit(edit)) return OPERATOR_FINISHED; PE_set_view3d_data(C, &data); @@ -1614,7 +1615,7 @@ int PE_lasso_select(bContext *C, int mcords[][2], short moves, short extend, sho PEData data; - if(!PE_start_edit(edit)) + if (!PE_start_edit(edit)) return OPERATOR_CANCELLED; if (extend == 0 && select) @@ -1624,38 +1625,38 @@ int PE_lasso_select(bContext *C, int mcords[][2], short moves, short extend, sho PE_set_view3d_data(C, &data); LOOP_VISIBLE_POINTS { - if(edit->psys && !(psys->flag & PSYS_GLOBAL_HAIR)) + if (edit->psys && !(psys->flag & PSYS_GLOBAL_HAIR)) psys_mat_hair_to_global(ob, psmd->dm, psys->part->from, psys->particles + p, mat); - if(pset->selectmode==SCE_SELECT_POINT) { + if (pset->selectmode==SCE_SELECT_POINT) { LOOP_KEYS { copy_v3_v3(co, key->co); mul_m4_v3(mat, co); project_int(ar, co, vertco); - if((vertco[0] != IS_CLIPPED) && lasso_inside(mcords,moves,vertco[0],vertco[1]) && key_test_depth(&data, co)) { - if(select && !(key->flag & PEK_SELECT)) { + if ((vertco[0] != IS_CLIPPED) && lasso_inside(mcords,moves,vertco[0],vertco[1]) && key_test_depth(&data, co)) { + if (select && !(key->flag & PEK_SELECT)) { key->flag |= PEK_SELECT; point->flag |= PEP_EDIT_RECALC; } - else if(key->flag & PEK_SELECT) { + else if (key->flag & PEK_SELECT) { key->flag &= ~PEK_SELECT; point->flag |= PEP_EDIT_RECALC; } } } } - else if(pset->selectmode==SCE_SELECT_END) { + else if (pset->selectmode==SCE_SELECT_END) { key= point->keys + point->totkey - 1; copy_v3_v3(co, key->co); mul_m4_v3(mat, co); project_int(ar, co,vertco); - if((vertco[0] != IS_CLIPPED) && lasso_inside(mcords,moves,vertco[0],vertco[1]) && key_test_depth(&data, co)) { - if(select && !(key->flag & PEK_SELECT)) { + if ((vertco[0] != IS_CLIPPED) && lasso_inside(mcords,moves,vertco[0],vertco[1]) && key_test_depth(&data, co)) { + if (select && !(key->flag & PEK_SELECT)) { key->flag |= PEK_SELECT; point->flag |= PEP_EDIT_RECALC; } - else if(key->flag & PEK_SELECT) { + else if (key->flag & PEK_SELECT) { key->flag &= ~PEK_SELECT; point->flag |= PEP_EDIT_RECALC; } @@ -1678,7 +1679,7 @@ static int hide_exec(bContext *C, wmOperator *op) PTCacheEdit *edit= PE_get_current(scene, ob); POINT_P; KEY_K; - if(RNA_enum_get(op->ptr, "unselected")) { + if (RNA_enum_get(op->ptr, "unselected")) { LOOP_UNSELECTED_POINTS { point->flag |= PEP_HIDE; point->flag |= PEP_EDIT_RECALC; @@ -1730,7 +1731,7 @@ static int reveal_exec(bContext *C, wmOperator *UNUSED(op)) POINT_P; KEY_K; LOOP_POINTS { - if(point->flag & PEP_HIDE) { + if (point->flag & PEP_HIDE) { point->flag &= ~PEP_HIDE; point->flag |= PEP_EDIT_RECALC; @@ -1768,22 +1769,22 @@ static void select_less_keys(PEData *data, int point_index) KEY_K; LOOP_SELECTED_KEYS { - if(k==0) { - if(((key+1)->flag&PEK_SELECT)==0) + if (k==0) { + if (((key+1)->flag&PEK_SELECT)==0) key->flag |= PEK_TAG; } - else if(k==point->totkey-1) { - if(((key-1)->flag&PEK_SELECT)==0) + else if (k==point->totkey-1) { + if (((key-1)->flag&PEK_SELECT)==0) key->flag |= PEK_TAG; } else { - if((((key-1)->flag & (key+1)->flag) & PEK_SELECT)==0) + if ((((key-1)->flag & (key+1)->flag) & PEK_SELECT)==0) key->flag |= PEK_TAG; } } LOOP_KEYS { - if(key->flag&PEK_TAG) { + if (key->flag&PEK_TAG) { key->flag &= ~(PEK_TAG|PEK_SELECT); point->flag |= PEP_EDIT_RECALC; /* redraw selection only */ } @@ -1826,24 +1827,24 @@ static void select_more_keys(PEData *data, int point_index) KEY_K; LOOP_KEYS { - if(key->flag & PEK_SELECT) continue; + if (key->flag & PEK_SELECT) continue; - if(k==0) { - if((key+1)->flag&PEK_SELECT) + if (k==0) { + if ((key+1)->flag&PEK_SELECT) key->flag |= PEK_TAG; } - else if(k==point->totkey-1) { - if((key-1)->flag&PEK_SELECT) + else if (k==point->totkey-1) { + if ((key-1)->flag&PEK_SELECT) key->flag |= PEK_TAG; } else { - if(((key-1)->flag | (key+1)->flag) & PEK_SELECT) + if (((key-1)->flag | (key+1)->flag) & PEK_SELECT) key->flag |= PEK_TAG; } } LOOP_KEYS { - if(key->flag&PEK_TAG) { + if (key->flag&PEK_TAG) { key->flag &= ~PEK_TAG; key->flag |= PEK_SELECT; point->flag |= PEP_EDIT_RECALC; /* redraw selection only */ @@ -1911,7 +1912,7 @@ static void rekey_particle(PEData *data, int pa_index) dval= (end - sta) / (float)(data->totrekey - 1); /* interpolate new keys from old ones */ - for(k=1,key++; ktotrekey-1; k++,key++) { + for (k=1,key++; ktotrekey-1; k++,key++) { state.time= (float)k / (float)(data->totrekey-1); psys_get_particle_on_path(&sim, pa_index, &state, 0); copy_v3_v3(key->co, state.co); @@ -1919,22 +1920,22 @@ static void rekey_particle(PEData *data, int pa_index) } /* replace keys */ - if(pa->hair) + if (pa->hair) MEM_freeN(pa->hair); pa->hair= new_keys; point->totkey=pa->totkey=data->totrekey; - if(point->keys) + if (point->keys) MEM_freeN(point->keys); ekey= point->keys= MEM_callocN(pa->totkey * sizeof(PTCacheEditKey),"Hair re-key edit keys"); - for(k=0, key=pa->hair; ktotkey; k++, key++, ekey++) { + for (k=0, key=pa->hair; ktotkey; k++, key++, ekey++) { ekey->co= key->co; ekey->time= &key->time; ekey->flag |= PEK_SELECT; - if(!(psys->flag & PSYS_GLOBAL_HAIR)) + if (!(psys->flag & PSYS_GLOBAL_HAIR)) ekey->flag |= PEK_USE_WCO; } @@ -1989,7 +1990,7 @@ static void rekey_particle_to_time(Scene *scene, Object *ob, int pa_index, float PTCacheEditKey *ekey; int k; - if(!edit || !edit->psys) return; + if (!edit || !edit->psys) return; psys = edit->psys; @@ -2004,19 +2005,19 @@ static void rekey_particle_to_time(Scene *scene, Object *ob, int pa_index, float key= new_keys= MEM_dupallocN(pa->hair); /* interpolate new keys from old ones (roots stay the same) */ - for(k=1, key++; k < pa->totkey; k++, key++) { + for (k=1, key++; k < pa->totkey; k++, key++) { state.time= path_time * (float)k / (float)(pa->totkey-1); psys_get_particle_on_path(&sim, pa_index, &state, 0); copy_v3_v3(key->co, state.co); } /* replace hair keys */ - if(pa->hair) + if (pa->hair) MEM_freeN(pa->hair); pa->hair= new_keys; /* update edit pointers */ - for(k=0, key=pa->hair, ekey=edit->points[pa_index].keys; ktotkey; k++, key++, ekey++) { + for (k=0, key=pa->hair, ekey=edit->points[pa_index].keys; ktotkey; k++, key++, ekey++) { ekey->co= key->co; ekey->time= &key->time; } @@ -2035,7 +2036,7 @@ static int remove_tagged_particles(Object *ob, ParticleSystem *psys, int mirror) ParticleSystemModifierData *psmd; int i, new_totpart= psys->totpart, removed= 0; - if(mirror) { + if (mirror) { /* mirror tags */ psmd= psys_get_modifier(ob, psys); @@ -2049,16 +2050,16 @@ static int remove_tagged_particles(Object *ob, ParticleSystem *psys, int mirror) removed++; } - if(new_totpart != psys->totpart) { - if(new_totpart) { + if (new_totpart != psys->totpart) { + if (new_totpart) { npa= new_pars= MEM_callocN(new_totpart * sizeof(ParticleData), "ParticleData array"); npoint= new_points= MEM_callocN(new_totpart * sizeof(PTCacheEditPoint), "PTCacheEditKey array"); - if(ELEM(NULL, new_pars, new_points)) { + if (ELEM(NULL, new_pars, new_points)) { /* allocation error! */ - if(new_pars) + if (new_pars) MEM_freeN(new_pars); - if(new_points) + if (new_points) MEM_freeN(new_points); return 0; } @@ -2066,11 +2067,11 @@ static int remove_tagged_particles(Object *ob, ParticleSystem *psys, int mirror) pa= psys->particles; point= edit->points; - for(i=0; itotpart; i++, pa++, point++) { - if(point->flag & PEP_TAG) { - if(point->keys) + for (i=0; itotpart; i++, pa++, point++) { + if (point->flag & PEP_TAG) { + if (point->keys) MEM_freeN(point->keys); - if(pa->hair) + if (pa->hair) MEM_freeN(pa->hair); } else { @@ -2081,18 +2082,18 @@ static int remove_tagged_particles(Object *ob, ParticleSystem *psys, int mirror) } } - if(psys->particles) MEM_freeN(psys->particles); + if (psys->particles) MEM_freeN(psys->particles); psys->particles= new_pars; - if(edit->points) MEM_freeN(edit->points); + if (edit->points) MEM_freeN(edit->points); edit->points= new_points; - if(edit->mirror_cache) { + if (edit->mirror_cache) { MEM_freeN(edit->mirror_cache); edit->mirror_cache= NULL; } - if(psys->child) { + if (psys->child) { MEM_freeN(psys->child); psys->child= NULL; psys->totchild=0; @@ -2114,7 +2115,7 @@ static void remove_tagged_keys(Object *ob, ParticleSystem *psys) ParticleSystemModifierData *psmd; short new_totkey; - if(pe_x_mirror(ob)) { + if (pe_x_mirror(ob)) { /* mirror key tags */ psmd= psys_get_modifier(ob, psys); @@ -2132,7 +2133,7 @@ static void remove_tagged_keys(Object *ob, ParticleSystem *psys) new_totkey--; } /* we can't have elements with less than two keys*/ - if(new_totkey < 2) + if (new_totkey < 2) point->flag |= PEP_TAG; } remove_tagged_particles(ob, psys, pe_x_mirror(ob)); @@ -2145,7 +2146,7 @@ static void remove_tagged_keys(Object *ob, ParticleSystem *psys) new_totkey--; } - if(new_totkey != pa->totkey) { + if (new_totkey != pa->totkey) { nhkey= new_hkeys= MEM_callocN(new_totkey*sizeof(HairKey), "HairKeys"); nkey= new_keys= MEM_callocN(new_totkey*sizeof(PTCacheEditKey), "particle edit keys"); @@ -2156,7 +2157,7 @@ static void remove_tagged_keys(Object *ob, ParticleSystem *psys) hkey++; } - if(hkey < pa->hair + pa->totkey) { + if (hkey < pa->hair + pa->totkey) { copy_v3_v3(nhkey->co, hkey->co); nhkey->editflag = hkey->editflag; nhkey->time= hkey->time; @@ -2175,10 +2176,10 @@ static void remove_tagged_keys(Object *ob, ParticleSystem *psys) hkey++; } - if(pa->hair) + if (pa->hair) MEM_freeN(pa->hair); - if(point->keys) + if (point->keys) MEM_freeN(point->keys); pa->hair= new_hkeys; @@ -2214,12 +2215,12 @@ static void subdivide_particle(PEData *data, int pa_index) sim.ob= data->ob; sim.psys= edit->psys; - for(k=0, ekey=point->keys; ktotkey-1; k++,ekey++) { - if(ekey->flag&PEK_SELECT && (ekey+1)->flag&PEK_SELECT) + for (k=0, ekey=point->keys; ktotkey-1; k++,ekey++) { + if (ekey->flag&PEK_SELECT && (ekey+1)->flag&PEK_SELECT) totnewkey++; } - if(totnewkey==0) return; + if (totnewkey==0) return; pa->flag |= PARS_REKEY; @@ -2229,7 +2230,7 @@ static void subdivide_particle(PEData *data, int pa_index) key = pa->hair; endtime= key[pa->totkey-1].time; - for(k=0, ekey=point->keys; ktotkey-1; k++, key++, ekey++) { + for (k=0, ekey=point->keys; ktotkey-1; k++, key++, ekey++) { memcpy(nkey,key,sizeof(HairKey)); memcpy(nekey,ekey,sizeof(PTCacheEditKey)); @@ -2240,7 +2241,7 @@ static void subdivide_particle(PEData *data, int pa_index) nkey++; nekey++; - if(ekey->flag & PEK_SELECT && (ekey+1)->flag & PEK_SELECT) { + if (ekey->flag & PEK_SELECT && (ekey+1)->flag & PEK_SELECT) { nkey->time= (key->time + (key+1)->time)*0.5f; state.time= (endtime != 0.0f)? nkey->time/endtime: 0.0f; psys_get_particle_on_path(&sim, pa_index, &state, 0); @@ -2249,7 +2250,7 @@ static void subdivide_particle(PEData *data, int pa_index) nekey->co= nkey->co; nekey->time= &nkey->time; nekey->flag |= PEK_SELECT; - if(!(psys->flag & PSYS_GLOBAL_HAIR)) + if (!(psys->flag & PSYS_GLOBAL_HAIR)) nekey->flag |= PEK_USE_WCO; nekey++; @@ -2263,11 +2264,11 @@ static void subdivide_particle(PEData *data, int pa_index) nekey->co= nkey->co; nekey->time= &nkey->time; - if(pa->hair) + if (pa->hair) MEM_freeN(pa->hair); pa->hair= new_keys; - if(point->keys) + if (point->keys) MEM_freeN(point->keys); point->keys= new_ekeys; @@ -2319,7 +2320,7 @@ static int remove_doubles_exec(bContext *C, wmOperator *op) float mat[4][4], co[3], threshold= RNA_float_get(op->ptr, "threshold"); int n, totn, removed, totremoved; - if(psys->flag & PSYS_GLOBAL_HAIR) + if (psys->flag & PSYS_GLOBAL_HAIR) return OPERATOR_CANCELLED; edit= psys->edit; @@ -2349,10 +2350,10 @@ static int remove_doubles_exec(bContext *C, wmOperator *op) totn= BLI_kdtree_find_n_nearest(tree,10,co,NULL,nearest); - for(n=0; n p && nearest[n].dist < threshold) { - if(!(point->flag & PEP_TAG)) { + if (nearest[n].index > p && nearest[n].dist < threshold) { + if (!(point->flag & PEP_TAG)) { point->flag |= PEP_TAG; removed++; } @@ -2367,7 +2368,7 @@ static int remove_doubles_exec(bContext *C, wmOperator *op) totremoved += removed; } while(removed); - if(totremoved == 0) + if (totremoved == 0) return OPERATOR_CANCELLED; BKE_reportf(op->reports, RPT_INFO, "Remove %d double particles", totremoved); @@ -2451,12 +2452,12 @@ static void brush_drawcursor(bContext *C, int x, int y, void *UNUSED(customdata) ParticleEditSettings *pset= PE_settings(CTX_data_scene(C)); ParticleBrushData *brush; - if(pset->brushtype < 0) + if (pset->brushtype < 0) return; brush= &pset->brush[pset->brushtype]; - if(brush) { + if (brush) { glPushMatrix(); glTranslatef((float)x, (float)y, 0.0f); @@ -2476,11 +2477,11 @@ static void toggle_particle_cursor(bContext *C, int enable) { ParticleEditSettings *pset= PE_settings(CTX_data_scene(C)); - if(pset->paintcursor && !enable) { + if (pset->paintcursor && !enable) { WM_paint_cursor_end(CTX_wm_manager(C), pset->paintcursor); pset->paintcursor = NULL; } - else if(enable) + else if (enable) pset->paintcursor= WM_paint_cursor_activate(CTX_wm_manager(C), PE_poll_view3d, brush_drawcursor, NULL); } @@ -2514,12 +2515,12 @@ static int delete_exec(bContext *C, wmOperator *op) PE_set_data(C, &data); - if(type == DEL_KEY) { + if (type == DEL_KEY) { foreach_selected_key(&data, set_delete_particle_key); remove_tagged_keys(data.ob, data.edit->psys); recalc_lengths(data.edit); } - else if(type == DEL_PARTICLE) { + else if (type == DEL_PARTICLE) { foreach_selected_point(&data, set_delete_particle); remove_tagged_particles(data.ob, data.edit->psys, pe_x_mirror(data.ob)); recalc_lengths(data.edit); @@ -2564,25 +2565,25 @@ static void PE_mirror_x(Scene *scene, Object *ob, int tagged) int *mirrorfaces = NULL; int rotation, totpart, newtotpart; - if(psys->flag & PSYS_GLOBAL_HAIR) + if (psys->flag & PSYS_GLOBAL_HAIR) return; psmd= psys_get_modifier(ob, psys); - if(!psmd->dm) + if (!psmd->dm) return; mirrorfaces= mesh_get_x_mirror_faces(ob, NULL); - if(!edit->mirror_cache) + if (!edit->mirror_cache) PE_update_mirror_cache(ob, psys); totpart= psys->totpart; newtotpart= psys->totpart; LOOP_VISIBLE_POINTS { pa = psys->particles + p; - if(!tagged) { - if(point_is_selected(point)) { - if(edit->mirror_cache[p] != -1) { + if (!tagged) { + if (point_is_selected(point)) { + if (edit->mirror_cache[p] != -1) { /* already has a mirror, don't need to duplicate */ PE_mirror_particle(ob, psmd->dm, psys, pa, NULL); continue; @@ -2592,28 +2593,28 @@ static void PE_mirror_x(Scene *scene, Object *ob, int tagged) } } - if((point->flag & PEP_TAG) && mirrorfaces[pa->num*2] != -1) + if ((point->flag & PEP_TAG) && mirrorfaces[pa->num*2] != -1) newtotpart++; } - if(newtotpart != psys->totpart) { + if (newtotpart != psys->totpart) { /* allocate new arrays and copy existing */ new_pars= MEM_callocN(newtotpart*sizeof(ParticleData), "ParticleData new"); new_points= MEM_callocN(newtotpart*sizeof(PTCacheEditPoint), "PTCacheEditPoint new"); - if(psys->particles) { + if (psys->particles) { memcpy(new_pars, psys->particles, totpart*sizeof(ParticleData)); MEM_freeN(psys->particles); } psys->particles= new_pars; - if(edit->points) { + if (edit->points) { memcpy(new_points, edit->points, totpart*sizeof(PTCacheEditPoint)); MEM_freeN(edit->points); } edit->points= new_points; - if(edit->mirror_cache) { + if (edit->mirror_cache) { MEM_freeN(edit->mirror_cache); edit->mirror_cache= NULL; } @@ -2624,19 +2625,19 @@ static void PE_mirror_x(Scene *scene, Object *ob, int tagged) newpa= psys->particles + totpart; newpoint= edit->points + totpart; - for(p=0, point=edit->points; ppoints; pparticles + p; - if(point->flag & PEP_HIDE) + if (point->flag & PEP_HIDE) continue; - if(!(point->flag & PEP_TAG) || mirrorfaces[pa->num*2] == -1) + if (!(point->flag & PEP_TAG) || mirrorfaces[pa->num*2] == -1) continue; /* duplicate */ *newpa= *pa; *newpoint= *point; - if(pa->hair) newpa->hair= MEM_dupallocN(pa->hair); - if(point->keys) newpoint->keys= MEM_dupallocN(point->keys); + if (pa->hair) newpa->hair= MEM_dupallocN(pa->hair); + if (point->keys) newpoint->keys= MEM_dupallocN(point->keys); /* rotate weights according to vertex index rotation */ rotation= mirrorfaces[pa->num*2+1]; @@ -2658,7 +2659,7 @@ static void PE_mirror_x(Scene *scene, Object *ob, int tagged) /* update edit key pointers */ key= newpoint->keys; - for(k=0, hkey=newpa->hair; ktotkey; k++, hkey++, key++) { + for (k=0, hkey=newpa->hair; ktotkey; k++, hkey++, key++) { key->co= hkey->co; key->time= &hkey->time; } @@ -2714,7 +2715,7 @@ static void brush_comb(PEData *data, float UNUSED(mat[][4]), float imat[][4], in ParticleEditSettings *pset= PE_settings(data->scene); float cvec[3], fac; - if(pset->flag & PE_LOCK_FIRST && key_index == 0) return; + if (pset->flag & PE_LOCK_FIRST && key_index == 0) return; fac= (float)pow((double)(1.0f - data->dist / data->rad), (double)data->combfac); @@ -2739,10 +2740,10 @@ static void brush_cut(PEData *data, int pa_index) int vertco[2]; /* blunt scissors */ - if(BLI_frand() > data->cutfac) return; + if (BLI_frand() > data->cutfac) return; /* don't cut hidden */ - if(edit->points[pa_index].flag & PEP_HIDE) + if (edit->points[pa_index].flag & PEP_HIDE) return; rad2= data->rad * data->rad; @@ -2760,16 +2761,16 @@ static void brush_cut(PEData *data, int pa_index) xo1= x1 - o1; /* check if root is inside circle */ - if(xo0*xo0 + xo1*xo1 < rad2 && key_test_depth(data, key->co)) { + if (xo0*xo0 + xo1*xo1 < rad2 && key_test_depth(data, key->co)) { cut_time= -1.0f; cut= 1; } else { /* calculate path time closest to root that was inside the circle */ - for(k=1, key++; k<=keys; k++, key++) { + for (k=1, key++; k<=keys; k++, key++) { project_int_noclip(ar, key->co, vertco); - if(key_test_depth(data, key->co) == 0) { + if (key_test_depth(data, key->co) == 0) { x0= (float)vertco[0]; x1= (float)vertco[1]; @@ -2787,15 +2788,15 @@ static void brush_cut(PEData *data, int pa_index) d= dv * rad2 - d*d; - if(d > 0.0f) { + if (d > 0.0f) { d= sqrt(d); cut_time= -(v0*xo0 + v1*xo1 + d); - if(cut_time > 0.0f) { + if (cut_time > 0.0f) { cut_time /= dv; - if(cut_time < 1.0f) { + if (cut_time < 1.0f) { cut_time += (float)(k-1); cut_time /= (float)keys; cut= 1; @@ -2812,8 +2813,8 @@ static void brush_cut(PEData *data, int pa_index) } } - if(cut) { - if(cut_time < 0.0f) { + if (cut) { + if (cut_time < 0.0f) { edit->points[pa_index].flag |= PEP_TAG; } else { @@ -2831,7 +2832,7 @@ static void brush_length(PEData *data, int point_index) float dvec[3],pvec[3] = {0.0f, 0.0f, 0.0f}; LOOP_KEYS { - if(k==0) { + if (k==0) { copy_v3_v3(pvec,key->co); } else { @@ -2863,7 +2864,7 @@ static void brush_puff(PEData *data, int point_index) puff_volume = brush->flag & PE_BRUSH_DATA_PUFF_VOLUME; } - if(psys && !(psys->flag & PSYS_GLOBAL_HAIR)) { + if (psys && !(psys->flag & PSYS_GLOBAL_HAIR)) { psys_mat_hair_to_global(data->ob, data->dm, psys->part->from, psys->particles + point_index, mat); invert_m4_m4(imat,mat); } @@ -2873,14 +2874,14 @@ static void brush_puff(PEData *data, int point_index) } LOOP_KEYS { - if(k==0) { + if (k==0) { /* find root coordinate and normal on emitter */ copy_v3_v3(co, key->co); mul_m4_v3(mat, co); mul_v3_m4v3(kco, data->ob->imat, co); /* use 'kco' as the object space version of worldspace 'co', ob->imat is set before calling */ point_index= BLI_kdtree_find_nearest(edit->emitter_field, kco, NULL, NULL); - if(point_index == -1) return; + if (point_index == -1) return; copy_v3_v3(rootco, co); copy_v3_v3(nor, &edit->emitter_cosnos[point_index*6+3]); @@ -2891,7 +2892,7 @@ static void brush_puff(PEData *data, int point_index) fac= (float)pow((double)(1.0f - data->dist / data->rad), (double)data->pufffac); fac *= 0.025f; - if(data->invert) + if (data->invert) fac= -fac; } else { @@ -2901,7 +2902,7 @@ static void brush_puff(PEData *data, int point_index) copy_v3_v3(co, key->co); mul_m4_v3(mat, co); length += len_v3v3(lastco, co); - if((data->select==0 || (key->flag & PEK_SELECT)) && !(key->flag & PEK_HIDE)) { + if ((data->select==0 || (key->flag & PEK_SELECT)) && !(key->flag & PEK_HIDE)) { madd_v3_v3v3fl(kco, rootco, nor, length); /* blend between the current and straight position */ @@ -2913,7 +2914,7 @@ static void brush_puff(PEData *data, int point_index) mul_v3_m4v3(key->co, imat, co); - if(puff_volume) { + if (puff_volume) { /* accumulate the total distance moved to apply to unselected * keys that come after */ ofs[0] += key->co[0] - dco[0]; @@ -2924,13 +2925,13 @@ static void brush_puff(PEData *data, int point_index) } else { - if(puff_volume) { + if (puff_volume) { #if 0 /* this is simple but looks bad, adds annoying kinks */ add_v3_v3(key->co, ofs); #else /* translate (not rotate) the rest of the hair if its not selected */ - if(ofs[0] || ofs[1] || ofs[2]) { + if (ofs[0] || ofs[1] || ofs[2]) { #if 0 /* kindof works but looks worse then whats below */ /* Move the unselected point on a vector based on the @@ -2955,7 +2956,7 @@ static void brush_puff(PEData *data, int point_index) mul_v3_m4v3(kco, data->ob->imat, oco); /* use 'kco' as the object space version of worldspace 'co', ob->imat is set before calling */ point_index= BLI_kdtree_find_nearest(edit->emitter_field, kco, NULL, NULL); - if(point_index != -1) { + if (point_index != -1) { copy_v3_v3(onor, &edit->emitter_cosnos[point_index*6+3]); mul_mat3_m4_v3(data->ob->obmat, onor); /* normal into worldspace */ mul_mat3_m4_v3(imat, onor); /* worldspace into particle space */ @@ -2973,7 +2974,7 @@ static void brush_puff(PEData *data, int point_index) } } - if(change) + if (change) point->flag |= PEP_EDIT_RECALC; } @@ -2981,7 +2982,7 @@ static void brush_puff(PEData *data, int point_index) static void brush_weight(PEData *data, float UNUSED(mat[][4]), float UNUSED(imat[][4]), int point_index, int key_index, PTCacheEditKey *UNUSED(key)) { /* roots have full weight allways */ - if(key_index) { + if (key_index) { PTCacheEdit *edit = data->edit; ParticleSystem *psys = edit->psys; @@ -2994,7 +2995,7 @@ static void brush_weight(PEData *data, float UNUSED(mat[][4]), float UNUSED(imat static void brush_smooth_get(PEData *data, float mat[][4], float UNUSED(imat[][4]), int UNUSED(point_index), int key_index, PTCacheEditKey *key) { - if(key_index) { + if (key_index) { float dvec[3]; sub_v3_v3v3(dvec,key->co,(key-1)->co); @@ -3008,7 +3009,7 @@ static void brush_smooth_do(PEData *data, float UNUSED(mat[][4]), float imat[][4 { float vec[3], dvec[3]; - if(key_index) { + if (key_index) { copy_v3_v3(vec, data->vec); mul_mat3_m4_v3(imat,vec); @@ -3054,16 +3055,16 @@ static int particle_intersect_dm(Scene *scene, Object *ob, DerivedMesh *dm, float cur_d, cur_uv[2], v1[3], v2[3], v3[3], v4[3], min[3], max[3], p_min[3],p_max[3]; float cur_ipoint[3]; - if(dm == NULL){ + if (dm == NULL) { psys_disable_all(ob); dm=mesh_get_derived_final(scene, ob, 0); - if(dm == NULL) + if (dm == NULL) dm=mesh_get_derived_deform(scene, ob, 0); psys_enable_all(ob); - if(dm == NULL) + if (dm == NULL) return 0; } @@ -3071,12 +3072,12 @@ static int particle_intersect_dm(Scene *scene, Object *ob, DerivedMesh *dm, DM_ensure_tessface(dm); - if(pa_minmax==0){ + if (pa_minmax==0) { INIT_MINMAX(p_min,p_max); DO_MINMAX(co1,p_min,p_max); DO_MINMAX(co2,p_min,p_max); } - else{ + else { copy_v3_v3(p_min,pa_minmax); copy_v3_v3(p_max,pa_minmax+3); } @@ -3086,23 +3087,23 @@ static int particle_intersect_dm(Scene *scene, Object *ob, DerivedMesh *dm, mvert=dm->getVertDataArray(dm,CD_MVERT); /* lets intersect the faces */ - for(i=0; iv1); copy_v3_v3(v2,vert_cos+3*mface->v2); copy_v3_v3(v3,vert_cos+3*mface->v3); - if(mface->v4) + if (mface->v4) copy_v3_v3(v4,vert_cos+3*mface->v4); } - else{ + else { copy_v3_v3(v1,mvert[mface->v1].co); copy_v3_v3(v2,mvert[mface->v2].co); copy_v3_v3(v3,mvert[mface->v3].co); - if(mface->v4) + if (mface->v4) copy_v3_v3(v4,mvert[mface->v4].co); } - if(face_minmax==0){ + if (face_minmax==0) { INIT_MINMAX(min,max); DO_MINMAX(v1,min,max); DO_MINMAX(v2,min,max); @@ -3112,25 +3113,25 @@ static int particle_intersect_dm(Scene *scene, Object *ob, DerivedMesh *dm, if (isect_aabb_aabb_v3(min,max,p_min,p_max)==0) continue; } - else{ + else { copy_v3_v3(min, face_minmax+6*i); copy_v3_v3(max, face_minmax+6*i+3); - if(isect_aabb_aabb_v3(min,max,p_min,p_max)==0) + if (isect_aabb_aabb_v3(min,max,p_min,p_max)==0) continue; } - if(radius>0.0f){ - if(isect_sweeping_sphere_tri_v3(co1, co2, radius, v2, v3, v1, &cur_d, cur_ipoint)){ - if(cur_d<*min_d){ + if (radius>0.0f) { + if (isect_sweeping_sphere_tri_v3(co1, co2, radius, v2, v3, v1, &cur_d, cur_ipoint)) { + if (cur_d<*min_d) { *min_d=cur_d; copy_v3_v3(ipoint,cur_ipoint); *min_face=i; intersect=1; } } - if(mface->v4){ - if(isect_sweeping_sphere_tri_v3(co1, co2, radius, v4, v1, v3, &cur_d, cur_ipoint)){ - if(cur_d<*min_d){ + if (mface->v4) { + if (isect_sweeping_sphere_tri_v3(co1, co2, radius, v4, v1, v3, &cur_d, cur_ipoint)) { + if (cur_d<*min_d) { *min_d=cur_d; copy_v3_v3(ipoint,cur_ipoint); *min_face=i; @@ -3139,23 +3140,23 @@ static int particle_intersect_dm(Scene *scene, Object *ob, DerivedMesh *dm, } } } - else{ - if(isect_line_tri_v3(co1, co2, v1, v2, v3, &cur_d, cur_uv)){ - if(cur_d<*min_d){ + else { + if (isect_line_tri_v3(co1, co2, v1, v2, v3, &cur_d, cur_uv)) { + if (cur_d<*min_d) { *min_d=cur_d; min_w[0]= 1.0f - cur_uv[0] - cur_uv[1]; min_w[1]= cur_uv[0]; min_w[2]= cur_uv[1]; min_w[3]= 0.0f; - if(mface->v4) + if (mface->v4) intersect_dm_quad_weights(v1, v2, v3, v4, min_w); *min_face=i; intersect=1; } } - if(mface->v4){ - if(isect_line_tri_v3(co1, co2, v1, v3, v4, &cur_d, cur_uv)){ - if(cur_d<*min_d){ + if (mface->v4) { + if (isect_line_tri_v3(co1, co2, v1, v3, v4, &cur_d, cur_uv)) { + if (cur_d<*min_d) { *min_d=cur_d; min_w[0]= 1.0f - cur_uv[0] - cur_uv[1]; min_w[1]= 0.0f; @@ -3192,7 +3193,7 @@ static int brush_add(PEData *data, short number) DerivedMesh *dm=0; invert_m4_m4(imat,ob->obmat); - if(psys->flag & PSYS_GLOBAL_HAIR) + if (psys->flag & PSYS_GLOBAL_HAIR) return 0; BLI_srandom(psys->seed+data->mval[0]+data->mval[1]); @@ -3205,13 +3206,13 @@ static int brush_add(PEData *data, short number) timestep= psys_get_timestep(&sim); /* painting onto the deformed mesh, could be an option? */ - if(psmd->dm->deformedOnly) + if (psmd->dm->deformedOnly) dm= psmd->dm; else dm= mesh_get_derived_deform(scene, ob, CD_MASK_BAREMESH); - for(i=0; i1) { + for (i=0; i1) { dmx=dmy=size; while(dmx*dmx+dmy*dmy>size2) { dmx=(short)((2.0f*BLI_frand()-1.0f)*size); @@ -3228,12 +3229,12 @@ static int brush_add(PEData *data, short number) min_d=2.0; /* warning, returns the derived mesh face */ - if(particle_intersect_dm(scene, ob,dm,0,co1,co2,&min_d,&add_pars[n].num,add_pars[n].fuv,0,0,0,0)) { + if (particle_intersect_dm(scene, ob,dm,0,co1,co2,&min_d,&add_pars[n].num,add_pars[n].fuv,0,0,0,0)) { add_pars[n].num_dmcache= psys_particle_dm_face_lookup(ob,psmd->dm,add_pars[n].num,add_pars[n].fuv,NULL); n++; } } - if(n) { + if (n) { int newtotpart=totpart+n; float hairmat[4][4], cur_co[3]; KDTree *tree=0; @@ -3247,22 +3248,22 @@ static int brush_add(PEData *data, short number) memcpy(new_points, edit->points, totpart * sizeof(PTCacheEditPoint)); /* change old arrays to new ones */ - if(psys->particles) MEM_freeN(psys->particles); + if (psys->particles) MEM_freeN(psys->particles); psys->particles= new_pars; - if(edit->points) MEM_freeN(edit->points); + if (edit->points) MEM_freeN(edit->points); edit->points= new_points; - if(edit->mirror_cache) { + if (edit->mirror_cache) { MEM_freeN(edit->mirror_cache); edit->mirror_cache= NULL; } /* create tree for interpolation */ - if(pset->flag & PE_INTERPOLATE_ADDED && psys->totpart) { + if (pset->flag & PE_INTERPOLATE_ADDED && psys->totpart) { tree=BLI_kdtree_new(psys->totpart); - for(i=0, pa=psys->particles; iparticles; idm,psys->part->from,pa->num,pa->num_dmcache,pa->fuv,pa->foffset,cur_co,0,0,0,0,0); BLI_kdtree_insert(tree, i, cur_co, NULL); } @@ -3276,17 +3277,17 @@ static int brush_add(PEData *data, short number) pa= psys->particles + totpart; point= edit->points + totpart; - for(i=totpart; ihair= MEM_callocN(pset->totaddkey * sizeof(HairKey), "BakeKey key add"); key= point->keys= MEM_callocN(pset->totaddkey * sizeof(PTCacheEditKey), "PTCacheEditKey add"); point->totkey= pa->totkey= pset->totaddkey; - for(k=0, hkey=pa->hair; ktotkey; k++, hkey++, key++) { + for (k=0, hkey=pa->hair; ktotkey; k++, hkey++, key++) { key->co= hkey->co; key->time= &hkey->time; - if(!(psys->flag & PSYS_GLOBAL_HAIR)) + if (!(psys->flag & PSYS_GLOBAL_HAIR)) key->flag |= PEK_USE_WCO; } @@ -3294,12 +3295,12 @@ static int brush_add(PEData *data, short number) initialize_particle(&sim, pa,i); reset_particle(&sim, pa, 0.0, 1.0); point->flag |= PEP_EDIT_RECALC; - if(pe_x_mirror(ob)) + if (pe_x_mirror(ob)) point->flag |= PEP_TAG; /* signal for duplicate */ framestep= pa->lifetime/(float)(pset->totaddkey-1); - if(tree) { + if (tree) { ParticleData *ppa; HairKey *thkey; ParticleKey key3[3]; @@ -3312,20 +3313,20 @@ static int brush_add(PEData *data, short number) maxd= ptn[maxw-1].dist; - for(w=0; wparticles+ptn[0].index; - for(k=0; ktotaddkey; k++) { + for (k=0; ktotaddkey; k++) { thkey= (HairKey*)pa->hair + k; thkey->time= pa->time + k * framestep; @@ -3336,13 +3337,13 @@ static int brush_add(PEData *data, short number) /* TODO: interpolatint the weight would be nicer */ thkey->weight= (ppa->hair+MIN2(k, ppa->totkey-1))->weight; - if(maxw>1) { + if (maxw>1) { key3[1].time= key3[0].time; psys_get_particle_on_path(&sim, ptn[1].index, &key3[1], 0); mul_v3_fl(key3[1].co, weight[1]); add_v3_v3(key3[0].co, key3[1].co); - if(maxw>2) { + if (maxw>2) { key3[2].time= key3[0].time; psys_get_particle_on_path(&sim, ptn[2].index, &key3[2], 0); mul_v3_fl(key3[2].co, weight[2]); @@ -3350,7 +3351,7 @@ static int brush_add(PEData *data, short number) } } - if(k==0) + if (k==0) sub_v3_v3v3(co1, pa->state.co, key3[0].co); add_v3_v3v3(thkey->co, key3[0].co, co1); @@ -3359,26 +3360,26 @@ static int brush_add(PEData *data, short number) } } else { - for(k=0, hkey=pa->hair; ktotaddkey; k++, hkey++) { + for (k=0, hkey=pa->hair; ktotaddkey; k++, hkey++) { madd_v3_v3v3fl(hkey->co, pa->state.co, pa->state.vel, k * framestep * timestep); hkey->time += k * framestep; hkey->weight = 1.f - (float)k/(float)(pset->totaddkey-1); } } - for(k=0, hkey=pa->hair; ktotaddkey; k++, hkey++) { + for (k=0, hkey=pa->hair; ktotaddkey; k++, hkey++) { psys_mat_hair_to_global(ob, psmd->dm, psys->part->from, pa, hairmat); invert_m4_m4(imat,hairmat); mul_m4_v3(imat, hkey->co); } } - if(tree) + if (tree) BLI_kdtree_free(tree); } - if(add_pars) + if (add_pars) MEM_freeN(add_pars); - if(!psmd->dm->deformedOnly) + if (!psmd->dm->deformedOnly) dm->release(dm); return n; @@ -3407,7 +3408,7 @@ static int brush_edit_init(bContext *C, wmOperator *op) ARegion *ar= CTX_wm_region(C); BrushEdit *bedit; - if(pset->brushtype < 0) + if (pset->brushtype < 0) return 0; initgrabz(ar->regiondata, ob->obmat[3][0], ob->obmat[3][1], ob->obmat[3][2]); @@ -3442,7 +3443,7 @@ static void brush_edit_apply(bContext *C, wmOperator *op, PointerRNA *itemptr) float dx, dy, dmax; int lock_root = pset->flag & PE_LOCK_FIRST; - if(!PE_start_edit(edit)) + if (!PE_start_edit(edit)) return; RNA_float_get_array(itemptr, "mouse", mousef); @@ -3450,7 +3451,7 @@ static void brush_edit_apply(bContext *C, wmOperator *op, PointerRNA *itemptr) mouse[1] = mousef[1]; flip= RNA_boolean_get(itemptr, "pen_flip"); - if(bedit->first) { + if (bedit->first) { bedit->lastmouse[0]= mouse[0]; bedit->lastmouse[1]= mouse[1]; } @@ -3463,10 +3464,10 @@ static void brush_edit_apply(bContext *C, wmOperator *op, PointerRNA *itemptr) /* disable locking temporatily for disconnected hair */ - if(edit->psys && edit->psys->flag & PSYS_GLOBAL_HAIR) + if (edit->psys && edit->psys->flag & PSYS_GLOBAL_HAIR) pset->flag &= ~PE_LOCK_FIRST; - if(((pset->brushtype == PE_BRUSH_ADD) ? + if (((pset->brushtype == PE_BRUSH_ADD) ? (sqrt(dx * dx + dy * dy) > pset->brush[PE_BRUSH_ADD].step) : (dx != 0 || dy != 0)) || bedit->first) { PEData data= bedit->data; @@ -3480,7 +3481,7 @@ static void brush_edit_apply(bContext *C, wmOperator *op, PointerRNA *itemptr) dx /= (float)tot_steps; dy /= (float)tot_steps; - for(step = 1; step<=tot_steps; step++) { + for (step = 1; step<=tot_steps; step++) { mval[0] = bedit->lastmouse[0] + step*dx; mval[1] = bedit->lastmouse[1] + step*dy; @@ -3492,7 +3493,7 @@ static void brush_edit_apply(bContext *C, wmOperator *op, PointerRNA *itemptr) data.rad= (float)brush->size; data.combfac= (brush->strength - 0.5f) * 2.0f; - if(data.combfac < 0.0f) + if (data.combfac < 0.0f) data.combfac= 1.0f - 9.0f * data.combfac; else data.combfac= 1.0f - data.combfac; @@ -3509,18 +3510,18 @@ static void brush_edit_apply(bContext *C, wmOperator *op, PointerRNA *itemptr) } case PE_BRUSH_CUT: { - if(edit->psys && edit->pathcache) { + if (edit->psys && edit->pathcache) { data.mval= mval; data.rad= (float)brush->size; data.cutfac= brush->strength; - if(selected) + if (selected) foreach_selected_point(&data, brush_cut); else foreach_point(&data, brush_cut); removed= remove_tagged_particles(ob, edit->psys, pe_x_mirror(ob)); - if(pset->flag & PE_KEEP_LENGTHS) + if (pset->flag & PE_KEEP_LENGTHS) recalc_lengths(edit); } else @@ -3535,27 +3536,27 @@ static void brush_edit_apply(bContext *C, wmOperator *op, PointerRNA *itemptr) data.rad= (float)brush->size; data.growfac= brush->strength / 50.0f; - if(brush->invert ^ flip) + if (brush->invert ^ flip) data.growfac= 1.0f - data.growfac; else data.growfac= 1.0f + data.growfac; foreach_mouse_hit_point(&data, brush_length, selected); - if(pset->flag & PE_KEEP_LENGTHS) + if (pset->flag & PE_KEEP_LENGTHS) recalc_lengths(edit); break; } case PE_BRUSH_PUFF: { - if(edit->psys) { + if (edit->psys) { data.dm= psmd->dm; data.mval= mval; data.rad= (float)brush->size; data.select= selected; data.pufffac= (brush->strength - 0.5f) * 2.0f; - if(data.pufffac < 0.0f) + if (data.pufffac < 0.0f) data.pufffac= 1.0f - 9.0f * data.pufffac; else data.pufffac= 1.0f - data.pufffac; @@ -3569,12 +3570,12 @@ static void brush_edit_apply(bContext *C, wmOperator *op, PointerRNA *itemptr) } case PE_BRUSH_ADD: { - if(edit->psys && edit->psys->part->from==PART_FROM_FACE) { + if (edit->psys && edit->psys->part->from==PART_FROM_FACE) { data.mval= mval; added= brush_add(&data, brush->count); - if(pset->flag & PE_KEEP_LENGTHS) + if (pset->flag & PE_KEEP_LENGTHS) recalc_lengths(edit); } else @@ -3595,7 +3596,7 @@ static void brush_edit_apply(bContext *C, wmOperator *op, PointerRNA *itemptr) foreach_mouse_hit_key(&data, brush_smooth_get, selected); - if(data.tot) { + if (data.tot) { mul_v3_fl(data.vec, 1.0f / (float)data.tot); foreach_mouse_hit_key(&data, brush_smooth_do, selected); } @@ -3604,7 +3605,7 @@ static void brush_edit_apply(bContext *C, wmOperator *op, PointerRNA *itemptr) } case PE_BRUSH_WEIGHT: { - if(edit->psys) { + if (edit->psys) { data.dm= psmd->dm; data.mval= mval; data.rad= (float)brush->size; @@ -3617,11 +3618,11 @@ static void brush_edit_apply(bContext *C, wmOperator *op, PointerRNA *itemptr) break; } } - if((pset->flag & PE_KEEP_LENGTHS)==0) + if ((pset->flag & PE_KEEP_LENGTHS)==0) recalc_lengths(edit); - if(ELEM(pset->brushtype, PE_BRUSH_ADD, PE_BRUSH_CUT) && (added || removed)) { - if(pset->brushtype == PE_BRUSH_ADD && pe_x_mirror(ob)) + if (ELEM(pset->brushtype, PE_BRUSH_ADD, PE_BRUSH_CUT) && (added || removed)) { + if (pset->brushtype == PE_BRUSH_ADD && pe_x_mirror(ob)) PE_mirror_x(scene, ob, 1); update_world_cos(ob,edit); @@ -3657,7 +3658,7 @@ static void brush_edit_exit(wmOperator *op) static int brush_edit_exec(bContext *C, wmOperator *op) { - if(!brush_edit_init(C, op)) + if (!brush_edit_init(C, op)) return OPERATOR_CANCELLED; RNA_BEGIN(op->ptr, itemptr, "stroke") { @@ -3689,7 +3690,7 @@ static void brush_edit_apply_event(bContext *C, wmOperator *op, wmEvent *event) static int brush_edit_invoke(bContext *C, wmOperator *op, wmEvent *event) { - if(!brush_edit_init(C, op)) + if (!brush_edit_init(C, op)) return OPERATOR_CANCELLED; brush_edit_apply_event(C, op, event); @@ -3749,16 +3750,16 @@ static void free_PTCacheUndo(PTCacheUndo *undo) PTCacheEditPoint *point; int i; - for(i=0, point=undo->points; itotpoint; i++, point++) { - if(undo->particles && (undo->particles + i)->hair) + for (i=0, point=undo->points; itotpoint; i++, point++) { + if (undo->particles && (undo->particles + i)->hair) MEM_freeN((undo->particles + i)->hair); - if(point->keys) + if (point->keys) MEM_freeN(point->keys); } - if(undo->points) + if (undo->points) MEM_freeN(undo->points); - if(undo->particles) + if (undo->particles) MEM_freeN(undo->particles); BKE_ptcache_free_mem(&undo->mem_cache); @@ -3771,12 +3772,12 @@ static void make_PTCacheUndo(PTCacheEdit *edit, PTCacheUndo *undo) undo->totpoint= edit->totpoint; - if(edit->psys) { + if (edit->psys) { ParticleData *pa; pa= undo->particles= MEM_dupallocN(edit->psys->particles); - for(i=0; itotpoint; i++, pa++) + for (i=0; itotpoint; i++, pa++) pa->hair= MEM_dupallocN(pa->hair); undo->psys_flag = edit->psys->flag; @@ -3787,8 +3788,8 @@ static void make_PTCacheUndo(PTCacheEdit *edit, PTCacheUndo *undo) BLI_duplicatelist(&undo->mem_cache, &edit->pid.cache->mem_cache); pm = undo->mem_cache.first; - for(; pm; pm=pm->next) { - for(i=0; inext) { + for (i=0; idata[i] = MEM_dupallocN(pm->data[i]); } } @@ -3796,7 +3797,7 @@ static void make_PTCacheUndo(PTCacheEdit *edit, PTCacheUndo *undo) point= undo->points = MEM_dupallocN(edit->points); undo->totpoint = edit->totpoint; - for(i=0; itotpoint; i++, point++) { + for (i=0; itotpoint; i++, point++) { point->keys= MEM_dupallocN(point->keys); /* no need to update edit key->co & key->time pointers here */ } @@ -3810,17 +3811,17 @@ static void get_PTCacheUndo(PTCacheEdit *edit, PTCacheUndo *undo) POINT_P; KEY_K; LOOP_POINTS { - if(psys && psys->particles[p].hair) + if (psys && psys->particles[p].hair) MEM_freeN(psys->particles[p].hair); - if(point->keys) + if (point->keys) MEM_freeN(point->keys); } - if(psys && psys->particles) + if (psys && psys->particles) MEM_freeN(psys->particles); - if(edit->points) + if (edit->points) MEM_freeN(edit->points); - if(edit->mirror_cache) { + if (edit->mirror_cache) { MEM_freeN(edit->mirror_cache); edit->mirror_cache= NULL; } @@ -3832,7 +3833,7 @@ static void get_PTCacheUndo(PTCacheEdit *edit, PTCacheUndo *undo) point->keys= MEM_dupallocN(point->keys); } - if(psys) { + if (psys) { psys->particles= MEM_dupallocN(undo->particles); psys->totpart= undo->totpoint; @@ -3860,15 +3861,15 @@ static void get_PTCacheUndo(PTCacheEdit *edit, PTCacheUndo *undo) pm = edit->pid.cache->mem_cache.first; - for(; pm; pm=pm->next) { - for(i=0; inext) { + for (i=0; idata[i] = MEM_dupallocN(pm->data[i]); BKE_ptcache_mem_pointers_init(pm); LOOP_POINTS { LOOP_KEYS { - if((int)key->ftime == (int)pm->frame) { + if ((int)key->ftime == (int)pm->frame) { key->co = pm->cur[BPHYS_DATA_LOCATION]; key->vel = pm->cur[BPHYS_DATA_VELOCITY]; key->rot = pm->cur[BPHYS_DATA_ROTATION]; @@ -3887,7 +3888,7 @@ void PE_undo_push(Scene *scene, const char *str) PTCacheUndo *undo; int nr; - if(!edit) return; + if (!edit) return; /* remove all undos after (also when curundo==NULL) */ while(edit->undo.last != edit->curundo) { @@ -3907,10 +3908,10 @@ void PE_undo_push(Scene *scene, const char *str) undo= edit->undo.last; while(undo) { nr++; - if(nr==U.undosteps) break; + if (nr==U.undosteps) break; undo= undo->prev; } - if(undo) { + if (undo) { while(edit->undo.first!=undo) { PTCacheUndo *first= edit->undo.first; BLI_remlink(&edit->undo, first); @@ -3927,16 +3928,16 @@ void PE_undo_step(Scene *scene, int step) { PTCacheEdit *edit= PE_get_current(scene, OBACT); - if(!edit) return; + if (!edit) return; - if(step==0) { + if (step==0) { get_PTCacheUndo(edit,edit->curundo); } - else if(step==1) { + else if (step==1) { - if(edit->curundo==NULL || edit->curundo->prev==NULL); + if (edit->curundo==NULL || edit->curundo->prev==NULL); else { - if(G.f & G_DEBUG) printf("undo %s\n", edit->curundo->name); + if (G.f & G_DEBUG) printf("undo %s\n", edit->curundo->name); edit->curundo= edit->curundo->prev; get_PTCacheUndo(edit, edit->curundo); } @@ -3944,11 +3945,11 @@ void PE_undo_step(Scene *scene, int step) else { /* curundo has to remain current situation! */ - if(edit->curundo==NULL || edit->curundo->next==NULL); + if (edit->curundo==NULL || edit->curundo->next==NULL); else { get_PTCacheUndo(edit, edit->curundo->next); edit->curundo= edit->curundo->next; - if(G.f & G_DEBUG) printf("redo %s\n", edit->curundo->name); + if (G.f & G_DEBUG) printf("redo %s\n", edit->curundo->name); } } @@ -3959,7 +3960,7 @@ int PE_undo_valid(Scene *scene) { PTCacheEdit *edit= PE_get_current(scene, OBACT); - if(edit) { + if (edit) { return (edit->undo.last != edit->undo.first); } return 0; @@ -3969,7 +3970,7 @@ static void PTCacheUndo_clear(PTCacheEdit *edit) { PTCacheUndo *undo; - if(edit==NULL) return; + if (edit==NULL) return; undo= edit->undo.first; while(undo) { @@ -3996,8 +3997,8 @@ void PE_undo_number(Scene *scene, int nr) PTCacheUndo *undo; int a=0; - for(undo= edit->undo.first; undo; undo= undo->next, a++) { - if(a==nr) break; + for (undo= edit->undo.first; undo; undo= undo->next, a++) { + if (a==nr) break; } edit->curundo= undo; PE_undo_step(scene, 0); @@ -4011,12 +4012,12 @@ const char *PE_undo_get_name(Scene *scene, int nr, int *active) PTCacheEdit *edit= PE_get_current(scene, OBACT); PTCacheUndo *undo; - if(active) *active= 0; + if (active) *active= 0; - if(edit) { + if (edit) { undo= BLI_findlink(&edit->undo, nr); - if(undo) { - if(active && undo==edit->curundo) + if (undo) { + if (active && undo==edit->curundo) *active= 1; return undo->name; } @@ -4036,15 +4037,15 @@ int PE_minmax(Scene *scene, float min[3], float max[3]) float co[3], mat[4][4]; int ok= 0; - if(!edit) return ok; + if (!edit) return ok; - if((psys = edit->psys)) + if ((psys = edit->psys)) psmd= psys_get_modifier(ob, psys); else unit_m4(mat); LOOP_VISIBLE_POINTS { - if(psys) + if (psys) psys_mat_hair_to_global(ob, psmd->dm, psys->part->from, psys->particles+p, mat); LOOP_SELECTED_KEYS { @@ -4055,7 +4056,7 @@ int PE_minmax(Scene *scene, float min[3], float max[3]) } } - if(!ok) { + if (!ok) { minmax_object(ob, min, max); ok= 1; } @@ -4076,23 +4077,23 @@ static void PE_create_particle_edit(Scene *scene, Object *ob, PointCache *cache, int totpoint; /* no psmd->dm happens in case particle system modifier is not enabled */ - if(!(psys && psmd && psmd->dm) && !cache) + if (!(psys && psmd && psmd->dm) && !cache) return; - if(cache && cache->flag & PTCACHE_DISK_CACHE) + if (cache && cache->flag & PTCACHE_DISK_CACHE) return; - if(psys == NULL && cache->mem_cache.first == NULL) + if (psys == NULL && cache->mem_cache.first == NULL) return; - if(!edit) { + if (!edit) { totpoint = psys ? psys->totpart : (int)((PTCacheMem*)cache->mem_cache.first)->totpoint; edit= MEM_callocN(sizeof(PTCacheEdit), "PE_create_particle_edit"); edit->points=MEM_callocN(totpoint*sizeof(PTCacheEditPoint),"PTCacheEditPoints"); edit->totpoint = totpoint; - if(psys && !cache) { + if (psys && !cache) { psys->edit= edit; edit->psys = psys; @@ -4112,7 +4113,7 @@ static void PE_create_particle_edit(Scene *scene, Object *ob, PointCache *cache, key->co= hkey->co; key->time= &hkey->time; key->flag= hkey->editflag; - if(!(psys->flag & PSYS_GLOBAL_HAIR)) { + if (!(psys->flag & PSYS_GLOBAL_HAIR)) { key->flag |= PEK_USE_WCO; hkey->editflag |= PEK_USE_WCO; } @@ -4131,15 +4132,15 @@ static void PE_create_particle_edit(Scene *scene, Object *ob, PointCache *cache, cache->free_edit= PE_free_ptcache_edit; edit->psys = NULL; - for(pm=cache->mem_cache.first; pm; pm=pm->next) + for (pm=cache->mem_cache.first; pm; pm=pm->next) totframe++; - for(pm=cache->mem_cache.first; pm; pm=pm->next) { + for (pm=cache->mem_cache.first; pm; pm=pm->next) { LOOP_POINTS { - if(BKE_ptcache_mem_pointers_seek(p, pm) == 0) + if (BKE_ptcache_mem_pointers_seek(p, pm) == 0) continue; - if(!point->totkey) { + if (!point->totkey) { key = point->keys = MEM_callocN(totframe*sizeof(PTCacheEditKey),"ParticleEditKeys"); point->flag |= PEP_EDIT_RECALC; } @@ -4163,7 +4164,7 @@ static void PE_create_particle_edit(Scene *scene, Object *ob, PointCache *cache, UI_GetThemeColor3ubv(TH_WIRE, edit->nosel_col); recalc_lengths(edit); - if(psys && !cache) + if (psys && !cache) recalc_emitter_field(ob, psys); PE_update_object(scene, ob, 1); @@ -4177,7 +4178,7 @@ static int particle_edit_toggle_poll(bContext *C) Scene *scene= CTX_data_scene(C); Object *ob= CTX_data_active_object(C); - if(!scene || !ob || ob->id.lib) + if (!scene || !ob || ob->id.lib) return 0; return (ob->particlesystem.first || modifiers_findByType(ob, eModifierType_Cloth) || modifiers_findByType(ob, eModifierType_Softbody)); @@ -4188,14 +4189,14 @@ static int particle_edit_toggle_exec(bContext *C, wmOperator *UNUSED(op)) Scene *scene= CTX_data_scene(C); Object *ob= CTX_data_active_object(C); - if(!(ob->mode & OB_MODE_PARTICLE_EDIT)) { + if (!(ob->mode & OB_MODE_PARTICLE_EDIT)) { PTCacheEdit *edit; ob->mode |= OB_MODE_PARTICLE_EDIT; edit= PE_create_current(scene, ob); /* mesh may have changed since last entering editmode. * note, this may have run before if the edit data was just created, so could avoid this and speed up a little */ - if(edit && edit->psys) + if (edit && edit->psys) recalc_emitter_field(ob, edit->psys); toggle_particle_cursor(C, 1); @@ -4234,8 +4235,8 @@ static int clear_edited_exec(bContext *C, wmOperator *UNUSED(op)) Object *ob= CTX_data_active_object(C); ParticleSystem *psys = psys_get_current(ob); - if(psys->edit) { - if(psys->edit->edited || 1) { // XXX okee("Lose changes done in particle mode?")) + if (psys->edit) { + if (psys->edit->edited || 1) { // XXX okee("Lose changes done in particle mode?")) PE_free_ptcache_edit(psys->edit); psys->edit = NULL; diff --git a/source/blender/editors/physics/particle_object.c b/source/blender/editors/physics/particle_object.c index 964f83d8d9f..1e71cf61817 100644 --- a/source/blender/editors/physics/particle_object.c +++ b/source/blender/editors/physics/particle_object.c @@ -70,7 +70,7 @@ static int particle_system_add_exec(bContext *C, wmOperator *UNUSED(op)) Object *ob= ED_object_context(C); Scene *scene = CTX_data_scene(C); - if(!scene || !ob) + if (!scene || !ob) return OPERATOR_CANCELLED; object_add_particle_system(scene, ob, NULL); @@ -101,7 +101,7 @@ static int particle_system_remove_exec(bContext *C, wmOperator *UNUSED(op)) Object *ob= ED_object_context(C); Scene *scene = CTX_data_scene(C); int mode_orig = ob->mode; - if(!scene || !ob) + if (!scene || !ob) return OPERATOR_CANCELLED; object_remove_particle_system(scene, ob); @@ -109,9 +109,9 @@ static int particle_system_remove_exec(bContext *C, wmOperator *UNUSED(op)) /* possible this isn't the active object * object_remove_particle_system() clears the mode on the last psys * */ - if(mode_orig & OB_MODE_PARTICLE_EDIT) - if((ob->mode & OB_MODE_PARTICLE_EDIT)==0) - if(scene->basact && scene->basact->object==ob) + if (mode_orig & OB_MODE_PARTICLE_EDIT) + if ((ob->mode & OB_MODE_PARTICLE_EDIT)==0) + if (scene->basact && scene->basact->object==ob) WM_event_add_notifier(C, NC_SCENE|ND_MODE|NS_MODE_OBJECT, NULL); WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE, ob); @@ -157,14 +157,14 @@ static int new_particle_settings_exec(bContext *C, wmOperator *UNUSED(op)) psys = ptr.data; /* add or copy particle setting */ - if(psys->part) + if (psys->part) part= psys_copy_settings(psys->part); else part= psys_new_settings("ParticleSettings", bmain); ob= ptr.id.data; - if(psys->part) + if (psys->part) psys->part->id.us--; psys->part = part; @@ -206,11 +206,11 @@ static int new_particle_target_exec(bContext *C, wmOperator *UNUSED(op)) ParticleTarget *pt; - if(!psys) + if (!psys) return OPERATOR_CANCELLED; pt = psys->targets.first; - for(; pt; pt=pt->next) + for (; pt; pt=pt->next) pt->flag &= ~PTARGET_CURRENT; pt = MEM_callocN(sizeof(ParticleTarget), "keyed particle target"); @@ -252,12 +252,12 @@ static int remove_particle_target_exec(bContext *C, wmOperator *UNUSED(op)) ParticleTarget *pt; - if(!psys) + if (!psys) return OPERATOR_CANCELLED; pt = psys->targets.first; - for(; pt; pt=pt->next) { - if(pt->flag & PTARGET_CURRENT) { + for (; pt; pt=pt->next) { + if (pt->flag & PTARGET_CURRENT) { BLI_remlink(&psys->targets, pt); MEM_freeN(pt); break; @@ -266,7 +266,7 @@ static int remove_particle_target_exec(bContext *C, wmOperator *UNUSED(op)) } pt = psys->targets.last; - if(pt) + if (pt) pt->flag |= PTARGET_CURRENT; DAG_scene_sort(bmain, scene); @@ -300,12 +300,12 @@ static int target_move_up_exec(bContext *C, wmOperator *UNUSED(op)) Object *ob = ptr.id.data; ParticleTarget *pt; - if(!psys) + if (!psys) return OPERATOR_CANCELLED; pt = psys->targets.first; - for(; pt; pt=pt->next) { - if(pt->flag & PTARGET_CURRENT && pt->prev) { + for (; pt; pt=pt->next) { + if (pt->flag & PTARGET_CURRENT && pt->prev) { BLI_remlink(&psys->targets, pt); BLI_insertlink(&psys->targets, pt->prev->prev, pt); @@ -339,11 +339,11 @@ static int target_move_down_exec(bContext *C, wmOperator *UNUSED(op)) Object *ob = ptr.id.data; ParticleTarget *pt; - if(!psys) + if (!psys) return OPERATOR_CANCELLED; pt = psys->targets.first; - for(; pt; pt=pt->next) { - if(pt->flag & PTARGET_CURRENT && pt->next) { + for (; pt; pt=pt->next) { + if (pt->flag & PTARGET_CURRENT && pt->next) { BLI_remlink(&psys->targets, pt); BLI_insertlink(&psys->targets, pt->next, pt); @@ -377,12 +377,12 @@ static int dupliob_move_up_exec(bContext *C, wmOperator *UNUSED(op)) ParticleSettings *part; ParticleDupliWeight *dw; - if(!psys) + if (!psys) return OPERATOR_CANCELLED; part = psys->part; - for(dw=part->dupliweights.first; dw; dw=dw->next) { - if(dw->flag & PART_DUPLIW_CURRENT && dw->prev) { + for (dw=part->dupliweights.first; dw; dw=dw->next) { + if (dw->flag & PART_DUPLIW_CURRENT && dw->prev) { BLI_remlink(&part->dupliweights, dw); BLI_insertlink(&part->dupliweights, dw->prev->prev, dw); @@ -415,11 +415,11 @@ static int copy_particle_dupliob_exec(bContext *C, wmOperator *UNUSED(op)) ParticleSettings *part; ParticleDupliWeight *dw; - if(!psys) + if (!psys) return OPERATOR_CANCELLED; part = psys->part; - for(dw=part->dupliweights.first; dw; dw=dw->next) { - if(dw->flag & PART_DUPLIW_CURRENT) { + for (dw=part->dupliweights.first; dw; dw=dw->next) { + if (dw->flag & PART_DUPLIW_CURRENT) { dw->flag &= ~PART_DUPLIW_CURRENT; dw = MEM_dupallocN(dw); dw->flag |= PART_DUPLIW_CURRENT; @@ -454,12 +454,12 @@ static int remove_particle_dupliob_exec(bContext *C, wmOperator *UNUSED(op)) ParticleSettings *part; ParticleDupliWeight *dw; - if(!psys) + if (!psys) return OPERATOR_CANCELLED; part = psys->part; - for(dw=part->dupliweights.first; dw; dw=dw->next) { - if(dw->flag & PART_DUPLIW_CURRENT) { + for (dw=part->dupliweights.first; dw; dw=dw->next) { + if (dw->flag & PART_DUPLIW_CURRENT) { BLI_remlink(&part->dupliweights, dw); MEM_freeN(dw); break; @@ -468,7 +468,7 @@ static int remove_particle_dupliob_exec(bContext *C, wmOperator *UNUSED(op)) } dw = part->dupliweights.last; - if(dw) + if (dw) dw->flag |= PART_DUPLIW_CURRENT; WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE, NULL); @@ -499,12 +499,12 @@ static int dupliob_move_down_exec(bContext *C, wmOperator *UNUSED(op)) ParticleSettings *part; ParticleDupliWeight *dw; - if(!psys) + if (!psys) return OPERATOR_CANCELLED; part = psys->part; - for(dw=part->dupliweights.first; dw; dw=dw->next) { - if(dw->flag & PART_DUPLIW_CURRENT && dw->next) { + for (dw=part->dupliweights.first; dw; dw=dw->next) { + if (dw->flag & PART_DUPLIW_CURRENT && dw->next) { BLI_remlink(&part->dupliweights, dw); BLI_insertlink(&part->dupliweights, dw->next, dw); @@ -542,27 +542,27 @@ static void disconnect_hair(Scene *scene, Object *ob, ParticleSystem *psys) int i, k; float hairmat[4][4]; - if(!ob || !psys || psys->flag & PSYS_GLOBAL_HAIR) + if (!ob || !psys || psys->flag & PSYS_GLOBAL_HAIR) return; - if(!psys->part || psys->part->type != PART_HAIR) + if (!psys->part || psys->part->type != PART_HAIR) return; edit = psys->edit; point= edit ? edit->points : NULL; - for(i=0, pa=psys->particles; itotpart; i++,pa++) { - if(point) { + for (i=0, pa=psys->particles; itotpart; i++,pa++) { + if (point) { ekey = point->keys; point++; } psys_mat_hair_to_global(ob, psmd->dm, psys->part->from, pa, hairmat); - for(k=0,key=pa->hair; ktotkey; k++,key++) { + for (k=0,key=pa->hair; ktotkey; k++,key++) { mul_m4_v3(hairmat,key->co); - if(ekey) { + if (ekey) { ekey->flag &= ~PEK_USE_WCO; ekey++; } @@ -573,7 +573,7 @@ static void disconnect_hair(Scene *scene, Object *ob, ParticleSystem *psys) psys->flag |= PSYS_GLOBAL_HAIR; - if(ELEM(pset->brushtype, PE_BRUSH_ADD, PE_BRUSH_PUFF)) + if (ELEM(pset->brushtype, PE_BRUSH_ADD, PE_BRUSH_PUFF)) pset->brushtype = PE_BRUSH_NONE; PE_update_object(scene, ob, 0); @@ -587,11 +587,11 @@ static int disconnect_hair_exec(bContext *C, wmOperator *op) ParticleSystem *psys= NULL; int all = RNA_boolean_get(op->ptr, "all"); - if(!ob) + if (!ob) return OPERATOR_CANCELLED; - if(all) { - for(psys=ob->particlesystem.first; psys; psys=psys->next) { + if (all) { + for (psys=ob->particlesystem.first; psys; psys=psys->next) { disconnect_hair(scene, ob, psys); } } @@ -637,13 +637,13 @@ static void connect_hair(Scene *scene, Object *ob, ParticleSystem *psys) float hairmat[4][4], imat[4][4]; float v[4][3], vec[3]; - if(!psys || !psys->part || psys->part->type != PART_HAIR) + if (!psys || !psys->part || psys->part->type != PART_HAIR) return; edit= psys->edit; point= edit ? edit->points : NULL; - if(psmd->dm->deformedOnly) + if (psmd->dm->deformedOnly) /* we don't want to mess up psmd->dm when converting to global coordinates below */ dm= CDDM_copy(psmd->dm); else @@ -661,7 +661,7 @@ static void connect_hair(Scene *scene, Object *ob, ParticleSystem *psys) bvhtree_from_mesh_faces(&bvhtree, dm, 0.0, 2, 6); - for(i=0, pa= psys->particles; itotpart; i++,pa++) { + for (i=0, pa= psys->particles; itotpart; i++,pa++) { key = pa->hair; nearest.index = -1; @@ -669,7 +669,7 @@ static void connect_hair(Scene *scene, Object *ob, ParticleSystem *psys) BLI_bvhtree_find_nearest(bvhtree.tree, key->co, &nearest, bvhtree.nearest_callback, &bvhtree); - if(nearest.index == -1) { + if (nearest.index == -1) { if (G.f & G_DEBUG) printf("No nearest point found for hair root!"); continue; @@ -680,7 +680,7 @@ static void connect_hair(Scene *scene, Object *ob, ParticleSystem *psys) copy_v3_v3(v[0], CDDM_get_vert(dm,mface->v1)->co); copy_v3_v3(v[1], CDDM_get_vert(dm,mface->v2)->co); copy_v3_v3(v[2], CDDM_get_vert(dm,mface->v3)->co); - if(mface->v4) { + if (mface->v4) { copy_v3_v3(v[3], CDDM_get_vert(dm,mface->v4)->co); interp_weights_poly_v3( pa->fuv,v, 4, nearest.co); } @@ -695,16 +695,16 @@ static void connect_hair(Scene *scene, Object *ob, ParticleSystem *psys) sub_v3_v3v3(vec, nearest.co, key->co); - if(point) { + if (point) { ekey = point->keys; point++; } - for(k=0,key=pa->hair; ktotkey; k++,key++) { + for (k=0,key=pa->hair; ktotkey; k++,key++) { add_v3_v3(key->co, vec); mul_m4_v3(imat,key->co); - if(ekey) { + if (ekey) { ekey->flag |= PEK_USE_WCO; ekey++; } @@ -729,11 +729,11 @@ static int connect_hair_exec(bContext *C, wmOperator *op) ParticleSystem *psys= NULL; int all = RNA_boolean_get(op->ptr, "all"); - if(!ob) + if (!ob) return OPERATOR_CANCELLED; - if(all) { - for(psys=ob->particlesystem.first; psys; psys=psys->next) { + if (all) { + for (psys=ob->particlesystem.first; psys; psys=psys->next) { connect_hair(scene, ob, psys); } } diff --git a/source/blender/editors/physics/physics_fluid.c b/source/blender/editors/physics/physics_fluid.c index af229fc4cb1..23765b03d35 100644 --- a/source/blender/editors/physics/physics_fluid.c +++ b/source/blender/editors/physics/physics_fluid.c @@ -129,7 +129,8 @@ static void get_fluid_gravity(float *gravity, Scene *scene, FluidsimSettings *fs { if (scene->physics_settings.flag & PHYS_GLOBAL_GRAVITY) { copy_v3_v3(gravity, scene->physics_settings.gravity); - } else { + } + else { copy_v3_v3(gravity, fss->grav); } } @@ -138,7 +139,8 @@ static float get_fluid_size_m(Scene *scene, Object *domainob, FluidsimSettings * { if (!scene->unit.system) { return fss->realsize; - } else { + } + else { float dim[3]; float longest_axis; @@ -212,20 +214,22 @@ static void fluidsimPrintChannel(FILE *file, float *channel, int paramsize, char int i,j; int channelSize = paramsize; - if(entries==3) { + if (entries==3) { elbeemSimplifyChannelVec3( channel, &channelSize); - } else if(entries==1) { + } + else if (entries==1) { elbeemSimplifyChannelFloat( channel, &channelSize); - } else { + } + else { // invalid, cant happen? } fprintf(file, " CHANNEL %s = \n", str); - for(i=0; iobmat rather than ob->rot to account for parent animations */ - if(i) { + if (i) { copy_v3_v3(old_rot, fobj->Rotation + 4*(i-1)); mul_v3_fl(old_rot, -M_PI/180.f); } @@ -538,16 +542,16 @@ static void export_fluid_objects(ListBase *fobjects, Scene *scene, int length) fsmesh.channelScale = fobj->Scale; fsmesh.channelActive = fobj->Active; - if( ELEM(fsmesh.type, OB_FLUIDSIM_FLUID, OB_FLUIDSIM_INFLOW)) { + if ( ELEM(fsmesh.type, OB_FLUIDSIM_FLUID, OB_FLUIDSIM_INFLOW)) { fsmesh.channelInitialVel = fobj->InitialVelocity; fsmesh.localInivelCoords = ((fluidmd->fss->typeFlags & OB_FSINFLOW_LOCALCOORD)?1:0); } - if(fluidmd->fss->typeFlags & OB_FSBND_NOSLIP) + if (fluidmd->fss->typeFlags & OB_FSBND_NOSLIP) fsmesh.obstacleType = FLUIDSIM_OBSTACLE_NOSLIP; - else if(fluidmd->fss->typeFlags & OB_FSBND_PARTSLIP) + else if (fluidmd->fss->typeFlags & OB_FSBND_PARTSLIP) fsmesh.obstacleType = FLUIDSIM_OBSTACLE_PARTSLIP; - else if(fluidmd->fss->typeFlags & OB_FSBND_FREESLIP) + else if (fluidmd->fss->typeFlags & OB_FSBND_FREESLIP) fsmesh.obstacleType = FLUIDSIM_OBSTACLE_FREESLIP; fsmesh.obstaclePartslip = fluidmd->fss->partSlipValue; @@ -578,7 +582,7 @@ static void export_fluid_objects(ListBase *fobjects, Scene *scene, int length) } /* animated meshes */ - if(deform) { + if (deform) { fsmesh.channelSizeVertices = length; fsmesh.channelVertices = fobj->VertexCache; @@ -590,8 +594,8 @@ static void export_fluid_objects(ListBase *fobjects, Scene *scene, int length) elbeemAddMesh(&fsmesh); - if(verts) MEM_freeN(verts); - if(tris) MEM_freeN(tris); + if (verts) MEM_freeN(verts); + if (tris) MEM_freeN(tris); } } @@ -602,7 +606,7 @@ static int fluid_validate_scene(ReportList *reports, Scene *scene, Object *fsDom int channelObjCount = 0; int fluidInputCount = 0; - for(base=scene->base.first; base; base= base->next) + for (base=scene->base.first; base; base= base->next) { Object *ob = base->object; FluidsimModifierData *fluidmdtmp = (FluidsimModifierData *)modifiers_findByType(ob, eModifierType_Fluidsim); @@ -610,7 +614,7 @@ static int fluid_validate_scene(ReportList *reports, Scene *scene, Object *fsDom /* only find objects with fluid modifiers */ if (!fluidmdtmp || ob->type != OB_MESH) continue; - if(fluidmdtmp->fss->type == OB_FLUIDSIM_DOMAIN) { + if (fluidmdtmp->fss->type == OB_FLUIDSIM_DOMAIN) { /* if no initial domain object given, find another potential domain */ if (!fsDomain) { newdomain = ob; @@ -685,13 +689,13 @@ static int fluid_init_filepaths(Object *fsDomain, char *targetDir, char *targetF // check selected directory // simply try to open cfg file for writing to test validity of settings fileCfg = BLI_fopen(targetFile, "w"); - if(fileCfg) { + if (fileCfg) { dirExist = 1; fclose(fileCfg); // remove cfg dummy from directory test BLI_delete(targetFile, 0,0); } - if(targetDir[0] == '\0' || (!dirExist)) { + if (targetDir[0] == '\0' || (!dirExist)) { char blendDir[FILE_MAX]; char blendFile[FILE_MAX]; @@ -709,7 +713,7 @@ static int fluid_init_filepaths(Object *fsDomain, char *targetDir, char *targetF // check if modified output dir is ok #if 0 - if(outStringsChanged) { + if (outStringsChanged) { char dispmsg[FILE_MAX+256]; int selection=0; BLI_strncpy(dispmsg,"Output settings set to: '", sizeof(dispmsg)); @@ -718,7 +722,7 @@ static int fluid_init_filepaths(Object *fsDomain, char *targetDir, char *targetF // ask user if thats what he/she wants... selection = pupmenu(dispmsg); - if(selection<1) return 0; // 0 from menu, or -1 aborted + if (selection<1) return 0; // 0 from menu, or -1 aborted BLI_strncpy(targetDir, newSurfdataPath, sizeof(targetDir)); strncpy(domainSettings->surfdataPath, newSurfdataPath, FILE_MAXDIR); BLI_path_abs(targetDir, G.main->name); // fixed #frame-no @@ -751,7 +755,7 @@ static int fluidbake_breakjob(void *customdata) { FluidBakeJob *fb= (FluidBakeJob *)customdata; - if(fb->stop && *(fb->stop)) + if (fb->stop && *(fb->stop)) return 1; /* this is not nice yet, need to make the jobs list template better @@ -865,7 +869,7 @@ static void fluidsim_delete_until_lastframe(FluidsimSettings *fss, const char *r BLI_delete(targetFileVel, 0, 0); BLI_delete(previewFile, 0, 0); } - } while(exists); + } while (exists); return; } @@ -904,7 +908,7 @@ static int fluidsimBake(bContext *C, ReportList *reports, Object *fsDomain, shor fb= MEM_callocN(sizeof(FluidBakeJob), "fluid bake job"); - if(getenv(strEnvName)) { + if (getenv(strEnvName)) { int dlevel = atoi(getenv(strEnvName)); elbeemSetDebugLevel(dlevel); BLI_snprintf(debugStrBuffer, sizeof(debugStrBuffer),"fluidsimBake::msg: Debug messages activated due to envvar '%s'\n",strEnvName); @@ -913,7 +917,7 @@ static int fluidsimBake(bContext *C, ReportList *reports, Object *fsDomain, shor /* make sure it corresponds to startFrame setting (old: noFrames = scene->r.efra - scene->r.sfra +1) */; noFrames = scene->r.efra - 0; - if(noFrames<=0) { + if (noFrames<=0) { BKE_report(reports, RPT_ERROR, "No frames to export - check your animation range settings"); fluidbake_free_data(channels, fobjects, fsset, fb); return 0; @@ -943,7 +947,7 @@ static int fluidsimBake(bContext *C, ReportList *reports, Object *fsDomain, shor fluidsim_delete_until_lastframe(domainSettings, relbase); /* rough check of settings... */ - if(domainSettings->previewresxyz > domainSettings->resolutionxyz) { + if (domainSettings->previewresxyz > domainSettings->resolutionxyz) { BLI_snprintf(debugStrBuffer,sizeof(debugStrBuffer),"fluidsimBake::warning - Preview (%d) >= Resolution (%d)... setting equal.\n", domainSettings->previewresxyz , domainSettings->resolutionxyz); elbeemDebugOut(debugStrBuffer); domainSettings->previewresxyz = domainSettings->resolutionxyz; @@ -952,16 +956,19 @@ static int fluidsimBake(bContext *C, ReportList *reports, Object *fsDomain, shor // this should do as an approximation, with in/outflow // doing this more accurate would be overkill // perhaps add manual setting? - if(domainSettings->maxRefine <0) { - if(domainSettings->resolutionxyz>128) { + if (domainSettings->maxRefine <0) { + if (domainSettings->resolutionxyz>128) { gridlevels = 2; - } else - if(domainSettings->resolutionxyz>64) { + } + else + if (domainSettings->resolutionxyz>64) { gridlevels = 1; - } else { + } + else { gridlevels = 0; } - } else { + } + else { gridlevels = domainSettings->maxRefine; } BLI_snprintf(debugStrBuffer,sizeof(debugStrBuffer),"fluidsimBake::msg: Baking %s, refine: %d\n", fsDomain->id.name , gridlevels ); @@ -983,7 +990,7 @@ static int fluidsimBake(bContext *C, ReportList *reports, Object *fsDomain, shor /* ******** init domain object's matrix ******** */ copy_m4_m4(domainMat, fsDomain->obmat); - if(!invert_m4_m4(invDomMat, domainMat)) { + if (!invert_m4_m4(invDomMat, domainMat)) { BLI_snprintf(debugStrBuffer,sizeof(debugStrBuffer),"fluidsimBake::error - Invalid obj matrix?\n"); elbeemDebugOut(debugStrBuffer); BKE_report(reports, RPT_ERROR, "Invalid object matrix"); @@ -997,7 +1004,7 @@ static int fluidsimBake(bContext *C, ReportList *reports, Object *fsDomain, shor BLI_join_dirfile(targetFile, sizeof(targetFile), targetDir, suffixConfigTmp); // make sure these directories exist as well - if(outStringsChanged) { + if (outStringsChanged) { BLI_make_existing_file(targetFile); } @@ -1051,7 +1058,7 @@ static int fluidsimBake(bContext *C, ReportList *reports, Object *fsDomain, shor fsset->domainobsPartslip = domainSettings->partSlipValue; /* use domainobsType also for surface generation flag (bit: >=64) */ - if(domainSettings->typeFlags & OB_FSSG_NOOBS) + if (domainSettings->typeFlags & OB_FSSG_NOOBS) fsset->mFsSurfGenSetting = FLUIDSIM_FSSG_NOOBS; else fsset->mFsSurfGenSetting = 0; // "normal" mode @@ -1060,8 +1067,8 @@ static int fluidsimBake(bContext *C, ReportList *reports, Object *fsDomain, shor // init blender domain transform matrix { int j; - for(i=0; i<4; i++) { - for(j=0; j<4; j++) { + for (i=0; i<4; i++) { + for (j=0; j<4; j++) { fsset->surfaceTrafo[i*4+j] = invDomMat[j][i]; } } } @@ -1076,7 +1083,7 @@ static int fluidsimBake(bContext *C, ReportList *reports, Object *fsDomain, shor /* custom data for fluid bake job */ fb->settings = fsset; - if(do_job) { + if (do_job) { wmJob *steve= WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), scene, "Fluid Simulation", WM_JOB_PROGRESS); /* setup job */ @@ -1139,10 +1146,10 @@ static int fluidsimBake(bContext *UNUSED(C), ReportList *UNUSED(reports), Object static int fluid_bake_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) { /* only one bake job at a time */ - if(WM_jobs_test(CTX_wm_manager(C), CTX_data_scene(C))) + if (WM_jobs_test(CTX_wm_manager(C), CTX_data_scene(C))) return OPERATOR_CANCELLED; - if(!fluidsimBake(C, op->reports, CTX_data_active_object(C), TRUE)) + if (!fluidsimBake(C, op->reports, CTX_data_active_object(C), TRUE)) return OPERATOR_CANCELLED; return OPERATOR_FINISHED; @@ -1150,7 +1157,7 @@ static int fluid_bake_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event) static int fluid_bake_exec(bContext *C, wmOperator *op) { - if(!fluidsimBake(C, op->reports, CTX_data_active_object(C), FALSE)) + if (!fluidsimBake(C, op->reports, CTX_data_active_object(C), FALSE)) return OPERATOR_CANCELLED; return OPERATOR_FINISHED; diff --git a/source/blender/editors/physics/physics_pointcache.c b/source/blender/editors/physics/physics_pointcache.c index 9501dee30db..6573647aaee 100644 --- a/source/blender/editors/physics/physics_pointcache.c +++ b/source/blender/editors/physics/physics_pointcache.c @@ -67,7 +67,7 @@ static int ptcache_bake_all_poll(bContext *C) { Scene *scene= CTX_data_scene(C); - if(!scene) + if (!scene) return 0; return 1; @@ -114,7 +114,8 @@ static int ptcache_bake_all_exec(bContext *C, wmOperator *op) baker.progressbar = (void (*)(void *, int))WM_timecursor; baker.progressend = (void (*)(void *))WM_cursor_restore; baker.progresscontext = win; - } else { + } + else { baker.progressbar = bake_console_progress; baker.progressend = bake_console_progress_end; baker.progresscontext = NULL; @@ -134,10 +135,10 @@ static int ptcache_free_bake_all_exec(bContext *C, wmOperator *UNUSED(op)) PTCacheID *pid; ListBase pidlist; - for(base=scene->base.first; base; base= base->next) { + for (base=scene->base.first; base; base= base->next) { BKE_ptcache_ids_from_object(&pidlist, base->object, scene, MAX_DUPLI_RECUR); - for(pid=pidlist.first; pid; pid=pid->next) { + for (pid=pidlist.first; pid; pid=pid->next) { pid->cache->flag &= ~PTCACHE_BAKED; } @@ -194,8 +195,8 @@ static int ptcache_bake_exec(bContext *C, wmOperator *op) BKE_ptcache_ids_from_object(&pidlist, ob, scene, MAX_DUPLI_RECUR); - for(pid=pidlist.first; pid; pid=pid->next) { - if(pid->cache == cache) + for (pid=pidlist.first; pid; pid=pid->next) { + if (pid->cache == cache) break; } @@ -216,7 +217,8 @@ static int ptcache_bake_exec(bContext *C, wmOperator *op) baker.progressbar = (void (*)(void *, int))WM_timecursor; baker.progressend = (void (*)(void *))WM_cursor_restore; baker.progresscontext = win; - } else { + } + else { printf("\n"); /* empty first line before console reports */ baker.progressbar = bake_console_progress; baker.progressend = bake_console_progress_end; @@ -238,8 +240,8 @@ static int ptcache_free_bake_exec(bContext *C, wmOperator *UNUSED(op)) PointCache *cache= ptr.data; Object *ob= ptr.id.data; - if(cache->edit) { - if(!cache->edit->edited || 1) {// XXX okee("Lose changes done in particle mode?")) { + if (cache->edit) { + if (!cache->edit->edited || 1) {// XXX okee("Lose changes done in particle mode?")) { PE_free_ptcache_edit(cache->edit); cache->edit = NULL; cache->flag &= ~PTCACHE_BAKED; @@ -320,8 +322,8 @@ static int ptcache_add_new_exec(bContext *C, wmOperator *UNUSED(op)) BKE_ptcache_ids_from_object(&pidlist, ob, scene, MAX_DUPLI_RECUR); - for(pid=pidlist.first; pid; pid=pid->next) { - if(pid->cache == cache) { + for (pid=pidlist.first; pid; pid=pid->next) { + if (pid->cache == cache) { PointCache *cache = BKE_ptcache_add(pid->ptcaches); cache->step = pid->default_step; *(pid->cache_ptr) = cache; @@ -347,9 +349,9 @@ static int ptcache_remove_exec(bContext *C, wmOperator *UNUSED(op)) BKE_ptcache_ids_from_object(&pidlist, ob, scene, MAX_DUPLI_RECUR); - for(pid=pidlist.first; pid; pid=pid->next) { - if(pid->cache == cache) { - if(pid->ptcaches->first == pid->ptcaches->last) + for (pid=pidlist.first; pid; pid=pid->next) { + if (pid->cache == cache) { + if (pid->ptcaches->first == pid->ptcaches->last) continue; /* don't delete last cache */ BLI_remlink(pid->ptcaches, pid->cache); diff --git a/source/blender/editors/render/render_internal.c b/source/blender/editors/render/render_internal.c index f3ef0f3cd64..465a2e37269 100644 --- a/source/blender/editors/render/render_internal.c +++ b/source/blender/editors/render/render_internal.c @@ -82,20 +82,20 @@ void image_buffer_rect_update(Scene *scene, RenderResult *rr, ImBuf *ibuf, volat unsigned char *rectc; /* if renrect argument, we only refresh scanlines */ - if(renrect) { + if (renrect) { /* if ymax==recty, rendering of layer is ready, we should not draw, other things happen... */ - if(rr->renlay==NULL || renrect->ymax>=rr->recty) + if (rr->renlay==NULL || renrect->ymax>=rr->recty) return; /* xmin here is first subrect x coord, xmax defines subrect width */ xmin = renrect->xmin + rr->crop; xmax = renrect->xmax - xmin + rr->crop; - if(xmax<2) + if (xmax<2) return; ymin= renrect->ymin + rr->crop; ymax= renrect->ymax - ymin + rr->crop; - if(ymax<2) + if (ymax<2) return; renrect->ymin = renrect->ymax; @@ -108,37 +108,37 @@ void image_buffer_rect_update(Scene *scene, RenderResult *rr, ImBuf *ibuf, volat /* xmin ymin is in tile coords. transform to ibuf */ rxmin= rr->tilerect.xmin + xmin; - if(rxmin >= ibuf->x) return; + if (rxmin >= ibuf->x) return; rymin= rr->tilerect.ymin + ymin; - if(rymin >= ibuf->y) return; + if (rymin >= ibuf->y) return; - if(rxmin + xmax > ibuf->x) + if (rxmin + xmax > ibuf->x) xmax= ibuf->x - rxmin; - if(rymin + ymax > ibuf->y) + if (rymin + ymax > ibuf->y) ymax= ibuf->y - rymin; - if(xmax < 1 || ymax < 1) return; + if (xmax < 1 || ymax < 1) return; /* find current float rect for display, first case is after composite... still weak */ - if(rr->rectf) + if (rr->rectf) rectf= rr->rectf; else { - if(rr->rect32) + if (rr->rect32) return; else { - if(rr->renlay==NULL || rr->renlay->rectf==NULL) return; + if (rr->renlay==NULL || rr->renlay->rectf==NULL) return; rectf= rr->renlay->rectf; } } - if(rectf==NULL) return; + if (rectf==NULL) return; - if(ibuf->rect==NULL) + if (ibuf->rect==NULL) imb_addrectImBuf(ibuf); rectf+= 4*(rr->rectx*ymin + xmin); rectc= (unsigned char*)(ibuf->rect + ibuf->x*rymin + rxmin); - if(scene && (scene->r.color_mgt_flag & R_COLOR_MANAGEMENT)) { + if (scene && (scene->r.color_mgt_flag & R_COLOR_MANAGEMENT)) { profile_from= IB_PROFILE_LINEAR_RGB; predivide= (scene->r.color_mgt_flag & R_COLOR_MANAGEMENT_PREDIVIDE); } @@ -160,7 +160,7 @@ void image_buffer_rect_update(Scene *scene, RenderResult *rr, ImBuf *ibuf, volat static void screen_render_scene_layer_set(wmOperator *op, Main *mainp, Scene **scene, SceneRenderLayer **srl) { /* single layer re-render */ - if(RNA_struct_property_is_set(op->ptr, "scene")) { + if (RNA_struct_property_is_set(op->ptr, "scene")) { Scene *scn; char scene_name[MAX_ID_NAME-2]; @@ -176,7 +176,7 @@ static void screen_render_scene_layer_set(wmOperator *op, Main *mainp, Scene **s } } - if(RNA_struct_property_is_set(op->ptr, "layer")) { + if (RNA_struct_property_is_set(op->ptr, "layer")) { SceneRenderLayer *rl; char rl_name[RE_MAXNAME]; @@ -205,7 +205,7 @@ static int screen_render_exec(bContext *C, wmOperator *op) /* custom scene and single layer re-render */ screen_render_scene_layer_set(op, mainp, &scene, &srl); - if(!is_animation && is_write_still && BKE_imtype_is_movie(scene->r.im_format.imtype)) { + if (!is_animation && is_write_still && BKE_imtype_is_movie(scene->r.im_format.imtype)) { BKE_report(op->reports, RPT_ERROR, "Can't write a single file with an animation format selected"); return OPERATOR_CANCELLED; } @@ -228,7 +228,7 @@ static int screen_render_exec(bContext *C, wmOperator *op) RE_SetReports(re, op->reports); - if(is_animation) + if (is_animation) RE_BlenderAnim(re, mainp, scene, camera_override, lay, scene->r.sfra, scene->r.efra, scene->r.frame_step); else RE_BlenderFrame(re, mainp, scene, srl, camera_override, lay, scene->r.cfra, is_write_still); @@ -283,40 +283,40 @@ static void make_renderinfo_string(RenderStats *rs, Scene *scene, char *str) mmap_used_memory= (mmap_in_use)/(1024.0*1024.0); megs_peak_memory = (peak_memory)/(1024.0*1024.0); - if(scene->lay & 0xFF000000) + if (scene->lay & 0xFF000000) spos+= sprintf(spos, "Localview | "); - else if(scene->r.scemode & R_SINGLE_LAYER) + else if (scene->r.scemode & R_SINGLE_LAYER) spos+= sprintf(spos, "Single Layer | "); - if(rs->statstr) { + if (rs->statstr) { spos+= sprintf(spos, "%s ", rs->statstr); } else { spos+= sprintf(spos, "Fra:%d ", (scene->r.cfra)); - if(rs->totvert) spos+= sprintf(spos, "Ve:%d ", rs->totvert); - if(rs->totface) spos+= sprintf(spos, "Fa:%d ", rs->totface); - if(rs->tothalo) spos+= sprintf(spos, "Ha:%d ", rs->tothalo); - if(rs->totstrand) spos+= sprintf(spos, "St:%d ", rs->totstrand); - if(rs->totlamp) spos+= sprintf(spos, "La:%d ", rs->totlamp); + if (rs->totvert) spos+= sprintf(spos, "Ve:%d ", rs->totvert); + if (rs->totface) spos+= sprintf(spos, "Fa:%d ", rs->totface); + if (rs->tothalo) spos+= sprintf(spos, "Ha:%d ", rs->tothalo); + if (rs->totstrand) spos+= sprintf(spos, "St:%d ", rs->totstrand); + if (rs->totlamp) spos+= sprintf(spos, "La:%d ", rs->totlamp); spos+= sprintf(spos, "Mem:%.2fM (%.2fM, peak %.2fM) ", megs_used_memory, mmap_used_memory, megs_peak_memory); - if(rs->curfield) + if (rs->curfield) spos+= sprintf(spos, "Field %d ", rs->curfield); - if(rs->curblur) + if (rs->curblur) spos+= sprintf(spos, "Blur %d ", rs->curblur); } BLI_timestr(rs->lastframetime, info_time_str); spos+= sprintf(spos, "Time:%s ", info_time_str); - if(rs->curfsa) + if (rs->curfsa) spos+= sprintf(spos, "| Full Sample %d ", rs->curfsa); - if(rs->infostr && rs->infostr[0]) + if (rs->infostr && rs->infostr[0]) spos+= sprintf(spos, "| %s ", rs->infostr); /* very weak... but 512 characters is quite safe */ - if(spos >= str+IMA_MAX_RENDER_TEXT) + if (spos >= str+IMA_MAX_RENDER_TEXT) if (G.f & G_DEBUG) printf("WARNING! renderwin text beyond limit \n"); @@ -329,9 +329,9 @@ static void image_renderinfo_cb(void *rjv, RenderStats *rs) rr= RE_AcquireResultRead(rj->re); - if(rr) { + if (rr) { /* malloc OK here, stats_draw is not in tile threads */ - if(rr->text==NULL) + if (rr->text==NULL) rr->text= MEM_callocN(IMA_MAX_RENDER_TEXT, "rendertext"); make_renderinfo_string(rs, rj->scene, rr->text); @@ -348,7 +348,7 @@ static void render_progress_update(void *rjv, float progress) { RenderJob *rj= rjv; - if(rj->progress && *rj->progress != progress) { + if (rj->progress && *rj->progress != progress) { *rj->progress = progress; /* make jobs timer to send notifier */ @@ -364,11 +364,11 @@ static void image_rect_update(void *rjv, RenderResult *rr, volatile rcti *renrec void *lock; /* only update if we are displaying the slot being rendered */ - if(ima->render_slot != ima->last_render_slot) + if (ima->render_slot != ima->last_render_slot) return; ibuf= BKE_image_acquire_ibuf(ima, &rj->iuser, &lock); - if(ibuf) { + if (ibuf) { image_buffer_rect_update(rj->scene, rr, ibuf, renrect); /* make jobs timer to send notifier */ @@ -387,7 +387,7 @@ static void render_startjob(void *rjv, short *stop, short *do_update, float *pro RE_SetReports(rj->re, rj->reports); - if(rj->anim) + if (rj->anim) RE_BlenderAnim(rj->re, rj->main, rj->scene, rj->camera_override, rj->lay, rj->scene->r.sfra, rj->scene->r.efra, rj->scene->r.frame_step); else RE_BlenderFrame(rj->re, rj->main, rj->scene, rj->srl, rj->camera_override, rj->lay, rj->scene->r.cfra, rj->write_still); @@ -403,11 +403,11 @@ static void render_endjob(void *rjv) * would be re-assigned. assign dummy callbacks to avoid referencing freed renderjobs bug [#24508] */ RE_InitRenderCB(rj->re); - if(rj->main != G.main) + if (rj->main != G.main) free_main(rj->main); /* else the frame will not update for the original value */ - if(!(rj->scene->r.scemode & R_NO_FRAME_UPDATE)) + if (!(rj->scene->r.scemode & R_NO_FRAME_UPDATE)) ED_update_for_newframe(G.main, rj->scene, rj->win->screen, 1); /* XXX above function sets all tags in nodes */ @@ -416,7 +416,7 @@ static void render_endjob(void *rjv) /* potentially set by caller */ rj->scene->r.scemode &= ~R_NO_FRAME_UPDATE; - if(rj->srl) { + if (rj->srl) { nodeUpdateID(rj->scene->nodetree, &rj->scene->id); WM_main_add_notifier(NC_NODE|NA_EDITED, rj->scene); } @@ -431,9 +431,9 @@ static int render_breakjob(void *rjv) { RenderJob *rj= rjv; - if(G.afbreek) + if (G.afbreek) return 1; - if(rj->stop && *(rj->stop)) + if (rj->stop && *(rj->stop)) return 1; return 0; } @@ -450,7 +450,7 @@ static void render_drawlock(void *UNUSED(rjv), int lock) static int screen_render_modal(bContext *C, wmOperator *UNUSED(op), wmEvent *event) { /* no running blender, remove handler and pass through */ - if(0==WM_jobs_test(CTX_wm_manager(C), CTX_data_scene(C))) { + if (0==WM_jobs_test(CTX_wm_manager(C), CTX_data_scene(C))) { return OPERATOR_FINISHED|OPERATOR_PASS_THROUGH; } @@ -483,14 +483,14 @@ static int screen_render_invoke(bContext *C, wmOperator *op, wmEvent *event) const char *name; /* only one render job at a time */ - if(WM_jobs_test(CTX_wm_manager(C), scene)) + if (WM_jobs_test(CTX_wm_manager(C), scene)) return OPERATOR_CANCELLED; - if(!RE_is_rendering_allowed(scene, camera_override, op->reports)) { + if (!RE_is_rendering_allowed(scene, camera_override, op->reports)) { return OPERATOR_CANCELLED; } - if(!is_animation && is_write_still && BKE_imtype_is_movie(scene->r.im_format.imtype)) { + if (!is_animation && is_write_still && BKE_imtype_is_movie(scene->r.im_format.imtype)) { BKE_report(op->reports, RPT_ERROR, "Can't write a single file with an animation format selected"); return OPERATOR_CANCELLED; } @@ -499,7 +499,7 @@ static int screen_render_invoke(bContext *C, wmOperator *op, wmEvent *event) WM_jobs_stop_all(CTX_wm_manager(C)); /* get main */ - if(G.rt == 101) { + if (G.rt == 101) { /* thread-safety experiment, copy main from the undo buffer */ mainp= BKE_undo_get_main(&scene); } @@ -537,7 +537,7 @@ static int screen_render_invoke(bContext *C, wmOperator *op, wmEvent *event) /* custom scene and single layer re-render */ screen_render_scene_layer_set(op, mainp, &scene, &srl); - if(RNA_struct_property_is_set(op->ptr, "layer")) + if (RNA_struct_property_is_set(op->ptr, "layer")) jobflag |= WM_JOB_SUSPEND; /* job custom data */ @@ -555,7 +555,7 @@ static int screen_render_invoke(bContext *C, wmOperator *op, wmEvent *event) rj->reports= op->reports; /* setup job */ - if(RE_seq_render_active(scene, &scene->r)) name= "Sequence Render"; + if (RE_seq_render_active(scene, &scene->r)) name= "Sequence Render"; else name= "Render"; steve= WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), scene, name, jobflag); diff --git a/source/blender/editors/render/render_opengl.c b/source/blender/editors/render/render_opengl.c index 53c4b232326..26996893ae5 100644 --- a/source/blender/editors/render/render_opengl.c +++ b/source/blender/editors/render/render_opengl.c @@ -104,7 +104,7 @@ typedef struct OGLRender { /* added because v3d is not always valid */ static unsigned int screen_opengl_layers(OGLRender *oglrender) { - if(oglrender->v3d) { + if (oglrender->v3d) { return oglrender->scene->lay | oglrender->v3d->lay; } else { @@ -129,11 +129,11 @@ static void screen_opengl_render_apply(OGLRender *oglrender) rr= RE_AcquireResultRead(oglrender->re); - if(view_context) { + if (view_context) { GPU_offscreen_bind(oglrender->ofs); /* bind */ /* render 3d view */ - if(rv3d->persp==RV3D_CAMOB && v3d->camera) { + if (rv3d->persp==RV3D_CAMOB && v3d->camera) { /*int is_ortho= scene->r.mode & R_ORTHO;*/ camera= v3d->camera; RE_GetCameraWindow(oglrender->re, camera, scene->r.cfra, winmat); @@ -144,11 +144,11 @@ static void screen_opengl_render_apply(OGLRender *oglrender) float clipsta, clipend; int is_ortho= ED_view3d_viewplane_get(v3d, rv3d, sizex, sizey, &viewplane, &clipsta, &clipend); - if(is_ortho) orthographic_m4(winmat, viewplane.xmin, viewplane.xmax, viewplane.ymin, viewplane.ymax, -clipend, clipend); + if (is_ortho) orthographic_m4(winmat, viewplane.xmin, viewplane.xmax, viewplane.ymin, viewplane.ymax, -clipend, clipend); else perspective_m4(winmat, viewplane.xmin, viewplane.xmax, viewplane.ymin, viewplane.ymax, clipsta, clipend); } - if((scene->r.mode & R_OSA) == 0) { + if ((scene->r.mode & R_OSA) == 0) { ED_view3d_draw_offscreen(scene, v3d, ar, sizex, sizey, NULL, winmat, TRUE); GPU_offscreen_read_pixels(oglrender->ofs, GL_FLOAT, rr->rectf); } @@ -167,7 +167,7 @@ static void screen_opengl_render_apply(OGLRender *oglrender) GPU_offscreen_read_pixels(oglrender->ofs, GL_FLOAT, accum_buffer); /* skip the first sample */ - for(j=1; j < scene->r.osa; j++) { + for (j=1; j < scene->r.osa; j++) { copy_m4_m4(winmat_jitter, winmat); window_translate_m4(winmat_jitter, rv3d->persmat, (jit_ofs[j][0] * 2.0f) / sizex, @@ -192,7 +192,7 @@ static void screen_opengl_render_apply(OGLRender *oglrender) ImBuf *ibuf_view= ED_view3d_draw_offscreen_imbuf_simple(scene, scene->camera, oglrender->sizex, oglrender->sizey, IB_rectfloat, OB_SOLID, TRUE, err_out); camera= scene->camera; - if(ibuf_view) { + if (ibuf_view) { memcpy(rr->rectf, ibuf_view->rect_float, sizeof(float) * 4 * oglrender->sizex * oglrender->sizey); IMB_freeImBuf(ibuf_view); } @@ -203,7 +203,7 @@ static void screen_opengl_render_apply(OGLRender *oglrender) /* rr->rectf is now filled with image data */ - if((scene->r.stamp & R_STAMP_ALL) && (scene->r.stamp & R_STAMP_DRAW)) + if ((scene->r.stamp & R_STAMP_ALL) && (scene->r.stamp & R_STAMP_DRAW)) BKE_stamp_buf(scene, camera, NULL, rr->rectf, rr->rectx, rr->recty, 4); /* note on color management: @@ -214,7 +214,7 @@ static void screen_opengl_render_apply(OGLRender *oglrender) * sRGB again, and so that e.g. openexr saving also saves the correct linear * float buffer. */ - if(oglrender->scene->r.color_mgt_flag & R_COLOR_MANAGEMENT) { + if (oglrender->scene->r.color_mgt_flag & R_COLOR_MANAGEMENT) { int predivide= 0; /* no alpha */ IMB_buffer_float_from_float(rr->rectf, rr->rectf, @@ -227,20 +227,20 @@ static void screen_opengl_render_apply(OGLRender *oglrender) /* update byte from float buffer */ ibuf= BKE_image_acquire_ibuf(oglrender->ima, &oglrender->iuser, &lock); - if(ibuf) { + if (ibuf) { image_buffer_rect_update(scene, rr, ibuf, NULL); - if(oglrender->write_still) { + if (oglrender->write_still) { char name[FILE_MAX]; int ok; - if(scene->r.im_format.planes == R_IMF_CHAN_DEPTH_8) { + if (scene->r.im_format.planes == R_IMF_CHAN_DEPTH_8) { IMB_color_to_bw(ibuf); } BKE_makepicstring(name, scene->r.pic, oglrender->bmain->name, scene->r.cfra, scene->r.im_format.imtype, scene->r.scemode & R_EXTENSION, FALSE); ok= BKE_write_ibuf_as(ibuf, name, &scene->r.im_format, TRUE); /* no need to stamp here */ - if(ok) printf("OpenGL Render written to '%s'\n", name); + if (ok) printf("OpenGL Render written to '%s'\n", name); else printf("OpenGL Render failed to write '%s'\n", name); } } @@ -263,28 +263,28 @@ static int screen_opengl_render_init(bContext *C, wmOperator *op) const short is_write_still= RNA_boolean_get(op->ptr, "write_still"); char err_out[256]= "unknown"; - if(G.background) { + if (G.background) { BKE_report(op->reports, RPT_ERROR, "Can't use OpenGL render in background mode (no opengl context)"); return 0; } /* ensure we have a 3d view */ - if(!ED_view3d_context_activate(C)) { + if (!ED_view3d_context_activate(C)) { RNA_boolean_set(op->ptr, "view_context", FALSE); is_view_context = 0; } /* only one render job at a time */ - if(WM_jobs_test(CTX_wm_manager(C), scene)) + if (WM_jobs_test(CTX_wm_manager(C), scene)) return 0; - if(!is_view_context && scene->camera==NULL) { + if (!is_view_context && scene->camera==NULL) { BKE_report(op->reports, RPT_ERROR, "Scene has no camera"); return 0; } - if(!is_animation && is_write_still && BKE_imtype_is_movie(scene->r.im_format.imtype)) { + if (!is_animation && is_write_still && BKE_imtype_is_movie(scene->r.im_format.imtype)) { BKE_report(op->reports, RPT_ERROR, "Can't write a single file with an animation format selected"); return 0; } @@ -302,7 +302,7 @@ static int screen_opengl_render_init(bContext *C, wmOperator *op) /* corrects render size with actual size, not every card supports non-power-of-two dimensions */ ofs= GPU_offscreen_create(sizex, sizey, err_out); - if(!ofs) { + if (!ofs) { BKE_reportf(op->reports, RPT_ERROR, "Failed to create OpenGL offscreen buffer, %s", err_out); return 0; } @@ -326,7 +326,7 @@ static int screen_opengl_render_init(bContext *C, wmOperator *op) oglrender->prevsa= prevsa; oglrender->prevar= prevar; - if(is_view_context) { + if (is_view_context) { ED_view3d_context_user_region(C, &oglrender->v3d, &oglrender->ar); /* so quad view renders camera */ oglrender->rv3d= oglrender->ar->regiondata; @@ -355,7 +355,7 @@ static int screen_opengl_render_init(bContext *C, wmOperator *op) RE_InitState(oglrender->re, NULL, &scene->r, NULL, sizex, sizey, NULL); rr= RE_AcquireResultWrite(oglrender->re); - if(rr->rectf==NULL) + if (rr->rectf==NULL) rr->rectf= MEM_callocN(sizeof(float)*4*sizex*sizey, "screen_opengl_render_init rect"); RE_ReleaseResult(oglrender->re); @@ -367,12 +367,12 @@ static void screen_opengl_render_end(bContext *C, OGLRender *oglrender) Main *bmain= CTX_data_main(C); Scene *scene= oglrender->scene; - if(oglrender->mh) { - if(BKE_imtype_is_movie(scene->r.im_format.imtype)) + if (oglrender->mh) { + if (BKE_imtype_is_movie(scene->r.im_format.imtype)) oglrender->mh->end_movie(); } - if(oglrender->timer) { /* exec will not have a timer */ + if (oglrender->timer) { /* exec will not have a timer */ scene->r.cfra= oglrender->cfrao; scene_update_for_newframe(bmain, scene, screen_opengl_layers(oglrender)); @@ -413,8 +413,8 @@ static int screen_opengl_render_anim_initialize(bContext *C, wmOperator *op) oglrender->reports= op->reports; oglrender->mh= BKE_get_movie_handle(scene->r.im_format.imtype); - if(BKE_imtype_is_movie(scene->r.im_format.imtype)) { - if(!oglrender->mh->start_movie(scene, &scene->r, oglrender->sizex, oglrender->sizey, oglrender->reports)) { + if (BKE_imtype_is_movie(scene->r.im_format.imtype)) { + if (!oglrender->mh->start_movie(scene, &scene->r, oglrender->sizex, oglrender->sizey, oglrender->reports)) { screen_opengl_render_end(C, oglrender); return 0; } @@ -443,10 +443,10 @@ static int screen_opengl_render_anim_step(bContext *C, wmOperator *op) ED_image_update_frame(bmain, scene->r.cfra); /* go to next frame */ - while(CFRAnfra) { + while (CFRAnfra) { unsigned int lay= screen_opengl_layers(oglrender); - if(lay & 0xFF000000) + if (lay & 0xFF000000) lay &= 0xFF000000; scene_update_for_newframe(bmain, scene, lay); @@ -455,11 +455,11 @@ static int screen_opengl_render_anim_step(bContext *C, wmOperator *op) scene_update_for_newframe(bmain, scene, screen_opengl_layers(oglrender)); - if(view_context) { - if(oglrender->rv3d->persp==RV3D_CAMOB && oglrender->v3d->camera && oglrender->v3d->scenelock) { + if (view_context) { + if (oglrender->rv3d->persp==RV3D_CAMOB && oglrender->v3d->camera && oglrender->v3d->scenelock) { /* since scene_update_for_newframe() is used rather * then ED_update_for_newframe() the camera needs to be set */ - if(scene_camera_switch_update(scene)) { + if (scene_camera_switch_update(scene)) { oglrender->v3d->camera= scene->camera; } @@ -478,10 +478,10 @@ static int screen_opengl_render_anim_step(bContext *C, wmOperator *op) /* save to disk */ ibuf= BKE_image_acquire_ibuf(oglrender->ima, &oglrender->iuser, &lock); - if(ibuf) { + if (ibuf) { /* color -> greyscale */ /* editing directly would alter the render view */ - if(scene->r.im_format.planes == R_IMF_PLANES_BW) { + if (scene->r.im_format.planes == R_IMF_PLANES_BW) { ImBuf *ibuf_bw= IMB_dupImBuf(ibuf); IMB_color_to_bw(ibuf_bw); // IMB_freeImBuf(ibuf); /* owned by the image */ @@ -497,10 +497,10 @@ static int screen_opengl_render_anim_step(bContext *C, wmOperator *op) ibuf= ibuf_cpy; } - if(BKE_imtype_is_movie(scene->r.im_format.imtype)) { + if (BKE_imtype_is_movie(scene->r.im_format.imtype)) { ok= oglrender->mh->append_movie(&scene->r, SFRA, CFRA, (int*)ibuf->rect, oglrender->sizex, oglrender->sizey, oglrender->reports); - if(ok) { + if (ok) { printf("Append frame %d", scene->r.cfra); BKE_reportf(op->reports, RPT_INFO, "Appended frame: %d", scene->r.cfra); } @@ -509,7 +509,7 @@ static int screen_opengl_render_anim_step(bContext *C, wmOperator *op) BKE_makepicstring(name, scene->r.pic, oglrender->bmain->name, scene->r.cfra, scene->r.im_format.imtype, scene->r.scemode & R_EXTENSION, TRUE); ok= BKE_write_ibuf_stamp(scene, camera, ibuf, name, &scene->r.im_format); - if(ok==0) { + if (ok==0) { printf("Write error: cannot save %s\n", name); BKE_reportf(op->reports, RPT_ERROR, "Write error: cannot save %s", name); } @@ -533,7 +533,7 @@ static int screen_opengl_render_anim_step(bContext *C, wmOperator *op) scene->r.cfra++; /* stop at the end or on error */ - if(scene->r.cfra > PEFRA || !ok) { + if (scene->r.cfra > PEFRA || !ok) { screen_opengl_render_end(C, op->customdata); return 0; } @@ -555,7 +555,7 @@ static int screen_opengl_render_modal(bContext *C, wmOperator *op, wmEvent *even return OPERATOR_FINISHED; case TIMER: /* render frame? */ - if(oglrender->timer == event->customdata) + if (oglrender->timer == event->customdata) break; default: /* nothing to do */ @@ -565,7 +565,7 @@ static int screen_opengl_render_modal(bContext *C, wmOperator *op, wmEvent *even /* run first because screen_opengl_render_anim_step can free oglrender */ WM_event_add_notifier(C, NC_SCENE|ND_RENDER_RESULT, oglrender->scene); - if(anim == 0) { + if (anim == 0) { screen_opengl_render_apply(op->customdata); screen_opengl_render_end(C, op->customdata); return OPERATOR_FINISHED; @@ -574,7 +574,7 @@ static int screen_opengl_render_modal(bContext *C, wmOperator *op, wmEvent *even ret= screen_opengl_render_anim_step(C, op); /* stop at the end or on error */ - if(ret == 0) { + if (ret == 0) { return OPERATOR_FINISHED; } @@ -586,11 +586,11 @@ static int screen_opengl_render_invoke(bContext *C, wmOperator *op, wmEvent *eve OGLRender *oglrender; int anim= RNA_boolean_get(op->ptr, "animation"); - if(!screen_opengl_render_init(C, op)) + if (!screen_opengl_render_init(C, op)) return OPERATOR_CANCELLED; - if(anim) { - if(!screen_opengl_render_anim_initialize(C, op)) + if (anim) { + if (!screen_opengl_render_anim_initialize(C, op)) return OPERATOR_CANCELLED; } @@ -608,10 +608,10 @@ static int screen_opengl_render_exec(bContext *C, wmOperator *op) { const short is_animation= RNA_boolean_get(op->ptr, "animation"); - if(!screen_opengl_render_init(C, op)) + if (!screen_opengl_render_init(C, op)) return OPERATOR_CANCELLED; - if(!is_animation) { /* same as invoke */ + if (!is_animation) { /* same as invoke */ /* render image */ screen_opengl_render_apply(op->customdata); screen_opengl_render_end(C, op->customdata); @@ -621,10 +621,10 @@ static int screen_opengl_render_exec(bContext *C, wmOperator *op) else { int ret= 1; - if(!screen_opengl_render_anim_initialize(C, op)) + if (!screen_opengl_render_anim_initialize(C, op)) return OPERATOR_CANCELLED; - while(ret) { + while (ret) { ret= screen_opengl_render_anim_step(C, op); } } diff --git a/source/blender/editors/render/render_preview.c b/source/blender/editors/render/render_preview.c index 8cdde5f160f..9ba961302f1 100644 --- a/source/blender/editors/render/render_preview.c +++ b/source/blender/editors/render/render_preview.c @@ -202,29 +202,29 @@ void ED_preview_init_dbase(void) void ED_preview_free_dbase(void) { - if(pr_main) + if (pr_main) free_main(pr_main); } static int preview_mat_has_sss(Material *mat, bNodeTree *ntree) { - if(mat) { - if(mat->sss_flag & MA_DIFF_SSS) + if (mat) { + if (mat->sss_flag & MA_DIFF_SSS) return 1; - if(mat->nodetree) - if( preview_mat_has_sss(NULL, mat->nodetree)) + if (mat->nodetree) + if ( preview_mat_has_sss(NULL, mat->nodetree)) return 1; } - else if(ntree) { + else if (ntree) { bNode *node; - for(node= ntree->nodes.first; node; node= node->next) { - if(node->type==NODE_GROUP && node->id) { - if( preview_mat_has_sss(NULL, (bNodeTree *)node->id)) + for (node= ntree->nodes.first; node; node= node->next) { + if (node->type==NODE_GROUP && node->id) { + if ( preview_mat_has_sss(NULL, (bNodeTree *)node->id)) return 1; } - else if(node->id && ELEM(node->type, SH_NODE_MATERIAL, SH_NODE_MATERIAL_EXT)) { + else if (node->id && ELEM(node->type, SH_NODE_MATERIAL, SH_NODE_MATERIAL_EXT)) { mat= (Material *)node->id; - if(mat->sss_flag & MA_DIFF_SSS) + if (mat->sss_flag & MA_DIFF_SSS) return 1; } } @@ -239,17 +239,17 @@ static Scene *preview_prepare_scene(Scene *scene, ID *id, int id_type, ShaderPre Scene *sce; Base *base; - if(pr_main==NULL) return NULL; + if (pr_main==NULL) return NULL; sce= pr_main->scene.first; - if(sce) { + if (sce) { /* this flag tells render to not execute depsgraph or ipos etc */ sce->r.scemode |= R_PREVIEWBUTS; /* set world always back, is used now */ sce->world= pr_main->world.first; /* now: exposure copy */ - if(scene->world) { + if (scene->world) { sce->world->exp= scene->world->exp; sce->world->range= scene->world->range; } @@ -257,16 +257,16 @@ static Scene *preview_prepare_scene(Scene *scene, ID *id, int id_type, ShaderPre sce->r.color_mgt_flag = scene->r.color_mgt_flag; /* prevent overhead for small renders and icons (32) */ - if(id && sp->sizex < 40) + if (id && sp->sizex < 40) sce->r.xparts= sce->r.yparts= 1; else sce->r.xparts= sce->r.yparts= 4; /* exception: don't color manage texture previews or icons */ - if((id && sp->pr_method==PR_ICON_RENDER) || id_type == ID_TE) + if ((id && sp->pr_method==PR_ICON_RENDER) || id_type == ID_TE) sce->r.color_mgt_flag &= ~R_COLOR_MANAGEMENT; - if((id && sp->pr_method==PR_ICON_RENDER) && id_type != ID_WO) + if ((id && sp->pr_method==PR_ICON_RENDER) && id_type != ID_WO) sce->r.alphamode= R_ALPHAPREMUL; else sce->r.alphamode= R_ADDSKY; @@ -274,10 +274,10 @@ static Scene *preview_prepare_scene(Scene *scene, ID *id, int id_type, ShaderPre sce->r.cfra= scene->r.cfra; BLI_strncpy(sce->r.engine, scene->r.engine, sizeof(sce->r.engine)); - if(id_type==ID_MA) { + if (id_type==ID_MA) { Material *mat= NULL, *origmat= (Material *)id; - if(origmat) { + if (origmat) { /* work on a copy */ mat= localize_material(origmat); sp->matcopy= mat; @@ -287,27 +287,27 @@ static Scene *preview_prepare_scene(Scene *scene, ID *id, int id_type, ShaderPre end_render_material(mat); /* un-useful option */ - if(sp->pr_method==PR_ICON_RENDER) + if (sp->pr_method==PR_ICON_RENDER) mat->shade_flag &= ~MA_OBCOLOR; /* turn on raytracing if needed */ - if(mat->mode_l & MA_RAYMIRROR) + if (mat->mode_l & MA_RAYMIRROR) sce->r.mode |= R_RAYTRACE; - if(mat->material_type == MA_TYPE_VOLUME) + if (mat->material_type == MA_TYPE_VOLUME) sce->r.mode |= R_RAYTRACE; - if((mat->mode_l & MA_RAYTRANSP) && (mat->mode_l & MA_TRANSP)) + if ((mat->mode_l & MA_RAYTRANSP) && (mat->mode_l & MA_TRANSP)) sce->r.mode |= R_RAYTRACE; - if(preview_mat_has_sss(mat, NULL)) + if (preview_mat_has_sss(mat, NULL)) sce->r.mode |= R_SSS; /* turn off fake shadows if needed */ /* this only works in a specific case where the preview.blend contains * an object starting with 'c' which has a material linked to it (not the obdata) * and that material has a fake shadow texture in the active texture slot */ - for(base= sce->base.first; base; base= base->next) { - if(base->object->id.name[2]=='c') { + for (base= sce->base.first; base; base= base->next) { + if (base->object->id.name[2]=='c') { Material *shadmat= give_current_material(base->object, base->object->actcol); - if(shadmat) { + if (shadmat) { if (mat->mode & MA_SHADBUF) shadmat->septex = 0; else shadmat->septex |= 1; } @@ -316,11 +316,11 @@ static Scene *preview_prepare_scene(Scene *scene, ID *id, int id_type, ShaderPre /* turn off bounce lights for volume, * doesn't make much visual difference and slows it down too */ - if(mat->material_type == MA_TYPE_VOLUME) { - for(base= sce->base.first; base; base= base->next) { - if(base->object->type == OB_LAMP) { + if (mat->material_type == MA_TYPE_VOLUME) { + for (base= sce->base.first; base; base= base->next) { + if (base->object->type == OB_LAMP) { /* if doesn't match 'Lamp.002' --> main key light */ - if( strcmp(base->object->id.name+2, "Lamp.002") != 0 ) { + if ( strcmp(base->object->id.name+2, "Lamp.002") != 0 ) { base->object->restrictflag |= OB_RESTRICT_RENDER; } } @@ -328,7 +328,7 @@ static Scene *preview_prepare_scene(Scene *scene, ID *id, int id_type, ShaderPre } - if(sp->pr_method==PR_ICON_RENDER) { + if (sp->pr_method==PR_ICON_RENDER) { if (mat->material_type == MA_TYPE_HALO) { sce->lay= 1<lay= 1<pr_type; - if(mat->nodetree && sp->pr_method==PR_NODE_RENDER) { + if (mat->nodetree && sp->pr_method==PR_NODE_RENDER) { /* two previews, they get copied by wmJob */ ntreeInitPreview(mat->nodetree, sp->sizex, sp->sizey); ntreeInitPreview(origmat->nodetree, sp->sizex, sp->sizey); @@ -350,45 +350,46 @@ static Scene *preview_prepare_scene(Scene *scene, ID *id, int id_type, ShaderPre } - for(base= sce->base.first; base; base= base->next) { - if(base->object->id.name[2]=='p') { + for (base= sce->base.first; base; base= base->next) { + if (base->object->id.name[2]=='p') { /* copy over object color, in case material uses it */ copy_v4_v4(base->object->col, sp->col); - if(OB_TYPE_SUPPORT_MATERIAL(base->object->type)) { + if (OB_TYPE_SUPPORT_MATERIAL(base->object->type)) { /* don't use assign_material, it changed mat->id.us, which shows in the UI */ Material ***matar= give_matarar(base->object); int actcol= MAX2(base->object->actcol > 0, 1) - 1; - if(matar && actcol < base->object->totcol) + if (matar && actcol < base->object->totcol) (*matar)[actcol]= mat; - } else if (base->object->type == OB_LAMP) { + } + else if (base->object->type == OB_LAMP) { base->object->restrictflag &= ~OB_RESTRICT_RENDER; } } } } - else if(id_type==ID_TE) { + else if (id_type==ID_TE) { Tex *tex= NULL, *origtex= (Tex *)id; - if(origtex) { + if (origtex) { tex= localize_texture(origtex); sp->texcopy= tex; BLI_addtail(&pr_main->tex, tex); } sce->lay= 1<base.first; base; base= base->next) { - if(base->object->id.name[2]=='t') { + for (base= sce->base.first; base; base= base->next) { + if (base->object->id.name[2]=='t') { Material *mat= give_current_material(base->object, base->object->actcol); - if(mat && mat->mtex[0]) { + if (mat && mat->mtex[0]) { mat->mtex[0]->tex= tex; - if(tex && sp->slot) + if (tex && sp->slot) mat->mtex[0]->which_output = sp->slot->which_output; /* show alpha in this case */ - if(tex==NULL || (tex->flag & TEX_PRV_ALPHA)) { + if (tex==NULL || (tex->flag & TEX_PRV_ALPHA)) { mat->mtex[0]->mapto |= MAP_ALPHA; mat->alpha= 0.0f; } @@ -400,23 +401,23 @@ static Scene *preview_prepare_scene(Scene *scene, ID *id, int id_type, ShaderPre } } - if(tex && tex->nodetree && sp->pr_method==PR_NODE_RENDER) { + if (tex && tex->nodetree && sp->pr_method==PR_NODE_RENDER) { /* two previews, they get copied by wmJob */ ntreeInitPreview(origtex->nodetree, sp->sizex, sp->sizey); ntreeInitPreview(tex->nodetree, sp->sizex, sp->sizey); } } - else if(id_type==ID_LA) { + else if (id_type==ID_LA) { Lamp *la= NULL, *origla= (Lamp *)id; /* work on a copy */ - if(origla) { + if (origla) { la= localize_lamp(origla); sp->lampcopy= la; BLI_addtail(&pr_main->lamp, la); } - if(la && la->type==LA_SUN && (la->sun_effect_type & LA_SUN_EFFECT_SKY)) { + if (la && la->type==LA_SUN && (la->sun_effect_type & LA_SUN_EFFECT_SKY)) { sce->lay= 1<world= scene->world; sce->camera= (Object *)BLI_findstring(&pr_main->object, "CameraAtmo", offsetof(ID, name)+2); @@ -428,23 +429,23 @@ static Scene *preview_prepare_scene(Scene *scene, ID *id, int id_type, ShaderPre } sce->r.mode &= ~R_SHADOW; - for(base= sce->base.first; base; base= base->next) { - if(base->object->id.name[2]=='p') { - if(base->object->type==OB_LAMP) + for (base= sce->base.first; base; base= base->next) { + if (base->object->id.name[2]=='p') { + if (base->object->type==OB_LAMP) base->object->data= la; } } - if(la && la->nodetree && sp->pr_method==PR_NODE_RENDER) { + if (la && la->nodetree && sp->pr_method==PR_NODE_RENDER) { /* two previews, they get copied by wmJob */ ntreeInitPreview(origla->nodetree, sp->sizex, sp->sizey); ntreeInitPreview(la->nodetree, sp->sizex, sp->sizey); } } - else if(id_type==ID_WO) { + else if (id_type==ID_WO) { World *wrld= NULL, *origwrld= (World *)id; - if(origwrld) { + if (origwrld) { wrld= localize_world(origwrld); sp->worldcopy= wrld; BLI_addtail(&pr_main->world, wrld); @@ -453,7 +454,7 @@ static Scene *preview_prepare_scene(Scene *scene, ID *id, int id_type, ShaderPre sce->lay= 1<world= wrld; - if(wrld && wrld->nodetree && sp->pr_method==PR_NODE_RENDER) { + if (wrld && wrld->nodetree && sp->pr_method==PR_NODE_RENDER) { /* two previews, they get copied by wmJob */ ntreeInitPreview(wrld->nodetree, sp->sizex, sp->sizey); ntreeInitPreview(origwrld->nodetree, sp->sizex, sp->sizey); @@ -484,11 +485,11 @@ static int ed_preview_draw_rect(ScrArea *sa, Scene *sce, ID *id, int split, int } } - if(!split || first) sprintf(name, "Preview %p", (void *)sa); + if (!split || first) sprintf(name, "Preview %p", (void *)sa); else sprintf(name, "SecondPreview %p", (void *)sa); - if(split) { - if(first) { + if (split) { + if (first) { offx= 0; newx= newx/2; } @@ -501,14 +502,14 @@ static int ed_preview_draw_rect(ScrArea *sa, Scene *sce, ID *id, int split, int re= RE_GetRender(name); RE_AcquireResultImage(re, &rres); - if(rres.rectf) { + if (rres.rectf) { - if(ABS(rres.rectx-newx)<2 && ABS(rres.recty-newy)<2) { + if (ABS(rres.rectx-newx)<2 && ABS(rres.recty-newy)<2) { newrect->xmax = MAX2(newrect->xmax, rect->xmin + rres.rectx + offx); newrect->ymax = MAX2(newrect->ymax, rect->ymin + rres.recty); - if(rres.rectx && rres.recty) { + if (rres.rectx && rres.recty) { /* temporary conversion to byte for drawing */ float fx= rect->xmin + offx; float fy= rect->ymin; @@ -538,7 +539,7 @@ static int ed_preview_draw_rect(ScrArea *sa, Scene *sce, ID *id, int split, int void ED_preview_draw(const bContext *C, void *idp, void *parentp, void *slotp, rcti *rect) { - if(idp) { + if (idp) { ScrArea *sa= CTX_wm_area(C); Scene *sce = CTX_data_scene(C); ID *id = (ID *)idp; @@ -554,23 +555,23 @@ void ED_preview_draw(const bContext *C, void *idp, void *parentp, void *slotp, r newrect.ymin = rect->ymin; newrect.ymax = rect->ymin; - if(parent) { + if (parent) { ok = ed_preview_draw_rect(sa, sce, id, 1, 1, rect, &newrect); ok &= ed_preview_draw_rect(sa, sce, parent, 1, 0, rect, &newrect); } else ok = ed_preview_draw_rect(sa, sce, id, 0, 0, rect, &newrect); - if(ok) + if (ok) *rect= newrect; /* check for spacetype... */ - if(sbuts->spacetype==SPACE_BUTS && sbuts->preview) { + if (sbuts->spacetype==SPACE_BUTS && sbuts->preview) { sbuts->preview= 0; ok= 0; } - if(ok==0) { + if (ok==0) { ED_preview_shader_job(C, sa, id, parent, slot, newx, newy, PR_BUTS_RENDER); } } @@ -599,30 +600,30 @@ static void shader_preview_updatejob(void *spv) { ShaderPreview *sp= spv; - if(sp->id) { - if(sp->pr_method==PR_NODE_RENDER) { - if( GS(sp->id->name) == ID_MA) { + if (sp->id) { + if (sp->pr_method==PR_NODE_RENDER) { + if ( GS(sp->id->name) == ID_MA) { Material *mat= (Material *)sp->id; - if(sp->matcopy && mat->nodetree && sp->matcopy->nodetree) + if (sp->matcopy && mat->nodetree && sp->matcopy->nodetree) ntreeLocalSync(sp->matcopy->nodetree, mat->nodetree); } - else if( GS(sp->id->name) == ID_TE) { + else if ( GS(sp->id->name) == ID_TE) { Tex *tex= (Tex *)sp->id; - if(sp->texcopy && tex->nodetree && sp->texcopy->nodetree) + if (sp->texcopy && tex->nodetree && sp->texcopy->nodetree) ntreeLocalSync(sp->texcopy->nodetree, tex->nodetree); } - else if( GS(sp->id->name) == ID_WO) { + else if ( GS(sp->id->name) == ID_WO) { World *wrld= (World *)sp->id; - if(sp->worldcopy && wrld->nodetree && sp->worldcopy->nodetree) + if (sp->worldcopy && wrld->nodetree && sp->worldcopy->nodetree) ntreeLocalSync(sp->worldcopy->nodetree, wrld->nodetree); } - else if( GS(sp->id->name) == ID_LA) { + else if ( GS(sp->id->name) == ID_LA) { Lamp *la= (Lamp *)sp->id; - if(sp->lampcopy && la->nodetree && sp->lampcopy->nodetree) + if (sp->lampcopy && la->nodetree && sp->lampcopy->nodetree) ntreeLocalSync(sp->lampcopy->nodetree, la->nodetree); } } @@ -640,27 +641,27 @@ static void shader_preview_render(ShaderPreview *sp, ID *id, int split, int firs /* get the stuff from the builtin preview dbase */ sce= preview_prepare_scene(sp->scene, id, idtype, sp); // XXX sizex - if(sce==NULL) return; + if (sce==NULL) return; - if(!split || first) sprintf(name, "Preview %p", sp->owner); + if (!split || first) sprintf(name, "Preview %p", sp->owner); else sprintf(name, "SecondPreview %p", sp->owner); re= RE_GetRender(name); /* full refreshed render from first tile */ - if(re==NULL) + if (re==NULL) re= RE_NewRender(name); /* sce->r gets copied in RE_InitState! */ sce->r.scemode &= ~(R_MATNODE_PREVIEW|R_TEXNODE_PREVIEW); sce->r.scemode &= ~R_NO_IMAGE_LOAD; - if(sp->pr_method==PR_ICON_RENDER) { + if (sp->pr_method==PR_ICON_RENDER) { sce->r.scemode |= R_NO_IMAGE_LOAD; sce->r.mode |= R_OSA; } - else if(sp->pr_method==PR_NODE_RENDER) { - if(idtype == ID_MA) sce->r.scemode |= R_MATNODE_PREVIEW; - else if(idtype == ID_TE) sce->r.scemode |= R_TEXNODE_PREVIEW; + else if (sp->pr_method==PR_NODE_RENDER) { + if (idtype == ID_MA) sce->r.scemode |= R_MATNODE_PREVIEW; + else if (idtype == ID_TE) sce->r.scemode |= R_TEXNODE_PREVIEW; sce->r.mode &= ~R_OSA; } else { /* PR_BUTS_RENDER */ @@ -668,8 +669,8 @@ static void shader_preview_render(ShaderPreview *sp, ID *id, int split, int firs } /* in case of split preview, use border render */ - if(split) { - if(first) sizex= sp->sizex/2; + if (split) { + if (first) sizex= sp->sizex/2; else sizex= sp->sizex - sp->sizex/2; } else sizex= sp->sizex; @@ -680,7 +681,7 @@ static void shader_preview_render(ShaderPreview *sp, ID *id, int split, int firs sce->r.size= 100; /* callbacs are cleared on GetRender() */ - if(ELEM(sp->pr_method, PR_BUTS_RENDER, PR_NODE_RENDER)) { + if (ELEM(sp->pr_method, PR_BUTS_RENDER, PR_NODE_RENDER)) { RE_display_draw_cb(re, sp, shader_preview_draw); } /* set this for all previews, default is react to G.afbreek still */ @@ -688,7 +689,7 @@ static void shader_preview_render(ShaderPreview *sp, ID *id, int split, int firs /* lens adjust */ oldlens= ((Camera *)sce->camera->data)->lens; - if(sizex > sp->sizey) + if (sizex > sp->sizey) ((Camera *)sce->camera->data)->lens *= (float)sp->sizey/(float)sizex; /* entire cycle for render engine */ @@ -697,10 +698,10 @@ static void shader_preview_render(ShaderPreview *sp, ID *id, int split, int firs ((Camera *)sce->camera->data)->lens= oldlens; /* handle results */ - if(sp->pr_method==PR_ICON_RENDER) { + if (sp->pr_method==PR_ICON_RENDER) { // char *rct= (char *)(sp->pr_rect + 32*16 + 16); - if(sp->pr_rect) + if (sp->pr_rect) RE_ResultGet32(re, sp->pr_rect); } else { @@ -714,9 +715,9 @@ static void shader_preview_render(ShaderPreview *sp, ID *id, int split, int firs preview_prepare_scene(sp->scene, NULL, GS(id->name), sp); /* XXX bad exception, end-exec is not being called in render, because it uses local main */ -// if(idtype == ID_TE) { +// if (idtype == ID_TE) { // Tex *tex= (Tex *)id; -// if(tex->use_nodes && tex->nodetree) +// if (tex->use_nodes && tex->nodetree) // ntreeEndExecTree(tex->nodetree); // } @@ -730,7 +731,7 @@ static void shader_preview_startjob(void *customdata, short *stop, short *do_upd sp->stop= stop; sp->do_update= do_update; - if(sp->parent) { + if (sp->parent) { shader_preview_render(sp, sp->id, 1, 1); shader_preview_render(sp, sp->parent, 1, 0); } @@ -744,7 +745,7 @@ static void shader_preview_free(void *customdata) { ShaderPreview *sp= customdata; - if(sp->matcopy) { + if (sp->matcopy) { struct IDProperty *properties; int a; @@ -755,9 +756,9 @@ static void shader_preview_free(void *customdata) BLI_remlink(&pr_main->mat, sp->matcopy); /* free_material decrements texture, prevent this. hack alert! */ - for(a=0; amatcopy->mtex[a]; - if(mtex && mtex->tex) mtex->tex= NULL; + if (mtex && mtex->tex) mtex->tex= NULL; } free_material(sp->matcopy); @@ -769,7 +770,7 @@ static void shader_preview_free(void *customdata) } MEM_freeN(sp->matcopy); } - if(sp->texcopy) { + if (sp->texcopy) { struct IDProperty *properties; /* node previews */ shader_preview_updatejob(sp); @@ -785,7 +786,7 @@ static void shader_preview_free(void *customdata) } MEM_freeN(sp->texcopy); } - if(sp->worldcopy) { + if (sp->worldcopy) { struct IDProperty *properties; /* node previews */ shader_preview_updatejob(sp); @@ -801,7 +802,7 @@ static void shader_preview_free(void *customdata) } MEM_freeN(sp->worldcopy); } - if(sp->lampcopy) { + if (sp->lampcopy) { struct IDProperty *properties; /* node previews */ shader_preview_updatejob(sp); @@ -831,7 +832,7 @@ static void icon_copy_rect(ImBuf *ibuf, unsigned int w, unsigned int h, unsigned short ex, ey, dx, dy; /* paranoia test */ - if(ibuf==NULL || (ibuf->rect==NULL && ibuf->rect_float==NULL)) + if (ibuf==NULL || (ibuf->rect==NULL && ibuf->rect_float==NULL)) return; /* waste of cpu cyles... but the imbuf API has no other way to scale fast (ton) */ @@ -858,14 +859,14 @@ static void icon_copy_rect(ImBuf *ibuf, unsigned int w, unsigned int h, unsigned IMB_scalefastImBuf(ima, ex, ey); /* if needed, convert to 32 bits */ - if(ima->rect==NULL) + if (ima->rect==NULL) IMB_rect_from_float(ima); srect = ima->rect; drect = rect; drect+= dy*w+dx; - for (;ey > 0; ey--){ + for (;ey > 0; ey--) { memcpy(drect,srect, ex * sizeof(int)); drect += w; srect += ima->x; @@ -878,7 +879,7 @@ static void set_alpha(char *cp, int sizex, int sizey, char alpha) { int a, size= sizex*sizey; - for(a=0; aid; short idtype= GS(id->name); - if(idtype == ID_IM) { + if (idtype == ID_IM) { Image *ima= (Image*)id; ImBuf *ibuf= NULL; ImageUser iuser= {NULL}; /* ima->ok is zero when Image cannot load */ - if(ima==NULL || ima->ok==0) + if (ima==NULL || ima->ok==0) return; /* setup dummy image user */ @@ -905,21 +906,21 @@ static void icon_preview_startjob(void *customdata, short *stop, short *do_updat * already there. Very expensive for large images. Need to find a way to * only get existing ibuf */ ibuf = BKE_image_get_ibuf(ima, &iuser); - if(ibuf==NULL || ibuf->rect==NULL) + if (ibuf==NULL || ibuf->rect==NULL) return; icon_copy_rect(ibuf, sp->sizex, sp->sizey, sp->pr_rect); *do_update= 1; } - else if(idtype == ID_BR) { + else if (idtype == ID_BR) { Brush *br= (Brush*)id; br->icon_imbuf= get_brush_icon(br); memset(sp->pr_rect, 0x888888, sp->sizex*sp->sizey*sizeof(unsigned int)); - if(!(br->icon_imbuf) || !(br->icon_imbuf->rect)) + if (!(br->icon_imbuf) || !(br->icon_imbuf->rect)) return; icon_copy_rect(br->icon_imbuf, sp->sizex, sp->sizey, sp->pr_rect); @@ -932,13 +933,13 @@ static void icon_preview_startjob(void *customdata, short *stop, short *do_updat /* world is rendered with alpha=0, so it wasn't displayed * this could be render option for sky to, for later */ - if(idtype == ID_WO) { + if (idtype == ID_WO) { set_alpha((char*)sp->pr_rect, sp->sizex, sp->sizey, 255); } - else if(idtype == ID_MA) { + else if (idtype == ID_MA) { Material* ma = (Material*)id; - if(ma->material_type == MA_TYPE_HALO) + if (ma->material_type == MA_TYPE_HALO) set_alpha((char*)sp->pr_rect, sp->sizex, sp->sizey, 255); } } @@ -951,7 +952,7 @@ static void common_preview_startjob(void *customdata, short *stop, short *do_upd { ShaderPreview *sp= customdata; - if(sp->pr_method == PR_ICON_RENDER) + if (sp->pr_method == PR_ICON_RENDER) icon_preview_startjob(customdata, stop, do_update); else shader_preview_startjob(customdata, stop, do_update); @@ -1069,7 +1070,7 @@ void ED_preview_shader_job(const bContext *C, void *owner, ID *id, ID *parent, M sp->id = id; sp->parent= parent; sp->slot= slot; - if(ob && ob->totcol) copy_v4_v4(sp->col, ob->col); + if (ob && ob->totcol) copy_v4_v4(sp->col, ob->col); else sp->col[0]= sp->col[1]= sp->col[2]= sp->col[3]= 1.0f; /* setup job */ @@ -1083,7 +1084,7 @@ void ED_preview_shader_job(const bContext *C, void *owner, ID *id, ID *parent, M void ED_preview_kill_jobs(const struct bContext *C) { wmWindowManager *wm= CTX_wm_manager(C); - if(wm) + if (wm) WM_jobs_kill(wm, NULL, common_preview_startjob); } diff --git a/source/blender/editors/render/render_shading.c b/source/blender/editors/render/render_shading.c index 2529e91d301..0aeeb0f71e2 100644 --- a/source/blender/editors/render/render_shading.c +++ b/source/blender/editors/render/render_shading.c @@ -95,7 +95,7 @@ static int material_slot_add_exec(bContext *C, wmOperator *UNUSED(op)) { Object *ob= ED_object_context(C); - if(!ob) + if (!ob) return OPERATOR_CANCELLED; object_add_material_slot(ob); @@ -124,11 +124,11 @@ static int material_slot_remove_exec(bContext *C, wmOperator *op) { Object *ob= ED_object_context(C); - if(!ob) + if (!ob) return OPERATOR_CANCELLED; /* Removing material slots in edit mode screws things up, see bug #21822.*/ - if(ob == CTX_data_edit_object(C)) { + if (ob == CTX_data_edit_object(C)) { BKE_report(op->reports, RPT_ERROR, "Unable to remove material slot in edit mode"); return OPERATOR_CANCELLED; } @@ -160,38 +160,38 @@ static int material_slot_assign_exec(bContext *C, wmOperator *UNUSED(op)) { Object *ob= ED_object_context(C); - if(!ob) + if (!ob) return OPERATOR_CANCELLED; - if(ob && ob->actcol>0) { - if(ob->type == OB_MESH) { + if (ob && ob->actcol>0) { + if (ob->type == OB_MESH) { BMEditMesh *em = BMEdit_FromObject(ob); BMFace *efa; BMIter iter; - if(em) { + if (em) { BM_ITER(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL) { - if(BM_elem_flag_test(efa, BM_ELEM_SELECT)) + if (BM_elem_flag_test(efa, BM_ELEM_SELECT)) efa->mat_nr= ob->actcol-1; } } } - else if(ELEM(ob->type, OB_CURVE, OB_SURF)) { + else if (ELEM(ob->type, OB_CURVE, OB_SURF)) { Nurb *nu; ListBase *nurbs= curve_editnurbs((Curve*)ob->data); - if(nurbs) { - for(nu= nurbs->first; nu; nu= nu->next) - if(isNurbsel(nu)) + if (nurbs) { + for (nu= nurbs->first; nu; nu= nu->next) + if (isNurbsel(nu)) nu->mat_nr= nu->charidx= ob->actcol-1; } } - else if(ob->type == OB_FONT) { + else if (ob->type == OB_FONT) { EditFont *ef= ((Curve*)ob->data)->editfont; int i, selstart, selend; - if(ef && BKE_font_getselection(ob, &selstart, &selend)) { - for(i=selstart; i<=selend; i++) + if (ef && BKE_font_getselection(ob, &selstart, &selend)) { + for (i=selstart; i<=selend; i++) ef->textbufinfo[i].mat_nr = ob->actcol; } } @@ -222,13 +222,13 @@ static int material_slot_de_select(bContext *C, int select) { Object *ob = ED_object_context(C); - if(!ob) + if (!ob) return OPERATOR_CANCELLED; - if(ob->type == OB_MESH) { + if (ob->type == OB_MESH) { BMEditMesh *em = BMEdit_FromObject(ob); - if(em) { + if (em) { EDBM_deselect_by_material(em, ob->actcol-1, select); } } @@ -239,15 +239,15 @@ static int material_slot_de_select(bContext *C, int select) BezTriple *bezt; int a; - if(nurbs) { - for(nu= nurbs->first; nu; nu=nu->next) { - if(nu->mat_nr==ob->actcol-1) { - if(nu->bezt) { + if (nurbs) { + for (nu= nurbs->first; nu; nu=nu->next) { + if (nu->mat_nr==ob->actcol-1) { + if (nu->bezt) { a= nu->pntsu; bezt= nu->bezt; - while(a--) { - if(bezt->hide==0) { - if(select) { + while (a--) { + if (bezt->hide==0) { + if (select) { bezt->f1 |= SELECT; bezt->f2 |= SELECT; bezt->f3 |= SELECT; @@ -261,12 +261,12 @@ static int material_slot_de_select(bContext *C, int select) bezt++; } } - else if(nu->bp) { + else if (nu->bp) { a= nu->pntsu*nu->pntsv; bp= nu->bp; - while(a--) { - if(bp->hide==0) { - if(select) bp->f1 |= SELECT; + while (a--) { + if (bp->hide==0) { + if (select) bp->f1 |= SELECT; else bp->f1 &= ~SELECT; } bp++; @@ -326,15 +326,15 @@ static int material_slot_copy_exec(bContext *C, wmOperator *UNUSED(op)) Object *ob= ED_object_context(C); Material ***matar; - if(!ob || !(matar= give_matarar(ob))) + if (!ob || !(matar= give_matarar(ob))) return OPERATOR_CANCELLED; CTX_DATA_BEGIN(C, Object*, ob_iter, selected_editable_objects) { - if(ob != ob_iter && give_matarar(ob_iter)) { + if (ob != ob_iter && give_matarar(ob_iter)) { if (ob->data != ob_iter->data) assign_matarar(ob_iter, matar, ob->totcol); - if(ob_iter->totcol==ob->totcol) { + if (ob_iter->totcol==ob->totcol) { ob_iter->actcol= ob->actcol; WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob_iter); } @@ -370,13 +370,13 @@ static int new_material_exec(bContext *C, wmOperator *UNUSED(op)) PropertyRNA *prop; /* add or copy material */ - if(ma) { + if (ma) { ma= copy_material(ma); } else { ma= add_material("Material"); - if(scene_use_new_shading_nodes(scene)) { + if (scene_use_new_shading_nodes(scene)) { ED_node_shader_default(scene, &ma->id); ma->use_nodes= 1; } @@ -385,7 +385,7 @@ static int new_material_exec(bContext *C, wmOperator *UNUSED(op)) /* hook into UI */ uiIDContextProperty(C, &ptr, &prop); - if(prop) { + if (prop) { /* when creating new ID blocks, use is already 1, but RNA * pointer se also increases user, so this compensates it */ ma->id.us--; @@ -423,7 +423,7 @@ static int new_texture_exec(bContext *C, wmOperator *UNUSED(op)) PropertyRNA *prop; /* add or copy texture */ - if(tex) + if (tex) tex= copy_texture(tex); else tex= add_texture("Texture"); @@ -431,7 +431,7 @@ static int new_texture_exec(bContext *C, wmOperator *UNUSED(op)) /* hook into UI */ uiIDContextProperty(C, &ptr, &prop); - if(prop) { + if (prop) { /* when creating new ID blocks, use is already 1, but RNA * pointer se also increases user, so this compensates it */ tex->id.us--; @@ -470,13 +470,13 @@ static int new_world_exec(bContext *C, wmOperator *UNUSED(op)) PropertyRNA *prop; /* add or copy world */ - if(wo) { + if (wo) { wo= copy_world(wo); } else { wo= add_world("World"); - if(scene_use_new_shading_nodes(scene)) { + if (scene_use_new_shading_nodes(scene)) { ED_node_shader_default(scene, &wo->id); wo->use_nodes= 1; } @@ -485,7 +485,7 @@ static int new_world_exec(bContext *C, wmOperator *UNUSED(op)) /* hook into UI */ uiIDContextProperty(C, &ptr, &prop); - if(prop) { + if (prop) { /* when creating new ID blocks, use is already 1, but RNA * pointer se also increases user, so this compensates it */ wo->id.us--; @@ -547,7 +547,7 @@ static int render_layer_remove_exec(bContext *C, wmOperator *UNUSED(op)) Scene *scene = CTX_data_scene(C); SceneRenderLayer *rl = BLI_findlink(&scene->r.layers, scene->r.actlay); - if(!scene_remove_render_layer(CTX_data_main(C), scene, rl)) + if (!scene_remove_render_layer(CTX_data_main(C), scene, rl)) return OPERATOR_CANCELLED; WM_event_add_notifier(C, NC_SCENE|ND_RENDER_OPTIONS, scene); @@ -573,7 +573,7 @@ static int texture_slot_move(bContext *C, wmOperator *op) { ID *id= CTX_data_pointer_get_type(C, "texture_slot", &RNA_TextureSlot).id.data; - if(id) { + if (id) { MTex **mtex_ar, *mtexswap; short act; int type= RNA_enum_get(op->ptr, "type"); @@ -581,8 +581,8 @@ static int texture_slot_move(bContext *C, wmOperator *op) give_active_mtex(id, &mtex_ar, &act); - if(type == -1) { /* Up */ - if(act > 0) { + if (type == -1) { /* Up */ + if (act > 0) { mtexswap = mtex_ar[act]; mtex_ar[act] = mtex_ar[act-1]; mtex_ar[act-1] = mtexswap; @@ -591,7 +591,7 @@ static int texture_slot_move(bContext *C, wmOperator *op) BKE_animdata_fix_paths_rename(id, adt, "texture_slots", NULL, NULL, act, act-1, 0); BKE_animdata_fix_paths_rename(id, adt, "texture_slots", NULL, NULL, -1, act, 0); - if(GS(id->name)==ID_MA) { + if (GS(id->name)==ID_MA) { Material *ma= (Material *)id; int mtexuse = ma->septex & (1<septex &= ~(1<name)==ID_MA) { + if (GS(id->name)==ID_MA) { Material *ma= (Material *)id; int mtexuse = ma->septex & (1<septex &= ~(1<ptr, "filepath", path); - if(scene->r.scemode & R_EXTENSION) { + if (scene->r.scemode & R_EXTENSION) { BKE_add_image_extension(path, imtype); } @@ -705,7 +705,7 @@ static int envmap_save_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event { //Scene *scene= CTX_data_scene(C); - if(RNA_struct_property_is_set(op->ptr, "filepath")) + if (RNA_struct_property_is_set(op->ptr, "filepath")) return envmap_save_exec(C, op); //RNA_enum_set(op->ptr, "file_type", scene->r.im_format.imtype); @@ -828,7 +828,7 @@ static int copy_material_exec(bContext *C, wmOperator *UNUSED(op)) { Material *ma= CTX_data_pointer_get_type(C, "material", &RNA_Material).data; - if(ma==NULL) + if (ma==NULL) return OPERATOR_CANCELLED; copy_matcopybuf(ma); @@ -854,7 +854,7 @@ static int paste_material_exec(bContext *C, wmOperator *UNUSED(op)) { Material *ma= CTX_data_pointer_get_type(C, "material", &RNA_Material).data; - if(ma==NULL) + if (ma==NULL) return OPERATOR_CANCELLED; paste_matcopybuf(ma); @@ -908,7 +908,7 @@ static void copy_mtex_copybuf(ID *id) break; } - if(mtex && *mtex) { + if (mtex && *mtex) { memcpy(&mtexcopybuf, *mtex, sizeof(MTex)); mtexcopied= 1; } @@ -921,7 +921,7 @@ static void paste_mtex_copybuf(ID *id) { MTex **mtex= NULL; - if(mtexcopied == 0 || mtexcopybuf.tex==NULL) + if (mtexcopied == 0 || mtexcopybuf.tex==NULL) return; switch(GS(id->name)) { @@ -944,11 +944,11 @@ static void paste_mtex_copybuf(ID *id) return; } - if(mtex) { - if(*mtex==NULL) { + if (mtex) { + if (*mtex==NULL) { *mtex= MEM_mallocN(sizeof(MTex), "mtex copy"); } - else if((*mtex)->tex) { + else if ((*mtex)->tex) { (*mtex)->tex->id.us--; } @@ -963,7 +963,7 @@ static int copy_mtex_exec(bContext *C, wmOperator *UNUSED(op)) { ID *id= CTX_data_pointer_get_type(C, "texture_slot", &RNA_TextureSlot).id.data; - if(id==NULL) { + if (id==NULL) { /* copying empty slot */ ED_render_clear_mtex_copybuf(); return OPERATOR_CANCELLED; @@ -1000,7 +1000,7 @@ static int paste_mtex_exec(bContext *C, wmOperator *UNUSED(op)) { ID *id= CTX_data_pointer_get_type(C, "texture_slot", &RNA_TextureSlot).id.data; - if(id==NULL) { + if (id==NULL) { Material *ma= CTX_data_pointer_get_type(C, "material", &RNA_Material).data; Lamp *la= CTX_data_pointer_get_type(C, "lamp", &RNA_Lamp).data; World *wo= CTX_data_pointer_get_type(C, "world", &RNA_World).data; diff --git a/source/blender/editors/render/render_update.c b/source/blender/editors/render/render_update.c index 4483d7d8ba1..72b29c56811 100644 --- a/source/blender/editors/render/render_update.c +++ b/source/blender/editors/render/render_update.c @@ -77,7 +77,7 @@ void ED_render_scene_update(Main *bmain, Scene *scene, int updated) /* don't do this render engine update if we're updating the scene from * other threads doing e.g. rendering or baking jobs */ - if(!BLI_thread_is_main()) + if (!BLI_thread_is_main()) return; C= CTX_create(); @@ -86,22 +86,22 @@ void ED_render_scene_update(Main *bmain, Scene *scene, int updated) CTX_wm_manager_set(C, bmain->wm.first); - for(sc=bmain->screen.first; sc; sc=sc->id.next) { - for(sa=sc->areabase.first; sa; sa=sa->next) { - if(sa->spacetype != SPACE_VIEW3D) + for (sc=bmain->screen.first; sc; sc=sc->id.next) { + for (sa=sc->areabase.first; sa; sa=sa->next) { + if (sa->spacetype != SPACE_VIEW3D) continue; - for(ar=sa->regionbase.first; ar; ar=ar->next) { + for (ar=sa->regionbase.first; ar; ar=ar->next) { RegionView3D *rv3d; RenderEngine *engine; - if(ar->regiontype != RGN_TYPE_WINDOW) + if (ar->regiontype != RGN_TYPE_WINDOW) continue; rv3d= ar->regiondata; engine= rv3d->render_engine; - if(engine && (updated || (engine->flag & RE_ENGINE_DO_UPDATE))) { + if (engine && (updated || (engine->flag & RE_ENGINE_DO_UPDATE))) { CTX_wm_screen_set(C, sc); CTX_wm_area_set(C, sa); CTX_wm_region_set(C, ar); @@ -123,20 +123,20 @@ void ED_render_engine_changed(Main *bmain) ScrArea *sa; ARegion *ar; - for(sc=bmain->screen.first; sc; sc=sc->id.next) { - for(sa=sc->areabase.first; sa; sa=sa->next) { - if(sa->spacetype != SPACE_VIEW3D) + for (sc=bmain->screen.first; sc; sc=sc->id.next) { + for (sa=sc->areabase.first; sa; sa=sa->next) { + if (sa->spacetype != SPACE_VIEW3D) continue; - for(ar=sa->regionbase.first; ar; ar=ar->next) { + for (ar=sa->regionbase.first; ar; ar=ar->next) { RegionView3D *rv3d; - if(ar->regiontype != RGN_TYPE_WINDOW) + if (ar->regiontype != RGN_TYPE_WINDOW) continue; rv3d= ar->regiondata; - if(rv3d->render_engine) { + if (rv3d->render_engine) { RE_engine_free(rv3d->render_engine); rv3d->render_engine= NULL; } @@ -154,11 +154,11 @@ static int mtex_use_tex(MTex **mtex, int tot, Tex *tex) { int a; - if(!mtex) + if (!mtex) return 0; - for(a=0; atex == tex) + for (a=0; atex == tex) return 1; return 0; @@ -168,17 +168,17 @@ static int nodes_use_tex(bNodeTree *ntree, Tex *tex) { bNode *node; - for(node=ntree->nodes.first; node; node= node->next) { - if(node->id) { - if(node->id == (ID*)tex) { + for (node=ntree->nodes.first; node; node= node->next) { + if (node->id) { + if (node->id == (ID*)tex) { return 1; } - else if(GS(node->id->name) == ID_MA) { - if(mtex_use_tex(((Material*)node->id)->mtex, MAX_MTEX, tex)) + else if (GS(node->id->name) == ID_MA) { + if (mtex_use_tex(((Material*)node->id)->mtex, MAX_MTEX, tex)) return 1; } - else if(node->type==NODE_GROUP) { - if(nodes_use_tex((bNodeTree *)node->id, tex)) + else if (node->type==NODE_GROUP) { + if (nodes_use_tex((bNodeTree *)node->id, tex)) return 1; } } @@ -191,13 +191,13 @@ static int nodes_use_material(bNodeTree *ntree, Material *ma) { bNode *node; - for(node=ntree->nodes.first; node; node= node->next) { - if(node->id) { - if(node->id == (ID*)ma) { + for (node=ntree->nodes.first; node; node= node->next) { + if (node->id) { + if (node->id == (ID*)ma) { return 1; } - else if(node->type==NODE_GROUP) { - if(nodes_use_material((bNodeTree *)node->id, ma)) + else if (node->type==NODE_GROUP) { + if (nodes_use_material((bNodeTree *)node->id, ma)) return 1; } } @@ -214,17 +214,17 @@ static void material_changed(Main *bmain, Material *ma) BKE_icon_changed(BKE_icon_getid(&ma->id)); /* glsl */ - if(ma->gpumaterial.first) + if (ma->gpumaterial.first) GPU_material_free(ma); /* find node materials using this */ - for(parent=bmain->mat.first; parent; parent=parent->id.next) { - if(parent->use_nodes && parent->nodetree && nodes_use_material(parent->nodetree, ma)); + for (parent=bmain->mat.first; parent; parent=parent->id.next) { + if (parent->use_nodes && parent->nodetree && nodes_use_material(parent->nodetree, ma)); else continue; BKE_icon_changed(BKE_icon_getid(&parent->id)); - if(parent->gpumaterial.first) + if (parent->gpumaterial.first) GPU_material_free(parent); } } @@ -241,40 +241,40 @@ static void texture_changed(Main *bmain, Tex *tex) BKE_icon_changed(BKE_icon_getid(&tex->id)); /* find materials */ - for(ma=bmain->mat.first; ma; ma=ma->id.next) { - if(mtex_use_tex(ma->mtex, MAX_MTEX, tex)); - else if(ma->use_nodes && ma->nodetree && nodes_use_tex(ma->nodetree, tex)); + for (ma=bmain->mat.first; ma; ma=ma->id.next) { + if (mtex_use_tex(ma->mtex, MAX_MTEX, tex)); + else if (ma->use_nodes && ma->nodetree && nodes_use_tex(ma->nodetree, tex)); else continue; BKE_icon_changed(BKE_icon_getid(&ma->id)); - if(ma->gpumaterial.first) + if (ma->gpumaterial.first) GPU_material_free(ma); } /* find lamps */ - for(la=bmain->lamp.first; la; la=la->id.next) { - if(mtex_use_tex(la->mtex, MAX_MTEX, tex)); - else if(la->nodetree && nodes_use_tex(la->nodetree, tex)); + for (la=bmain->lamp.first; la; la=la->id.next) { + if (mtex_use_tex(la->mtex, MAX_MTEX, tex)); + else if (la->nodetree && nodes_use_tex(la->nodetree, tex)); else continue; BKE_icon_changed(BKE_icon_getid(&la->id)); } /* find worlds */ - for(wo=bmain->world.first; wo; wo=wo->id.next) { - if(mtex_use_tex(wo->mtex, MAX_MTEX, tex)); - else if(wo->nodetree && nodes_use_tex(wo->nodetree, tex)); + for (wo=bmain->world.first; wo; wo=wo->id.next) { + if (mtex_use_tex(wo->mtex, MAX_MTEX, tex)); + else if (wo->nodetree && nodes_use_tex(wo->nodetree, tex)); else continue; BKE_icon_changed(BKE_icon_getid(&wo->id)); } /* find compositing nodes */ - for(scene=bmain->scene.first; scene; scene=scene->id.next) { - if(scene->use_nodes && scene->nodetree) { - for(node=scene->nodetree->nodes.first; node; node=node->next) { - if(node->id == &tex->id) + for (scene=bmain->scene.first; scene; scene=scene->id.next) { + if (scene->use_nodes && scene->nodetree) { + for (node=scene->nodetree->nodes.first; node; node=node->next) { + if (node->id == &tex->id) ED_node_changed_update(&scene->id, node); } } @@ -290,12 +290,12 @@ static void lamp_changed(Main *bmain, Lamp *la) BKE_icon_changed(BKE_icon_getid(&la->id)); /* glsl */ - for(ob=bmain->object.first; ob; ob=ob->id.next) - if(ob->data == la && ob->gpulamp.first) + for (ob=bmain->object.first; ob; ob=ob->id.next) + if (ob->data == la && ob->gpulamp.first) GPU_lamp_free(ob); - for(ma=bmain->mat.first; ma; ma=ma->id.next) - if(ma->gpumaterial.first) + for (ma=bmain->mat.first; ma; ma=ma->id.next) + if (ma->gpumaterial.first) GPU_material_free(ma); } @@ -307,8 +307,8 @@ static void world_changed(Main *bmain, World *wo) BKE_icon_changed(BKE_icon_getid(&wo->id)); /* glsl */ - for(ma=bmain->mat.first; ma; ma=ma->id.next) - if(ma->gpumaterial.first) + for (ma=bmain->mat.first; ma; ma=ma->id.next) + if (ma->gpumaterial.first) GPU_material_free(ma); } @@ -320,8 +320,8 @@ static void image_changed(Main *bmain, Image *ima) BKE_icon_changed(BKE_icon_getid(&ima->id)); /* textures */ - for(tex=bmain->tex.first; tex; tex=tex->id.next) - if(tex->ima == ima) + for (tex=bmain->tex.first; tex; tex=tex->id.next) + if (tex->ima == ima) texture_changed(bmain, tex); } @@ -331,12 +331,12 @@ static void scene_changed(Main *bmain, Scene *UNUSED(scene)) Material *ma; /* glsl */ - for(ob=bmain->object.first; ob; ob=ob->id.next) - if(ob->gpulamp.first) + for (ob=bmain->object.first; ob; ob=ob->id.next) + if (ob->gpulamp.first) GPU_lamp_free(ob); - for(ma=bmain->mat.first; ma; ma=ma->id.next) - if(ma->gpumaterial.first) + for (ma=bmain->mat.first; ma; ma=ma->id.next) + if (ma->gpumaterial.first) GPU_material_free(ma); } diff --git a/source/blender/editors/render/render_view.c b/source/blender/editors/render/render_view.c index 64f54e63cb9..31b53fcabe1 100644 --- a/source/blender/editors/render/render_view.c +++ b/source/blender/editors/render/render_view.c @@ -66,16 +66,16 @@ static ScrArea *biggest_non_image_area(bContext *C) int size, maxsize= 0, bwmaxsize= 0; short foundwin= 0; - for(sa= sc->areabase.first; sa; sa= sa->next) { - if(sa->winx > 30 && sa->winy > 30) { + for (sa= sc->areabase.first; sa; sa= sa->next) { + if (sa->winx > 30 && sa->winy > 30) { size= sa->winx*sa->winy; - if(sa->spacetype == SPACE_BUTS) { - if(foundwin == 0 && size > bwmaxsize) { + if (sa->spacetype == SPACE_BUTS) { + if (foundwin == 0 && size > bwmaxsize) { bwmaxsize= size; big= sa; } } - else if(sa->spacetype != SPACE_IMAGE && size > maxsize) { + else if (sa->spacetype != SPACE_IMAGE && size > maxsize) { maxsize= size; big= sa; foundwin= 1; @@ -93,15 +93,15 @@ static ScrArea *find_area_showing_r_result(bContext *C, wmWindow **win) SpaceImage *sima; /* find an imagewindow showing render result */ - for(*win=wm->windows.first; *win; *win= (*win)->next) { - for(sa= (*win)->screen->areabase.first; sa; sa= sa->next) { - if(sa->spacetype==SPACE_IMAGE) { + for (*win=wm->windows.first; *win; *win= (*win)->next) { + for (sa= (*win)->screen->areabase.first; sa; sa= sa->next) { + if (sa->spacetype==SPACE_IMAGE) { sima= sa->spacedata.first; - if(sima->image && sima->image->type==IMA_TYPE_R_RESULT) + if (sima->image && sima->image->type==IMA_TYPE_R_RESULT) break; } } - if(sa) + if (sa) break; } @@ -115,10 +115,10 @@ static ScrArea *find_area_image_empty(bContext *C) SpaceImage *sima; /* find an imagewindow showing render result */ - for(sa=sc->areabase.first; sa; sa= sa->next) { - if(sa->spacetype==SPACE_IMAGE) { + for (sa=sc->areabase.first; sa; sa= sa->next) { + if (sa->spacetype==SPACE_IMAGE) { sima= sa->spacedata.first; - if(!sima->image) + if (!sima->image) break; } } @@ -137,10 +137,10 @@ void render_view_open(bContext *C, int mx, int my) SpaceImage *sima; int area_was_image=0; - if(scene->r.displaymode==R_OUTPUT_NONE) + if (scene->r.displaymode==R_OUTPUT_NONE) return; - if(scene->r.displaymode==R_OUTPUT_WINDOW) { + if (scene->r.displaymode==R_OUTPUT_WINDOW) { rcti rect; int sizex, sizey; @@ -148,8 +148,8 @@ void render_view_open(bContext *C, int mx, int my) sizey= 40 + (scene->r.ysch*scene->r.size)/100; /* arbitrary... miniature image window views don't make much sense */ - if(sizex < 320) sizex= 320; - if(sizey < 256) sizey= 256; + if (sizex < 320) sizex= 320; + if (sizey < 256) sizey= 256; /* XXX some magic to calculate postition */ rect.xmin = mx + win->posx - sizex/2; @@ -162,7 +162,7 @@ void render_view_open(bContext *C, int mx, int my) sa= CTX_wm_area(C); } - else if(scene->r.displaymode==R_OUTPUT_SCREEN) { + else if (scene->r.displaymode==R_OUTPUT_SCREEN) { if (CTX_wm_area(C) && CTX_wm_area(C)->spacetype == SPACE_IMAGE) area_was_image = 1; @@ -170,19 +170,19 @@ void render_view_open(bContext *C, int mx, int my) sa= ED_screen_full_newspace(C, CTX_wm_area(C), SPACE_IMAGE); } - if(!sa) { + if (!sa) { sa= find_area_showing_r_result(C, &win); - if(sa==NULL) + if (sa==NULL) sa= find_area_image_empty(C); /* if area found in other window, we make that one show in front */ - if(win && win!=CTX_wm_window(C)) + if (win && win!=CTX_wm_window(C)) wm_window_raise(win); - if(sa==NULL) { + if (sa==NULL) { /* find largest open non-image area */ sa= biggest_non_image_area(C); - if(sa) { + if (sa) { ED_area_newspace(C, sa, SPACE_IMAGE); sima= sa->spacedata.first; @@ -192,7 +192,7 @@ void render_view_open(bContext *C, int mx, int my) else { /* use any area of decent size */ sa= BKE_screen_find_big_area(CTX_wm_screen(C), -1, 0); - if(sa->spacetype!=SPACE_IMAGE) { + if (sa->spacetype!=SPACE_IMAGE) { // XXX newspace(sa, SPACE_IMAGE); sima= sa->spacedata.first; @@ -210,7 +210,7 @@ void render_view_open(bContext *C, int mx, int my) /* if we're rendering to full screen, set appropriate hints on image editor * so it can restore properly on pressing esc */ - if(sa->full) { + if (sa->full) { sima->flag |= SI_FULLWINDOW; /* Tell the image editor to revert to previous space in space list on close @@ -234,15 +234,15 @@ static int render_view_cancel_exec(bContext *C, wmOperator *UNUSED(op)) SpaceImage *sima= sa->spacedata.first; /* test if we have a temp screen in front */ - if(CTX_wm_window(C)->screen->temp) { + if (CTX_wm_window(C)->screen->temp) { wm_window_lower(CTX_wm_window(C)); return OPERATOR_FINISHED; } /* determine if render already shows */ - else if(sima->flag & SI_PREVSPACE) { + else if (sima->flag & SI_PREVSPACE) { sima->flag &= ~SI_PREVSPACE; - if(sima->flag & SI_FULLWINDOW) { + if (sima->flag & SI_FULLWINDOW) { sima->flag &= ~SI_FULLWINDOW; ED_screen_full_prevspace(C, sa); } @@ -251,7 +251,7 @@ static int render_view_cancel_exec(bContext *C, wmOperator *UNUSED(op)) return OPERATOR_FINISHED; } - else if(sima->flag & SI_FULLWINDOW) { + else if (sima->flag & SI_FULLWINDOW) { sima->flag &= ~SI_FULLWINDOW; ED_screen_full_toggle(C, win, sa); return OPERATOR_FINISHED; @@ -279,7 +279,7 @@ static int render_view_show_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent wmWindow *wincur = CTX_wm_window(C); /* test if we have currently a temp screen active */ - if(wincur->screen->temp) { + if (wincur->screen->temp) { wm_window_lower(wincur); } else { @@ -287,30 +287,30 @@ static int render_view_show_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent ScrArea *sa= find_area_showing_r_result(C, &winshow); /* is there another window showing result? */ - for(win= CTX_wm_manager(C)->windows.first; win; win= win->next) { - if(win->screen->temp || (win==winshow && winshow!=wincur)) { + for (win= CTX_wm_manager(C)->windows.first; win; win= win->next) { + if (win->screen->temp || (win==winshow && winshow!=wincur)) { wm_window_raise(win); return OPERATOR_FINISHED; } } /* determine if render already shows */ - if(sa) { + if (sa) { /* but don't close it when rendering */ - if(!G.rendering) { + if (!G.rendering) { SpaceImage *sima= sa->spacedata.first; - if(sima->flag & SI_PREVSPACE) { + if (sima->flag & SI_PREVSPACE) { sima->flag &= ~SI_PREVSPACE; - if(sima->flag & SI_FULLWINDOW) { + if (sima->flag & SI_FULLWINDOW) { sima->flag &= ~SI_FULLWINDOW; ED_screen_full_prevspace(C, sa); } - else if(sima->next) { + else if (sima->next) { /* workaround for case of double prevspace, render window * with a file browser on top of it (same as in ED_area_prevspace) */ - if(sima->next->spacetype == SPACE_FILE && sima->next->next) + if (sima->next->spacetype == SPACE_FILE && sima->next->next) ED_area_newspace(C, sa, sima->next->next->spacetype); else ED_area_newspace(C, sa, sima->next->spacetype); diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c index 955a19f6725..8f429321fbb 100644 --- a/source/blender/editors/screen/area.c +++ b/source/blender/editors/screen/area.c @@ -117,7 +117,7 @@ void ED_region_do_listen(ARegion *ar, wmNotifier *note) /* generic notes first */ switch(note->category) { case NC_WM: - if(note->data==ND_FILEREAD) + if (note->data==ND_FILEREAD) ED_region_tag_redraw(ar); break; case NC_WINDOW: @@ -125,7 +125,7 @@ void ED_region_do_listen(ARegion *ar, wmNotifier *note) break; } - if(ar->type && ar->type->listener) + if (ar->type && ar->type->listener) ar->type->listener(ar, note); } @@ -133,7 +133,7 @@ void ED_region_do_listen(ARegion *ar, wmNotifier *note) void ED_area_do_listen(ScrArea *sa, wmNotifier *note) { /* no generic notes? */ - if(sa->type && sa->type->listener) { + if (sa->type && sa->type->listener) { sa->type->listener(sa, note); } } @@ -142,7 +142,7 @@ void ED_area_do_listen(ScrArea *sa, wmNotifier *note) void ED_area_do_refresh(bContext *C, ScrArea *sa) { /* no generic notes? */ - if(sa->type && sa->type->refresh) { + if (sa->type && sa->type->refresh) { sa->type->refresh(C, sa); } sa->do_refresh= 0; @@ -154,14 +154,14 @@ void ED_area_overdraw_flush(ScrArea *sa, ARegion *ar) { AZone *az; - for(az= sa->actionzones.first; az; az= az->next) { + for (az= sa->actionzones.first; az; az= az->next) { int xs, ys; xs= (az->x1+az->x2)/2; ys= (az->y1+az->y2)/2; /* test if inside */ - if(BLI_in_rcti(&ar->winrct, xs, ys)) { + if (BLI_in_rcti(&ar->winrct, xs, ys)) { az->do_draw= 1; } } @@ -360,22 +360,23 @@ void ED_area_overdraw(bContext *C) glEnable( GL_BLEND ); glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ); - for(sa= screen->areabase.first; sa; sa= sa->next) { + for (sa= screen->areabase.first; sa; sa= sa->next) { AZone *az; - for(az= sa->actionzones.first; az; az= az->next) { - if(az->do_draw) { - if(az->type==AZONE_AREA) { + for (az= sa->actionzones.first; az; az= az->next) { + if (az->do_draw) { + if (az->type==AZONE_AREA) { area_draw_azone(az->x1, az->y1, az->x2, az->y2); - } else if(az->type==AZONE_REGION) { + } + else if (az->type==AZONE_REGION) { - if(az->ar) { + if (az->ar) { /* only display tab or icons when the region is hidden */ if (az->ar->flag & (RGN_FLAG_HIDDEN|RGN_FLAG_TOO_SMALL)) { - if(G.rt==3) + if (G.rt==3) region_draw_azone_icon(az); - else if(G.rt==2) + else if (G.rt==2) region_draw_azone_tria(az); - else if(G.rt==1) + else if (G.rt==1) region_draw_azone_tab(az); else region_draw_azone_tab_plus(az); @@ -396,19 +397,19 @@ void region_scissor_winrct(ARegion *ar, rcti *winrct) { *winrct= ar->winrct; - if(ELEM(ar->alignment, RGN_OVERLAP_LEFT, RGN_OVERLAP_RIGHT)) + if (ELEM(ar->alignment, RGN_OVERLAP_LEFT, RGN_OVERLAP_RIGHT)) return; - while(ar->prev) { + while (ar->prev) { ar= ar->prev; - if(BLI_isect_rcti(winrct, &ar->winrct, NULL)) { - if(ar->flag & RGN_FLAG_HIDDEN); - else if(ar->alignment & RGN_SPLIT_PREV); - else if(ar->alignment==RGN_OVERLAP_LEFT) { + if (BLI_isect_rcti(winrct, &ar->winrct, NULL)) { + if (ar->flag & RGN_FLAG_HIDDEN); + else if (ar->alignment & RGN_SPLIT_PREV); + else if (ar->alignment==RGN_OVERLAP_LEFT) { winrct->xmin = ar->winrct.xmax + 1; } - else if(ar->alignment==RGN_OVERLAP_RIGHT) { + else if (ar->alignment==RGN_OVERLAP_RIGHT) { winrct->xmax = ar->winrct.xmin - 1; } else break; @@ -447,14 +448,14 @@ void ED_region_do_draw(bContext *C, ARegion *ar) rcti winrct; /* see BKE_spacedata_draw_locks() */ - if(at->do_lock) + if (at->do_lock) return; /* checks other overlapping regions */ region_scissor_winrct(ar, &winrct); /* if no partial draw rect set, full rect */ - if(ar->drawrct.xmin == ar->drawrct.xmax) + if (ar->drawrct.xmin == ar->drawrct.xmax) ar->drawrct= winrct; else { /* extra clip for safety */ @@ -470,14 +471,14 @@ void ED_region_do_draw(bContext *C, ARegion *ar) UI_SetTheme(sa?sa->spacetype:0, ar->type?ar->type->regionid:0); /* optional header info instead? */ - if(ar->headerstr) { + if (ar->headerstr) { UI_ThemeClearColor(TH_HEADER); glClear(GL_COLOR_BUFFER_BIT); UI_ThemeColor(TH_TEXT); BLF_draw_default(20, 8, 0.0f, ar->headerstr, BLF_DRAW_STR_DUMMY_MAX); } - else if(at->draw) { + else if (at->draw) { at->draw(C, ar); } @@ -491,7 +492,7 @@ void ED_region_do_draw(bContext *C, ARegion *ar) uiFreeInactiveBlocks(C, &ar->uiblocks); - if(sa) + if (sa) region_draw_emboss(ar, &winrct); } @@ -502,7 +503,7 @@ void ED_region_do_draw(bContext *C, ARegion *ar) void ED_region_tag_redraw(ARegion *ar) { - if(ar) { + if (ar) { /* zero region means full region redraw */ ar->do_draw= RGN_DRAW; memset(&ar->drawrct, 0, sizeof(ar->drawrct)); @@ -511,19 +512,19 @@ void ED_region_tag_redraw(ARegion *ar) void ED_region_tag_redraw_overlay(ARegion *ar) { - if(ar) + if (ar) ar->do_draw_overlay= RGN_DRAW; } void ED_region_tag_redraw_partial(ARegion *ar, rcti *rct) { - if(ar) { - if(!ar->do_draw) { + if (ar) { + if (!ar->do_draw) { /* no redraw set yet, set partial region */ ar->do_draw= RGN_DRAW_PARTIAL; ar->drawrct= *rct; } - else if(ar->drawrct.xmin != ar->drawrct.xmax) { + else if (ar->drawrct.xmin != ar->drawrct.xmax) { /* partial redraw already set, expand region */ ar->drawrct.xmin = MIN2(ar->drawrct.xmin, rct->xmin); ar->drawrct.ymin = MIN2(ar->drawrct.ymin, rct->ymin); @@ -537,8 +538,8 @@ void ED_area_tag_redraw(ScrArea *sa) { ARegion *ar; - if(sa) - for(ar= sa->regionbase.first; ar; ar= ar->next) + if (sa) + for (ar= sa->regionbase.first; ar; ar= ar->next) ED_region_tag_redraw(ar); } @@ -546,9 +547,9 @@ void ED_area_tag_redraw_regiontype(ScrArea *sa, int regiontype) { ARegion *ar; - if(sa) { - for(ar= sa->regionbase.first; ar; ar= ar->next) { - if(ar->regiontype == regiontype) { + if (sa) { + for (ar= sa->regionbase.first; ar; ar= ar->next) { + if (ar->regiontype == regiontype) { ED_region_tag_redraw(ar); } } @@ -557,7 +558,7 @@ void ED_area_tag_redraw_regiontype(ScrArea *sa, int regiontype) void ED_area_tag_refresh(ScrArea *sa) { - if(sa) + if (sa) sa->do_refresh= 1; } @@ -569,17 +570,17 @@ void ED_area_headerprint(ScrArea *sa, const char *str) ARegion *ar; /* happens when running transform operators in backround mode */ - if(sa == NULL) + if (sa == NULL) return; - for(ar= sa->regionbase.first; ar; ar= ar->next) { - if(ar->regiontype==RGN_TYPE_HEADER) { - if(str) { - if(ar->headerstr==NULL) + for (ar= sa->regionbase.first; ar; ar= ar->next) { + if (ar->regiontype==RGN_TYPE_HEADER) { + if (str) { + if (ar->headerstr==NULL) ar->headerstr= MEM_mallocN(256, "headerprint"); BLI_strncpy(ar->headerstr, str, 256); } - else if(ar->headerstr) { + else if (ar->headerstr) { MEM_freeN(ar->headerstr); ar->headerstr= NULL; } @@ -660,8 +661,8 @@ static void region_azone_icon(ScrArea *sa, AZone *az, ARegion *ar) /* count how many actionzones with along same edge are available. * This allows for adding more action zones in the future without * having to worry about correct offset */ - for(azt= sa->actionzones.first; azt; azt= azt->next) { - if(azt->edge == az->edge) tot++; + for (azt= sa->actionzones.first; azt; azt= azt->next) { + if (azt->edge == az->edge) tot++; } switch(az->edge) { @@ -694,14 +695,14 @@ static void region_azone_icon(ScrArea *sa, AZone *az, ARegion *ar) BLI_init_rcti(&az->rect, az->x1, az->x2, az->y1, az->y2); /* if more azones on 1 spot, set offset */ - for(azt= sa->actionzones.first; azt; azt= azt->next) { - if(az!=azt) { - if( ABS(az->x1-azt->x1) < 2 && ABS(az->y1-azt->y1) < 2) { - if(az->edge==AE_TOP_TO_BOTTOMRIGHT || az->edge==AE_BOTTOM_TO_TOPLEFT) { + for (azt= sa->actionzones.first; azt; azt= azt->next) { + if (az!=azt) { + if ( ABS(az->x1-azt->x1) < 2 && ABS(az->y1-azt->y1) < 2) { + if (az->edge==AE_TOP_TO_BOTTOMRIGHT || az->edge==AE_BOTTOM_TO_TOPLEFT) { az->x1+= AZONESPOT; az->x2+= AZONESPOT; } - else{ + else { az->y1-= AZONESPOT; az->y2-= AZONESPOT; } @@ -720,13 +721,13 @@ static void region_azone_tab_plus(ScrArea *sa, AZone *az, ARegion *ar) AZone *azt; int tot= 0, add; - for(azt= sa->actionzones.first; azt; azt= azt->next) { - if(azt->edge == az->edge) tot++; + for (azt= sa->actionzones.first; azt; azt= azt->next) { + if (azt->edge == az->edge) tot++; } switch(az->edge) { case AE_TOP_TO_BOTTOMRIGHT: - if(ar->winrct.ymax == sa->totrct.ymin) add= 1; else add= 0; + if (ar->winrct.ymax == sa->totrct.ymin) add= 1; else add= 0; az->x1= ar->winrct.xmax - 2.5*AZONEPAD_TAB_PLUSW; az->y1= ar->winrct.ymax - add; az->x2= ar->winrct.xmax - 1.5*AZONEPAD_TAB_PLUSW; @@ -765,13 +766,13 @@ static void region_azone_tab(ScrArea *sa, AZone *az, ARegion *ar) AZone *azt; int tot= 0, add; - for(azt= sa->actionzones.first; azt; azt= azt->next) { - if(azt->edge == az->edge) tot++; + for (azt= sa->actionzones.first; azt; azt= azt->next) { + if (azt->edge == az->edge) tot++; } switch(az->edge) { case AE_TOP_TO_BOTTOMRIGHT: - if(ar->winrct.ymax == sa->totrct.ymin) add= 1; else add= 0; + if (ar->winrct.ymax == sa->totrct.ymin) add= 1; else add= 0; az->x1= ar->winrct.xmax - 2*AZONEPAD_TABW; az->y1= ar->winrct.ymax - add; az->x2= ar->winrct.xmax - AZONEPAD_TABW; @@ -810,13 +811,13 @@ static void region_azone_tria(ScrArea *sa, AZone *az, ARegion *ar) AZone *azt; int tot= 0, add; - for(azt= sa->actionzones.first; azt; azt= azt->next) { - if(azt->edge == az->edge) tot++; + for (azt= sa->actionzones.first; azt; azt= azt->next) { + if (azt->edge == az->edge) tot++; } switch(az->edge) { case AE_TOP_TO_BOTTOMRIGHT: - if(ar->winrct.ymax == sa->totrct.ymin) add= 1; else add= 0; + if (ar->winrct.ymax == sa->totrct.ymin) add= 1; else add= 0; az->x1= ar->winrct.xmax - 2*AZONEPAD_TRIAW; az->y1= ar->winrct.ymax - add; az->x2= ar->winrct.xmax - AZONEPAD_TRIAW; @@ -857,15 +858,16 @@ static void region_azone_initialize(ScrArea *sa, ARegion *ar, AZEdge edge) az->edge= edge; if (ar->flag & (RGN_FLAG_HIDDEN|RGN_FLAG_TOO_SMALL)) { - if(G.rt==3) + if (G.rt==3) region_azone_icon(sa, az, ar); - else if(G.rt==2) + else if (G.rt==2) region_azone_tria(sa, az, ar); - else if(G.rt==1) + else if (G.rt==1) region_azone_tab(sa, az, ar); else region_azone_tab_plus(sa, az, ar); - } else { + } + else { region_azone_edge(az, ar); } @@ -878,20 +880,20 @@ static void region_azone_add(ScrArea *sa, ARegion *ar, int alignment) { /* edge code (t b l r) is along which area edge azone will be drawn */ - if(alignment==RGN_ALIGN_TOP) + if (alignment==RGN_ALIGN_TOP) region_azone_initialize(sa, ar, AE_BOTTOM_TO_TOPLEFT); - else if(alignment==RGN_ALIGN_BOTTOM) + else if (alignment==RGN_ALIGN_BOTTOM) region_azone_initialize(sa, ar, AE_TOP_TO_BOTTOMRIGHT); - else if(ELEM(alignment, RGN_ALIGN_RIGHT, RGN_OVERLAP_RIGHT)) + else if (ELEM(alignment, RGN_ALIGN_RIGHT, RGN_OVERLAP_RIGHT)) region_azone_initialize(sa, ar, AE_LEFT_TO_TOPRIGHT); - else if(ELEM(alignment, RGN_ALIGN_LEFT, RGN_OVERLAP_LEFT)) + else if (ELEM(alignment, RGN_ALIGN_LEFT, RGN_OVERLAP_LEFT)) region_azone_initialize(sa, ar, AE_RIGHT_TO_TOPLEFT); } /* dir is direction to check, not the splitting edge direction! */ static int rct_fits(rcti *rect, char dir, int size) { - if(dir=='h') { + if (dir=='h') { return rect->xmax-rect->xmin - size; } else { // 'v' @@ -905,15 +907,15 @@ static void region_rect_recursive(ScrArea *sa, ARegion *ar, rcti *remainder, int int prefsizex, prefsizey; int alignment; - if(ar==NULL) + if (ar==NULL) return; /* no returns in function, winrct gets set in the end again */ BLI_init_rcti(&ar->winrct, 0, 0, 0, 0); /* for test; allow split of previously defined region */ - if(ar->alignment & RGN_SPLIT_PREV) - if(ar->prev) + if (ar->alignment & RGN_SPLIT_PREV) + if (ar->prev) remainder= &ar->prev->winrct; alignment = ar->alignment & ~RGN_SPLIT_PREV; @@ -921,46 +923,46 @@ static void region_rect_recursive(ScrArea *sa, ARegion *ar, rcti *remainder, int /* clear state flags first */ ar->flag &= ~RGN_FLAG_TOO_SMALL; /* user errors */ - if(ar->next==NULL && alignment!=RGN_ALIGN_QSPLIT) + if (ar->next==NULL && alignment!=RGN_ALIGN_QSPLIT) alignment= RGN_ALIGN_NONE; /* prefsize, for header we stick to exception */ prefsizex= ar->sizex?ar->sizex:ar->type->prefsizex; - if(ar->regiontype==RGN_TYPE_HEADER) + if (ar->regiontype==RGN_TYPE_HEADER) prefsizey= ar->type->prefsizey; - else if(ar->regiontype==RGN_TYPE_UI && sa->spacetype == SPACE_FILE) { + else if (ar->regiontype==RGN_TYPE_UI && sa->spacetype == SPACE_FILE) { prefsizey= UI_UNIT_Y * 2 + (UI_UNIT_Y/2); } else prefsizey= ar->sizey?ar->sizey:ar->type->prefsizey; /* hidden is user flag */ - if(ar->flag & RGN_FLAG_HIDDEN); + if (ar->flag & RGN_FLAG_HIDDEN); /* XXX floating area region, not handled yet here */ - else if(alignment == RGN_ALIGN_FLOAT); + else if (alignment == RGN_ALIGN_FLOAT); /* remainder is too small for any usage */ - else if( rct_fits(remainder, 'v', 1)<0 || rct_fits(remainder, 'h', 1) < 0 ) { + else if ( rct_fits(remainder, 'v', 1)<0 || rct_fits(remainder, 'h', 1) < 0 ) { ar->flag |= RGN_FLAG_TOO_SMALL; } - else if(alignment==RGN_ALIGN_NONE) { + else if (alignment==RGN_ALIGN_NONE) { /* typically last region */ ar->winrct= *remainder; BLI_init_rcti(remainder, 0, 0, 0, 0); } - else if(alignment==RGN_ALIGN_TOP || alignment==RGN_ALIGN_BOTTOM) { + else if (alignment==RGN_ALIGN_TOP || alignment==RGN_ALIGN_BOTTOM) { - if( rct_fits(remainder, 'v', prefsizey) < 0 ) { + if ( rct_fits(remainder, 'v', prefsizey) < 0 ) { ar->flag |= RGN_FLAG_TOO_SMALL; } else { int fac= rct_fits(remainder, 'v', prefsizey); - if(fac < 0 ) + if (fac < 0 ) prefsizey += fac; ar->winrct= *remainder; - if(alignment==RGN_ALIGN_TOP) { + if (alignment==RGN_ALIGN_TOP) { ar->winrct.ymin = ar->winrct.ymax - prefsizey + 1; remainder->ymax = ar->winrct.ymin - 1; } @@ -970,37 +972,37 @@ static void region_rect_recursive(ScrArea *sa, ARegion *ar, rcti *remainder, int } } } - else if( ELEM4(alignment, RGN_ALIGN_LEFT, RGN_ALIGN_RIGHT, RGN_OVERLAP_LEFT, RGN_OVERLAP_RIGHT)) { + else if ( ELEM4(alignment, RGN_ALIGN_LEFT, RGN_ALIGN_RIGHT, RGN_OVERLAP_LEFT, RGN_OVERLAP_RIGHT)) { - if( rct_fits(remainder, 'h', prefsizex) < 0 ) { + if ( rct_fits(remainder, 'h', prefsizex) < 0 ) { ar->flag |= RGN_FLAG_TOO_SMALL; } else { int fac= rct_fits(remainder, 'h', prefsizex); - if(fac < 0 ) + if (fac < 0 ) prefsizex += fac; ar->winrct= *remainder; - if(ELEM(alignment, RGN_ALIGN_RIGHT, RGN_OVERLAP_RIGHT)) { + if (ELEM(alignment, RGN_ALIGN_RIGHT, RGN_OVERLAP_RIGHT)) { ar->winrct.xmin = ar->winrct.xmax - prefsizex + 1; - if(alignment==RGN_ALIGN_RIGHT) + if (alignment==RGN_ALIGN_RIGHT) remainder->xmax = ar->winrct.xmin - 1; } else { ar->winrct.xmax = ar->winrct.xmin + prefsizex - 1; - if(alignment==RGN_ALIGN_LEFT) + if (alignment==RGN_ALIGN_LEFT) remainder->xmin = ar->winrct.xmax + 1; } } } - else if(alignment==RGN_ALIGN_VSPLIT || alignment==RGN_ALIGN_HSPLIT) { + else if (alignment==RGN_ALIGN_VSPLIT || alignment==RGN_ALIGN_HSPLIT) { /* percentage subdiv*/ ar->winrct= *remainder; - if(alignment==RGN_ALIGN_HSPLIT) { - if( rct_fits(remainder, 'h', prefsizex) > 4) { + if (alignment==RGN_ALIGN_HSPLIT) { + if ( rct_fits(remainder, 'h', prefsizex) > 4) { ar->winrct.xmax = (remainder->xmin+remainder->xmax)/2; remainder->xmin = ar->winrct.xmax+1; } @@ -1009,7 +1011,7 @@ static void region_rect_recursive(ScrArea *sa, ARegion *ar, rcti *remainder, int } } else { - if( rct_fits(remainder, 'v', prefsizey) > 4) { + if ( rct_fits(remainder, 'v', prefsizey) > 4) { ar->winrct.ymax = (remainder->ymin+remainder->ymax)/2; remainder->ymin = ar->winrct.ymax+1; } @@ -1018,21 +1020,21 @@ static void region_rect_recursive(ScrArea *sa, ARegion *ar, rcti *remainder, int } } } - else if(alignment==RGN_ALIGN_QSPLIT) { + else if (alignment==RGN_ALIGN_QSPLIT) { ar->winrct= *remainder; /* test if there's still 4 regions left */ - if(quad==0) { + if (quad==0) { ARegion *artest= ar->next; int count= 1; - while(artest) { + while (artest) { artest->alignment= RGN_ALIGN_QSPLIT; artest= artest->next; count++; } - if(count!=4) { + if (count!=4) { /* let's stop adding regions */ BLI_init_rcti(remainder, 0, 0, 0, 0); if (G.f & G_DEBUG) @@ -1040,16 +1042,16 @@ static void region_rect_recursive(ScrArea *sa, ARegion *ar, rcti *remainder, int } else quad= 1; } - if(quad) { - if(quad==1) { /* left bottom */ + if (quad) { + if (quad==1) { /* left bottom */ ar->winrct.xmax = (remainder->xmin + remainder->xmax)/2; ar->winrct.ymax = (remainder->ymin + remainder->ymax)/2; } - else if(quad==2) { /* left top */ + else if (quad==2) { /* left top */ ar->winrct.xmax = (remainder->xmin + remainder->xmax)/2; ar->winrct.ymin = 1 + (remainder->ymin + remainder->ymax)/2; } - else if(quad==3) { /* right bottom */ + else if (quad==3) { /* right bottom */ ar->winrct.xmin = 1 + (remainder->xmin + remainder->xmax)/2; ar->winrct.ymax = (remainder->ymin + remainder->ymax)/2; } @@ -1068,24 +1070,24 @@ static void region_rect_recursive(ScrArea *sa, ARegion *ar, rcti *remainder, int ar->winy= ar->winrct.ymax - ar->winrct.ymin + 1; /* set winrect for azones */ - if(ar->flag & (RGN_FLAG_HIDDEN|RGN_FLAG_TOO_SMALL)) { + if (ar->flag & (RGN_FLAG_HIDDEN|RGN_FLAG_TOO_SMALL)) { ar->winrct= *remainder; - if(alignment==RGN_ALIGN_TOP) + if (alignment==RGN_ALIGN_TOP) ar->winrct.ymin = ar->winrct.ymax; - else if(alignment==RGN_ALIGN_BOTTOM) + else if (alignment==RGN_ALIGN_BOTTOM) ar->winrct.ymax = ar->winrct.ymin; - else if(ELEM(alignment, RGN_ALIGN_RIGHT, RGN_OVERLAP_RIGHT)) + else if (ELEM(alignment, RGN_ALIGN_RIGHT, RGN_OVERLAP_RIGHT)) ar->winrct.xmin = ar->winrct.xmax; - else if(ELEM(alignment, RGN_ALIGN_LEFT, RGN_OVERLAP_LEFT)) + else if (ELEM(alignment, RGN_ALIGN_LEFT, RGN_OVERLAP_LEFT)) ar->winrct.xmax = ar->winrct.xmin; else /* prevent winrct to be valid */ ar->winrct.xmax = ar->winrct.xmin; } /* restore prev-split exception */ - if(ar->alignment & RGN_SPLIT_PREV) { - if(ar->prev) { + if (ar->alignment & RGN_SPLIT_PREV) { + if (ar->prev) { remainder= remainder_prev; ar->prev->winx= ar->prev->winrct.xmax - ar->prev->winrct.xmin + 1; ar->prev->winy= ar->prev->winrct.ymax - ar->prev->winrct.ymin + 1; @@ -1093,7 +1095,7 @@ static void region_rect_recursive(ScrArea *sa, ARegion *ar, rcti *remainder, int } /* in end, add azones, where appropriate */ - if(ar->regiontype == RGN_TYPE_HEADER && ar->winy + 6 > sa->winy) { + if (ar->regiontype == RGN_TYPE_HEADER && ar->winy + 6 > sa->winy) { /* The logic for this is: when the header takes up the full area, * disallow hiding it to view the main window. * @@ -1113,14 +1115,14 @@ static void area_calc_totrct(ScrArea *sa, int sizex, int sizey) { short rt= 0; // CLAMPIS(G.rt, 0, 16); - if(sa->v1->vec.x>0) sa->totrct.xmin = sa->v1->vec.x+1+rt; + if (sa->v1->vec.x>0) sa->totrct.xmin = sa->v1->vec.x+1+rt; else sa->totrct.xmin = sa->v1->vec.x; - if(sa->v4->vec.xtotrct.xmax = sa->v4->vec.x-1-rt; + if (sa->v4->vec.xtotrct.xmax = sa->v4->vec.x-1-rt; else sa->totrct.xmax = sa->v4->vec.x; - if(sa->v1->vec.y>0) sa->totrct.ymin = sa->v1->vec.y+1+rt; + if (sa->v1->vec.y>0) sa->totrct.ymin = sa->v1->vec.y+1+rt; else sa->totrct.ymin = sa->v1->vec.y; - if(sa->v2->vec.ytotrct.ymax = sa->v2->vec.y-1-rt; + if (sa->v2->vec.ytotrct.ymax = sa->v2->vec.y-1-rt; else sa->totrct.ymax = sa->v2->vec.y; /* for speedup */ @@ -1132,12 +1134,12 @@ static void area_calc_totrct(ScrArea *sa, int sizex, int sizey) /* used for area initialize below */ static void region_subwindow(wmWindow *win, ARegion *ar) { - if(ar->flag & (RGN_FLAG_HIDDEN|RGN_FLAG_TOO_SMALL)) { - if(ar->swinid) + if (ar->flag & (RGN_FLAG_HIDDEN|RGN_FLAG_TOO_SMALL)) { + if (ar->swinid) wm_subwindow_close(win, ar->swinid); ar->swinid= 0; } - else if(ar->swinid==0) + else if (ar->swinid==0) ar->swinid= wm_subwindow_open(win, &ar->winrct); else wm_subwindow_position(win, ar->swinid, &ar->winrct); @@ -1148,47 +1150,47 @@ static void ed_default_handlers(wmWindowManager *wm, ScrArea *sa, ListBase *hand /* note, add-handler checks if it already exists */ // XXX it would be good to have boundbox checks for some of these... - if(flag & ED_KEYMAP_UI) { + if (flag & ED_KEYMAP_UI) { /* user interface widgets */ UI_add_region_handlers(handlers); } - if(flag & ED_KEYMAP_VIEW2D) { + if (flag & ED_KEYMAP_VIEW2D) { /* 2d-viewport handling+manipulation */ wmKeyMap *keymap = WM_keymap_find(wm->defaultconf, "View2D", 0, 0); WM_event_add_keymap_handler(handlers, keymap); } - if(flag & ED_KEYMAP_MARKERS) { + if (flag & ED_KEYMAP_MARKERS) { /* time-markers */ wmKeyMap *keymap = WM_keymap_find(wm->defaultconf, "Markers", 0, 0); /* time space only has this keymap, the others get a boundbox restricted map */ - if(sa->spacetype!=SPACE_TIME) { + if (sa->spacetype!=SPACE_TIME) { ARegion *ar; static rcti rect= {0, 10000, 0, 30}; /* same local check for all areas */ ar= BKE_area_find_region_type(sa, RGN_TYPE_WINDOW); - if(ar) { + if (ar) { WM_event_add_keymap_handler_bb(handlers, keymap, &rect, &ar->winrct); } } else WM_event_add_keymap_handler(handlers, keymap); } - if(flag & ED_KEYMAP_ANIMATION) { + if (flag & ED_KEYMAP_ANIMATION) { /* frame changing and timeline operators (for time spaces) */ wmKeyMap *keymap = WM_keymap_find(wm->defaultconf, "Animation", 0, 0); WM_event_add_keymap_handler(handlers, keymap); } - if(flag & ED_KEYMAP_FRAMES) { + if (flag & ED_KEYMAP_FRAMES) { /* frame changing/jumping (for all spaces) */ wmKeyMap *keymap = WM_keymap_find(wm->defaultconf, "Frames", 0, 0); WM_event_add_keymap_handler(handlers, keymap); } - if(flag & ED_KEYMAP_GPENCIL) { + if (flag & ED_KEYMAP_GPENCIL) { /* grease pencil */ wmKeyMap *keymap = WM_keymap_find(wm->defaultconf, "Grease Pencil", 0, 0); WM_event_add_keymap_handler(handlers, keymap); } - if(flag & ED_KEYMAP_HEADER) { + if (flag & ED_KEYMAP_HEADER) { /* standard keymap for headers regions */ wmKeyMap *keymap = WM_keymap_find(wm->defaultconf, "Header", 0, 0); WM_event_add_keymap_handler(handlers, keymap); @@ -1205,12 +1207,12 @@ void ED_area_initialize(wmWindowManager *wm, wmWindow *win, ScrArea *sa) /* set typedefinitions */ sa->type= BKE_spacetype_from_id(sa->spacetype); - if(sa->type==NULL) { + if (sa->type==NULL) { sa->butspacetype= sa->spacetype= SPACE_VIEW3D; sa->type= BKE_spacetype_from_id(sa->spacetype); } - for(ar= sa->regionbase.first; ar; ar= ar->next) + for (ar= sa->regionbase.first; ar; ar= ar->next) ar->type= BKE_regiontype_from_id(sa->type, ar->regiontype); /* area sizes */ @@ -1226,18 +1228,18 @@ void ED_area_initialize(wmWindowManager *wm, wmWindow *win, ScrArea *sa) /* default area handlers */ ed_default_handlers(wm, sa, &sa->handlers, sa->type->keymapflag); /* checks spacedata, adds own handlers */ - if(sa->type->init) + if (sa->type->init) sa->type->init(wm, sa); /* region windows, default and own handlers */ - for(ar= sa->regionbase.first; ar; ar= ar->next) { + for (ar= sa->regionbase.first; ar; ar= ar->next) { region_subwindow(win, ar); - if(ar->swinid) { + if (ar->swinid) { /* default region handlers */ ed_default_handlers(wm, sa, &ar->handlers, ar->type->keymapflag); /* own handlers */ - if(ar->type->init) + if (ar->type->init) ar->type->init(wm, ar); } else { @@ -1246,7 +1248,7 @@ void ED_area_initialize(wmWindowManager *wm, wmWindow *win, ScrArea *sa) } /* rechecks 2d matrix for header on dpi changing, do not do for other regions, it resets view && blocks view2d operator polls (ton) */ - if(ar->regiontype==RGN_TYPE_HEADER) + if (ar->regiontype==RGN_TYPE_HEADER) ar->v2d.flag &= ~V2D_IS_INITIALISED; } } @@ -1273,7 +1275,7 @@ void ED_region_toggle_hidden(bContext *C, ARegion *ar) ar->flag ^= RGN_FLAG_HIDDEN; - if(ar->flag & RGN_FLAG_HIDDEN) + if (ar->flag & RGN_FLAG_HIDDEN) WM_event_remove_handlers(C, &ar->handlers); ED_area_initialize(CTX_wm_manager(C), CTX_wm_window(C), sa); @@ -1292,10 +1294,10 @@ void area_copy_data(ScrArea *sa1, ScrArea *sa2, int swap_space) sa1->spacetype= sa2->spacetype; sa1->butspacetype= sa2->butspacetype; - if(swap_space == 1) { + if (swap_space == 1) { SWAP(ListBase, sa1->spacedata, sa2->spacedata); /* exception: ensure preview is reset */ -// if(sa1->spacetype==SPACE_VIEW3D) +// if (sa1->spacetype==SPACE_VIEW3D) // XXX BIF_view3d_previewrender_free(sa1->spacedata.first); } else if (swap_space == 2) { @@ -1309,19 +1311,19 @@ void area_copy_data(ScrArea *sa1, ScrArea *sa2, int swap_space) /* Note; SPACE_EMPTY is possible on new screens */ /* regions */ - if(swap_space == 1) { + if (swap_space == 1) { SWAP(ListBase, sa1->regionbase, sa2->regionbase); } else { - if(swap_space<2) { + if (swap_space<2) { st= BKE_spacetype_from_id(spacetype); - for(ar= sa1->regionbase.first; ar; ar= ar->next) + for (ar= sa1->regionbase.first; ar; ar= ar->next) BKE_area_region_free(st, ar); BLI_freelistN(&sa1->regionbase); } st= BKE_spacetype_from_id(sa2->spacetype); - for(ar= sa2->regionbase.first; ar; ar= ar->next) { + for (ar= sa2->regionbase.first; ar; ar= ar->next) { ARegion *newar= BKE_area_region_copy(st, ar); BLI_addtail(&sa1->regionbase, newar); } @@ -1357,7 +1359,7 @@ void ED_area_swapspace(bContext *C, ScrArea *sa1, ScrArea *sa2) void ED_area_newspace(bContext *C, ScrArea *sa, int type) { - if(sa->spacetype != type) { + if (sa->spacetype != type) { SpaceType *st; SpaceLink *slold; SpaceLink *sl; @@ -1373,14 +1375,14 @@ void ED_area_newspace(bContext *C, ScrArea *sa, int type) /* check previously stored space */ for (sl= sa->spacedata.first; sl; sl= sl->next) - if(sl->spacetype==type) + if (sl->spacetype==type) break; /* old spacedata... happened during work on 2.50, remove */ - if(sl && sl->regionbase.first==NULL) { + if (sl && sl->regionbase.first==NULL) { st->free(sl); BLI_freelinkN(&sa->spacedata, sl); - if(slold == sl) { + if (slold == sl) { slold= NULL; } sl= NULL; @@ -1399,12 +1401,12 @@ void ED_area_newspace(bContext *C, ScrArea *sa, int type) } else { /* new space */ - if(st) { + if (st) { sl= st->new(C); BLI_addhead(&sa->spacedata, sl); /* swap regions */ - if(slold) + if (slold) slold->regionbase= sa->regionbase; sa->regionbase= sl->regionbase; sl->regionbase.first= sl->regionbase.last= NULL; @@ -1430,10 +1432,10 @@ void ED_area_prevspace(bContext *C, ScrArea *sa) { SpaceLink *sl = (sa) ? sa->spacedata.first : CTX_wm_space_data(C); - if(sl->next) { + if (sl->next) { /* workaround for case of double prevspace, render window * with a file browser on top of it */ - if(sl->next->spacetype == SPACE_FILE && sl->next->next) + if (sl->next->spacetype == SPACE_FILE && sl->next->next) ED_area_newspace(C, sa, sl->next->next->spacetype); else ED_area_newspace(C, sa, sl->next->spacetype); @@ -1561,10 +1563,10 @@ void ED_region_panels(const bContext *C, ARegion *ar, int vertical, const char * View2DScrollers *scrollers; int x, y, xco, yco, w, em, triangle, open, newcontext= 0; - if(contextnr >= 0) + if (contextnr >= 0) newcontext= UI_view2d_tab_set(v2d, contextnr); - if(vertical) { + if (vertical) { w= v2d->cur.xmax - v2d->cur.xmin; em= (ar->type->prefsizex)? UI_UNIT_Y/2: UI_UNIT_Y; } @@ -1579,21 +1581,21 @@ void ED_region_panels(const bContext *C, ARegion *ar, int vertical, const char * /* set view2d view matrix for scrolling (without scrollers) */ UI_view2d_view_ortho(v2d); - for(pt= ar->type->paneltypes.first; pt; pt= pt->next) { + for (pt= ar->type->paneltypes.first; pt; pt= pt->next) { /* verify context */ - if(context) - if(pt->context[0] && strcmp(context, pt->context) != 0) + if (context) + if (pt->context[0] && strcmp(context, pt->context) != 0) continue; /* draw panel */ - if(pt->draw && (!pt->poll || pt->poll(C, pt))) { + if (pt->draw && (!pt->poll || pt->poll(C, pt))) { block= uiBeginBlock(C, ar, pt->idname, UI_EMBOSS); panel= uiBeginPanel(sa, ar, block, pt, &open); /* bad fixed values */ triangle= (int)(UI_UNIT_Y * 1.1f); - if(pt->draw_header && !(pt->flag & PNL_NO_HEADER) && (open || vertical)) { + if (pt->draw_header && !(pt->flag & PNL_NO_HEADER) && (open || vertical)) { /* for enabled buttons */ panel->layout= uiBlockLayout(block, UI_LAYOUT_HORIZONTAL, UI_LAYOUT_HEADER, triangle, UI_UNIT_Y+style->panelspace+2, UI_UNIT_Y, 1, style); @@ -1608,7 +1610,7 @@ void ED_region_panels(const bContext *C, ARegion *ar, int vertical, const char * panel->labelofs= 0; } - if(open) { + if (open) { short panelContext; /* panel context can either be toolbar region or normal panels region */ @@ -1645,7 +1647,7 @@ void ED_region_panels(const bContext *C, ARegion *ar, int vertical, const char * glClear(GL_COLOR_BUFFER_BIT); /* before setting the view */ - if(vertical) { + if (vertical) { /* only allow scrolling in vertical direction */ v2d->keepofs |= V2D_LOCKOFS_X|V2D_KEEPOFS_Y; v2d->keepofs &= ~(V2D_LOCKOFS_Y|V2D_KEEPOFS_X); @@ -1653,7 +1655,7 @@ void ED_region_panels(const bContext *C, ARegion *ar, int vertical, const char * v2d->scroll &= ~V2D_SCROLL_VERTICAL_HIDE; // don't jump back when panels close or hide - if(!newcontext) + if (!newcontext) y= MAX2(-y, -v2d->cur.ymin); else y= -y; @@ -1669,7 +1671,7 @@ void ED_region_panels(const bContext *C, ARegion *ar, int vertical, const char * v2d->scroll &= ~V2D_SCROLL_HORIZONTAL_HIDE; // don't jump back when panels close or hide - if(!newcontext) + if (!newcontext) x= MAX2(x, v2d->cur.xmax); y= -y; } @@ -1704,7 +1706,7 @@ void ED_region_panels_init(wmWindowManager *wm, ARegion *ar) ar->v2d.keepzoom |= V2D_KEEPZOOM; // correctly initialized User-Prefs? - if(!(ar->v2d.align & V2D_ALIGN_NO_POS_Y)) + if (!(ar->v2d.align & V2D_ALIGN_NO_POS_Y)) ar->v2d.flag &= ~V2D_IS_INITIALISED; UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_PANELS_UI, ar->winx, ar->winy); @@ -1734,25 +1736,25 @@ void ED_region_header(const bContext *C, ARegion *ar) yco= headery-4; /* draw all headers types */ - for(ht= ar->type->headertypes.first; ht; ht= ht->next) { + for (ht= ar->type->headertypes.first; ht; ht= ht->next) { block= uiBeginBlock(C, ar, ht->idname, UI_EMBOSS); layout= uiBlockLayout(block, UI_LAYOUT_HORIZONTAL, UI_LAYOUT_HEADER, xco, yco, UI_UNIT_Y, 1, style); - if(ht->draw) { + if (ht->draw) { header.type= ht; header.layout= layout; ht->draw(C, &header); /* for view2d */ xco= uiLayoutGetWidth(layout); - if(xco > maxco) + if (xco > maxco) maxco= xco; } uiBlockLayoutResolve(block, &xco, &yco); /* for view2d */ - if(xco > maxco) + if (xco > maxco) maxco= xco; uiEndBlock(C, block); @@ -1791,7 +1793,7 @@ void ED_region_info_draw(ARegion *ar, const char *text, int block, float alpha) rect.xmin = 0; rect.ymin = ar->winrct.ymax - ar->winrct.ymin - header_height; - if(block) { + if (block) { rect.xmax = ar->winrct.xmax - ar->winrct.xmin; } else { diff --git a/source/blender/editors/screen/glutil.c b/source/blender/editors/screen/glutil.c index 495bfb9ba39..28fe8caf34b 100644 --- a/source/blender/editors/screen/glutil.c +++ b/source/blender/editors/screen/glutil.c @@ -150,7 +150,7 @@ void fdrawbezier(float vec[4][3]) glBegin(GL_LINE_STRIP); while (spline_step < 1.000001f) { #if 0 - if(do_shaded) + if (do_shaded) UI_ThemeColorBlend(th_col1, th_col2, spline_step); #endif glEvalCoord1f(spline_step); @@ -261,7 +261,7 @@ void sdrawbox(short x1, short y1, short x2, short y2) void setlinestyle(int nr) { - if(nr==0) { + if (nr==0) { glDisable(GL_LINE_STIPPLE); } else { @@ -284,7 +284,7 @@ void set_inverted_drawing(int enable) void sdrawXORline(int x0, int y0, int x1, int y1) { - if(x0==x1 && y0==y1) return; + if (x0==x1 && y0==y1) return; set_inverted_drawing(1); @@ -306,7 +306,7 @@ void sdrawXORline4(int nr, int x0, int y0, int x1, int y1) set_inverted_drawing(1); glBegin(GL_LINES); - if(nr== -1) { /* flush */ + if (nr== -1) { /* flush */ for (nr=0; nr<4; nr++) { if (flags[nr]) { glVertex2sv(old[nr][0]); @@ -314,9 +314,10 @@ void sdrawXORline4(int nr, int x0, int y0, int x1, int y1) flags[nr]= 0; } } - } else { - if(nr>=0 && nr<4) { - if(flags[nr]) { + } + else { + if (nr>=0 && nr<4) { + if (flags[nr]) { glVertex2sv(old[nr][0]); glVertex2sv(old[nr][1]); } @@ -339,7 +340,7 @@ void sdrawXORline4(int nr, int x0, int y0, int x1, int y1) void fdrawXORellipse(float xofs, float yofs, float hw, float hh) { - if(hw==0) return; + if (hw==0) return; set_inverted_drawing(1); @@ -502,28 +503,28 @@ void glaDrawPixelsTexScaled(float x, float y, int img_w, int img_h, int format, float rast_y= y+subpart_y*offset_y*yzoom; /* check if we already got these because we always get 2 more when doing seamless*/ - if(subpart_w<=seamless || subpart_h<=seamless) + if (subpart_w<=seamless || subpart_h<=seamless) continue; - if(format==GL_FLOAT) { + if (format==GL_FLOAT) { glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, subpart_w, subpart_h, GL_RGBA, GL_FLOAT, &f_rect[subpart_y*offset_y*img_w*4 + subpart_x*offset_x*4]); /* add an extra border of pixels so linear looks ok at edges of full image. */ - if(subpart_w=0 && rast_y>=0) { glRasterPos2f(rast_x, rast_y); - } else { + } + else { glaRasterPosSafe2f(rast_x, rast_y, 0, 0); } glPixelStorei(GL_UNPACK_ROW_LENGTH, row_w); - if(format==GL_LUMINANCE || format==GL_RED) { - if(type==GL_FLOAT) { + if (format==GL_LUMINANCE || format==GL_RED) { + if (type==GL_FLOAT) { float *f_rect= (float *)rect; glDrawPixels(draw_w, draw_h, format, type, f_rect + (off_y*row_w + off_x)); } - else if(type==GL_INT || type==GL_UNSIGNED_INT) { + else if (type==GL_INT || type==GL_UNSIGNED_INT) { int *i_rect= (int *)rect; glDrawPixels(draw_w, draw_h, format, type, i_rect + (off_y*row_w + off_x)); } } else { /* RGBA */ - if(type==GL_FLOAT) { + if (type==GL_FLOAT) { float *f_rect= (float *)rect; glDrawPixels(draw_w, draw_h, format, type, f_rect + (off_y*row_w + off_x)*4); } - else if(type==GL_UNSIGNED_BYTE) { + else if (type==GL_UNSIGNED_BYTE) { unsigned char *uc_rect= (unsigned char *) rect; glDrawPixels(draw_w, draw_h, format, type, uc_rect + (off_y*row_w + off_x)*4); } @@ -709,7 +711,8 @@ gla2DDrawInfo *glaBegin2DDraw(rcti *screen_rect, rctf *world_rect) di->screen_rect= *screen_rect; if (world_rect) { di->world_rect= *world_rect; - } else { + } + else { di->world_rect.xmin = di->screen_rect.xmin; di->world_rect.ymin = di->screen_rect.ymin; di->world_rect.xmax = di->screen_rect.xmax; @@ -765,13 +768,13 @@ void bglBegin(int mode) { curmode= mode; - if(mode==GL_POINTS) { + if (mode==GL_POINTS) { float value[4]; glGetFloatv(GL_POINT_SIZE_RANGE, value); - if(value[1] < 2.0f) { + if (value[1] < 2.0f) { glGetFloatv(GL_POINT_SIZE, value); pointhack= floor(value[0] + 0.5f); - if(pointhack>4) pointhack= 4; + if (pointhack>4) pointhack= 4; } else glBegin(mode); } @@ -782,10 +785,10 @@ int bglPointHack(void) float value[4]; int pointhack_px; glGetFloatv(GL_POINT_SIZE_RANGE, value); - if(value[1] < 2.0f) { + if (value[1] < 2.0f) { glGetFloatv(GL_POINT_SIZE, value); pointhack_px= floorf(value[0]+0.5f); - if(pointhack_px>4) pointhack_px= 4; + if (pointhack_px>4) pointhack_px= 4; return pointhack_px; } return 0; @@ -795,7 +798,7 @@ void bglVertex3fv(const float vec[3]) { switch(curmode) { case GL_POINTS: - if(pointhack) { + if (pointhack) { glRasterPos3fv(vec); glBitmap(pointhack, pointhack, (float)pointhack/2.0f, (float)pointhack/2.0f, 0.0, 0.0, Squaredot); } @@ -808,7 +811,7 @@ void bglVertex3f(float x, float y, float z) { switch(curmode) { case GL_POINTS: - if(pointhack) { + if (pointhack) { glRasterPos3f(x, y, z); glBitmap(pointhack, pointhack, (float)pointhack/2.0f, (float)pointhack/2.0f, 0.0, 0.0, Squaredot); } @@ -821,7 +824,7 @@ void bglVertex2fv(const float vec[2]) { switch(curmode) { case GL_POINTS: - if(pointhack) { + if (pointhack) { glRasterPos2fv(vec); glBitmap(pointhack, pointhack, (float)pointhack/2, pointhack/2, 0.0, 0.0, Squaredot); } @@ -833,7 +836,7 @@ void bglVertex2fv(const float vec[2]) void bglEnd(void) { - if(pointhack) pointhack= 0; + if (pointhack) pointhack= 0; else glEnd(); } @@ -849,10 +852,10 @@ void bgl_get_mats(bglMats *mats) /* Very strange code here - it seems that certain bad values in the * modelview matrix can cause gluUnProject to give bad results. */ - if(mats->modelview[0] < badvalue && + if (mats->modelview[0] < badvalue && mats->modelview[0] > -badvalue) mats->modelview[0]= 0; - if(mats->modelview[5] < badvalue && + if (mats->modelview[5] < badvalue && mats->modelview[5] > -badvalue) mats->modelview[5]= 0; @@ -868,7 +871,7 @@ void bglPolygonOffset(float viewdist, float dist) { static float winmat[16], offset=0.0; - if(dist != 0.0f) { + if (dist != 0.0f) { float offs; // glEnable(GL_POLYGON_OFFSET_FILL); @@ -880,7 +883,7 @@ void bglPolygonOffset(float viewdist, float dist) /* dist is from camera to center point */ - if(winmat[15]>0.5f) offs= 0.00001f*dist*viewdist; // ortho tweaking + if (winmat[15]>0.5f) offs= 0.00001f*dist*viewdist; // ortho tweaking else offs= 0.0005f*dist; // should be clipping value or so... winmat[14]-= offs; @@ -903,7 +906,7 @@ void bglFlush(void) { glFlush(); #ifdef __APPLE__ -// if(GPU_type_matches(GPU_DEVICE_INTEL, GPU_OS_MAC, GPU_DRIVER_OFFICIAL)) +// if (GPU_type_matches(GPU_DEVICE_INTEL, GPU_OS_MAC, GPU_DRIVER_OFFICIAL)) // XXX myswapbuffers(); //hack to get mac intel graphics to show frontbuffer #endif } diff --git a/source/blender/editors/screen/screen_context.c b/source/blender/editors/screen/screen_context.c index 9e2a2f54e0b..9e044068468 100644 --- a/source/blender/editors/screen/screen_context.c +++ b/source/blender/editors/screen/screen_context.c @@ -87,20 +87,20 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult base= BASACT; #endif - if(CTX_data_dir(member)) { + if (CTX_data_dir(member)) { CTX_data_dir_set(result, screen_context_dir); return 1; } - else if(CTX_data_equals(member, "scene")) { + else if (CTX_data_equals(member, "scene")) { CTX_data_id_pointer_set(result, &scene->id); return 1; } - else if(CTX_data_equals(member, "visible_objects") || CTX_data_equals(member, "visible_bases")) { + else if (CTX_data_equals(member, "visible_objects") || CTX_data_equals(member, "visible_bases")) { int visible_objects= CTX_data_equals(member, "visible_objects"); - for(base=scene->base.first; base; base=base->next) { - if(((base->object->restrictflag & OB_RESTRICT_VIEW) == 0) && (base->lay & scene->lay)) { - if(visible_objects) + for (base=scene->base.first; base; base=base->next) { + if (((base->object->restrictflag & OB_RESTRICT_VIEW) == 0) && (base->lay & scene->lay)) { + if (visible_objects) CTX_data_id_list_add(result, &base->object->id); else CTX_data_list_add(result, &scene->id, &RNA_ObjectBase, base); @@ -109,13 +109,13 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult CTX_data_type_set(result, CTX_DATA_TYPE_COLLECTION); return 1; } - else if(CTX_data_equals(member, "selectable_objects") || CTX_data_equals(member, "selectable_bases")) { + else if (CTX_data_equals(member, "selectable_objects") || CTX_data_equals(member, "selectable_bases")) { int selectable_objects= CTX_data_equals(member, "selectable_objects"); - for(base=scene->base.first; base; base=base->next) { - if(base->lay & lay) { - if((base->object->restrictflag & OB_RESTRICT_VIEW)==0 && (base->object->restrictflag & OB_RESTRICT_SELECT)==0) { - if(selectable_objects) + for (base=scene->base.first; base; base=base->next) { + if (base->lay & lay) { + if ((base->object->restrictflag & OB_RESTRICT_VIEW)==0 && (base->object->restrictflag & OB_RESTRICT_SELECT)==0) { + if (selectable_objects) CTX_data_id_list_add(result, &base->object->id); else CTX_data_list_add(result, &scene->id, &RNA_ObjectBase, base); @@ -125,12 +125,12 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult CTX_data_type_set(result, CTX_DATA_TYPE_COLLECTION); return 1; } - else if(CTX_data_equals(member, "selected_objects") || CTX_data_equals(member, "selected_bases")) { + else if (CTX_data_equals(member, "selected_objects") || CTX_data_equals(member, "selected_bases")) { int selected_objects= CTX_data_equals(member, "selected_objects"); - for(base=scene->base.first; base; base=base->next) { - if((base->flag & SELECT) && (base->lay & scene->lay)) { - if(selected_objects) + for (base=scene->base.first; base; base=base->next) { + if ((base->flag & SELECT) && (base->lay & scene->lay)) { + if (selected_objects) CTX_data_id_list_add(result, &base->object->id); else CTX_data_list_add(result, &scene->id, &RNA_ObjectBase, base); @@ -139,14 +139,14 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult CTX_data_type_set(result, CTX_DATA_TYPE_COLLECTION); return 1; } - else if(CTX_data_equals(member, "selected_editable_objects") || CTX_data_equals(member, "selected_editable_bases")) { + else if (CTX_data_equals(member, "selected_editable_objects") || CTX_data_equals(member, "selected_editable_bases")) { int selected_editable_objects= CTX_data_equals(member, "selected_editable_objects"); - for(base=scene->base.first; base; base=base->next) { - if((base->flag & SELECT) && (base->lay & scene->lay)) { - if((base->object->restrictflag & OB_RESTRICT_VIEW)==0) { - if(0==object_is_libdata(base->object)) { - if(selected_editable_objects) + for (base=scene->base.first; base; base=base->next) { + if ((base->flag & SELECT) && (base->lay & scene->lay)) { + if ((base->object->restrictflag & OB_RESTRICT_VIEW)==0) { + if (0==object_is_libdata(base->object)) { + if (selected_editable_objects) CTX_data_id_list_add(result, &base->object->id); else CTX_data_list_add(result, &scene->id, &RNA_ObjectBase, base); @@ -157,7 +157,7 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult CTX_data_type_set(result, CTX_DATA_TYPE_COLLECTION); return 1; } - else if(CTX_data_equals(member, "visible_bones") || CTX_data_equals(member, "editable_bones")) { + else if (CTX_data_equals(member, "visible_bones") || CTX_data_equals(member, "editable_bones")) { bArmature *arm= (obedit && obedit->type == OB_ARMATURE) ? obedit->data : NULL; EditBone *ebone, *flipbone=NULL; int editable_bones= CTX_data_equals(member, "editable_bones"); @@ -199,7 +199,7 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult return 1; } } - else if(CTX_data_equals(member, "selected_bones") || CTX_data_equals(member, "selected_editable_bones")) { + else if (CTX_data_equals(member, "selected_bones") || CTX_data_equals(member, "selected_editable_bones")) { bArmature *arm= (obedit && obedit->type == OB_ARMATURE) ? obedit->data : NULL; EditBone *ebone, *flipbone=NULL; int selected_editable_bones= CTX_data_equals(member, "selected_editable_bones"); @@ -241,7 +241,7 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult return 1; } } - else if(CTX_data_equals(member, "visible_pose_bones")) { + else if (CTX_data_equals(member, "visible_pose_bones")) { Object *obpose= object_pose_armature_get(obact); bArmature *arm= (obpose) ? obpose->data : NULL; bPoseChannel *pchan; @@ -257,7 +257,7 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult return 1; } } - else if(CTX_data_equals(member, "selected_pose_bones")) { + else if (CTX_data_equals(member, "selected_pose_bones")) { Object *obpose= object_pose_armature_get(obact); bArmature *arm= (obpose) ? obpose->data : NULL; bPoseChannel *pchan; @@ -274,24 +274,24 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult return 1; } } - else if(CTX_data_equals(member, "active_bone")) { - if(obact && obact->type == OB_ARMATURE) { + else if (CTX_data_equals(member, "active_bone")) { + if (obact && obact->type == OB_ARMATURE) { bArmature *arm= obact->data; - if(arm->edbo) { - if(arm->act_edbone) { + if (arm->edbo) { + if (arm->act_edbone) { CTX_data_pointer_set(result, &arm->id, &RNA_EditBone, arm->act_edbone); return 1; } } else { - if(arm->act_bone) { + if (arm->act_bone) { CTX_data_pointer_set(result, &arm->id, &RNA_Bone, arm->act_bone); return 1; } } } } - else if(CTX_data_equals(member, "active_pose_bone")) { + else if (CTX_data_equals(member, "active_pose_bone")) { bPoseChannel *pchan; Object *obpose= object_pose_armature_get(obact); @@ -301,64 +301,64 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult return 1; } } - else if(CTX_data_equals(member, "active_base")) { - if(base) + else if (CTX_data_equals(member, "active_base")) { + if (base) CTX_data_pointer_set(result, &scene->id, &RNA_ObjectBase, base); return 1; } - else if(CTX_data_equals(member, "active_object")) { - if(obact) + else if (CTX_data_equals(member, "active_object")) { + if (obact) CTX_data_id_pointer_set(result, &obact->id); return 1; } - else if(CTX_data_equals(member, "object")) { - if(obact) + else if (CTX_data_equals(member, "object")) { + if (obact) CTX_data_id_pointer_set(result, &obact->id); return 1; } - else if(CTX_data_equals(member, "edit_object")) { + else if (CTX_data_equals(member, "edit_object")) { /* convenience for now, 1 object per scene in editmode */ - if(obedit) + if (obedit) CTX_data_id_pointer_set(result, &obedit->id); return 1; } - else if(CTX_data_equals(member, "sculpt_object")) { - if(obact && (obact->mode & OB_MODE_SCULPT)) + else if (CTX_data_equals(member, "sculpt_object")) { + if (obact && (obact->mode & OB_MODE_SCULPT)) CTX_data_id_pointer_set(result, &obact->id); return 1; } - else if(CTX_data_equals(member, "vertex_paint_object")) { - if(obact && (obact->mode & OB_MODE_VERTEX_PAINT)) + else if (CTX_data_equals(member, "vertex_paint_object")) { + if (obact && (obact->mode & OB_MODE_VERTEX_PAINT)) CTX_data_id_pointer_set(result, &obact->id); return 1; } - else if(CTX_data_equals(member, "weight_paint_object")) { - if(obact && (obact->mode & OB_MODE_WEIGHT_PAINT)) + else if (CTX_data_equals(member, "weight_paint_object")) { + if (obact && (obact->mode & OB_MODE_WEIGHT_PAINT)) CTX_data_id_pointer_set(result, &obact->id); return 1; } - else if(CTX_data_equals(member, "image_paint_object")) { - if(obact && (obact->mode & OB_MODE_TEXTURE_PAINT)) + else if (CTX_data_equals(member, "image_paint_object")) { + if (obact && (obact->mode & OB_MODE_TEXTURE_PAINT)) CTX_data_id_pointer_set(result, &obact->id); return 1; } - else if(CTX_data_equals(member, "particle_edit_object")) { - if(obact && (obact->mode & OB_MODE_PARTICLE_EDIT)) + else if (CTX_data_equals(member, "particle_edit_object")) { + if (obact && (obact->mode & OB_MODE_PARTICLE_EDIT)) CTX_data_id_pointer_set(result, &obact->id); return 1; } - else if(CTX_data_equals(member, "sequences")) { + else if (CTX_data_equals(member, "sequences")) { Editing *ed= seq_give_editing(scene, FALSE); - if(ed) { + if (ed) { Sequence *seq; for (seq= ed->seqbasep->first; seq; seq= seq->next) { CTX_data_list_add(result, &scene->id, &RNA_Sequence, seq); @@ -367,9 +367,9 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult return 1; } } - else if(CTX_data_equals(member, "selected_sequences")) { + else if (CTX_data_equals(member, "selected_sequences")) { Editing *ed= seq_give_editing(scene, FALSE); - if(ed) { + if (ed) { Sequence *seq; for (seq= ed->seqbasep->first; seq; seq= seq->next) { if (seq->flag & SELECT) { @@ -380,9 +380,9 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult return 1; } } - else if(CTX_data_equals(member, "selected_editable_sequences")) { + else if (CTX_data_equals(member, "selected_editable_sequences")) { Editing *ed= seq_give_editing(scene, FALSE); - if(ed) { + if (ed) { Sequence *seq; for (seq= ed->seqbasep->first; seq; seq= seq->next) { if (seq->flag & SELECT && !(seq->flag & SEQ_LOCK)) { @@ -393,11 +393,11 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult return 1; } } - else if(CTX_data_equals(member, "active_operator")) { + else if (CTX_data_equals(member, "active_operator")) { wmOperator *op= NULL; SpaceFile *sfile= CTX_wm_space_file(C); - if(sfile) { + if (sfile) { op= sfile->op; } else if ((op= uiContextActiveOperator(C))) { diff --git a/source/blender/editors/screen/screen_edit.c b/source/blender/editors/screen/screen_edit.c index f07ca8b87e1..48b1afad891 100644 --- a/source/blender/editors/screen/screen_edit.c +++ b/source/blender/editors/screen/screen_edit.c @@ -111,7 +111,7 @@ ScrEdge *screen_findedge(bScreen *sc, ScrVert *v1, ScrVert *v2) sortscrvert(&v1, &v2); for (se= sc->edgebase.first; se; se= se->next) - if(se->v1==v1 && se->v2==v2) + if (se->v1==v1 && se->v2==v2) return se; return NULL; @@ -124,12 +124,12 @@ void removedouble_scrverts(bScreen *sc) ScrArea *sa; verg= sc->vertbase.first; - while(verg) { - if(verg->newv==NULL) { /* !!! */ + while (verg) { + if (verg->newv==NULL) { /* !!! */ v1= verg->next; - while(v1) { - if(v1->newv==NULL) { /* !?! */ - if(v1->vec.x==verg->vec.x && v1->vec.y==verg->vec.y) { + while (v1) { + if (v1->newv==NULL) { /* !?! */ + if (v1->vec.x==verg->vec.x && v1->vec.y==verg->vec.y) { /* printf("doublevert\n"); */ v1->newv= verg; } @@ -142,27 +142,27 @@ void removedouble_scrverts(bScreen *sc) /* replace pointers in edges and faces */ se= sc->edgebase.first; - while(se) { - if(se->v1->newv) se->v1= se->v1->newv; - if(se->v2->newv) se->v2= se->v2->newv; + while (se) { + if (se->v1->newv) se->v1= se->v1->newv; + if (se->v2->newv) se->v2= se->v2->newv; /* edges changed: so.... */ sortscrvert(&(se->v1), &(se->v2)); se= se->next; } sa= sc->areabase.first; - while(sa) { - if(sa->v1->newv) sa->v1= sa->v1->newv; - if(sa->v2->newv) sa->v2= sa->v2->newv; - if(sa->v3->newv) sa->v3= sa->v3->newv; - if(sa->v4->newv) sa->v4= sa->v4->newv; + while (sa) { + if (sa->v1->newv) sa->v1= sa->v1->newv; + if (sa->v2->newv) sa->v2= sa->v2->newv; + if (sa->v3->newv) sa->v3= sa->v3->newv; + if (sa->v4->newv) sa->v4= sa->v4->newv; sa= sa->next; } /* remove */ verg= sc->vertbase.first; - while(verg) { + while (verg) { v1= verg->next; - if(verg->newv) { + if (verg->newv) { BLI_remlink(&sc->vertbase, verg); MEM_freeN(verg); } @@ -179,16 +179,16 @@ void removenotused_scrverts(bScreen *sc) /* we assume edges are ok */ se= sc->edgebase.first; - while(se) { + while (se) { se->v1->flag= 1; se->v2->flag= 1; se= se->next; } sv= sc->vertbase.first; - while(sv) { + while (sv) { svn= sv->next; - if(sv->flag==0) { + if (sv->flag==0) { BLI_remlink(&sc->vertbase, sv); MEM_freeN(sv); } @@ -203,11 +203,11 @@ void removedouble_scredges(bScreen *sc) /* compare */ verg= sc->edgebase.first; - while(verg) { + while (verg) { se= verg->next; - while(se) { + while (se) { sn= se->next; - if(verg->v1==se->v1 && verg->v2==se->v2) { + if (verg->v1==se->v1 && verg->v2==se->v2) { BLI_remlink(&sc->edgebase, se); MEM_freeN(se); } @@ -225,26 +225,26 @@ void removenotused_scredges(bScreen *sc) /* sets flags when edge is used in area */ sa= sc->areabase.first; - while(sa) { + while (sa) { se= screen_findedge(sc, sa->v1, sa->v2); - if(se==NULL) printf("error: area %d edge 1 doesn't exist\n", a); + if (se==NULL) printf("error: area %d edge 1 doesn't exist\n", a); else se->flag= 1; se= screen_findedge(sc, sa->v2, sa->v3); - if(se==NULL) printf("error: area %d edge 2 doesn't exist\n", a); + if (se==NULL) printf("error: area %d edge 2 doesn't exist\n", a); else se->flag= 1; se= screen_findedge(sc, sa->v3, sa->v4); - if(se==NULL) printf("error: area %d edge 3 doesn't exist\n", a); + if (se==NULL) printf("error: area %d edge 3 doesn't exist\n", a); else se->flag= 1; se= screen_findedge(sc, sa->v4, sa->v1); - if(se==NULL) printf("error: area %d edge 4 doesn't exist\n", a); + if (se==NULL) printf("error: area %d edge 4 doesn't exist\n", a); else se->flag= 1; sa= sa->next; a++; } se= sc->edgebase.first; - while(se) { + while (se) { sen= se->next; - if(se->flag==0) { + if (se->flag==0) { BLI_remlink(&sc->edgebase, se); MEM_freeN(se); } @@ -320,18 +320,18 @@ static short testsplitpoint(ScrArea *sa, char dir, float fac) short x, y; // area big enough? - if(dir=='v' && (sa->v4->vec.x- sa->v1->vec.x <= 2*AREAMINX)) return 0; - if(dir=='h' && (sa->v2->vec.y- sa->v1->vec.y <= 2*AREAMINY)) return 0; + if (dir=='v' && (sa->v4->vec.x- sa->v1->vec.x <= 2*AREAMINX)) return 0; + if (dir=='h' && (sa->v2->vec.y- sa->v1->vec.y <= 2*AREAMINY)) return 0; // to be sure CLAMP(fac, 0.0f, 1.0f); - if(dir=='h') { + if (dir=='h') { y= sa->v1->vec.y+ fac*(sa->v2->vec.y- sa->v1->vec.y); - if(y- sa->v1->vec.y < AREAMINY) + if (y- sa->v1->vec.y < AREAMINY) y= sa->v1->vec.y+ AREAMINY; - else if(sa->v2->vec.y- y < AREAMINY) + else if (sa->v2->vec.y- y < AREAMINY) y= sa->v2->vec.y- AREAMINY; else y-= (y % AREAGRID); @@ -340,9 +340,9 @@ static short testsplitpoint(ScrArea *sa, char dir, float fac) else { x= sa->v1->vec.x+ fac*(sa->v4->vec.x- sa->v1->vec.x); - if(x- sa->v1->vec.x < AREAMINX) + if (x- sa->v1->vec.x < AREAMINX) x= sa->v1->vec.x+ AREAMINX; - else if(sa->v4->vec.x- x < AREAMINX) + else if (sa->v4->vec.x- x < AREAMINX) x= sa->v4->vec.x- AREAMINX; else x-= (x % AREAGRID); @@ -356,12 +356,12 @@ ScrArea *area_split(bScreen *sc, ScrArea *sa, char dir, float fac, int merge) ScrVert *sv1, *sv2; short split; - if(sa==NULL) return NULL; + if (sa==NULL) return NULL; split= testsplitpoint(sa, dir, fac); - if(split==0) return NULL; + if (split==0) return NULL; - if(dir=='h') { + if (dir=='h') { /* new vertices */ sv1= screen_addvert(sc, sa->v1->vec.x, split); sv2= screen_addvert(sc, sa->v4->vec.x, split); @@ -404,7 +404,7 @@ ScrArea *area_split(bScreen *sc, ScrArea *sa, char dir, float fac, int merge) } /* remove double vertices en edges */ - if(merge) + if (merge) removedouble_scrverts(sc); removedouble_scredges(sc); removenotused_scredges(sc); @@ -456,18 +456,18 @@ static void screen_copy(bScreen *to, bScreen *from) to->regionbase.first= to->regionbase.last= NULL; s2= to->vertbase.first; - for(s1= from->vertbase.first; s1; s1= s1->next, s2= s2->next) { + for (s1= from->vertbase.first; s1; s1= s1->next, s2= s2->next) { s1->newv= s2; } - for(se= to->edgebase.first; se; se= se->next) { + for (se= to->edgebase.first; se; se= se->next) { se->v1= se->v1->newv; se->v2= se->v2->newv; sortscrvert(&(se->v1), &(se->v2)); } saf= from->areabase.first; - for(sa= to->areabase.first; sa; sa= sa->next, saf= saf->next) { + for (sa= to->areabase.first; sa; sa= sa->next, saf= saf->next) { sa->v1= sa->v1->newv; sa->v2= sa->v2->newv; sa->v3= sa->v3->newv; @@ -482,7 +482,7 @@ static void screen_copy(bScreen *to, bScreen *from) } /* put at zero (needed?) */ - for(s1= from->vertbase.first; s1; s1= s1->next) + for (s1= from->vertbase.first; s1; s1= s1->next) s1->newv= NULL; } @@ -496,7 +496,7 @@ int area_getorientation(ScrArea *sa, ScrArea *sb) ScrVert *sav1, *sav2, *sav3, *sav4; ScrVert *sbv1, *sbv2, *sbv3, *sbv4; - if(sa==NULL || sb==NULL) return -1; + if (sa==NULL || sb==NULL) return -1; sav1= sa->v1; sav2= sa->v2; @@ -507,16 +507,16 @@ int area_getorientation(ScrArea *sa, ScrArea *sb) sbv3= sb->v3; sbv4= sb->v4; - if(sav1==sbv4 && sav2==sbv3) { /* sa to right of sb = W */ + if (sav1==sbv4 && sav2==sbv3) { /* sa to right of sb = W */ return 0; } - else if(sav2==sbv1 && sav3==sbv4) { /* sa to bottom of sb = N */ + else if (sav2==sbv1 && sav3==sbv4) { /* sa to bottom of sb = N */ return 1; } - else if(sav3==sbv2 && sav4==sbv1) { /* sa to left of sb = E */ + else if (sav3==sbv2 && sav4==sbv1) { /* sa to left of sb = E */ return 2; } - else if(sav1==sbv2 && sav4==sbv3) { /* sa on top of sb = S*/ + else if (sav1==sbv2 && sav4==sbv3) { /* sa on top of sb = S*/ return 3; } @@ -539,25 +539,25 @@ int screen_area_join(bContext *C, bScreen* scr, ScrArea *sa1, ScrArea *sa2) return 0; } - if(dir == 0) { + if (dir == 0) { sa1->v1= sa2->v1; sa1->v2= sa2->v2; screen_addedge(scr, sa1->v2, sa1->v3); screen_addedge(scr, sa1->v1, sa1->v4); } - else if(dir == 1) { + else if (dir == 1) { sa1->v2= sa2->v2; sa1->v3= sa2->v3; screen_addedge(scr, sa1->v1, sa1->v2); screen_addedge(scr, sa1->v3, sa1->v4); } - else if(dir == 2) { + else if (dir == 2) { sa1->v3= sa2->v3; sa1->v4= sa2->v4; screen_addedge(scr, sa1->v2, sa1->v3); screen_addedge(scr, sa1->v1, sa1->v4); } - else if(dir == 3) { + else if (dir == 3) { sa1->v1= sa2->v1; sa1->v4= sa2->v4; screen_addedge(scr, sa1->v1, sa1->v2); @@ -581,11 +581,11 @@ void select_connected_scredge(bScreen *sc, ScrEdge *edge) /* select connected, only in the right direction */ /* 'dir' is the direction of EDGE */ - if(edge->v1->vec.x==edge->v2->vec.x) dir= 'v'; + if (edge->v1->vec.x==edge->v2->vec.x) dir= 'v'; else dir= 'h'; sv= sc->vertbase.first; - while(sv) { + while (sv) { sv->flag = 0; sv= sv->next; } @@ -594,16 +594,16 @@ void select_connected_scredge(bScreen *sc, ScrEdge *edge) edge->v2->flag= 1; oneselected= 1; - while(oneselected) { + while (oneselected) { se= sc->edgebase.first; oneselected= 0; - while(se) { - if(se->v1->flag + se->v2->flag==1) { - if(dir=='h') if(se->v1->vec.y==se->v2->vec.y) { + while (se) { + if (se->v1->flag + se->v2->flag==1) { + if (dir=='h') if(se->v1->vec.y==se->v2->vec.y) { se->v1->flag= se->v2->flag= 1; oneselected= 1; } - if(dir=='v') if(se->v1->vec.x==se->v2->vec.x) { + if (dir=='v') if(se->v1->vec.x==se->v2->vec.x) { se->v1->flag= se->v2->flag= 1; oneselected= 1; } @@ -625,7 +625,7 @@ static void screen_test_scale(bScreen *sc, int winsizex, int winsizey) min[0]= min[1]= 10000.0f; max[0]= max[1]= 0.0f; - for(sv= sc->vertbase.first; sv; sv= sv->next) { + for (sv= sc->vertbase.first; sv; sv= sv->next) { min[0]= MIN2(min[0], sv->vec.x); min[1]= MIN2(min[1], sv->vec.y); max[0]= MAX2(max[0], sv->vec.x); @@ -633,7 +633,7 @@ static void screen_test_scale(bScreen *sc, int winsizex, int winsizey) } /* always make 0.0 left under */ - for(sv= sc->vertbase.first; sv; sv= sv->next) { + for (sv= sc->vertbase.first; sv; sv= sv->next) { sv->vec.x -= min[0]; sv->vec.y -= min[1]; } @@ -641,14 +641,14 @@ static void screen_test_scale(bScreen *sc, int winsizex, int winsizey) sizex= max[0]-min[0]; sizey= max[1]-min[1]; - if(sizex!= winsizex || sizey!= winsizey) { + if (sizex!= winsizex || sizey!= winsizey) { facx= winsizex; facx/= (float)sizex; facy= winsizey; facy/= (float)sizey; /* make sure it fits! */ - for(sv= sc->vertbase.first; sv; sv= sv->next) { + for (sv= sc->vertbase.first; sv; sv= sv->next) { /* FIXME, this re-sizing logic is no good when re-sizing the window + redrawing [#24428] * need some way to store these as floats internally and re-apply from there. */ tempf= ((float)sv->vec.x)*facx; @@ -671,13 +671,13 @@ static void screen_test_scale(bScreen *sc, int winsizex, int winsizey) /* ton: removed option now, it needs Context... */ /* make each window at least ED_area_headersize() high */ - for(sa= sc->areabase.first; sa; sa= sa->next) { + for (sa= sc->areabase.first; sa; sa= sa->next) { int headery= ED_area_headersize()+1; - if(sa->v1->vec.y+headery > sa->v2->vec.y) { + if (sa->v1->vec.y+headery > sa->v2->vec.y) { /* lower edge */ ScrEdge *se= screen_findedge(sc, sa->v4, sa->v1); - if(se && sa->v1!=sa->v2 ) { + if (se && sa->v1!=sa->v2 ) { int yval; select_connected_scredge(sc, se); @@ -685,10 +685,10 @@ static void screen_test_scale(bScreen *sc, int winsizex, int winsizey) /* all selected vertices get the right offset */ yval= sa->v2->vec.y-headery; sv= sc->vertbase.first; - while(sv) { + while (sv) { /* if is a collapsed area */ - if(sv!=sa->v2 && sv!=sa->v3) { - if(sv->flag) sv->vec.y= yval; + if (sv!=sa->v2 && sv!=sa->v3) { + if (sv->flag) sv->vec.y= yval; } sv= sv->next; } @@ -714,7 +714,7 @@ static void draw_horizontal_join_shape(ScrArea *sa, char dir) float width = sa->v3->vec.x - sa->v1->vec.x; float height = sa->v3->vec.y - sa->v1->vec.y; - if(heightv4->vec.x; points[9].y = sa->v4->vec.y + height/2 + h; - if(dir=='l') { + if (dir=='l') { /* when direction is left, then we flip direction of arrow */ float cx = sa->v1->vec.x + width; - for(i=0;i<10;i++) { + for (i=0;i<10;i++) { points[i].x -= cx; points[i].x = -points[i].x; points[i].x += sa->v1->vec.x; @@ -764,11 +764,11 @@ static void draw_horizontal_join_shape(ScrArea *sa, char dir) } glBegin(GL_POLYGON); - for(i=0;i<5;i++) + for (i=0;i<5;i++) glVertex2f(points[i].x, points[i].y); glEnd(); glBegin(GL_POLYGON); - for(i=4;i<8;i++) + for (i=4;i<8;i++) glVertex2f(points[i].x, points[i].y); glVertex2f(points[0].x, points[0].y); glEnd(); @@ -786,7 +786,7 @@ static void draw_vertical_join_shape(ScrArea *sa, char dir) float width = sa->v3->vec.x - sa->v1->vec.x; float height = sa->v3->vec.y - sa->v1->vec.y; - if(heightv1->vec.x + width/2 + w; points[9].y = sa->v1->vec.y; - if(dir=='u') { + if (dir=='u') { /* when direction is up, then we flip direction of arrow */ float cy = sa->v1->vec.y + height; - for(i=0;i<10;i++) { + for (i=0;i<10;i++) { points[i].y -= cy; points[i].y = -points[i].y; points[i].y += sa->v1->vec.y; @@ -836,11 +836,11 @@ static void draw_vertical_join_shape(ScrArea *sa, char dir) } glBegin(GL_POLYGON); - for(i=0;i<5;i++) + for (i=0;i<5;i++) glVertex2f(points[i].x, points[i].y); glEnd(); glBegin(GL_POLYGON); - for(i=4;i<8;i++) + for (i=4;i<8;i++) glVertex2f(points[i].x, points[i].y); glVertex2f(points[0].x, points[0].y); glEnd(); @@ -852,7 +852,7 @@ static void draw_vertical_join_shape(ScrArea *sa, char dir) /* draw join shape due to direction of joining */ static void draw_join_shape(ScrArea *sa, char dir) { - if(dir=='u' || dir=='d') + if (dir=='u' || dir=='d') draw_vertical_join_shape(sa, dir); else draw_horizontal_join_shape(sa, dir); @@ -883,19 +883,19 @@ static void scrarea_draw_shape_light(ScrArea *sa, char UNUSED(dir)) static void drawscredge_area_draw(int sizex, int sizey, short x1, short y1, short x2, short y2, short a) { /* right border area */ - if(x20) /* otherwise it draws the emboss of window over */ + if (x1>0) /* otherwise it draws the emboss of window over */ sdrawline(x1+a, y1, x1+a, y2); /* top border area */ - if(y20) + if (y1>0) sdrawline(x1, y1+a, x2, y1+a); } @@ -911,10 +911,10 @@ static void drawscredge_area(ScrArea *sa, int sizex, int sizey, int center) rt= 0; // CLAMPIS(G.rt, 0, 16); - if(center==0) { + if (center==0) { cpack(0x505050); - for(a=-rt; a<=rt; a++) - if(a!=0) + for (a=-rt; a<=rt; a++) + if (a!=0) drawscredge_area_draw(sizex, sizey, x1, y1, x2, y2, a); } else { @@ -929,7 +929,7 @@ bScreen *ED_screen_duplicate(wmWindow *win, bScreen *sc) { bScreen *newsc; - if(sc->full != SCREENNORMAL) return NULL; /* XXX handle this case! */ + if (sc->full != SCREENNORMAL) return NULL; /* XXX handle this case! */ /* make new empty screen: */ newsc= ED_screen_add(win, sc->scene, sc->id.name+2); @@ -944,11 +944,11 @@ static void region_cursor_set(wmWindow *win, int swinid) { ScrArea *sa= win->screen->areabase.first; - for(;sa; sa= sa->next) { + for (;sa; sa= sa->next) { ARegion *ar= sa->regionbase.first; - for(;ar; ar= ar->next) { - if(ar->swinid == swinid) { - if(ar->type && ar->type->cursor) + for (;ar; ar= ar->next) { + if (ar->swinid == swinid) { + if (ar->type && ar->type->cursor) ar->type->cursor(win, sa, ar); else WM_cursor_set(win, CURSOR_STD); @@ -965,20 +965,20 @@ void ED_screen_do_listen(bContext *C, wmNotifier *note) /* generic notes */ switch(note->category) { case NC_WM: - if(note->data==ND_FILEREAD) + if (note->data==ND_FILEREAD) win->screen->do_draw= 1; break; case NC_WINDOW: win->screen->do_draw= 1; break; case NC_SCREEN: - if(note->data==ND_SUBWINACTIVE) + if (note->data==ND_SUBWINACTIVE) uiFreeActiveButtons(C, win->screen); - if(note->action==NA_EDITED) + if (note->action==NA_EDITED) win->screen->do_draw= win->screen->do_refresh= 1; break; case NC_SCENE: - if(note->data==ND_MODE) + if (note->data==ND_MODE) region_cursor_set(win, note->swinid); break; } @@ -996,13 +996,13 @@ void ED_screen_draw(wmWindow *win) wmSubWindowSet(win, win->screen->mainwin); - for(sa= win->screen->areabase.first; sa; sa= sa->next) { + for (sa= win->screen->areabase.first; sa; sa= sa->next) { if (sa->flag & AREA_FLAG_DRAWJOINFROM) sa1 = sa; if (sa->flag & AREA_FLAG_DRAWJOINTO) sa2 = sa; if (sa->flag & (AREA_FLAG_DRAWSPLIT_H|AREA_FLAG_DRAWSPLIT_V)) sa3 = sa; drawscredge_area(sa, win->sizex, win->sizey, 0); } - for(sa= win->screen->areabase.first; sa; sa= sa->next) + for (sa= win->screen->areabase.first; sa; sa= sa->next) drawscredge_area(sa, win->sizex, win->sizey, 1); /* blended join arrow */ @@ -1033,11 +1033,11 @@ void ED_screen_draw(wmWindow *win) } /* splitpoint */ - if(sa3) { + if (sa3) { glEnable(GL_BLEND); glColor4ub(255, 255, 255, 100); - if(sa3->flag & AREA_FLAG_DRAWSPLIT_H) { + if (sa3->flag & AREA_FLAG_DRAWSPLIT_H) { sdrawline(sa3->totrct.xmin, win->eventstate->y, sa3->totrct.xmax, win->eventstate->y); glColor4ub(0, 0, 0, 100); sdrawline(sa3->totrct.xmin, win->eventstate->y+1, sa3->totrct.xmax, win->eventstate->y+1); @@ -1060,9 +1060,9 @@ static void screen_refresh_headersizes(void) const ListBase *lb= BKE_spacetypes_list(); SpaceType *st; - for(st= lb->first; st; st= st->next) { + for (st= lb->first; st; st= st->next) { ARegionType *art= BKE_regiontype_from_id(st, RGN_TYPE_HEADER); - if(art) art->prefsizey= ED_area_headersize(); + if (art) art->prefsizey= ED_area_headersize(); } } @@ -1082,7 +1082,7 @@ void ED_screen_refresh(wmWindowManager *wm, wmWindow *win) screen_test_scale(win->screen, win->sizex, win->sizey); - if(win->screen->mainwin==0) + if (win->screen->mainwin==0) win->screen->mainwin= wm_subwindow_open(win, &winrct); else wm_subwindow_position(win, win->screen->mainwin, &winrct); @@ -1090,18 +1090,18 @@ void ED_screen_refresh(wmWindowManager *wm, wmWindow *win) /* header size depends on DPI, let's verify */ screen_refresh_headersizes(); - for(sa= win->screen->areabase.first; sa; sa= sa->next) { + for (sa= win->screen->areabase.first; sa; sa= sa->next) { /* set spacetype and region callbacks, calls init() */ /* sets subwindows for regions, adds handlers */ ED_area_initialize(wm, win, sa); } /* wake up animtimer */ - if(win->screen->animtimer) + if (win->screen->animtimer) WM_event_timer_sleep(wm, win, win->screen->animtimer, 0); } - if(G.f & G_DEBUG) printf("set screen\n"); + if (G.f & G_DEBUG) printf("set screen\n"); win->screen->do_refresh= 0; win->screen->context= ed_screen_context; @@ -1112,9 +1112,9 @@ void ED_screens_initialize(wmWindowManager *wm) { wmWindow *win; - for(win= wm->windows.first; win; win= win->next) { + for (win= wm->windows.first; win; win= win->next) { - if(win->screen==NULL) + if (win->screen==NULL) win->screen= G.main->screen.first; ED_screen_refresh(wm, win); @@ -1130,11 +1130,11 @@ void ED_region_exit(bContext *C, ARegion *ar) CTX_wm_region_set(C, ar); WM_event_remove_handlers(C, &ar->handlers); - if(ar->swinid) + if (ar->swinid) wm_subwindow_close(CTX_wm_window(C), ar->swinid); ar->swinid= 0; - if(ar->headerstr) + if (ar->headerstr) MEM_freeN(ar->headerstr); ar->headerstr= NULL; @@ -1148,13 +1148,13 @@ void ED_area_exit(bContext *C, ScrArea *sa) if (sa->spacetype == SPACE_FILE) { SpaceLink *sl= sa->spacedata.first; - if(sl && sl->spacetype == SPACE_FILE) { + if (sl && sl->spacetype == SPACE_FILE) { ED_fileselect_exit(C, (SpaceFile *)sl); } } CTX_wm_area_set(C, sa); - for(ar= sa->regionbase.first; ar; ar= ar->next) + for (ar= sa->regionbase.first; ar; ar= ar->next) ED_region_exit(C, ar); WM_event_remove_handlers(C, &sa->handlers); @@ -1170,19 +1170,19 @@ void ED_screen_exit(bContext *C, wmWindow *window, bScreen *screen) CTX_wm_window_set(C, window); - if(screen->animtimer) + if (screen->animtimer) WM_event_remove_timer(wm, window, screen->animtimer); screen->animtimer= NULL; - if(screen->mainwin) + if (screen->mainwin) wm_subwindow_close(window, screen->mainwin); screen->mainwin= 0; screen->subwinactive= 0; - for(ar= screen->regionbase.first; ar; ar= ar->next) + for (ar= screen->regionbase.first; ar; ar= ar->next) ED_region_exit(C, ar); - for(sa= screen->areabase.first; sa; sa= sa->next) + for (sa= screen->areabase.first; sa; sa= sa->next) ED_area_exit(C, sa); /* mark it available for use for other windows */ @@ -1191,7 +1191,8 @@ void ED_screen_exit(bContext *C, wmWindow *window, bScreen *screen) if (prevwin->screen->temp == 0) { /* use previous window if possible */ CTX_wm_window_set(C, prevwin); - } else { + } + else { /* none otherwise */ CTX_wm_window_set(C, NULL); } @@ -1206,15 +1207,15 @@ static void screen_cursor_set(wmWindow *win, wmEvent *event) AZone *az= NULL; ScrArea *sa; - for(sa= win->screen->areabase.first; sa; sa= sa->next) - if((az=is_in_area_actionzone(sa, event->x, event->y))) + for (sa= win->screen->areabase.first; sa; sa= sa->next) + if ((az=is_in_area_actionzone(sa, event->x, event->y))) break; - if(sa) { - if(az->type==AZONE_AREA) + if (sa) { + if (az->type==AZONE_AREA) WM_cursor_set(win, CURSOR_EDIT); - else if(az->type==AZONE_REGION) { - if(az->edge == AE_LEFT_TO_TOPRIGHT || az->edge == AE_RIGHT_TO_TOPLEFT) + else if (az->type==AZONE_REGION) { + if (az->edge == AE_LEFT_TO_TOPRIGHT || az->edge == AE_RIGHT_TO_TOPLEFT) WM_cursor_set(win, CURSOR_X_MOVE); else WM_cursor_set(win, CURSOR_Y_MOVE); @@ -1224,7 +1225,7 @@ static void screen_cursor_set(wmWindow *win, wmEvent *event) ScrEdge *actedge= screen_find_active_scredge(win->screen, event->x, event->y); if (actedge) { - if(scredge_is_horizontal(actedge)) + if (scredge_is_horizontal(actedge)) WM_cursor_set(win, CURSOR_Y_MOVE); else WM_cursor_set(win, CURSOR_X_MOVE); @@ -1241,21 +1242,21 @@ void ED_screen_set_subwinactive(bContext *C, wmEvent *event) { wmWindow *win= CTX_wm_window(C); - if(win->screen) { + if (win->screen) { bScreen *scr= win->screen; ScrArea *sa; ARegion *ar; int oldswin= scr->subwinactive; - for(sa= scr->areabase.first; sa; sa= sa->next) { - if(event->x > sa->totrct.xmin && event->x < sa->totrct.xmax) - if(event->y > sa->totrct.ymin && event->y < sa->totrct.ymax) - if(NULL==is_in_area_actionzone(sa, event->x, event->y)) + for (sa= scr->areabase.first; sa; sa= sa->next) { + if (event->x > sa->totrct.xmin && event->x < sa->totrct.xmax) + if (event->y > sa->totrct.ymin && event->y < sa->totrct.ymax) + if (NULL==is_in_area_actionzone(sa, event->x, event->y)) break; } - if(sa) { - for(ar= sa->regionbase.first; ar; ar= ar->next) { - if(BLI_in_rcti(&ar->winrct, event->x, event->y)) + if (sa) { + for (ar= sa->regionbase.first; ar; ar= ar->next) { + if (BLI_in_rcti(&ar->winrct, event->x, event->y)) scr->subwinactive= ar->swinid; } } @@ -1263,28 +1264,28 @@ void ED_screen_set_subwinactive(bContext *C, wmEvent *event) scr->subwinactive= scr->mainwin; /* check for redraw headers */ - if(oldswin!=scr->subwinactive) { + if (oldswin!=scr->subwinactive) { - for(sa= scr->areabase.first; sa; sa= sa->next) { + for (sa= scr->areabase.first; sa; sa= sa->next) { int do_draw= 0; - for(ar= sa->regionbase.first; ar; ar= ar->next) - if(ar->swinid==oldswin || ar->swinid==scr->subwinactive) + for (ar= sa->regionbase.first; ar; ar= ar->next) + if (ar->swinid==oldswin || ar->swinid==scr->subwinactive) do_draw= 1; - if(do_draw) { - for(ar= sa->regionbase.first; ar; ar= ar->next) - if(ar->regiontype==RGN_TYPE_HEADER) + if (do_draw) { + for (ar= sa->regionbase.first; ar; ar= ar->next) + if (ar->regiontype==RGN_TYPE_HEADER) ED_region_tag_redraw(ar); } } } /* cursors, for time being set always on edges, otherwise aregion doesnt switch */ - if(scr->subwinactive==scr->mainwin) { + if (scr->subwinactive==scr->mainwin) { screen_cursor_set(win, event); } - else if(oldswin!=scr->subwinactive) { + else if (oldswin!=scr->subwinactive) { region_cursor_set(win, scr->subwinactive); WM_event_add_notifier(C, NC_SCREEN|ND_SUBWINACTIVE, scr); } @@ -1297,15 +1298,15 @@ int ED_screen_area_active(const bContext *C) bScreen *sc= CTX_wm_screen(C); ScrArea *sa= CTX_wm_area(C); - if(win && sc && sa) { + if (win && sc && sa) { AZone *az= is_in_area_actionzone(sa, win->eventstate->x, win->eventstate->y); ARegion *ar; if (az && az->type == AZONE_REGION) return 1; - for(ar= sa->regionbase.first; ar; ar= ar->next) - if(ar->swinid == sc->subwinactive) + for (ar= sa->regionbase.first; ar; ar= ar->next) + if (ar->swinid == sc->subwinactive) return 1; } return 0; @@ -1321,21 +1322,21 @@ void ED_screen_set(bContext *C, bScreen *sc) ID *id; /* validate screen, it's called with notifier reference */ - for(id= CTX_data_main(C)->screen.first; id; id= id->next) - if(sc == (bScreen *)id) + for (id= CTX_data_main(C)->screen.first; id; id= id->next) + if (sc == (bScreen *)id) break; - if(id==NULL) + if (id==NULL) return; /* check for valid winid */ - if(sc->winid!=0 && sc->winid!=win->winid) + if (sc->winid!=0 && sc->winid!=win->winid) return; - if(sc->full) { /* find associated full */ + if (sc->full) { /* find associated full */ bScreen *sc1; - for(sc1= CTX_data_main(C)->screen.first; sc1; sc1= sc1->id.next) { + for (sc1= CTX_data_main(C)->screen.first; sc1; sc1= sc1->id.next) { ScrArea *sa= sc1->areabase.first; - if(sa->full==sc) { + if (sa->full==sc) { sc= sc1; break; } @@ -1347,13 +1348,13 @@ void ED_screen_set(bContext *C, bScreen *sc) ScrArea *sa; /* remove handlers referencing areas in old screen */ - for(sa = oldscreen->areabase.first; sa; sa = sa->next) { + for (sa = oldscreen->areabase.first; sa; sa = sa->next) { WM_event_remove_area_handler(&win->modalhandlers, sa); } /* we put timer to sleep, so screen_exit has to think there's no timer */ oldscreen->animtimer= NULL; - if(wt) + if (wt) WM_event_timer_sleep(wm, win, wt, 1); ED_screen_exit(C, win, oldscreen); @@ -1378,8 +1379,8 @@ static int ed_screen_used(wmWindowManager *wm, bScreen *sc) { wmWindow *win; - for(win=wm->windows.first; win; win=win->next) - if(win->screen == sc) + for (win=wm->windows.first; win; win=win->next) + if (win->screen == sc) return 1; return 0; @@ -1404,22 +1405,22 @@ void ED_screen_delete(bContext *C, bScreen *sc) * long as we are able to find a screen that is unused, we * can safely assume ours is not in use anywhere an delete it */ - for(newsc= sc->id.prev; newsc; newsc=newsc->id.prev) - if(!ed_screen_used(wm, newsc)) + for (newsc= sc->id.prev; newsc; newsc=newsc->id.prev) + if (!ed_screen_used(wm, newsc)) break; - if(!newsc) { - for(newsc= sc->id.next; newsc; newsc=newsc->id.next) - if(!ed_screen_used(wm, newsc)) + if (!newsc) { + for (newsc= sc->id.next; newsc; newsc=newsc->id.next) + if (!ed_screen_used(wm, newsc)) break; } - if(!newsc) + if (!newsc) return; ED_screen_set(C, newsc); - if(delete && win->screen != sc) + if (delete && win->screen != sc) free_libblock(&bmain->screen, sc); } @@ -1429,19 +1430,19 @@ void ED_screen_set_scene(bContext *C, bScreen *screen, Scene *scene) Main *bmain= CTX_data_main(C); bScreen *sc; - if(screen == NULL) + if (screen == NULL) return; - if(ed_screen_used(CTX_wm_manager(C), screen)) + if (ed_screen_used(CTX_wm_manager(C), screen)) ED_object_exit_editmode(C, EM_FREEDATA|EM_DO_UNDO); - for(sc= CTX_data_main(C)->screen.first; sc; sc= sc->id.next) { - if((U.flag & USER_SCENEGLOBAL) || sc==screen) { + for (sc= CTX_data_main(C)->screen.first; sc; sc= sc->id.next) { + if ((U.flag & USER_SCENEGLOBAL) || sc==screen) { - if(scene != sc->scene) { + if (scene != sc->scene) { /* all areas endlocalview */ // XXX ScrArea *sa= sc->areabase.first; - // while(sa) { + // while (sa) { // endlocalview(sa); // sa= sa->next; // } @@ -1454,13 +1455,13 @@ void ED_screen_set_scene(bContext *C, bScreen *screen, Scene *scene) // copy_view3d_lock(0); /* space.c */ /* are there cameras in the views that are not in the scene? */ - for(sc= CTX_data_main(C)->screen.first; sc; sc= sc->id.next) { - if( (U.flag & USER_SCENEGLOBAL) || sc==screen) { + for (sc= CTX_data_main(C)->screen.first; sc; sc= sc->id.next) { + if ( (U.flag & USER_SCENEGLOBAL) || sc==screen) { ScrArea *sa= sc->areabase.first; - while(sa) { + while (sa) { SpaceLink *sl= sa->spacedata.first; - while(sl) { - if(sl->spacetype==SPACE_VIEW3D) { + while (sl) { + if (sl->spacetype==SPACE_VIEW3D) { View3D *v3d= (View3D*) sl; BKE_screen_view3d_sync(v3d, scene); @@ -1470,11 +1471,11 @@ void ED_screen_set_scene(bContext *C, bScreen *screen, Scene *scene) // XXX if (sc==curscreen) handle_view3d_lock(); if (!v3d->camera) { ARegion *ar; - for(ar=v3d->regionbase.first; ar; ar= ar->next) { - if(ar->regiontype == RGN_TYPE_WINDOW) { + for (ar=v3d->regionbase.first; ar; ar= ar->next) { + if (ar->regiontype == RGN_TYPE_WINDOW) { RegionView3D *rv3d= ar->regiondata; - if(rv3d->persp==RV3D_CAMOB) + if (rv3d->persp==RV3D_CAMOB) rv3d->persp= RV3D_PERSP; } } @@ -1505,9 +1506,9 @@ void ED_screen_delete_scene(bContext *C, Scene *scene) Main *bmain= CTX_data_main(C); Scene *newscene; - if(scene->id.prev) + if (scene->id.prev) newscene= scene->id.prev; - else if(scene->id.next) + else if (scene->id.next) newscene= scene->id.next; else return; @@ -1523,11 +1524,11 @@ ScrArea *ED_screen_full_newspace(bContext *C, ScrArea *sa, int type) bScreen *screen= CTX_wm_screen(C); ScrArea *newsa= NULL; - if(!sa || sa->full==NULL) { + if (!sa || sa->full==NULL) { newsa= ED_screen_full_toggle(C, win, sa); } - if(!newsa) { + if (!newsa) { if (sa->full) { /* if this has been called from the temporary info header generated in * temp fullscreen layouts, find the correct fullscreen area to change @@ -1536,8 +1537,10 @@ ScrArea *ED_screen_full_newspace(bContext *C, ScrArea *sa, int type) if (!(sa->flag & AREA_TEMP_INFO)) break; } - } else - newsa= sa; + } + else { + newsa = sa; + } } ED_area_newspace(C, newsa, type); @@ -1551,7 +1554,7 @@ void ED_screen_full_prevspace(bContext *C, ScrArea *sa) ED_area_prevspace(C, sa); - if(sa->full) + if (sa->full) ED_screen_full_toggle(C, win, sa); } @@ -1584,10 +1587,13 @@ void ED_screen_full_restore(bContext *C, ScrArea *sa) sima->flag &= ~SI_FULLWINDOW; ED_screen_full_prevspace(C, sa); } - } else if (sl->spacetype == SPACE_FILE) { + } + else if (sl->spacetype == SPACE_FILE) { ED_screen_full_prevspace(C, sa); - } else + } + else { ED_screen_full_toggle(C, win, sa); + } } /* otherwise just tile the area again */ else { @@ -1601,18 +1607,18 @@ ScrArea *ED_screen_full_toggle(bContext *C, wmWindow *win, ScrArea *sa) bScreen *sc, *oldscreen; ARegion *ar; - if(sa) { + if (sa) { /* ensure we don't have a button active anymore, can crash when * switching screens with tooltip open because region and tooltip * are no longer in the same screen */ - for(ar=sa->regionbase.first; ar; ar=ar->next) + for (ar=sa->regionbase.first; ar; ar=ar->next) uiFreeBlocks(C, &ar->uiblocks); /* prevent hanging header prints */ ED_area_headerprint(sa, NULL); } - if(sa && sa->full) { + if (sa && sa->full) { ScrArea *old; /*short fulltype;*/ /*UNUSED*/ @@ -1625,9 +1631,9 @@ ScrArea *ED_screen_full_toggle(bContext *C, wmWindow *win, ScrArea *sa) /* removed: SCREENAUTOPLAY exception here */ /* find old area */ - for(old= sc->areabase.first; old; old= old->next) - if(old->full) break; - if(old==NULL) { + for (old= sc->areabase.first; old; old= old->next) + if (old->full) break; + if (old==NULL) { if (G.f & G_DEBUG) printf("something wrong in areafullscreen\n"); return NULL; @@ -1656,7 +1662,7 @@ ScrArea *ED_screen_full_toggle(bContext *C, wmWindow *win, ScrArea *sa) /* nothing wrong with having only 1 area, as far as I can see... * is there only 1 area? */ #if 0 - if(oldscreen->areabase.first==oldscreen->areabase.last) + if (oldscreen->areabase.first==oldscreen->areabase.last) return NULL; #endif @@ -1675,7 +1681,7 @@ ScrArea *ED_screen_full_toggle(bContext *C, wmWindow *win, ScrArea *sa) /* use random area when we have no active one, e.g. when the * mouse is outside of the window and we open a file browser */ - if(!sa) + if (!sa) sa= oldscreen->areabase.first; /* copy area */ @@ -1732,11 +1738,11 @@ void ED_screen_animation_timer(bContext *C, int redraws, int refresh, int sync, wmWindow *win= CTX_wm_window(C); Scene *scene= CTX_data_scene(C); - if(screen->animtimer) + if (screen->animtimer) WM_event_remove_timer(wm, win, screen->animtimer); screen->animtimer= NULL; - if(enable) { + if (enable) { ScreenAnimData *sad= MEM_callocN(sizeof(ScreenAnimData), "ScreenAnimData"); screen->animtimer= WM_event_add_timer(wm, win, TIMER0, (1.0/FPS)); @@ -1744,7 +1750,7 @@ void ED_screen_animation_timer(bContext *C, int redraws, int refresh, int sync, sad->ar= CTX_wm_region(C); /* if startframe is larger than current frame, we put currentframe on startframe. * note: first frame then is not drawn! (ton) */ - if(scene->r.sfra > scene->r.cfra) { + if (scene->r.sfra > scene->r.cfra) { sad->sfra= scene->r.cfra; scene->r.cfra= scene->r.sfra; } @@ -1769,12 +1775,12 @@ static ARegion *time_top_left_3dwindow(bScreen *screen) ScrArea *sa; int min= 10000; - for(sa= screen->areabase.first; sa; sa= sa->next) { - if(sa->spacetype==SPACE_VIEW3D) { + for (sa= screen->areabase.first; sa; sa= sa->next) { + if (sa->spacetype==SPACE_VIEW3D) { ARegion *ar; - for(ar= sa->regionbase.first; ar; ar= ar->next) { - if(ar->regiontype==RGN_TYPE_WINDOW) { - if(ar->winrct.xmin - ar->winrct.ymin < min) { + for (ar= sa->regionbase.first; ar; ar= ar->next) { + if (ar->regiontype==RGN_TYPE_WINDOW) { + if (ar->winrct.xmin - ar->winrct.ymin < min) { aret= ar; min= ar->winrct.xmin - ar->winrct.ymin; } @@ -1788,14 +1794,14 @@ static ARegion *time_top_left_3dwindow(bScreen *screen) void ED_screen_animation_timer_update(bScreen *screen, int redraws, int refresh) { - if(screen && screen->animtimer) { + if (screen && screen->animtimer) { wmTimer *wt= screen->animtimer; ScreenAnimData *sad= wt->customdata; sad->redraws= redraws; sad->refresh= refresh; sad->ar= NULL; - if(redraws & TIME_REGION) + if (redraws & TIME_REGION) sad->ar= time_top_left_3dwindow(screen); } } @@ -1806,11 +1812,11 @@ void ED_update_for_newframe(Main *bmain, Scene *scene, bScreen *screen, int UNUS { #ifdef DURIAN_CAMERA_SWITCH void *camera= scene_camera_switch_find(scene); - if(camera && scene->camera != camera) { + if (camera && scene->camera != camera) { bScreen *sc; scene->camera= camera; /* are there cameras in the views that are not in the scene? */ - for(sc= bmain->screen.first; sc; sc= sc->id.next) { + for (sc= bmain->screen.first; sc; sc= sc->id.next) { BKE_screen_view3d_scene_sync(sc); } } @@ -1838,13 +1844,13 @@ void ED_update_for_newframe(Main *bmain, Scene *scene, bScreen *screen, int UNUS //BIF_image_update_frame(); /* composite */ - if(scene->use_nodes && scene->nodetree) + if (scene->use_nodes && scene->nodetree) ntreeCompositTagAnimated(scene->nodetree); /* update animated texture nodes */ { Tex *tex; - for(tex= bmain->tex.first; tex; tex= tex->id.next) + for (tex= bmain->tex.first; tex; tex= tex->id.next) if (tex->use_nodes && tex->nodetree) { ntreeTexTagAnimated(tex->nodetree); } diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c index 00915be9758..d6a74cc19ce 100644 --- a/source/blender/editors/screen/screen_ops.c +++ b/source/blender/editors/screen/screen_ops.c @@ -89,42 +89,42 @@ int ED_operator_regionactive(bContext *C) { - if(CTX_wm_window(C)==NULL) return 0; - if(CTX_wm_screen(C)==NULL) return 0; - if(CTX_wm_region(C)==NULL) return 0; + if (CTX_wm_window(C)==NULL) return 0; + if (CTX_wm_screen(C)==NULL) return 0; + if (CTX_wm_region(C)==NULL) return 0; return 1; } int ED_operator_areaactive(bContext *C) { - if(CTX_wm_window(C)==NULL) return 0; - if(CTX_wm_screen(C)==NULL) return 0; - if(CTX_wm_area(C)==NULL) return 0; + if (CTX_wm_window(C)==NULL) return 0; + if (CTX_wm_screen(C)==NULL) return 0; + if (CTX_wm_area(C)==NULL) return 0; return 1; } int ED_operator_screenactive(bContext *C) { - if(CTX_wm_window(C)==NULL) return 0; - if(CTX_wm_screen(C)==NULL) return 0; + if (CTX_wm_window(C)==NULL) return 0; + if (CTX_wm_screen(C)==NULL) return 0; return 1; } /* XXX added this to prevent anim state to change during renders */ static int ED_operator_screenactive_norender(bContext *C) { - if(G.rendering) return 0; - if(CTX_wm_window(C)==NULL) return 0; - if(CTX_wm_screen(C)==NULL) return 0; + if (G.rendering) return 0; + if (CTX_wm_window(C)==NULL) return 0; + if (CTX_wm_screen(C)==NULL) return 0; return 1; } static int screen_active_editable(bContext *C) { - if(ED_operator_screenactive(C)) { + if (ED_operator_screenactive(C)) { /* no full window splitting allowed */ - if(CTX_wm_screen(C)->full != SCREENNORMAL) + if (CTX_wm_screen(C)->full != SCREENNORMAL) return 0; return 1; } @@ -134,8 +134,8 @@ static int screen_active_editable(bContext *C) /* when mouse is over area-edge */ int ED_operator_screen_mainwinactive(bContext *C) { - if(CTX_wm_window(C)==NULL) return 0; - if(CTX_wm_screen(C)==NULL) return 0; + if (CTX_wm_window(C)==NULL) return 0; + if (CTX_wm_screen(C)==NULL) return 0; if (CTX_wm_screen(C)->subwinactive!=CTX_wm_screen(C)->mainwin) return 0; return 1; } @@ -143,7 +143,7 @@ int ED_operator_screen_mainwinactive(bContext *C) int ED_operator_scene_editable(bContext *C) { Scene *scene= CTX_data_scene(C); - if(scene && scene->id.lib==NULL) + if (scene && scene->id.lib==NULL) return 1; return 0; } @@ -153,13 +153,13 @@ int ED_operator_objectmode(bContext *C) Scene *scene= CTX_data_scene(C); Object *obact= CTX_data_active_object(C); - if(scene==NULL || scene->id.lib) + if (scene==NULL || scene->id.lib) return 0; - if( CTX_data_edit_object(C) ) + if ( CTX_data_edit_object(C) ) return 0; /* add a check for ob->mode too? */ - if(obact && obact->mode) + if (obact && obact->mode) return 0; return 1; @@ -168,7 +168,7 @@ int ED_operator_objectmode(bContext *C) static int ed_spacetype_test(bContext *C, int type) { - if(ED_operator_areaactive(C)) { + if (ED_operator_areaactive(C)) { SpaceLink *sl= (SpaceLink *)CTX_wm_space_data(C); return sl && (sl->spacetype == type); } @@ -182,7 +182,7 @@ int ED_operator_view3d_active(bContext *C) int ED_operator_region_view3d_active(bContext *C) { - if(CTX_wm_region_view3d(C)) + if (CTX_wm_region_view3d(C)) return TRUE; CTX_wm_operator_poll_msg_set(C, "expected a view3d region"); @@ -192,7 +192,7 @@ int ED_operator_region_view3d_active(bContext *C) /* generic for any view2d which uses anim_ops */ int ED_operator_animview_active(bContext *C) { - if(ED_operator_areaactive(C)) { + if (ED_operator_areaactive(C)) { SpaceLink *sl= (SpaceLink *)CTX_wm_space_data(C); if (sl && (ELEM5(sl->spacetype, SPACE_SEQ, SPACE_ACTION, SPACE_NLA, SPACE_IPO, SPACE_TIME))) return TRUE; @@ -214,10 +214,10 @@ int ED_operator_outliner_active(bContext *C) int ED_operator_outliner_active_no_editobject(bContext *C) { - if(ed_spacetype_test(C, SPACE_OUTLINER)) { + if (ed_spacetype_test(C, SPACE_OUTLINER)) { Object *ob = ED_object_active_context(C); Object *obedit= CTX_data_edit_object(C); - if(ob && ob == obedit) + if (ob && ob == obedit) return 0; else return 1; @@ -244,7 +244,7 @@ int ED_operator_node_active(bContext *C) { SpaceNode *snode= CTX_wm_space_node(C); - if(snode && snode->edittree) + if (snode && snode->edittree) return 1; return 0; @@ -314,7 +314,7 @@ int ED_operator_object_active_editable_font(bContext *C) int ED_operator_editmesh(bContext *C) { Object *obedit= CTX_data_edit_object(C); - if(obedit && obedit->type==OB_MESH) + if (obedit && obedit->type==OB_MESH) return NULL != BMEdit_FromObject(obedit); return 0; } @@ -326,7 +326,7 @@ int ED_operator_editmesh_view3d(bContext *C) int ED_operator_editmesh_region_view3d(bContext *C) { - if(ED_operator_editmesh(C) && CTX_wm_region_view3d(C)) + if (ED_operator_editmesh(C) && CTX_wm_region_view3d(C)) return 1; CTX_wm_operator_poll_msg_set(C, "expected a view3d region & editmesh"); @@ -336,7 +336,7 @@ int ED_operator_editmesh_region_view3d(bContext *C) int ED_operator_editarmature(bContext *C) { Object *obedit= CTX_data_edit_object(C); - if(obedit && obedit->type==OB_ARMATURE) + if (obedit && obedit->type==OB_ARMATURE) return NULL != ((bArmature *)obedit->data)->edbo; return 0; } @@ -347,8 +347,8 @@ int ED_operator_posemode(bContext *C) if (obact && !(obact->mode & OB_MODE_EDIT)) { Object *obpose; - if((obpose= object_pose_armature_get(obact))) { - if((obact == obpose) || (obact->mode & OB_MODE_WEIGHT_PAINT)) { + if ((obpose= object_pose_armature_get(obact))) { + if ((obact == obpose) || (obact->mode & OB_MODE_WEIGHT_PAINT)) { return 1; } } @@ -370,11 +370,11 @@ int ED_operator_uvmap(bContext *C) Object *obedit = CTX_data_edit_object(C); BMEditMesh *em = NULL; - if(obedit && obedit->type == OB_MESH) { + if (obedit && obedit->type == OB_MESH) { em = BMEdit_FromObject(obedit); } - if(em && (em->bm->totface)) { + if (em && (em->bm->totface)) { return TRUE; } @@ -384,14 +384,14 @@ int ED_operator_uvmap(bContext *C) int ED_operator_editsurfcurve(bContext *C) { Object *obedit= CTX_data_edit_object(C); - if(obedit && ELEM(obedit->type, OB_CURVE, OB_SURF)) + if (obedit && ELEM(obedit->type, OB_CURVE, OB_SURF)) return NULL != ((Curve *)obedit->data)->editnurb; return 0; } int ED_operator_editsurfcurve_region_view3d(bContext *C) { - if(ED_operator_editsurfcurve(C) && CTX_wm_region_view3d(C)) + if (ED_operator_editsurfcurve(C) && CTX_wm_region_view3d(C)) return 1; CTX_wm_operator_poll_msg_set(C, "expected a view3d region & editcurve"); @@ -401,7 +401,7 @@ int ED_operator_editsurfcurve_region_view3d(bContext *C) int ED_operator_editcurve(bContext *C) { Object *obedit= CTX_data_edit_object(C); - if(obedit && obedit->type==OB_CURVE) + if (obedit && obedit->type==OB_CURVE) return NULL != ((Curve *)obedit->data)->editnurb; return 0; } @@ -409,7 +409,7 @@ int ED_operator_editcurve(bContext *C) int ED_operator_editcurve_3d(bContext *C) { Object *obedit= CTX_data_edit_object(C); - if(obedit && obedit->type==OB_CURVE) { + if (obedit && obedit->type==OB_CURVE) { Curve *cu= (Curve *)obedit->data; return (cu->flag&CU_3D) && (NULL != cu->editnurb); @@ -420,7 +420,7 @@ int ED_operator_editcurve_3d(bContext *C) int ED_operator_editsurf(bContext *C) { Object *obedit= CTX_data_edit_object(C); - if(obedit && obedit->type==OB_SURF) + if (obedit && obedit->type==OB_SURF) return NULL != ((Curve *)obedit->data)->editnurb; return 0; } @@ -428,7 +428,7 @@ int ED_operator_editsurf(bContext *C) int ED_operator_editfont(bContext *C) { Object *obedit= CTX_data_edit_object(C); - if(obedit && obedit->type==OB_FONT) + if (obedit && obedit->type==OB_FONT) return NULL != ((Curve *)obedit->data)->editfont; return 0; } @@ -436,7 +436,7 @@ int ED_operator_editfont(bContext *C) int ED_operator_editlattice(bContext *C) { Object *obedit= CTX_data_edit_object(C); - if(obedit && obedit->type==OB_LATTICE) + if (obedit && obedit->type==OB_LATTICE) return NULL != ((Lattice *)obedit->data)->editlatt; return 0; } @@ -444,7 +444,7 @@ int ED_operator_editlattice(bContext *C) int ED_operator_editmball(bContext *C) { Object *obedit= CTX_data_edit_object(C); - if(obedit && obedit->type==OB_MBALL) + if (obedit && obedit->type==OB_MBALL) return NULL != ((MetaBall *)obedit->data)->editelems; return 0; } @@ -484,8 +484,8 @@ static ScrArea *screen_areahascursor(bScreen *scr, int x, int y) { ScrArea *sa= NULL; sa= scr->areabase.first; - while(sa) { - if(BLI_in_rcti(&sa->totrct, x, y)) break; + while (sa) { + if (BLI_in_rcti(&sa->totrct, x, y)) break; sa= sa->next; } @@ -498,13 +498,13 @@ static int actionzone_area_poll(bContext *C) wmWindow *win= CTX_wm_window(C); ScrArea *sa= CTX_wm_area(C); - if(sa && win) { + if (sa && win) { AZone *az; int x= win->eventstate->x; int y= win->eventstate->y; - for(az= sa->actionzones.first; az; az= az->next) - if(BLI_in_rcti(&az->rect, x, y)) + for (az= sa->actionzones.first; az; az= az->next) + if (BLI_in_rcti(&az->rect, x, y)) return 1; } return 0; @@ -514,16 +514,16 @@ AZone *is_in_area_actionzone(ScrArea *sa, int x, int y) { AZone *az= NULL; - for(az= sa->actionzones.first; az; az= az->next) { - if(BLI_in_rcti(&az->rect, x, y)) { - if(az->type == AZONE_AREA) { + for (az= sa->actionzones.first; az; az= az->next) { + if (BLI_in_rcti(&az->rect, x, y)) { + if (az->type == AZONE_AREA) { /* no triangle intersect but a hotspot circle based on corner */ int radius= (x-az->x1)*(x-az->x1) + (y-az->y1)*(y-az->y1); - if(radius <= AZONESPOT*AZONESPOT) + if (radius <= AZONESPOT*AZONESPOT) break; } - else if(az->type == AZONE_REGION) { + else if (az->type == AZONE_REGION) { break; } } @@ -535,7 +535,7 @@ AZone *is_in_area_actionzone(ScrArea *sa, int x, int y) static void actionzone_exit(wmOperator *op) { - if(op->customdata) + if (op->customdata) MEM_freeN(op->customdata); op->customdata= NULL; } @@ -550,7 +550,7 @@ static void actionzone_apply(bContext *C, wmOperator *op, int type) sad->modifier= RNA_int_get(op->ptr, "modifier"); event= *(win->eventstate); /* XXX huh huh? make api call */ - if(type==AZONE_AREA) + if (type==AZONE_AREA) event.type= EVT_ACTIONZONE_AREA; else event.type= EVT_ACTIONZONE_REGION; @@ -567,7 +567,7 @@ static int actionzone_invoke(bContext *C, wmOperator *op, wmEvent *event) sActionzoneData *sad; /* quick escape */ - if(az==NULL) + if (az==NULL) return OPERATOR_PASS_THROUGH; /* ok we do the actionzone */ @@ -577,7 +577,7 @@ static int actionzone_invoke(bContext *C, wmOperator *op, wmEvent *event) sad->x= event->x; sad->y= event->y; /* region azone directly reacts on mouse clicks */ - if(sad->az->type==AZONE_REGION) { + if (sad->az->type==AZONE_REGION) { actionzone_apply(C, op, AZONE_REGION); actionzone_exit(op); return OPERATOR_FINISHED; @@ -603,17 +603,17 @@ static int actionzone_modal(bContext *C, wmOperator *op, wmEvent *event) deltax= (event->x - sad->x); deltay= (event->y - sad->y); - if(deltay > ABS(deltax)) + if (deltay > ABS(deltax)) sad->gesture_dir= 'n'; - else if(deltax > ABS(deltay)) + else if (deltax > ABS(deltay)) sad->gesture_dir= 'e'; - else if(deltay < -ABS(deltax)) + else if (deltay < -ABS(deltax)) sad->gesture_dir= 's'; else sad->gesture_dir= 'w'; /* gesture is large enough? */ - if(ABS(deltax) > mindelta || ABS(deltay) > mindelta) { + if (ABS(deltax) > mindelta || ABS(deltay) > mindelta) { /* second area, for join */ sad->sa2= screen_areahascursor(CTX_wm_screen(C), event->x, event->y); @@ -691,7 +691,7 @@ static int area_swap_init(wmOperator *op, wmEvent *event) sAreaSwapData *sd= NULL; sActionzoneData *sad= event->customdata; - if(sad==NULL || sad->sa1==NULL) + if (sad==NULL || sad->sa1==NULL) return 0; sd= MEM_callocN(sizeof(sAreaSwapData), "sAreaSwapData"); @@ -706,7 +706,7 @@ static int area_swap_init(wmOperator *op, wmEvent *event) static void area_swap_exit(bContext *C, wmOperator *op) { WM_cursor_restore(CTX_wm_window(C)); - if(op->customdata) + if (op->customdata) MEM_freeN(op->customdata); op->customdata= NULL; } @@ -720,7 +720,7 @@ static int area_swap_cancel(bContext *C, wmOperator *op) static int area_swap_invoke(bContext *C, wmOperator *op, wmEvent *event) { - if(!area_swap_init(op, event)) + if (!area_swap_init(op, event)) return OPERATOR_PASS_THROUGH; /* add modal handler */ @@ -741,8 +741,8 @@ static int area_swap_modal(bContext *C, wmOperator *op, wmEvent *event) sad->sa2= screen_areahascursor(CTX_wm_screen(C), event->x, event->y); break; case LEFTMOUSE: /* release LMB */ - if(event->val==KM_RELEASE) { - if(!sad->sa2 || sad->sa1 == sad->sa2) { + if (event->val==KM_RELEASE) { + if (!sad->sa2 || sad->sa1 == sad->sa2) { return area_swap_cancel(C, op); } @@ -795,18 +795,18 @@ static int area_dupli_invoke(bContext *C, wmOperator *op, wmEvent *event) sa= CTX_wm_area(C); /* XXX hrmf! */ - if(event->type==EVT_ACTIONZONE_AREA) { + if (event->type==EVT_ACTIONZONE_AREA) { sActionzoneData *sad= event->customdata; - if(sad==NULL) + if (sad==NULL) return OPERATOR_PASS_THROUGH; sa= sad->sa1; } /* poll() checks area context, but we don't accept full-area windows */ - if(sc->full != SCREENNORMAL) { - if(event->type==EVT_ACTIONZONE_AREA) + if (sc->full != SCREENNORMAL) { + if (event->type==EVT_ACTIONZONE_AREA) actionzone_exit(op); return OPERATOR_CANCELLED; } @@ -828,7 +828,7 @@ static int area_dupli_invoke(bContext *C, wmOperator *op, wmEvent *event) /* screen, areas init */ WM_event_add_notifier(C, NC_SCREEN|NA_EDITED, NULL); - if(event->type==EVT_ACTIONZONE_AREA) + if (event->type==EVT_ACTIONZONE_AREA) actionzone_exit(op); return OPERATOR_FINISHED; @@ -889,23 +889,23 @@ static void area_move_set_limits(bScreen *sc, int dir, int *bigger, int *smaller /* we check all areas and test for free space with MINSIZE */ *bigger= *smaller= 100000; - for(sa= sc->areabase.first; sa; sa= sa->next) { - if(dir=='h') { + for (sa= sc->areabase.first; sa; sa= sa->next) { + if (dir=='h') { int y1= sa->v2->vec.y - sa->v1->vec.y-areaminy; /* if top or down edge selected, test height */ - if(sa->v1->flag && sa->v4->flag) + if (sa->v1->flag && sa->v4->flag) *bigger= MIN2(*bigger, y1); - else if(sa->v2->flag && sa->v3->flag) + else if (sa->v2->flag && sa->v3->flag) *smaller= MIN2(*smaller, y1); } else { int x1= sa->v4->vec.x - sa->v1->vec.x-AREAMINX; /* if left or right edge selected, test width */ - if(sa->v1->flag && sa->v2->flag) + if (sa->v1->flag && sa->v2->flag) *bigger= MIN2(*bigger, x1); - else if(sa->v3->flag && sa->v4->flag) + else if (sa->v3->flag && sa->v4->flag) *smaller= MIN2(*smaller, x1); } } @@ -926,13 +926,13 @@ static int area_move_init (bContext *C, wmOperator *op) /* setup */ actedge= screen_find_active_scredge(sc, x, y); - if(actedge==NULL) return 0; + if (actedge==NULL) return 0; md= MEM_callocN(sizeof(sAreaMoveData), "sAreaMoveData"); op->customdata= md; md->dir= scredge_is_horizontal(actedge)?'h':'v'; - if(md->dir=='h') md->origval= actedge->v1->vec.y; + if (md->dir=='h') md->origval= actedge->v1->vec.y; else md->origval= actedge->v1->vec.x; select_connected_scredge(sc, actedge); @@ -957,25 +957,25 @@ static void area_move_apply_do(bContext *C, int origval, int delta, int dir, int for (v1= sc->vertbase.first; v1; v1= v1->next) { if (v1->flag) { /* that way a nice AREAGRID */ - if((dir=='v') && v1->vec.x>0 && v1->vec.xsizex-1) { + if ((dir=='v') && v1->vec.x>0 && v1->vec.xsizex-1) { v1->vec.x= origval + delta; - if(delta != bigger && delta != -smaller) v1->vec.x-= (v1->vec.x % AREAGRID); + if (delta != bigger && delta != -smaller) v1->vec.x-= (v1->vec.x % AREAGRID); } - if((dir=='h') && v1->vec.y>0 && v1->vec.ysizey-1) { + if ((dir=='h') && v1->vec.y>0 && v1->vec.ysizey-1) { v1->vec.y= origval + delta; v1->vec.y+= AREAGRID-1; v1->vec.y-= (v1->vec.y % AREAGRID); /* prevent too small top header */ - if(v1->vec.y > win->sizey-areaminy) + if (v1->vec.y > win->sizey-areaminy) v1->vec.y= win->sizey-areaminy; } } } - for(sa= sc->areabase.first; sa; sa= sa->next) { - if(sa->v1->flag || sa->v2->flag || sa->v3->flag || sa->v4->flag) + for (sa= sc->areabase.first; sa; sa= sa->next) { + if (sa->v1->flag || sa->v2->flag || sa->v3->flag || sa->v4->flag) ED_area_tag_redraw(sa); } @@ -993,7 +993,7 @@ static void area_move_apply(bContext *C, wmOperator *op) static void area_move_exit(bContext *C, wmOperator *op) { - if(op->customdata) + if (op->customdata) MEM_freeN(op->customdata); op->customdata= NULL; @@ -1004,7 +1004,7 @@ static void area_move_exit(bContext *C, wmOperator *op) static int area_move_exec(bContext *C, wmOperator *op) { - if(!area_move_init(C, op)) + if (!area_move_init(C, op)) return OPERATOR_CANCELLED; area_move_apply(C, op); @@ -1019,7 +1019,7 @@ static int area_move_invoke(bContext *C, wmOperator *op, wmEvent *event) RNA_int_set(op->ptr, "x", event->x); RNA_int_set(op->ptr, "y", event->y); - if(!area_move_init(C, op)) + if (!area_move_init(C, op)) return OPERATOR_PASS_THROUGH; /* add temp handler */ @@ -1052,7 +1052,7 @@ static int area_move_modal(bContext *C, wmOperator *op, wmEvent *event) y= RNA_int_get(op->ptr, "y"); delta= (md->dir == 'v')? event->x - x: event->y - y; - if(md->step) delta= delta - (delta % md->step); + if (md->step) delta= delta - (delta % md->step); RNA_int_set(op->ptr, "delta", delta); area_move_apply(C, op); @@ -1166,10 +1166,10 @@ static int area_split_menu_init(bContext *C, wmOperator *op) sd->sarea= CTX_wm_area(C); - if(sd->sarea) { + if (sd->sarea) { int dir= RNA_enum_get(op->ptr, "direction"); - if(dir=='h') + if (dir=='h') sd->sarea->flag |= AREA_FLAG_DRAWSPLIT_H; else sd->sarea->flag |= AREA_FLAG_DRAWSPLIT_V; @@ -1186,14 +1186,14 @@ static int area_split_init(bContext *C, wmOperator *op) int dir; /* required context */ - if(sa==NULL) return 0; + if (sa==NULL) return 0; /* required properties */ dir= RNA_enum_get(op->ptr, "direction"); /* minimal size */ - if(dir=='v' && sa->winx < 2*AREAMINX) return 0; - if(dir=='h' && sa->winy < 2*areaminy) return 0; + if (dir=='v' && sa->winx < 2*AREAMINX) return 0; + if (dir=='h' && sa->winy < 2*areaminy) return 0; /* custom data */ sd= (sAreaSplitData*)MEM_callocN(sizeof (sAreaSplitData), "op_area_split"); @@ -1219,16 +1219,16 @@ static ScrEdge *area_findsharededge(bScreen *screen, ScrArea *sa, ScrArea *sb) ScrVert *sbv3= sb->v3; ScrVert *sbv4= sb->v4; - if(sav1==sbv4 && sav2==sbv3) { /* sa to right of sb = W */ + if (sav1==sbv4 && sav2==sbv3) { /* sa to right of sb = W */ return screen_findedge(screen, sav1, sav2); } - else if(sav2==sbv1 && sav3==sbv4) { /* sa to bottom of sb = N */ + else if (sav2==sbv1 && sav3==sbv4) { /* sa to bottom of sb = N */ return screen_findedge(screen, sav2, sav3); } - else if(sav3==sbv2 && sav4==sbv1) { /* sa to left of sb = E */ + else if (sav3==sbv2 && sav4==sbv1) { /* sa to left of sb = E */ return screen_findedge(screen, sav3, sav4); } - else if(sav1==sbv2 && sav4==sbv3) { /* sa on top of sb = S*/ + else if (sav1==sbv2 && sav4==sbv3) { /* sa on top of sb = S*/ return screen_findedge(screen, sav1, sav4); } @@ -1249,19 +1249,19 @@ static int area_split_apply(bContext *C, wmOperator *op) sd->narea= area_split(sc, sd->sarea, dir, fac, 0); /* 0 = no merge */ - if(sd->narea) { + if (sd->narea) { ScrVert *sv; sd->nedge= area_findsharededge(sc, sd->sarea, sd->narea); /* select newly created edge, prepare for moving edge */ - for(sv= sc->vertbase.first; sv; sv= sv->next) + for (sv= sc->vertbase.first; sv; sv= sv->next) sv->flag = 0; sd->nedge->v1->flag= 1; sd->nedge->v2->flag= 1; - if(dir=='h') sd->origval= sd->nedge->v1->vec.y; + if (dir=='h') sd->origval= sd->nedge->v1->vec.y; else sd->origval= sd->nedge->v1->vec.x; ED_area_tag_redraw(sd->sarea); @@ -1279,10 +1279,10 @@ static void area_split_exit(bContext *C, wmOperator *op) { if (op->customdata) { sAreaSplitData *sd= (sAreaSplitData *)op->customdata; - if(sd->sarea) ED_area_tag_redraw(sd->sarea); - if(sd->narea) ED_area_tag_redraw(sd->narea); + if (sd->sarea) ED_area_tag_redraw(sd->sarea); + if (sd->narea) ED_area_tag_redraw(sd->narea); - if(sd->sarea) + if (sd->sarea) sd->sarea->flag &= ~(AREA_FLAG_DRAWSPLIT_H|AREA_FLAG_DRAWSPLIT_V); MEM_freeN(op->customdata); @@ -1305,26 +1305,26 @@ static int area_split_invoke(bContext *C, wmOperator *op, wmEvent *event) int dir; /* no full window splitting allowed */ - if(CTX_wm_screen(C)->full != SCREENNORMAL) + if (CTX_wm_screen(C)->full != SCREENNORMAL) return OPERATOR_CANCELLED; - if(event->type==EVT_ACTIONZONE_AREA) { + if (event->type==EVT_ACTIONZONE_AREA) { sActionzoneData *sad= event->customdata; - if(sad->modifier>0) { + if (sad->modifier>0) { return OPERATOR_PASS_THROUGH; } /* verify *sad itself */ - if(sad==NULL || sad->sa1==NULL || sad->az==NULL) + if (sad==NULL || sad->sa1==NULL || sad->az==NULL) return OPERATOR_PASS_THROUGH; /* is this our *sad? if areas not equal it should be passed on */ - if(CTX_wm_area(C)!=sad->sa1 || sad->sa1!=sad->sa2) + if (CTX_wm_area(C)!=sad->sa1 || sad->sa1!=sad->sa2) return OPERATOR_PASS_THROUGH; /* prepare operator state vars */ - if(sad->gesture_dir=='n' || sad->gesture_dir=='s') { + if (sad->gesture_dir=='n' || sad->gesture_dir=='s') { dir= 'h'; RNA_float_set(op->ptr, "factor", ((float)(event->x - sad->sa1->v1->vec.x)) / (float)sad->sa1->winx); } @@ -1335,7 +1335,7 @@ static int area_split_invoke(bContext *C, wmOperator *op, wmEvent *event) RNA_enum_set(op->ptr, "direction", dir); /* general init, also non-UI case, adds customdata, sets area and defaults */ - if(!area_split_init(C, op)) + if (!area_split_init(C, op)) return OPERATOR_PASS_THROUGH; } @@ -1344,18 +1344,18 @@ static int area_split_invoke(bContext *C, wmOperator *op, wmEvent *event) int x, y; /* retrieve initial mouse coord, so we can find the active edge */ - if(RNA_struct_property_is_set(op->ptr, "mouse_x")) + if (RNA_struct_property_is_set(op->ptr, "mouse_x")) x= RNA_int_get(op->ptr, "mouse_x"); else x= event->x; - if(RNA_struct_property_is_set(op->ptr, "mouse_y")) + if (RNA_struct_property_is_set(op->ptr, "mouse_y")) y= RNA_int_get(op->ptr, "mouse_y"); else y= event->x; actedge= screen_find_active_scredge(CTX_wm_screen(C), x, y); - if(actedge==NULL) + if (actedge==NULL) return OPERATOR_CANCELLED; dir= scredge_is_horizontal(actedge)?'v':'h'; @@ -1363,7 +1363,7 @@ static int area_split_invoke(bContext *C, wmOperator *op, wmEvent *event) RNA_enum_set(op->ptr, "direction", dir); /* special case, adds customdata, sets defaults */ - if(!area_split_menu_init(C, op)) + if (!area_split_menu_init(C, op)) return OPERATOR_CANCELLED; } @@ -1373,10 +1373,10 @@ static int area_split_invoke(bContext *C, wmOperator *op, wmEvent *event) sd->x= event->x; sd->y= event->y; - if(event->type==EVT_ACTIONZONE_AREA) { + if (event->type==EVT_ACTIONZONE_AREA) { /* do the split */ - if(area_split_apply(C, op)) { + if (area_split_apply(C, op)) { area_move_set_limits(CTX_wm_screen(C), dir, &sd->bigger, &sd->smaller); /* add temp handler for edge move or cancel */ @@ -1401,7 +1401,7 @@ static int area_split_invoke(bContext *C, wmOperator *op, wmEvent *event) static int area_split_exec(bContext *C, wmOperator *op) { - if(!area_split_init(C, op)) + if (!area_split_init(C, op)) return OPERATOR_CANCELLED; area_split_apply(C, op); @@ -1415,7 +1415,7 @@ static int area_split_cancel(bContext *C, wmOperator *op) { sAreaSplitData *sd= (sAreaSplitData *)op->customdata; - if(sd->previewmode) { + if (sd->previewmode) { } else { if (screen_area_join(C, CTX_wm_screen(C), sd->sarea, sd->narea)) { @@ -1443,16 +1443,16 @@ static int area_split_modal(bContext *C, wmOperator *op, wmEvent *event) dir= RNA_enum_get(op->ptr, "direction"); sd->delta= (dir == 'v')? event->x - sd->origval: event->y - sd->origval; - if(sd->previewmode==0) + if (sd->previewmode==0) area_move_apply_do(C, sd->origval, sd->delta, dir, sd->bigger, sd->smaller); else { - if(sd->sarea) { + if (sd->sarea) { sd->sarea->flag &= ~(AREA_FLAG_DRAWSPLIT_H|AREA_FLAG_DRAWSPLIT_V); ED_area_tag_redraw(sd->sarea); } sd->sarea= screen_areahascursor(CTX_wm_screen(C), event->x, event->y); /* area context not set */ - if(sd->sarea) { + if (sd->sarea) { ED_area_tag_redraw(sd->sarea); if (dir=='v') { sd->origsize= sd->sarea->winx; @@ -1476,13 +1476,13 @@ static int area_split_modal(bContext *C, wmOperator *op, wmEvent *event) break; case LEFTMOUSE: - if(sd->previewmode) { + if (sd->previewmode) { area_split_apply(C, op); area_split_exit(C, op); return OPERATOR_FINISHED; } else { - if(event->val==KM_RELEASE) { /* mouse up */ + if (event->val==KM_RELEASE) { /* mouse up */ area_split_exit(C, op); return OPERATOR_FINISHED; } @@ -1491,23 +1491,23 @@ static int area_split_modal(bContext *C, wmOperator *op, wmEvent *event) case MIDDLEMOUSE: case TABKEY: - if (sd->previewmode==0){ + if (sd->previewmode==0) { } - else{ + else { dir = RNA_enum_get(op->ptr, "direction"); - if(event->val==KM_PRESS){ - if (sd->sarea){ + if (event->val==KM_PRESS) { + if (sd->sarea) { sd->sarea->flag &= ~(AREA_FLAG_DRAWSPLIT_H|AREA_FLAG_DRAWSPLIT_V); ED_area_tag_redraw(sd->sarea); - if (dir=='v'){ + if (dir=='v') { RNA_enum_set(op->ptr, "direction", 'h'); sd->sarea->flag |= AREA_FLAG_DRAWSPLIT_H; WM_cursor_set(CTX_wm_window(C),CURSOR_X_MOVE); } - else{ + else { RNA_enum_set(op->ptr, "direction", 'v'); sd->sarea->flag |= AREA_FLAG_DRAWSPLIT_V; @@ -1574,9 +1574,10 @@ static int area_max_regionsize(ScrArea *sa, ARegion *scalear, AZEdge edge) ARegion *ar; int dist; - if(edge==AE_RIGHT_TO_TOPLEFT || edge==AE_LEFT_TO_TOPRIGHT) { + if (edge==AE_RIGHT_TO_TOPLEFT || edge==AE_LEFT_TO_TOPRIGHT) { dist = sa->totrct.xmax - sa->totrct.xmin; - } else { /* AE_BOTTOM_TO_TOPLEFT, AE_TOP_TO_BOTTOMRIGHT */ + } + else { /* AE_BOTTOM_TO_TOPLEFT, AE_TOP_TO_BOTTOMRIGHT */ dist = sa->totrct.ymax - sa->totrct.ymin; } @@ -1611,14 +1612,14 @@ static int region_scale_invoke(bContext *C, wmOperator *op, wmEvent *event) sActionzoneData *sad= event->customdata; AZone *az; - if(event->type!=EVT_ACTIONZONE_REGION) { + if (event->type!=EVT_ACTIONZONE_REGION) { BKE_report(op->reports, RPT_ERROR, "Can only scale region size from an action zone"); return OPERATOR_CANCELLED; } az = sad->az; - if(az->ar) { + if (az->ar) { RegionMoveData *rmd= MEM_callocN(sizeof(RegionMoveData), "RegionMoveData"); int maxsize; @@ -1633,15 +1634,16 @@ static int region_scale_invoke(bContext *C, wmOperator *op, wmEvent *event) rmd->maxsize = area_max_regionsize(rmd->sa, rmd->ar, rmd->edge); /* if not set we do now, otherwise it uses type */ - if(rmd->ar->sizex==0) + if (rmd->ar->sizex==0) rmd->ar->sizex= rmd->ar->type->prefsizex; - if(rmd->ar->sizey==0) + if (rmd->ar->sizey==0) rmd->ar->sizey= rmd->ar->type->prefsizey; /* now copy to regionmovedata */ - if(rmd->edge==AE_LEFT_TO_TOPRIGHT || rmd->edge==AE_RIGHT_TO_TOPLEFT) { + if (rmd->edge==AE_LEFT_TO_TOPRIGHT || rmd->edge==AE_RIGHT_TO_TOPLEFT) { rmd->origval= rmd->ar->sizex; - } else { + } + else { rmd->origval= rmd->ar->sizey; } @@ -1666,11 +1668,11 @@ static int region_scale_get_maxsize(RegionMoveData *rmd) { int maxsize= 0; - if(rmd->edge==AE_LEFT_TO_TOPRIGHT || rmd->edge==AE_RIGHT_TO_TOPLEFT) { + if (rmd->edge==AE_LEFT_TO_TOPRIGHT || rmd->edge==AE_RIGHT_TO_TOPLEFT) { return rmd->sa->winx - UI_UNIT_X; } - if(rmd->ar->regiontype == RGN_TYPE_TOOL_PROPS) { + if (rmd->ar->regiontype == RGN_TYPE_TOOL_PROPS) { /* this calculation seems overly verbose * can someone explain why this method is necessary? - campbell */ maxsize = rmd->maxsize - ((rmd->sa->headertype==HEADERTOP)?UI_UNIT_Y*2:UI_UNIT_Y) - (UI_UNIT_Y/4); @@ -1681,18 +1683,18 @@ static int region_scale_get_maxsize(RegionMoveData *rmd) static void region_scale_validate_size(RegionMoveData *rmd) { - if((rmd->ar->flag & RGN_FLAG_HIDDEN)==0) { + if ((rmd->ar->flag & RGN_FLAG_HIDDEN)==0) { short *size, maxsize= -1; - if(rmd->edge==AE_LEFT_TO_TOPRIGHT || rmd->edge==AE_RIGHT_TO_TOPLEFT) + if (rmd->edge==AE_LEFT_TO_TOPRIGHT || rmd->edge==AE_RIGHT_TO_TOPLEFT) size= &rmd->ar->sizex; else size= &rmd->ar->sizey; maxsize= region_scale_get_maxsize(rmd); - if(*size > maxsize && maxsize > 0) + if (*size > maxsize && maxsize > 0) *size= maxsize; } } @@ -1712,25 +1714,25 @@ static int region_scale_modal(bContext *C, wmOperator *op, wmEvent *event) switch(event->type) { case MOUSEMOVE: - if(rmd->edge==AE_LEFT_TO_TOPRIGHT || rmd->edge==AE_RIGHT_TO_TOPLEFT) { + if (rmd->edge==AE_LEFT_TO_TOPRIGHT || rmd->edge==AE_RIGHT_TO_TOPLEFT) { delta= event->x - rmd->origx; - if(rmd->edge==AE_LEFT_TO_TOPRIGHT) delta= -delta; + if (rmd->edge==AE_LEFT_TO_TOPRIGHT) delta= -delta; rmd->ar->sizex= rmd->origval + delta; CLAMP(rmd->ar->sizex, 0, rmd->maxsize); - if(rmd->ar->sizex < UI_UNIT_X) { + if (rmd->ar->sizex < UI_UNIT_X) { rmd->ar->sizex= rmd->origval; - if(!(rmd->ar->flag & RGN_FLAG_HIDDEN)) + if (!(rmd->ar->flag & RGN_FLAG_HIDDEN)) region_scale_toggle_hidden(C, rmd); } - else if(rmd->ar->flag & RGN_FLAG_HIDDEN) + else if (rmd->ar->flag & RGN_FLAG_HIDDEN) region_scale_toggle_hidden(C, rmd); } else { int maxsize= region_scale_get_maxsize(rmd); delta= event->y - rmd->origy; - if(rmd->edge==AE_BOTTOM_TO_TOPLEFT) delta= -delta; + if (rmd->edge==AE_BOTTOM_TO_TOPLEFT) delta= -delta; rmd->ar->sizey= rmd->origval + delta; CLAMP(rmd->ar->sizey, 0, rmd->maxsize); @@ -1738,14 +1740,14 @@ static int region_scale_modal(bContext *C, wmOperator *op, wmEvent *event) /* note, 'UI_UNIT_Y/4' means you need to drag the header almost * all the way down for it to become hidden, this is done * otherwise its too easy to do this by accident */ - if(rmd->ar->sizey < UI_UNIT_Y/4) { + if (rmd->ar->sizey < UI_UNIT_Y/4) { rmd->ar->sizey= rmd->origval; - if(!(rmd->ar->flag & RGN_FLAG_HIDDEN)) + if (!(rmd->ar->flag & RGN_FLAG_HIDDEN)) region_scale_toggle_hidden(C, rmd); } - else if(maxsize > 0 && (rmd->ar->sizey > maxsize)) + else if (maxsize > 0 && (rmd->ar->sizey > maxsize)) rmd->ar->sizey= maxsize; - else if(rmd->ar->flag & RGN_FLAG_HIDDEN) + else if (rmd->ar->flag & RGN_FLAG_HIDDEN) region_scale_toggle_hidden(C, rmd); } ED_area_tag_redraw(rmd->sa); @@ -1754,13 +1756,13 @@ static int region_scale_modal(bContext *C, wmOperator *op, wmEvent *event) break; case LEFTMOUSE: - if(event->val==KM_RELEASE) { + if (event->val==KM_RELEASE) { - if(ABS(event->x - rmd->origx) < 2 && ABS(event->y - rmd->origy) < 2) { - if(rmd->ar->flag & RGN_FLAG_HIDDEN) { + if (ABS(event->x - rmd->origx) < 2 && ABS(event->y - rmd->origy) < 2) { + if (rmd->ar->flag & RGN_FLAG_HIDDEN) { region_scale_toggle_hidden(C, rmd); } - else if(rmd->ar->flag & RGN_FLAG_TOO_SMALL) { + else if (rmd->ar->flag & RGN_FLAG_TOO_SMALL) { region_scale_validate_size(rmd); } @@ -1854,7 +1856,7 @@ static int frame_jump_exec(bContext *C, wmOperator *op) * first/last frame not to be actually shown (bad since for example physics * simulations aren't reset properly). */ - if(animtimer) { + if (animtimer) { ScreenAnimData *sad = animtimer->customdata; sad->flag |= ANIMPLAY_FLAG_USE_NEXT_FRAME; @@ -1990,22 +1992,22 @@ static int screen_set_exec(bContext *C, wmOperator *op) int delta= RNA_int_get(op->ptr, "delta"); /* temp screens are for userpref or render display */ - if(screen->temp) + if (screen->temp) return OPERATOR_CANCELLED; - if(delta==1) { - while(tot--) { + if (delta==1) { + while (tot--) { screen= screen->id.next; - if(screen==NULL) screen= CTX_data_main(C)->screen.first; - if(screen->winid==0 && screen->full==0 && screen != screen_prev) + if (screen==NULL) screen= CTX_data_main(C)->screen.first; + if (screen->winid==0 && screen->full==0 && screen != screen_prev) break; } } - else if(delta== -1) { - while(tot--) { + else if (delta== -1) { + while (tot--) { screen= screen->id.prev; - if(screen==NULL) screen= CTX_data_main(C)->screen.last; - if(screen->winid==0 && screen->full==0 && screen != screen_prev) + if (screen==NULL) screen= CTX_data_main(C)->screen.last; + if (screen->winid==0 && screen->full==0 && screen != screen_prev) break; } } @@ -2013,9 +2015,9 @@ static int screen_set_exec(bContext *C, wmOperator *op) screen= NULL; } - if(screen && screen_prev != screen) { + if (screen && screen_prev != screen) { /* return to previous state before switching screens */ - if(sa && sa->full) { + if (sa && sa->full) { ED_screen_full_restore(C, sa); /* may free 'screen_prev' */ } @@ -2053,7 +2055,7 @@ static int screen_full_area_exec(bContext *C, wmOperator *UNUSED(op)) if (sa->full) break; } - if(sa==NULL) sa= CTX_wm_area(C); + if (sa==NULL) sa= CTX_wm_area(C); ED_screen_full_toggle(C, CTX_wm_window(C), sa); return OPERATOR_FINISHED; @@ -2130,15 +2132,15 @@ static int area_join_init(bContext *C, wmOperator *op) sa1 = screen_areahascursor(CTX_wm_screen(C), x1, y1); sa2 = screen_areahascursor(CTX_wm_screen(C), x2, y2); - if(sa1==NULL || sa2==NULL || sa1==sa2) + if (sa1==NULL || sa2==NULL || sa1==sa2) return 0; /* do areas share an edge? */ - if(sa1->v1==sa2->v1 || sa1->v1==sa2->v2 || sa1->v1==sa2->v3 || sa1->v1==sa2->v4) shared++; - if(sa1->v2==sa2->v1 || sa1->v2==sa2->v2 || sa1->v2==sa2->v3 || sa1->v2==sa2->v4) shared++; - if(sa1->v3==sa2->v1 || sa1->v3==sa2->v2 || sa1->v3==sa2->v3 || sa1->v3==sa2->v4) shared++; - if(sa1->v4==sa2->v1 || sa1->v4==sa2->v2 || sa1->v4==sa2->v3 || sa1->v4==sa2->v4) shared++; - if(shared!=2) { + if (sa1->v1==sa2->v1 || sa1->v1==sa2->v2 || sa1->v1==sa2->v3 || sa1->v1==sa2->v4) shared++; + if (sa1->v2==sa2->v1 || sa1->v2==sa2->v2 || sa1->v2==sa2->v3 || sa1->v2==sa2->v4) shared++; + if (sa1->v3==sa2->v1 || sa1->v3==sa2->v2 || sa1->v3==sa2->v3 || sa1->v3==sa2->v4) shared++; + if (sa1->v4==sa2->v1 || sa1->v4==sa2->v2 || sa1->v4==sa2->v3 || sa1->v4==sa2->v4) shared++; + if (shared!=2) { printf("areas don't share edge\n"); return 0; } @@ -2161,7 +2163,7 @@ static int area_join_apply(bContext *C, wmOperator *op) sAreaJoinData *jd = (sAreaJoinData *)op->customdata; if (!jd) return 0; - if(!screen_area_join(C, CTX_wm_screen(C), jd->sa1, jd->sa2)){ + if (!screen_area_join(C, CTX_wm_screen(C), jd->sa1, jd->sa2)) { return 0; } if (CTX_wm_area(C) == jd->sa2) { @@ -2188,7 +2190,7 @@ static void area_join_exit(bContext *C, wmOperator *op) static int area_join_exec(bContext *C, wmOperator *op) { - if(!area_join_init(C, op)) + if (!area_join_init(C, op)) return OPERATOR_CANCELLED; area_join_apply(C, op); @@ -2201,19 +2203,19 @@ static int area_join_exec(bContext *C, wmOperator *op) static int area_join_invoke(bContext *C, wmOperator *op, wmEvent *event) { - if(event->type==EVT_ACTIONZONE_AREA) { + if (event->type==EVT_ACTIONZONE_AREA) { sActionzoneData *sad= event->customdata; - if(sad->modifier>0) { + if (sad->modifier>0) { return OPERATOR_PASS_THROUGH; } /* verify *sad itself */ - if(sad==NULL || sad->sa1==NULL || sad->sa2==NULL) + if (sad==NULL || sad->sa1==NULL || sad->sa2==NULL) return OPERATOR_PASS_THROUGH; /* is this our *sad? if areas equal it should be passed on */ - if(sad->sa1==sad->sa2) + if (sad->sa1==sad->sa2) return OPERATOR_PASS_THROUGH; /* prepare operator state vars */ @@ -2224,7 +2226,7 @@ static int area_join_invoke(bContext *C, wmOperator *op, wmEvent *event) } - if(!area_join_init(C, op)) + if (!area_join_init(C, op)) return OPERATOR_PASS_THROUGH; /* add temp handler */ @@ -2325,7 +2327,7 @@ static int area_join_modal(bContext *C, wmOperator *op, wmEvent *event) } break; case LEFTMOUSE: - if(event->val==KM_RELEASE) { + if (event->val==KM_RELEASE) { ED_area_tag_redraw(jd->sa1); ED_area_tag_redraw(jd->sa2); @@ -2377,7 +2379,7 @@ static int screen_area_options_invoke(bContext *C, wmOperator *op, wmEvent *even PointerRNA ptr1, ptr2; ScrEdge *actedge= screen_find_active_scredge(CTX_wm_screen(C), event->x, event->y); - if(actedge==NULL) return OPERATOR_CANCELLED; + if (actedge==NULL) return OPERATOR_CANCELLED; pup= uiPupMenuBegin(C, op->type->name, ICON_NONE); layout= uiPupMenuLayout(pup); @@ -2428,9 +2430,9 @@ static int spacedata_cleanup(bContext *C, wmOperator *op) ScrArea *sa; int tot= 0; - for(screen= bmain->screen.first; screen; screen= screen->id.next) { - for(sa= screen->areabase.first; sa; sa= sa->next) { - if(sa->spacedata.first != sa->spacedata.last) { + for (screen= bmain->screen.first; screen; screen= screen->id.next) { + for (sa= screen->areabase.first; sa; sa= sa->next) { + if (sa->spacedata.first != sa->spacedata.last) { SpaceLink *sl= sa->spacedata.first; BLI_remlink(&sa->spacedata, sl); @@ -2464,7 +2466,7 @@ static int repeat_last_exec(bContext *C, wmOperator *UNUSED(op)) { wmOperator *lastop= CTX_wm_manager(C)->operators.last; - if(lastop) + if (lastop) WM_operator_repeat(C, lastop); return OPERATOR_CANCELLED; @@ -2493,7 +2495,7 @@ static int repeat_history_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(ev int items, i; items= BLI_countlist(&wm->operators); - if(items==0) + if (items==0) return OPERATOR_CANCELLED; pup= uiPupMenuBegin(C, op->type->name, ICON_NONE); @@ -2512,7 +2514,7 @@ static int repeat_history_exec(bContext *C, wmOperator *op) wmWindowManager *wm= CTX_wm_manager(C); op= BLI_findlink(&wm->operators, RNA_int_get(op->ptr, "index")); - if(op) { + if (op) { /* let's put it as last operator in list */ BLI_remlink(&wm->operators, op); BLI_addtail(&wm->operators, op); @@ -2545,7 +2547,7 @@ static int redo_last_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *UNUSED { wmOperator *lastop= WM_operator_last_redo(C); - if(lastop) + if (lastop) WM_operator_redo_popup(C, lastop); return OPERATOR_CANCELLED; @@ -2572,24 +2574,24 @@ static int region_quadview_exec(bContext *C, wmOperator *op) ARegion *ar= CTX_wm_region(C); /* some rules... */ - if(ar->regiontype!=RGN_TYPE_WINDOW) + if (ar->regiontype!=RGN_TYPE_WINDOW) BKE_report(op->reports, RPT_ERROR, "Only window region can be 4-splitted"); - else if(ar->alignment==RGN_ALIGN_QSPLIT) { + else if (ar->alignment==RGN_ALIGN_QSPLIT) { ScrArea *sa= CTX_wm_area(C); ARegion *arn; /* keep current region */ ar->alignment= 0; - if(sa->spacetype==SPACE_VIEW3D) { + if (sa->spacetype==SPACE_VIEW3D) { RegionView3D *rv3d= ar->regiondata; rv3d->viewlock= 0; rv3d->rflag &= ~RV3D_CLIPPING; } - for(ar= sa->regionbase.first; ar; ar= arn) { + for (ar= sa->regionbase.first; ar; ar= arn) { arn= ar->next; - if(ar->alignment==RGN_ALIGN_QSPLIT) { + if (ar->alignment==RGN_ALIGN_QSPLIT) { ED_region_exit(C, ar); BKE_area_region_free(sa->type, ar); BLI_remlink(&sa->regionbase, ar); @@ -2599,7 +2601,7 @@ static int region_quadview_exec(bContext *C, wmOperator *op) ED_area_tag_redraw(sa); WM_event_add_notifier(C, NC_SCREEN|NA_EDITED, NULL); } - else if(ar->next) + else if (ar->next) BKE_report(op->reports, RPT_ERROR, "Only last region can be 4-splitted"); else { ScrArea *sa= CTX_wm_area(C); @@ -2608,13 +2610,13 @@ static int region_quadview_exec(bContext *C, wmOperator *op) ar->alignment= RGN_ALIGN_QSPLIT; - for(count=0; count<3; count++) { + for (count=0; count<3; count++) { newar= BKE_area_region_copy(sa->type, ar); BLI_addtail(&sa->regionbase, newar); } /* lock views and set them */ - if(sa->spacetype==SPACE_VIEW3D) { + if (sa->spacetype==SPACE_VIEW3D) { /* run ED_view3d_lock() so the correct 'rv3d->viewquat' is set, * otherwise when restoring rv3d->localvd the 'viewquat' won't * match the 'view', set on entering localview See: [#26315], @@ -2680,13 +2682,13 @@ static int region_flip_exec(bContext *C, wmOperator *UNUSED(op)) if (!ar) return OPERATOR_CANCELLED; - if(ar->alignment==RGN_ALIGN_TOP) + if (ar->alignment==RGN_ALIGN_TOP) ar->alignment= RGN_ALIGN_BOTTOM; - else if(ar->alignment==RGN_ALIGN_BOTTOM) + else if (ar->alignment==RGN_ALIGN_BOTTOM) ar->alignment= RGN_ALIGN_TOP; - else if(ar->alignment==RGN_ALIGN_LEFT) + else if (ar->alignment==RGN_ALIGN_LEFT) ar->alignment= RGN_ALIGN_RIGHT; - else if(ar->alignment==RGN_ALIGN_RIGHT) + else if (ar->alignment==RGN_ALIGN_RIGHT) ar->alignment= RGN_ALIGN_LEFT; ED_area_tag_redraw(CTX_wm_area(C)); @@ -2718,23 +2720,23 @@ static int header_flip_exec(bContext *C, wmOperator *UNUSED(op)) /* find the header region * - try context first, but upon failing, search all regions in area... */ - if((ar == NULL) || (ar->regiontype != RGN_TYPE_HEADER)) { + if ((ar == NULL) || (ar->regiontype != RGN_TYPE_HEADER)) { ScrArea *sa= CTX_wm_area(C); ar= BKE_area_find_region_type(sa, RGN_TYPE_HEADER); /* don't do anything if no region */ - if(ar == NULL) + if (ar == NULL) return OPERATOR_CANCELLED; } /* copied from SCREEN_OT_region_flip */ - if(ar->alignment==RGN_ALIGN_TOP) + if (ar->alignment==RGN_ALIGN_TOP) ar->alignment= RGN_ALIGN_BOTTOM; - else if(ar->alignment==RGN_ALIGN_BOTTOM) + else if (ar->alignment==RGN_ALIGN_BOTTOM) ar->alignment= RGN_ALIGN_TOP; - else if(ar->alignment==RGN_ALIGN_LEFT) + else if (ar->alignment==RGN_ALIGN_LEFT) ar->alignment= RGN_ALIGN_RIGHT; - else if(ar->alignment==RGN_ALIGN_RIGHT) + else if (ar->alignment==RGN_ALIGN_RIGHT) ar->alignment= RGN_ALIGN_LEFT; ED_area_tag_redraw(CTX_wm_area(C)); @@ -2818,49 +2820,49 @@ static int match_area_with_refresh(int spacetype, int refresh) static int match_region_with_redraws(int spacetype, int regiontype, int redraws) { - if(regiontype==RGN_TYPE_WINDOW) { + if (regiontype==RGN_TYPE_WINDOW) { switch (spacetype) { case SPACE_VIEW3D: - if(redraws & TIME_ALL_3D_WIN) + if (redraws & TIME_ALL_3D_WIN) return 1; break; case SPACE_IPO: case SPACE_ACTION: case SPACE_NLA: - if(redraws & TIME_ALL_ANIM_WIN) + if (redraws & TIME_ALL_ANIM_WIN) return 1; break; case SPACE_TIME: /* if only 1 window or 3d windows, we do timeline too */ - if(redraws & (TIME_ALL_ANIM_WIN|TIME_REGION|TIME_ALL_3D_WIN)) + if (redraws & (TIME_ALL_ANIM_WIN|TIME_REGION|TIME_ALL_3D_WIN)) return 1; break; case SPACE_BUTS: - if(redraws & TIME_ALL_BUTS_WIN) + if (redraws & TIME_ALL_BUTS_WIN) return 1; break; case SPACE_SEQ: - if(redraws & (TIME_SEQ|TIME_ALL_ANIM_WIN)) + if (redraws & (TIME_SEQ|TIME_ALL_ANIM_WIN)) return 1; break; case SPACE_NODE: - if(redraws & (TIME_NODES)) + if (redraws & (TIME_NODES)) return 1; break; case SPACE_IMAGE: - if(redraws & TIME_ALL_IMAGE_WIN) + if (redraws & TIME_ALL_IMAGE_WIN) return 1; break; case SPACE_CLIP: - if(redraws & TIME_CLIPS) + if (redraws & TIME_CLIPS) return 1; break; } } - else if(regiontype==RGN_TYPE_UI) { - if(spacetype==SPACE_CLIP) { + else if (regiontype==RGN_TYPE_UI) { + if (spacetype==SPACE_CLIP) { /* Track Preview button is on Properties Editor in SpaceClip, * and it's very common case when users want it be refreshing * during playback, so asking people to enable special option @@ -2869,17 +2871,17 @@ static int match_region_with_redraws(int spacetype, int regiontype, int redraws) return 1; } - if(redraws & TIME_ALL_BUTS_WIN) + if (redraws & TIME_ALL_BUTS_WIN) return 1; } - else if(regiontype==RGN_TYPE_HEADER) { - if(spacetype==SPACE_TIME) + else if (regiontype==RGN_TYPE_HEADER) { + if (spacetype==SPACE_TIME) return 1; } else if (regiontype==RGN_TYPE_PREVIEW) { switch (spacetype) { case SPACE_SEQ: - if(redraws & (TIME_SEQ|TIME_ALL_ANIM_WIN)) + if (redraws & (TIME_SEQ|TIME_ALL_ANIM_WIN)) return 1; break; case SPACE_CLIP: @@ -2893,7 +2895,7 @@ static int screen_animation_step(bContext *C, wmOperator *UNUSED(op), wmEvent *e { bScreen *screen= CTX_wm_screen(C); - if(screen->animtimer && screen->animtimer==event->customdata) { + if (screen->animtimer && screen->animtimer==event->customdata) { Main *bmain= CTX_data_main(C); Scene *scene= CTX_data_scene(C); wmTimer *wt= screen->animtimer; @@ -2968,7 +2970,7 @@ static int screen_animation_step(bContext *C, wmOperator *UNUSED(op), wmEvent *e } /* next frame overriden by user action (pressed jump to first/last frame) */ - if(sad->flag & ANIMPLAY_FLAG_USE_NEXT_FRAME) { + if (sad->flag & ANIMPLAY_FLAG_USE_NEXT_FRAME) { scene->r.cfra = sad->nextfra; sad->flag &= ~ANIMPLAY_FLAG_USE_NEXT_FRAME; sad->flag |= ANIMPLAY_FLAG_JUMPED; @@ -3089,7 +3091,7 @@ static int screen_animation_cancel_exec(bContext *C, wmOperator *op) bScreen *screen= CTX_wm_screen(C); if (screen->animtimer) { - if(RNA_boolean_get(op->ptr, "restore_frame")) { + if (RNA_boolean_get(op->ptr, "restore_frame")) { ScreenAnimData *sad= screen->animtimer->customdata; Scene *scene= CTX_data_scene(C); @@ -3148,9 +3150,9 @@ static int border_select_do(bContext *C, wmOperator *op) { int event_type= RNA_int_get(op->ptr, "event_type"); - if(event_type==LEFTMOUSE) + if (event_type==LEFTMOUSE) printf("border select do select\n"); - else if(event_type==RIGHTMOUSE) + else if (event_type==RIGHTMOUSE) printf("border select deselect\n"); else printf("border select do something\n"); @@ -3312,17 +3314,17 @@ static int scene_new_exec(bContext *C, wmOperator *op) Main *bmain= CTX_data_main(C); int type= RNA_enum_get(op->ptr, "type"); - if(type == SCE_COPY_NEW) { + if (type == SCE_COPY_NEW) { newscene= add_scene("Scene"); } else { /* different kinds of copying */ newscene= copy_scene(scene, type); /* these can't be handled in blenkernel curently, so do them here */ - if(type == SCE_COPY_LINK_DATA) { + if (type == SCE_COPY_LINK_DATA) { ED_object_single_users(bmain, newscene, 0); } - else if(type == SCE_COPY_FULL) { + else if (type == SCE_COPY_FULL) { ED_object_single_users(bmain, newscene, 1); } } @@ -3368,7 +3370,7 @@ static int scene_delete_exec(bContext *C, wmOperator *UNUSED(op)) ED_screen_delete_scene(C, scene); - if(G.f & G_DEBUG) + if (G.f & G_DEBUG) printf("scene delete %p\n", scene); WM_event_add_notifier(C, NC_SCENE|NA_REMOVED, scene); @@ -3472,8 +3474,8 @@ static void keymap_modal_set(wmKeyConfig *keyconf) static int open_file_drop_poll(bContext *UNUSED(C), wmDrag *drag, wmEvent *UNUSED(event)) { - if(drag->type==WM_DRAG_PATH) { - if(drag->icon==ICON_FILE_BLEND) + if (drag->type==WM_DRAG_PATH) { + if (drag->icon==ICON_FILE_BLEND) return 1; } return 0; diff --git a/source/blender/editors/screen/screendump.c b/source/blender/editors/screen/screendump.c index ca5616f3502..e12e6b0ef82 100644 --- a/source/blender/editors/screen/screendump.c +++ b/source/blender/editors/screen/screendump.c @@ -106,14 +106,14 @@ static int screenshot_data_create(bContext *C, wmOperator *op) dumprect= screenshot(C, &dumpsx, &dumpsy); - if(dumprect) { + if (dumprect) { ScreenshotData *scd= MEM_callocN(sizeof(ScreenshotData), "screenshot"); ScrArea *sa= CTX_wm_area(C); scd->dumpsx= dumpsx; scd->dumpsy= dumpsy; scd->dumprect= dumprect; - if(sa) + if (sa) scd->crop= sa->totrct; op->customdata= scd; @@ -129,8 +129,8 @@ static void screenshot_data_free(wmOperator *op) { ScreenshotData *scd= op->customdata; - if(scd) { - if(scd->dumprect) + if (scd) { + if (scd->dumprect) MEM_freeN(scd->dumprect); MEM_freeN(scd); op->customdata= NULL; @@ -143,8 +143,8 @@ static void screenshot_crop(ImBuf *ibuf, rcti crop) unsigned int *from= ibuf->rect + crop.ymin*ibuf->x + crop.xmin; int y, cropw= crop.xmax - crop.xmin, croph = crop.ymax - crop.ymin; - if(cropw > 0 && croph > 0) { - for(y=0; yx) + if (cropw > 0 && croph > 0) { + for (y=0; yx) memmove(to, from, sizeof(unsigned int)*cropw); ibuf->x= cropw; @@ -156,14 +156,14 @@ static int screenshot_exec(bContext *C, wmOperator *op) { ScreenshotData *scd= op->customdata; - if(scd == NULL) { + if (scd == NULL) { /* when running exec directly */ screenshot_data_create(C, op); scd= op->customdata; } - if(scd) { - if(scd->dumprect) { + if (scd) { + if (scd->dumprect) { Scene *scene= CTX_data_scene(C); ImBuf *ibuf; char path[FILE_MAX]; @@ -174,15 +174,15 @@ static int screenshot_exec(bContext *C, wmOperator *op) BLI_path_abs(path, G.main->name); /* BKE_add_image_extension() checks for if extension was already set */ - if(scene->r.scemode & R_EXTENSION) - if(strlen(path)r.scemode & R_EXTENSION) + if (strlen(path)r.im_format.imtype); ibuf= IMB_allocImBuf(scd->dumpsx, scd->dumpsy, 24, 0); ibuf->rect= scd->dumprect; /* crop to show only single editor */ - if(!RNA_boolean_get(op->ptr, "full")) + if (!RNA_boolean_get(op->ptr, "full")) screenshot_crop(ibuf, scd->crop); BKE_write_ibuf(ibuf, path, &scene->r.im_format); @@ -197,8 +197,8 @@ static int screenshot_exec(bContext *C, wmOperator *op) static int screenshot_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) { - if(screenshot_data_create(C, op)) { - if(RNA_struct_property_is_set(op->ptr, "filepath")) + if (screenshot_data_create(C, op)) { + if (RNA_struct_property_is_set(op->ptr, "filepath")) return screenshot_exec(C, op); RNA_string_set(op->ptr, "filepath", G.ima); @@ -249,7 +249,7 @@ static void screenshot_freejob(void *sjv) { ScreenshotJob *sj= sjv; - if(sj->dumprect) + if (sj->dumprect) MEM_freeN(sj->dumprect); MEM_freeN(sj); @@ -262,7 +262,7 @@ static void screenshot_updatejob(void *sjv) ScreenshotJob *sj= sjv; unsigned int *dumprect; - if(sj->dumprect==NULL) { + if (sj->dumprect==NULL) { dumprect= MEM_mallocN(sizeof(int) * sj->dumpsx * sj->dumpsy, "dumprect"); glReadPixels(sj->x, sj->y, sj->dumpsx, sj->dumpsy, GL_RGBA, GL_UNSIGNED_BYTE, dumprect); glFinish(); @@ -283,8 +283,8 @@ static void screenshot_startjob(void *sjv, short *stop, short *do_update, float rd.frs_sec= U.scrcastfps; rd.frs_sec_base= 1.0f; - if(BKE_imtype_is_movie(rd.im_format.imtype)) { - if(!mh->start_movie(sj->scene, &rd, sj->dumpsx, sj->dumpsy, &sj->reports)) { + if (BKE_imtype_is_movie(rd.im_format.imtype)) { + if (!mh->start_movie(sj->scene, &rd, sj->dumpsx, sj->dumpsy, &sj->reports)) { printf("screencast job stopped\n"); return; } @@ -297,18 +297,20 @@ static void screenshot_startjob(void *sjv, short *stop, short *do_update, float *do_update= 1; // wait for opengl rect - while(*stop==0) { + while (*stop==0) { - if(sj->dumprect) { + if (sj->dumprect) { - if(mh) { - if(mh->append_movie(&rd, rd.sfra, rd.cfra, (int *)sj->dumprect, + if (mh) { + if (mh->append_movie(&rd, rd.sfra, rd.cfra, (int *)sj->dumprect, sj->dumpsx, sj->dumpsy, &sj->reports)) { BKE_reportf(&sj->reports, RPT_INFO, "Appended frame: %d", rd.cfra); printf("Appended frame %d\n", rd.cfra); - } else + } + else { break; + } } else { ImBuf *ibuf= IMB_allocImBuf(sj->dumpsx, sj->dumpsy, rd.im_format.planes, 0); @@ -320,7 +322,7 @@ static void screenshot_startjob(void *sjv, short *stop, short *do_update, float ibuf->rect= sj->dumprect; ok= BKE_write_ibuf(ibuf, name, &rd.im_format); - if(ok==0) { + if (ok==0) { printf("Write error: cannot save %s\n", name); BKE_reportf(&sj->reports, RPT_INFO, "Write error: cannot save %s\n", name); break; @@ -346,7 +348,7 @@ static void screenshot_startjob(void *sjv, short *stop, short *do_update, float PIL_sleep_ms(U.scrcastwait); } - if(mh) + if (mh) mh->end_movie(); BKE_report(&sj->reports, RPT_INFO, "Screencast job stopped"); @@ -359,7 +361,7 @@ static int screencast_exec(bContext *C, wmOperator *op) ScreenshotJob *sj= MEM_callocN(sizeof(ScreenshotJob), "screenshot job"); /* setup sj */ - if(RNA_boolean_get(op->ptr, "full")) { + if (RNA_boolean_get(op->ptr, "full")) { wmWindow *win= CTX_wm_window(C); sj->x= 0; sj->y= 0; diff --git a/source/blender/editors/sculpt_paint/paint_cursor.c b/source/blender/editors/sculpt_paint/paint_cursor.c index ea1e3eb47af..be50b842914 100644 --- a/source/blender/editors/sculpt_paint/paint_cursor.c +++ b/source/blender/editors/sculpt_paint/paint_cursor.c @@ -341,7 +341,7 @@ static int sculpt_get_brush_geometry(bContext* C, ViewContext *vc, window[0] = x + vc->ar->winrct.xmin; window[1] = y + vc->ar->winrct.ymin; - if(vc->obact->sculpt && vc->obact->sculpt->pbvh && + if (vc->obact->sculpt && vc->obact->sculpt->pbvh && sculpt_stroke_get_location(C, location, window)) { *pixel_radius = project_brush_radius(vc, @@ -375,7 +375,7 @@ static void paint_draw_alpha_overlay(Sculpt *sd, Brush *brush, rctf quad; /* check for overlay mode */ - if(!(brush->flag & BRUSH_TEXTURE_OVERLAY) || + if (!(brush->flag & BRUSH_TEXTURE_OVERLAY) || !(ELEM(brush->mtex.brush_map_mode, MTEX_MAP_MODE_FIXED, MTEX_MAP_MODE_TILED))) return; @@ -392,7 +392,7 @@ static void paint_draw_alpha_overlay(Sculpt *sd, Brush *brush, GL_VIEWPORT_BIT| GL_TEXTURE_BIT); - if(load_tex(sd, brush, vc)) { + if (load_tex(sd, brush, vc)) { glEnable(GL_BLEND); glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); @@ -403,7 +403,7 @@ static void paint_draw_alpha_overlay(Sculpt *sd, Brush *brush, glPushMatrix(); glLoadIdentity(); - if(brush->mtex.brush_map_mode == MTEX_MAP_MODE_FIXED) { + if (brush->mtex.brush_map_mode == MTEX_MAP_MODE_FIXED) { /* brush rotation */ glTranslatef(0.5, 0.5, 0); glRotatef((double)RAD2DEGF((brush->flag & BRUSH_RAKE) ? @@ -412,13 +412,13 @@ static void paint_draw_alpha_overlay(Sculpt *sd, Brush *brush, glTranslatef(-0.5f, -0.5f, 0); /* scale based on tablet pressure */ - if(sd->draw_pressure && brush_use_size_pressure(vc->scene, brush)) { + if (sd->draw_pressure && brush_use_size_pressure(vc->scene, brush)) { glTranslatef(0.5f, 0.5f, 0); glScalef(1.0f/sd->pressure_value, 1.0f/sd->pressure_value, 1); glTranslatef(-0.5f, -0.5f, 0); } - if(sd->draw_anchored) { + if (sd->draw_anchored) { const float *aim = sd->anchored_initial_mouse; const rcti *win = &vc->ar->winrct; quad.xmin = aim[0]-sd->anchored_size - win->xmin; @@ -473,12 +473,12 @@ static void paint_cursor_on_hit(Sculpt *sd, Brush *brush, ViewContext *vc, float unprojected_radius, projected_radius; /* update the brush's cached 3D radius */ - if(!brush_use_locked_size(vc->scene, brush)) { + if (!brush_use_locked_size(vc->scene, brush)) { /* get 2D brush radius */ - if(sd->draw_anchored) + if (sd->draw_anchored) projected_radius = sd->anchored_size; else { - if(brush->flag & BRUSH_ANCHORED) + if (brush->flag & BRUSH_ANCHORED) projected_radius = 8; else projected_radius = brush_size(vc->scene, brush); @@ -489,7 +489,7 @@ static void paint_cursor_on_hit(Sculpt *sd, Brush *brush, ViewContext *vc, projected_radius); /* scale 3D brush radius by pressure */ - if(sd->draw_pressure && brush_use_size_pressure(vc->scene, brush)) + if (sd->draw_pressure && brush_use_size_pressure(vc->scene, brush)) unprojected_radius *= sd->pressure_value; /* set cached value in either Brush or UnifiedPaintSettings */ @@ -515,7 +515,7 @@ static void paint_draw_cursor(bContext *C, int x, int y, void *UNUSED(unused)) final_radius = brush_size(scene, brush); /* check that brush drawing is enabled */ - if(!(paint->flags & PAINT_SHOW_BRUSH)) + if (!(paint->flags & PAINT_SHOW_BRUSH)) return; /* can't use stroke vc here because this will be called during @@ -524,7 +524,7 @@ static void paint_draw_cursor(bContext *C, int x, int y, void *UNUSED(unused)) /* TODO: as sculpt and other paint modes are unified, this * special mode of drawing will go away */ - if(vc.obact->sculpt) { + if (vc.obact->sculpt) { Sculpt *sd = CTX_data_tool_settings(C)->sculpt; float location[3]; int pixel_radius, hit; @@ -541,7 +541,7 @@ static void paint_draw_cursor(bContext *C, int x, int y, void *UNUSED(unused)) const float dx = sd->last_x - x; const float dy = sd->last_y - y; - if(dx*dx + dy*dy >= r*r) { + if (dx*dx + dy*dy >= r*r) { sd->last_angle = atan2(dx, dy); sd->last_x = u*sd->last_x + v*x; @@ -555,13 +555,13 @@ static void paint_draw_cursor(bContext *C, int x, int y, void *UNUSED(unused)) /* draw overlay */ paint_draw_alpha_overlay(sd, brush, &vc, x, y); - if(brush_use_locked_size(scene, brush)) + if (brush_use_locked_size(scene, brush)) brush_set_size(scene, brush, pixel_radius); /* check if brush is subtracting, use different color then */ /* TODO: no way currently to know state of pen flip or * invert key modifier without starting a stroke */ - if((!(brush->flag & BRUSH_INVERTED) ^ + if ((!(brush->flag & BRUSH_INVERTED) ^ !(brush->flag & BRUSH_DIR_IN)) && ELEM5(brush->sculpt_tool, SCULPT_TOOL_DRAW, SCULPT_TOOL_INFLATE, SCULPT_TOOL_CLAY, @@ -569,10 +569,10 @@ static void paint_draw_cursor(bContext *C, int x, int y, void *UNUSED(unused)) outline_col = brush->sub_col; /* only do if brush is over the mesh */ - if(hit) + if (hit) paint_cursor_on_hit(sd, brush, &vc, location); - if(sd->draw_anchored) { + if (sd->draw_anchored) { final_radius = sd->anchored_size; translation[0] = sd->anchored_initial_mouse[0] - vc.ar->winrct.xmin; translation[1] = sd->anchored_initial_mouse[1] - vc.ar->winrct.ymin; @@ -602,6 +602,6 @@ void paint_cursor_start(bContext *C, int (*poll)(bContext *C)) { Paint *p = paint_get_active(CTX_data_scene(C)); - if(p && !p->paint_cursor) + if (p && !p->paint_cursor) p->paint_cursor = WM_paint_cursor_activate(CTX_wm_manager(C), poll, paint_draw_cursor, NULL); } diff --git a/source/blender/editors/sculpt_paint/paint_hide.c b/source/blender/editors/sculpt_paint/paint_hide.c index fbb0df401f9..fcf7d2eba68 100644 --- a/source/blender/editors/sculpt_paint/paint_hide.c +++ b/source/blender/editors/sculpt_paint/paint_hide.c @@ -74,8 +74,8 @@ static int planes_contain_v3(float (*planes)[4], int totplane, const float p[3]) { int i; - for(i = 0; i < totplane; i++) { - if(dot_v3v3(planes[i], p) + planes[i][3] > 0) + for (i = 0; i < totplane; i++) { + if (dot_v3v3(planes[i], p) + planes[i][3] > 0) return 0; } @@ -87,7 +87,7 @@ static int is_effected(PartialVisArea area, float planes[4][4], const float co[3]) { - if(area == PARTIALVIS_ALL) + if (area == PARTIALVIS_ALL) return 1; else { int inside = planes_contain_v3(planes, 4, co); @@ -112,23 +112,23 @@ static void partialvis_update_mesh(Object *ob, sculpt_undo_push_node(ob, node, SCULPT_UNDO_HIDDEN); - for(i = 0; i < totvert; i++) { + for (i = 0; i < totvert; i++) { MVert *v = &mvert[vert_indices[i]]; /* hide vertex if in the hide volume */ - if(is_effected(area, planes, v->co)) { - if(action == PARTIALVIS_HIDE) + if (is_effected(area, planes, v->co)) { + if (action == PARTIALVIS_HIDE) v->flag |= ME_HIDE; else v->flag &= ~ME_HIDE; any_changed = 1; } - if(!(v->flag & ME_HIDE)) + if (!(v->flag & ME_HIDE)) any_visible = 1; } - if(any_changed) { + if (any_changed) { BLI_pbvh_node_mark_rebuild_draw(node); BLI_pbvh_node_fully_hidden_set(node, !any_visible); } @@ -157,12 +157,12 @@ static void partialvis_update_grids(Object *ob, sculpt_undo_push_node(ob, node, SCULPT_UNDO_HIDDEN); any_changed = 0; - for(i = 0; i < totgrid; i++) { + for (i = 0; i < totgrid; i++) { int any_hidden = 0; int g = grid_indices[i], x, y; BLI_bitmap gh = grid_hidden[g]; - if(!gh) { + if (!gh) { switch(action) { case PARTIALVIS_HIDE: /* create grid flags data */ @@ -174,7 +174,7 @@ static void partialvis_update_grids(Object *ob, continue; } } - else if(action == PARTIALVIS_SHOW && area == PARTIALVIS_ALL) { + else if (action == PARTIALVIS_SHOW && area == PARTIALVIS_ALL) { /* special case if we're showing all, just free the grid */ MEM_freeN(gh); @@ -184,12 +184,12 @@ static void partialvis_update_grids(Object *ob, continue; } - for(y = 0; y < gridsize; y++) { - for(x = 0; x < gridsize; x++) { + for (y = 0; y < gridsize; y++) { + for (x = 0; x < gridsize; x++) { const float *co = grids[g][y * gridsize + x].co; /* skip grid element if not in the effected area */ - if(is_effected(area, planes, co)) { + if (is_effected(area, planes, co)) { /* set or clear the hide flag */ BLI_BITMAP_MODIFY(gh, y * gridsize + x, action == PARTIALVIS_HIDE); @@ -198,7 +198,7 @@ static void partialvis_update_grids(Object *ob, } /* keep track of whether any elements are still hidden */ - if(BLI_BITMAP_GET(gh, y * gridsize + x)) + if (BLI_BITMAP_GET(gh, y * gridsize + x)) any_hidden = 1; else any_visible = 1; @@ -207,14 +207,14 @@ static void partialvis_update_grids(Object *ob, /* if everything in the grid is now visible, free the grid flags */ - if(!any_hidden) { + if (!any_hidden) { MEM_freeN(gh); grid_hidden[g] = NULL; } } /* mark updates if anything was hidden/shown */ - if(any_changed) { + if (any_changed) { BLI_pbvh_node_mark_rebuild_draw(node); BLI_pbvh_node_fully_hidden_set(node, !any_visible); multires_mark_as_modified(ob, MULTIRES_HIDDEN_MODIFIED); @@ -310,7 +310,7 @@ static int hide_show_exec(bContext *C, wmOperator *op) break; } - for(i = 0; i < totnode; i++) { + for (i = 0; i < totnode; i++) { switch(pbvh_type) { case PBVH_FACES: partialvis_update_mesh(ob, pbvh, nodes[i], action, area, clip_planes); @@ -321,7 +321,7 @@ static int hide_show_exec(bContext *C, wmOperator *op) } } - if(nodes) + if (nodes) MEM_freeN(nodes); /* end undo */ @@ -329,7 +329,7 @@ static int hide_show_exec(bContext *C, wmOperator *op) /* ensure that edges and faces get hidden as well (not used by sculpt but it looks wrong when entering editmode otherwise) */ - if(pbvh_type == PBVH_FACES) { + if (pbvh_type == PBVH_FACES) { mesh_flush_hidden_from_verts(me->mvert, me->mloop, me->medge, me->totedge, me->mpoly, me->totpoly); @@ -344,7 +344,7 @@ static int hide_show_invoke(bContext *C, wmOperator *op, wmEvent *event) { PartialVisArea area = RNA_enum_get(op->ptr, "area"); - if(area != PARTIALVIS_ALL) + if (area != PARTIALVIS_ALL) return WM_border_select_invoke(C, op, event); else return op->type->exec(C, op); diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c index a19d00b4926..40b04437cdf 100644 --- a/source/blender/editors/sculpt_paint/paint_image.c +++ b/source/blender/editors/sculpt_paint/paint_image.c @@ -403,13 +403,14 @@ static void undo_copy_tile(UndoImageTile *tile, ImBuf *tmpibuf, ImBuf *ibuf, int IMB_rectcpy(tmpibuf, ibuf, 0, 0, tile->x*IMAPAINT_TILE_SIZE, tile->y*IMAPAINT_TILE_SIZE, IMAPAINT_TILE_SIZE, IMAPAINT_TILE_SIZE); - if(ibuf->rect_float) { + if (ibuf->rect_float) { SWAP(void*, tmpibuf->rect_float, tile->rect); - } else { + } + else { SWAP(void*, tmpibuf->rect, tile->rect); } - if(restore) + if (restore) IMB_rectcpy(ibuf, tmpibuf, tile->x*IMAPAINT_TILE_SIZE, tile->y*IMAPAINT_TILE_SIZE, 0, 0, IMAPAINT_TILE_SIZE, IMAPAINT_TILE_SIZE); } @@ -421,10 +422,10 @@ static void *image_undo_push_tile(Image *ima, ImBuf *ibuf, ImBuf **tmpibuf, int int allocsize; short use_float = ibuf->rect_float ? 1 : 0; - for(tile=lb->first; tile; tile=tile->next) - if(tile->x == x_tile && tile->y == y_tile && ima->gen_type == tile->gen_type && ima->source == tile->source) - if(tile->use_float == use_float) - if(strcmp(tile->idname, ima->id.name)==0 && strcmp(tile->ibufname, ibuf->name)==0) + for (tile=lb->first; tile; tile=tile->next) + if (tile->x == x_tile && tile->y == y_tile && ima->gen_type == tile->gen_type && ima->source == tile->source) + if (tile->use_float == use_float) + if (strcmp(tile->idname, ima->id.name)==0 && strcmp(tile->ibufname, ibuf->name)==0) return tile->rect; if (*tmpibuf==NULL) @@ -463,11 +464,11 @@ static void image_undo_restore(bContext *C, ListBase *lb) tmpibuf= IMB_allocImBuf(IMAPAINT_TILE_SIZE, IMAPAINT_TILE_SIZE, 32, IB_rectfloat|IB_rect); - for(tile=lb->first; tile; tile=tile->next) { + for (tile=lb->first; tile; tile=tile->next) { short use_float; /* find image based on name, pointer becomes invalid with global undo */ - if(ima && strcmp(tile->idname, ima->id.name)==0) { + if (ima && strcmp(tile->idname, ima->id.name)==0) { /* ima is valid */ } else { @@ -476,7 +477,7 @@ static void image_undo_restore(bContext *C, ListBase *lb) ibuf= BKE_image_get_ibuf(ima, NULL); - if(ima && ibuf && strcmp(tile->ibufname, ibuf->name)!=0) { + if (ima && ibuf && strcmp(tile->ibufname, ibuf->name)!=0) { /* current ImBuf filename was changed, probably current frame * was changed when paiting on image sequence, rather than storing * full image user (which isn't so obvious, btw) try to find ImBuf with @@ -499,9 +500,9 @@ static void image_undo_restore(bContext *C, ListBase *lb) undo_copy_tile(tile, tmpibuf, ibuf, 1); GPU_free_image(ima); /* force OpenGL reload */ - if(ibuf->rect_float) + if (ibuf->rect_float) ibuf->userflags |= IB_RECT_INVALID; /* force recreate of char rect */ - if(ibuf->mipmap[0]) + if (ibuf->mipmap[0]) ibuf->userflags |= IB_MIPMAP_INVALID; /* force mipmap recreatiom */ } @@ -513,7 +514,7 @@ static void image_undo_free(ListBase *lb) { UndoImageTile *tile; - for(tile=lb->first; tile; tile=tile->next) + for (tile=lb->first; tile; tile=tile->next) MEM_freeN(tile->rect); } @@ -523,7 +524,7 @@ static Image *imapaint_face_image(const ImagePaintState *s, int face_index) { Image *ima; - if(scene_use_new_shading_nodes(s->scene)) { + if (scene_use_new_shading_nodes(s->scene)) { MFace *mf = s->me->mface+face_index; ED_object_get_active_image(s->ob, mf->mat_nr, &ima, NULL, NULL); } @@ -539,7 +540,7 @@ static Image *project_paint_face_image(const ProjPaintState *ps, MTFace *dm_mtfa { Image *ima; - if(ps->do_new_shading_nodes) { /* cached scene_use_new_shading_nodes result */ + if (ps->do_new_shading_nodes) { /* cached scene_use_new_shading_nodes result */ MFace *mf = ps->dm_mface+face_index; ED_object_get_active_image(ps->ob, mf->mat_nr, &ima, NULL, NULL); } @@ -815,7 +816,7 @@ static int project_paint_PickColor(const ProjPaintState *ps, float pt[2], float static int project_paint_occlude_ptv(float pt[3], float v1[4], float v2[4], float v3[4], float w[3], int is_ortho) { /* if all are behind us, return false */ - if(v1[2] > pt[2] && v2[2] > pt[2] && v3[2] > pt[2]) + if (v1[2] > pt[2] && v2[2] > pt[2] && v3[2] > pt[2]) return 0; /* do a 2D point in try intersection */ @@ -825,7 +826,7 @@ static int project_paint_occlude_ptv(float pt[3], float v1[4], float v2[4], floa /* From here on we know there IS an intersection */ /* if ALL of the verts are infront of us then we know it intersects ? */ - if(v1[2] < pt[2] && v2[2] < pt[2] && v3[2] < pt[2]) { + if (v1[2] < pt[2] && v2[2] < pt[2] && v3[2] < pt[2]) { return 1; } else { @@ -889,14 +890,14 @@ static int project_bucket_point_occluded(const ProjPaintState *ps, LinkNode *buc if (orig_face != face_index) { mf = ps->dm_mface + face_index; - if(do_clip) + if (do_clip) isect_ret = project_paint_occlude_ptv_clip(ps, mf, pixelScreenCo, ps->screenCoords[mf->v1], ps->screenCoords[mf->v2], ps->screenCoords[mf->v3], 0); else isect_ret = project_paint_occlude_ptv(pixelScreenCo, ps->screenCoords[mf->v1], ps->screenCoords[mf->v2], ps->screenCoords[mf->v3], w, ps->is_ortho); /* Note, if isect_ret==-1 then we don't want to test the other side of the quad */ if (isect_ret==0 && mf->v4) { - if(do_clip) + if (do_clip) isect_ret = project_paint_occlude_ptv_clip(ps, mf, pixelScreenCo, ps->screenCoords[mf->v1], ps->screenCoords[mf->v3], ps->screenCoords[mf->v4], 1); else isect_ret = project_paint_occlude_ptv(pixelScreenCo, ps->screenCoords[mf->v1], ps->screenCoords[mf->v3], ps->screenCoords[mf->v4], w, ps->is_ortho); @@ -1392,7 +1393,8 @@ static float project_paint_uvpixel_mask( else { return 0.0f; } - } else { + } + else { mask = 1.0f; } @@ -2095,7 +2097,7 @@ static void project_bucket_clip_face( /* now we have all points we need, collect their angles and sort them clockwise */ - for(i=0; i<(*tot); i++) { + for (i=0; i<(*tot); i++) { cent[0] += isectVCosSS[i][0]; cent[1] += isectVCosSS[i][1]; } @@ -2108,7 +2110,7 @@ static void project_bucket_clip_face( #if 0 /* uses a few more cycles then the above loop */ - for(i=0; i<(*tot); i++) { + for (i=0; i<(*tot); i++) { isectVCosSS[i][2] = angle_2d_clockwise(up, cent, isectVCosSS[i]); } #endif @@ -2116,7 +2118,7 @@ static void project_bucket_clip_face( v1_clipSS[0] = cent[0]; /* Abuse this var for the loop below */ v1_clipSS[1] = cent[1] + 1.0f; - for(i=0; i<(*tot); i++) { + for (i=0; i<(*tot); i++) { v2_clipSS[0] = isectVCosSS[i][0] - cent[0]; v2_clipSS[1] = isectVCosSS[i][1] - cent[1]; isectVCosSS[i][2] = atan2f(v1_clipSS[0]*v2_clipSS[1] - v1_clipSS[1]*v2_clipSS[0], v1_clipSS[0]*v2_clipSS[0]+v1_clipSS[1]*v2_clipSS[1]); @@ -2141,12 +2143,12 @@ static void project_bucket_clip_face( doubles = TRUE; while (doubles==TRUE) { doubles = FALSE; - for(i=1; i<(*tot); i++) { + for (i=1; i<(*tot); i++) { if (fabsf(isectVCosSS[i-1][0]-isectVCosSS[i][0]) < PROJ_GEOM_TOLERANCE && fabsf(isectVCosSS[i-1][1]-isectVCosSS[i][1]) < PROJ_GEOM_TOLERANCE) { int j; - for(j=i+1; j<(*tot); j++) { + for (j=i+1; j<(*tot); j++) { isectVCosSS[j-1][0] = isectVCosSS[j][0]; isectVCosSS[j-1][1] = isectVCosSS[j][1]; } @@ -2165,13 +2167,13 @@ static void project_bucket_clip_face( if (is_ortho) { - for(i=0; i<(*tot); i++) { + for (i=0; i<(*tot); i++) { barycentric_weights_v2(v1coSS, v2coSS, v3coSS, isectVCosSS[i], w); interp_v2_v2v2v2(bucket_bounds_uv[i], uv1co, uv2co, uv3co, w); } } else { - for(i=0; i<(*tot); i++) { + for (i=0; i<(*tot); i++) { barycentric_weights_v2_persp(v1coSS, v2coSS, v3coSS, isectVCosSS[i], w); interp_v2_v2v2v2(bucket_bounds_uv[i], uv1co, uv2co, uv3co, w); } @@ -2405,12 +2407,12 @@ static void project_paint_face_init(const ProjPaintState *ps, const int thread_i if (pixel_bounds_array(uv_clip, &bounds_px, ibuf->x, ibuf->y, uv_clip_tot)) { - if(clamp_u) { + if (clamp_u) { CLAMP(bounds_px.xmin, 0, ibuf->x); CLAMP(bounds_px.xmax, 0, ibuf->x); } - if(clamp_v) { + if (clamp_v) { CLAMP(bounds_px.ymin, 0, ibuf->y); CLAMP(bounds_px.ymax, 0, ibuf->y); } @@ -2429,7 +2431,7 @@ static void project_paint_face_init(const ProjPaintState *ps, const int thread_i /* Note about IsectPoly2Df_twoside, checking the face or uv flipping doesnt work, * could check the poly direction but better to do this */ - if( (do_backfacecull && IsectPoly2Df(uv, uv_clip, uv_clip_tot)) || + if ( (do_backfacecull && IsectPoly2Df(uv, uv_clip, uv_clip_tot)) || (do_backfacecull==0 && IsectPoly2Df_twoside(uv, uv_clip, uv_clip_tot))) { has_x_isect = has_isect = 1; @@ -2438,7 +2440,7 @@ static void project_paint_face_init(const ProjPaintState *ps, const int thread_i else screen_px_from_persp(uv, v1coSS, v2coSS, v3coSS, uv1co, uv2co, uv3co, pixelScreenCo, w); /* a pity we need to get the worldspace pixel location here */ - if(do_clip) { + if (do_clip) { interp_v3_v3v3v3(wco, ps->dm_mvert[ (*(&mf->v1 + i1)) ].co, ps->dm_mvert[ (*(&mf->v1 + i2)) ].co, ps->dm_mvert[ (*(&mf->v1 + i3)) ].co, w); if (ED_view3d_clipping_test(ps->rv3d, wco, TRUE)) { continue; /* Watch out that no code below this needs to run */ @@ -2479,7 +2481,7 @@ static void project_paint_face_init(const ProjPaintState *ps, const int thread_i #endif } } - } while(side--); + } while (side--); @@ -2659,7 +2661,7 @@ static void project_paint_face_init(const ProjPaintState *ps, const int thread_i } /* a pity we need to get the worldspace pixel location here */ - if(do_clip) { + if (do_clip) { if (side) interp_v3_v3v3v3(wco, ps->dm_mvert[mf->v1].co, ps->dm_mvert[mf->v3].co, ps->dm_mvert[mf->v4].co, w); else interp_v3_v3v3v3(wco, ps->dm_mvert[mf->v1].co, ps->dm_mvert[mf->v2].co, ps->dm_mvert[mf->v3].co, w); @@ -2952,7 +2954,7 @@ static void project_paint_begin(ProjPaintState *ps) /* ---- end defines ---- */ - if(ps->source==PROJ_SRC_VIEW) + if (ps->source==PROJ_SRC_VIEW) ED_view3d_clipping_local(ps->rv3d, ps->ob->obmat); /* faster clipping lookups */ /* paint onto the derived mesh */ @@ -2963,7 +2965,7 @@ static void project_paint_begin(ProjPaintState *ps) ps->dm = mesh_create_derived_render(ps->scene, ps->ob, ps->scene->customdata_mask | CD_MASK_MTFACE); ps->dm_release= TRUE; } - else if(ps->ob->derivedFinal && CustomData_has_layer( &ps->ob->derivedFinal->faceData, CD_MTFACE)) { + else if (ps->ob->derivedFinal && CustomData_has_layer( &ps->ob->derivedFinal->faceData, CD_MTFACE)) { ps->dm = ps->ob->derivedFinal; ps->dm_release= FALSE; } @@ -2974,7 +2976,7 @@ static void project_paint_begin(ProjPaintState *ps) if ( !CustomData_has_layer( &ps->dm->faceData, CD_MTFACE) ) { - if(ps->dm_release) + if (ps->dm_release) ps->dm->release(ps->dm); ps->dm = NULL; @@ -3019,7 +3021,7 @@ static void project_paint_begin(ProjPaintState *ps) } /* when using subsurf or multires, mface arrays are thrown away, we need to keep a copy */ - if(ps->dm->type != DM_TYPE_CDDM) { + if (ps->dm->type != DM_TYPE_CDDM) { ps->dm_mvert= MEM_dupallocN(ps->dm_mvert); ps->dm_mface= MEM_dupallocN(ps->dm_mface); /* looks like these are ok for now.*/ @@ -3040,7 +3042,7 @@ static void project_paint_begin(ProjPaintState *ps) invert_m4_m4(ps->ob->imat, ps->ob->obmat); - if(ps->source==PROJ_SRC_VIEW) { + if (ps->source==PROJ_SRC_VIEW) { /* normal drawing */ ps->winx= ps->ar->winx; ps->winy= ps->ar->winy; @@ -3126,7 +3128,7 @@ static void project_paint_begin(ProjPaintState *ps) projScreenCo= *ps->screenCoords; if (ps->is_ortho) { - for(a=0, mv=ps->dm_mvert; a < ps->dm_totvert; a++, mv++, projScreenCo+=4) { + for (a=0, mv=ps->dm_mvert; a < ps->dm_totvert; a++, mv++, projScreenCo+=4) { mul_v3_m4v3(projScreenCo, ps->projectMat, mv->co); /* screen space, not clamped */ @@ -3136,7 +3138,7 @@ static void project_paint_begin(ProjPaintState *ps) } } else { - for(a=0, mv=ps->dm_mvert; a < ps->dm_totvert; a++, mv++, projScreenCo+=4) { + for (a=0, mv=ps->dm_mvert; a < ps->dm_totvert; a++, mv++, projScreenCo+=4) { copy_v3_v3(projScreenCo, mv->co); projScreenCo[3] = 1.0f; @@ -3169,7 +3171,7 @@ static void project_paint_begin(ProjPaintState *ps) ps->screenMax[1] += projMargin; ps->screenMin[1] -= projMargin; - if(ps->source==PROJ_SRC_VIEW) { + if (ps->source==PROJ_SRC_VIEW) { #ifdef PROJ_DEBUG_WINCLIP CLAMP(ps->screenMin[0], (float)(-diameter), (float)(ps->winx + diameter)); CLAMP(ps->screenMax[0], (float)(-diameter), (float)(ps->winx + diameter)); @@ -3235,7 +3237,7 @@ static void project_paint_begin(ProjPaintState *ps) ps->vertFlags = MEM_callocN(sizeof(char) * ps->dm_totvert, "paint-vertFlags"); - for(a=0, mv=ps->dm_mvert; a < ps->dm_totvert; a++, mv++) { + for (a=0, mv=ps->dm_mvert; a < ps->dm_totvert; a++, mv++) { normal_short_to_float_v3(no, mv->no); if (ps->is_ortho) { @@ -3254,7 +3256,7 @@ static void project_paint_begin(ProjPaintState *ps) } - for(face_index = 0, tf = ps->dm_mtface, mf = ps->dm_mface; face_index < ps->dm_totface; mf++, tf++, face_index++) { + for (face_index = 0, tf = ps->dm_mtface, mf = ps->dm_mface; face_index < ps->dm_totface; mf++, tf++, face_index++) { #ifndef PROJ_DEBUG_NOSEAMBLEED /* add face user if we have bleed enabled, set the UV seam flags later */ @@ -3400,7 +3402,7 @@ static void project_paint_end(ProjPaintState *ps) int a; /* build undo data from original pixel colors */ - if(U.uiflag & USER_GLOBALUNDO) { + if (U.uiflag & USER_GLOBALUNDO) { ProjPixel *projPixel; ImBuf *tmpibuf = NULL, *tmpibuf_float = NULL; LinkNode *pixel_node; @@ -3419,7 +3421,7 @@ static void project_paint_end(ProjPaintState *ps) int last_image_index = -1; int last_tile_width=0; - for(a=0, last_projIma=ps->projImages; a < ps->image_tot; a++, last_projIma++) { + for (a=0, last_projIma=ps->projImages; a < ps->image_tot; a++, last_projIma++) { int size = sizeof(void **) * IMAPAINT_TILE_NUMBER(last_projIma->ibuf->x) * IMAPAINT_TILE_NUMBER(last_projIma->ibuf->y); last_projIma->undoRect = (void **) BLI_memarena_alloc(arena, size); memset(last_projIma->undoRect, 0, size); @@ -3428,7 +3430,7 @@ static void project_paint_end(ProjPaintState *ps) for (bucket_index = 0; bucket_index < bucket_tot; bucket_index++) { /* loop through all pixels */ - for(pixel_node= ps->bucketRect[bucket_index]; pixel_node; pixel_node= pixel_node->next) { + for (pixel_node= ps->bucketRect[bucket_index]; pixel_node; pixel_node= pixel_node->next) { /* ok we have a pixel, was it modified? */ projPixel = (ProjPixel *)pixel_node->link; @@ -3506,18 +3508,18 @@ static void project_paint_end(ProjPaintState *ps) } /* copy for subsurf/multires, so throw away */ - if(ps->dm->type != DM_TYPE_CDDM) { - if(ps->dm_mvert) MEM_freeN(ps->dm_mvert); - if(ps->dm_mface) MEM_freeN(ps->dm_mface); + if (ps->dm->type != DM_TYPE_CDDM) { + if (ps->dm_mvert) MEM_freeN(ps->dm_mvert); + if (ps->dm_mface) MEM_freeN(ps->dm_mface); /* looks like these don't need copying */ #if 0 - if(ps->dm_mtface) MEM_freeN(ps->dm_mtface); - if(ps->dm_mtface_clone) MEM_freeN(ps->dm_mtface_clone); - if(ps->dm_mtface_stencil) MEM_freeN(ps->dm_mtface_stencil); + if (ps->dm_mtface) MEM_freeN(ps->dm_mtface); + if (ps->dm_mtface_clone) MEM_freeN(ps->dm_mtface_clone); + if (ps->dm_mtface_stencil) MEM_freeN(ps->dm_mtface_stencil); #endif } - if(ps->dm_release) + if (ps->dm_release) ps->dm->release(ps->dm); } @@ -3589,7 +3591,7 @@ static int project_image_refresh_tagged(ProjPaintState *ps) /* run this per painting onto each mouse location */ static int project_bucket_iter_init(ProjPaintState *ps, const float mval_f[2]) { - if(ps->source==PROJ_SRC_VIEW) { + if (ps->source==PROJ_SRC_VIEW) { float min_brush[2], max_brush[2]; const float radius = (float)brush_size(ps->scene, ps->brush); @@ -3791,17 +3793,17 @@ static void do_projectpaint_draw_f(ProjPaintState *ps, ProjPixel *projPixel, flo { if (ps->is_texbrush) { /* rgba already holds a texture result here from higher level function */ - if(use_color_correction){ + if (use_color_correction) { float rgba_br[3]; srgb_to_linearrgb_v3_v3(rgba_br, ps->brush->rgb); mul_v3_v3(rgba, rgba_br); } - else{ + else { mul_v3_v3(rgba, ps->brush->rgb); } } else { - if(use_color_correction){ + if (use_color_correction) { srgb_to_linearrgb_v3_v3(rgba, ps->brush->rgb); } else { @@ -3879,7 +3881,7 @@ static void *do_projectpaint_thread(void *ph_v) project_bucket_init(ps, thread_index, bucket_index, &bucket_bounds); } - if(ps->source != PROJ_SRC_VIEW) { + if (ps->source != PROJ_SRC_VIEW) { /* Re-Projection, simple, no brushes! */ @@ -3887,7 +3889,7 @@ static void *do_projectpaint_thread(void *ph_v) projPixel = (ProjPixel *)node->link; bicubic_interpolation_color(ps->reproject_ibuf, projPixel->newColor.ch, NULL, projPixel->projCoSS[0], projPixel->projCoSS[1]); - if(projPixel->newColor.ch[3]) { + if (projPixel->newColor.ch[3]) { mask = ((float)projPixel->mask)/65535.0f; blend_color_mix_accum(projPixel->pixel.ch_pt, projPixel->origColor.ch, projPixel->newColor.ch, (int)(mask*projPixel->newColor.ch[3])); @@ -3914,7 +3916,8 @@ static void *do_projectpaint_thread(void *ph_v) /* note, for clone and smear, we only use the alpha, could be a special function */ brush_sample_tex(ps->scene, ps->brush, projPixel->projCoSS, rgba, thread_index); alpha = rgba[3]; - } else { + } + else { alpha = 1.0f; } @@ -3986,7 +3989,7 @@ static void *do_projectpaint_thread(void *ph_v) } } - if(lock_alpha) { + if (lock_alpha) { if (is_floatbuf) projPixel->pixel.f_pt[3]= projPixel->origColor.f[3]; else projPixel->pixel.ch_pt[3]= projPixel->origColor.ch[3]; } @@ -4035,7 +4038,7 @@ static int project_paint_op(void *state, ImBuf *UNUSED(ibufb), const float lastp BLI_init_threads(&threads, do_projectpaint_thread, ps->thread_tot); /* get the threads running */ - for(a=0; a < ps->thread_tot; a++) { + for (a=0; a < ps->thread_tot; a++) { /* set defaults in handles */ //memset(&handles[a], 0, sizeof(BakeShade)); @@ -4068,9 +4071,9 @@ static int project_paint_op(void *state, ImBuf *UNUSED(ibufb), const float lastp /* move threaded bounds back into ps->projectPartialRedraws */ - for(i=0; i < ps->image_tot; i++) { + for (i=0; i < ps->image_tot; i++) { int touch = 0; - for(a=0; a < ps->thread_tot; a++) { + for (a=0; a < ps->thread_tot; a++) { touch |= partial_redraw_array_merge(ps->projImages[i].partRedrawRect, handles[a].projImages[i].partRedrawRect, PROJ_BOUNDBOX_SQUARED); } @@ -4112,7 +4115,7 @@ static int project_paint_stroke(ProjPaintState *ps, BrushPainter *painter, const redraw= project_paint_sub_stroke(ps, painter, prevmval_i, mval_i, time, pressure); - if(project_image_refresh_tagged(ps)) + if (project_image_refresh_tagged(ps)) return redraw; return 0; @@ -4166,14 +4169,14 @@ static void imapaint_dirty_region(Image *ima, ImBuf *ibuf, int x, int y, int w, static void imapaint_image_update(SpaceImage *sima, Image *image, ImBuf *ibuf, short texpaint) { - if(ibuf->rect_float) + if (ibuf->rect_float) ibuf->userflags |= IB_RECT_INVALID; /* force recreate of char rect */ - if(ibuf->mipmap[0]) + if (ibuf->mipmap[0]) ibuf->userflags |= IB_MIPMAP_INVALID; /* todo: should set_tpage create ->rect? */ - if(texpaint || (sima && sima->lock)) { + if (texpaint || (sima && sima->lock)) { int w = imapaintpartial.x2 - imapaintpartial.x1; int h = imapaintpartial.y2 - imapaintpartial.y1; /* Testing with partial update in uv editor too */ @@ -4197,7 +4200,8 @@ static void imapaint_ibuf_get_set_rgb(ImBuf *ibuf, int x, int y, short torus, sh if (set) { IMAPAINT_FLOAT_RGB_COPY(rrgbf, rgb); - } else { + } + else { IMAPAINT_FLOAT_RGB_COPY(rgb, rrgbf); } } @@ -4206,7 +4210,8 @@ static void imapaint_ibuf_get_set_rgb(ImBuf *ibuf, int x, int y, short torus, sh if (set) { IMAPAINT_FLOAT_RGB_TO_CHAR(rrgb, rgb) - } else { + } + else { IMAPAINT_CHAR_RGB_TO_FLOAT(rgb, rrgb) } } @@ -4340,7 +4345,7 @@ static void imapaint_lift_smear(ImBuf *ibuf, ImBuf *ibufb, int *pos) imapaint_set_region(region, 0, 0, pos[0], pos[1], ibufb->x, ibufb->y); tot= imapaint_torus_split_region(region, ibufb, ibuf); - for(a=0; atool == PAINT_TOOL_SOFTEN) { + if (s->tool == PAINT_TOOL_SOFTEN) { imapaint_lift_soften(s->canvas, ibufb, bpos, torus); } - else if(s->tool == PAINT_TOOL_SMEAR) { + else if (s->tool == PAINT_TOOL_SMEAR) { if (lastpos[0]==pos[0] && lastpos[1]==pos[1]) return 0; imapaint_convert_brushco(ibufb, lastpos, blastpos); imapaint_lift_smear(s->canvas, ibufb, blastpos); } - else if(s->tool == PAINT_TOOL_CLONE && s->clonecanvas) { + else if (s->tool == PAINT_TOOL_CLONE && s->clonecanvas) { liftpos[0]= pos[0] - offset[0]*s->canvas->x; liftpos[1]= pos[1] - offset[1]*s->canvas->y; @@ -4405,7 +4410,7 @@ static int imapaint_paint_op(void *state, ImBuf *ibufb, const float lastpos[2], frombuf= (clonebuf)? clonebuf: ibufb; - if(torus) { + if (torus) { imapaint_set_region(region, bpos[0], bpos[1], 0, 0, frombuf->x, frombuf->y); tot= imapaint_torus_split_region(region, s->canvas, frombuf); } @@ -4415,7 +4420,7 @@ static int imapaint_paint_op(void *state, ImBuf *ibufb, const float lastpos[2], } /* blend into canvas */ - for(a=0; aimage, s->canvas, region[a].destx, region[a].desty, region[a].width, region[a].height); @@ -4426,7 +4431,7 @@ static int imapaint_paint_op(void *state, ImBuf *ibufb, const float lastpos[2], region[a].width, region[a].height, blend); } - if(clonebuf) IMB_freeImBuf(clonebuf); + if (clonebuf) IMB_freeImBuf(clonebuf); return 1; } @@ -4453,35 +4458,35 @@ static int imapaint_canvas_set(ImagePaintState *s, Image *ima) ImBuf *ibuf= BKE_image_get_ibuf(ima, s->sima? &s->sima->iuser: NULL); /* verify that we can paint and set canvas */ - if(ima==NULL) { + if (ima==NULL) { return 0; } - else if(ima->packedfile && ima->rr) { + else if (ima->packedfile && ima->rr) { s->warnpackedfile = ima->id.name + 2; return 0; } - else if(ibuf && ibuf->channels!=4) { + else if (ibuf && ibuf->channels!=4) { s->warnmultifile = ima->id.name + 2; return 0; } - else if(!ibuf || !(ibuf->rect || ibuf->rect_float)) + else if (!ibuf || !(ibuf->rect || ibuf->rect_float)) return 0; s->image= ima; s->canvas= ibuf; /* set clone canvas */ - if(s->tool == PAINT_TOOL_CLONE) { + if (s->tool == PAINT_TOOL_CLONE) { ima= s->brush->clone.image; ibuf= BKE_image_get_ibuf(ima, s->sima? &s->sima->iuser: NULL); - if(!ima || !ibuf || !(ibuf->rect || ibuf->rect_float)) + if (!ima || !ibuf || !(ibuf->rect || ibuf->rect_float)) return 0; s->clonecanvas= ibuf; /* temporarily add float rect for cloning */ - if(s->canvas->rect_float && !s->clonecanvas->rect_float) { + if (s->canvas->rect_float && !s->clonecanvas->rect_float) { int profile = IB_PROFILE_NONE; /* Don't want to color manage, but don't disturb existing profiles */ @@ -4492,7 +4497,7 @@ static int imapaint_canvas_set(ImagePaintState *s, Image *ima) SWAP(int, s->clonecanvas->profile, profile); } - else if(!s->canvas->rect_float && !s->clonecanvas->rect) + else if (!s->canvas->rect_float && !s->clonecanvas->rect) IMB_rect_from_float(s->clonecanvas); } @@ -4510,7 +4515,7 @@ static int imapaint_paint_sub_stroke(ImagePaintState *s, BrushPainter *painter, ImBuf *ibuf= BKE_image_get_ibuf(image, s->sima? &s->sima->iuser: NULL); float pos[2]; - if(!ibuf) + if (!ibuf) return 0; pos[0] = uv[0]*ibuf->x; @@ -4543,7 +4548,7 @@ static int imapaint_paint_stroke(ViewContext *vc, ImagePaintState *s, BrushPaint newimage = imapaint_face_image(s, newfaceindex); ibuf= BKE_image_get_ibuf(newimage, s->sima? &s->sima->iuser: NULL); - if(ibuf && ibuf->rect) + if (ibuf && ibuf->rect) imapaint_pick_uv(s->scene, s->ob, newfaceindex, mval, newuv); else { newimage = NULL; @@ -4621,7 +4626,7 @@ static Brush *uv_sculpt_brush(bContext *C) Scene *scene= CTX_data_scene(C); ToolSettings *settings= scene->toolsettings; - if(!settings->uvsculpt) + if (!settings->uvsculpt) return NULL; return paint_brush(&settings->uvsculpt->paint); } @@ -4630,19 +4635,19 @@ static int image_paint_poll(bContext *C) { Object *obact = CTX_data_active_object(C); - if(!image_paint_brush(C)) + if (!image_paint_brush(C)) return 0; - if((obact && obact->mode & OB_MODE_TEXTURE_PAINT) && CTX_wm_region_view3d(C)) { + if ((obact && obact->mode & OB_MODE_TEXTURE_PAINT) && CTX_wm_region_view3d(C)) { return 1; } else { SpaceImage *sima= CTX_wm_space_image(C); - if(sima) { + if (sima) { ARegion *ar= CTX_wm_region(C); - if((sima->flag & SI_DRAWTOOL) && ar->regiontype==RGN_TYPE_WINDOW) + if ((sima->flag & SI_DRAWTOOL) && ar->regiontype==RGN_TYPE_WINDOW) return 1; } } @@ -4659,15 +4664,15 @@ static int uv_sculpt_brush_poll(bContext *C) Scene *scene = CTX_data_scene(C); ToolSettings *toolsettings = scene->toolsettings; - if(!uv_sculpt_brush(C) || !obedit || obedit->type != OB_MESH) + if (!uv_sculpt_brush(C) || !obedit || obedit->type != OB_MESH) return 0; em = BMEdit_FromObject(obedit); ret = EDBM_texFaceCheck(em); - if(ret && sima) { + if (ret && sima) { ARegion *ar= CTX_wm_region(C); - if((toolsettings->use_uv_sculpt) && ar->regiontype==RGN_TYPE_WINDOW) + if ((toolsettings->use_uv_sculpt) && ar->regiontype==RGN_TYPE_WINDOW) return 1; } @@ -4676,7 +4681,7 @@ static int uv_sculpt_brush_poll(bContext *C) static int image_paint_3d_poll(bContext *C) { - if(CTX_wm_region_view3d(C)) + if (CTX_wm_region_view3d(C)) return image_paint_poll(C); return 0; @@ -4686,9 +4691,9 @@ static int image_paint_2d_clone_poll(bContext *C) { Brush *brush= image_paint_brush(C); - if(!CTX_wm_region_view3d(C) && image_paint_poll(C)) - if(brush && (brush->imagepaint_tool == PAINT_TOOL_CLONE)) - if(brush->clone.image) + if (!CTX_wm_region_view3d(C) && image_paint_poll(C)) + if (brush && (brush->imagepaint_tool == PAINT_TOOL_CLONE)) + if (brush->clone.image) return 1; return 0; @@ -4723,15 +4728,15 @@ typedef struct PaintOperation { static void paint_redraw(bContext *C, ImagePaintState *s, int final) { - if(final) { - if(s->image) + if (final) { + if (s->image) GPU_free_image(s->image); /* compositor listener deals with updating */ WM_event_add_notifier(C, NC_IMAGE|NA_EDITED, s->image); } else { - if(!s->sima || !s->sima->lock) + if (!s->sima || !s->sima->lock) ED_region_tag_redraw(CTX_wm_region(C)); else WM_event_add_notifier(C, NC_IMAGE|NA_EDITED, s->image); @@ -4779,7 +4784,7 @@ static void project_state_init(bContext *C, Object *ob, ProjPaintState *ps) ps->seam_bleed_px = settings->imapaint.seam_bleed; /* pixel num to bleed */ #endif - if(ps->do_mask_normal) { + if (ps->do_mask_normal) { ps->normal_angle_inner = settings->imapaint.normal_angle; ps->normal_angle = (ps->normal_angle_inner + 90.0f) * 0.5f; } @@ -4791,16 +4796,16 @@ static void project_state_init(bContext *C, Object *ob, ProjPaintState *ps) ps->normal_angle *= (float)(M_PI_2 / 90); ps->normal_angle_range = ps->normal_angle - ps->normal_angle_inner; - if(ps->normal_angle_range <= 0.0f) + if (ps->normal_angle_range <= 0.0f) ps->do_mask_normal = 0; /* no need to do blending */ } static void paint_brush_init_tex(Brush *brush) { /* init mtex nodes */ - if(brush) { + if (brush) { MTex *mtex= &brush->mtex; - if(mtex->tex && mtex->tex->nodetree) + if (mtex->tex && mtex->tex->nodetree) ntreeTexBeginExecTree(mtex->tex->nodetree, 1); /* has internal flag to detect it only does it once */ } @@ -4818,16 +4823,16 @@ static int texture_paint_init(bContext *C, wmOperator *op) /* XXX: Soften tool does not support projection painting atm, so just disable * projection for this brush */ - if(brush->imagepaint_tool == PAINT_TOOL_SOFTEN) { + if (brush->imagepaint_tool == PAINT_TOOL_SOFTEN) { settings->imapaint.flag |= IMAGEPAINT_PROJECT_DISABLE; pop->restore_projection = 1; } /* initialize from context */ - if(CTX_wm_region_view3d(C)) { + if (CTX_wm_region_view3d(C)) { pop->mode= PAINT_MODE_3D; - if(!(settings->imapaint.flag & IMAGEPAINT_PROJECT_DISABLE)) + if (!(settings->imapaint.flag & IMAGEPAINT_PROJECT_DISABLE)) pop->mode= PAINT_MODE_3D_PROJECT; else view3d_set_viewcontext(C, &pop->vc); @@ -4842,12 +4847,12 @@ static int texture_paint_init(bContext *C, wmOperator *op) pop->s.brush = brush; pop->s.tool = brush->imagepaint_tool; - if(pop->mode == PAINT_MODE_3D && (pop->s.tool == PAINT_TOOL_CLONE)) + if (pop->mode == PAINT_MODE_3D && (pop->s.tool == PAINT_TOOL_CLONE)) pop->s.tool = PAINT_TOOL_DRAW; pop->s.blend = brush->blend; pop->orig_brush_size= brush_size(scene, brush); - if(pop->mode != PAINT_MODE_2D) { + if (pop->mode != PAINT_MODE_2D) { pop->s.ob = OBACT; pop->s.me = get_mesh(pop->s.ob); if (!pop->s.me) return 0; @@ -4855,10 +4860,10 @@ static int texture_paint_init(bContext *C, wmOperator *op) else { pop->s.image = pop->s.sima->image; - if(!imapaint_canvas_set(&pop->s, pop->s.image)) { - if(pop->s.warnmultifile) + if (!imapaint_canvas_set(&pop->s, pop->s.image)) { + if (pop->s.warnmultifile) BKE_report(op->reports, RPT_WARNING, "Image requires 4 color channels to paint"); - if(pop->s.warnpackedfile) + if (pop->s.warnpackedfile) BKE_report(op->reports, RPT_WARNING, "Packed MultiLayer files cannot be painted"); return 0; @@ -4868,7 +4873,7 @@ static int texture_paint_init(bContext *C, wmOperator *op) paint_brush_init_tex(pop->s.brush); /* note, if we have no UVs on the derived mesh, then we must return here */ - if(pop->mode == PAINT_MODE_3D_PROJECT) { + if (pop->mode == PAINT_MODE_3D_PROJECT) { /* initialize all data from the context */ project_state_init(C, OBACT, &pop->ps); @@ -4887,7 +4892,7 @@ static int texture_paint_init(bContext *C, wmOperator *op) /* allocate and initialize spacial data structures */ project_paint_begin(&pop->ps); - if(pop->ps.dm==NULL) + if (pop->ps.dm==NULL) return 0; } @@ -4914,13 +4919,13 @@ static void paint_apply(bContext *C, wmOperator *op, PointerRNA *itemptr) time= RNA_float_get(itemptr, "time"); pressure= RNA_float_get(itemptr, "pressure"); - if(pop->first) + if (pop->first) project_paint_begin_clone(&pop->ps, mouse); - if(pop->mode == PAINT_MODE_3D) + if (pop->mode == PAINT_MODE_3D) view3d_operator_needs_opengl(C); - if(pop->mode == PAINT_MODE_3D_PROJECT) { + if (pop->mode == PAINT_MODE_3D_PROJECT) { redraw= project_paint_stroke(&pop->ps, pop->painter, pop->prevmouse, mouse, time, pressure); pop->prevmouse[0]= mouse[0]; pop->prevmouse[1]= mouse[1]; @@ -4932,7 +4937,7 @@ static void paint_apply(bContext *C, wmOperator *op, PointerRNA *itemptr) pop->prevmouse[1]= mouse[1]; } - if(redraw) + if (redraw) paint_redraw(C, &pop->s, 0); pop->first= 0; @@ -4940,9 +4945,9 @@ static void paint_apply(bContext *C, wmOperator *op, PointerRNA *itemptr) static void paint_brush_exit_tex(Brush *brush) { - if(brush) { + if (brush) { MTex *mtex= &brush->mtex; - if(mtex->tex && mtex->tex->nodetree) + if (mtex->tex && mtex->tex->nodetree) ntreeTexEndExecTree(mtex->tex->nodetree->execdata, 1); } } @@ -4953,10 +4958,10 @@ static void paint_exit(bContext *C, wmOperator *op) ToolSettings *settings= scene->toolsettings; PaintOperation *pop= op->customdata; - if(pop->timer) + if (pop->timer) WM_event_remove_timer(CTX_wm_manager(C), CTX_wm_window(C), pop->timer); - if(pop->restore_projection) + if (pop->restore_projection) settings->imapaint.flag &= ~IMAGEPAINT_PROJECT_DISABLE; paint_brush_exit_tex(pop->s.brush); @@ -4965,7 +4970,7 @@ static void paint_exit(bContext *C, wmOperator *op) imapaint_canvas_free(&pop->s); brush_painter_free(pop->painter); - if(pop->mode == PAINT_MODE_3D_PROJECT) { + if (pop->mode == PAINT_MODE_3D_PROJECT) { brush_set_size(scene, pop->ps.brush, pop->orig_brush_size); paint_brush_exit_tex(pop->ps.brush); @@ -4975,9 +4980,9 @@ static void paint_exit(bContext *C, wmOperator *op) paint_redraw(C, &pop->s, 1); undo_paint_push_end(UNDO_PAINT_IMAGE); - if(pop->s.warnmultifile) + if (pop->s.warnmultifile) BKE_reportf(op->reports, RPT_WARNING, "Image requires 4 color channels to paint: %s", pop->s.warnmultifile); - if(pop->s.warnpackedfile) + if (pop->s.warnpackedfile) BKE_reportf(op->reports, RPT_WARNING, "Packed MultiLayer files cannot be painted: %s", pop->s.warnpackedfile); MEM_freeN(pop); @@ -4985,7 +4990,7 @@ static void paint_exit(bContext *C, wmOperator *op) static int paint_exec(bContext *C, wmOperator *op) { - if(!texture_paint_init(C, op)) { + if (!texture_paint_init(C, op)) { MEM_freeN(op->customdata); return OPERATOR_CANCELLED; } @@ -5015,19 +5020,19 @@ static void paint_apply_event(bContext *C, wmOperator *op, wmEvent *event) tablet= 0; pop->s.blend= pop->s.brush->blend; - if(event->custom == EVT_DATA_TABLET) { + if (event->custom == EVT_DATA_TABLET) { wmtab= event->customdata; tablet= (wmtab->Active != EVT_TABLET_NONE); pressure= wmtab->Pressure; - if(wmtab->Active == EVT_TABLET_ERASER) + if (wmtab->Active == EVT_TABLET_ERASER) pop->s.blend= IMB_BLEND_ERASE_ALPHA; } else { /* otherwise airbrush becomes 1.0 pressure instantly */ pressure= pop->prev_pressure ? pop->prev_pressure : 1.0f; } - if(pop->first) { + if (pop->first) { pop->prevmouse[0]= event->mval[0]; pop->prevmouse[1]= event->mval[1]; pop->starttime= time; @@ -5064,7 +5069,7 @@ static int paint_invoke(bContext *C, wmOperator *op, wmEvent *event) { PaintOperation *pop; - if(!texture_paint_init(C, op)) { + if (!texture_paint_init(C, op)) { MEM_freeN(op->customdata); return OPERATOR_CANCELLED; } @@ -5074,7 +5079,7 @@ static int paint_invoke(bContext *C, wmOperator *op, wmEvent *event) pop= op->customdata; WM_event_add_modal_handler(C, op); - if(pop->s.brush->flag & BRUSH_AIRBRUSH) + if (pop->s.brush->flag & BRUSH_AIRBRUSH) pop->timer= WM_event_add_timer(CTX_wm_manager(C), CTX_wm_window(C), TIMER, 0.01f); return OPERATOR_RUNNING_MODAL; @@ -5095,7 +5100,7 @@ static int paint_modal(bContext *C, wmOperator *op, wmEvent *event) paint_apply_event(C, op, event); break; case TIMER: - if(event->customdata == pop->timer) + if (event->customdata == pop->timer) paint_apply_event(C, op, event); break; } @@ -5134,7 +5139,7 @@ int get_imapaint_zoom(bContext *C, float *zoomx, float *zoomy) { RegionView3D *rv3d= CTX_wm_region_view3d(C); - if(!rv3d) { + if (!rv3d) { SpaceImage *sima= CTX_wm_space_image(C); ARegion *ar= CTX_wm_region(C); @@ -5160,7 +5165,7 @@ static void brush_drawcursor(bContext *C, int x, int y, void *UNUSED(customdata) Paint *paint= paint_get_active(scene); Brush *brush= paint_brush(paint); - if(paint && brush && paint->flags & PAINT_SHOW_BRUSH) { + if (paint && brush && paint->flags & PAINT_SHOW_BRUSH) { ToolSettings *ts; float zoomx, zoomy; const float size= (float)brush_size(scene, brush); @@ -5172,7 +5177,7 @@ static void brush_drawcursor(bContext *C, int x, int y, void *UNUSED(customdata) use_zoom= get_imapaint_zoom(C, &zoomx, &zoomy) && !(ts->use_uv_sculpt && (scene->basact->object->mode == OB_MODE_EDIT)); - if(use_zoom){ + if (use_zoom) { pixel_size = MAX2(size * zoomx, size * zoomy); } else { @@ -5180,7 +5185,7 @@ static void brush_drawcursor(bContext *C, int x, int y, void *UNUSED(customdata) } /* fade out the brush (cheap trick to work around brush interfearing with sampling [#])*/ - if(pixel_size < PX_SIZE_FADE_MIN) { + if (pixel_size < PX_SIZE_FADE_MIN) { return; } else if (pixel_size < PX_SIZE_FADE_MAX) { @@ -5192,7 +5197,7 @@ static void brush_drawcursor(bContext *C, int x, int y, void *UNUSED(customdata) glTranslatef((float)x, (float)y, 0.0f); /* No need to scale for uv sculpting, on the contrary it might be useful to keep unscaled */ - if(use_zoom) + if (use_zoom) glScalef(zoomx, zoomy, 1.0f); glColor4f(brush->add_col[0], brush->add_col[1], brush->add_col[2], alpha); @@ -5214,11 +5219,11 @@ static void toggle_paint_cursor(bContext *C, int enable) Scene *scene = CTX_data_scene(C); ToolSettings *settings= scene->toolsettings; - if(settings->imapaint.paintcursor && !enable) { + if (settings->imapaint.paintcursor && !enable) { WM_paint_cursor_end(wm, settings->imapaint.paintcursor); settings->imapaint.paintcursor = NULL; } - else if(enable) + else if (enable) settings->imapaint.paintcursor= WM_paint_cursor_activate(wm, image_paint_poll, brush_drawcursor, NULL); } @@ -5231,7 +5236,7 @@ void ED_space_image_paint_update(wmWindowManager *wm, ToolSettings *settings) { ImagePaintSettings *imapaint = &settings->imapaint; - if(!imapaint->paintcursor) { + if (!imapaint->paintcursor) { imapaint->paintcursor = WM_paint_cursor_activate(wm, image_paint_poll, brush_drawcursor, NULL); @@ -5241,8 +5246,8 @@ void ED_space_image_paint_update(wmWindowManager *wm, ToolSettings *settings) void ED_space_image_uv_sculpt_update(wmWindowManager *wm, ToolSettings *settings) { - if(settings->use_uv_sculpt) { - if(!settings->uvsculpt) { + if (settings->use_uv_sculpt) { + if (!settings->uvsculpt) { settings->uvsculpt = MEM_callocN(sizeof(*settings->uvsculpt), "UV Smooth paint"); settings->uv_sculpt_tool = UV_SCULPT_TOOL_GRAB; settings->uv_sculpt_settings = UV_SCULPT_LOCK_BORDERS | UV_SCULPT_ALL_ISLANDS; @@ -5255,7 +5260,7 @@ void ED_space_image_uv_sculpt_update(wmWindowManager *wm, ToolSettings *settings brush_drawcursor, NULL); } else { - if(settings->uvsculpt) + if (settings->uvsculpt) settings->uvsculpt->paint.flags &= ~PAINT_SHOW_BRUSH; } } @@ -5402,12 +5407,12 @@ static int sample_color_modal(bContext *C, wmOperator *op, wmEvent *event) /* same as image_paint_poll but fail when face mask mode is enabled */ static int image_paint_sample_color_poll(bContext *C) { - if(image_paint_poll(C)) { - if(CTX_wm_view3d(C)) { + if (image_paint_poll(C)) { + if (CTX_wm_view3d(C)) { Object *obact = CTX_data_active_object(C); if (obact && obact->mode & OB_MODE_TEXTURE_PAINT) { Mesh *me= get_mesh(obact); - if(me) { + if (me) { return !(me->editflag & ME_EDIT_PAINT_MASK); } } @@ -5462,7 +5467,7 @@ static int set_clone_cursor_invoke(bContext *C, wmOperator *op, wmEvent *event) view3d_operator_needs_opengl(C); - if(!ED_view3d_autodist(scene, ar, v3d, event->mval, location)) + if (!ED_view3d_autodist(scene, ar, v3d, event->mval, location)) return OPERATOR_CANCELLED; RNA_float_set_array(op->ptr, "location", location); @@ -5492,9 +5497,9 @@ void PAINT_OT_clone_cursor_set(wmOperatorType *ot) static int texture_paint_toggle_poll(bContext *C) { - if(CTX_data_edit_object(C)) + if (CTX_data_edit_object(C)) return 0; - if(CTX_data_active_object(C)==NULL) + if (CTX_data_active_object(C)==NULL) return 0; return 1; @@ -5506,7 +5511,7 @@ static int texture_paint_toggle_exec(bContext *C, wmOperator *op) Object *ob= CTX_data_active_object(C); Mesh *me= NULL; - if(ob==NULL) + if (ob==NULL) return OPERATOR_CANCELLED; if (object_data_is_libdata(ob)) { @@ -5516,15 +5521,15 @@ static int texture_paint_toggle_exec(bContext *C, wmOperator *op) me= get_mesh(ob); - if(!(ob->mode & OB_MODE_TEXTURE_PAINT) && !me) { + if (!(ob->mode & OB_MODE_TEXTURE_PAINT) && !me) { BKE_report(op->reports, RPT_ERROR, "Can only enter texture paint mode for mesh objects"); return OPERATOR_CANCELLED; } - if(ob->mode & OB_MODE_TEXTURE_PAINT) { + if (ob->mode & OB_MODE_TEXTURE_PAINT) { ob->mode &= ~OB_MODE_TEXTURE_PAINT; - if(U.glreslimit != 0) + if (U.glreslimit != 0) GPU_free_images(); GPU_paint_set_mipmap(1); @@ -5533,13 +5538,13 @@ static int texture_paint_toggle_exec(bContext *C, wmOperator *op) else { ob->mode |= OB_MODE_TEXTURE_PAINT; - if(me->mtface==NULL) + if (me->mtface==NULL) me->mtface= CustomData_add_layer(&me->fdata, CD_MTFACE, CD_DEFAULT, NULL, me->totface); paint_init(&scene->toolsettings->imapaint.paint, PAINT_CURSOR_TEXTURE_PAINT); - if(U.glreslimit != 0) + if (U.glreslimit != 0) GPU_free_images(); GPU_paint_set_mipmap(0); @@ -5568,8 +5573,8 @@ void PAINT_OT_texture_paint_toggle(wmOperatorType *ot) static int texture_paint_poll(bContext *C) { - if(texture_paint_toggle_poll(C)) - if(CTX_data_active_object(C)->mode & OB_MODE_TEXTURE_PAINT) + if (texture_paint_toggle_poll(C)) + if (CTX_data_active_object(C)->mode & OB_MODE_TEXTURE_PAINT) return 1; return 0; @@ -5611,12 +5616,12 @@ static int texture_paint_camera_project_exec(bContext *C, wmOperator *op) project_state_init(C, OBACT, &ps); - if(ps.ob==NULL || ps.ob->type != OB_MESH) { + if (ps.ob==NULL || ps.ob->type != OB_MESH) { BKE_report(op->reports, RPT_ERROR, "No active mesh object"); return OPERATOR_CANCELLED; } - if(image==NULL) { + if (image==NULL) { BKE_report(op->reports, RPT_ERROR, "Image could not be found"); return OPERATOR_CANCELLED; } @@ -5624,31 +5629,31 @@ static int texture_paint_camera_project_exec(bContext *C, wmOperator *op) ps.reproject_image= image; ps.reproject_ibuf= BKE_image_get_ibuf(image, NULL); - if(ps.reproject_ibuf==NULL || ps.reproject_ibuf->rect==NULL) { + if (ps.reproject_ibuf==NULL || ps.reproject_ibuf->rect==NULL) { BKE_report(op->reports, RPT_ERROR, "Image data could not be found"); return OPERATOR_CANCELLED; } idgroup= IDP_GetProperties(&image->id, 0); - if(idgroup) { + if (idgroup) { view_data= IDP_GetPropertyTypeFromGroup(idgroup, PROJ_VIEW_DATA_ID, IDP_ARRAY); /* type check to make sure its ok */ - if(view_data->len != PROJ_VIEW_DATA_SIZE || view_data->subtype != IDP_FLOAT) { + if (view_data->len != PROJ_VIEW_DATA_SIZE || view_data->subtype != IDP_FLOAT) { BKE_report(op->reports, RPT_ERROR, "Image project data invalid"); return OPERATOR_CANCELLED; } } - if(view_data) { + if (view_data) { /* image has stored view projection info */ ps.source= PROJ_SRC_IMAGE_VIEW; } else { ps.source= PROJ_SRC_IMAGE_CAM; - if(scene->camera==NULL) { + if (scene->camera==NULL) { BKE_report(op->reports, RPT_ERROR, "No active camera set"); return OPERATOR_CANCELLED; } @@ -5670,7 +5675,7 @@ static int texture_paint_camera_project_exec(bContext *C, wmOperator *op) /* allocate and initialize spacial data structures */ project_paint_begin(&ps); - if(ps.dm==NULL) { + if (ps.dm==NULL) { brush_set_size(scene, ps.brush, orig_brush_size); return OPERATOR_CANCELLED; } @@ -5738,11 +5743,11 @@ static int texture_paint_image_from_view_exec(bContext *C, wmOperator *op) glGetIntegerv(GL_MAX_TEXTURE_SIZE, &maxsize); - if(w > maxsize) w= maxsize; - if(h > maxsize) h= maxsize; + if (w > maxsize) w= maxsize; + if (h > maxsize) h= maxsize; ibuf= ED_view3d_draw_offscreen_imbuf(CTX_data_scene(C), CTX_wm_view3d(C), CTX_wm_region(C), w, h, IB_rect, FALSE, err_out); - if(!ibuf) { + if (!ibuf) { /* Mostly happens when OpenGL offscreen buffer was failed to create, */ /* but could be other reasons. Should be handled in the future. nazgul */ BKE_reportf(op->reports, RPT_ERROR, "Failed to create OpenGL offscreen buffer: %s", err_out); @@ -5751,7 +5756,7 @@ static int texture_paint_image_from_view_exec(bContext *C, wmOperator *op) image= BKE_add_image_imbuf(ibuf); - if(image) { + if (image) { /* now for the trickyness. store the view projection here! * re-projection will reuse this */ View3D *v3d= CTX_wm_view3d(C); diff --git a/source/blender/editors/sculpt_paint/paint_ops.c b/source/blender/editors/sculpt_paint/paint_ops.c index 86af3505f65..046a3b374ba 100644 --- a/source/blender/editors/sculpt_paint/paint_ops.c +++ b/source/blender/editors/sculpt_paint/paint_ops.c @@ -175,9 +175,9 @@ static int brush_reset_exec(bContext *C, wmOperator *UNUSED(op)) struct Brush *brush = paint_brush(paint); Object *ob = CTX_data_active_object(C); - if(!ob) return OPERATOR_CANCELLED; + if (!ob) return OPERATOR_CANCELLED; - if(ob->mode & OB_MODE_SCULPT) + if (ob->mode & OB_MODE_SCULPT) brush_reset_sculpt(brush); /* TODO: other modes */ @@ -208,15 +208,15 @@ static Brush *brush_tool_cycle(Main *bmain, Brush *brush_orig, const int tool, c { struct Brush *brush; - if(!brush_orig && !(brush_orig= bmain->brush.first)) { + if (!brush_orig && !(brush_orig= bmain->brush.first)) { return NULL; } /* get the next brush with the active tool */ - for(brush= brush_orig->id.next ? brush_orig->id.next : bmain->brush.first; + for (brush= brush_orig->id.next ? brush_orig->id.next : bmain->brush.first; brush != brush_orig; brush= brush->id.next ? brush->id.next : bmain->brush.first) { - if((brush->ob_mode & ob_mode) && + if ((brush->ob_mode & ob_mode) && (brush_tool(brush, tool_offset) == tool)) { return brush; } @@ -231,7 +231,7 @@ static int brush_generic_tool_set(Main *bmain, Paint *paint, const int tool, con brush= brush_tool_cycle(bmain, brush_orig, tool, tool_offset, ob_mode); - if(brush) { + if (brush) { paint_brush_set(paint, brush); WM_main_add_notifier(NC_BRUSH|NA_EDITED, brush); return OPERATOR_FINISHED; @@ -252,7 +252,7 @@ static int brush_select_exec(bContext *C, wmOperator *op) int tool, paint_mode= RNA_enum_get(op->ptr, "paint_mode"); size_t tool_offset; - if(paint_mode == OB_MODE_ACTIVE) { + if (paint_mode == OB_MODE_ACTIVE) { /* select current paint mode */ paint_mode = CTX_data_active_object(C)->mode & (OB_MODE_SCULPT| @@ -487,7 +487,7 @@ static void set_brush_rc_props(PointerRNA *ptr, const char *paint, brush_path = BLI_sprintfN("tool_settings.%s.brush", paint); set_brush_rc_path(ptr, brush_path, "data_path_primary", prop); - if(secondary_prop) { + if (secondary_prop) { set_brush_rc_path(ptr, ups_path, "use_secondary", secondary_prop); set_brush_rc_path(ptr, ups_path, "data_path_secondary", prop); } @@ -499,11 +499,11 @@ static void set_brush_rc_props(PointerRNA *ptr, const char *paint, set_brush_rc_path(ptr, brush_path, "rotation_path", "texture_slot.angle"); RNA_string_set(ptr, "image_id", brush_path); - if(flags & RC_COLOR) + if (flags & RC_COLOR) set_brush_rc_path(ptr, brush_path, "fill_color_path", "color"); else RNA_string_set(ptr, "fill_color_path", ""); - if(flags & RC_ZOOM) + if (flags & RC_ZOOM) RNA_string_set(ptr, "zoom_path", "space_data.zoom"); else RNA_string_set(ptr, "zoom_path", ""); @@ -522,7 +522,7 @@ static void ed_keymap_paint_brush_radial_control(wmKeyMap *keymap, const char *p kmi = WM_keymap_add_item(keymap, "WM_OT_radial_control", FKEY, KM_PRESS, KM_SHIFT, 0); set_brush_rc_props(kmi->ptr, paint, "strength", "use_unified_strength", flags); - if(flags & RC_ROTATION) { + if (flags & RC_ROTATION) { kmi = WM_keymap_add_item(keymap, "WM_OT_radial_control", FKEY, KM_PRESS, KM_CTRL, 0); set_brush_rc_props(kmi->ptr, paint, "texture_slot.angle", NULL, flags); } @@ -561,7 +561,7 @@ void ED_keymap_paint(wmKeyConfig *keyconf) /* Partial visibility, sculpt-only for now */ paint_partial_visibility_keys(keymap); - for(i=0; i<=5; i++) + for (i=0; i<=5; i++) RNA_int_set(WM_keymap_add_item(keymap, "OBJECT_OT_subdivision_set", ZEROKEY+i, KM_PRESS, KM_CTRL, 0)->ptr, "level", i); /* multires switch */ diff --git a/source/blender/editors/sculpt_paint/paint_stroke.c b/source/blender/editors/sculpt_paint/paint_stroke.c index d306abef9d0..28fee887cd8 100644 --- a/source/blender/editors/sculpt_paint/paint_stroke.c +++ b/source/blender/editors/sculpt_paint/paint_stroke.c @@ -95,7 +95,7 @@ static void paint_draw_smooth_stroke(bContext *C, int x, int y, void *customdata glEnable(GL_LINE_SMOOTH); glEnable(GL_BLEND); - if(stroke && brush && (brush->flag & BRUSH_SMOOTH_STROKE)) { + if (stroke && brush && (brush->flag & BRUSH_SMOOTH_STROKE)) { ARegion *ar = CTX_wm_region(C); sdrawline(x, y, (int)stroke->last_mouse_position[0] - ar->winrct.xmin, (int)stroke->last_mouse_position[1] - ar->winrct.ymin); @@ -112,14 +112,14 @@ static float event_tablet_data(wmEvent *event, int *pen_flip) int erasor = 0; float pressure = 1; - if(event->custom == EVT_DATA_TABLET) { + if (event->custom == EVT_DATA_TABLET) { wmTabletData *wmtab= event->customdata; erasor = (wmtab->Active == EVT_TABLET_ERASER); pressure = (wmtab->Active != EVT_TABLET_NONE) ? wmtab->Pressure : 1; } - if(pen_flip) + if (pen_flip) (*pen_flip) = erasor; return pressure; @@ -143,7 +143,7 @@ static void paint_brush_stroke_add_step(bContext *C, wmOperator *op, wmEvent *ev /* TODO: as sculpt and other paint modes are unified, this * separation will go away */ - if(stroke->vc.obact->sculpt) { + if (stroke->vc.obact->sculpt) { float delta[2]; brush_jitter_pos(scene, brush, mouse_in, mouse); @@ -151,7 +151,7 @@ static void paint_brush_stroke_add_step(bContext *C, wmOperator *op, wmEvent *ev /* XXX: meh, this is round about because * brush_jitter_pos isn't written in the best way to * be reused here */ - if(brush->flag & BRUSH_JITTER_PRESSURE) { + if (brush->flag & BRUSH_JITTER_PRESSURE) { sub_v2_v2v2(delta, mouse, mouse_in); mul_v2_fl(delta, pressure); add_v2_v2v2(mouse, mouse_in, delta); @@ -162,7 +162,7 @@ static void paint_brush_stroke_add_step(bContext *C, wmOperator *op, wmEvent *ev } /* TODO: can remove the if statement once all modes have this */ - if(stroke->get_location) + if (stroke->get_location) stroke->get_location(C, location, mouse); else zero_v3(location); @@ -197,7 +197,7 @@ static int paint_smooth_stroke(PaintStroke *stroke, float output[2], wmEvent *ev /* If the mouse is moving within the radius of the last move, * don't update the mouse position. This allows sharp turns. */ - if(dx*dx + dy*dy < stroke->brush->smooth_stroke_radius * stroke->brush->smooth_stroke_radius) + if (dx*dx + dy*dy < stroke->brush->smooth_stroke_radius * stroke->brush->smooth_stroke_radius) return 0; output[0] = event->x * v + stroke->last_mouse_position[0] * u; @@ -214,7 +214,7 @@ static int paint_space_stroke(bContext *C, wmOperator *op, wmEvent *event, const PaintStroke *stroke = op->customdata; int cnt = 0; - if(paint_space_stroke_enabled(stroke->brush)) { + if (paint_space_stroke_enabled(stroke->brush)) { float mouse[2]; float vec[2]; float length, scale; @@ -224,24 +224,24 @@ static int paint_space_stroke(bContext *C, wmOperator *op, wmEvent *event, const length = len_v2(vec); - if(length > FLT_EPSILON) { + if (length > FLT_EPSILON) { const Scene *scene = CTX_data_scene(C); int steps; int i; float pressure= 1.0f; /* XXX mysterious :) what has 'use size' do with this here... if you don't check for it, pressure fails */ - if(brush_use_size_pressure(scene, stroke->brush)) + if (brush_use_size_pressure(scene, stroke->brush)) pressure = event_tablet_data(event, NULL); - if(pressure > FLT_EPSILON) { + if (pressure > FLT_EPSILON) { scale = (brush_size(scene, stroke->brush)*pressure*stroke->brush->spacing/50.0f) / length; - if(scale > FLT_EPSILON) { + if (scale > FLT_EPSILON) { mul_v2_fl(vec, scale); steps = (int)(1.0f / scale); - for(i = 0; i < steps; ++i, ++cnt) { + for (i = 0; i < steps; ++i, ++cnt) { add_v2_v2(mouse, vec); paint_brush_stroke_add_step(C, op, event, mouse); } @@ -302,16 +302,16 @@ int paint_stroke_modal(bContext *C, wmOperator *op, wmEvent *event) if (event->type == NDOF_MOTION) return OPERATOR_PASS_THROUGH; - if(!stroke->stroke_started) { + if (!stroke->stroke_started) { stroke->last_mouse_position[0] = event->x; stroke->last_mouse_position[1] = event->y; stroke->stroke_started = stroke->test_start(C, op, event); - if(stroke->stroke_started) { + if (stroke->stroke_started) { stroke->smooth_stroke_cursor = WM_paint_cursor_activate(CTX_wm_manager(C), paint_poll, paint_draw_smooth_stroke, stroke); - if(stroke->brush->flag & BRUSH_AIRBRUSH) + if (stroke->brush->flag & BRUSH_AIRBRUSH) stroke->timer = WM_event_add_timer(CTX_wm_manager(C), CTX_wm_window(C), TIMER, stroke->brush->rate); } @@ -319,26 +319,26 @@ int paint_stroke_modal(bContext *C, wmOperator *op, wmEvent *event) //ED_region_tag_redraw(ar); } - if(event->type == stroke->event_type && event->val == KM_RELEASE) { + if (event->type == stroke->event_type && event->val == KM_RELEASE) { /* exit stroke, free data */ - if(stroke->smooth_stroke_cursor) + if (stroke->smooth_stroke_cursor) WM_paint_cursor_end(CTX_wm_manager(C), stroke->smooth_stroke_cursor); - if(stroke->timer) + if (stroke->timer) WM_event_remove_timer(CTX_wm_manager(C), CTX_wm_window(C), stroke->timer); stroke->done(C, stroke); MEM_freeN(stroke); return OPERATOR_FINISHED; } - else if( (first) || + else if ( (first) || (ELEM(event->type, MOUSEMOVE, INBETWEEN_MOUSEMOVE)) || (event->type == TIMER && (event->customdata == stroke->timer)) ) { - if(stroke->stroke_started) { - if(paint_smooth_stroke(stroke, mouse, event)) { - if(paint_space_stroke_enabled(stroke->brush)) { - if(!paint_space_stroke(C, op, event, mouse)) { + if (stroke->stroke_started) { + if (paint_smooth_stroke(stroke, mouse, event)) { + if (paint_space_stroke_enabled(stroke->brush)) { + if (!paint_space_stroke(C, op, event, mouse)) { //ED_region_tag_redraw(ar); } } @@ -354,7 +354,7 @@ int paint_stroke_modal(bContext *C, wmOperator *op, wmEvent *event) /* we want the stroke to have the first daub at the start location * instead of waiting till we have moved the space distance */ - if(first && + if (first && stroke->stroke_started && paint_space_stroke_enabled(stroke->brush) && !(stroke->brush->flag & BRUSH_ANCHORED) && @@ -371,7 +371,7 @@ int paint_stroke_exec(bContext *C, wmOperator *op) PaintStroke *stroke = op->customdata; /* only when executed for the first time */ - if(stroke->stroke_started == 0) { + if (stroke->stroke_started == 0) { /* XXX stroke->last_mouse_position is unset, this may cause problems */ stroke->test_start(C, op, NULL); stroke->stroke_started= 1; @@ -394,7 +394,7 @@ int paint_stroke_cancel(bContext *C, wmOperator *op) { PaintStroke *stroke = op->customdata; - if(stroke->done) + if (stroke->done) stroke->done(C, stroke); MEM_freeN(stroke); diff --git a/source/blender/editors/sculpt_paint/paint_undo.c b/source/blender/editors/sculpt_paint/paint_undo.c index b00910195ff..8406c8b20af 100644 --- a/source/blender/editors/sculpt_paint/paint_undo.c +++ b/source/blender/editors/sculpt_paint/paint_undo.c @@ -71,13 +71,13 @@ static UndoStack MeshUndoStack = {UNDO_PAINT_MESH, {NULL, NULL}, NULL}; static void undo_restore(bContext *C, UndoStack *UNUSED(stack), UndoElem *uel) { - if(uel && uel->restore) + if (uel && uel->restore) uel->restore(C, &uel->elems); } static void undo_elem_free(UndoStack *UNUSED(stack), UndoElem *uel) { - if(uel && uel->free) { + if (uel && uel->free) { uel->free(&uel->elems); BLI_freelistN(&uel->elems); } @@ -93,7 +93,7 @@ static void undo_stack_push_begin(UndoStack *stack, const char *name, UndoRestor * know how much memory the undo used to remove old undo elements */ /* remove all undos after (also when stack->current==NULL) */ - while(stack->elems.last != stack->current) { + while (stack->elems.last != stack->current) { uel= stack->elems.last; undo_elem_free(stack, uel); BLI_freelinkN(&stack->elems, uel); @@ -111,13 +111,13 @@ static void undo_stack_push_begin(UndoStack *stack, const char *name, UndoRestor /* limit amount to the maximum amount*/ nr= 0; uel= stack->elems.last; - while(uel) { + while (uel) { nr++; - if(nr==U.undosteps) break; + if (nr==U.undosteps) break; uel= uel->prev; } - if(uel) { - while(stack->elems.first!=uel) { + if (uel) { + while (stack->elems.first!=uel) { UndoElem *first= stack->elems.first; undo_elem_free(stack, first); BLI_freelinkN(&stack->elems, first); @@ -130,20 +130,20 @@ static void undo_stack_push_end(UndoStack *stack) UndoElem *uel; uintptr_t totmem, maxmem; - if(U.undomemory != 0) { + if (U.undomemory != 0) { /* limit to maximum memory (afterwards, we can't know in advance) */ totmem= 0; maxmem= ((uintptr_t)U.undomemory)*1024*1024; uel= stack->elems.last; - while(uel) { + while (uel) { totmem+= uel->undosize; - if(totmem>maxmem) break; + if (totmem>maxmem) break; uel= uel->prev; } - if(uel) { - while(stack->elems.first!=uel) { + if (uel) { + while (stack->elems.first!=uel) { UndoElem *first= stack->elems.first; undo_elem_free(stack, first); BLI_freelinkN(&stack->elems, first); @@ -156,25 +156,25 @@ static int undo_stack_step(bContext *C, UndoStack *stack, int step, const char * { UndoElem *undo; - if(step==1) { - if(stack->current==NULL); + if (step==1) { + if (stack->current==NULL); else { - if(!name || strcmp(stack->current->name, name) == 0) { - if(G.f & G_DEBUG) printf("undo %s\n", stack->current->name); + if (!name || strcmp(stack->current->name, name) == 0) { + if (G.f & G_DEBUG) printf("undo %s\n", stack->current->name); undo_restore(C, stack, stack->current); stack->current= stack->current->prev; return 1; } } } - else if(step==-1) { - if((stack->current!=NULL && stack->current->next==NULL) || stack->elems.first==NULL); + else if (step==-1) { + if ((stack->current!=NULL && stack->current->next==NULL) || stack->elems.first==NULL); else { - if(!name || strcmp(stack->current->name, name) == 0) { + if (!name || strcmp(stack->current->name, name) == 0) { undo= (stack->current && stack->current->next)? stack->current->next: stack->elems.first; undo_restore(C, stack, undo); stack->current= undo; - if(G.f & G_DEBUG) printf("redo %s\n", undo->name); + if (G.f & G_DEBUG) printf("redo %s\n", undo->name); return 1; } } @@ -187,7 +187,7 @@ static void undo_stack_free(UndoStack *stack) { UndoElem *uel; - for(uel=stack->elems.first; uel; uel=uel->next) + for (uel=stack->elems.first; uel; uel=uel->next) undo_elem_free(stack, uel); BLI_freelistN(&stack->elems); @@ -198,20 +198,20 @@ static void undo_stack_free(UndoStack *stack) void undo_paint_push_begin(int type, const char *name, UndoRestoreCb restore, UndoFreeCb free) { - if(type == UNDO_PAINT_IMAGE) + if (type == UNDO_PAINT_IMAGE) undo_stack_push_begin(&ImageUndoStack, name, restore, free); - else if(type == UNDO_PAINT_MESH) + else if (type == UNDO_PAINT_MESH) undo_stack_push_begin(&MeshUndoStack, name, restore, free); } ListBase *undo_paint_push_get_list(int type) { - if(type == UNDO_PAINT_IMAGE) { - if(ImageUndoStack.current) + if (type == UNDO_PAINT_IMAGE) { + if (ImageUndoStack.current) return &ImageUndoStack.current->elems; } - else if(type == UNDO_PAINT_MESH) { - if(MeshUndoStack.current) + else if (type == UNDO_PAINT_MESH) { + if (MeshUndoStack.current) return &MeshUndoStack.current->elems; } @@ -220,25 +220,25 @@ ListBase *undo_paint_push_get_list(int type) void undo_paint_push_count_alloc(int type, int size) { - if(type == UNDO_PAINT_IMAGE) + if (type == UNDO_PAINT_IMAGE) ImageUndoStack.current->undosize += size; - else if(type == UNDO_PAINT_MESH) + else if (type == UNDO_PAINT_MESH) MeshUndoStack.current->undosize += size; } void undo_paint_push_end(int type) { - if(type == UNDO_PAINT_IMAGE) + if (type == UNDO_PAINT_IMAGE) undo_stack_push_end(&ImageUndoStack); - else if(type == UNDO_PAINT_MESH) + else if (type == UNDO_PAINT_MESH) undo_stack_push_end(&MeshUndoStack); } int ED_undo_paint_step(bContext *C, int type, int step, const char *name) { - if(type == UNDO_PAINT_IMAGE) + if (type == UNDO_PAINT_IMAGE) return undo_stack_step(C, &ImageUndoStack, step, name); - else if(type == UNDO_PAINT_MESH) + else if (type == UNDO_PAINT_MESH) return undo_stack_step(C, &MeshUndoStack, step, name); return 0; @@ -248,16 +248,16 @@ int ED_undo_paint_valid(int type, const char *name) { UndoStack *stack; - if(type == UNDO_PAINT_IMAGE) + if (type == UNDO_PAINT_IMAGE) stack= &ImageUndoStack; - else if(type == UNDO_PAINT_MESH) + else if (type == UNDO_PAINT_MESH) stack= &MeshUndoStack; else return 0; - if(stack->current==NULL); + if (stack->current==NULL); else { - if(name && strcmp(stack->current->name, name) == 0) + if (name && strcmp(stack->current->name, name) == 0) return 1; else return stack->elems.first != stack->elems.last; diff --git a/source/blender/editors/sculpt_paint/paint_utils.c b/source/blender/editors/sculpt_paint/paint_utils.c index 3cd963c11df..3508f8e7f11 100644 --- a/source/blender/editors/sculpt_paint/paint_utils.c +++ b/source/blender/editors/sculpt_paint/paint_utils.c @@ -84,14 +84,14 @@ int paint_convert_bb_to_rect(rcti *rect, rect->xmax = rect->ymax = INT_MIN; /* return zero if the bounding box has non-positive volume */ - if(bb_min[0] > bb_max[0] || bb_min[1] > bb_max[1] || bb_min[2] > bb_max[2]) + if (bb_min[0] > bb_max[0] || bb_min[1] > bb_max[1] || bb_min[2] > bb_max[2]) return 0; ED_view3d_ob_project_mat_get(rv3d, ob, projection_mat); - for(i = 0; i < 2; ++i) { - for(j = 0; j < 2; ++j) { - for(k = 0; k < 2; ++k) { + for (i = 0; i < 2; ++i) { + for (j = 0; j < 2; ++j) { + for (k = 0; k < 2; ++k) { float vec[3], proj[2]; vec[0] = i ? bb_min[0] : bb_max[0]; vec[1] = j ? bb_min[1] : bb_max[1]; @@ -243,7 +243,7 @@ static void imapaint_tri_weights(Object *ob, /* w is still divided by perspdiv, make it sum to one */ divw= w[0] + w[1] + w[2]; - if(divw != 0.0f) { + if (divw != 0.0f) { mul_v3_fl(w, 1.0f/divw); } } @@ -263,16 +263,16 @@ void imapaint_pick_uv(Scene *scene, Object *ob, unsigned int faceindex, const in uv[0] = uv[1] = 0.0; /* test all faces in the derivedmesh with the original index of the picked face */ - for(a = 0; a < numfaces; a++) { + for (a = 0; a < numfaces; a++) { findex= index ? index[a]: a; - if(findex == faceindex) { + if (findex == faceindex) { dm->getTessFace(dm, a, &mf); dm->getVert(dm, mf.v1, &mv[0]); dm->getVert(dm, mf.v2, &mv[1]); dm->getVert(dm, mf.v3, &mv[2]); - if(mf.v4) + if (mf.v4) dm->getVert(dm, mf.v4, &mv[3]); tf= &tface[a]; @@ -280,12 +280,12 @@ void imapaint_pick_uv(Scene *scene, Object *ob, unsigned int faceindex, const in p[0]= xy[0]; p[1]= xy[1]; - if(mf.v4) { + if (mf.v4) { /* the triangle with the largest absolute values is the one * with the most negative weights */ imapaint_tri_weights(ob, mv[0].co, mv[1].co, mv[3].co, p, w); absw= fabs(w[0]) + fabs(w[1]) + fabs(w[2]); - if(absw < minabsw) { + if (absw < minabsw) { uv[0]= tf->uv[0][0]*w[0] + tf->uv[1][0]*w[1] + tf->uv[3][0]*w[2]; uv[1]= tf->uv[0][1]*w[0] + tf->uv[1][1]*w[1] + tf->uv[3][1]*w[2]; minabsw = absw; @@ -293,7 +293,7 @@ void imapaint_pick_uv(Scene *scene, Object *ob, unsigned int faceindex, const in imapaint_tri_weights(ob, mv[1].co, mv[2].co, mv[3].co, p, w); absw= fabs(w[0]) + fabs(w[1]) + fabs(w[2]); - if(absw < minabsw) { + if (absw < minabsw) { uv[0]= tf->uv[1][0]*w[0] + tf->uv[2][0]*w[1] + tf->uv[3][0]*w[2]; uv[1]= tf->uv[1][1]*w[0] + tf->uv[2][1]*w[1] + tf->uv[3][1]*w[2]; minabsw = absw; @@ -302,7 +302,7 @@ void imapaint_pick_uv(Scene *scene, Object *ob, unsigned int faceindex, const in else { imapaint_tri_weights(ob, mv[0].co, mv[1].co, mv[2].co, p, w); absw= fabs(w[0]) + fabs(w[1]) + fabs(w[2]); - if(absw < minabsw) { + if (absw < minabsw) { uv[0]= tf->uv[0][0]*w[0] + tf->uv[1][0]*w[1] + tf->uv[2][0]*w[2]; uv[1]= tf->uv[0][1]*w[0] + tf->uv[1][1]*w[1] + tf->uv[2][1]*w[2]; minabsw = absw; @@ -317,13 +317,13 @@ void imapaint_pick_uv(Scene *scene, Object *ob, unsigned int faceindex, const in ///* returns 0 if not found, otherwise 1 */ int imapaint_pick_face(ViewContext *vc, Mesh *me, const int mval[2], unsigned int *index) { - if(!me || me->totface==0) + if (!me || me->totface==0) return 0; /* sample only on the exact position */ *index = view3d_sample_backbuf(vc, mval[0], mval[1]); - if((*index)<=0 || (*index)>(unsigned int)me->totface) + if ((*index)<=0 || (*index)>(unsigned int)me->totface) return 0; (*index)--; @@ -347,7 +347,7 @@ void paint_sample_color(Scene *scene, ARegion *ar, int x, int y) /* frontbuf */ cp = (char *)&col; - if(br) { + if (br) { br->rgb[0]= cp[0]/255.0f; br->rgb[1]= cp[1]/255.0f; br->rgb[2]= cp[2]/255.0f; diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c b/source/blender/editors/sculpt_paint/paint_vertex.c index cb920e3f048..59c034f1cd1 100644 --- a/source/blender/editors/sculpt_paint/paint_vertex.c +++ b/source/blender/editors/sculpt_paint/paint_vertex.c @@ -129,12 +129,12 @@ int vertex_paint_mode_poll(bContext *C) int vertex_paint_poll(bContext *C) { - if(vertex_paint_mode_poll(C) && + if (vertex_paint_mode_poll(C) && paint_brush(&CTX_data_tool_settings(C)->vpaint->paint)) { ScrArea *sa= CTX_wm_area(C); - if(sa->spacetype==SPACE_VIEW3D) { + if (sa->spacetype==SPACE_VIEW3D) { ARegion *ar= CTX_wm_region(C); - if(ar->regiontype==RGN_TYPE_WINDOW) + if (ar->regiontype==RGN_TYPE_WINDOW) return 1; } } @@ -153,14 +153,14 @@ int weight_paint_poll(bContext *C) Object *ob= CTX_data_active_object(C); ScrArea *sa; - if( (ob != NULL) && + if ( (ob != NULL) && (ob->mode & OB_MODE_WEIGHT_PAINT) && (paint_brush(&CTX_data_tool_settings(C)->wpaint->paint) != NULL) && (sa= CTX_wm_area(C)) && (sa->spacetype == SPACE_VIEW3D) ) { ARegion *ar= CTX_wm_region(C); - if(ar->regiontype==RGN_TYPE_WINDOW) { + if (ar->regiontype==RGN_TYPE_WINDOW) { return 1; } } @@ -173,7 +173,7 @@ static VPaint *new_vpaint(int wpaint) vp->flag= VP_AREA+VP_SPRAY; - if(wpaint) + if (wpaint) vp->flag= VP_AREA; return vp; @@ -203,33 +203,33 @@ static void do_shared_vertex_tesscol(Mesh *me) short *scolmain, *scol; char *mcol; - if(me->mcol==NULL || me->totvert==0 || me->totface==0) return; + if (me->mcol==NULL || me->totvert==0 || me->totface==0) return; scolmain= MEM_callocN(4*sizeof(short)*me->totvert, "colmain"); tface= me->mtface; mface= me->mface; mcol= (char *)me->mcol; - for(a=me->totface; a>0; a--, mface++, mcol+=16) { - if((tface && tface->mode & TF_SHAREDCOL) || (me->editflag & ME_EDIT_PAINT_MASK)==0) { + for (a=me->totface; a>0; a--, mface++, mcol+=16) { + if ((tface && tface->mode & TF_SHAREDCOL) || (me->editflag & ME_EDIT_PAINT_MASK)==0) { scol= scolmain+4*mface->v1; scol[0]++; scol[1]+= mcol[1]; scol[2]+= mcol[2]; scol[3]+= mcol[3]; scol= scolmain+4*mface->v2; scol[0]++; scol[1]+= mcol[5]; scol[2]+= mcol[6]; scol[3]+= mcol[7]; scol= scolmain+4*mface->v3; scol[0]++; scol[1]+= mcol[9]; scol[2]+= mcol[10]; scol[3]+= mcol[11]; - if(mface->v4) { + if (mface->v4) { scol= scolmain+4*mface->v4; scol[0]++; scol[1]+= mcol[13]; scol[2]+= mcol[14]; scol[3]+= mcol[15]; } } - if(tface) tface++; + if (tface) tface++; } a= me->totvert; scol= scolmain; - while(a--) { - if(scol[0]>1) { + while (a--) { + if (scol[0]>1) { scol[1]/= scol[0]; scol[2]/= scol[0]; scol[3]/= scol[0]; @@ -240,20 +240,20 @@ static void do_shared_vertex_tesscol(Mesh *me) tface= me->mtface; mface= me->mface; mcol= (char *)me->mcol; - for(a=me->totface; a>0; a--, mface++, mcol+=16) { - if((tface && tface->mode & TF_SHAREDCOL) || (me->editflag & ME_EDIT_PAINT_MASK)==0) { + for (a=me->totface; a>0; a--, mface++, mcol+=16) { + if ((tface && tface->mode & TF_SHAREDCOL) || (me->editflag & ME_EDIT_PAINT_MASK)==0) { scol= scolmain+4*mface->v1; mcol[1]= scol[1]; mcol[2]= scol[2]; mcol[3]= scol[3]; scol= scolmain+4*mface->v2; mcol[5]= scol[1]; mcol[6]= scol[2]; mcol[7]= scol[3]; scol= scolmain+4*mface->v3; mcol[9]= scol[1]; mcol[10]= scol[2]; mcol[11]= scol[3]; - if(mface->v4) { + if (mface->v4) { scol= scolmain+4*mface->v4; mcol[13]= scol[1]; mcol[14]= scol[2]; mcol[15]= scol[3]; } } - if(tface) tface++; + if (tface) tface++; } MEM_freeN(scolmain); @@ -271,7 +271,7 @@ void do_shared_vertexcol(Mesh *me, int do_tessface) /* if no mloopcol: do not do */ /* if mtexpoly: only the involved faces, otherwise all */ - if(me->mloopcol==0 || me->totvert==0 || me->totpoly==0) return; + if (me->mloopcol==0 || me->totvert==0 || me->totpoly==0) return; scol = MEM_callocN(sizeof(float)*me->totvert*5, "scol"); @@ -324,14 +324,14 @@ void do_shared_vertexcol(Mesh *me, int do_tessface) static void make_vertexcol(Object *ob) /* single ob */ { Mesh *me; - if(!ob || ob->id.lib) return; + if (!ob || ob->id.lib) return; me= get_mesh(ob); - if(me==NULL) return; - if(me->edit_btmesh) return; + if (me==NULL) return; + if (me->edit_btmesh) return; /* copies from shadedisplist to mcol */ if (!me->mloopcol) { - if(!me->mcol) { + if (!me->mcol) { CustomData_add_layer(&me->fdata, CD_MCOL, CD_DEFAULT, NULL, me->totface); } if (!me->mloopcol) { @@ -372,21 +372,21 @@ static int wpaint_mirror_vgroup_ensure(Object *ob, const int vgroup_active) { bDeformGroup *defgroup= BLI_findlink(&ob->defbase, vgroup_active); - if(defgroup) { + if (defgroup) { bDeformGroup *curdef; int mirrdef; char name[MAXBONENAME]; flip_side_name(name, defgroup->name, FALSE); - if(strcmp(name, defgroup->name) != 0) { + if (strcmp(name, defgroup->name) != 0) { for (curdef= ob->defbase.first, mirrdef= 0; curdef; curdef=curdef->next, mirrdef++) { if (!strcmp(curdef->name, name)) { break; } } - if(curdef==NULL) { + if (curdef==NULL) { int olddef= ob->actdef; /* tsk, ED_vgroup_add sets the active defgroup */ curdef= ED_vgroup_add_name(ob, name); ob->actdef= olddef; @@ -394,7 +394,7 @@ static int wpaint_mirror_vgroup_ensure(Object *ob, const int vgroup_active) /* curdef should never be NULL unless this is * a lamp and ED_vgroup_add_name fails */ - if(curdef) { + if (curdef) { return mirrdef; } } @@ -405,13 +405,13 @@ static int wpaint_mirror_vgroup_ensure(Object *ob, const int vgroup_active) static void copy_vpaint_prev(VPaint *vp, unsigned int *lcol, int tot) { - if(vp->vpaint_prev) { + if (vp->vpaint_prev) { MEM_freeN(vp->vpaint_prev); vp->vpaint_prev= NULL; } vp->tot= tot; - if(lcol==NULL || tot==0) return; + if (lcol==NULL || tot==0) return; vp->vpaint_prev= MEM_mallocN(sizeof(int)*tot, "vpaint_prev"); memcpy(vp->vpaint_prev, lcol, sizeof(int)*tot); @@ -425,7 +425,7 @@ static void copy_wpaint_prev (VPaint *wp, MDeformVert *dverts, int dcount) wp->wpaint_prev= NULL; } - if(dverts && dcount) { + if (dverts && dcount) { wp->wpaint_prev = MEM_mallocN (sizeof(MDeformVert)*dcount, "wpaint prev"); wp->tot = dcount; @@ -442,10 +442,10 @@ void vpaint_fill(Object *ob, unsigned int paintcol) int i, j, selected; me= get_mesh(ob); - if(me==NULL || me->totpoly==0) return; + if (me==NULL || me->totpoly==0) return; - if(!me->mloopcol) make_vertexcol(ob); - if(!me->mloopcol) return; /* possible we can't make mcol's */ + if (!me->mloopcol) make_vertexcol(ob); + if (!me->mloopcol) return; /* possible we can't make mcol's */ selected= (me->editflag & ME_EDIT_PAINT_MASK); @@ -480,18 +480,18 @@ void wpaint_fill(VPaint *wp, Object *ob, float paintweight) /* mutually exclusive, could be made into a */ const short paint_selmode= ME_EDIT_PAINT_SEL_MODE(me); - if(me->totpoly==0 || me->dvert==NULL || !me->mpoly) return; + if (me->totpoly==0 || me->dvert==NULL || !me->mpoly) return; vgroup_active = ob->actdef - 1; /* if mirror painting, find the other group */ - if(me->editflag & ME_EDIT_MIRROR_X) { + if (me->editflag & ME_EDIT_MIRROR_X) { vgroup_mirror= wpaint_mirror_vgroup_ensure(ob, vgroup_active); } copy_wpaint_prev(wp, me->dvert, me->totvert); - for(index=0, mf= me->mpoly; index < me->totpoly; index++, mf++) { + for (index=0, mf= me->mpoly; index < me->totpoly; index++, mf++) { unsigned int fidx= mf->totloop - 1; if ((paint_selmode == SCE_SELECT_FACE) && !(mf->flag & ME_FACE_SEL)) { @@ -501,25 +501,26 @@ void wpaint_fill(VPaint *wp, Object *ob, float paintweight) do { unsigned int vidx= me->mloop[mf->loopstart + fidx].v; - if(!me->dvert[vidx].flag) { - if((paint_selmode == SCE_SELECT_VERTEX) && !(me->mvert[vidx].flag & SELECT)) { + if (!me->dvert[vidx].flag) { + if ((paint_selmode == SCE_SELECT_VERTEX) && !(me->mvert[vidx].flag & SELECT)) { continue; } dw= defvert_verify_index(&me->dvert[vidx], vgroup_active); - if(dw) { + if (dw) { dw_prev= defvert_verify_index(wp->wpaint_prev+vidx, vgroup_active); dw_prev->weight= dw->weight; /* set the undo weight */ dw->weight= paintweight; - if(me->editflag & ME_EDIT_MIRROR_X) { /* x mirror painting */ + if (me->editflag & ME_EDIT_MIRROR_X) { /* x mirror painting */ int j= mesh_get_x_mirror_vert(ob, vidx); - if(j>=0) { + if (j>=0) { /* copy, not paint again */ - if(vgroup_mirror != -1) { + if (vgroup_mirror != -1) { dw= defvert_verify_index(me->dvert+j, vgroup_mirror); dw_prev= defvert_verify_index(wp->wpaint_prev+j, vgroup_mirror); - } else { + } + else { dw= defvert_verify_index(me->dvert+j, vgroup_active); dw_prev= defvert_verify_index(wp->wpaint_prev+j, vgroup_active); } @@ -536,7 +537,7 @@ void wpaint_fill(VPaint *wp, Object *ob, float paintweight) { MDeformVert *dv= me->dvert; - for(index= me->totvert; index != 0; index--, dv++) { + for (index= me->totvert; index != 0; index--, dv++) { dv->flag= 0; } } @@ -560,25 +561,25 @@ void vpaint_dogamma(Scene *scene) ob= OBACT; me= get_mesh(ob); - if(!(ob->mode & OB_MODE_VERTEX_PAINT)) return; - if(me==0 || me->mcol==0 || me->totface==0) return; + if (!(ob->mode & OB_MODE_VERTEX_PAINT)) return; + if (me==0 || me->mcol==0 || me->totface==0) return; igam= 1.0/vp->gamma; - for(a=0; a<256; a++) { + for (a=0; a<256; a++) { fac= ((float)a)/255.0; fac= vp->mul*pow( fac, igam); temp= 255.9*fac; - if(temp<=0) gamtab[a]= 0; - else if(temp>=255) gamtab[a]= 255; + if (temp<=0) gamtab[a]= 0; + else if (temp>=255) gamtab[a]= 255; else gamtab[a]= temp; } a= 4*me->totface; cp= (unsigned char *)me->mcol; - while(a--) { + while (a--) { cp[1]= gamtab[ cp[1] ]; cp[2]= gamtab[ cp[2] ]; @@ -787,7 +788,7 @@ static unsigned int vpaint_blend(VPaint *vp, unsigned int col, unsigned int colo col = vpaint_blend_tool(tool, col, paintcol, alpha_i); /* if no spray, clip color adding with colorig & orig alpha */ - if((vp->flag & VP_SPRAY)==0) { + if ((vp->flag & VP_SPRAY)==0) { unsigned int testcol, a; char *cp, *ct, *co; @@ -797,14 +798,14 @@ static unsigned int vpaint_blend(VPaint *vp, unsigned int col, unsigned int colo ct= (char *)&testcol; co= (char *)&colorig; - for(a=0; a<4; a++) { - if( ct[a]co[a] ) cp[a]= co[a]; + for (a=0; a<4; a++) { + if ( ct[a]co[a] ) cp[a]= co[a]; } else { - if( cp[a]ct[a] ) cp[a]= ct[a]; + if ( cp[a]ct[a] ) cp[a]= ct[a]; } } } @@ -823,25 +824,25 @@ static int sample_backbuf_area(ViewContext *vc, int *indexar, int totface, int x /*if(size>64.0) size= 64.0;*/ ibuf= view3d_read_backbuf(vc, x-size, y-size, x+size, y+size); - if(ibuf) { + if (ibuf) { unsigned int *rt= ibuf->rect; memset(indexar, 0, sizeof(int)*(totface+1)); size= ibuf->x*ibuf->y; - while(size--) { + while (size--) { - if(*rt) { + if (*rt) { index= WM_framebuffer_to_index(*rt); - if(index>0 && index<=totface) + if (index>0 && index<=totface) indexar[index] = 1; } rt++; } - for(a=1; a<=totface; a++) { - if(indexar[a]) indexar[tot++]= a; + for (a=1; a<=totface; a++) { + if (indexar[a]) indexar[tot++]= a; } IMB_freeImBuf(ibuf); @@ -880,7 +881,7 @@ static float calc_vp_alpha_dl(VPaint *vp, ViewContext *vc, if (strength > 0.0f) { float alpha= brush_alpha_pressure * strength; - if(vp->flag & VP_NORMALS) { + if (vp->flag & VP_NORMALS) { float dvec[3]; const float *no= vert_nor + 3; @@ -978,19 +979,19 @@ static float wpaint_blend(VPaint *wp, float weight, float weight_prev, weight = wpaint_blend_tool(tool, weight, paintval, alpha); /* delay clamping until the end so multi-paint can function when the active group is at the limits */ - if(do_multipaint_totsel == FALSE) { + if (do_multipaint_totsel == FALSE) { CLAMP(weight, 0.0f, 1.0f); } /* if no spray, clip result with orig weight & orig alpha */ if ((wp->flag & VP_SPRAY) == 0) { - if(do_multipaint_totsel == FALSE) { + if (do_multipaint_totsel == FALSE) { float testw = wpaint_blend_tool(tool, weight_prev, paintval, brush_alpha_value); CLAMP(testw, 0.0f, 1.0f); if (testw < weight_prev) { - if(weight < testw) weight = testw; - else if(weight > weight_prev) weight = weight_prev; + if (weight < testw) weight = testw; + else if (weight > weight_prev) weight = weight_prev; } else { if (weight > testw) weight = testw; @@ -1023,10 +1024,10 @@ static int weight_sample_invoke(bContext *C, wmOperator *op, wmEvent *event) index= view3d_sample_backbuf(&vc, event->mval[0], event->mval[1]); - if(index && index<=me->totpoly) { + if (index && index<=me->totpoly) { DerivedMesh *dm= mesh_get_derived_final(vc.scene, vc.obact, CD_MASK_BAREMESH); - if(dm->getVertCo==NULL) { + if (dm->getVertCo==NULL) { BKE_report(op->reports, RPT_WARNING, "The modifier used does not support deformed locations"); } else { @@ -1048,13 +1049,13 @@ static int weight_sample_invoke(bContext *C, wmOperator *op, wmEvent *event) dm->getVertCo(dm, v_idx, co); project_float_noclip(vc.ar, co, sco); len= len_squared_v2v2(mval_f, sco); - if(len < len_best) { + if (len < len_best) { len_best= len; v_idx_best= v_idx; } } while (fidx--); - if(v_idx_best != -1) { /* should always be valid */ + if (v_idx_best != -1) { /* should always be valid */ ts->vgroup_weight= defvert_find_weight(&me->dvert[v_idx_best], vgroup_active); change= TRUE; } @@ -1063,7 +1064,7 @@ static int weight_sample_invoke(bContext *C, wmOperator *op, wmEvent *event) } } - if(change) { + if (change) { /* not really correct since the brush didnt change, but redraws the toolbar */ WM_main_add_notifier(NC_BRUSH|NA_EDITED, NULL); /* ts->wpaint->paint.brush */ @@ -1093,7 +1094,7 @@ static EnumPropertyItem *weight_paint_sample_enum_itemf(bContext *C, PointerRNA { if (C) { wmWindow *win= CTX_wm_window(C); - if(win && win->eventstate) { + if (win && win->eventstate) { ViewContext vc; Mesh *me; @@ -1107,9 +1108,9 @@ static EnumPropertyItem *weight_paint_sample_enum_itemf(bContext *C, PointerRNA index= view3d_sample_backbuf(&vc, win->eventstate->x - vc.ar->winrct.xmin, win->eventstate->y - vc.ar->winrct.ymin); - if(index && index<=me->totpoly) { + if (index && index<=me->totpoly) { const int defbase_tot= BLI_countlist(&vc.obact->defbase); - if(defbase_tot) { + if (defbase_tot) { MPoly *mf= ((MPoly *)me->mpoly) + index-1; unsigned int fidx= mf->totloop - 1; int *groups= MEM_callocN(defbase_tot*sizeof(int), "groups"); @@ -1119,7 +1120,7 @@ static EnumPropertyItem *weight_paint_sample_enum_itemf(bContext *C, PointerRNA MDeformVert *dvert= me->dvert + me->mloop[mf->loopstart + fidx].v; int i= dvert->totweight; MDeformWeight *dw; - for(dw= dvert->dw; i > 0; dw++, i--) { + for (dw= dvert->dw; i > 0; dw++, i--) { if (dw->def_nr < defbase_tot) { groups[dw->def_nr]= TRUE; found= TRUE; @@ -1127,7 +1128,7 @@ static EnumPropertyItem *weight_paint_sample_enum_itemf(bContext *C, PointerRNA } } while (fidx--); - if(found==FALSE) { + if (found==FALSE) { MEM_freeN(groups); } else { @@ -1135,8 +1136,8 @@ static EnumPropertyItem *weight_paint_sample_enum_itemf(bContext *C, PointerRNA int totitem= 0; int i= 0; bDeformGroup *dg; - for(dg= vc.obact->defbase.first; dg && inext) { - if(groups[i]) { + for (dg= vc.obact->defbase.first; dg && inext) { + if (groups[i]) { item_tmp.identifier= item_tmp.name= dg->name; item_tmp.value= i; RNA_enum_item_add(&item, &totitem, &item_tmp); @@ -1324,7 +1325,7 @@ static char *gen_lock_flags(Object* ob, int defbase_tot) char *lock_flags = MEM_mallocN(defbase_tot*sizeof(char), "defflags"); bDeformGroup *defgroup; - for(i = 0, defgroup = ob->defbase.first; i < defbase_tot && defgroup; defgroup = defgroup->next, i++) { + for (i = 0, defgroup = ob->defbase.first; i < defbase_tot && defgroup; defgroup = defgroup->next, i++) { lock_flags[i] = ((defgroup->flag & DG_LOCK_WEIGHT) != 0); is_locked |= lock_flags[i]; } @@ -1339,8 +1340,8 @@ static char *gen_lock_flags(Object* ob, int defbase_tot) static int has_locked_group_selected(int defbase_tot, const char *defbase_sel, const char *lock_flags) { int i; - for(i = 0; i < defbase_tot; i++) { - if(defbase_sel[i] && lock_flags[i]) { + for (i = 0; i < defbase_tot; i++) { + if (defbase_sel[i] && lock_flags[i]) { return TRUE; } } @@ -1352,11 +1353,11 @@ static int has_locked_group_selected(int defbase_tot, const char *defbase_sel, c static int has_unselected_unlocked_bone_group(int defbase_tot, char *defbase_sel, int selected, char *lock_flags, char *vgroup_validmap) { int i; - if(defbase_tot == selected) { + if (defbase_tot == selected) { return FALSE; } - for(i = 0; i < defbase_tot; i++) { - if(vgroup_validmap[i] && !defbase_sel[i] && !lock_flags[i]) { + for (i = 0; i < defbase_tot; i++) { + if (vgroup_validmap[i] && !defbase_sel[i] && !lock_flags[i]) { return TRUE; } } @@ -1371,12 +1372,12 @@ static void multipaint_selection(MDeformVert *dvert, const int defbase_tot, floa MDeformWeight *dw; float val; /* make sure they are all at most 1 after the change */ - for(i = 0; i < defbase_tot; i++) { - if(defbase_sel[i]) { + for (i = 0; i < defbase_tot; i++) { + if (defbase_sel[i]) { dw = defvert_find_index(dvert, i); - if(dw && dw->weight) { + if (dw && dw->weight) { val = dw->weight * change; - if(val > 1) { + if (val > 1) { /* TODO: when the change is reduced, you need to recheck * the earlier values to make sure they are not 0 * (precision error) */ @@ -1384,17 +1385,17 @@ static void multipaint_selection(MDeformVert *dvert, const int defbase_tot, floa } /* the value should never reach zero while multi-painting if it * was nonzero beforehand */ - if(val <= 0) { + if (val <= 0) { return; } } } } /* apply the valid change */ - for(i = 0; i < defbase_tot; i++) { - if(defbase_sel[i]) { + for (i = 0; i < defbase_tot; i++) { + if (defbase_sel[i]) { dw = defvert_find_index(dvert, i); - if(dw && dw->weight) { + if (dw && dw->weight) { dw->weight = dw->weight * change; } } @@ -1419,24 +1420,24 @@ static float redistribute_change(MDeformVert *ndv, const int defbase_tot, was_change = FALSE; /* change each group by the same amount each time */ change = totchange/total_valid; - for(i = 0; i < ndv->totweight && total_valid && totchange; i++) { + for (i = 0; i < ndv->totweight && total_valid && totchange; i++) { ndw = (ndv->dw+i); /* ignore anything outside the value range */ if (ndw->def_nr < defbase_tot) { /* change only the groups with a valid status */ - if(change_status[ndw->def_nr] == change_me) { + if (change_status[ndw->def_nr] == change_me) { oldval = ndw->weight; /* if auto normalize is active, don't worry about upper bounds */ - if(do_auto_normalize == FALSE && ndw->weight + change > 1) { + if (do_auto_normalize == FALSE && ndw->weight + change > 1) { totchange -= 1-ndw->weight; ndw->weight = 1; /* stop the changes to this group */ change_status[ndw->def_nr] = changeto; total_valid--; } - else if(ndw->weight + change < 0) { /* check the lower bound */ + else if (ndw->weight + change < 0) { /* check the lower bound */ totchange -= ndw->weight; ndw->weight = 0; change_status[ndw->def_nr] = changeto; @@ -1447,7 +1448,7 @@ static float redistribute_change(MDeformVert *ndv, const int defbase_tot, ndw->weight += change; } /* see if there was a change */ - if(oldval != ndw->weight) { + if (oldval != ndw->weight) { was_change = TRUE; } } @@ -1455,7 +1456,7 @@ static float redistribute_change(MDeformVert *ndv, const int defbase_tot, } /* don't go again if there was no change, if there is no valid group, * or there is no change left */ - } while(was_change && total_valid && totchange); + } while (was_change && total_valid && totchange); /* left overs */ return totchange; } @@ -1482,17 +1483,17 @@ static void enforce_locks(MDeformVert *odv, MDeformVert *ndv, char *change_status; - if(!lock_flags || !has_locked_group(ndv, defbase_tot, vgroup_validmap, lock_flags)) { + if (!lock_flags || !has_locked_group(ndv, defbase_tot, vgroup_validmap, lock_flags)) { return; } /* record if a group was changed, unlocked and not changed, or locked */ change_status = MEM_callocN(sizeof(char)*defbase_tot, "unlocked_unchanged"); - for(i = 0; i < defbase_tot; i++) { + for (i = 0; i < defbase_tot; i++) { ndw = defvert_find_index(ndv, i); odw = defvert_find_index(odv, i); /* the weights are zero, so we can assume a lot */ - if(!ndw || !odw) { + if (!ndw || !odw) { if (!lock_flags[i] && vgroup_validmap[i]) { defvert_verify_index(odv, i); defvert_verify_index(ndv, i); @@ -1502,10 +1503,10 @@ static void enforce_locks(MDeformVert *odv, MDeformVert *ndv, continue; } /* locked groups should not be changed */ - if(lock_flags[i]) { + if (lock_flags[i]) { ndw->weight = odw->weight; } - else if(ndw->weight != odw->weight) { /* changed groups are handled here */ + else if (ndw->weight != odw->weight) { /* changed groups are handled here */ totchange += ndw->weight - odw->weight; changed_sum += ndw->weight; change_status[i] = 2; /* was altered already */ @@ -1518,26 +1519,26 @@ static void enforce_locks(MDeformVert *odv, MDeformVert *ndv, } } /* if there was any change, redistribute it */ - if(total_changed) { + if (total_changed) { /* auto normalize will allow weights to temporarily go above 1 in redistribution */ - if(vgroup_validmap && total_changed < 0 && total_valid) { + if (vgroup_validmap && total_changed < 0 && total_valid) { totchange_allowed = total_valid; } /* the way you modify the unlocked+unchanged groups is different depending * on whether or not you are painting the weight(s) up or down */ - if(totchange < 0) { + if (totchange < 0) { totchange_allowed = total_valid - totchange_allowed; } else { totchange_allowed *= -1; } /* there needs to be change allowed, or you should not bother */ - if(totchange_allowed) { + if (totchange_allowed) { left_over = 0; - if(fabsf(totchange_allowed) < fabsf(totchange)) { + if (fabsf(totchange_allowed) < fabsf(totchange)) { /* this amount goes back onto the changed, unlocked weights */ left_over = fabsf(fabsf(totchange) - fabsf(totchange_allowed)); - if(totchange > 0) { + if (totchange > 0) { left_over *= -1; } } @@ -1548,9 +1549,9 @@ static void enforce_locks(MDeformVert *odv, MDeformVert *ndv, /* move the weight evenly between the allowed groups, move excess back onto the used groups based on the change */ totchange_allowed = redistribute_change(ndv, defbase_tot, change_status, 1, -1, totchange_allowed, total_valid, do_auto_normalize); left_over += totchange_allowed; - if(left_over) { + if (left_over) { /* more than one nonzero weights were changed with the same ratio with multipaint, so keep them changed that way! */ - if(total_changed > 1 && do_multipaint) { + if (total_changed > 1 && do_multipaint) { float undo_change = get_mp_change(ndv, defbase_tot, defbase_sel, left_over); multipaint_selection(ndv, defbase_tot, undo_change, defbase_sel); } @@ -1584,12 +1585,12 @@ static float get_mp_change(MDeformVert *odv, const int defbase_tot, const char * for (i= odv->totweight; i != 0; i--, dw++) { if (dw->def_nr < defbase_tot) { - if(defbase_sel[dw->def_nr]) { + if (defbase_sel[dw->def_nr]) { selwsum += dw->weight; } } } - if(selwsum && selwsum+brush_change > 0) { + if (selwsum && selwsum+brush_change > 0) { return (selwsum+brush_change)/selwsum; } return 0.0f; @@ -1672,8 +1673,8 @@ static int apply_mp_locks_normalize(Mesh *me, const WeightPaintInfo *wpi, ((wpi->lock_flags[dw->def_nr] == FALSE) && /* def_nr range has to be checked for by caller */ has_locked_group_selected(wpi->defbase_tot, wpi->defbase_sel, wpi->lock_flags) == FALSE)) { - if(wpi->do_multipaint && wpi->defbase_tot_sel > 1) { - if(change && change!=1) { + if (wpi->do_multipaint && wpi->defbase_tot_sel > 1) { + if (change && change!=1) { multipaint_selection(dv, wpi->defbase_tot, change, wpi->defbase_sel); } } @@ -1690,16 +1691,16 @@ static int apply_mp_locks_normalize(Mesh *me, const WeightPaintInfo *wpi, do_weight_paint_normalize_all(dv, wpi->defbase_tot, wpi->vgroup_validmap); } - if(oldChange && wpi->do_multipaint && wpi->defbase_tot_sel > 1) { - if(tdw->weight != oldw) { - if(neww > oldw) { - if(tdw->weight <= oldw) { + if (oldChange && wpi->do_multipaint && wpi->defbase_tot_sel > 1) { + if (tdw->weight != oldw) { + if (neww > oldw) { + if (tdw->weight <= oldw) { MEM_freeN(dv_test.dw); return TRUE; } } else { - if(tdw->weight >= oldw) { + if (tdw->weight >= oldw) { MEM_freeN(dv_test.dw); return TRUE; } @@ -1716,7 +1717,7 @@ static int get_first_selected_nonzero_weight(MDeformVert *dvert, const int defba { int i; MDeformWeight *dw= dvert->dw; - for(i=0; i< dvert->totweight; i++, dw++) { + for (i=0; i< dvert->totweight; i++, dw++) { if (dw->def_nr < defbase_tot) { if (defbase_sel[dw->def_nr] && dw->weight > 0.0f) { return i; @@ -1750,7 +1751,7 @@ static void do_weight_paint_vertex(/* vars which remain the same for every vert const short do_multipaint_totsel = (wpi->do_multipaint && wpi->defbase_tot_sel > 1); - if(wp->flag & VP_ONLYVGROUP) { + if (wp->flag & VP_ONLYVGROUP) { dw= defvert_find_index(dv, wpi->vgroup_active); dw_prev= defvert_find_index(wp->wpaint_prev+index, wpi->vgroup_active); } @@ -1759,7 +1760,7 @@ static void do_weight_paint_vertex(/* vars which remain the same for every vert dw_prev= defvert_verify_index(wp->wpaint_prev+index, wpi->vgroup_active); } - if(dw==NULL || dw_prev==NULL) { + if (dw==NULL || dw_prev==NULL) { return; } @@ -1829,7 +1830,7 @@ static void do_weight_paint_vertex(/* vars which remain the same for every vert * can give wrong results [#26193], least confusing if normalize is done last */ /* apply mirror */ - if(index_mirr != -1) { + if (index_mirr != -1) { /* copy, not paint again */ dw_mirr->weight = dw->weight; } @@ -1899,10 +1900,10 @@ static void do_weight_paint_vertex(/* vars which remain the same for every vert tdw = dw; tdw_prev = dw_prev; change = get_mp_change(&wp->wpaint_prev[index], wpi->defbase_tot, wpi->defbase_sel, neww - oldw); - if(change) { - if(!tdw->weight) { + if (change) { + if (!tdw->weight) { i = get_first_selected_nonzero_weight(dv, wpi->defbase_tot, wpi->defbase_sel); - if(i>=0) { + if (i>=0) { tdw = &(dv->dw[i]); tdw_prev = defvert_verify_index(&wp->wpaint_prev[index], tdw->def_nr); } @@ -1910,12 +1911,12 @@ static void do_weight_paint_vertex(/* vars which remain the same for every vert change = 0; } } - if(change && tdw_prev->weight && tdw_prev->weight * change) { - if(tdw->weight != tdw_prev->weight) { + if (change && tdw_prev->weight && tdw_prev->weight * change) { + if (tdw->weight != tdw_prev->weight) { oldChange = tdw->weight/tdw_prev->weight; testw = tdw_prev->weight*change; - if( testw > tdw_prev->weight ) { - if(change > oldChange) { + if ( testw > tdw_prev->weight ) { + if (change > oldChange) { /* reset the weights and use the new change */ defvert_reset_to_prev(wp->wpaint_prev+index, dv); } @@ -1926,7 +1927,7 @@ static void do_weight_paint_vertex(/* vars which remain the same for every vert } } else { - if(change < oldChange) { + if (change < oldChange) { defvert_reset_to_prev(wp->wpaint_prev+index, dv); } else { @@ -1941,12 +1942,12 @@ static void do_weight_paint_vertex(/* vars which remain the same for every vert } } - if(apply_mp_locks_normalize(me, wpi, index, dw, tdw, change, oldChange, oldw, neww)) { + if (apply_mp_locks_normalize(me, wpi, index, dw, tdw, change, oldChange, oldw, neww)) { defvert_reset_to_prev(&dv_copy, dv); change = 0; oldChange = 0; } - if(dv_copy.dw) { + if (dv_copy.dw) { MEM_freeN(dv_copy.dw); } #if 0 @@ -1959,7 +1960,7 @@ static void do_weight_paint_vertex(/* vars which remain the same for every vert #endif /* x mirror painting */ - if(index_mirr != -1) { + if (index_mirr != -1) { /* copy, not paint again */ /* dw_mirr->weight = dw->weight; */ /* TODO, explain the logic in not assigning weight! - campbell */ @@ -1979,9 +1980,9 @@ static int set_wpaint(bContext *C, wmOperator *UNUSED(op)) /* toggle */ Mesh *me; me= get_mesh(ob); - if(ob->id.lib || me==NULL) return OPERATOR_PASS_THROUGH; + if (ob->id.lib || me==NULL) return OPERATOR_PASS_THROUGH; - if(ob->mode & OB_MODE_WEIGHT_PAINT) ob->mode &= ~OB_MODE_WEIGHT_PAINT; + if (ob->mode & OB_MODE_WEIGHT_PAINT) ob->mode &= ~OB_MODE_WEIGHT_PAINT; else ob->mode |= OB_MODE_WEIGHT_PAINT; @@ -1992,10 +1993,10 @@ static int set_wpaint(bContext *C, wmOperator *UNUSED(op)) /* toggle */ */ DAG_id_tag_update(&me->id, 0); - if(ob->mode & OB_MODE_WEIGHT_PAINT) { + if (ob->mode & OB_MODE_WEIGHT_PAINT) { Object *par; - if(wp==NULL) + if (wp==NULL) wp= scene->toolsettings->wpaint= new_vpaint(1); paint_init(&wp->paint, PAINT_CURSOR_WEIGHT_PAINT); @@ -2005,10 +2006,10 @@ static int set_wpaint(bContext *C, wmOperator *UNUSED(op)) /* toggle */ /* verify if active weight group is also active bone */ par= modifiers_isDeformedByArmature(ob); - if(par && (par->mode & OB_MODE_POSE)) { + if (par && (par->mode & OB_MODE_POSE)) { bArmature *arm= par->data; - if(arm->act_bone) + if (arm->act_bone) ED_vgroup_select_by_name(ob, arm->act_bone->name); } } @@ -2026,11 +2027,11 @@ static int set_wpaint(bContext *C, wmOperator *UNUSED(op)) /* toggle */ static int paint_poll_test(bContext *C) { Object *ob= CTX_data_active_object(C); - if(CTX_data_edit_object(C)) + if (CTX_data_edit_object(C)) return 0; - if(CTX_data_active_object(C)==NULL) + if (CTX_data_active_object(C)==NULL) return 0; - if(!ob->data || ((ID *)ob->data)->lib) + if (!ob->data || ((ID *)ob->data)->lib) return 0; return 1; } @@ -2075,7 +2076,7 @@ static char *wpaint_make_validmap(Object *ob) GHash *gh; int i, step1=1; - if(ob->defbase.first == NULL) { + if (ob->defbase.first == NULL) { return NULL; } @@ -2094,7 +2095,7 @@ static char *wpaint_make_validmap(Object *ob) if (md->type == eModifierType_Armature) { ArmatureModifierData *amd= (ArmatureModifierData*) md; - if(amd->object && amd->object->pose) { + if (amd->object && amd->object->pose) { bPose *pose= amd->object->pose; bPoseChannel *chan; @@ -2138,12 +2139,12 @@ static int wpaint_stroke_test_start(bContext *C, wmOperator *op, wmEvent *UNUSED float mat[4][4], imat[4][4]; - if(scene->obedit) { + if (scene->obedit) { return FALSE; } me= get_mesh(ob); - if(me==NULL || me->totpoly==0) return OPERATOR_PASS_THROUGH; + if (me==NULL || me->totpoly==0) return OPERATOR_PASS_THROUGH; /* if nothing was added yet, we make dverts and a vertex deform group */ if (!me->dvert) { @@ -2154,14 +2155,14 @@ static int wpaint_stroke_test_start(bContext *C, wmOperator *op, wmEvent *UNUSED /* this happens on a Bone select, when no vgroup existed yet */ if (ob->actdef <= 0) { Object *modob; - if((modob = modifiers_isDeformedByArmature(ob))) { + if ((modob = modifiers_isDeformedByArmature(ob))) { Bone *actbone= ((bArmature *)modob->data)->act_bone; - if(actbone) { + if (actbone) { bPoseChannel *pchan= get_pose_channel(modob->pose, actbone->name); - if(pchan) { + if (pchan) { bDeformGroup *dg= defgroup_find_name(ob, pchan->name); - if(dg==NULL) { + if (dg==NULL) { dg= ED_vgroup_add_name(ob, pchan->name); /* sets actdef */ } else { @@ -2173,7 +2174,7 @@ static int wpaint_stroke_test_start(bContext *C, wmOperator *op, wmEvent *UNUSED } } } - if(ob->defbase.first==NULL) { + if (ob->defbase.first==NULL) { ED_vgroup_add(ob); } @@ -2219,7 +2220,7 @@ static int wpaint_stroke_test_start(bContext *C, wmOperator *op, wmEvent *UNUSED copy_m3_m4(wpd->wpimat, imat); /* if mirror painting, find the other group */ - if(me->editflag & ME_EDIT_MIRROR_X) { + if (me->editflag & ME_EDIT_MIRROR_X) { wpd->vgroup_mirror = wpaint_mirror_vgroup_ensure(ob, wpd->vgroup_active); } @@ -2283,7 +2284,7 @@ static void wpaint_stroke_update_step(bContext *C, struct PaintStroke *stroke, P defbase_sel= MEM_mallocN(wpi.defbase_tot*sizeof(char), "wpi.defbase_sel"); wpi.defbase_tot_sel= get_selected_defgroups(ob, defbase_sel, wpi.defbase_tot); wpi.defbase_sel= defbase_sel; /* so we can stay const */ - if(wpi.defbase_tot_sel == 0 && ob->actdef > 0) wpi.defbase_tot_sel = 1; + if (wpi.defbase_tot_sel == 0 && ob->actdef > 0) wpi.defbase_tot_sel = 1; wpi.defbase_tot_unsel= wpi.defbase_tot - wpi.defbase_tot_sel; wpi.vgroup_active= wpd->vgroup_active; @@ -2303,7 +2304,7 @@ static void wpaint_stroke_update_step(bContext *C, struct PaintStroke *stroke, P use_vert_sel= (me->editflag & ME_EDIT_VERT_SEL) != 0; /* which faces are involved */ - if(wp->flag & VP_AREA) { + if (wp->flag & VP_AREA) { /* Ugly hack, to avoid drawing vertex index when getting the face index buffer - campbell */ me->editflag &= ~ME_EDIT_VERT_SEL; totindex= sample_backbuf_area(vc, indexar, me->totpoly, mval[0], mval[1], brush_size_pressure); @@ -2311,28 +2312,28 @@ static void wpaint_stroke_update_step(bContext *C, struct PaintStroke *stroke, P } else { indexar[0]= view3d_sample_backbuf(vc, mval[0], mval[1]); - if(indexar[0]) totindex= 1; + if (indexar[0]) totindex= 1; else totindex= 0; } - if(wp->flag & VP_COLINDEX) { - for(index=0; indextotpoly) { + if (wp->flag & VP_COLINDEX) { + for (index=0; indextotpoly) { MPoly *mpoly= ((MPoly *)me->mpoly) + (indexar[index]-1); - if(mpoly->mat_nr!=ob->actcol-1) { + if (mpoly->mat_nr!=ob->actcol-1) { indexar[index]= 0; } } } } - if((me->editflag & ME_EDIT_PAINT_MASK) && me->mpoly) { - for(index=0; indextotpoly) { + if ((me->editflag & ME_EDIT_PAINT_MASK) && me->mpoly) { + for (index=0; indextotpoly) { MPoly *mpoly= ((MPoly *)me->mpoly) + (indexar[index]-1); - if((mpoly->flag & ME_FACE_SEL)==0) { + if ((mpoly->flag & ME_FACE_SEL)==0) { indexar[index]= 0; } } @@ -2347,13 +2348,13 @@ static void wpaint_stroke_update_step(bContext *C, struct PaintStroke *stroke, P else paintweight= ts->vgroup_weight; - for(index=0; indextotpoly) { + for (index=0; indextotpoly) { MPoly *mpoly= me->mpoly + (indexar[index]-1); MLoop *ml = me->mloop + mpoly->loopstart; int i; - if(use_vert_sel) { + if (use_vert_sel) { for (i=0; itotloop; i++, ml++) { me->dvert[ml->v].flag = (me->mvert[ml->v].flag & SELECT); } @@ -2367,7 +2368,7 @@ static void wpaint_stroke_update_step(bContext *C, struct PaintStroke *stroke, P if (brush->vertexpaint_tool == PAINT_BLEND_BLUR) { MDeformWeight *dw, *(*dw_func)(MDeformVert *, const int); - if(wp->flag & VP_ONLYVGROUP) + if (wp->flag & VP_ONLYVGROUP) dw_func= (MDeformWeight *(*)(MDeformVert *, const int))defvert_find_index; else dw_func= defvert_verify_index; @@ -2390,9 +2391,9 @@ static void wpaint_stroke_update_step(bContext *C, struct PaintStroke *stroke, P paintweight /= totw; } - for(index=0; indextotpoly) { + if (indexar[index] && indexar[index]<=me->totpoly) { MPoly *mpoly= me->mpoly + (indexar[index]-1); MLoop *ml=me->mloop+mpoly->loopstart; int i; @@ -2403,7 +2404,7 @@ static void wpaint_stroke_update_step(bContext *C, struct PaintStroke *stroke, P if (me->dvert[vidx].flag) { alpha= calc_vp_alpha_dl(wp, vc, wpd->wpimat, wpd->vertexcosnos+6*vidx, mval, brush_size_pressure, brush_alpha_pressure); - if(alpha) { + if (alpha) { do_weight_paint_vertex(wp, ob, &wpi, vidx, alpha, paintweight); } me->dvert[vidx].flag= 0; @@ -2430,14 +2431,14 @@ static void wpaint_stroke_done(bContext *C, struct PaintStroke *stroke) Object *ob= CTX_data_active_object(C); struct WPaintData *wpd= paint_stroke_mode_data(stroke); - if(wpd) { - if(wpd->vertexcosnos) + if (wpd) { + if (wpd->vertexcosnos) MEM_freeN(wpd->vertexcosnos); MEM_freeN(wpd->indexar); if (wpd->vgroup_validmap) MEM_freeN((void *)wpd->vgroup_validmap); - if(wpd->lock_flags) + if (wpd->lock_flags) MEM_freeN((void *)wpd->lock_flags); MEM_freeN(wpd); @@ -2447,13 +2448,13 @@ static void wpaint_stroke_done(bContext *C, struct PaintStroke *stroke) copy_wpaint_prev(ts->wpaint, NULL, 0); /* and particles too */ - if(ob->particlesystem.first) { + if (ob->particlesystem.first) { ParticleSystem *psys; int i; - for(psys= ob->particlesystem.first; psys; psys= psys->next) { - for(i=0; ivgroup[i]==ob->actdef) { + for (psys= ob->particlesystem.first; psys; psys= psys->next) { + for (i=0; ivgroup[i]==ob->actdef) { psys->recalc |= PSYS_RECALC_RESET; break; } @@ -2543,15 +2544,15 @@ static int set_vpaint(bContext *C, wmOperator *op) /* toggle */ me= get_mesh(ob); - if(me==NULL || object_data_is_libdata(ob)) { + if (me==NULL || object_data_is_libdata(ob)) { ob->mode &= ~OB_MODE_VERTEX_PAINT; return OPERATOR_PASS_THROUGH; } - if(me && me->mloopcol==NULL) make_vertexcol(ob); + if (me && me->mloopcol==NULL) make_vertexcol(ob); /* toggle: end vpaint */ - if(ob->mode & OB_MODE_VERTEX_PAINT) { + if (ob->mode & OB_MODE_VERTEX_PAINT) { ob->mode &= ~OB_MODE_VERTEX_PAINT; } @@ -2561,7 +2562,7 @@ static int set_vpaint(bContext *C, wmOperator *op) /* toggle */ if (ob->mode & OB_MODE_WEIGHT_PAINT) set_wpaint(C, op); - if(vp==NULL) + if (vp==NULL) vp= scene->toolsettings->vpaint= new_vpaint(0); paint_cursor_start(C, vertex_paint_poll); @@ -2677,12 +2678,12 @@ static int vpaint_stroke_test_start(bContext *C, struct wmOperator *op, wmEvent /* context checks could be a poll() */ me= get_mesh(ob); - if(me==NULL || me->totpoly==0) + if (me==NULL || me->totpoly==0) return OPERATOR_PASS_THROUGH; - if(me->mloopcol==NULL) + if (me->mloopcol==NULL) make_vertexcol(ob); - if(me->mloopcol==NULL) + if (me->mloopcol==NULL) return OPERATOR_CANCELLED; /* make mode data storage */ @@ -2733,13 +2734,13 @@ static void vpaint_paint_face(VPaint *vp, VPaintData *vpd, Object *ob, int brush_alpha_pressure_i; - if((vp->flag & VP_COLINDEX && mface->mat_nr!=ob->actcol-1) || + if ((vp->flag & VP_COLINDEX && mface->mat_nr!=ob->actcol-1) || ((me->editflag & ME_EDIT_PAINT_MASK) && !(mface->flag & ME_FACE_SEL))) return; if (brush->vertexpaint_tool == PAINT_BLEND_BLUR) { unsigned int fcol1= mcol_blend( mcol[0], mcol[1], 128); - if(mface->v4) { + if (mface->v4) { unsigned int fcol2= mcol_blend( mcol[2], mcol[3], 128); vpd->paintcol= mcol_blend( fcol1, fcol2, 128); } @@ -2750,7 +2751,7 @@ static void vpaint_paint_face(VPaint *vp, VPaintData *vpd, Object *ob, brush_alpha_pressure_i = (int)(brush_alpha_pressure*255.0f); - for(i = 0; i < (mface->v4 ? 4 : 3); ++i) { + for (i = 0; i < (mface->v4 ? 4 : 3); ++i) { alpha = calc_vp_alpha_dl(vp, vc, vpd->vpimat, vpd->vertexcosnos+6*(&mface->v1)[i], mval, brush_size_pressure, brush_alpha_pressure); if (alpha) { @@ -2785,7 +2786,7 @@ static void vpaint_paint_poly(VPaint *vp, VPaintData *vpd, Object *ob, int brush_alpha_pressure_i = (int)(brush_alpha_pressure*255.0f); - if(brush->vertexpaint_tool == PAINT_BLEND_BLUR) { + if (brush->vertexpaint_tool == PAINT_BLEND_BLUR) { unsigned int blend[4] = {0}; unsigned int tcol; char *col; @@ -2816,7 +2817,7 @@ static void vpaint_paint_poly(VPaint *vp, VPaintData *vpd, Object *ob, alpha= calc_vp_alpha_dl(vp, vc, vpd->vpimat, vpd->vertexcosnos+6*ml->v, mval, brush_size_pressure, brush_alpha_pressure); - if(alpha > 0.0f) { + if (alpha > 0.0f) { const int alpha_i = (int)(alpha*255.0f); lcol[i] = vpaint_blend(vp, lcol[i], lcolorig[i], vpd->paintcol, alpha_i, brush_alpha_pressure_i); } @@ -2888,34 +2889,34 @@ static void vpaint_stroke_update_step(bContext *C, struct PaintStroke *stroke, P /* which faces are involved */ - if(vp->flag & VP_AREA) { + if (vp->flag & VP_AREA) { totindex= sample_backbuf_area(vc, indexar, me->totpoly, mval[0], mval[1], brush_size_pressure); } else { indexar[0]= view3d_sample_backbuf(vc, mval[0], mval[1]); - if(indexar[0]) totindex= 1; + if (indexar[0]) totindex= 1; else totindex= 0; } - if(vp->flag & VP_COLINDEX) { - for(index=0; indextotpoly) { + if (vp->flag & VP_COLINDEX) { + for (index=0; indextotpoly) { MPoly *mpoly= ((MPoly *)me->mpoly) + (indexar[index]-1); - if(mpoly->mat_nr!=ob->actcol-1) { + if (mpoly->mat_nr!=ob->actcol-1) { indexar[index]= 0; } } } } - if((me->editflag & ME_EDIT_PAINT_MASK) && me->mpoly) { - for(index=0; indextotpoly) { + if ((me->editflag & ME_EDIT_PAINT_MASK) && me->mpoly) { + for (index=0; indextotpoly) { MPoly *mpoly= ((MPoly *)me->mpoly) + (indexar[index]-1); - if((mpoly->flag & ME_FACE_SEL)==0) + if ((mpoly->flag & ME_FACE_SEL)==0) indexar[index]= 0; } } @@ -2924,9 +2925,9 @@ static void vpaint_stroke_update_step(bContext *C, struct PaintStroke *stroke, P swap_m4m4(vc->rv3d->persmat, mat); - for(index=0; indextotpoly) { + if (indexar[index] && indexar[index]<=me->totpoly) { vpaint_paint_poly(vp, vpd, ob, indexar[index]-1, mval, brush_size_pressure, brush_alpha_pressure, flip); } } @@ -2934,7 +2935,7 @@ static void vpaint_stroke_update_step(bContext *C, struct PaintStroke *stroke, P swap_m4m4(vc->rv3d->persmat, mat); /* was disabled because it is slow, but necessary for blur */ - if(brush->vertexpaint_tool == PAINT_BLEND_BLUR) { + if (brush->vertexpaint_tool == PAINT_BLEND_BLUR) { int do_tessface = vpd->use_fast_update; do_shared_vertexcol(me, do_tessface); } @@ -2953,7 +2954,7 @@ static void vpaint_stroke_done(bContext *C, struct PaintStroke *stroke) ToolSettings *ts= CTX_data_tool_settings(C); struct VPaintData *vpd= paint_stroke_mode_data(stroke); - if(vpd->vertexcosnos) + if (vpd->vertexcosnos) MEM_freeN(vpd->vertexcosnos); MEM_freeN(vpd->indexar); diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index dcb832ec31f..319570cf65e 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -97,7 +97,7 @@ void ED_sculpt_force_update(bContext *C) { Object *ob= CTX_data_active_object(C); - if(ob && (ob->mode & OB_MODE_SCULPT)) + if (ob && (ob->mode & OB_MODE_SCULPT)) multires_force_update(ob); } @@ -108,19 +108,19 @@ struct MultiresModifierData *sculpt_multires_active(Scene *scene, Object *ob) Mesh *me= (Mesh*)ob->data; ModifierData *md; - if(!CustomData_get_layer(&me->ldata, CD_MDISPS)) { + if (!CustomData_get_layer(&me->ldata, CD_MDISPS)) { /* multires can't work without displacement layer */ return NULL; } - for(md= modifiers_getVirtualModifierList(ob); md; md= md->next) { - if(md->type == eModifierType_Multires) { + for (md= modifiers_getVirtualModifierList(ob); md; md= md->next) { + if (md->type == eModifierType_Multires) { MultiresModifierData *mmd= (MultiresModifierData*)md; - if(!modifier_isEnabled(scene, md, eModifierMode_Realtime)) + if (!modifier_isEnabled(scene, md, eModifierMode_Realtime)) continue; - if(mmd->sculptlvl > 0) return mmd; + if (mmd->sculptlvl > 0) return mmd; else return NULL; } } @@ -136,8 +136,8 @@ static int sculpt_has_active_modifiers(Scene *scene, Object *ob) md= modifiers_getVirtualModifierList(ob); /* exception for shape keys because we can edit those */ - for(; md; md= md->next) { - if(modifier_isEnabled(scene, md, eModifierMode_Realtime)) + for (; md; md= md->next) { + if (modifier_isEnabled(scene, md, eModifierMode_Realtime)) return 1; } @@ -151,22 +151,22 @@ static int sculpt_modifiers_active(Scene *scene, Sculpt *sd, Object *ob) Mesh *me= (Mesh*)ob->data; MultiresModifierData *mmd= sculpt_multires_active(scene, ob); - if(mmd) return 0; + if (mmd) return 0; /* non-locked shape keys could be handled in the same way as deformed mesh */ - if((ob->shapeflag&OB_SHAPE_LOCK)==0 && me->key && ob->shapenr) + if ((ob->shapeflag&OB_SHAPE_LOCK)==0 && me->key && ob->shapenr) return 1; md= modifiers_getVirtualModifierList(ob); /* exception for shape keys because we can edit those */ - for(; md; md= md->next) { + for (; md; md= md->next) { ModifierTypeInfo *mti = modifierType_getInfo(md->type); - if(!modifier_isEnabled(scene, md, eModifierMode_Realtime)) continue; - if(md->type==eModifierType_ShapeKey) continue; + if (!modifier_isEnabled(scene, md, eModifierMode_Realtime)) continue; + if (md->type==eModifierType_ShapeKey) continue; - if(mti->type==eModifierTypeType_OnlyDeform) return 1; - else if((sd->flags & SCULPT_ONLY_DEFORM)==0) return 1; + if (mti->type==eModifierTypeType_OnlyDeform) return 1; + else if ((sd->flags & SCULPT_ONLY_DEFORM)==0) return 1; } return 0; @@ -254,13 +254,13 @@ static int sculpt_get_redraw_rect(ARegion *ar, RegionView3D *rv3d, PBVH *pbvh= ob->sculpt->pbvh; float bb_min[3], bb_max[3]; - if(!pbvh) + if (!pbvh) return 0; BLI_pbvh_redraw_BB(pbvh, bb_min, bb_max); /* convert 3D bounding box to screen space */ - if(!paint_convert_bb_to_rect(rect, + if (!paint_convert_bb_to_rect(rect, bb_min, bb_max, ar, @@ -276,8 +276,8 @@ static int sculpt_get_redraw_rect(ARegion *ar, RegionView3D *rv3d, * optimized PBVH draw function and 3d view redraw (if not -- some * mesh parts could disappear from screen (sergey) */ ss = ob->sculpt; - if(ss->cache) { - if(!BLI_rcti_is_empty(&ss->cache->previous_r)) + if (ss->cache) { + if (!BLI_rcti_is_empty(&ss->cache->previous_r)) BLI_union_rcti(rect, &ss->cache->previous_r); } @@ -295,7 +295,7 @@ void sculpt_get_redraw_planes(float planes[4][4], ARegion *ar, paint_calc_redraw_planes(planes, ar, rv3d, ob, &rect); /* clear redraw flag from nodes */ - if(pbvh) + if (pbvh) BLI_pbvh_update(pbvh, PBVH_UpdateRedraw, NULL); } @@ -318,7 +318,7 @@ static int sculpt_brush_test(SculptBrushTest *test, float co[3]) { float distsq = len_squared_v3v3(co, test->location); - if(distsq <= test->radius_squared) { + if (distsq <= test->radius_squared) { test->dist = sqrt(distsq); return 1; } @@ -331,7 +331,7 @@ static int sculpt_brush_test_sq(SculptBrushTest *test, float co[3]) { float distsq = len_squared_v3v3(co, test->location); - if(distsq <= test->radius_squared) { + if (distsq <= test->radius_squared) { test->dist = distsq; return 1; } @@ -451,7 +451,7 @@ static float integrate_overlap(Brush* br) float max; max= 0; - for(i= 0; i < m; i++) { + for (i= 0; i < m; i++) { float overlap= overlapped_curve(br, i*g); if (overlap > max) @@ -464,15 +464,15 @@ static float integrate_overlap(Brush* br) /* Uses symm to selectively flip any axis of a coordinate. */ static void flip_coord(float out[3], float in[3], const char symm) { - if(symm & SCULPT_SYMM_X) + if (symm & SCULPT_SYMM_X) out[0]= -in[0]; else out[0]= in[0]; - if(symm & SCULPT_SYMM_Y) + if (symm & SCULPT_SYMM_Y) out[1]= -in[1]; else out[1]= in[1]; - if(symm & SCULPT_SYMM_Z) + if (symm & SCULPT_SYMM_Z) out[2]= -in[2]; else out[2]= in[2]; @@ -486,7 +486,7 @@ static float calc_overlap(StrokeCache *cache, const char symm, const char axis, /* flip_coord(mirror, cache->traced_location, symm); */ flip_coord(mirror, cache->true_location, symm); - if(axis != 0) { + if (axis != 0) { float mat[4][4]= MAT4_UNITY; rotate_m4(mat, axis, angle); mul_m4_v3(mat, mirror); @@ -507,7 +507,7 @@ static float calc_radial_symmetry_feather(Sculpt *sd, StrokeCache *cache, const float overlap; overlap = 0; - for(i = 1; i < sd->radial_symm[axis-'X']; ++i) { + for (i = 1; i < sd->radial_symm[axis-'X']; ++i) { const float angle = 2*M_PI*i/sd->radial_symm[axis-'X']; overlap += calc_overlap(cache, symm, axis, angle); } @@ -524,7 +524,7 @@ static float calc_symmetry_feather(Sculpt *sd, StrokeCache* cache) overlap = 0; for (i = 0; i <= symm; i++) { - if(i == 0 || (symm & i && (symm != 5 || i != 3) && (symm != 6 || (i != 3 && i != 5)))) { + if (i == 0 || (symm & i && (symm != 5 || i != 3) && (symm != 6 || (i != 3 && i != 5)))) { overlap += calc_overlap(cache, i, 0, 0); @@ -565,7 +565,7 @@ static float brush_strength(Sculpt *sd, StrokeCache *cache, float feather) (brush->spacing < 100)) ? 1.0f/accum : 1; float flip = dir * invert * pen_flip; - switch(brush->sculpt_tool){ + switch(brush->sculpt_tool) { case SCULPT_TOOL_CLAY: case SCULPT_TOOL_CLAY_STRIPS: case SCULPT_TOOL_DRAW: @@ -638,10 +638,10 @@ static float tex_strength(SculptSession *ss, Brush *br, float point[3], MTex *mtex = &br->mtex; float avg= 1; - if(!mtex->tex) { + if (!mtex->tex) { avg= 1; } - else if(mtex->brush_map_mode == MTEX_MAP_MODE_3D) { + else if (mtex->brush_map_mode == MTEX_MAP_MODE_3D) { float jnk; /* Get strength by feeding the vertex @@ -649,7 +649,7 @@ static float tex_strength(SculptSession *ss, Brush *br, float point[3], externtex(mtex, point, &avg, &jnk, &jnk, &jnk, &jnk, 0); } - else if(ss->texcache) { + else if (ss->texcache) { float rotation = -mtex->rot; float symm_point[3], point_2d[2]; float x, y; @@ -668,7 +668,7 @@ static float tex_strength(SculptSession *ss, Brush *br, float point[3], ED_view3d_project_float_v2(ss->cache->vc->ar, symm_point, point_2d, ss->cache->projection_mat); /* if fixed mode, keep coordinates relative to mouse */ - if(mtex->brush_map_mode == MTEX_MAP_MODE_FIXED) { + if (mtex->brush_map_mode == MTEX_MAP_MODE_FIXED) { rotation += ss->cache->special_rotation; point_2d[0] -= ss->cache->tex_mouse[0]; @@ -746,15 +746,15 @@ static int sculpt_search_sphere_cb(PBVHNode *node, void *data_v) float t[3], bb_min[3], bb_max[3]; int i; - if(data->original) + if (data->original) BLI_pbvh_node_get_original_BB(node, bb_min, bb_max); else BLI_pbvh_node_get_BB(node, bb_min, bb_max); - for(i = 0; i < 3; ++i) { - if(bb_min[i] > center[i]) + for (i = 0; i < 3; ++i) { + if (bb_min[i] > center[i]) nearest[i] = bb_min[i]; - else if(bb_max[i] < center[i]) + else if (bb_max[i] < center[i]) nearest[i] = bb_max[i]; else nearest[i] = center[i]; @@ -770,11 +770,11 @@ static void sculpt_clip(Sculpt *sd, SculptSession *ss, float *co, const float va { int i; - for(i=0; i<3; ++i) { - if(sd->flags & (SCULPT_LOCK_X << i)) + for (i=0; i<3; ++i) { + if (sd->flags & (SCULPT_LOCK_X << i)) continue; - if((ss->cache->flag & (CLIP_X << i)) && (fabsf(co[i]) <= ss->cache->clip_tolerance[i])) + if ((ss->cache->flag & (CLIP_X << i)) && (fabsf(co[i]) <= ss->cache->clip_tolerance[i])) co[i]= 0.0f; else co[i]= val[i]; @@ -783,9 +783,10 @@ static void sculpt_clip(Sculpt *sd, SculptSession *ss, float *co, const float va static void add_norm_if(float view_vec[3], float out[3], float out_flip[3], float fno[3]) { - if((dot_v3v3(view_vec, fno)) > 0) { + if ((dot_v3v3(view_vec, fno)) > 0) { add_v3_v3(out, fno); - } else { + } + else { add_v3_v3(out_flip, fno); /* out_flip is used when out is {0,0,0} */ } } @@ -802,7 +803,7 @@ static void calc_area_normal(Sculpt *sd, Object *ob, float an[3], PBVHNode **nod zero_v3(an); #pragma omp parallel for schedule(guided) if (sd->flags & SCULPT_USE_OPENMP) - for(n=0; ncache->original) { + if (ss->cache->original) { BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) { - if(sculpt_brush_test_fast(&test, unode->co[vd.i])) { + if (sculpt_brush_test_fast(&test, unode->co[vd.i])) { float fno[3]; normal_short_to_float_v3(fno, unode->no[vd.i]); @@ -825,8 +826,8 @@ static void calc_area_normal(Sculpt *sd, Object *ob, float an[3], PBVHNode **nod } else { BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) { - if(sculpt_brush_test_fast(&test, vd.co)) { - if(vd.no) { + if (sculpt_brush_test_fast(&test, vd.co)) { + if (vd.no) { float fno[3]; normal_short_to_float_v3(fno, vd.no); @@ -915,14 +916,14 @@ static void neighbor_average(SculptSession *ss, float avg[3], unsigned vert) zero_v3(avg); /* Don't modify corner vertices */ - if(vert_map->count > 1) { + if (vert_map->count > 1) { int i, total = 0; - for(i = 0; i < vert_map->count; i++) { + for (i = 0; i < vert_map->count; i++) { const MPoly *p= &ss->mpoly[vert_map->indices[i]]; unsigned f_adj_v[3]; - if(poly_get_adj_loops_from_vert(f_adj_v, p, ss->mloop, vert) != -1) { + if (poly_get_adj_loops_from_vert(f_adj_v, p, ss->mloop, vert) != -1) { int j; for (j = 0; j < 3; j++) { @@ -936,7 +937,7 @@ static void neighbor_average(SculptSession *ss, float avg[3], unsigned vert) } } - if(total > 0) { + if (total > 0) { mul_v3_fl(avg, 1.0f / total); return; } @@ -956,7 +957,7 @@ static void do_mesh_smooth_brush(Sculpt *sd, SculptSession *ss, PBVHNode *node, sculpt_brush_test_init(ss, &test); BLI_pbvh_vertex_iter_begin(ss->pbvh, node, vd, PBVH_ITER_UNIQUE) { - if(sculpt_brush_test(&test, vd.co)) { + if (sculpt_brush_test(&test, vd.co)) { const float fade = bstrength*tex_strength(ss, brush, vd.co, test.dist, ss->cache->view_normal, vd.no, vd.fno); float avg[3], val[3]; @@ -969,7 +970,7 @@ static void do_mesh_smooth_brush(Sculpt *sd, SculptSession *ss, PBVHNode *node, sculpt_clip(sd, ss, vd.co, val); - if(vd.mvert) + if (vd.mvert) vd.mvert->flag |= ME_VERT_PBVH_UPDATE; } } @@ -999,7 +1000,7 @@ static void do_multires_smooth_brush(Sculpt *sd, SculptSession *ss, PBVHNode *no tmprow= MEM_mallocN(sizeof(float)*3*gridsize, "tmprow"); } - for(i = 0; i < totgrid; ++i) { + for (i = 0; i < totgrid; ++i) { data = griddata[grid_indices[i]]; adj = &gridadj[grid_indices[i]]; @@ -1028,29 +1029,29 @@ static void do_multires_smooth_brush(Sculpt *sd, SculptSession *ss, PBVHNode *no } /* blend with existing coordinates */ - for(y = 0; y < gridsize; ++y) { - for(x = 0; x < gridsize; ++x) { + for (y = 0; y < gridsize; ++y) { + for (x = 0; x < gridsize; ++x) { float *co; float *fno; int index; - if(x == 0 && adj->index[0] == -1) + if (x == 0 && adj->index[0] == -1) continue; - if(x == gridsize - 1 && adj->index[2] == -1) + if (x == gridsize - 1 && adj->index[2] == -1) continue; - if(y == 0 && adj->index[3] == -1) + if (y == 0 && adj->index[3] == -1) continue; - if(y == gridsize - 1 && adj->index[1] == -1) + if (y == gridsize - 1 && adj->index[1] == -1) continue; index = x + y*gridsize; co= data[index].co; fno= data[index].no; - if(sculpt_brush_test(&test, co)) { + if (sculpt_brush_test(&test, co)) { const float fade = bstrength*tex_strength(ss, brush, co, test.dist, ss->cache->view_normal, NULL, fno); float *avg, val[3]; @@ -1060,10 +1061,10 @@ static void do_multires_smooth_brush(Sculpt *sd, SculptSession *ss, PBVHNode *no n = 1/16.0f; - if(x == 0 || x == gridsize - 1) + if (x == 0 || x == gridsize - 1) n *= 2; - if(y == 0 || y == gridsize - 1) + if (y == 0 || y == gridsize - 1) n *= 2; mul_v3_fl(avg, n); @@ -1099,17 +1100,17 @@ static void smooth(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode, float count = (int)(bstrength*max_iterations); last = max_iterations*(bstrength - count*fract); - for(iteration = 0; iteration <= count; ++iteration) { + for (iteration = 0; iteration <= count; ++iteration) { #pragma omp parallel for schedule(guided) if (sd->flags & SCULPT_USE_OPENMP) - for(n=0; nmultires) { + for (n=0; nmultires) { do_multires_smooth_brush(sd, ss, nodes[n], iteration != count ? 1.0f : last); } - else if(ss->pmap) + else if (ss->pmap) do_mesh_smooth_brush(sd, ss, nodes[n], iteration != count ? 1.0f : last); } - if(ss->multires) + if (ss->multires) multires_stitch_grids(ob); } } @@ -1137,7 +1138,7 @@ static void do_draw_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode) /* threaded loop over nodes */ #pragma omp parallel for schedule(guided) if (sd->flags & SCULPT_USE_OPENMP) - for(n=0; nflag |= ME_VERT_PBVH_UPDATE; } } @@ -1181,7 +1182,7 @@ static void do_crease_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnod /* we divide out the squared alpha and multiply by the squared crease to give us the pinch strength */ - if(brush_alpha(scene, brush) > 0.0f) + if (brush_alpha(scene, brush) > 0.0f) crease_correction = brush->crease_pinch_factor*brush->crease_pinch_factor/(brush_alpha(scene, brush)*brush_alpha(scene, brush)); else crease_correction = brush->crease_pinch_factor*brush->crease_pinch_factor; @@ -1189,11 +1190,11 @@ static void do_crease_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnod /* we always want crease to pinch or blob to relax even when draw is negative */ flippedbstrength = (bstrength < 0) ? -crease_correction*bstrength : crease_correction*bstrength; - if(brush->sculpt_tool == SCULPT_TOOL_BLOB) flippedbstrength *= -1.0f; + if (brush->sculpt_tool == SCULPT_TOOL_BLOB) flippedbstrength *= -1.0f; /* threaded loop over nodes */ #pragma omp parallel for schedule(guided) if (sd->flags & SCULPT_USE_OPENMP) - for(n=0; npbvh, nodes[n], vd, PBVH_ITER_UNIQUE) { - if(sculpt_brush_test(&test, vd.co)) { + if (sculpt_brush_test(&test, vd.co)) { /* offset vertex */ const float fade = tex_strength(ss, brush, vd.co, test.dist, area_normal, vd.no, vd.fno); @@ -1219,7 +1220,7 @@ static void do_crease_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnod add_v3_v3v3(proxy[vd.i], val1, val2); - if(vd.mvert) + if (vd.mvert) vd.mvert->flag |= ME_VERT_PBVH_UPDATE; } } @@ -1235,7 +1236,7 @@ static void do_pinch_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode int n; #pragma omp parallel for schedule(guided) if (sd->flags & SCULPT_USE_OPENMP) - for(n=0; npbvh, nodes[n], vd, PBVH_ITER_UNIQUE) { - if(sculpt_brush_test(&test, vd.co)) { + if (sculpt_brush_test(&test, vd.co)) { float fade = bstrength*tex_strength(ss, brush, vd.co, test.dist, ss->cache->view_normal, vd.no, vd.fno); float val[3]; @@ -1253,7 +1254,7 @@ static void do_pinch_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode sub_v3_v3v3(val, test.location, vd.co); mul_v3_v3fl(proxy[vd.i], val, fade); - if(vd.mvert) + if (vd.mvert) vd.mvert->flag |= ME_VERT_PBVH_UPDATE; } } @@ -1289,7 +1290,7 @@ static void do_grab_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode) } #pragma omp parallel for schedule(guided) if (sd->flags & SCULPT_USE_OPENMP) - for(n=0; npbvh, nodes[n], vd, PBVH_ITER_UNIQUE) { - if(sculpt_brush_test(&test, origco[vd.i])) { + if (sculpt_brush_test(&test, origco[vd.i])) { const float fade = bstrength*tex_strength(ss, brush, origco[vd.i], test.dist, an, origno[vd.i], NULL); mul_v3_v3fl(proxy[vd.i], grab_delta, fade); - if(vd.mvert) + if (vd.mvert) vd.mvert->flag |= ME_VERT_PBVH_UPDATE; } } @@ -1338,7 +1339,7 @@ static void do_nudge_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode cross_v3_v3v3(cono, tmp, an); #pragma omp parallel for schedule(guided) if (sd->flags & SCULPT_USE_OPENMP) - for(n = 0; n < totnode; n++) { + for (n = 0; n < totnode; n++) { PBVHVertexIter vd; SculptBrushTest test; float (*proxy)[3]; @@ -1348,13 +1349,13 @@ static void do_nudge_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode sculpt_brush_test_init(ss, &test); BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) { - if(sculpt_brush_test(&test, vd.co)) { + if (sculpt_brush_test(&test, vd.co)) { const float fade = bstrength*tex_strength(ss, brush, vd.co, test.dist, an, vd.no, vd.fno); mul_v3_v3fl(proxy[vd.i], cono, fade); - if(vd.mvert) + if (vd.mvert) vd.mvert->flag |= ME_VERT_PBVH_UPDATE; } } @@ -1388,7 +1389,7 @@ static void do_snake_hook_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int to } #pragma omp parallel for schedule(guided) if (sd->flags & SCULPT_USE_OPENMP) - for(n = 0; n < totnode; n++) { + for (n = 0; n < totnode; n++) { PBVHVertexIter vd; SculptBrushTest test; float (*proxy)[3]; @@ -1398,13 +1399,13 @@ static void do_snake_hook_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int to sculpt_brush_test_init(ss, &test); BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) { - if(sculpt_brush_test(&test, vd.co)) { + if (sculpt_brush_test(&test, vd.co)) { const float fade = bstrength*tex_strength(ss, brush, vd.co, test.dist, an, vd.no, vd.fno); mul_v3_v3fl(proxy[vd.i], grab_delta, fade); - if(vd.mvert) + if (vd.mvert) vd.mvert->flag |= ME_VERT_PBVH_UPDATE; } } @@ -1430,7 +1431,7 @@ static void do_thumb_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode cross_v3_v3v3(cono, tmp, an); #pragma omp parallel for schedule(guided) if (sd->flags & SCULPT_USE_OPENMP) - for(n = 0; n < totnode; n++) { + for (n = 0; n < totnode; n++) { PBVHVertexIter vd; SculptUndoNode* unode; SculptBrushTest test; @@ -1447,13 +1448,13 @@ static void do_thumb_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode sculpt_brush_test_init(ss, &test); BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) { - if(sculpt_brush_test(&test, origco[vd.i])) { + if (sculpt_brush_test(&test, origco[vd.i])) { const float fade = bstrength*tex_strength(ss, brush, origco[vd.i], test.dist, an, origno[vd.i], NULL); mul_v3_v3fl(proxy[vd.i], cono, fade); - if(vd.mvert) + if (vd.mvert) vd.mvert->flag |= ME_VERT_PBVH_UPDATE; } } @@ -1484,7 +1485,7 @@ static void do_rotate_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnod mul_serie_m4(m, lmat, rot, ilmat, NULL, NULL, NULL, NULL, NULL); #pragma omp parallel for schedule(guided) if (sd->flags & SCULPT_USE_OPENMP) - for(n=0; npbvh, nodes[n], vd, PBVH_ITER_UNIQUE) { - if(sculpt_brush_test(&test, origco[vd.i])) { + if (sculpt_brush_test(&test, origco[vd.i])) { const float fade = bstrength*tex_strength(ss, brush, origco[vd.i], test.dist, an, origno[vd.i], NULL); @@ -1509,7 +1510,7 @@ static void do_rotate_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnod sub_v3_v3(proxy[vd.i], origco[vd.i]); mul_v3_fl(proxy[vd.i], fade); - if(vd.mvert) + if (vd.mvert) vd.mvert->flag |= ME_VERT_PBVH_UPDATE; } } @@ -1526,7 +1527,7 @@ static void do_layer_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode float lim= brush->height; int n; - if(bstrength < 0) + if (bstrength < 0) lim = -lim; calc_sculpt_normal(sd, ob, area_normal, nodes, totnode); @@ -1534,7 +1535,7 @@ static void do_layer_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode mul_v3_v3v3(offset, ss->cache->scale, area_normal); #pragma omp parallel for schedule(guided) if (sd->flags & SCULPT_USE_OPENMP) - for(n=0; npbvh, nodes[n], vd, PBVH_ITER_UNIQUE) { - if(sculpt_brush_test(&test, origco[vd.i])) { + if (sculpt_brush_test(&test, origco[vd.i])) { const float fade = bstrength*tex_strength(ss, brush, vd.co, test.dist, area_normal, vd.no, vd.fno); float *disp= &layer_disp[vd.i]; @@ -1563,12 +1564,12 @@ static void do_layer_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode *disp+= fade; /* Don't let the displacement go past the limit */ - if((lim < 0 && *disp < lim) || (lim >= 0 && *disp > lim)) + if ((lim < 0 && *disp < lim) || (lim >= 0 && *disp > lim)) *disp = lim; mul_v3_v3fl(val, offset, *disp); - if(ss->layer_co && (brush->flag & BRUSH_PERSISTENT)) { + if (ss->layer_co && (brush->flag & BRUSH_PERSISTENT)) { int index= vd.vert_indices[vd.i]; /* persistent base */ @@ -1580,7 +1581,7 @@ static void do_layer_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode sculpt_clip(sd, ss, vd.co, val); - if(vd.mvert) + if (vd.mvert) vd.mvert->flag |= ME_VERT_PBVH_UPDATE; } } @@ -1596,7 +1597,7 @@ static void do_inflate_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totno int n; #pragma omp parallel for schedule(guided) if (sd->flags & SCULPT_USE_OPENMP) - for(n=0; npbvh, nodes[n], vd, PBVH_ITER_UNIQUE) { - if(sculpt_brush_test(&test, vd.co)) { + if (sculpt_brush_test(&test, vd.co)) { const float fade = bstrength*tex_strength(ss, brush, vd.co, test.dist, ss->cache->view_normal, vd.no, vd.fno); float val[3]; - if(vd.fno) copy_v3_v3(val, vd.fno); + if (vd.fno) copy_v3_v3(val, vd.fno); else normal_short_to_float_v3(val, vd.no); mul_v3_fl(val, fade * ss->cache->radius); mul_v3_v3v3(proxy[vd.i], val, ss->cache->scale); - if(vd.mvert) + if (vd.mvert) vd.mvert->flag |= ME_VERT_PBVH_UPDATE; } } @@ -1637,7 +1638,7 @@ static void calc_flatten_center(Sculpt *sd, Object *ob, PBVHNode **nodes, int to zero_v3(fc); #pragma omp parallel for schedule(guided) if (sd->flags & SCULPT_USE_OPENMP) - for(n=0; ncache->original) { + if (ss->cache->original) { BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) { - if(sculpt_brush_test_fast(&test, unode->co[vd.i])) { + if (sculpt_brush_test_fast(&test, unode->co[vd.i])) { add_v3_v3(private_fc, unode->co[vd.i]); private_count++; } @@ -1658,7 +1659,7 @@ static void calc_flatten_center(Sculpt *sd, Object *ob, PBVHNode **nodes, int to } else { BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) { - if(sculpt_brush_test_fast(&test, vd.co)) { + if (sculpt_brush_test_fast(&test, vd.co)) { add_v3_v3(private_fc, vd.co); private_count++; } @@ -1700,7 +1701,7 @@ static void calc_area_normal_and_flatten_center(Sculpt *sd, Object *ob, zero_v3(fc); #pragma omp parallel for schedule(guided) if (sd->flags & SCULPT_USE_OPENMP) - for(n=0; ncache->original) { + if (ss->cache->original) { BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) { - if(sculpt_brush_test_fast(&test, unode->co[vd.i])) { + if (sculpt_brush_test_fast(&test, unode->co[vd.i])) { /* for area normal */ float fno[3]; @@ -1730,9 +1731,9 @@ static void calc_area_normal_and_flatten_center(Sculpt *sd, Object *ob, } else { BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) { - if(sculpt_brush_test_fast(&test, vd.co)) { + if (sculpt_brush_test_fast(&test, vd.co)) { /* for area normal */ - if(vd.no) { + if (vd.no) { float fno[3]; normal_short_to_float_v3(fno, vd.no); @@ -1923,7 +1924,7 @@ static void do_flatten_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totno add_v3_v3(fc, temp); #pragma omp parallel for schedule(guided) if (sd->flags & SCULPT_USE_OPENMP) - for(n = 0; n < totnode; n++) { + for (n = 0; n < totnode; n++) { PBVHVertexIter vd; SculptBrushTest test; float (*proxy)[3]; @@ -1947,7 +1948,7 @@ static void do_flatten_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totno mul_v3_v3fl(proxy[vd.i], val, fade); - if(vd.mvert) + if (vd.mvert) vd.mvert->flag |= ME_VERT_PBVH_UPDATE; } } @@ -2020,7 +2021,7 @@ static void do_clay_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode) mul_v3_v3fl(proxy[vd.i], val, fade); - if(vd.mvert) + if (vd.mvert) vd.mvert->flag |= ME_VERT_PBVH_UPDATE; } } @@ -2121,7 +2122,7 @@ static void do_clay_strips_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int t mul_v3_v3fl(proxy[vd.i], val, fade); - if(vd.mvert) + if (vd.mvert) vd.mvert->flag |= ME_VERT_PBVH_UPDATE; } } @@ -2184,7 +2185,7 @@ static void do_fill_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode) mul_v3_v3fl(proxy[vd.i], val, fade); - if(vd.mvert) + if (vd.mvert) vd.mvert->flag |= ME_VERT_PBVH_UPDATE; } } @@ -2247,7 +2248,7 @@ static void do_scrape_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnod mul_v3_v3fl(proxy[vd.i], val, fade); - if(vd.mvert) + if (vd.mvert) vd.mvert->flag |= ME_VERT_PBVH_UPDATE; } } @@ -2267,7 +2268,7 @@ void sculpt_vertcos_to_key(Object *ob, KeyBlock *kb, float (*vertCos)[3]) /* for relative keys editing of base should update other keys */ if (me->key->type == KEY_RELATIVE) for (currkey = me->key->block.first; currkey; currkey= currkey->next) - if(ob->shapenr-1 == currkey->relative) { + if (ob->shapenr-1 == currkey->relative) { is_basis= 1; break; } @@ -2331,7 +2332,7 @@ static void do_brush_action(Sculpt *sd, Object *ob, Brush *brush) } /* Apply one type of brush action */ - switch(brush->sculpt_tool){ + switch(brush->sculpt_tool) { case SCULPT_TOOL_DRAW: do_draw_brush(sd, ob, nodes, totnode); break; @@ -2413,7 +2414,7 @@ static void sculpt_flush_pbvhvert_deform(Object *ob, PBVHVertexIter *vd) copy_v3_v3(ss->deform_cos[index], vd->co); copy_v3_v3(ss->orig_cos[index], newco); - if(!ss->kb) + if (!ss->kb) copy_v3_v3(me->mvert[index].co, newco); } @@ -2426,7 +2427,7 @@ static void sculpt_combine_proxies(Sculpt *sd, Object *ob) BLI_pbvh_gather_proxies(ss->pbvh, &nodes, &totnode); - if(!ELEM(brush->sculpt_tool, SCULPT_TOOL_SMOOTH, SCULPT_TOOL_LAYER)) { + if (!ELEM(brush->sculpt_tool, SCULPT_TOOL_SMOOTH, SCULPT_TOOL_LAYER)) { /* these brushes start from original coordinates */ const int use_orco = (ELEM3(brush->sculpt_tool, SCULPT_TOOL_GRAB, SCULPT_TOOL_ROTATE, SCULPT_TOOL_THUMB)); @@ -2438,7 +2439,7 @@ static void sculpt_combine_proxies(Sculpt *sd, Object *ob) int proxy_count; float (*orco)[3]; - if(use_orco) + if (use_orco) orco= sculpt_undo_push_node(ob, nodes[n], SCULPT_UNDO_COORDS)->co; BLI_pbvh_node_get_proxies(nodes[n], &proxies, &proxy_count); @@ -2447,7 +2448,7 @@ static void sculpt_combine_proxies(Sculpt *sd, Object *ob) float val[3]; int p; - if(use_orco) + if (use_orco) copy_v3_v3(val, orco[vd.i]); else copy_v3_v3(val, vd.co); @@ -2457,7 +2458,7 @@ static void sculpt_combine_proxies(Sculpt *sd, Object *ob) sculpt_clip(sd, ss, vd.co, val); - if(ss->modifiers_active) + if (ss->modifiers_active) sculpt_flush_pbvhvert_deform(ob, &vd); } BLI_pbvh_vertex_iter_end; @@ -2478,13 +2479,13 @@ static void sculpt_update_keyblock(Object *ob) /* Keyblock update happens after hadning deformation caused by modifiers, * so ss->orig_cos would be updated with new stroke */ - if(ss->orig_cos) vertCos = ss->orig_cos; + if (ss->orig_cos) vertCos = ss->orig_cos; else vertCos = BLI_pbvh_get_vertCos(ss->pbvh); if (vertCos) { sculpt_vertcos_to_key(ob, ss->kb, vertCos); - if(vertCos != ss->orig_cos) + if (vertCos != ss->orig_cos) MEM_freeN(vertCos); } } @@ -2495,7 +2496,7 @@ static void sculpt_flush_stroke_deform(Sculpt *sd, Object *ob) SculptSession *ss = ob->sculpt; Brush *brush= paint_brush(&sd->paint); - if(ELEM(brush->sculpt_tool, SCULPT_TOOL_SMOOTH, SCULPT_TOOL_LAYER)) { + if (ELEM(brush->sculpt_tool, SCULPT_TOOL_SMOOTH, SCULPT_TOOL_LAYER)) { /* this brushes aren't using proxies, so sculpt_combine_proxies() wouldn't * propagate needed deformation to original base */ @@ -2504,7 +2505,7 @@ static void sculpt_flush_stroke_deform(Sculpt *sd, Object *ob) PBVHNode** nodes; float (*vertCos)[3]= NULL; - if(ss->kb) + if (ss->kb) vertCos= MEM_callocN(sizeof(*vertCos)*me->totvert, "flushStrokeDeofrm keyVerts"); BLI_pbvh_search_gather(ss->pbvh, NULL, NULL, &nodes, &totnode); @@ -2516,7 +2517,7 @@ static void sculpt_flush_stroke_deform(Sculpt *sd, Object *ob) BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) { sculpt_flush_pbvhvert_deform(ob, &vd); - if(vertCos) { + if (vertCos) { int index= vd.vert_indices[vd.i]; copy_v3_v3(vertCos[index], ss->orig_cos[index]); } @@ -2524,7 +2525,7 @@ static void sculpt_flush_stroke_deform(Sculpt *sd, Object *ob) BLI_pbvh_vertex_iter_end; } - if(vertCos) { + if (vertCos) { sculpt_vertcos_to_key(ob, ss->kb, vertCos); MEM_freeN(vertCos); } @@ -2535,8 +2536,10 @@ static void sculpt_flush_stroke_deform(Sculpt *sd, Object *ob) * Note, then if sculpting happens on locked key, normals should be re-calculated * after applying coords from keyblock on base mesh */ mesh_calc_normals(me->mvert, me->totvert, me->mloop, me->mpoly, me->totloop, me->totpoly, NULL); - } else if (ss->kb) + } + else if (ss->kb) { sculpt_update_keyblock(ob); + } } /* Flip all the editdata across the axis/axes specified by symm. Used to @@ -2566,7 +2569,7 @@ static void calc_brushdata_symm(Sculpt *sd, StrokeCache *cache, const char symm, unit_m4(cache->symm_rot_mat); unit_m4(cache->symm_rot_mat_inv); - if(axis) { /* expects XYZ */ + if (axis) { /* expects XYZ */ rotate_m4(cache->symm_rot_mat, axis, angle); rotate_m4(cache->symm_rot_mat_inv, axis, -angle); } @@ -2582,7 +2585,7 @@ static void do_radial_symmetry(Sculpt *sd, Object *ob, Brush *brush, SculptSession *ss = ob->sculpt; int i; - for(i = 1; i < sd->radial_symm[axis-'X']; ++i) { + for (i = 1; i < sd->radial_symm[axis-'X']; ++i) { const float angle = 2*M_PI*i/sd->radial_symm[axis-'X']; ss->cache->radial_symmetry_pass= i; calc_brushdata_symm(sd, ss->cache, symm, axis, angle, feather); @@ -2599,7 +2602,7 @@ static void sculpt_fix_noise_tear(Sculpt *sd, Object *ob) Brush *brush = paint_brush(&sd->paint); MTex *mtex = &brush->mtex; - if(ss->multires && mtex->tex && mtex->tex->type == TEX_NOISE) + if (ss->multires && mtex->tex && mtex->tex->type == TEX_NOISE) multires_stitch_grids(ob); } @@ -2618,8 +2621,8 @@ static void do_symmetrical_brush_actions(Sculpt *sd, Object *ob) cache->symmetry= symm; /* symm is a bit combination of XYZ - 1 is mirror X; 2 is Y; 3 is XY; 4 is Z; 5 is XZ; 6 is YZ; 7 is XYZ */ - for(i = 0; i <= symm; ++i) { - if(i == 0 || (symm & i && (symm != 5 || i != 3) && (symm != 6 || (i != 3 && i != 5)))) { + for (i = 0; i <= symm; ++i) { + if (i == 0 || (symm & i && (symm != 5 || i != 3) && (symm != 6 || (i != 3 && i != 5)))) { cache->mirror_symmetry_pass= i; cache->radial_symmetry_pass= 0; @@ -2648,14 +2651,14 @@ static void sculpt_update_tex(const Scene *scene, Sculpt *sd, SculptSession *ss) Brush *brush = paint_brush(&sd->paint); const int radius= brush_size(scene, brush); - if(ss->texcache) { + if (ss->texcache) { MEM_freeN(ss->texcache); ss->texcache= NULL; } /* Need to allocate a bigger buffer for bigger brush size */ ss->texcache_side = 2*radius; - if(!ss->texcache || ss->texcache_side > ss->texcache_actual) { + if (!ss->texcache || ss->texcache_side > ss->texcache_actual) { ss->texcache = brush_gen_texture_cache(brush, radius); ss->texcache_actual = ss->texcache_side; } @@ -2669,10 +2672,10 @@ void sculpt_update_mesh_elements(Scene *scene, Sculpt *sd, Object *ob, int need_ ss->modifiers_active= sculpt_modifiers_active(scene, sd, ob); - if(!mmd) ss->kb= ob_get_keyblock(ob); + if (!mmd) ss->kb= ob_get_keyblock(ob); else ss->kb= NULL; - if(mmd) { + if (mmd) { ss->multires = mmd; ss->totvert = dm->getNumVerts(dm); ss->totpoly = dm->getNumPolys(dm); @@ -2698,22 +2701,23 @@ void sculpt_update_mesh_elements(Scene *scene, Sculpt *sd, Object *ob, int need_ ss->pbvh = dm->getPBVH(ob, dm); ss->pmap = (need_pmap && dm->getPolyMap)? dm->getPolyMap(ob, dm): NULL; - if(ss->modifiers_active) { - if(!ss->orig_cos) { + if (ss->modifiers_active) { + if (!ss->orig_cos) { int a; free_sculptsession_deformMats(ss); - if(ss->kb) ss->orig_cos = key_to_vertcos(ob, ss->kb); + if (ss->kb) ss->orig_cos = key_to_vertcos(ob, ss->kb); else ss->orig_cos = mesh_getVertexCos(ob->data, NULL); crazyspace_build_sculpt(scene, ob, &ss->deform_imats, &ss->deform_cos); BLI_pbvh_apply_vertCos(ss->pbvh, ss->deform_cos); - for(a = 0; a < ((Mesh*)ob->data)->totvert; ++a) + for (a = 0; a < ((Mesh*)ob->data)->totvert; ++a) invert_m3(ss->deform_imats[a]); } - } else free_sculptsession_deformMats(ss); + } + else free_sculptsession_deformMats(ss); /* if pbvh is deformed, key block is already applied to it */ if (ss->kb && !BLI_pbvh_isDeformed(ss->pbvh)) { @@ -2784,7 +2788,7 @@ static const char *sculpt_tool_name(Sculpt *sd) static void sculpt_cache_free(StrokeCache *cache) { - if(cache->face_norms) + if (cache->face_norms) MEM_freeN(cache->face_norms); MEM_freeN(cache); } @@ -2795,20 +2799,20 @@ static void sculpt_init_mirror_clipping(Object *ob, SculptSession *ss) ModifierData *md; int i; - for(md= ob->modifiers.first; md; md= md->next) { - if(md->type==eModifierType_Mirror && + for (md= ob->modifiers.first; md; md= md->next) { + if (md->type==eModifierType_Mirror && (md->mode & eModifierMode_Realtime)) { MirrorModifierData *mmd = (MirrorModifierData*)md; - if(mmd->flag & MOD_MIR_CLIPPING) { + if (mmd->flag & MOD_MIR_CLIPPING) { /* check each axis for mirroring */ - for(i = 0; i < 3; ++i) { - if(mmd->flag & (MOD_MIR_AXIS_X << i)) { + for (i = 0; i < 3; ++i) { + if (mmd->flag & (MOD_MIR_AXIS_X << i)) { /* enable sculpt clipping */ ss->cache->flag |= CLIP_X << i; /* update the clip tolerance */ - if(mmd->tolerance > + if (mmd->tolerance > ss->cache->clip_tolerance[i]) ss->cache->clip_tolerance[i] = mmd->tolerance; @@ -2858,7 +2862,7 @@ static void sculpt_update_cache_invariants(bContext* C, Sculpt *sd, SculptSessio /* not very nice, but with current events system implementation * we can't handle brush appearance inversion hotkey separately (sergey) */ - if(cache->invert) brush->flag |= BRUSH_INVERTED; + if (cache->invert) brush->flag |= BRUSH_INVERTED; else brush->flag &= ~BRUSH_INVERTED; /* Alt-Smooth */ @@ -2869,7 +2873,7 @@ static void sculpt_update_cache_invariants(bContext* C, Sculpt *sd, SculptSessio BLI_strncpy(cache->saved_active_brush_name, brush->id.name+2, sizeof(cache->saved_active_brush_name)); br= (Brush *)find_id("BR", "Smooth"); - if(br) { + if (br) { paint_brush_set(p, br); brush = br; } @@ -2889,16 +2893,16 @@ static void sculpt_update_cache_invariants(bContext* C, Sculpt *sd, SculptSessio ED_view3d_global_to_vector(cache->vc->rv3d, cache->vc->rv3d->twmat[3], cache->true_view_normal); /* Initialize layer brush displacements and persistent coords */ - if(brush->sculpt_tool == SCULPT_TOOL_LAYER) { + if (brush->sculpt_tool == SCULPT_TOOL_LAYER) { /* not supported yet for multires */ - if(!ss->multires && !ss->layer_co && (brush->flag & BRUSH_PERSISTENT)) { - if(!ss->layer_co) + if (!ss->multires && !ss->layer_co && (brush->flag & BRUSH_PERSISTENT)) { + if (!ss->layer_co) ss->layer_co= MEM_mallocN(sizeof(float) * 3 * ss->totvert, "sculpt mesh vertices copy"); - if(ss->deform_cos) memcpy(ss->layer_co, ss->deform_cos, ss->totvert); + if (ss->deform_cos) memcpy(ss->layer_co, ss->deform_cos, ss->totvert); else { - for(i = 0; i < ss->totvert; ++i) { + for (i = 0; i < ss->totvert; ++i) { copy_v3_v3(ss->layer_co[i], ss->mvert[i].co); } } @@ -2906,22 +2910,22 @@ static void sculpt_update_cache_invariants(bContext* C, Sculpt *sd, SculptSessio } /* Make copies of the mesh vertex locations and normals for some tools */ - if(brush->flag & BRUSH_ANCHORED) { - if(ss->face_normals) { + if (brush->flag & BRUSH_ANCHORED) { + if (ss->face_normals) { float *fn = ss->face_normals; cache->face_norms= MEM_mallocN(sizeof(float) * 3 * ss->totpoly, "Sculpt face norms"); - for(i = 0; i < ss->totpoly; ++i, fn += 3) + for (i = 0; i < ss->totpoly; ++i, fn += 3) copy_v3_v3(cache->face_norms[i], fn); } cache->original = 1; } - if(ELEM8(brush->sculpt_tool, + if (ELEM8(brush->sculpt_tool, SCULPT_TOOL_DRAW, SCULPT_TOOL_CREASE, SCULPT_TOOL_BLOB, SCULPT_TOOL_LAYER, SCULPT_TOOL_INFLATE, SCULPT_TOOL_CLAY, SCULPT_TOOL_CLAY_STRIPS, SCULPT_TOOL_ROTATE)) - if(!(brush->flag & BRUSH_ACCUMULATE)) + if (!(brush->flag & BRUSH_ACCUMULATE)) cache->original = 1; cache->special_rotation = (brush->flag & BRUSH_RAKE) ? sd->last_angle : 0; @@ -2941,17 +2945,17 @@ static void sculpt_update_brush_delta(Sculpt *sd, Object *ob, Brush *brush) }; int tool = brush->sculpt_tool; - if(ELEM5(tool, + if (ELEM5(tool, SCULPT_TOOL_GRAB, SCULPT_TOOL_NUDGE, SCULPT_TOOL_CLAY_STRIPS, SCULPT_TOOL_SNAKE_HOOK, SCULPT_TOOL_THUMB)) { float grab_location[3], imat[4][4], delta[3], loc[3]; - if(cache->first_time) { + if (cache->first_time) { copy_v3_v3(cache->orig_grab_location, cache->true_location); } - else if(tool == SCULPT_TOOL_SNAKE_HOOK) + else if (tool == SCULPT_TOOL_SNAKE_HOOK) add_v3_v3(cache->true_location, cache->grab_delta); /* compute 3d coordinate at same z from original location + mouse */ @@ -2961,7 +2965,7 @@ static void sculpt_update_brush_delta(Sculpt *sd, Object *ob, Brush *brush) ED_view3d_win_to_3d(cache->vc->ar, loc, mouse, grab_location); /* compute delta to move verts by */ - if(!cache->first_time) { + if (!cache->first_time) { switch(tool) { case SCULPT_TOOL_GRAB: case SCULPT_TOOL_THUMB: @@ -2973,7 +2977,7 @@ static void sculpt_update_brush_delta(Sculpt *sd, Object *ob, Brush *brush) case SCULPT_TOOL_CLAY_STRIPS: case SCULPT_TOOL_NUDGE: case SCULPT_TOOL_SNAKE_HOOK: - if(brush->flag & BRUSH_ANCHORED) { + if (brush->flag & BRUSH_ANCHORED) { float orig[3]; mul_v3_m4v3(orig, ob->obmat, cache->orig_grab_location); sub_v3_v3v3(cache->grab_delta, grab_location, orig); @@ -2994,12 +2998,12 @@ static void sculpt_update_brush_delta(Sculpt *sd, Object *ob, Brush *brush) copy_v3_v3(cache->old_grab_location, grab_location); - if(tool == SCULPT_TOOL_GRAB) + if (tool == SCULPT_TOOL_GRAB) copy_v3_v3(sd->anchored_location, cache->true_location); - else if(tool == SCULPT_TOOL_THUMB) + else if (tool == SCULPT_TOOL_THUMB) copy_v3_v3(sd->anchored_location, cache->orig_grab_location); - if(ELEM(tool, SCULPT_TOOL_GRAB, SCULPT_TOOL_THUMB)) { + if (ELEM(tool, SCULPT_TOOL_GRAB, SCULPT_TOOL_THUMB)) { /* location stays the same for finding vertices in brush radius */ copy_v3_v3(cache->true_location, cache->orig_grab_location); @@ -3041,7 +3045,7 @@ static void sculpt_update_cache_variants(bContext *C, Sculpt *sd, Object *ob, * brush coord/pressure/etc. * It's more an events design issue, which doesn't split coordinate/pressure/angle * changing events. We should avoid this after events system re-design */ - if(paint_space_stroke_enabled(brush) || cache->first_time) + if (paint_space_stroke_enabled(brush) || cache->first_time) cache->pressure = RNA_float_get(ptr, "pressure"); /* Truly temporary data that isn't stored in properties */ @@ -3052,7 +3056,7 @@ static void sculpt_update_cache_variants(bContext *C, Sculpt *sd, Object *ob, cache->previous_pixel_radius = cache->pixel_radius; cache->pixel_radius = brush_size(scene, brush); - if(cache->first_time) { + if (cache->first_time) { if (!brush_use_locked_size(scene, brush)) { cache->initial_radius= paint_calc_object_space_radius(cache->vc, cache->true_location, brush_size(scene, brush)); brush_set_unprojected_radius(scene, brush, cache->initial_radius); @@ -3062,7 +3066,7 @@ static void sculpt_update_cache_variants(bContext *C, Sculpt *sd, Object *ob, } } - if(brush_use_size_pressure(scene, brush)) { + if (brush_use_size_pressure(scene, brush)) { cache->pixel_radius *= cache->pressure; cache->radius= cache->initial_radius * cache->pressure; } @@ -3071,7 +3075,7 @@ static void sculpt_update_cache_variants(bContext *C, Sculpt *sd, Object *ob, cache->radius_squared = cache->radius*cache->radius; - if(!(brush->flag & BRUSH_ANCHORED || + if (!(brush->flag & BRUSH_ANCHORED || ELEM4(brush->sculpt_tool, SCULPT_TOOL_GRAB, SCULPT_TOOL_SNAKE_HOOK, SCULPT_TOOL_THUMB, SCULPT_TOOL_ROTATE))) { copy_v2_v2(cache->tex_mouse, cache->mouse); @@ -3084,7 +3088,7 @@ static void sculpt_update_cache_variants(bContext *C, Sculpt *sd, Object *ob, } } - if(brush->flag & BRUSH_ANCHORED) { + if (brush->flag & BRUSH_ANCHORED) { int hit = 0; dx = cache->mouse[0] - cache->initial_mouse[0]; @@ -3124,7 +3128,7 @@ static void sculpt_update_cache_variants(bContext *C, Sculpt *sd, Object *ob, sd->draw_anchored = 1; } - else if(brush->flag & BRUSH_RAKE) { + else if (brush->flag & BRUSH_RAKE) { const float u = 0.5f; const float v = 1 - u; const float r = 20; @@ -3145,7 +3149,7 @@ static void sculpt_update_cache_variants(bContext *C, Sculpt *sd, Object *ob, sculpt_update_brush_delta(sd, ob, brush); - if(brush->sculpt_tool == SCULPT_TOOL_ROTATE) { + if (brush->sculpt_tool == SCULPT_TOOL_ROTATE) { dx = cache->mouse[0] - cache->initial_mouse[0]; dy = cache->mouse[1] - cache->initial_mouse[1]; @@ -3164,7 +3168,7 @@ static void sculpt_stroke_modifiers_check(bContext *C, Object *ob) { SculptSession *ss = ob->sculpt; - if(ss->modifiers_active) { + if (ss->modifiers_active) { Sculpt *sd = CTX_data_tool_settings(C)->sculpt; Brush *brush = paint_brush(&sd->paint); @@ -3186,7 +3190,7 @@ static void sculpt_raycast_cb(PBVHNode *node, void *data_v, float* tmin) SculptRaycastData *srd = data_v; float (*origco)[3]= NULL; - if(srd->original && srd->ss->cache) { + if (srd->original && srd->ss->cache) { /* intersect with coordinates from before we started stroke */ SculptUndoNode *unode= sculpt_undo_get_node(node); origco= (unode)? unode->co: NULL; @@ -3256,7 +3260,7 @@ static void sculpt_brush_init_tex(const Scene *scene, Sculpt *sd, SculptSession MTex *mtex= &brush->mtex; /* init mtex nodes */ - if(mtex->tex && mtex->tex->nodetree) + if (mtex->tex && mtex->tex->nodetree) ntreeTexBeginExecTree(mtex->tex->nodetree, 1); /* has internal flag to detect it only does it once */ /* TODO: Shouldn't really have to do this at the start of every @@ -3291,7 +3295,7 @@ static void sculpt_restore_mesh(Sculpt *sd, SculptSession *ss) Brush *brush = paint_brush(&sd->paint); /* Restore the mesh before continuing with anchored stroke */ - if((brush->flag & BRUSH_ANCHORED) || + if ((brush->flag & BRUSH_ANCHORED) || (brush->sculpt_tool == SCULPT_TOOL_GRAB && brush_use_size_pressure(ss->cache->vc->scene, brush)) || (brush->flag & BRUSH_RESTORE_MESH)) @@ -3305,19 +3309,19 @@ static void sculpt_restore_mesh(Sculpt *sd, SculptSession *ss) BLI_pbvh_search_gather(ss->pbvh, NULL, NULL, &nodes, &totnode); #pragma omp parallel for schedule(guided) if (sd->flags & SCULPT_USE_OPENMP) - for(n=0; npbvh, nodes[n], vd, PBVH_ITER_UNIQUE) { copy_v3_v3(vd.co, unode->co[vd.i]); - if(vd.no) copy_v3_v3_short(vd.no, unode->no[vd.i]); + if (vd.no) copy_v3_v3_short(vd.no, unode->no[vd.i]); else normal_short_to_float_v3(vd.fno, unode->no[vd.i]); - if(vd.mvert) vd.mvert->flag |= ME_VERT_PBVH_UPDATE; + if (vd.mvert) vd.mvert->flag |= ME_VERT_PBVH_UPDATE; } BLI_pbvh_vertex_iter_end; @@ -3325,13 +3329,13 @@ static void sculpt_restore_mesh(Sculpt *sd, SculptSession *ss) } } - if(ss->face_normals) { + if (ss->face_normals) { float *fn = ss->face_normals; - for(i = 0; i < ss->totpoly; ++i, fn += 3) + for (i = 0; i < ss->totpoly; ++i, fn += 3) copy_v3_v3(fn, cache->face_norms[i]); } - if(nodes) + if (nodes) MEM_freeN(nodes); } } @@ -3343,12 +3347,12 @@ static void sculpt_flush_update(bContext *C) ARegion *ar = CTX_wm_region(C); MultiresModifierData *mmd = ss->multires; - if(mmd) + if (mmd) multires_mark_as_modified(ob, MULTIRES_COORDS_MODIFIED); - if(ob->derivedFinal) /* VBO no longer valid */ + if (ob->derivedFinal) /* VBO no longer valid */ GPU_drawobject_free(ob->derivedFinal); - if(ss->modifiers_active) { + if (ss->modifiers_active) { DAG_id_tag_update(&ob->id, OB_RECALC_DATA); ED_region_tag_redraw(ar); } @@ -3388,7 +3392,7 @@ static int sculpt_stroke_test_start(bContext *C, struct wmOperator *op, { /* Don't start the stroke until mouse goes over the mesh. * note: event will only be null when re-executing the saved stroke. */ - if(event==NULL || over_mesh(C, op, event->x, event->y)) { + if (event==NULL || over_mesh(C, op, event->x, event->y)) { Object *ob = CTX_data_active_object(C); SculptSession *ss = ob->sculpt; Sculpt *sd = CTX_data_tool_settings(C)->sculpt; @@ -3438,7 +3442,7 @@ static void sculpt_brush_exit_tex(Sculpt *sd) Brush *brush= paint_brush(&sd->paint); MTex *mtex= &brush->mtex; - if(mtex->tex && mtex->tex->nodetree) + if (mtex->tex && mtex->tex->nodetree) ntreeTexEndExecTree(mtex->tex->nodetree->execdata, 1); } @@ -3454,7 +3458,7 @@ static void sculpt_stroke_done(bContext *C, struct PaintStroke *UNUSED(stroke)) sd->special_rotation= 0; /* Finished */ - if(ss->cache) { + if (ss->cache) { Brush *brush= paint_brush(&sd->paint); brush->flag &= ~BRUSH_INVERTED; @@ -3464,7 +3468,7 @@ static void sculpt_stroke_done(bContext *C, struct PaintStroke *UNUSED(stroke)) if (ss->cache->alt_smooth) { Paint *p= &sd->paint; brush= (Brush *)find_id("BR", ss->cache->saved_active_brush_name); - if(brush) { + if (brush) { paint_brush_set(p, brush); } } @@ -3479,12 +3483,12 @@ static void sculpt_stroke_done(bContext *C, struct PaintStroke *UNUSED(stroke)) /* optimization: if there is locked key and active modifiers present in */ /* the stack, keyblock is updating at each step. otherwise we could update */ /* keyblock only when stroke is finished */ - if(ss->kb && !ss->modifiers_active) sculpt_update_keyblock(ob); + if (ss->kb && !ss->modifiers_active) sculpt_update_keyblock(ob); ss->partial_redraw = 0; /* try to avoid calling this, only for e.g. linked duplicates now */ - if(((Mesh*)ob->data)->id.us > 1) + if (((Mesh*)ob->data)->id.us > 1) DAG_id_tag_update(&ob->id, OB_RECALC_DATA); WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob); @@ -3498,7 +3502,7 @@ static int sculpt_brush_stroke_invoke(bContext *C, wmOperator *op, wmEvent *even struct PaintStroke *stroke; int ignore_background_click; - if(!sculpt_brush_stroke_init(C, op)) + if (!sculpt_brush_stroke_init(C, op)) return OPERATOR_CANCELLED; stroke = paint_stroke_new(C, sculpt_stroke_get_location, @@ -3512,7 +3516,7 @@ static int sculpt_brush_stroke_invoke(bContext *C, wmOperator *op, wmEvent *even ignore_background_click = RNA_boolean_get(op->ptr, "ignore_background_click"); - if(ignore_background_click && !over_mesh(C, op, event->x, event->y)) { + if (ignore_background_click && !over_mesh(C, op, event->x, event->y)) { paint_stroke_free(stroke); return OPERATOR_PASS_THROUGH; } @@ -3527,7 +3531,7 @@ static int sculpt_brush_stroke_invoke(bContext *C, wmOperator *op, wmEvent *even static int sculpt_brush_stroke_exec(bContext *C, wmOperator *op) { - if(!sculpt_brush_stroke_init(C, op)) + if (!sculpt_brush_stroke_init(C, op)) return OPERATOR_CANCELLED; op->customdata = paint_stroke_new(C, sculpt_stroke_get_location, sculpt_stroke_test_start, @@ -3547,7 +3551,7 @@ static int sculpt_brush_stroke_cancel(bContext *C, wmOperator *op) paint_stroke_cancel(C, op); - if(ss->cache) { + if (ss->cache) { sculpt_cache_free(ss->cache); ss->cache = NULL; } @@ -3600,8 +3604,8 @@ static int sculpt_set_persistent_base(bContext *C, wmOperator *UNUSED(op)) { SculptSession *ss = CTX_data_active_object(C)->sculpt; - if(ss) { - if(ss->layer_co) + if (ss) { + if (ss->layer_co) MEM_freeN(ss->layer_co); ss->layer_co = NULL; } @@ -3644,11 +3648,11 @@ static int sculpt_toggle_mode(bContext *C, wmOperator *UNUSED(op)) /* if object has got active modifiers, it's dm could be different in sculpt mode */ flush_recalc |= sculpt_has_active_modifiers(scene, ob); - if(ob->mode & OB_MODE_SCULPT) { - if(mmd) + if (ob->mode & OB_MODE_SCULPT) { + if (mmd) multires_force_update(ob); - if(flush_recalc) + if (flush_recalc) DAG_id_tag_update(&ob->id, OB_RECALC_DATA); /* Leave sculptmode */ @@ -3660,11 +3664,11 @@ static int sculpt_toggle_mode(bContext *C, wmOperator *UNUSED(op)) /* Enter sculptmode */ ob->mode |= OB_MODE_SCULPT; - if(flush_recalc) + if (flush_recalc) DAG_id_tag_update(&ob->id, OB_RECALC_DATA); /* Create persistent sculpt mode data */ - if(!ts->sculpt) { + if (!ts->sculpt) { ts->sculpt = MEM_callocN(sizeof(Sculpt), "sculpt mode data"); /* Turn on X plane mirror symmetry by default */ @@ -3672,7 +3676,7 @@ static int sculpt_toggle_mode(bContext *C, wmOperator *UNUSED(op)) } /* Create sculpt mode session data */ - if(ob->sculpt) + if (ob->sculpt) free_sculptsession(ob); sculpt_init_session(scene, ob); diff --git a/source/blender/editors/sculpt_paint/sculpt_undo.c b/source/blender/editors/sculpt_paint/sculpt_undo.c index a130245d6d7..73fa546b357 100644 --- a/source/blender/editors/sculpt_paint/sculpt_undo.c +++ b/source/blender/editors/sculpt_paint/sculpt_undo.c @@ -71,17 +71,20 @@ static void update_cb(PBVHNode *node, void *rebuild) { BLI_pbvh_node_mark_update(node); - if(*((int*)rebuild)) + if (*((int*)rebuild)) BLI_pbvh_node_mark_rebuild_draw(node); BLI_pbvh_node_fully_hidden_set(node, 0); } static void sculpt_undo_restore_deformed(SculptSession *ss, SculptUndoNode *unode, int uindex, int oindex, float coord[3]) { - if(unode->orig_co) { + if (unode->orig_co) { swap_v3_v3(coord, unode->orig_co[uindex]); copy_v3_v3(unode->co[uindex], ss->deform_cos[oindex]); - } else swap_v3_v3(coord, unode->co[uindex]); + } + else { + swap_v3_v3(coord, unode->co[uindex]); + } } static int sculpt_undo_restore_coords(bContext *C, DerivedMesh *dm, SculptUndoNode *unode) @@ -93,7 +96,7 @@ static int sculpt_undo_restore_coords(bContext *C, DerivedMesh *dm, SculptUndoNo MVert *mvert; int *index, i, j; - if(unode->maxvert) { + if (unode->maxvert) { /* regular mesh restore */ if (ss->kb && strcmp(ss->kb->name, unode->shapeName)) { @@ -107,7 +110,8 @@ static int sculpt_undo_restore_coords(bContext *C, DerivedMesh *dm, SculptUndoNo sculpt_update_mesh_elements(scene, sd, ob, 0); WM_event_add_notifier(C, NC_OBJECT|ND_DATA, ob); - } else { + } + else { /* key has been removed -- skip this undo node */ return 0; } @@ -120,10 +124,10 @@ static int sculpt_undo_restore_coords(bContext *C, DerivedMesh *dm, SculptUndoNo float (*vertCos)[3]; vertCos= key_to_vertcos(ob, ss->kb); - for(i=0; itotvert; i++) { - if(ss->modifiers_active) sculpt_undo_restore_deformed(ss, unode, i, index[i], vertCos[index[i]]); + for (i=0; itotvert; i++) { + if (ss->modifiers_active) sculpt_undo_restore_deformed(ss, unode, i, index[i], vertCos[index[i]]); else { - if(unode->orig_co) swap_v3_v3(vertCos[index[i]], unode->orig_co[i]); + if (unode->orig_co) swap_v3_v3(vertCos[index[i]], unode->orig_co[i]); else swap_v3_v3(vertCos[index[i]], unode->co[i]); } } @@ -136,18 +140,19 @@ static int sculpt_undo_restore_coords(bContext *C, DerivedMesh *dm, SculptUndoNo BLI_pbvh_apply_vertCos(ss->pbvh, vertCos); MEM_freeN(vertCos); - } else { - for(i=0; itotvert; i++) { - if(ss->modifiers_active) sculpt_undo_restore_deformed(ss, unode, i, index[i], mvert[index[i]].co); + } + else { + for (i=0; itotvert; i++) { + if (ss->modifiers_active) sculpt_undo_restore_deformed(ss, unode, i, index[i], mvert[index[i]].co); else { - if(unode->orig_co) swap_v3_v3(mvert[index[i]].co, unode->orig_co[i]); + if (unode->orig_co) swap_v3_v3(mvert[index[i]].co, unode->orig_co[i]); else swap_v3_v3(mvert[index[i]].co, unode->co[i]); } mvert[index[i]].flag |= ME_VERT_PBVH_UPDATE; } } } - else if(unode->maxgrid && dm->getGridData) { + else if (unode->maxgrid && dm->getGridData) { /* multires restore */ DMGridData **grids, *grid; float (*co)[3]; @@ -157,10 +162,10 @@ static int sculpt_undo_restore_coords(bContext *C, DerivedMesh *dm, SculptUndoNo gridsize= dm->getGridSize(dm); co = unode->co; - for(j=0; jtotgrid; j++) { + for (j=0; jtotgrid; j++) { grid= grids[unode->grids[j]]; - for(i=0; isculpt; int i; - if(unode->maxvert) { + if (unode->maxvert) { MVert *mvert= ss->mvert; - for(i=0; itotvert; i++) { + for (i=0; itotvert; i++) { MVert *v = &mvert[unode->index[i]]; int uval= BLI_BITMAP_GET(unode->vert_hidden, i); BLI_BITMAP_MODIFY(unode->vert_hidden, i, v->flag & ME_HIDE); - if(uval) + if (uval) v->flag |= ME_HIDE; else v->flag &= ~ME_HIDE; @@ -192,10 +197,10 @@ static int sculpt_undo_restore_hidden(bContext *C, DerivedMesh *dm, v->flag |= ME_VERT_PBVH_UPDATE; } } - else if(unode->maxgrid && dm->getGridData) { + else if (unode->maxgrid && dm->getGridData) { BLI_bitmap *grid_hidden = dm->getGridHidden(dm); - for(i=0; itotgrid; i++) { + for (i=0; itotgrid; i++) { SWAP(BLI_bitmap, unode->grid_hidden[i], grid_hidden[unode->grids[i]]); @@ -219,18 +224,18 @@ static void sculpt_undo_restore(bContext *C, ListBase *lb) sculpt_update_mesh_elements(scene, sd, ob, 0); - for(unode=lb->first; unode; unode=unode->next) { - if(!(strcmp(unode->idname, ob->id.name)==0)) + for (unode=lb->first; unode; unode=unode->next) { + if (!(strcmp(unode->idname, ob->id.name)==0)) continue; /* check if undo data matches current data well enough to * continue */ - if(unode->maxvert) { - if(ss->totvert != unode->maxvert) + if (unode->maxvert) { + if (ss->totvert != unode->maxvert) continue; } - else if(unode->maxgrid && dm->getGridData) { - if((dm->getNumGrids(dm) != unode->maxgrid) || + else if (unode->maxgrid && dm->getGridData) { + if ((dm->getNumGrids(dm) != unode->maxgrid) || (dm->getGridSize(dm) != unode->gridsize)) continue; } @@ -240,17 +245,17 @@ static void sculpt_undo_restore(bContext *C, ListBase *lb) switch(unode->type) { case SCULPT_UNDO_COORDS: - if(sculpt_undo_restore_coords(C, dm, unode)) + if (sculpt_undo_restore_coords(C, dm, unode)) update= 1; break; case SCULPT_UNDO_HIDDEN: - if(sculpt_undo_restore_hidden(C, dm, unode)) + if (sculpt_undo_restore_hidden(C, dm, unode)) rebuild= 1; break; } } - if(update || rebuild) { + if (update || rebuild) { int tag_update= 0; /* we update all nodes still, should be more clever, but also * needs to work correct when exiting/entering sculpt mode and @@ -258,8 +263,8 @@ static void sculpt_undo_restore(bContext *C, ListBase *lb) BLI_pbvh_search_callback(ss->pbvh, NULL, NULL, update_cb, &rebuild); BLI_pbvh_update(ss->pbvh, PBVH_UpdateBB|PBVH_UpdateOriginalBB|PBVH_UpdateRedraw, NULL); - if((mmd=sculpt_multires_active(scene, ob))) { - if(rebuild) + if ((mmd=sculpt_multires_active(scene, ob))) { + if (rebuild) multires_mark_as_modified(ob, MULTIRES_HIDDEN_MODIFIED); else multires_mark_as_modified(ob, MULTIRES_COORDS_MODIFIED); @@ -267,7 +272,7 @@ static void sculpt_undo_restore(bContext *C, ListBase *lb) tag_update= ((Mesh*)ob->data)->id.us > 1; - if(ss->modifiers_active) { + if (ss->modifiers_active) { Mesh *mesh= ob->data; mesh_calc_normals_mapping(mesh->mvert, mesh->totvert, mesh->mloop, mesh->mpoly, mesh->totloop, mesh->totpoly, NULL, NULL, 0, NULL, NULL); @@ -275,7 +280,7 @@ static void sculpt_undo_restore(bContext *C, ListBase *lb) tag_update|= 1; } - if(tag_update) + if (tag_update) DAG_id_tag_update(&ob->id, OB_RECALC_DATA); /* for non-PBVH drawing, need to recreate VBOs */ @@ -288,24 +293,24 @@ static void sculpt_undo_free(ListBase *lb) SculptUndoNode *unode; int i; - for(unode=lb->first; unode; unode=unode->next) { - if(unode->co) + for (unode=lb->first; unode; unode=unode->next) { + if (unode->co) MEM_freeN(unode->co); - if(unode->no) + if (unode->no) MEM_freeN(unode->no); - if(unode->index) + if (unode->index) MEM_freeN(unode->index); - if(unode->grids) + if (unode->grids) MEM_freeN(unode->grids); - if(unode->layer_disp) + if (unode->layer_disp) MEM_freeN(unode->layer_disp); - if(unode->orig_co) + if (unode->orig_co) MEM_freeN(unode->orig_co); - if(unode->vert_hidden) + if (unode->vert_hidden) MEM_freeN(unode->vert_hidden); - if(unode->grid_hidden) { - for(i=0; itotgrid; i++) { - if(unode->grid_hidden[i]) + if (unode->grid_hidden) { + for (i=0; itotgrid; i++) { + if (unode->grid_hidden[i]) MEM_freeN(unode->grid_hidden[i]); } MEM_freeN(unode->grid_hidden); @@ -318,11 +323,11 @@ SculptUndoNode *sculpt_undo_get_node(PBVHNode *node) ListBase *lb= undo_paint_push_get_list(UNDO_PAINT_MESH); SculptUndoNode *unode; - if(!lb) + if (!lb) return NULL; - for(unode=lb->first; unode; unode=unode->next) - if(unode->node == node) + for (unode=lb->first; unode; unode=unode->next) + if (unode->node == node) return unode; return NULL; @@ -343,8 +348,8 @@ static void sculpt_undo_alloc_and_store_hidden(PBVH *pbvh, unode->grid_hidden= MEM_mapallocN(sizeof(BLI_bitmap) * totgrid, "unode->grid_hidden"); - for(i = 0; i < totgrid; i++) { - if(grid_hidden[grid_indices[i]]) + for (i = 0; i < totgrid; i++) { + if (grid_hidden[grid_indices[i]]) unode->grid_hidden[i] = MEM_dupallocN(grid_hidden[grid_indices[i]]); else unode->grid_hidden[i] = NULL; @@ -380,7 +385,7 @@ static SculptUndoNode *sculpt_undo_alloc_node(Object *ob, PBVHNode *node, undo_paint_push_count_alloc(UNDO_PAINT_MESH, (sizeof(float)*3 + sizeof(short)*3 + sizeof(int))*allvert); break; case SCULPT_UNDO_HIDDEN: - if(maxgrid) + if (maxgrid) sculpt_undo_alloc_and_store_hidden(ss->pbvh, unode); else unode->vert_hidden= BLI_BITMAP_NEW(allvert, "SculptUndoNode.vert_hidden"); @@ -390,7 +395,7 @@ static SculptUndoNode *sculpt_undo_alloc_node(Object *ob, PBVHNode *node, BLI_addtail(lb, unode); - if(maxgrid) { + if (maxgrid) { /* multires */ unode->maxgrid= maxgrid; unode->totgrid= totgrid; @@ -403,7 +408,7 @@ static SculptUndoNode *sculpt_undo_alloc_node(Object *ob, PBVHNode *node, unode->index= MEM_mapallocN(sizeof(int)*allvert, "SculptUndoNode.index"); } - if(ss->modifiers_active) + if (ss->modifiers_active) unode->orig_co= MEM_callocN(allvert*sizeof(*unode->orig_co), "undoSculpt orig_cos"); return unode; @@ -416,10 +421,10 @@ static void sculpt_undo_store_coords(Object *ob, SculptUndoNode *unode) BLI_pbvh_vertex_iter_begin(ss->pbvh, unode->node, vd, PBVH_ITER_ALL) { copy_v3_v3(unode->co[vd.i], vd.co); - if(vd.no) copy_v3_v3_short(unode->no[vd.i], vd.no); + if (vd.no) copy_v3_v3_short(unode->no[vd.i], vd.no); else normal_float_to_short_v3(unode->no[vd.i], vd.fno); - if(ss->modifiers_active) + if (ss->modifiers_active) copy_v3_v3(unode->orig_co[vd.i], ss->orig_cos[unode->index[vd.i]]); } BLI_pbvh_vertex_iter_end; @@ -430,7 +435,7 @@ static void sculpt_undo_store_hidden(Object *ob, SculptUndoNode *unode) PBVH *pbvh= ob->sculpt->pbvh; PBVHNode *node= unode->node; - if(unode->grids) { + if (unode->grids) { /* already stored during allocation */ } else { @@ -440,7 +445,7 @@ static void sculpt_undo_store_hidden(Object *ob, SculptUndoNode *unode) BLI_pbvh_node_num_verts(pbvh, node, NULL, &allvert); BLI_pbvh_node_get_verts(pbvh, node, &vert_indices, &mvert); - for(i = 0; i < allvert; i++) { + for (i = 0; i < allvert; i++) { BLI_BITMAP_MODIFY(unode->vert_hidden, i, mvert[vert_indices[i]].flag & ME_HIDE); } @@ -456,7 +461,7 @@ SculptUndoNode *sculpt_undo_push_node(Object *ob, PBVHNode *node, /* list is manipulated by multiple threads, so we lock */ BLI_lock_thread(LOCK_CUSTOM1); - if((unode= sculpt_undo_get_node(node))) { + if ((unode= sculpt_undo_get_node(node))) { BLI_unlock_thread(LOCK_CUSTOM1); return unode; } @@ -475,7 +480,7 @@ SculptUndoNode *sculpt_undo_push_node(Object *ob, PBVHNode *node, break; } - if(unode->grids) { + if (unode->grids) { int totgrid, *grids; BLI_pbvh_node_get_grids(ss->pbvh, node, &grids, &totgrid, NULL, NULL, NULL, NULL); @@ -489,7 +494,7 @@ SculptUndoNode *sculpt_undo_push_node(Object *ob, PBVHNode *node, } /* store active shape key */ - if(ss->kb) BLI_strncpy(unode->shapeName, ss->kb->name, sizeof(ss->kb->name)); + if (ss->kb) BLI_strncpy(unode->shapeName, ss->kb->name, sizeof(ss->kb->name)); else unode->shapeName[0]= '\0'; return unode; @@ -507,13 +512,13 @@ void sculpt_undo_push_end(void) SculptUndoNode *unode; /* we don't need normals in the undo stack */ - for(unode=lb->first; unode; unode=unode->next) { - if(unode->no) { + for (unode=lb->first; unode; unode=unode->next) { + if (unode->no) { MEM_freeN(unode->no); unode->no= NULL; } - if(unode->layer_disp) { + if (unode->layer_disp) { MEM_freeN(unode->layer_disp); unode->layer_disp= NULL; } diff --git a/source/blender/editors/sculpt_paint/sculpt_uv.c b/source/blender/editors/sculpt_paint/sculpt_uv.c index 72e9f861aa9..240a8feeb88 100644 --- a/source/blender/editors/sculpt_paint/sculpt_uv.c +++ b/source/blender/editors/sculpt_paint/sculpt_uv.c @@ -372,7 +372,8 @@ static void uv_sculpt_stroke_apply(bContext *C, wmOperator *op, wmEvent *event, unsigned int method = toolsettings->uv_relax_method; if (method == UV_SCULPT_TOOL_RELAX_HC) { HC_relaxation_iteration_uv(em, sculptdata, co, alpha, radius, aspectRatio); - }else{ + } + else { laplacian_relaxation_iteration_uv(em, sculptdata, co, alpha, radius, aspectRatio); } } @@ -501,13 +502,16 @@ static UvSculptData *uv_sculpt_stroke_init(bContext *C, wmOperator *op, wmEvent /* We will need island information */ if (ts->uv_flag & UV_SYNC_SELECTION) { data->elementMap = EDBM_make_uv_element_map(em, 0, 1); - }else{ + } + else { data->elementMap = EDBM_make_uv_element_map(em, 1, 1); } - }else { + } + else { if (ts->uv_flag & UV_SYNC_SELECTION) { data->elementMap = EDBM_make_uv_element_map(em, 0, 0); - }else{ + } + else { data->elementMap = EDBM_make_uv_element_map(em, 1, 0); } } @@ -610,7 +614,7 @@ static UvSculptData *uv_sculpt_stroke_init(bContext *C, wmOperator *op, wmEvent edges[counter].uv1 = offset1; edges[counter].uv2 = offset2; } - else{ + else { edges[counter].uv1 = offset2; edges[counter].uv2 = offset1; } @@ -619,7 +623,7 @@ static UvSculptData *uv_sculpt_stroke_init(bContext *C, wmOperator *op, wmEvent char *flag = BLI_ghash_lookup(edgeHash, &edges[counter]); *flag = 1; } - else{ + else { /* Hack mentioned */ BLI_ghash_insert(edgeHash, &edges[counter], &edges[counter].flag); } diff --git a/source/blender/editors/sound/sound_ops.c b/source/blender/editors/sound/sound_ops.c index 29cb11f64ce..f7598045f81 100644 --- a/source/blender/editors/sound/sound_ops.c +++ b/source/blender/editors/sound/sound_ops.c @@ -105,11 +105,11 @@ static int sound_open_exec(bContext *C, wmOperator *op) RNA_string_get(op->ptr, "filepath", path); sound = sound_new_file(bmain, path); - if(!op->customdata) + if (!op->customdata) sound_open_init(C, op); if (sound==NULL || sound->playback_handle == NULL) { - if(op->customdata) MEM_freeN(op->customdata); + if (op->customdata) MEM_freeN(op->customdata); BKE_report(op->reports, RPT_ERROR, "Unsupported audio format"); return OPERATOR_CANCELLED; } @@ -118,12 +118,12 @@ static int sound_open_exec(bContext *C, wmOperator *op) if (info.specs.channels == AUD_CHANNELS_INVALID) { sound_delete(bmain, sound); - if(op->customdata) MEM_freeN(op->customdata); + if (op->customdata) MEM_freeN(op->customdata); BKE_report(op->reports, RPT_ERROR, "Unsupported audio format"); return OPERATOR_CANCELLED; } - if(RNA_boolean_get(op->ptr, "mono")) { + if (RNA_boolean_get(op->ptr, "mono")) { sound->flags |= SOUND_FLAGS_MONO; sound_load(bmain, sound); } @@ -135,7 +135,7 @@ static int sound_open_exec(bContext *C, wmOperator *op) /* hook into UI */ pprop= op->customdata; - if(pprop->prop) { + if (pprop->prop) { /* when creating new ID blocks, use is already 1, but RNA * pointer se also increases user, so this compensates it */ sound->id.us--; @@ -145,7 +145,7 @@ static int sound_open_exec(bContext *C, wmOperator *op) RNA_property_update(C, &pprop->ptr, pprop->prop); } - if(op->customdata) MEM_freeN(op->customdata); + if (op->customdata) MEM_freeN(op->customdata); return OPERATOR_FINISHED; } @@ -162,7 +162,7 @@ static int sound_open_exec(bContext *UNUSED(C), wmOperator *op) static int sound_open_invoke(bContext *C, wmOperator *op, wmEvent *event) { - if(RNA_struct_property_is_set(op->ptr, "filepath")) + if (RNA_struct_property_is_set(op->ptr, "filepath")) return sound_open_exec(C, op); sound_open_init(C, op); @@ -223,19 +223,19 @@ static int sound_update_animation_flags_exec(bContext *C, wmOperator *UNUSED(op) SEQ_BEGIN(scene->ed, seq) { fcu = id_data_find_fcurve(&scene->id, seq, &RNA_Sequence, "volume", 0, &driven); - if(fcu || driven) + if (fcu || driven) seq->flag |= SEQ_AUDIO_VOLUME_ANIMATED; else seq->flag &= ~SEQ_AUDIO_VOLUME_ANIMATED; fcu = id_data_find_fcurve(&scene->id, seq, &RNA_Sequence, "pitch", 0, &driven); - if(fcu || driven) + if (fcu || driven) seq->flag |= SEQ_AUDIO_PITCH_ANIMATED; else seq->flag &= ~SEQ_AUDIO_PITCH_ANIMATED; fcu = id_data_find_fcurve(&scene->id, seq, &RNA_Sequence, "pan", 0, &driven); - if(fcu || driven) + if (fcu || driven) seq->flag |= SEQ_AUDIO_PAN_ANIMATED; else seq->flag &= ~SEQ_AUDIO_PAN_ANIMATED; @@ -243,7 +243,7 @@ static int sound_update_animation_flags_exec(bContext *C, wmOperator *UNUSED(op) SEQ_END fcu = id_data_find_fcurve(&scene->id, scene, &RNA_Scene, "audio_volume", 0, &driven); - if(fcu || driven) + if (fcu || driven) scene->audio.flag |= AUDIO_VOLUME_ANIMATED; else scene->audio.flag &= ~AUDIO_VOLUME_ANIMATED; @@ -283,7 +283,7 @@ static int sound_bake_animation_exec(bContext *C, wmOperator *UNUSED(op)) sound_update_animation_flags_exec(C, NULL); - for(cfra = scene->r.sfra > 0 ? scene->r.sfra - 1 : 0; cfra <= scene->r.efra + 1; cfra++) + for (cfra = scene->r.sfra > 0 ? scene->r.sfra - 1 : 0; cfra <= scene->r.efra + 1; cfra++) { scene->r.cfra = cfra; scene_update_for_newframe(bmain, scene, scene->lay); @@ -358,7 +358,7 @@ static int sound_mixdown_exec(bContext *C, wmOperator *op) static int sound_mixdown_invoke(bContext *C, wmOperator *op, wmEvent *event) { - if(RNA_struct_property_is_set(op->ptr, "filepath")) + if (RNA_struct_property_is_set(op->ptr, "filepath")) return sound_mixdown_exec(C, op); return WM_operator_filesel(C, op, event); @@ -602,7 +602,7 @@ static int sound_poll(bContext *C) { Editing* ed = CTX_data_scene(C)->ed; - if(!ed || !ed->act_seq || ed->act_seq->type != SEQ_SOUND) + if (!ed || !ed->act_seq || ed->act_seq->type != SEQ_SOUND) return 0; return 1; @@ -615,12 +615,12 @@ static int sound_pack_exec(bContext *C, wmOperator *op) Editing* ed = CTX_data_scene(C)->ed; bSound* sound; - if(!ed || !ed->act_seq || ed->act_seq->type != SEQ_SOUND) + if (!ed || !ed->act_seq || ed->act_seq->type != SEQ_SOUND) return OPERATOR_CANCELLED; sound = ed->act_seq->sound; - if(!sound || sound->packedfile) + if (!sound || sound->packedfile) return OPERATOR_CANCELLED; sound->packedfile= newPackedFile(op->reports, sound->name, ID_BLEND_PATH(bmain, &sound->id)); @@ -658,10 +658,10 @@ static int sound_unpack_exec(bContext *C, wmOperator *op) sound = BLI_findstring(&CTX_data_main(C)->sound, sndname, offsetof(ID, name) + 2); } - if(!sound || !sound->packedfile) + if (!sound || !sound->packedfile) return OPERATOR_CANCELLED; - if(G.fileflags & G_AUTOPACK) + if (G.fileflags & G_AUTOPACK) BKE_report(op->reports, RPT_WARNING, "AutoPack is enabled, so image will be packed again on file save"); unpackSound(CTX_data_main(C), op->reports, sound, method); @@ -674,18 +674,18 @@ static int sound_unpack_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(even Editing* ed = CTX_data_scene(C)->ed; bSound* sound; - if(RNA_struct_property_is_set(op->ptr, "id")) + if (RNA_struct_property_is_set(op->ptr, "id")) return sound_unpack_exec(C, op); - if(!ed || !ed->act_seq || ed->act_seq->type != SEQ_SOUND) + if (!ed || !ed->act_seq || ed->act_seq->type != SEQ_SOUND) return OPERATOR_CANCELLED; sound = ed->act_seq->sound; - if(!sound || !sound->packedfile) + if (!sound || !sound->packedfile) return OPERATOR_CANCELLED; - if(G.fileflags & G_AUTOPACK) + if (G.fileflags & G_AUTOPACK) BKE_report(op->reports, RPT_WARNING, "AutoPack is enabled, so image will be packed again on file save"); unpack_menu(C, "SOUND_OT_unpack", sound->id.name+2, sound->name, "sounds", sound->packedfile); diff --git a/source/blender/editors/space_action/action_select.c b/source/blender/editors/space_action/action_select.c index 3f3966b6f87..630bb75ed5d 100644 --- a/source/blender/editors/space_action/action_select.c +++ b/source/blender/editors/space_action/action_select.c @@ -785,7 +785,7 @@ static void actkeys_select_leftright (bAnimContext *ac, short leftright, short s TimeMarker *marker; for (marker= markers->first; marker; marker= marker->next) { - if( ((leftright == ACTKEYS_LRSEL_LEFT) && (marker->frame < CFRA)) || + if ( ((leftright == ACTKEYS_LRSEL_LEFT) && (marker->frame < CFRA)) || ((leftright == ACTKEYS_LRSEL_RIGHT) && (marker->frame >= CFRA)) ) { marker->flag |= SELECT; diff --git a/source/blender/editors/space_action/space_action.c b/source/blender/editors/space_action/space_action.c index 8f14ef337c8..9d0dab7d34e 100644 --- a/source/blender/editors/space_action/space_action.c +++ b/source/blender/editors/space_action/space_action.c @@ -289,17 +289,17 @@ static void action_channel_area_listener(ARegion *ar, wmNotifier *wmn) ED_region_tag_redraw(ar); break; case ND_MODIFIER: - if(wmn->action == NA_RENAME) + if (wmn->action == NA_RENAME) ED_region_tag_redraw(ar); break; } break; case NC_ID: - if(wmn->action == NA_RENAME) + if (wmn->action == NA_RENAME) ED_region_tag_redraw(ar); break; default: - if(wmn->data==ND_KEYS) + if (wmn->data==ND_KEYS) ED_region_tag_redraw(ar); } } @@ -341,12 +341,12 @@ static void action_main_area_listener(ARegion *ar, wmNotifier *wmn) } break; case NC_ID: - if(wmn->action == NA_RENAME) + if (wmn->action == NA_RENAME) ED_region_tag_redraw(ar); break; default: - if(wmn->data==ND_KEYS) + if (wmn->data==ND_KEYS) ED_region_tag_redraw(ar); } } @@ -438,7 +438,7 @@ static void action_header_area_listener(ARegion *ar, wmNotifier *wmn) } 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_api/spacetypes.c b/source/blender/editors/space_api/spacetypes.c index b876003c059..31243184961 100644 --- a/source/blender/editors/space_api/spacetypes.c +++ b/source/blender/editors/space_api/spacetypes.c @@ -117,8 +117,8 @@ void ED_spacetypes_init(void) /* register operators */ spacetypes = BKE_spacetypes_list(); - for(type=spacetypes->first; type; type=type->next) { - if(type->operatortypes) + for (type=spacetypes->first; type; type=type->next) { + if (type->operatortypes) type->operatortypes(); } @@ -136,8 +136,8 @@ void ED_spacetypes_init(void) /* register dropboxes (can use macros) */ spacetypes = BKE_spacetypes_list(); - for(type=spacetypes->first; type; type=type->next) { - if(type->dropboxes) + for (type=spacetypes->first; type; type=type->next) { + if (type->dropboxes) type->dropboxes(); } @@ -169,11 +169,11 @@ void ED_spacetypes_keymap(wmKeyConfig *keyconf) UI_view2d_keymap(keyconf); spacetypes = BKE_spacetypes_list(); - for(stype=spacetypes->first; stype; stype=stype->next) { - if(stype->keymap) + for (stype=spacetypes->first; stype; stype=stype->next) { + if (stype->keymap) stype->keymap(keyconf); - for(atype=stype->regiontypes.first; atype; atype=atype->next) { - if(atype->keymap) + for (atype=stype->regiontypes.first; atype; atype=atype->next) { + if (atype->keymap) atype->keymap(keyconf); } } @@ -209,8 +209,8 @@ void ED_region_draw_cb_exit(ARegionType *art, void *handle) { RegionDrawCB *rdc; - for(rdc= art->drawcalls.first; rdc; rdc= rdc->next) { - if(rdc==(RegionDrawCB *)handle) { + for (rdc= art->drawcalls.first; rdc; rdc= rdc->next) { + if (rdc==(RegionDrawCB *)handle) { BLI_remlink(&art->drawcalls, rdc); MEM_freeN(rdc); return; @@ -227,8 +227,8 @@ void ED_region_draw_cb_draw(const bContext *C, ARegion *ar, int type) { RegionDrawCB *rdc; - for(rdc= ar->type->drawcalls.first; rdc; rdc= rdc->next) { - if(rdc->type==type) + for (rdc= ar->type->drawcalls.first; rdc; rdc= rdc->next) { + if (rdc->type==type) rdc->draw(C, ar, rdc->customdata); } } diff --git a/source/blender/editors/space_buttons/buttons_context.c b/source/blender/editors/space_buttons/buttons_context.c index 440c3c66a4b..b698ec03668 100644 --- a/source/blender/editors/space_buttons/buttons_context.c +++ b/source/blender/editors/space_buttons/buttons_context.c @@ -70,10 +70,10 @@ static int set_pointer_type(ButsContextPath *path, bContextDataResult *result, S PointerRNA *ptr; int a; - for(a=0; alen; a++) { + for (a=0; alen; a++) { ptr= &path->ptr[a]; - if(RNA_struct_is_a(ptr->type, type)) { + if (RNA_struct_is_a(ptr->type, type)) { CTX_data_pointer_set(result, ptr->id.data, ptr->type, ptr->data); return 1; } @@ -87,10 +87,10 @@ static PointerRNA *get_pointer_type(ButsContextPath *path, StructRNA *type) PointerRNA *ptr; int a; - for(a=0; alen; a++) { + for (a=0; alen; a++) { ptr= &path->ptr[a]; - if(RNA_struct_is_a(ptr->type, type)) + if (RNA_struct_is_a(ptr->type, type)) return ptr; } @@ -116,15 +116,15 @@ static int buttons_context_path_world(ButsContextPath *path) PointerRNA *ptr= &path->ptr[path->len-1]; /* if we already have a (pinned) world, we're done */ - if(RNA_struct_is_a(ptr->type, &RNA_World)) { + if (RNA_struct_is_a(ptr->type, &RNA_World)) { return 1; } /* if we have a scene, use the scene's world */ - else if(buttons_context_path_scene(path)) { + else if (buttons_context_path_scene(path)) { scene= path->ptr[path->len-1].data; world= scene->world; - if(world) { + if (world) { RNA_id_pointer_create(&scene->world->id, &path->ptr[path->len]); path->len++; return 1; @@ -146,15 +146,15 @@ static int buttons_context_path_object(ButsContextPath *path) PointerRNA *ptr= &path->ptr[path->len-1]; /* if we already have a (pinned) object, we're done */ - if(RNA_struct_is_a(ptr->type, &RNA_Object)) { + if (RNA_struct_is_a(ptr->type, &RNA_Object)) { return 1; } /* if we have a scene, use the scene's active object */ - else if(buttons_context_path_scene(path)) { + else if (buttons_context_path_scene(path)) { scene= path->ptr[path->len-1].data; ob= (scene->basact)? scene->basact->object: NULL; - if(ob) { + if (ob) { RNA_id_pointer_create(&ob->id, &path->ptr[path->len]); path->len++; @@ -172,19 +172,19 @@ 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 || ELEM3(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_Lamp) && (type == -1 || type == OB_LAMP)) return 1; - else if(RNA_struct_is_a(ptr->type, &RNA_Speaker) && (type == -1 || type == OB_SPEAKER)) 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 || ELEM3(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_Lamp) && (type == -1 || type == OB_LAMP)) return 1; + else if (RNA_struct_is_a(ptr->type, &RNA_Speaker) && (type == -1 || type == OB_SPEAKER)) return 1; /* try to get an object in the path, no pinning supported here */ - else if(buttons_context_path_object(path)) { + else if (buttons_context_path_object(path)) { ob= path->ptr[path->len-1].data; - if(ob && (type == -1 || type == ob->type)) { + if (ob && (type == -1 || type == ob->type)) { RNA_id_pointer_create(ob->data, &path->ptr[path->len]); path->len++; @@ -200,10 +200,10 @@ static int buttons_context_path_modifier(ButsContextPath *path) { Object *ob; - if(buttons_context_path_object(path)) { + if (buttons_context_path_object(path)) { ob= path->ptr[path->len-1].data; - if(ob && ELEM5(ob->type, OB_MESH, OB_CURVE, OB_FONT, OB_SURF, OB_LATTICE)) + if (ob && ELEM5(ob->type, OB_MESH, OB_CURVE, OB_FONT, OB_SURF, OB_LATTICE)) return 1; } @@ -217,23 +217,23 @@ static int buttons_context_path_material(ButsContextPath *path, int for_texture) Material *ma; /* if we already have a (pinned) material, we're done */ - if(RNA_struct_is_a(ptr->type, &RNA_Material)) { + if (RNA_struct_is_a(ptr->type, &RNA_Material)) { return 1; } /* if we have an object, use the object material slot */ - else if(buttons_context_path_object(path)) { + else if (buttons_context_path_object(path)) { ob= path->ptr[path->len-1].data; - if(ob && OB_TYPE_SUPPORT_MATERIAL(ob->type)) { + if (ob && OB_TYPE_SUPPORT_MATERIAL(ob->type)) { ma= give_current_material(ob, ob->actcol); RNA_id_pointer_create(&ma->id, &path->ptr[path->len]); path->len++; - if(for_texture && give_current_material_texture_node(ma)) + if (for_texture && give_current_material_texture_node(ma)) return 1; ma= give_node_material(ma); - if(ma) { + if (ma) { RNA_id_pointer_create(&ma->id, &path->ptr[path->len]); path->len++; } @@ -251,11 +251,11 @@ static int buttons_context_path_bone(ButsContextPath *path) EditBone *edbo; /* if we have an armature, get the active bone */ - if(buttons_context_path_data(path, OB_ARMATURE)) { + if (buttons_context_path_data(path, OB_ARMATURE)) { arm= path->ptr[path->len-1].data; - if(arm->edbo) { - if(arm->act_edbone) { + if (arm->edbo) { + if (arm->act_edbone) { edbo= arm->act_edbone; RNA_pointer_create(&arm->id, &RNA_EditBone, edbo, &path->ptr[path->len]); path->len++; @@ -263,7 +263,7 @@ static int buttons_context_path_bone(ButsContextPath *path) } } else { - if(arm->act_bone) { + if (arm->act_bone) { RNA_pointer_create(&arm->id, &RNA_Bone, arm->act_bone, &path->ptr[path->len]); path->len++; return 1; @@ -280,22 +280,22 @@ static int buttons_context_path_pose_bone(ButsContextPath *path) PointerRNA *ptr= &path->ptr[path->len-1]; /* if we already have a (pinned) PoseBone, we're done */ - if(RNA_struct_is_a(ptr->type, &RNA_PoseBone)) { + if (RNA_struct_is_a(ptr->type, &RNA_PoseBone)) { return 1; } /* if we have an armature, get the active bone */ - if(buttons_context_path_object(path)) { + if (buttons_context_path_object(path)) { Object *ob= path->ptr[path->len-1].data; bArmature *arm= ob->data; /* path->ptr[path->len-1].data - works too */ - if(ob->type != OB_ARMATURE || arm->edbo) { + if (ob->type != OB_ARMATURE || arm->edbo) { return 0; } else { - if(arm->act_bone) { + if (arm->act_bone) { bPoseChannel *pchan= get_pose_channel(ob->pose, arm->act_bone->name); - if(pchan) { + if (pchan) { RNA_pointer_create(&ob->id, &RNA_PoseBone, pchan, &path->ptr[path->len]); path->len++; return 1; @@ -316,14 +316,14 @@ static int buttons_context_path_particle(ButsContextPath *path) PointerRNA *ptr= &path->ptr[path->len-1]; /* if we already have (pinned) particle settings, we're done */ - if(RNA_struct_is_a(ptr->type, &RNA_ParticleSettings)) { + if (RNA_struct_is_a(ptr->type, &RNA_ParticleSettings)) { return 1; } /* if we have an object, get the active particle system */ - if(buttons_context_path_object(path)) { + if (buttons_context_path_object(path)) { ob= path->ptr[path->len-1].data; - if(ob && ob->type == OB_MESH) { + if (ob && ob->type == OB_MESH) { psys= psys_get_current(ob); RNA_pointer_create(&ob->id, &RNA_ParticleSystem, psys, &path->ptr[path->len]); @@ -343,17 +343,17 @@ static int buttons_context_path_brush(ButsContextPath *path) PointerRNA *ptr= &path->ptr[path->len-1]; /* if we already have a (pinned) brush, we're done */ - if(RNA_struct_is_a(ptr->type, &RNA_Brush)) { + if (RNA_struct_is_a(ptr->type, &RNA_Brush)) { return 1; } /* if we have a scene, use the toolsettings brushes */ - else if(buttons_context_path_scene(path)) { + else if (buttons_context_path_scene(path)) { scene= path->ptr[path->len-1].data; - if(scene) + if (scene) br= paint_brush(paint_get_active(scene)); - if(br) { + if (br) { RNA_id_pointer_create((ID *)br, &path->ptr[path->len]); path->len++; @@ -367,36 +367,36 @@ static int buttons_context_path_brush(ButsContextPath *path) static int buttons_context_path_texture(ButsContextPath *path, ButsContextTexture *ct) { - if(ct) { + if (ct) { /* new shading system */ PointerRNA *ptr= &path->ptr[path->len-1]; ID *id; /* 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 (id) { + if (GS(id->name) == ID_BR) buttons_context_path_brush(path); - else if(GS(id->name) == ID_MA) + else if (GS(id->name) == ID_MA) buttons_context_path_material(path, 0); - else if(GS(id->name) == ID_WO) + else if (GS(id->name) == ID_WO) buttons_context_path_world(path); - else if(GS(id->name) == ID_LA) + else if (GS(id->name) == ID_LA) buttons_context_path_data(path, OB_LAMP); - 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); } - if(ct->texture) { + if (ct->texture) { RNA_id_pointer_create(&ct->texture->id, &path->ptr[path->len]); path->len++; } @@ -415,14 +415,14 @@ static int buttons_context_path_texture(ButsContextPath *path, ButsContextTextur int orig_len = path->len; /* 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; } /* try brush */ - if((path->tex_ctx == SB_TEXC_BRUSH) && buttons_context_path_brush(path)) { + if ((path->tex_ctx == SB_TEXC_BRUSH) && buttons_context_path_brush(path)) { br= path->ptr[path->len-1].data; - if(br) { + if (br) { tex= give_current_brush_texture(br); RNA_id_pointer_create(&tex->id, &path->ptr[path->len]); @@ -431,10 +431,10 @@ static int buttons_context_path_texture(ButsContextPath *path, ButsContextTextur } } /* try world */ - if((path->tex_ctx == SB_TEXC_WORLD) && buttons_context_path_world(path)) { + if ((path->tex_ctx == SB_TEXC_WORLD) && buttons_context_path_world(path)) { wo= path->ptr[path->len-1].data; - if(wo && GS(wo->id.name)==ID_WO) { + if (wo && GS(wo->id.name)==ID_WO) { tex= give_current_world_texture(wo); RNA_id_pointer_create(&tex->id, &path->ptr[path->len]); @@ -443,8 +443,8 @@ static int buttons_context_path_texture(ButsContextPath *path, ButsContextTextur } } /* try particles */ - if((path->tex_ctx == SB_TEXC_PARTICLES) && buttons_context_path_particle(path)) { - if(path->ptr[path->len-1].type == &RNA_ParticleSettings) { + if ((path->tex_ctx == SB_TEXC_PARTICLES) && buttons_context_path_particle(path)) { + if (path->ptr[path->len-1].type == &RNA_ParticleSettings) { ParticleSettings *part = path->ptr[path->len-1].data; tex= give_current_particle_texture(part); @@ -455,7 +455,7 @@ static int buttons_context_path_texture(ButsContextPath *path, ButsContextTextur else { psys= path->ptr[path->len-1].data; - if(psys && psys->part && GS(psys->part->id.name)==ID_PA) { + if (psys && psys->part && GS(psys->part->id.name)==ID_PA) { tex= give_current_particle_texture(psys->part); RNA_id_pointer_create(&tex->id, &path->ptr[path->len]); @@ -465,10 +465,10 @@ static int buttons_context_path_texture(ButsContextPath *path, ButsContextTextur } } /* try material */ - if(buttons_context_path_material(path, 1)) { + if (buttons_context_path_material(path, 1)) { ma= path->ptr[path->len-1].data; - if(ma) { + if (ma) { tex= give_current_material_texture(ma); RNA_id_pointer_create(&tex->id, &path->ptr[path->len]); @@ -477,10 +477,10 @@ static int buttons_context_path_texture(ButsContextPath *path, ButsContextTextur } } /* try lamp */ - if(buttons_context_path_data(path, OB_LAMP)) { + if (buttons_context_path_data(path, OB_LAMP)) { la= path->ptr[path->len-1].data; - if(la) { + if (la) { tex= give_current_lamp_texture(la); RNA_id_pointer_create(&tex->id, &path->ptr[path->len]); @@ -490,10 +490,10 @@ static int buttons_context_path_texture(ButsContextPath *path, ButsContextTextur } /* try brushes again in case of no material, lamp, etc */ path->len = orig_len; - if(buttons_context_path_brush(path)) { + if (buttons_context_path_brush(path)) { br= path->ptr[path->len-1].data; - if(br) { + if (br) { tex= give_current_brush_texture(br); RNA_id_pointer_create(&tex->id, &path->ptr[path->len]); @@ -519,7 +519,7 @@ static int buttons_context_path(const bContext *C, ButsContextPath *path, int ma path->tex_ctx = sbuts->texture_context; /* if some ID datablock is pinned, set the root pointer */ - if(sbuts->pinid) { + if (sbuts->pinid) { id= sbuts->pinid; RNA_id_pointer_create(id, &path->ptr[0]); @@ -527,7 +527,7 @@ static int buttons_context_path(const bContext *C, ButsContextPath *path, int ma } /* no pinned root, use scene as root */ - if(path->len == 0) { + if (path->len == 0) { id= (ID*)CTX_data_scene(C); RNA_id_pointer_create(id, &path->ptr[0]); path->len++; @@ -565,7 +565,7 @@ 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: @@ -583,9 +583,9 @@ static int buttons_shading_context(const bContext *C, int mainb) { Object *ob= CTX_data_active_object(C); - if(ELEM3(mainb, BCONTEXT_MATERIAL, BCONTEXT_WORLD, BCONTEXT_TEXTURE)) + if (ELEM3(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; @@ -595,11 +595,11 @@ static int buttons_shading_new_context(const bContext *C, int flag) { Object *ob= CTX_data_active_object(C); - 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; @@ -613,22 +613,22 @@ void buttons_context_compute(const bContext *C, SpaceButs *sbuts) buttons_texture_context_compute(C, sbuts); - if(!sbuts->path) + if (!sbuts->path) sbuts->path= MEM_callocN(sizeof(ButsContextPath), "ButsContextPath"); path= sbuts->path; /* for each context, see if we can compute a valid path to it, if * this is the case, we know we have to display the button */ - for(a=0; aptr[path->len-1]; - if(ptr->type) + if (ptr->type) sbuts->dataicon= RNA_struct_ui_icon(ptr->type); else sbuts->dataicon= ICON_EMPTY_DATA; @@ -642,17 +642,17 @@ void buttons_context_compute(const bContext *C, SpaceButs *sbuts) sbuts->mainb= sbuts->mainbuser; /* in case something becomes invalid, change */ - if((flag & (1 << sbuts->mainb)) == 0) { - if(sbuts->flag & SB_SHADING_CONTEXT) { + if ((flag & (1 << sbuts->mainb)) == 0) { + if (sbuts->flag & SB_SHADING_CONTEXT) { /* try to keep showing shading related buttons */ sbuts->mainb= buttons_shading_new_context(C, flag); } - else if(flag & BCONTEXT_OBJECT) { + else if (flag & BCONTEXT_OBJECT) { sbuts->mainb= BCONTEXT_OBJECT; } else { - for(a=0; amainb= a; break; } @@ -662,14 +662,14 @@ void buttons_context_compute(const bContext *C, SpaceButs *sbuts) buttons_context_path(C, path, sbuts->mainb, pflag); - if(!(flag & (1 << sbuts->mainb))) { - if(flag & (1 << BCONTEXT_OBJECT)) + if (!(flag & (1 << sbuts->mainb))) { + if (flag & (1 << BCONTEXT_OBJECT)) sbuts->mainb= BCONTEXT_OBJECT; 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 sbuts->flag &= ~SB_SHADING_CONTEXT; @@ -691,62 +691,62 @@ int buttons_context(const bContext *C, const char *member, bContextDataResult *r SpaceButs *sbuts= CTX_wm_space_buts(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)) { + if (CTX_data_dir(member)) { CTX_data_dir_set(result, buttons_context_dir); return 1; } - else if(CTX_data_equals(member, "world")) { + else if (CTX_data_equals(member, "world")) { set_pointer_type(path, result, &RNA_World); return 1; } - else if(CTX_data_equals(member, "object")) { + else if (CTX_data_equals(member, "object")) { set_pointer_type(path, result, &RNA_Object); return 1; } - else if(CTX_data_equals(member, "mesh")) { + else if (CTX_data_equals(member, "mesh")) { set_pointer_type(path, result, &RNA_Mesh); return 1; } - else if(CTX_data_equals(member, "armature")) { + else if (CTX_data_equals(member, "armature")) { set_pointer_type(path, result, &RNA_Armature); return 1; } - else if(CTX_data_equals(member, "lattice")) { + else if (CTX_data_equals(member, "lattice")) { set_pointer_type(path, result, &RNA_Lattice); return 1; } - else if(CTX_data_equals(member, "curve")) { + else if (CTX_data_equals(member, "curve")) { set_pointer_type(path, result, &RNA_Curve); return 1; } - else if(CTX_data_equals(member, "meta_ball")) { + else if (CTX_data_equals(member, "meta_ball")) { set_pointer_type(path, result, &RNA_MetaBall); return 1; } - else if(CTX_data_equals(member, "lamp")) { + else if (CTX_data_equals(member, "lamp")) { set_pointer_type(path, result, &RNA_Lamp); return 1; } - else if(CTX_data_equals(member, "camera")) { + else if (CTX_data_equals(member, "camera")) { set_pointer_type(path, result, &RNA_Camera); return 1; } - else if(CTX_data_equals(member, "speaker")) { + else if (CTX_data_equals(member, "speaker")) { set_pointer_type(path, result, &RNA_Speaker); return 1; } - else if(CTX_data_equals(member, "material")) { + else if (CTX_data_equals(member, "material")) { set_pointer_type(path, result, &RNA_Material); return 1; } - else if(CTX_data_equals(member, "texture")) { + else if (CTX_data_equals(member, "texture")) { ButsContextTexture *ct= sbuts->texuser; - if(ct) { + if (ct) { /* new shading system */ CTX_data_pointer_set(result, &ct->texture->id, &RNA_Texture, ct->texture); } @@ -757,41 +757,41 @@ int buttons_context(const bContext *C, const char *member, bContextDataResult *r return 1; } - else if(CTX_data_equals(member, "material_slot")) { + else if (CTX_data_equals(member, "material_slot")) { PointerRNA *ptr= get_pointer_type(path, &RNA_Object); - if(ptr) { + if (ptr) { Object *ob= ptr->data; - if(ob && OB_TYPE_SUPPORT_MATERIAL(ob->type) && ob->totcol) { + 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]); } } return 1; } - else if(CTX_data_equals(member, "texture_user")) { + else if (CTX_data_equals(member, "texture_user")) { ButsContextTexture *ct= sbuts->texuser; - if(!ct) + if (!ct) return -1; /* old shading system (found but not available) */ - if(ct->user && ct->user->ptr.data) { + if (ct->user && ct->user->ptr.data) { ButsTextureUser *user= ct->user; CTX_data_pointer_set(result, user->ptr.id.data, user->ptr.type, user->ptr.data); } return 1; } - else if(CTX_data_equals(member, "texture_node")) { + else if (CTX_data_equals(member, "texture_node")) { ButsContextTexture *ct= sbuts->texuser; - if(ct) { + if (ct) { /* new shading system */ - if(ct->user && ct->user->node) + if (ct->user && ct->user->node) CTX_data_pointer_set(result, &ct->user->ntree->id, &RNA_Node, ct->user->node); return 1; @@ -800,10 +800,10 @@ int buttons_context(const bContext *C, const char *member, bContextDataResult *r /* old shading system */ PointerRNA *ptr; - if((ptr=get_pointer_type(path, &RNA_Material))) { + if ((ptr=get_pointer_type(path, &RNA_Material))) { Material *ma= ptr->data; - if(ma) { + if (ma) { bNode *node= give_current_material_texture_node(ma); CTX_data_pointer_set(result, &ma->nodetree->id, &RNA_Node, node); } @@ -812,18 +812,18 @@ int buttons_context(const bContext *C, const char *member, bContextDataResult *r return 1; } } - else if(CTX_data_equals(member, "texture_slot")) { + else if (CTX_data_equals(member, "texture_slot")) { ButsContextTexture *ct= sbuts->texuser; PointerRNA *ptr; - if(ct) + if (ct) return 0; /* new shading system */ - if((ptr=get_pointer_type(path, &RNA_Material))) { + if ((ptr=get_pointer_type(path, &RNA_Material))) { Material *ma= ptr->data; /* if we have a node material, get slot from material in material node */ - if(ma && ma->use_nodes && ma->nodetree) { + if (ma && ma->use_nodes && ma->nodetree) { /* if there's an active texture node in the node tree, * then that texture is in context directly, without a texture slot */ if (give_current_material_texture_node(ma)) @@ -834,84 +834,85 @@ int buttons_context(const bContext *C, const char *member, bContextDataResult *r CTX_data_pointer_set(result, &ma->id, &RNA_MaterialTextureSlot, ma->mtex[(int)ma->texact]); else return 0; - } else if(ma) { + } + else if (ma) { CTX_data_pointer_set(result, &ma->id, &RNA_MaterialTextureSlot, ma->mtex[(int)ma->texact]); } } - else if((ptr=get_pointer_type(path, &RNA_Lamp))) { + else if ((ptr=get_pointer_type(path, &RNA_Lamp))) { Lamp *la= ptr->data; - if(la) + if (la) CTX_data_pointer_set(result, &la->id, &RNA_LampTextureSlot, la->mtex[(int)la->texact]); } - else if((ptr=get_pointer_type(path, &RNA_World))) { + else if ((ptr=get_pointer_type(path, &RNA_World))) { World *wo= ptr->data; - if(wo) + if (wo) CTX_data_pointer_set(result, &wo->id, &RNA_WorldTextureSlot, wo->mtex[(int)wo->texact]); } - else if((ptr=get_pointer_type(path, &RNA_Brush))) { /* how to get this into context? */ + else if ((ptr=get_pointer_type(path, &RNA_Brush))) { /* how to get this into context? */ Brush *br= ptr->data; - if(br) + if (br) CTX_data_pointer_set(result, &br->id, &RNA_BrushTextureSlot, &br->mtex); } - else if((ptr=get_pointer_type(path, &RNA_ParticleSystem))) { + else 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]); } return 1; } - else if(CTX_data_equals(member, "bone")) { + else if (CTX_data_equals(member, "bone")) { set_pointer_type(path, result, &RNA_Bone); return 1; } - else if(CTX_data_equals(member, "edit_bone")) { + else if (CTX_data_equals(member, "edit_bone")) { set_pointer_type(path, result, &RNA_EditBone); return 1; } - else if(CTX_data_equals(member, "pose_bone")) { + else if (CTX_data_equals(member, "pose_bone")) { set_pointer_type(path, result, &RNA_PoseBone); return 1; } - else if(CTX_data_equals(member, "particle_system")) { + else if (CTX_data_equals(member, "particle_system")) { set_pointer_type(path, result, &RNA_ParticleSystem); return 1; } - else if(CTX_data_equals(member, "particle_system_editable")) { - if(PE_poll((bContext*)C)) + else if (CTX_data_equals(member, "particle_system_editable")) { + if (PE_poll((bContext*)C)) set_pointer_type(path, result, &RNA_ParticleSystem); else CTX_data_pointer_set(result, NULL, &RNA_ParticleSystem, NULL); return 1; } - else if(CTX_data_equals(member, "cloth")) { + else if (CTX_data_equals(member, "cloth")) { PointerRNA *ptr= get_pointer_type(path, &RNA_Object); - if(ptr && ptr->data) { + if (ptr && ptr->data) { Object *ob= ptr->data; ModifierData *md= modifiers_findByType(ob, eModifierType_Cloth); CTX_data_pointer_set(result, &ob->id, &RNA_ClothModifier, md); return 1; } } - else if(CTX_data_equals(member, "soft_body")) { + else if (CTX_data_equals(member, "soft_body")) { PointerRNA *ptr= get_pointer_type(path, &RNA_Object); - if(ptr && ptr->data) { + if (ptr && ptr->data) { Object *ob= ptr->data; ModifierData *md= modifiers_findByType(ob, eModifierType_Softbody); CTX_data_pointer_set(result, &ob->id, &RNA_SoftBodyModifier, md); return 1; } } - else if(CTX_data_equals(member, "fluid")) { + else if (CTX_data_equals(member, "fluid")) { PointerRNA *ptr= get_pointer_type(path, &RNA_Object); - if(ptr && ptr->data) { + if (ptr && ptr->data) { Object *ob= ptr->data; ModifierData *md= modifiers_findByType(ob, eModifierType_Fluidsim); CTX_data_pointer_set(result, &ob->id, &RNA_FluidSimulationModifier, md); @@ -919,34 +920,34 @@ int buttons_context(const bContext *C, const char *member, bContextDataResult *r } } - else if(CTX_data_equals(member, "smoke")) { + else if (CTX_data_equals(member, "smoke")) { PointerRNA *ptr= get_pointer_type(path, &RNA_Object); - if(ptr && ptr->data) { + if (ptr && ptr->data) { Object *ob= ptr->data; ModifierData *md= modifiers_findByType(ob, eModifierType_Smoke); CTX_data_pointer_set(result, &ob->id, &RNA_SmokeModifier, md); return 1; } } - else if(CTX_data_equals(member, "collision")) { + else if (CTX_data_equals(member, "collision")) { PointerRNA *ptr= get_pointer_type(path, &RNA_Object); - if(ptr && ptr->data) { + if (ptr && ptr->data) { Object *ob= ptr->data; ModifierData *md= modifiers_findByType(ob, eModifierType_Collision); CTX_data_pointer_set(result, &ob->id, &RNA_CollisionModifier, md); return 1; } } - else if(CTX_data_equals(member, "brush")) { + else if (CTX_data_equals(member, "brush")) { set_pointer_type(path, result, &RNA_Brush); return 1; } - else if(CTX_data_equals(member, "dynamic_paint")) { + else if (CTX_data_equals(member, "dynamic_paint")) { PointerRNA *ptr= get_pointer_type(path, &RNA_Object); - if(ptr && ptr->data) { + if (ptr && ptr->data) { Object *ob= ptr->data; ModifierData *md= modifiers_findByType(ob, eModifierType_DynamicPaint); CTX_data_pointer_set(result, &ob->id, &RNA_DynamicPaintModifier, md); @@ -966,7 +967,7 @@ static void pin_cb(bContext *C, void *UNUSED(arg1), void *UNUSED(arg2)) { SpaceButs *sbuts= CTX_wm_space_buts(C); - if(sbuts->flag & SB_PIN_CONTEXT) { + if (sbuts->flag & SB_PIN_CONTEXT) { sbuts->pinid= buttons_context_id_path(C); } else @@ -986,7 +987,7 @@ void buttons_context_draw(const bContext *C, uiLayout *layout) char namebuf[128], *name; int a, icon; - if(!path) + if (!path) return; row= uiLayoutRow(layout, 1); @@ -998,23 +999,23 @@ void buttons_context_draw(const bContext *C, uiLayout *layout) uiButClearFlag(but, UI_BUT_UNDO); /* skip undo on screen buttons */ uiButSetFunc(but, pin_cb, NULL, NULL); - for(a=0; alen; a++) { + for (a=0; alen; a++) { ptr= &path->ptr[a]; - if(a != 0) + if (a != 0) uiItemL(row, "", VICO_SMALL_TRI_RIGHT_VEC); - if(ptr->data) { + if (ptr->data) { icon= RNA_struct_ui_icon(ptr->type); name= RNA_struct_name_get_alloc(ptr, namebuf, sizeof(namebuf), NULL); - if(name) { - if(!ELEM(sbuts->mainb, BCONTEXT_RENDER, BCONTEXT_SCENE) && ptr->type == &RNA_Scene) + if (name) { + if (!ELEM(sbuts->mainb, BCONTEXT_RENDER, BCONTEXT_SCENE) && ptr->type == &RNA_Scene) uiItemLDrag(row, ptr, "", icon); /* save some space */ else uiItemLDrag(row, ptr, name, icon); - if(name != namebuf) + if (name != namebuf) MEM_freeN(name); } else @@ -1047,19 +1048,19 @@ ID *buttons_context_id_path(const bContext *C) PointerRNA *ptr; int a; - if(path->len) { - for(a=path->len-1; a>=0; a--) { + if (path->len) { + for (a=path->len-1; a>=0; a--) { ptr= &path->ptr[a]; /* pin particle settings instead of system, since only settings are an idblock*/ - if(sbuts->mainb == BCONTEXT_PARTICLE && sbuts->flag & SB_PIN_CONTEXT) { - if(ptr->type == &RNA_ParticleSystem && ptr->data) { + if (sbuts->mainb == BCONTEXT_PARTICLE && sbuts->flag & SB_PIN_CONTEXT) { + if (ptr->type == &RNA_ParticleSystem && ptr->data) { ParticleSystem *psys = (ParticleSystem *)ptr->data; return &psys->part->id; } } - if(ptr->id.data) { + if (ptr->id.data) { return ptr->id.data; } } diff --git a/source/blender/editors/space_buttons/buttons_header.c b/source/blender/editors/space_buttons/buttons_header.c index 52327d3b59b..fcc5b488ca9 100644 --- a/source/blender/editors/space_buttons/buttons_header.c +++ b/source/blender/editors/space_buttons/buttons_header.c @@ -63,7 +63,7 @@ static void set_texture_context(bContext *C, SpaceButs *sbuts) case BCONTEXT_DATA: { Object *ob = CTX_data_active_object(C); - if(ob && ob->type==OB_LAMP) + if (ob && ob->type==OB_LAMP) sbuts->texture_context = SB_TEXC_MAT_OR_LAMP; break; } @@ -80,7 +80,7 @@ static void do_buttons_buttons(bContext *C, void *UNUSED(arg), int event) { SpaceButs *sbuts= CTX_wm_space_buts(C); - if(!sbuts) /* editor type switch */ + if (!sbuts) /* editor type switch */ return; switch(event) { @@ -122,7 +122,7 @@ void buttons_header_buttons(const bContext *C, ARegion *ar) uiBlockBeginAlign(block); #define BUTTON_HEADER_CTX(_ctx, _icon, _tip) \ - if(sbuts->pathflag & (1<<_ctx)) { \ + if (sbuts->pathflag & (1<<_ctx)) { \ but = uiDefIconButS(block, ROW, B_CONTEXT_SWITCH, _icon, xco+=BUT_UNIT_X, yco, BUT_UNIT_X, UI_UNIT_Y, &(sbuts->mainb), 0.0, (float)_ctx, 0, 0, TIP_(_tip)); \ uiButClearFlag(but, UI_BUT_UNDO); \ } \ diff --git a/source/blender/editors/space_buttons/buttons_ops.c b/source/blender/editors/space_buttons/buttons_ops.c index ebdea00fd4f..ec1c74013e0 100644 --- a/source/blender/editors/space_buttons/buttons_ops.c +++ b/source/blender/editors/space_buttons/buttons_ops.c @@ -110,7 +110,7 @@ static int file_browse_exec(bContext *C, wmOperator *op) str= RNA_string_get_alloc(op->ptr, path_prop, NULL, 0); /* add slash for directories, important for some properties */ - if(RNA_property_subtype(fbo->prop) == PROP_DIRPATH) { + if (RNA_property_subtype(fbo->prop) == PROP_DIRPATH) { char name[FILE_MAX]; id = fbo->ptr.id.data; @@ -118,7 +118,7 @@ static int file_browse_exec(bContext *C, wmOperator *op) BLI_strncpy(path, str, FILE_MAX); BLI_path_abs(path, id ? ID_BLEND_PATH(G.main, id) : G.main->name); - if(BLI_is_dir(path)) { + if (BLI_is_dir(path)) { str = MEM_reallocN(str, strlen(str)+2); BLI_add_slash(str); } @@ -134,8 +134,8 @@ static int file_browse_exec(bContext *C, wmOperator *op) /* special, annoying exception, filesel on redo panel [#26618] */ { wmOperator *redo_op= WM_operator_last_redo(C); - if(redo_op) { - if(fbo->ptr.data == redo_op->ptr->data) { + if (redo_op) { + if (fbo->ptr.data == redo_op->ptr->data) { ED_undo_operator_repeat(C, redo_op); } } @@ -168,19 +168,19 @@ static int file_browse_invoke(bContext *C, wmOperator *op, wmEvent *event) uiFileBrowseContextProperty(C, &ptr, &prop); - if(!prop) + if (!prop) return OPERATOR_CANCELLED; str= RNA_property_string_get_alloc(&ptr, prop, NULL, 0, NULL); /* useful yet irritating feature, Shift+Click to open the file * Alt+Click to browse a folder in the OS's browser */ - if(event->shift || event->alt) { + if (event->shift || event->alt) { PointerRNA props_ptr; - if(event->alt) { + if (event->alt) { char *lslash= BLI_last_slash(str); - if(lslash) + if (lslash) *lslash= '\0'; } @@ -205,8 +205,8 @@ static int file_browse_invoke(bContext *C, wmOperator *op, wmEvent *event) /* normally ED_fileselect_get_params would handle this but we need to because of stupid * user-prefs exception - campbell */ - if(RNA_struct_find_property(op->ptr, "relative_path")) { - if(!RNA_struct_property_is_set(op->ptr, "relative_path")) { + if (RNA_struct_find_property(op->ptr, "relative_path")) { + if (!RNA_struct_property_is_set(op->ptr, "relative_path")) { /* annoying exception!, if were dealign with the user prefs, default relative to be off */ RNA_boolean_set(op->ptr, "relative_path", U.flag & USER_RELPATHS && (ptr.data != &U)); } diff --git a/source/blender/editors/space_buttons/buttons_texture.c b/source/blender/editors/space_buttons/buttons_texture.c index ae1f504697e..ba37cb8a892 100644 --- a/source/blender/editors/space_buttons/buttons_texture.c +++ b/source/blender/editors/space_buttons/buttons_texture.c @@ -111,9 +111,9 @@ static void buttons_texture_users_find_nodetree(ListBase *users, ID *id, { bNode *node; - if(ntree) { - for(node=ntree->nodes.first; node; node=node->next) { - if(node->typeinfo->nclass == NODE_CLASS_TEXTURE) { + if (ntree) { + for (node=ntree->nodes.first; node; node=node->next) { + if (node->typeinfo->nclass == NODE_CLASS_TEXTURE) { PointerRNA ptr; /* PropertyRNA *prop; */ /* UNUSED */ @@ -123,7 +123,7 @@ static void buttons_texture_users_find_nodetree(ListBase *users, ID *id, buttons_texture_user_node_add(users, id, ntree, node, category, RNA_struct_ui_icon(ptr.type), node->name); } - else if(node->type == NODE_GROUP && node->id) { + else if (node->type == NODE_GROUP && node->id) { buttons_texture_users_find_nodetree(users, id, (bNodeTree*)node->id, category); } } @@ -154,46 +154,46 @@ static void buttons_texture_users_from_context(ListBase *users, const bContext * ID *pinid = sbuts->pinid; /* get data from context */ - if(pinid) { - if(GS(pinid->name) == ID_SCE) + if (pinid) { + 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_LA) + else if (GS(pinid->name) == ID_LA) la= (Lamp*)pinid; - else if(GS(pinid->name) == ID_WO) + else if (GS(pinid->name) == ID_WO) wrld= (World*)pinid; - else if(GS(pinid->name) == ID_MA) + else if (GS(pinid->name) == ID_MA) ma= (Material*)pinid; - else if(GS(pinid->name) == ID_BR) + else if (GS(pinid->name) == ID_BR) brush= (Brush*)pinid; } - if(!scene) + if (!scene) scene= CTX_data_scene(C); - if(!(pinid || pinid == &scene->id)) { + if (!(pinid || pinid == &scene->id)) { ob= (scene->basact)? scene->basact->object: NULL; wrld= scene->world; brush= paint_brush(paint_get_active(scene)); } - if(ob && ob->type == OB_LAMP && !la) + if (ob && ob->type == OB_LAMP && !la) la= ob->data; - if(ob && !ma) + if (ob && !ma) ma= give_current_material(ob, ob->actcol); /* fill users */ users->first = users->last = NULL; - if(ma) + if (ma) buttons_texture_users_find_nodetree(users, &ma->id, ma->nodetree, "Material"); - if(la) + if (la) buttons_texture_users_find_nodetree(users, &la->id, la->nodetree, "Lamp"); - if(wrld) + if (wrld) buttons_texture_users_find_nodetree(users, &wrld->id, wrld->nodetree, "World"); - if(ob) { + if (ob) { ParticleSystem *psys= psys_get_current(ob); MTex *mtex; int a; @@ -202,12 +202,12 @@ static void buttons_texture_users_from_context(ListBase *users, const bContext * modifiers_foreachTexLink(ob, buttons_texture_modifier_foreach, users); /* particle systems */ - if(psys) { + if (psys) { /* todo: these slots are not in the UI */ - for(a=0; apart->mtex[a]; - if(mtex) { + if (mtex) { PointerRNA ptr; PropertyRNA *prop; @@ -221,7 +221,7 @@ static void buttons_texture_users_from_context(ListBase *users, const bContext * } /* field */ - if(ob->pd && ob->pd->forcefield == PFIELD_TEXTURE) { + if (ob->pd && ob->pd->forcefield == PFIELD_TEXTURE) { PointerRNA ptr; PropertyRNA *prop; @@ -234,7 +234,7 @@ static void buttons_texture_users_from_context(ListBase *users, const bContext * } /* brush */ - if(brush) { + if (brush) { PointerRNA ptr; PropertyRNA *prop; @@ -253,8 +253,8 @@ void buttons_texture_context_compute(const bContext *C, SpaceButs *sbuts) ButsContextTexture *ct= sbuts->texuser; Scene *scene= CTX_data_scene(C); - if(!scene_use_new_shading_nodes(scene)) { - if(ct) { + if (!scene_use_new_shading_nodes(scene)) { + if (ct) { BLI_freelistN(&ct->users); MEM_freeN(ct); sbuts->texuser= NULL; @@ -263,7 +263,7 @@ void buttons_texture_context_compute(const bContext *C, SpaceButs *sbuts) return; } - if(!ct) { + if (!ct) { ct= MEM_callocN(sizeof(ButsContextTexture), "ButsContextTexture"); sbuts->texuser= ct; } @@ -274,14 +274,14 @@ void buttons_texture_context_compute(const bContext *C, SpaceButs *sbuts) buttons_texture_users_from_context(&ct->users, C, sbuts); /* set one user as active based on active index */ - if(ct->index >= BLI_countlist(&ct->users)) + if (ct->index >= BLI_countlist(&ct->users)) ct->index= 0; ct->user = BLI_findlink(&ct->users, ct->index); ct->texture = NULL; - if(ct->user) { - if(ct->user->ptr.data) { + if (ct->user) { + if (ct->user->ptr.data) { PointerRNA texptr; Tex *tex; @@ -291,14 +291,14 @@ void buttons_texture_context_compute(const bContext *C, SpaceButs *sbuts) ct->texture = tex; } - else if(ct->user->node && !(ct->user->node->flag & NODE_ACTIVE_TEXTURE)) { + else if (ct->user->node && !(ct->user->node->flag & NODE_ACTIVE_TEXTURE)) { ButsTextureUser *user; /* detect change of active texture node in same node tree, in that * case we also automatically switch to the other node */ - for(user=ct->users.first; user; user=user->next) { - if(user->ntree == ct->user->ntree && user->node != ct->user->node) { - if(user->node->flag & NODE_ACTIVE_TEXTURE) { + for (user=ct->users.first; user; user=user->next) { + if (user->ntree == ct->user->ntree && user->node != ct->user->node) { + if (user->node->flag & NODE_ACTIVE_TEXTURE) { ct->user = user; ct->index = BLI_findindex(&ct->users, user); break; @@ -318,11 +318,11 @@ 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) { + if (user->node) { ED_node_set_active(CTX_data_main(C), user->ntree, user->node); ct->texture = NULL; } @@ -346,12 +346,12 @@ static void template_texture_user_menu(bContext *C, uiLayout *layout, void *UNUS uiBlock *block = uiLayoutGetBlock(layout); const char *last_category = NULL; - for(user=ct->users.first; user; user=user->next) { + for (user=ct->users.first; user; user=user->next) { uiBut *but; char name[UI_MAX_NAME_STR]; /* add label per category */ - if(!last_category || strcmp(last_category, user->category) != 0) { + if (!last_category || strcmp(last_category, user->category) != 0) { uiItemL(layout, user->category, ICON_NONE); but= block->buttons.last; but->flag= UI_TEXT_LEFT; @@ -380,13 +380,13 @@ 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; - if(!user) { + if (!user) { uiItemL(layout, "No textures in context.", ICON_NONE); return; } @@ -394,7 +394,7 @@ void uiTemplateTextureUser(uiLayout *layout, bContext *C) /* create button */ BLI_snprintf(name, UI_MAX_NAME_STR, "%s", user->name); - if(user->icon) { + if (user->icon) { but = uiDefIconTextMenuBut(block, template_texture_user_menu, NULL, user->icon, name, 0, 0, UI_UNIT_X*4, UI_UNIT_Y, ""); } @@ -417,14 +417,14 @@ 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) { + if (user) { /* select texture */ template_texture_select(C, user, NULL); @@ -446,16 +446,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) { + if (user) { uiBlock *block = uiLayoutGetBlock(layout); uiBut *but; diff --git a/source/blender/editors/space_buttons/space_buttons.c b/source/blender/editors/space_buttons/space_buttons.c index de6c1c2d9b3..f1f4fb37b6e 100644 --- a/source/blender/editors/space_buttons/space_buttons.c +++ b/source/blender/editors/space_buttons/space_buttons.c @@ -97,10 +97,10 @@ static void buttons_free(SpaceLink *sl) { SpaceButs *sbuts= (SpaceButs*) sl; - if(sbuts->path) + if (sbuts->path) MEM_freeN(sbuts->path); - if(sbuts->texuser) { + if (sbuts->texuser) { ButsContextTexture *ct= sbuts->texuser; BLI_freelistN(&ct->users); MEM_freeN(ct); @@ -113,8 +113,8 @@ static void buttons_init(struct wmWindowManager *UNUSED(wm), ScrArea *sa) SpaceButs *sbuts= sa->spacedata.first; /* auto-align based on size */ - if(sbuts->align == BUT_AUTO || !sbuts->align) { - if(sa->winx > sa->winy) + if (sbuts->align == BUT_AUTO || !sbuts->align) { + if (sa->winx > sa->winy) sbuts->align= BUT_HORIZONTAL; else sbuts->align= BUT_VERTICAL; @@ -151,31 +151,31 @@ static void buttons_main_area_draw(const bContext *C, ARegion *ar) buttons_context_compute(C, sbuts); - if(sbuts->mainb == BCONTEXT_SCENE) + if (sbuts->mainb == BCONTEXT_SCENE) ED_region_panels(C, ar, vertical, "scene", sbuts->mainb); - else if(sbuts->mainb == BCONTEXT_RENDER) + else if (sbuts->mainb == BCONTEXT_RENDER) ED_region_panels(C, ar, vertical, "render", sbuts->mainb); - else if(sbuts->mainb == BCONTEXT_WORLD) + else if (sbuts->mainb == BCONTEXT_WORLD) ED_region_panels(C, ar, vertical, "world", sbuts->mainb); - else if(sbuts->mainb == BCONTEXT_OBJECT) + else if (sbuts->mainb == BCONTEXT_OBJECT) ED_region_panels(C, ar, vertical, "object", sbuts->mainb); - else if(sbuts->mainb == BCONTEXT_DATA) + else if (sbuts->mainb == BCONTEXT_DATA) ED_region_panels(C, ar, vertical, "data", sbuts->mainb); - else if(sbuts->mainb == BCONTEXT_MATERIAL) + else if (sbuts->mainb == BCONTEXT_MATERIAL) ED_region_panels(C, ar, vertical, "material", sbuts->mainb); - else if(sbuts->mainb == BCONTEXT_TEXTURE) + else if (sbuts->mainb == BCONTEXT_TEXTURE) ED_region_panels(C, ar, vertical, "texture", sbuts->mainb); - else if(sbuts->mainb == BCONTEXT_PARTICLE) + else if (sbuts->mainb == BCONTEXT_PARTICLE) ED_region_panels(C, ar, vertical, "particle", sbuts->mainb); - else if(sbuts->mainb == BCONTEXT_PHYSICS) + else if (sbuts->mainb == BCONTEXT_PHYSICS) ED_region_panels(C, ar, vertical, "physics", sbuts->mainb); - else if(sbuts->mainb == BCONTEXT_BONE) + else if (sbuts->mainb == BCONTEXT_BONE) ED_region_panels(C, ar, vertical, "bone", sbuts->mainb); - else if(sbuts->mainb == BCONTEXT_MODIFIER) + else if (sbuts->mainb == BCONTEXT_MODIFIER) ED_region_panels(C, ar, vertical, "modifier", sbuts->mainb); else if (sbuts->mainb == BCONTEXT_CONSTRAINT) ED_region_panels(C, ar, vertical, "constraint", sbuts->mainb); - else if(sbuts->mainb == BCONTEXT_BONE_CONSTRAINT) + else if (sbuts->mainb == BCONTEXT_BONE_CONSTRAINT) ED_region_panels(C, ar, vertical, "bone_constraint", sbuts->mainb); sbuts->re_align= 0; @@ -224,7 +224,7 @@ static void buttons_area_redraw(ScrArea *sa, short buttons) SpaceButs *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); } @@ -276,7 +276,7 @@ static void buttons_area_listener(ScrArea *sa, wmNotifier *wmn) 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 buttons_area_redraw(sa, BCONTEXT_MODIFIER); @@ -342,11 +342,11 @@ static void buttons_area_listener(ScrArea *sa, wmNotifier *wmn) sbuts->preview= 1; 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: @@ -358,10 +358,10 @@ static void buttons_area_listener(ScrArea *sa, wmNotifier *wmn) } break; case NC_NODE: - if(wmn->action==NA_SELECTED) { + 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; @@ -372,7 +372,7 @@ static void buttons_area_listener(ScrArea *sa, wmNotifier *wmn) break; } - if(wmn->data == ND_KEYS) + if (wmn->data == ND_KEYS) ED_area_tag_redraw(sa); } diff --git a/source/blender/editors/space_clip/clip_buttons.c b/source/blender/editors/space_clip/clip_buttons.c index 0b191b7e1a5..bb816d1b8b2 100644 --- a/source/blender/editors/space_clip/clip_buttons.c +++ b/source/blender/editors/space_clip/clip_buttons.c @@ -85,17 +85,17 @@ void uiTemplateMovieClip(uiLayout *layout, bContext *C, PointerRNA *ptr, const c uiLayout *row, *split; uiBlock *block; - if(!ptr->data) + if (!ptr->data) return; prop= RNA_struct_find_property(ptr, propname); - if(!prop) { + if (!prop) { printf("%s: property not found: %s.%s\n", __func__, RNA_struct_identifier(ptr->type), propname); return; } - if(RNA_property_type(prop) != PROP_POINTER) { + if (RNA_property_type(prop) != PROP_POINTER) { printf("%s: expected pointer property for %s.%s\n", __func__, RNA_struct_identifier(ptr->type), propname); return; @@ -106,10 +106,10 @@ void uiTemplateMovieClip(uiLayout *layout, bContext *C, PointerRNA *ptr, const c uiLayoutSetContextPointer(layout, "edit_movieclip", &clipptr); - if(!compact) + if (!compact) uiTemplateID(layout, C, ptr, propname, NULL, "CLIP_OT_open", NULL); - if(clip) { + if (clip) { row= uiLayoutRow(layout, 0); block= uiLayoutGetBlock(row); uiDefBut(block, LABEL, 0, "File Path:", 0, 19, 145, 19, NULL, 0, 0, 0, 0, ""); @@ -133,17 +133,17 @@ void uiTemplateTrack(uiLayout *layout, PointerRNA *ptr, const char *propname) rctf rect; MovieClipScopes *scopes; - if(!ptr->data) + if (!ptr->data) return; prop= RNA_struct_find_property(ptr, propname); - if(!prop) { + if (!prop) { printf("%s: property not found: %s.%s\n", __func__, RNA_struct_identifier(ptr->type), propname); return; } - if(RNA_property_type(prop) != PROP_POINTER) { + if (RNA_property_type(prop) != PROP_POINTER) { printf("%s: expected pointer property for %s.%s\n", __func__, RNA_struct_identifier(ptr->type), propname); return; @@ -198,7 +198,7 @@ static void marker_update_cb(bContext *C, void *arg_cb, void *UNUSED(arg)) MarkerUpdateCb *cb= (MarkerUpdateCb*) arg_cb; MovieTrackingMarker *marker; - if(!cb->compact) + if (!cb->compact) return; marker= BKE_tracking_ensure_marker(cb->track, cb->framenr); @@ -218,7 +218,7 @@ static void marker_block_handler(bContext *C, void *arg_cb, int event) marker= BKE_tracking_ensure_marker(cb->track, cb->framenr); - if(event==B_MARKER_POS) { + if (event==B_MARKER_POS) { marker->pos[0]= cb->marker_pos[0]/width; marker->pos[1]= cb->marker_pos[1]/height; @@ -228,7 +228,7 @@ static void marker_block_handler(bContext *C, void *arg_cb, int event) ok= 1; } - else if(event==B_MARKER_PAT_DIM) { + else if (event==B_MARKER_PAT_DIM) { float dim[2], pat_dim[2]; sub_v2_v2v2(pat_dim, cb->track->pat_max, cb->track->pat_min); @@ -249,7 +249,7 @@ static void marker_block_handler(bContext *C, void *arg_cb, int event) ok= 1; } - else if(event==B_MARKER_SEARCH_POS) { + else if (event==B_MARKER_SEARCH_POS) { float delta[2], side[2]; sub_v2_v2v2(side, cb->track->search_max, cb->track->search_min); @@ -265,7 +265,7 @@ static void marker_block_handler(bContext *C, void *arg_cb, int event) ok= 1; } - else if(event==B_MARKER_SEARCH_DIM) { + else if (event==B_MARKER_SEARCH_DIM) { float dim[2], search_dim[2]; sub_v2_v2v2(search_dim, cb->track->search_max, cb->track->search_min); @@ -285,11 +285,13 @@ static void marker_block_handler(bContext *C, void *arg_cb, int event) BKE_tracking_clamp_track(cb->track, CLAMP_SEARCH_DIM); ok= 1; - } else if(event==B_MARKER_FLAG) { + } + else if (event==B_MARKER_FLAG) { marker->flag= cb->marker_flag; ok= 1; - } else if(event==B_MARKER_OFFSET) { + } + else if (event==B_MARKER_OFFSET) { float offset[2], delta[2]; int i; @@ -299,7 +301,7 @@ static void marker_block_handler(bContext *C, void *arg_cb, int event) sub_v2_v2v2(delta, offset, cb->track->offset); copy_v2_v2(cb->track->offset, offset); - for(i=0; itrack->markersnr; i++) + for (i=0; itrack->markersnr; i++) sub_v2_v2(cb->track->markers[i].pos, delta); /* to update position of "parented" objects */ @@ -309,7 +311,7 @@ static void marker_block_handler(bContext *C, void *arg_cb, int event) ok= 1; } - if(ok) + if (ok) WM_event_add_notifier(C, NC_MOVIECLIP|NA_EDITED, cb->clip); } @@ -326,17 +328,17 @@ void uiTemplateMarker(uiLayout *layout, PointerRNA *ptr, const char *propname, P MarkerUpdateCb *cb; const char *tip; - if(!ptr->data) + if (!ptr->data) return; prop= RNA_struct_find_property(ptr, propname); - if(!prop) { + if (!prop) { printf("%s: property not found: %s.%s\n", __func__, RNA_struct_identifier(ptr->type), propname); return; } - if(RNA_property_type(prop) != PROP_POINTER) { + if (RNA_property_type(prop) != PROP_POINTER) { printf("%s: expected pointer property for %s.%s\n", __func__, RNA_struct_identifier(ptr->type), propname); return; @@ -357,24 +359,25 @@ void uiTemplateMarker(uiLayout *layout, PointerRNA *ptr, const char *propname, P cb->marker_flag= marker->flag; cb->framenr= user->framenr; - if(compact) { + if (compact) { block= uiLayoutGetBlock(layout); - if(cb->marker_flag&MARKER_DISABLED) + if (cb->marker_flag&MARKER_DISABLED) tip= "Marker is disabled at current frame"; else tip= "Marker is enabled at current frame"; bt= uiDefIconButBitI(block, TOGN, MARKER_DISABLED, 0, ICON_RESTRICT_VIEW_OFF, 0, 0, 20, 20, &cb->marker_flag, 0, 0, 1, 0, tip); uiButSetNFunc(bt, marker_update_cb, cb, NULL); - } else { + } + else { int width, height, step, digits; float pat_dim[2], pat_pos[2], search_dim[2], search_pos[2]; uiLayout *col; BKE_movieclip_get_size(clip, user, &width, &height); - if(track->flag&TRACK_LOCKED) { + if (track->flag&TRACK_LOCKED) { uiLayoutSetActive(layout, 0); block= uiLayoutAbsoluteBlock(layout); uiDefBut(block, LABEL, 0, "Track is locked", 0, 0, 300, 19, NULL, 0, 0, 0, 0, ""); @@ -406,7 +409,7 @@ void uiTemplateMarker(uiLayout *layout, PointerRNA *ptr, const char *propname, P uiBlockSetHandleFunc(block, marker_block_handler, cb); uiBlockSetNFunc(block, marker_update_cb, cb, NULL); - if(cb->marker_flag&MARKER_DISABLED) + if (cb->marker_flag&MARKER_DISABLED) tip= "Marker is disabled at current frame"; else tip= "Marker is enabled at current frame"; diff --git a/source/blender/editors/space_clip/clip_draw.c b/source/blender/editors/space_clip/clip_draw.c index 920b8dc3ccb..ef83a62c290 100644 --- a/source/blender/editors/space_clip/clip_draw.c +++ b/source/blender/editors/space_clip/clip_draw.c @@ -107,10 +107,10 @@ static void draw_movieclip_cache(SpaceClip *sc, ARegion *ar, MovieClip *clip, Sc /* cached segments -- could be usefu lto debug caching strategies */ BKE_movieclip_get_cache_segments(clip, &sc->user, &totseg, &points); - if(totseg) { + if (totseg) { glColor4ub(128, 128, 255, 128); - for(a= 0; awinx; @@ -121,31 +121,31 @@ static void draw_movieclip_cache(SpaceClip *sc, ARegion *ar, MovieClip *clip, Sc } /* track */ - if(act_track) { + if (act_track) { MovieTrackingTrack *track= act_track; - for(i= sfra, a= 0; i <= efra; i++) { + for (i= sfra, a= 0; i <= efra; i++) { int framenr; MovieTrackingMarker *marker; - while(amarkersnr) { - if(track->markers[a].framenr>=i) + while (amarkersnr) { + if (track->markers[a].framenr>=i) break; - if(amarkersnr-1 && track->markers[a+1].framenr>i) + if (amarkersnr-1 && track->markers[a+1].framenr>i) break; a++; } - if(amarkersnr) marker= &track->markers[a]; + if (amarkersnr) marker= &track->markers[a]; else marker= &track->markers[track->markersnr-1]; - if((marker->flag&MARKER_DISABLED)==0) { + if ((marker->flag&MARKER_DISABLED)==0) { framenr= marker->framenr; - if(framenr!=i) glColor4ub(128, 128, 0, 96); - else if((marker->flag&MARKER_TRACKED)==0) glColor4ub(255, 255, 0, 196); + if (framenr!=i) glColor4ub(128, 128, 0, 96); + else if ((marker->flag&MARKER_TRACKED)==0) glColor4ub(255, 255, 0, 196); else glColor4ub(255, 255, 0, 96); glRecti((i-sfra)*framelen, 0, (i-sfra+1)*framelen, 4); @@ -154,28 +154,28 @@ static void draw_movieclip_cache(SpaceClip *sc, ARegion *ar, MovieClip *clip, Sc } /* failed frames */ - if(reconstruction->flag&TRACKING_RECONSTRUCTED) { + if (reconstruction->flag&TRACKING_RECONSTRUCTED) { int n= reconstruction->camnr; MovieReconstructedCamera *cameras= reconstruction->cameras; glColor4ub(255, 0, 0, 96); - for(i= sfra, a= 0; i <= efra; i++) { + for (i= sfra, a= 0; i <= efra; i++) { int ok= 0; - while(ai) { + else if (cameras[a].framenr>i) { break; } a++; } - if(!ok) + if (!ok) glRecti((i-sfra)*framelen, 0, (i-sfra+1)*framelen, 8); } } @@ -198,15 +198,16 @@ static void draw_movieclip_notes(SpaceClip *sc, ARegion *ar) char str[256]= {0}; int block= 0; - if(tracking->stats) { + if (tracking->stats) { BLI_strncpy(str, tracking->stats->message, sizeof(str)); block= 1; - } else { - if(sc->flag&SC_LOCK_SELECTION) + } + else { + if (sc->flag&SC_LOCK_SELECTION) strcpy(str, "Locked"); } - if(str[0]) + if (str[0]) ED_region_info_draw(ar, str, block, 0.6f); } @@ -222,20 +223,21 @@ static void draw_movieclip_buffer(SpaceClip *sc, ARegion *ar, ImBuf *ibuf, /* find window pixel coordinates of origin */ UI_view2d_to_region_no_clip(&ar->v2d, 0.0f, 0.0f, &x, &y); - if(sc->flag&SC_MUTE_FOOTAGE) { + if (sc->flag&SC_MUTE_FOOTAGE) { glColor3f(0.0f, 0.0f, 0.0f); glRectf(x, y, x+zoomx*width, y+zoomy*height); - } else { - if(ibuf->rect_float && !ibuf->rect) { + } + else { + if (ibuf->rect_float && !ibuf->rect) { IMB_rect_from_float(ibuf); } - if(ibuf->rect) + if (ibuf->rect) glaDrawPixelsSafe(x, y, ibuf->x, ibuf->y, ibuf->x, GL_RGBA, GL_UNSIGNED_BYTE, ibuf->rect); } /* draw boundary border for frame if stabilization is enabled */ - if(sc->flag&SC_SHOW_STABLE && clip->tracking.stabilization.flag&TRACKING_2D_STABILIZATION) { + if (sc->flag&SC_SHOW_STABLE && clip->tracking.stabilization.flag&TRACKING_2D_STABILIZATION) { glColor3f(0.0f, 0.0f, 0.0f); glLineStipple(3, 0xaaaa); glEnable(GL_LINE_STIPPLE); @@ -274,63 +276,66 @@ static void draw_track_path(SpaceClip *sc, MovieClip *UNUSED(clip), MovieTrackin int tiny= sc->flag&SC_SHOW_TINY_MARKER, framenr; MovieTrackingMarker *marker; - if(count==0) + if (count==0) return; marker= BKE_tracking_get_marker(track, sc->user.framenr); - if(marker->framenr!=sc->user.framenr || marker->flag&MARKER_DISABLED) + if (marker->framenr!=sc->user.framenr || marker->flag&MARKER_DISABLED) return; framenr= marker->framenr; a= count; i= framenr-1; - while(i>=framenr-count) { + while (i>=framenr-count) { marker= BKE_tracking_get_marker(track, i); - if(!marker || marker->flag&MARKER_DISABLED) + if (!marker || marker->flag&MARKER_DISABLED) break; - if(marker->framenr==i) { + if (marker->framenr==i) { add_v2_v2v2(path[--a], marker->pos, track->offset); ED_clip_point_undistorted_pos(sc, path[a], path[a]); - if(marker->framenr==sc->user.framenr) + if (marker->framenr==sc->user.framenr) curindex= a; - } else + } + else { break; + } i--; } b= count; i= framenr; - while(i<=framenr+count) { + while (i<=framenr+count) { marker= BKE_tracking_get_marker(track, i); - if(!marker || marker->flag&MARKER_DISABLED) + if (!marker || marker->flag&MARKER_DISABLED) break; - if(marker->framenr==i) { - if(marker->framenr==sc->user.framenr) + if (marker->framenr==i) { + if (marker->framenr==sc->user.framenr) curindex= b; add_v2_v2v2(path[b++], marker->pos, track->offset); ED_clip_point_undistorted_pos(sc, path[b-1], path[b-1]); - } else + } + else break; i++; } - if(!tiny) { + if (!tiny) { UI_ThemeColor(TH_MARKER_OUTLINE); - if(TRACK_VIEW_SELECTED(sc, track)) { + if (TRACK_VIEW_SELECTED(sc, track)) { glPointSize(5.0f); glBegin(GL_POINTS); - for(i= a; izoom; px[1]= 1.0f/height/sc->zoom; - if((marker->flag&MARKER_DISABLED)==0) { + if ((marker->flag&MARKER_DISABLED)==0) { float pos[2]; rctf r; @@ -392,15 +397,16 @@ static void draw_marker_outline(SpaceClip *sc, MovieTrackingTrack *track, MovieT ED_clip_point_undistorted_pos(sc, pos, pos); - if(BLI_in_rctf(&r, pos[0]-marker_pos[0], pos[1]-marker_pos[1])) { - if(tiny) glPointSize(3.0f); + if (BLI_in_rctf(&r, pos[0]-marker_pos[0], pos[1]-marker_pos[1])) { + if (tiny) glPointSize(3.0f); else glPointSize(4.0f); glBegin(GL_POINTS); glVertex2f(pos[0], pos[1]); glEnd(); glPointSize(1.0f); - } else { - if(!tiny) glLineWidth(3.0f); + } + else { + if (!tiny) glLineWidth(3.0f); glBegin(GL_LINES); glVertex2f(pos[0] + px[0]*2, pos[1]); glVertex2f(pos[0] + px[0]*8, pos[1]); @@ -414,7 +420,7 @@ static void draw_marker_outline(SpaceClip *sc, MovieTrackingTrack *track, MovieT glVertex2f(pos[0], pos[1] + px[1]*2); glVertex2f(pos[0], pos[1] + px[1]*8); glEnd(); - if(!tiny) glLineWidth(1.0f); + if (!tiny) glLineWidth(1.0f); } } @@ -422,9 +428,9 @@ static void draw_marker_outline(SpaceClip *sc, MovieTrackingTrack *track, MovieT glPushMatrix(); glTranslatef(marker_pos[0], marker_pos[1], 0); - if(!tiny) glLineWidth(3.0f); + if (!tiny) glLineWidth(3.0f); - if(sc->flag&SC_SHOW_MARKER_PATTERN) { + if (sc->flag&SC_SHOW_MARKER_PATTERN) { glBegin(GL_LINE_LOOP); glVertex2f(track->pat_min[0], track->pat_min[1]); glVertex2f(track->pat_max[0], track->pat_min[1]); @@ -434,7 +440,7 @@ static void draw_marker_outline(SpaceClip *sc, MovieTrackingTrack *track, MovieT } show_search= TRACK_VIEW_SELECTED(sc, track) && ((marker->flag&MARKER_DISABLED)==0 || (sc->flag&SC_SHOW_MARKER_PATTERN)==0); - if(sc->flag&SC_SHOW_MARKER_SEARCH && show_search) { + if (sc->flag&SC_SHOW_MARKER_SEARCH && show_search) { glBegin(GL_LINE_LOOP); glVertex2f(track->search_min[0], track->search_min[1]); glVertex2f(track->search_max[0], track->search_min[1]); @@ -444,20 +450,21 @@ static void draw_marker_outline(SpaceClip *sc, MovieTrackingTrack *track, MovieT } glPopMatrix(); - if(!tiny) glLineWidth(1.0f); + if (!tiny) glLineWidth(1.0f); } static void track_colors(MovieTrackingTrack *track, int act, float col[3], float scol[3]) { - if(track->flag&TRACK_CUSTOMCOLOR) { - if(act) UI_GetThemeColor3fv(TH_ACT_MARKER, scol); + if (track->flag&TRACK_CUSTOMCOLOR) { + if (act) UI_GetThemeColor3fv(TH_ACT_MARKER, scol); else copy_v3_v3(scol, track->color); mul_v3_v3fl(col, track->color, 0.5f); - } else { + } + else { UI_GetThemeColor3fv(TH_MARKER, col); - if(act) UI_GetThemeColor3fv(TH_ACT_MARKER, scol); + if (act) UI_GetThemeColor3fv(TH_ACT_MARKER, scol); else UI_GetThemeColor3fv(TH_SEL_MARKER, scol); } } @@ -474,16 +481,17 @@ static void draw_marker_areas(SpaceClip *sc, MovieTrackingTrack *track, MovieTra px[1]= 1.0f/height/sc->zoom; /* marker position and offset position */ - if((track->flag&SELECT)==sel && (marker->flag&MARKER_DISABLED)==0) { + if ((track->flag&SELECT)==sel && (marker->flag&MARKER_DISABLED)==0) { float pos[2]; rctf r; - if(track->flag&TRACK_LOCKED) { - if(act) UI_ThemeColor(TH_ACT_MARKER); - else if(track->flag&SELECT) UI_ThemeColorShade(TH_LOCK_MARKER, 64); + if (track->flag&TRACK_LOCKED) { + if (act) UI_ThemeColor(TH_ACT_MARKER); + else if (track->flag&SELECT) UI_ThemeColorShade(TH_LOCK_MARKER, 64); else UI_ThemeColor(TH_LOCK_MARKER); - } else { - if(track->flag&SELECT) glColor3fv(scol); + } + else { + if (track->flag&SELECT) glColor3fv(scol); else glColor3fv(col); } @@ -491,13 +499,14 @@ static void draw_marker_areas(SpaceClip *sc, MovieTrackingTrack *track, MovieTra add_v2_v2v2(pos, marker->pos, track->offset); ED_clip_point_undistorted_pos(sc, pos, pos); - if(BLI_in_rctf(&r, pos[0]-marker_pos[0], pos[1]-marker_pos[1])) { - if(!tiny) glPointSize(2.0f); + if (BLI_in_rctf(&r, pos[0]-marker_pos[0], pos[1]-marker_pos[1])) { + if (!tiny) glPointSize(2.0f); glBegin(GL_POINTS); glVertex2f(pos[0], pos[1]); glEnd(); - if(!tiny) glPointSize(1.0f); - } else { + if (!tiny) glPointSize(1.0f); + } + else { glBegin(GL_LINES); glVertex2f(pos[0] + px[0]*3, pos[1]); glVertex2f(pos[0] + px[0]*7, pos[1]); @@ -532,23 +541,24 @@ static void draw_marker_areas(SpaceClip *sc, MovieTrackingTrack *track, MovieTra glPushMatrix(); glTranslatef(marker_pos[0], marker_pos[1], 0); - if(tiny) { + if (tiny) { glLineStipple(3, 0xaaaa); glEnable(GL_LINE_STIPPLE); } - if((track->pat_flag&SELECT)==sel && (sc->flag&SC_SHOW_MARKER_PATTERN)) { - if(track->flag&TRACK_LOCKED) { - if(act) UI_ThemeColor(TH_ACT_MARKER); - else if(track->pat_flag&SELECT) UI_ThemeColorShade(TH_LOCK_MARKER, 64); + if ((track->pat_flag&SELECT)==sel && (sc->flag&SC_SHOW_MARKER_PATTERN)) { + if (track->flag&TRACK_LOCKED) { + if (act) UI_ThemeColor(TH_ACT_MARKER); + else if (track->pat_flag&SELECT) UI_ThemeColorShade(TH_LOCK_MARKER, 64); else UI_ThemeColor(TH_LOCK_MARKER); } - else if(marker->flag&MARKER_DISABLED) { - if(act) UI_ThemeColor(TH_ACT_MARKER); - else if(track->pat_flag&SELECT) UI_ThemeColorShade(TH_DIS_MARKER, 128); + else if (marker->flag&MARKER_DISABLED) { + if (act) UI_ThemeColor(TH_ACT_MARKER); + else if (track->pat_flag&SELECT) UI_ThemeColorShade(TH_DIS_MARKER, 128); else UI_ThemeColor(TH_DIS_MARKER); - } else { - if(track->pat_flag&SELECT) glColor3fv(scol); + } + else { + if (track->pat_flag&SELECT) glColor3fv(scol); else glColor3fv(col); } @@ -562,18 +572,19 @@ static void draw_marker_areas(SpaceClip *sc, MovieTrackingTrack *track, MovieTra /* search */ show_search= TRACK_VIEW_SELECTED(sc, track) && ((marker->flag&MARKER_DISABLED)==0 || (sc->flag&SC_SHOW_MARKER_PATTERN)==0); - if((track->search_flag&SELECT)==sel && (sc->flag&SC_SHOW_MARKER_SEARCH) && show_search) { - if(track->flag&TRACK_LOCKED) { - if(act) UI_ThemeColor(TH_ACT_MARKER); - else if(track->search_flag&SELECT) UI_ThemeColorShade(TH_LOCK_MARKER, 64); + if ((track->search_flag&SELECT)==sel && (sc->flag&SC_SHOW_MARKER_SEARCH) && show_search) { + if (track->flag&TRACK_LOCKED) { + if (act) UI_ThemeColor(TH_ACT_MARKER); + else if (track->search_flag&SELECT) UI_ThemeColorShade(TH_LOCK_MARKER, 64); else UI_ThemeColor(TH_LOCK_MARKER); } - else if(marker->flag&MARKER_DISABLED) { - if(act) UI_ThemeColor(TH_ACT_MARKER); - else if(track->search_flag&SELECT) UI_ThemeColorShade(TH_DIS_MARKER, 128); + else if (marker->flag&MARKER_DISABLED) { + if (act) UI_ThemeColor(TH_ACT_MARKER); + else if (track->search_flag&SELECT) UI_ThemeColorShade(TH_DIS_MARKER, 128); else UI_ThemeColor(TH_DIS_MARKER); - } else { - if(track->search_flag&SELECT) glColor3fv(scol); + } + else { + if (track->search_flag&SELECT) glColor3fv(scol); else glColor3fv(col); } @@ -586,18 +597,19 @@ static void draw_marker_areas(SpaceClip *sc, MovieTrackingTrack *track, MovieTra } /* pyramid */ - if(sel && TRACK_VIEW_SELECTED(sc, track) && (track->tracker==TRACKER_KLT) && (marker->flag&MARKER_DISABLED)==0) { - if(track->flag&TRACK_LOCKED) { - if(act) UI_ThemeColor(TH_ACT_MARKER); - else if(track->pat_flag&SELECT) UI_ThemeColorShade(TH_LOCK_MARKER, 64); + if (sel && TRACK_VIEW_SELECTED(sc, track) && (track->tracker==TRACKER_KLT) && (marker->flag&MARKER_DISABLED)==0) { + if (track->flag&TRACK_LOCKED) { + if (act) UI_ThemeColor(TH_ACT_MARKER); + else if (track->pat_flag&SELECT) UI_ThemeColorShade(TH_LOCK_MARKER, 64); else UI_ThemeColor(TH_LOCK_MARKER); } - else if(marker->flag&MARKER_DISABLED) { - if(act) UI_ThemeColor(TH_ACT_MARKER); - else if(track->pat_flag&SELECT) UI_ThemeColorShade(TH_DIS_MARKER, 128); + else if (marker->flag&MARKER_DISABLED) { + if (act) UI_ThemeColor(TH_ACT_MARKER); + else if (track->pat_flag&SELECT) UI_ThemeColorShade(TH_DIS_MARKER, 128); else UI_ThemeColor(TH_DIS_MARKER); - } else { - if(track->pat_flag&SELECT) glColor3fv(scol); + } + else { + if (track->pat_flag&SELECT) glColor3fv(scol); else glColor3fv(col); } @@ -620,7 +632,7 @@ static void draw_marker_areas(SpaceClip *sc, MovieTrackingTrack *track, MovieTra } } - if(tiny) + if (tiny) glDisable(GL_LINE_STIPPLE); glPopMatrix(); @@ -633,15 +645,15 @@ static void draw_marker_slide_zones(SpaceClip *sc, MovieTrackingTrack *track, Mo int tiny= sc->flag&SC_SHOW_TINY_MARKER; float col[3], scol[3], px[2]; - if((tiny && outline) || (marker->flag&MARKER_DISABLED)) + if ((tiny && outline) || (marker->flag&MARKER_DISABLED)) return; - if(!TRACK_VIEW_SELECTED(sc, track) || track->flag&TRACK_LOCKED) + if (!TRACK_VIEW_SELECTED(sc, track) || track->flag&TRACK_LOCKED) return; track_colors(track, act, col, scol); - if(outline) { + if (outline) { glLineWidth(3.0f); UI_ThemeColor(TH_MARKER_OUTLINE); } @@ -661,9 +673,9 @@ static void draw_marker_slide_zones(SpaceClip *sc, MovieTrackingTrack *track, Mo px[0]= 1.0f/sc->zoom/width/sc->scale; px[1]= 1.0f/sc->zoom/height/sc->scale; - if((sc->flag&SC_SHOW_MARKER_SEARCH) && ((track->search_flag&SELECT)==sel || outline)) { - if(!outline) { - if(track->search_flag&SELECT) glColor3fv(scol); + if ((sc->flag&SC_SHOW_MARKER_SEARCH) && ((track->search_flag&SELECT)==sel || outline)) { + if (!outline) { + if (track->search_flag&SELECT) glColor3fv(scol); else glColor3fv(col); } @@ -674,7 +686,7 @@ static void draw_marker_slide_zones(SpaceClip *sc, MovieTrackingTrack *track, Mo tdx= searchdx; tdy= searchdy; - if(outline) { + if (outline) { tdx+= px[0]; tdy+= px[1]; } @@ -693,7 +705,7 @@ static void draw_marker_slide_zones(SpaceClip *sc, MovieTrackingTrack *track, Mo tdx= searchdx*2.0f; tdy= searchdy*2.0f; - if(outline) { + if (outline) { tdx+= px[0]; tdy+= px[1]; } @@ -705,9 +717,9 @@ static void draw_marker_slide_zones(SpaceClip *sc, MovieTrackingTrack *track, Mo glEnd(); } - if((sc->flag&SC_SHOW_MARKER_PATTERN) && ((track->pat_flag&SELECT)==sel || outline)) { - if(!outline) { - if(track->pat_flag&SELECT) glColor3fv(scol); + if ((sc->flag&SC_SHOW_MARKER_PATTERN) && ((track->pat_flag&SELECT)==sel || outline)) { + if (!outline) { + if (track->pat_flag&SELECT) glColor3fv(scol); else glColor3fv(col); } @@ -718,7 +730,7 @@ static void draw_marker_slide_zones(SpaceClip *sc, MovieTrackingTrack *track, Mo tdx= patdx; tdy= patdy; - if(outline) { + if (outline) { tdx+= px[0]; tdy+= px[1]; } @@ -737,7 +749,7 @@ static void draw_marker_slide_zones(SpaceClip *sc, MovieTrackingTrack *track, Mo tdx= patdx*2.0f; tdy= patdy*2.0f; - if(outline) { + if (outline) { tdx+= px[0]; tdy+= px[1]; } @@ -751,7 +763,7 @@ static void draw_marker_slide_zones(SpaceClip *sc, MovieTrackingTrack *track, Mo glPopMatrix(); - if(outline) + if (outline) glLineWidth(1.0f); } @@ -763,26 +775,28 @@ static void draw_marker_texts(SpaceClip *sc, MovieTrackingTrack *track, MovieTra uiStyle *style= U.uistyles.first; int fontid= style->widget.uifont_id; - if(!TRACK_VIEW_SELECTED(sc, track)) + if (!TRACK_VIEW_SELECTED(sc, track)) return; BLF_size(fontid, 11.0f, U.dpi); fontsize= BLF_height_max(fontid); - if(marker->flag&MARKER_DISABLED) { - if(act) UI_ThemeColor(TH_ACT_MARKER); + if (marker->flag&MARKER_DISABLED) { + if (act) UI_ThemeColor(TH_ACT_MARKER); else UI_ThemeColorShade(TH_DIS_MARKER, 128); - } else { - if(act) UI_ThemeColor(TH_ACT_MARKER); + } + else { + if (act) UI_ThemeColor(TH_ACT_MARKER); else UI_ThemeColor(TH_SEL_MARKER); } - if((sc->flag&SC_SHOW_MARKER_SEARCH) && + if ((sc->flag&SC_SHOW_MARKER_SEARCH) && ((marker->flag&MARKER_DISABLED)==0 || (sc->flag&SC_SHOW_MARKER_PATTERN)==0)) { dx= track->search_min[0]; dy= track->search_min[1]; - } else if(sc->flag&SC_SHOW_MARKER_PATTERN) { + } + else if (sc->flag&SC_SHOW_MARKER_PATTERN) { dx= track->pat_min[0]; dy= track->pat_min[1]; } @@ -796,12 +810,12 @@ static void draw_marker_texts(SpaceClip *sc, MovieTrackingTrack *track, MovieTra pos[0]= pos[0]*zoomx; pos[1]= pos[1]*zoomy - fontsize; - if(marker->flag&MARKER_DISABLED) strcpy(state, "disabled"); - else if(marker->framenr!=sc->user.framenr) strcpy(state, "estimated"); - else if(marker->flag&MARKER_TRACKED) strcpy(state, "tracked"); + if (marker->flag&MARKER_DISABLED) strcpy(state, "disabled"); + else if (marker->framenr!=sc->user.framenr) strcpy(state, "estimated"); + else if (marker->flag&MARKER_TRACKED) strcpy(state, "tracked"); else strcpy(state, "keyframed"); - if(state[0]) + if (state[0]) BLI_snprintf(str, sizeof(str), "%s: %s", track->name, state); else BLI_snprintf(str, sizeof(str), "%s", track->name); @@ -810,14 +824,14 @@ static void draw_marker_texts(SpaceClip *sc, MovieTrackingTrack *track, MovieTra BLF_draw(fontid, str, sizeof(str)); pos[1]-= fontsize; - if(track->flag&TRACK_HAS_BUNDLE) { + if (track->flag&TRACK_HAS_BUNDLE) { BLI_snprintf(str, sizeof(str), "Average error: %.3f", track->error); BLF_position(fontid, pos[0], pos[1], 0.0f); BLF_draw(fontid, str, sizeof(str)); pos[1]-= fontsize; } - if(track->flag&TRACK_LOCKED) { + if (track->flag&TRACK_LOCKED) { BLF_position(fontid, pos[0], pos[1], 0.0f); BLF_draw(fontid, "locked", 6); } @@ -865,16 +879,16 @@ static void draw_tracking_tracks(SpaceClip *sc, ARegion *ar, MovieClip *clip, act_track= BKE_tracking_active_track(tracking); - if(sc->user.render_flag&MCLIP_PROXY_RENDER_UNDISTORT) { + if (sc->user.render_flag&MCLIP_PROXY_RENDER_UNDISTORT) { int count= 0; /* count */ track= tracksbase->first; - while(track) { - if((track->flag&TRACK_HIDDEN)==0) { + while (track) { + if ((track->flag&TRACK_HIDDEN)==0) { marker= BKE_tracking_get_marker(track, framenr); - if(MARKER_VISIBLE(sc, marker)) + if (MARKER_VISIBLE(sc, marker)) count++; } @@ -882,19 +896,19 @@ static void draw_tracking_tracks(SpaceClip *sc, ARegion *ar, MovieClip *clip, } /* undistort */ - if(count) { + if (count) { marker_pos= MEM_callocN(2*sizeof(float)*count, "draw_tracking_tracks marker_pos"); track= tracksbase->first; fp= marker_pos; - while(track) { - if((track->flag&TRACK_HIDDEN)==0) { + while (track) { + if ((track->flag&TRACK_HIDDEN)==0) { marker= BKE_tracking_get_marker(track, framenr); - if(MARKER_VISIBLE(sc, marker)) { + if (MARKER_VISIBLE(sc, marker)) { ED_clip_point_undistorted_pos(sc, marker->pos, fp); - if(track==act_track) + if (track==act_track) active_pos= fp; fp+= 2; @@ -906,10 +920,10 @@ static void draw_tracking_tracks(SpaceClip *sc, ARegion *ar, MovieClip *clip, } } - if(sc->flag&SC_SHOW_TRACK_PATH) { + if (sc->flag&SC_SHOW_TRACK_PATH) { track= tracksbase->first; - while(track) { - if((track->flag&TRACK_HIDDEN)==0) + while (track) { + if ((track->flag&TRACK_HIDDEN)==0) draw_track_path(sc, clip, track); track= track->next; @@ -919,11 +933,11 @@ static void draw_tracking_tracks(SpaceClip *sc, ARegion *ar, MovieClip *clip, /* markers outline and non-selected areas */ track= tracksbase->first; fp= marker_pos; - while(track) { - if((track->flag&TRACK_HIDDEN)==0) { + while (track) { + if ((track->flag&TRACK_HIDDEN)==0) { marker= BKE_tracking_get_marker(track, framenr); - if(MARKER_VISIBLE(sc, marker)) { + if (MARKER_VISIBLE(sc, marker)) { copy_v2_v2(cur_pos, fp ? fp : marker->pos); draw_marker_outline(sc, track, marker, cur_pos, width, height); @@ -931,7 +945,7 @@ static void draw_tracking_tracks(SpaceClip *sc, ARegion *ar, MovieClip *clip, draw_marker_slide_zones(sc, track, marker, cur_pos, 1, 0, 0, width, height); draw_marker_slide_zones(sc, track, marker, cur_pos, 0, 0, 0, width, height); - if(fp) + if (fp) fp+= 2; } } @@ -943,20 +957,20 @@ static void draw_tracking_tracks(SpaceClip *sc, ARegion *ar, MovieClip *clip, * non-selected areas */ track= tracksbase->first; fp= marker_pos; - while(track) { - if((track->flag&TRACK_HIDDEN)==0) { + while (track) { + if ((track->flag&TRACK_HIDDEN)==0) { int act= track==act_track; marker= BKE_tracking_get_marker(track, framenr); - if(MARKER_VISIBLE(sc, marker)) { - if(!act) { + if (MARKER_VISIBLE(sc, marker)) { + if (!act) { copy_v2_v2(cur_pos, fp ? fp : marker->pos); draw_marker_areas(sc, track, marker, cur_pos, width, height, 0, 1); draw_marker_slide_zones(sc, track, marker, cur_pos, 0, 1, 0, width, height); } - if(fp) + if (fp) fp+= 2; } } @@ -965,11 +979,11 @@ static void draw_tracking_tracks(SpaceClip *sc, ARegion *ar, MovieClip *clip, } /* active marker would be displayed on top of everything else */ - if(act_track) { - if((act_track->flag&TRACK_HIDDEN)==0) { + if (act_track) { + if ((act_track->flag&TRACK_HIDDEN)==0) { marker= BKE_tracking_get_marker(act_track, framenr); - if(MARKER_VISIBLE(sc, marker)) { + if (MARKER_VISIBLE(sc, marker)) { copy_v2_v2(cur_pos, active_pos ? active_pos : marker->pos); draw_marker_areas(sc, act_track, marker, cur_pos, width, height, 1, 1); @@ -978,7 +992,7 @@ static void draw_tracking_tracks(SpaceClip *sc, ARegion *ar, MovieClip *clip, } } - if(sc->flag&SC_SHOW_BUNDLES) { + if (sc->flag&SC_SHOW_BUNDLES) { MovieTrackingObject *object= BKE_tracking_active_object(tracking); float pos[4], vec[4], mat[4][4], aspy; @@ -989,11 +1003,11 @@ static void draw_tracking_tracks(SpaceClip *sc, ARegion *ar, MovieClip *clip, BKE_tracking_projection_matrix(tracking, object, framenr, width, height, mat); track= tracksbase->first; - while(track) { - if((track->flag&TRACK_HIDDEN)==0 && track->flag&TRACK_HAS_BUNDLE) { + while (track) { + if ((track->flag&TRACK_HIDDEN)==0 && track->flag&TRACK_HAS_BUNDLE) { marker= BKE_tracking_get_marker(track, framenr); - if(MARKER_VISIBLE(sc, marker)) { + if (MARKER_VISIBLE(sc, marker)) { float npos[2]; copy_v4_v4(vec, track->bundle_pos); vec[3]=1; @@ -1005,17 +1019,17 @@ static void draw_tracking_tracks(SpaceClip *sc, ARegion *ar, MovieClip *clip, BKE_tracking_apply_intrinsics(tracking, pos, npos); - if(npos[0]>=0.0f && npos[1]>=0.0f && npos[0]<=width && npos[1]<=height*aspy) { + if (npos[0]>=0.0f && npos[1]>=0.0f && npos[0]<=width && npos[1]<=height*aspy) { vec[0]= (marker->pos[0]+track->offset[0])*width; vec[1]= (marker->pos[1]+track->offset[1])*height*aspy; sub_v2_v2(vec, npos); - if(len_v2(vec)<3) glColor3f(0.0f, 1.0f, 0.0f); + if (len_v2(vec)<3) glColor3f(0.0f, 1.0f, 0.0f); else glColor3f(1.0f, 0.0f, 0.0f); glBegin(GL_POINTS); - if(undistort) glVertex3f(pos[0]/width, pos[1]/(height*aspy), 0); + if (undistort) glVertex3f(pos[0]/width, pos[1]/(height*aspy), 0); else glVertex3f(npos[0]/width, npos[1]/(height*aspy), 0); glEnd(); } @@ -1031,22 +1045,22 @@ static void draw_tracking_tracks(SpaceClip *sc, ARegion *ar, MovieClip *clip, glPopMatrix(); - if(sc->flag&SC_SHOW_NAMES) { + if (sc->flag&SC_SHOW_NAMES) { /* scaling should be cleared before drawing texts, otherwise font would also be scaled */ track= tracksbase->first; fp= marker_pos; - while(track) { - if((track->flag&TRACK_HIDDEN)==0) { + while (track) { + if ((track->flag&TRACK_HIDDEN)==0) { marker= BKE_tracking_get_marker(track, framenr); - if(MARKER_VISIBLE(sc, marker)) { + if (MARKER_VISIBLE(sc, marker)) { int act= track==act_track; copy_v2_v2(cur_pos, fp ? fp : marker->pos); draw_marker_texts(sc, track, marker, cur_pos, act, width, height, zoomx, zoomy); - if(fp) fp+= 2; + if (fp) fp+= 2; } } @@ -1056,7 +1070,7 @@ static void draw_tracking_tracks(SpaceClip *sc, ARegion *ar, MovieClip *clip, glPopMatrix(); - if(marker_pos) + if (marker_pos) MEM_freeN(marker_pos); } @@ -1070,13 +1084,13 @@ static void draw_distortion(SpaceClip *sc, ARegion *ar, MovieClip *clip, int wid float aspy= 1.0f/tracking->camera.pixel_aspect; float dx= (float)width/n, dy= (float)height/n*aspy; - if(sc->mode!=SC_MODE_DISTORTION) + if (sc->mode!=SC_MODE_DISTORTION) return; - if(!tracking->camera.focal) + if (!tracking->camera.focal) return; - if((sc->flag&SC_SHOW_GRID)==0 && (sc->flag&SC_MANUAL_CALIBRATION)==0) + if ((sc->flag&SC_SHOW_GRID)==0 && (sc->flag&SC_MANUAL_CALIBRATION)==0) return; view2d_to_region_float(&ar->v2d, 0.0f, 0.0f, &x, &y); @@ -1088,28 +1102,28 @@ static void draw_distortion(SpaceClip *sc, ARegion *ar, MovieClip *clip, int wid glScalef(width, height, 0); /* grid */ - if(sc->flag&SC_SHOW_GRID) { + if (sc->flag&SC_SHOW_GRID) { float val[4][2], idx[4][2]; float min[2], max[2]; - for(a=0; a<4; a++) { - if(a<2) val[a][a%2]= FLT_MAX; + for (a=0; a<4; a++) { + if (a<2) val[a][a%2]= FLT_MAX; else val[a][a%2]= -FLT_MAX; } zero_v2(pos); - for(i= 0; i<=n; i++) { - for(j= 0; j<=n; j++) { - if(i==0 || j==0 || i==n || j==n) { + for (i= 0; i<=n; i++) { + for (j= 0; j<=n; j++) { + if (i==0 || j==0 || i==n || j==n) { BKE_tracking_apply_intrinsics(tracking, pos, tpos); - for(a=0; a<4; a++) { + for (a=0; a<4; a++) { int ok; - if(a<2) ok= tpos[a%2] < val[a][a%2]; + if (a<2) ok= tpos[a%2] < val[a][a%2]; else ok= tpos[a%2] > val[a][a%2]; - if(ok) { + if (ok) { copy_v2_v2(val[a], tpos); idx[a][0]= j; idx[a][1]= i; @@ -1126,7 +1140,7 @@ static void draw_distortion(SpaceClip *sc, ARegion *ar, MovieClip *clip, int wid INIT_MINMAX2(min, max); - for(a= 0; a<4; a++) { + for (a= 0; a<4; a++) { pos[0]= idx[a][0]*dx; pos[1]= idx[a][1]*dy; @@ -1139,8 +1153,8 @@ static void draw_distortion(SpaceClip *sc, ARegion *ar, MovieClip *clip, int wid dx= (max[0]-min[0])/n; dy= (max[1]-min[1])/n; - for(i= 0; i<=n; i++) { - for(j= 0; j<=n; j++) { + for (i= 0; i<=n; i++) { + for (j= 0; j<=n; j++) { BKE_tracking_apply_intrinsics(tracking, pos, grid[i][j]); grid[i][j][0]/= width; @@ -1155,30 +1169,30 @@ static void draw_distortion(SpaceClip *sc, ARegion *ar, MovieClip *clip, int wid glColor3f(1.0f, 0.0f, 0.0f); - for(i= 0; i<=n; i++) { + for (i= 0; i<=n; i++) { glBegin(GL_LINE_STRIP); - for(j= 0; j<=n; j++) { + for (j= 0; j<=n; j++) { glVertex2fv(grid[i][j]); } glEnd(); } - for(j= 0; j<=n; j++) { + for (j= 0; j<=n; j++) { glBegin(GL_LINE_STRIP); - for(i= 0; i<=n; i++) { + for (i= 0; i<=n; i++) { glVertex2fv(grid[i][j]); } glEnd(); } } - if(sc->flag&SC_MANUAL_CALIBRATION && clip->gpd) { + if (sc->flag&SC_MANUAL_CALIBRATION && clip->gpd) { bGPDlayer *layer= clip->gpd->layers.first; - while(layer) { + while (layer) { bGPDframe *frame= layer->frames.first; - if(layer->flag & GP_LAYER_HIDE) { + if (layer->flag & GP_LAYER_HIDE) { layer= layer->next; continue; } @@ -1187,14 +1201,14 @@ static void draw_distortion(SpaceClip *sc, ARegion *ar, MovieClip *clip, int wid glLineWidth(layer->thickness); glPointSize((float)(layer->thickness + 2)); - while(frame) { + while (frame) { bGPDstroke *stroke= frame->strokes.first; - while(stroke) { - if(stroke->flag&GP_STROKE_2DSPACE) { - if(stroke->totpoints>1) { + while (stroke) { + if (stroke->flag&GP_STROKE_2DSPACE) { + if (stroke->totpoints>1) { glBegin(GL_LINE_STRIP); - for(i= 0; itotpoints-1; i++) { + for (i= 0; itotpoints-1; i++) { float npos[2], dpos[2], len; int steps; @@ -1208,7 +1222,7 @@ static void draw_distortion(SpaceClip *sc, ARegion *ar, MovieClip *clip, int wid steps= ceil(len/5.0f); /* we want to distort only long straight lines */ - if(stroke->totpoints==2) { + if (stroke->totpoints==2) { BKE_tracking_invert_intrinsics(tracking, pos, pos); BKE_tracking_invert_intrinsics(tracking, npos, npos); } @@ -1216,7 +1230,7 @@ static void draw_distortion(SpaceClip *sc, ARegion *ar, MovieClip *clip, int wid sub_v2_v2v2(dpos, npos, pos); mul_v2_fl(dpos, 1.0f/steps); - for(j= 0; j<=steps; j++) { + for (j= 0; j<=steps; j++) { BKE_tracking_apply_intrinsics(tracking, pos, tpos); glVertex2f(tpos[0]/width, tpos[1]/(height*aspy)); @@ -1225,7 +1239,7 @@ static void draw_distortion(SpaceClip *sc, ARegion *ar, MovieClip *clip, int wid } glEnd(); } - else if(stroke->totpoints==1) { + else if (stroke->totpoints==1) { glBegin(GL_POINTS); glVertex2f(stroke->points[0].x, stroke->points[0].y); glEnd(); @@ -1256,22 +1270,22 @@ void clip_draw_main(SpaceClip *sc, ARegion *ar, Scene *scene) float zoomx, zoomy; /* if no clip, nothing to do */ - if(!clip) + if (!clip) return; ED_space_clip_size(sc, &width, &height); ED_space_clip_zoom(sc, ar, &zoomx, &zoomy); - if(sc->flag&SC_SHOW_STABLE) { + if (sc->flag&SC_SHOW_STABLE) { float smat[4][4], ismat[4][4]; ibuf= ED_space_clip_get_stable_buffer(sc, sc->loc, &sc->scale, &sc->angle); - if(ibuf) { + if (ibuf) { float loc[2]; float aspect= clip->tracking.camera.pixel_aspect; - if(width != ibuf->x) + if (width != ibuf->x) mul_v2_v2fl(loc, sc->loc, (float)width / ibuf->x); else copy_v2_v2(loc, sc->loc); @@ -1285,7 +1299,8 @@ void clip_draw_main(SpaceClip *sc, ARegion *ar, Scene *scene) mul_serie_m4(sc->unistabmat, smat, sc->stabmat, ismat, NULL, NULL, NULL, NULL, NULL); } - } else { + } + else { ibuf= ED_space_clip_get_buffer(sc); zero_v2(sc->loc); @@ -1294,7 +1309,7 @@ void clip_draw_main(SpaceClip *sc, ARegion *ar, Scene *scene) unit_m4(sc->unistabmat); } - if(ibuf) { + if (ibuf) { draw_movieclip_buffer(sc, ar, ibuf, width, height, zoomx, zoomy); IMB_freeImBuf(ibuf); @@ -1313,16 +1328,16 @@ void clip_draw_grease_pencil(bContext *C, int onlyv2d) MovieClip *clip= ED_space_clip(sc); ImBuf *ibuf; - if(!clip) + if (!clip) return; - if(onlyv2d) { + if (onlyv2d) { /* if manual calibration is used then grease pencil data is already * drawed in draw_distortion */ - if((sc->flag&SC_MANUAL_CALIBRATION)==0 || sc->mode!=SC_MODE_DISTORTION) { + if ((sc->flag&SC_MANUAL_CALIBRATION)==0 || sc->mode!=SC_MODE_DISTORTION) { ibuf= ED_space_clip_get_buffer(sc); - if(ibuf) { + if (ibuf) { glPushMatrix(); glMultMatrixf(sc->unistabmat); draw_gpencil_2dimage(C, ibuf); @@ -1331,7 +1346,8 @@ void clip_draw_grease_pencil(bContext *C, int onlyv2d) glPopMatrix(); } } - } else { + } + else { draw_gpencil_view2d(C, 0); } } diff --git a/source/blender/editors/space_clip/clip_editor.c b/source/blender/editors/space_clip/clip_editor.c index 35d870022a4..87b0ac1aac1 100644 --- a/source/blender/editors/space_clip/clip_editor.c +++ b/source/blender/editors/space_clip/clip_editor.c @@ -59,7 +59,7 @@ int ED_space_clip_poll(bContext *C) { SpaceClip *sc= CTX_wm_space_clip(C); - if(sc && sc->clip) + if (sc && sc->clip) return 1; return 0; @@ -69,10 +69,10 @@ void ED_space_clip_set(bContext *C, SpaceClip *sc, MovieClip *clip) { sc->clip= clip; - if(sc->clip && sc->clip->id.us==0) + if (sc->clip && sc->clip->id.us==0) sc->clip->id.us= 1; - if(C) + if (C) WM_event_add_notifier(C, NC_MOVIECLIP|NA_SELECTED, sc->clip); } @@ -83,15 +83,15 @@ MovieClip *ED_space_clip(SpaceClip *sc) ImBuf *ED_space_clip_get_buffer(SpaceClip *sc) { - if(sc->clip) { + if (sc->clip) { ImBuf *ibuf; ibuf= BKE_movieclip_get_postprocessed_ibuf(sc->clip, &sc->user, sc->postproc_flag); - if(ibuf && (ibuf->rect || ibuf->rect_float)) + if (ibuf && (ibuf->rect || ibuf->rect_float)) return ibuf; - if(ibuf) + if (ibuf) IMB_freeImBuf(ibuf); } @@ -100,15 +100,15 @@ ImBuf *ED_space_clip_get_buffer(SpaceClip *sc) ImBuf *ED_space_clip_get_stable_buffer(SpaceClip *sc, float loc[2], float *scale, float *angle) { - if(sc->clip) { + if (sc->clip) { ImBuf *ibuf; ibuf= BKE_movieclip_get_stable_ibuf(sc->clip, &sc->user, loc, scale, angle, sc->postproc_flag); - if(ibuf && (ibuf->rect || ibuf->rect_float)) + if (ibuf && (ibuf->rect || ibuf->rect_float)) return ibuf; - if(ibuf) + if (ibuf) IMB_freeImBuf(ibuf); } @@ -117,11 +117,12 @@ ImBuf *ED_space_clip_get_stable_buffer(SpaceClip *sc, float loc[2], float *scale void ED_space_clip_size(SpaceClip *sc, int *width, int *height) { - if(!sc->clip) { - *width= 0; - *height= 0; - } else + if (!sc->clip) { + *width = *height = 0; + } + else { BKE_movieclip_get_size(sc->clip, &sc->user, width, height); + } } void ED_space_clip_zoom(SpaceClip *sc, ARegion *ar, float *zoomx, float *zoomy) @@ -138,7 +139,7 @@ void ED_space_clip_aspect(SpaceClip *sc, float *aspx, float *aspy) { MovieClip *clip= ED_space_clip(sc); - if(clip) + if (clip) BKE_movieclip_aspect(clip, aspx, aspy); else *aspx= *aspy= 1.0f; @@ -150,11 +151,11 @@ void ED_clip_update_frame(const Main *mainp, int cfra) wmWindow *win; /* image window, compo node users */ - for(wm=mainp->wm.first; wm; wm= wm->id.next) { /* only 1 wm */ - for(win= wm->windows.first; win; win= win->next) { + for (wm=mainp->wm.first; wm; wm= wm->id.next) { /* only 1 wm */ + for (win= wm->windows.first; win; win= win->next) { ScrArea *sa; - for(sa= win->screen->areabase.first; sa; sa= sa->next) { - if(sa->spacetype==SPACE_CLIP) { + for (sa= win->screen->areabase.first; sa; sa= sa->next) { + if (sa->spacetype==SPACE_CLIP) { SpaceClip *sc= sa->spacedata.first; sc->scopes.ok= 0; @@ -178,11 +179,11 @@ static int selected_boundbox(SpaceClip *sc, float min[2], float max[2]) ED_space_clip_size(sc, &width, &height); track= tracksbase->first; - while(track) { - if(TRACK_VIEW_SELECTED(sc, track)) { + while (track) { + if (TRACK_VIEW_SELECTED(sc, track)) { MovieTrackingMarker *marker= BKE_tracking_get_marker(track, sc->user.framenr); - if(marker) { + if (marker) { float pos[3]; pos[0]= marker->pos[0]+track->offset[0]; @@ -190,7 +191,7 @@ static int selected_boundbox(SpaceClip *sc, float min[2], float max[2]) pos[2]= 0.0f; /* undistortion happens for normalized coords */ - if(sc->user.render_flag&MCLIP_PROXY_RENDER_UNDISTORT) + if (sc->user.render_flag&MCLIP_PROXY_RENDER_UNDISTORT) /* undistortion happens for normalized coords */ ED_clip_point_undistorted_pos(sc, pos, pos); @@ -218,9 +219,9 @@ int ED_clip_view_selection(SpaceClip *sc, ARegion *ar, int fit) ED_space_clip_size(sc, &frame_width, &frame_height); - if(frame_width==0 || frame_height==0) return 0; + if (frame_width==0 || frame_height==0) return 0; - if(!selected_boundbox(sc, min, max)) + if (!selected_boundbox(sc, min, max)) return 0; /* center view */ @@ -230,7 +231,7 @@ int ED_clip_view_selection(SpaceClip *sc, ARegion *ar, int fit) h= max[1]-min[1]; /* set zoom to see all selection */ - if(w>0 && h>0) { + if (w>0 && h>0) { int width, height; float zoomx, zoomy, newzoom, aspx, aspy; @@ -244,7 +245,7 @@ int ED_clip_view_selection(SpaceClip *sc, ARegion *ar, int fit) newzoom= 1.0f/power_of_2(1/MIN2(zoomx, zoomy)); - if(fit || sc->zoom>newzoom) + if (fit || sc->zoom>newzoom) sc->zoom= newzoom; } @@ -255,7 +256,7 @@ void ED_clip_point_undistorted_pos(SpaceClip *sc, float co[2], float nco[2]) { copy_v2_v2(nco, co); - if(sc->user.render_flag&MCLIP_PROXY_RENDER_UNDISTORT) { + if (sc->user.render_flag&MCLIP_PROXY_RENDER_UNDISTORT) { MovieClip *clip= ED_space_clip(sc); float aspy= 1.0f/clip->tracking.camera.pixel_aspect; int width, height; @@ -292,7 +293,7 @@ void ED_clip_point_stable_pos(bContext *C, float x, float y, float *xr, float *y *xr= pos[0]/width; *yr= pos[1]/height; - if(sc->user.render_flag&MCLIP_PROXY_RENDER_UNDISTORT) { + if (sc->user.render_flag&MCLIP_PROXY_RENDER_UNDISTORT) { MovieClip *clip= ED_space_clip(sc); MovieTracking *tracking= &clip->tracking; float aspy= 1.0f/tracking->camera.pixel_aspect; diff --git a/source/blender/editors/space_clip/clip_graph_draw.c b/source/blender/editors/space_clip/clip_graph_draw.c index 1e21d0e5120..c1089d2bbcf 100644 --- a/source/blender/editors/space_clip/clip_graph_draw.c +++ b/source/blender/editors/space_clip/clip_graph_draw.c @@ -155,10 +155,11 @@ void tracking_segment_start_cb(void *userdata, MovieTrackingTrack *track, int co copy_v3_v3(col, colors[coord]); - if(track==userdata) { + if (track==userdata) { col[3]= 1.0f; glLineWidth(2.0f); - } else { + } + else { col[3]= 0.5f; glLineWidth(1.0f); } @@ -181,14 +182,14 @@ static void tracking_segment_knot_cb(void *userdata, MovieTrackingTrack *track, struct { MovieTrackingTrack *act_track; int sel; float xscale, yscale, hsize; } *data = userdata; int sel= 0, sel_flag; - if(track!=data->act_track) + if (track!=data->act_track) return; sel_flag= coord == 0 ? MARKER_GRAPH_SEL_X : MARKER_GRAPH_SEL_Y; sel= (marker->flag & sel_flag) ? 1 : 0; - if(sel == data->sel) { - if(sel) UI_ThemeColor(TH_HANDLE_VERTEX_SELECT); + if (sel == data->sel) { + if (sel) UI_ThemeColor(TH_HANDLE_VERTEX_SELECT); else UI_ThemeColor(TH_HANDLE_VERTEX); draw_curve_knot(marker->framenr, val, data->xscale, data->yscale, data->hsize); @@ -205,7 +206,7 @@ static void draw_tracks_curves(View2D *v2d, SpaceClip *sc) BKE_movieclip_get_size(clip, &sc->user, &width, &height); - if(!width || !height) + if (!width || !height) return; /* non-selected knot handles */ @@ -234,15 +235,15 @@ static void draw_frame_curves(SpaceClip *sc) glColor3f(0.0f, 0.0f, 1.0f); - for(i= 0; icamnr; i++) { + for (i= 0; icamnr; i++) { MovieReconstructedCamera *camera= &reconstruction->cameras[i]; - if(lines && camera->framenr!=prevfra+1) { + if (lines && camera->framenr!=prevfra+1) { glEnd(); lines= 0; } - if(!lines) { + if (!lines) { glBegin(GL_LINE_STRIP); lines= 1; } @@ -252,7 +253,7 @@ static void draw_frame_curves(SpaceClip *sc) prevfra= camera->framenr; } - if(lines) + if (lines) glEnd(); } @@ -268,11 +269,11 @@ void clip_draw_graph(SpaceClip *sc, ARegion *ar, Scene *scene) UI_view2d_grid_draw(v2d, grid, V2D_GRIDLINES_ALL); UI_view2d_grid_free(grid); - if(clip) { - if(sc->flag&SC_SHOW_GRAPH_TRACKS) + if (clip) { + if (sc->flag&SC_SHOW_GRAPH_TRACKS) draw_tracks_curves(v2d, sc); - if(sc->flag&SC_SHOW_GRAPH_FRAMES) + if (sc->flag&SC_SHOW_GRAPH_FRAMES) draw_frame_curves(sc); } diff --git a/source/blender/editors/space_clip/clip_graph_ops.c b/source/blender/editors/space_clip/clip_graph_ops.c index 0b8b4724062..4a1f2c56ee0 100644 --- a/source/blender/editors/space_clip/clip_graph_ops.c +++ b/source/blender/editors/space_clip/clip_graph_ops.c @@ -65,7 +65,7 @@ static int ED_space_clip_graph_poll(bContext *C) { SpaceClip *sc = CTX_wm_space_clip(C); - if(sc && sc->clip) { + if (sc && sc->clip) { ARegion *ar = CTX_wm_region(C); return ar->regiontype == RGN_TYPE_PREVIEW; @@ -116,10 +116,10 @@ static void find_nearest_tracking_segment_cb(void *userdata, MovieTrackingTrack MouseSelectUserData *data= userdata; float co[2]= {marker->framenr, val}; - if(data->has_prev) { + if (data->has_prev) { float d= dist_to_line_segment_v2(data->mouse_co, data->prev_co, co); - if(data->track==NULL || dmin_dist) { + if (data->track==NULL || dmin_dist) { data->track= track; data->min_dist= d; data->coord= coord; @@ -145,7 +145,7 @@ static void find_nearest_tracking_knot_cb(void *userdata, MovieTrackingTrack *tr float dx= marker->framenr-data->mouse_co[0], dy= val-data->mouse_co[1]; float d= dx*dx+dy*dy; - if(data->marker==NULL || dmin_dist) { + if (data->marker==NULL || dmin_dist) { float co[2]= {marker->framenr, val}; data->track= track; @@ -174,26 +174,26 @@ static int mouse_select_knot(bContext *C, float co[2], int extend) MovieTrackingTrack *act_track= BKE_tracking_active_track(tracking); static const int delta= 6; - if(act_track) { + if (act_track) { MouseSelectUserData userdata; mouse_select_init_data(&userdata, co); clip_graph_tracking_values_iterate_track(sc, act_track, &userdata, find_nearest_tracking_knot_cb, NULL, NULL); - if(userdata.marker) { + if (userdata.marker) { int x1, y1, x2, y2; UI_view2d_view_to_region(v2d, co[0], co[1], &x1, &y1); UI_view2d_view_to_region(v2d, userdata.min_co[0], userdata.min_co[1], &x2, &y2); - if(abs(x2-x1)<=delta && abs(y2-y1)<=delta) { - if(!extend) { + if (abs(x2-x1)<=delta && abs(y2-y1)<=delta) { + if (!extend) { SelectUserData selectdata = {SEL_DESELECT}; clip_graph_tracking_iterate(sc, &selectdata, toggle_selection_cb); } - if(userdata.coord==0) + if (userdata.coord==0) userdata.marker->flag|= MARKER_GRAPH_SEL_X; else userdata.marker->flag|= MARKER_GRAPH_SEL_Y; @@ -217,14 +217,14 @@ static int mouse_select_curve(bContext *C, float co[2], int extend) mouse_select_init_data(&userdata, co); clip_graph_tracking_values_iterate(sc, &userdata, find_nearest_tracking_segment_cb, NULL, find_nearest_tracking_segment_end_cb); - if(userdata.track) { - if(extend) { - if(act_track==userdata.track) { + if (userdata.track) { + if (extend) { + if (act_track==userdata.track) { /* currently only single curve can be selected (selected curve represents active track) */ act_track= NULL; } } - else if(act_track!=userdata.track) { + else if (act_track!=userdata.track) { MovieTrackingMarker *marker; SelectUserData selectdata = {SEL_DESELECT}; @@ -252,12 +252,12 @@ static int mouse_select(bContext *C, float co[2], int extend) /* first try to select knot on selected curves */ sel= mouse_select_knot(C, co, extend); - if(!sel) { + if (!sel) { /* if there's no close enough knot to mouse osition, select nearest curve */ sel= mouse_select_curve(C, co, extend); } - if(sel) + if (sel) WM_event_add_notifier(C, NC_GEOM|ND_SELECT, NULL); return OPERATOR_FINISHED; @@ -468,7 +468,7 @@ static int delete_curve_exec(bContext *C, wmOperator *UNUSED(op)) ListBase *tracksbase= BKE_tracking_get_tracks(tracking); MovieTrackingTrack *act_track= BKE_tracking_active_track(tracking); - if(act_track) + if (act_track) clip_delete_track(C, clip, tracksbase, act_track); return OPERATOR_FINISHED; @@ -500,13 +500,13 @@ static int delete_knot_exec(bContext *C, wmOperator *UNUSED(op)) ListBase *tracksbase= BKE_tracking_get_tracks(tracking); MovieTrackingTrack *act_track= BKE_tracking_active_track(tracking); - if(act_track) { + if (act_track) { int a= 0; - while(amarkersnr) { + while (amarkersnr) { MovieTrackingMarker *marker= &act_track->markers[a]; - if(marker->flag & MARKER_GRAPH_SEL) + if (marker->flag & MARKER_GRAPH_SEL) clip_delete_marker(C, clip, tracksbase, act_track, marker); else a++; @@ -542,8 +542,8 @@ static void view_all_cb(void *userdata, MovieTrackingTrack *UNUSED(track), Movie { ViewAllUserData *data = (ViewAllUserData *)userdata; - if(val < data->min) data->min = val; - if(val > data->max) data->max = val; + if (val < data->min) data->min = val; + if (val > data->max) data->max = val; } static int view_all_exec(bContext *C, wmOperator *UNUSED(op)) @@ -656,7 +656,7 @@ static int graph_disable_markers_exec(bContext *C, wmOperator *op) if (marker->flag & MARKER_GRAPH_SEL) { if (action==0) marker->flag |= MARKER_DISABLED; - else if(action==1) + else if (action==1) marker->flag &= ~MARKER_DISABLED; else marker->flag ^= MARKER_DISABLED; diff --git a/source/blender/editors/space_clip/clip_ops.c b/source/blender/editors/space_clip/clip_ops.c index 6be1a83d7d9..2fa7f447f38 100644 --- a/source/blender/editors/space_clip/clip_ops.c +++ b/source/blender/editors/space_clip/clip_ops.c @@ -82,15 +82,15 @@ static void sclip_zoom_set(SpaceClip *sc, ARegion *ar, float zoom, float locatio width*= sc->zoom; height*= sc->zoom; - if((width < 4) && (height < 4)) + if ((width < 4) && (height < 4)) sc->zoom= oldzoom; - else if((ar->winrct.xmax - ar->winrct.xmin) <= sc->zoom) + else if ((ar->winrct.xmax - ar->winrct.xmin) <= sc->zoom) sc->zoom= oldzoom; - else if((ar->winrct.ymax - ar->winrct.ymin) <= sc->zoom) + else if ((ar->winrct.ymax - ar->winrct.ymin) <= sc->zoom) sc->zoom= oldzoom; } - if((U.uiflag & USER_ZOOM_TO_MOUSEPOS) && location) { + if ((U.uiflag & USER_ZOOM_TO_MOUSEPOS) && location) { ED_space_clip_size(sc, &width, &height); sc->xof+= ((location[0]-0.5f)*width-sc->xof)*(sc->zoom-oldzoom)/sc->zoom; @@ -158,8 +158,8 @@ static int open_exec(bContext *C, wmOperator *op) clip= BKE_add_movieclip_file(str); - if(!clip) { - if(op->customdata) + if (!clip) { + if (op->customdata) MEM_freeN(op->customdata); BKE_reportf(op->reports, RPT_ERROR, "Can't read: \"%s\", %s.", str, errno ? strerror(errno) : "Unsupported movie clip format"); @@ -167,13 +167,13 @@ static int open_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } - if(!op->customdata) + if (!op->customdata) open_init(C, op); /* hook into UI */ pprop= op->customdata; - if(pprop->prop) { + if (pprop->prop) { /* when creating new ID blocks, use is already 1, but RNA * pointer se also increases user, so this compensates it */ clip->id.us--; @@ -182,7 +182,7 @@ static int open_exec(bContext *C, wmOperator *op) RNA_property_pointer_set(&pprop->ptr, pprop->prop, idptr); RNA_property_update(C, &pprop->ptr, pprop->prop); } - else if(sc) { + else if (sc) { ED_space_clip_set(C, sc, clip); } @@ -199,16 +199,16 @@ static int open_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) char *path= U.textudir; MovieClip *clip= NULL; - if(sc) + if (sc) clip= ED_space_clip(sc); - if(clip) + if (clip) path= clip->name; - 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", U.flag & USER_RELPATHS); - if(RNA_struct_property_is_set(op->ptr, "filepath")) + if (RNA_struct_property_is_set(op->ptr, "filepath")) return open_exec(C, op); open_init(C, op); @@ -243,7 +243,7 @@ static int reload_exec(bContext *C, wmOperator *UNUSED(op)) { MovieClip *clip= CTX_data_edit_movieclip(C); - if(!clip) + if (!clip) return OPERATOR_CANCELLED; BKE_movieclip_reload(clip); @@ -284,7 +284,7 @@ static void view_pan_init(bContext *C, wmOperator *op, wmEvent *event) vpd->x= event->x; vpd->y= event->y; - if(sc->flag&SC_LOCK_SELECTION) vpd->vec= &sc->xlockof; + if (sc->flag&SC_LOCK_SELECTION) vpd->vec= &sc->xlockof; else vpd->vec= &sc->xof; copy_v2_v2(&vpd->xof, vpd->vec); @@ -299,7 +299,7 @@ static void view_pan_exit(bContext *C, wmOperator *op, int cancel) { ViewPanData *vpd= op->customdata; - if(cancel) { + if (cancel) { copy_v2_v2(vpd->vec, &vpd->xorig); ED_region_tag_redraw(CTX_wm_region(C)); @@ -316,10 +316,11 @@ static int view_pan_exec(bContext *C, wmOperator *op) RNA_float_get_array(op->ptr, "offset", offset); - if(sc->flag&SC_LOCK_SELECTION) { + if (sc->flag&SC_LOCK_SELECTION) { sc->xlockof+= offset[0]; sc->ylockof+= offset[1]; - } else { + } + else { sc->xof+= offset[0]; sc->yof+= offset[1]; } @@ -370,7 +371,7 @@ static int view_pan_modal(bContext *C, wmOperator *op, wmEvent *event) view_pan_exit(C, op, 0); return OPERATOR_FINISHED; default: - if(event->type==vpd->event_type && event->val==KM_RELEASE) { + if (event->type==vpd->event_type && event->val==KM_RELEASE) { view_pan_exit(C, op, 0); return OPERATOR_FINISHED; } @@ -440,7 +441,7 @@ static void view_zoom_exit(bContext *C, wmOperator *op, int cancel) SpaceClip *sc= CTX_wm_space_clip(C); ViewZoomData *vpd= op->customdata; - if(cancel) { + if (cancel) { sc->zoom= vpd->zoom; ED_region_tag_redraw(CTX_wm_region(C)); } @@ -495,7 +496,7 @@ static int view_zoom_modal(bContext *C, wmOperator *op, wmEvent *event) ED_region_tag_redraw(CTX_wm_region(C)); break; default: - if(event->type==vpd->event_type && event->val==KM_RELEASE) { + if (event->type==vpd->event_type && event->val==KM_RELEASE) { view_zoom_exit(C, op, 0); return OPERATOR_FINISHED; } @@ -672,7 +673,7 @@ static int view_all_exec(bContext *C, wmOperator *op) width= ar->winrct.xmax - ar->winrct.xmin + 1; height= ar->winrct.ymax - ar->winrct.ymin + 1; - if(fit_view) { + if (fit_view) { const int margin = 5; /* margin from border */ zoomx= (float)width / (w + 2*margin); @@ -681,7 +682,7 @@ static int view_all_exec(bContext *C, wmOperator *op) sclip_zoom_set(sc, ar, MIN2(zoomx, zoomy), NULL); } else { - if((w >= width || h >= height) && (width > 0 && height > 0)) { + if ((w >= width || h >= height) && (width > 0 && height > 0)) { zoomx= (float)width/w; zoomy= (float)height/h; @@ -745,7 +746,7 @@ void CLIP_OT_view_selected(wmOperatorType *ot) static int change_frame_poll(bContext *C) { /* prevent changes during render */ - if(G.rendering) + if (G.rendering) return 0; return ED_space_clip_poll(C); @@ -778,11 +779,12 @@ static int frame_from_event(bContext *C, wmEvent *event) Scene *scene= CTX_data_scene(C); int framenr= 0; - if(ar->regiontype == RGN_TYPE_WINDOW) { + if (ar->regiontype == RGN_TYPE_WINDOW) { float sfra= SFRA, efra= EFRA, framelen= ar->winx/(efra-sfra+1); framenr= sfra+event->mval[0]/framelen; - } else { + } + else { float viewx, viewy; UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], &viewx, &viewy); @@ -797,8 +799,8 @@ static int change_frame_invoke(bContext *C, wmOperator *op, wmEvent *event) { ARegion *ar= CTX_wm_region(C); - if(ar->regiontype == RGN_TYPE_WINDOW) { - if(event->mval[1]>16) + if (ar->regiontype == RGN_TYPE_WINDOW) { + if (event->mval[1]>16) return OPERATOR_PASS_THROUGH; } @@ -883,10 +885,10 @@ static int proxy_bitflag_to_array(int size_flag, int build_sizes[4], int undisto MCLIP_PROXY_UNDISTORTED_SIZE_100}}; int size_nr = undistort ? 1 : 0; - if(size_flag & size_flags[size_nr][0]) build_sizes[build_count++]= MCLIP_PROXY_RENDER_SIZE_25; - if(size_flag & size_flags[size_nr][1]) build_sizes[build_count++]= MCLIP_PROXY_RENDER_SIZE_50; - if(size_flag & size_flags[size_nr][2]) build_sizes[build_count++]= MCLIP_PROXY_RENDER_SIZE_75; - if(size_flag & size_flags[size_nr][3]) build_sizes[build_count++]= MCLIP_PROXY_RENDER_SIZE_100; + if (size_flag & size_flags[size_nr][0]) build_sizes[build_count++]= MCLIP_PROXY_RENDER_SIZE_25; + if (size_flag & size_flags[size_nr][1]) build_sizes[build_count++]= MCLIP_PROXY_RENDER_SIZE_50; + if (size_flag & size_flags[size_nr][2]) build_sizes[build_count++]= MCLIP_PROXY_RENDER_SIZE_75; + if (size_flag & size_flags[size_nr][3]) build_sizes[build_count++]= MCLIP_PROXY_RENDER_SIZE_100; return build_count; } @@ -908,11 +910,11 @@ static void proxy_startjob(void *pjv, short *stop, short *do_update, float *prog build_count= proxy_bitflag_to_array(size_flag, build_sizes, 0); build_undistort_count= proxy_bitflag_to_array(size_flag, build_undistort_sizes, 1); - if(clip->source == MCLIP_SRC_MOVIE) { + if (clip->source == MCLIP_SRC_MOVIE) { if (pj->index_context) IMB_anim_index_rebuild(pj->index_context, stop, do_update, progress); - if(!build_undistort_count) { + if (!build_undistort_count) { if (*stop) pj->stop = 1; @@ -924,23 +926,23 @@ static void proxy_startjob(void *pjv, short *stop, short *do_update, float *prog } } - if(build_undistort_count) + if (build_undistort_count) distortion= BKE_tracking_distortion_create(); - for(cfra= sfra; cfra<=efra; cfra++) { - if(clip->source != MCLIP_SRC_MOVIE) + for (cfra= sfra; cfra<=efra; cfra++) { + if (clip->source != MCLIP_SRC_MOVIE) BKE_movieclip_build_proxy_frame(clip, pj->clip_flag, NULL, cfra, build_sizes, build_count, 0); BKE_movieclip_build_proxy_frame(clip, pj->clip_flag, distortion, cfra, build_undistort_sizes, build_undistort_count, 1); - if(*stop || G.afbreek) + if (*stop || G.afbreek) break; *do_update= 1; *progress= ((float)cfra)/(efra-sfra); } - if(distortion) + if (distortion) BKE_tracking_distortion_destroy(distortion); if (*stop) @@ -971,7 +973,7 @@ static int clip_rebuild_proxy_exec(bContext *C, wmOperator *UNUSED(op)) SpaceClip *sc= CTX_wm_space_clip(C); MovieClip *clip= ED_space_clip(sc); - if((clip->flag&MCLIP_USE_PROXY)==0) + if ((clip->flag&MCLIP_USE_PROXY)==0) return OPERATOR_CANCELLED; steve= WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), sa, "Building Proxies", WM_JOB_PROGRESS); @@ -1022,10 +1024,11 @@ static int mode_set_exec(bContext *C, wmOperator *op) int mode= RNA_enum_get(op->ptr, "mode"); int toggle= RNA_boolean_get(op->ptr, "toggle"); - if(sc->mode==mode) { - if(toggle) + if (sc->mode==mode) { + if (toggle) sc->mode= SC_MODE_TRACKING; - } else { + } + else { sc->mode= mode; } diff --git a/source/blender/editors/space_clip/clip_toolbar.c b/source/blender/editors/space_clip/clip_toolbar.c index 287edfa3f1c..b42b4137ea0 100644 --- a/source/blender/editors/space_clip/clip_toolbar.c +++ b/source/blender/editors/space_clip/clip_toolbar.c @@ -61,14 +61,14 @@ static ARegion *clip_has_properties_region(ScrArea *sa) ARegion *ar, *arnew; ar= BKE_area_find_region_type(sa, RGN_TYPE_UI); - if(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) + if (ar==NULL) return NULL; arnew= MEM_callocN(sizeof(ARegion), "clip properties region"); @@ -92,7 +92,7 @@ static int properties_exec(bContext *C, wmOperator *UNUSED(op)) ScrArea *sa= CTX_wm_area(C); ARegion *ar= clip_has_properties_region(sa); - if(ar) + if (ar) ED_region_toggle_hidden(C, ar); return OPERATOR_FINISHED; @@ -116,23 +116,23 @@ static ARegion *clip_has_tools_region(ScrArea *sa) { ARegion *ar, *artool=NULL, *arprops=NULL, *arhead; - for(ar= sa->regionbase.first; ar; ar= ar->next) { - if(ar->regiontype==RGN_TYPE_TOOLS) + for (ar= sa->regionbase.first; ar; ar= ar->next) { + if (ar->regiontype==RGN_TYPE_TOOLS) artool= ar; - if(ar->regiontype==RGN_TYPE_TOOL_PROPS) + if (ar->regiontype==RGN_TYPE_TOOL_PROPS) arprops= ar; } /* tool region hide/unhide also hides props */ - if(arprops && artool) + if (arprops && artool) return artool; - if(artool==NULL) { + if (artool==NULL) { /* add subdiv level; after header */ arhead= BKE_area_find_region_type(sa, RGN_TYPE_HEADER); /* is error! */ - if(arhead==NULL) + if (arhead==NULL) return NULL; artool= MEM_callocN(sizeof(ARegion), "clip tools region"); @@ -144,7 +144,7 @@ static ARegion *clip_has_tools_region(ScrArea *sa) artool->flag= RGN_FLAG_HIDDEN; } - if(arprops==NULL) { + if (arprops==NULL) { /* add extra subdivided region for tool properties */ arprops= MEM_callocN(sizeof(ARegion), "tool props for clip"); @@ -166,7 +166,7 @@ static int tools_exec(bContext *C, wmOperator *UNUSED(op)) ScrArea *sa= CTX_wm_area(C); ARegion *ar= clip_has_tools_region(sa); - if(ar) + if (ar) ED_region_toggle_hidden(C, ar); return OPERATOR_FINISHED; @@ -195,14 +195,14 @@ static void clip_panel_operator_redo_header(const bContext *C, Panel *pa) { wmOperator *op= WM_operator_last_redo(C); - if(op) BLI_strncpy(pa->drawname, op->type->name, sizeof(pa->drawname)); + if (op) BLI_strncpy(pa->drawname, op->type->name, sizeof(pa->drawname)); else BLI_strncpy(pa->drawname, "Operator", sizeof(pa->drawname)); } static void clip_panel_operator_redo_operator(const bContext *C, Panel *pa, wmOperator *op) { - if(op->type->flag & OPTYPE_MACRO) { - for(op= op->macro.first; op; op= op->next) { + if (op->type->flag & OPTYPE_MACRO) { + for (op= op->macro.first; op; op= op->next) { uiItemL(pa->layout, op->type->name, ICON_NONE); clip_panel_operator_redo_operator(C, pa, op); } @@ -218,9 +218,9 @@ static void clip_panel_operator_redo(const bContext *C, Panel *pa) wmOperator *op= WM_operator_last_redo(C); uiBlock *block; - if(op==NULL) + if (op==NULL) return; - if(WM_operator_poll((bContext*)C, op->type) == 0) + if (WM_operator_poll((bContext*)C, op->type) == 0) return; block= uiLayoutGetBlock(pa->layout); diff --git a/source/blender/editors/space_clip/clip_utils.c b/source/blender/editors/space_clip/clip_utils.c index 46442d39a7b..c637bffe3ad 100644 --- a/source/blender/editors/space_clip/clip_utils.c +++ b/source/blender/editors/space_clip/clip_utils.c @@ -67,17 +67,17 @@ void clip_graph_tracking_values_iterate_track(SpaceClip *sc, MovieTrackingTrack BKE_movieclip_get_size(clip, &sc->user, &width, &height); - for(coord= 0; coord<2; coord++) { + for (coord= 0; coord<2; coord++) { int i, open= 0, prevfra= 0; float prevval= 0.0f; - for(i= 0; imarkersnr; i++) { + for (i= 0; imarkersnr; i++) { MovieTrackingMarker *marker= &track->markers[i]; float val; - if(marker->flag&MARKER_DISABLED) { - if(open) { - if(segment_end) + if (marker->flag&MARKER_DISABLED) { + if (open) { + if (segment_end) segment_end(userdata); open= 0; @@ -86,8 +86,8 @@ void clip_graph_tracking_values_iterate_track(SpaceClip *sc, MovieTrackingTrack continue; } - if(!open) { - if(segment_start) + if (!open) { + if (segment_start) segment_start(userdata, track, coord); open= 1; @@ -98,15 +98,15 @@ void clip_graph_tracking_values_iterate_track(SpaceClip *sc, MovieTrackingTrack val= (marker->pos[coord] - prevval) * ((coord==0) ? (width) : (height)); val/= marker->framenr-prevfra; - if(func) + if (func) func(userdata, track, marker, coord, val); prevval= marker->pos[coord]; prevfra= marker->framenr; } - if(open) { - if(segment_end) + if (open) { + if (segment_end) segment_end(userdata); } } @@ -123,8 +123,8 @@ void clip_graph_tracking_values_iterate(SpaceClip *sc, void *userdata, MovieTrackingTrack *track; track= tracksbase->first; - while(track) { - if(TRACK_VIEW_SELECTED(sc, track)) { + while (track) { + if (TRACK_VIEW_SELECTED(sc, track)) { clip_graph_tracking_values_iterate_track(sc, track, userdata, func, segment_start, segment_end); } @@ -141,17 +141,17 @@ void clip_graph_tracking_iterate(SpaceClip *sc, void *userdata, MovieTrackingTrack *track; track= tracksbase->first; - while(track) { - if(TRACK_VIEW_SELECTED(sc, track)) { + while (track) { + if (TRACK_VIEW_SELECTED(sc, track)) { int i; - for(i= 0; imarkersnr; i++) { + for (i= 0; imarkersnr; i++) { MovieTrackingMarker *marker= &track->markers[i]; - if(marker->flag&MARKER_DISABLED) + if (marker->flag&MARKER_DISABLED) continue; - if(func) + if (func) func(userdata, marker); } } @@ -168,17 +168,17 @@ void clip_delete_track(bContext *C, MovieClip *clip, ListBase *tracksbase, Movie int has_bundle= 0, update_stab= 0; - if(track==act_track) + if (track==act_track) tracking->act_track= NULL; - if(track==stab->rot_track) { + if (track==stab->rot_track) { stab->rot_track= NULL; update_stab= 1; } /* handle reconstruction display in 3d viewport */ - if(track->flag&TRACK_HAS_BUNDLE) + if (track->flag&TRACK_HAS_BUNDLE) has_bundle= 1; BKE_tracking_free_track(track); @@ -186,20 +186,20 @@ void clip_delete_track(bContext *C, MovieClip *clip, ListBase *tracksbase, Movie WM_event_add_notifier(C, NC_MOVIECLIP|NA_EDITED, clip); - if(update_stab) { + if (update_stab) { tracking->stabilization.ok= 0; DAG_id_tag_update(&clip->id, 0); WM_event_add_notifier(C, NC_MOVIECLIP|ND_DISPLAY, clip); } - if(has_bundle) + if (has_bundle) WM_event_add_notifier(C, NC_SPACE|ND_SPACE_VIEW3D, NULL); } void clip_delete_marker(bContext *C, MovieClip *clip, ListBase *tracksbase, MovieTrackingTrack *track, MovieTrackingMarker *marker) { - if(track->markersnr==1) { + if (track->markersnr==1) { clip_delete_track(C, clip, tracksbase, track); } else { diff --git a/source/blender/editors/space_clip/space_clip.c b/source/blender/editors/space_clip/space_clip.c index 96c348fb6e2..ca66248682c 100644 --- a/source/blender/editors/space_clip/space_clip.c +++ b/source/blender/editors/space_clip/space_clip.c @@ -101,14 +101,14 @@ static ARegion *clip_has_preview_region(const bContext *C, ScrArea *sa) ARegion *ar, *arnew; ar= BKE_area_find_region_type(sa, RGN_TYPE_PREVIEW); - if(ar) + if (ar) return ar; /* add subdiv level; after header */ ar= BKE_area_find_region_type(sa, RGN_TYPE_WINDOW); /* is error! */ - if(ar==NULL) + if (ar==NULL) return NULL; arnew= MEM_callocN(sizeof(ARegion), "clip preview region"); @@ -124,7 +124,7 @@ static void clip_scopes_tag_refresh(ScrArea *sa) SpaceClip *sc= (SpaceClip *)sa->spacedata.first; ARegion *ar; - if(sc->mode!=SC_MODE_TRACKING) + if (sc->mode!=SC_MODE_TRACKING) return; /* only while proeprties are visible */ @@ -141,7 +141,7 @@ static void clip_stabilization_tag_refresh(ScrArea *sa) SpaceClip *sc= (SpaceClip *)sa->spacedata.first; MovieClip *clip= ED_space_clip(sc); - if(clip) { + if (clip) { MovieTrackingStabilization *stab= &clip->tracking.stabilization; stab->ok= 0; @@ -212,7 +212,7 @@ static void clip_free(SpaceLink *sl) sc->clip= NULL; - if(sc->scopes.track_preview) + if (sc->scopes.track_preview) IMB_freeImBuf(sc->scopes.track_preview); } @@ -278,12 +278,12 @@ static void clip_listener(ScrArea *sa, wmNotifier *wmn) } break; case NC_SCREEN: - if(wmn->data==ND_ANIMPLAY) { + if (wmn->data==ND_ANIMPLAY) { ED_area_tag_redraw(sa); } break; case NC_SPACE: - if(wmn->data==ND_SPACE_CLIP) { + if (wmn->data==ND_SPACE_CLIP) { clip_scopes_tag_refresh(sa); clip_stabilization_tag_refresh(sa); ED_area_tag_redraw(sa); @@ -617,11 +617,11 @@ static int clip_context(const bContext *C, const char *member, bContextDataResul { SpaceClip *sc= CTX_wm_space_clip(C); - if(CTX_data_dir(member)) { + if (CTX_data_dir(member)) { CTX_data_dir_set(result, clip_context_dir); return 1; } - else if(CTX_data_equals(member, "edit_movieclip")) { + else if (CTX_data_equals(member, "edit_movieclip")) { CTX_data_id_pointer_set(result, &sc->clip->id); return 1; } @@ -684,7 +684,7 @@ static void clip_refresh(const bContext *C, ScrArea *sa) break; } - if(view_changed) { + if (view_changed) { ED_area_initialize(wm, window, sa); ED_area_tag_redraw(sa); } @@ -706,7 +706,7 @@ static void movieclip_main_area_set_view2d(SpaceClip *sc, ARegion *ar) w= width; h= height; - if(clip) + if (clip) h*= clip->aspy/clip->aspx/clip->tracking.camera.pixel_aspect; winx= ar->winrct.xmax - ar->winrct.xmin + 1; @@ -767,22 +767,22 @@ static void clip_main_area_draw(const bContext *C, ARegion *ar) /* if tracking is in progress, we should synchronize framenr from clipuser * so latest tracked frame would be shown */ - if(clip && clip->tracking_context) + if (clip && clip->tracking_context) BKE_tracking_sync_user(&sc->user, clip->tracking_context); - if(sc->flag&SC_LOCK_SELECTION) { + if (sc->flag&SC_LOCK_SELECTION) { ImBuf *tmpibuf= NULL; - if(clip && clip->tracking.stabilization.flag&TRACKING_2D_STABILIZATION) { + if (clip && clip->tracking.stabilization.flag&TRACKING_2D_STABILIZATION) { tmpibuf= ED_space_clip_get_stable_buffer(sc, NULL, NULL, NULL); } - if(ED_clip_view_selection(sc, ar, 0)) { + if (ED_clip_view_selection(sc, ar, 0)) { sc->xof+= sc->xlockof; sc->yof+= sc->ylockof; } - if(tmpibuf) + if (tmpibuf) IMB_freeImBuf(tmpibuf); } @@ -840,7 +840,7 @@ static void clip_preview_area_draw(const bContext *C, ARegion *ar) Scene *scene= CTX_data_scene(C); short unitx= V2D_UNIT_FRAMESCALE, unity= V2D_UNIT_VALUES; - if(sc->flag & SC_LOCK_TIMECURSOR) + if (sc->flag & SC_LOCK_TIMECURSOR) ED_clip_graph_center_current_frame(scene, ar); /* clear and setup matrix */ @@ -898,19 +898,19 @@ static void clip_props_area_listener(ARegion *ar, wmNotifier *wmn) /* 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_CLIP) + if (wmn->data == ND_SPACE_CLIP) ED_region_tag_redraw(ar); break; case NC_SCREEN: - if(wmn->data == ND_GPENCIL) + if (wmn->data == ND_GPENCIL) ED_region_tag_redraw(ar); break; } @@ -947,7 +947,7 @@ static void clip_properties_area_listener(ARegion *ar, wmNotifier *wmn) ED_region_tag_redraw(ar); break; case NC_BRUSH: - if(wmn->action==NA_EDITED) + if (wmn->action==NA_EDITED) ED_region_tag_redraw(ar); break; } diff --git a/source/blender/editors/space_clip/tracking_ops.c b/source/blender/editors/space_clip/tracking_ops.c index f1ce73a8ab0..6cb7536b1ae 100644 --- a/source/blender/editors/space_clip/tracking_ops.c +++ b/source/blender/editors/space_clip/tracking_ops.c @@ -82,10 +82,10 @@ static int space_clip_frame_poll(bContext *C) { SpaceClip *sc= CTX_wm_space_clip(C); - if(sc) { + if (sc) { MovieClip *clip= ED_space_clip(sc); - if(clip) + if (clip) return BKE_movieclip_has_frame(clip, &sc->user); } @@ -119,7 +119,7 @@ static int add_marker_exec(bContext *C, wmOperator *op) int width, height; ED_space_clip_size(sc, &width, &height); - if(!width || !height) + if (!width || !height) return OPERATOR_CANCELLED; RNA_float_get_array(op->ptr, "location", pos); @@ -176,10 +176,10 @@ static int delete_track_exec(bContext *C, wmOperator *UNUSED(op)) ListBase *tracksbase= BKE_tracking_get_tracks(tracking); MovieTrackingTrack *track= tracksbase->first, *next; - while(track) { + while (track) { next= track->next; - if(TRACK_VIEW_SELECTED(sc, track)) + if (TRACK_VIEW_SELECTED(sc, track)) clip_delete_track(C, clip, tracksbase, track); track= next; @@ -218,13 +218,13 @@ static int delete_marker_exec(bContext *C, wmOperator *UNUSED(op)) int framenr= sc->user.framenr; int has_selection= 0; - while(track) { + while (track) { next= track->next; - if(TRACK_VIEW_SELECTED(sc, track)) { + if (TRACK_VIEW_SELECTED(sc, track)) { MovieTrackingMarker *marker= BKE_tracking_exact_marker(track, framenr); - if(marker) { + if (marker) { has_selection|= track->markersnr>1; clip_delete_marker(C, clip, tracksbase, track, marker); @@ -234,7 +234,7 @@ static int delete_marker_exec(bContext *C, wmOperator *UNUSED(op)) track= next; } - if(!has_selection) { + if (!has_selection) { /* nothing selected now, unlock view so it can be scrolled nice again */ sc->flag&= ~SC_LOCK_SELECTION; } @@ -290,16 +290,18 @@ static SlideMarkerData *create_slide_marker_data(SpaceClip *sc, MovieTrackingTra data->track= track; data->marker= marker; - if(area==TRACK_AREA_POINT) { + if (area==TRACK_AREA_POINT) { data->pos= marker->pos; data->offset= track->offset; copy_v2_v2(data->spos, marker->pos); copy_v2_v2(data->soff, track->offset); - } else if(area==TRACK_AREA_PAT) { - if(action==SLIDE_ACTION_SIZE) { + } + else if (area==TRACK_AREA_PAT) { + if (action==SLIDE_ACTION_SIZE) { data->min= track->pat_min; data->max= track->pat_max; - } else { + } + else { int a; data->pos= marker->pos; @@ -308,15 +310,16 @@ static SlideMarkerData *create_slide_marker_data(SpaceClip *sc, MovieTrackingTra copy_v2_v2(data->soff, track->offset); data->smarkers= MEM_callocN(sizeof(*data->smarkers)*track->markersnr, "slide marekrs"); - for(a= 0; amarkersnr; a++) + for (a= 0; amarkersnr; a++) copy_v2_v2(data->smarkers[a], track->markers[a].pos); } - } else if(area==TRACK_AREA_SEARCH) { + } + else if (area==TRACK_AREA_SEARCH) { data->min= track->search_min; data->max= track->search_max; } - if(area==TRACK_AREA_SEARCH || (area==TRACK_AREA_PAT && action!=SLIDE_ACTION_OFFSET)) { + if (area==TRACK_AREA_SEARCH || (area==TRACK_AREA_PAT && action!=SLIDE_ACTION_OFFSET)) { copy_v2_v2(data->smin, data->min); copy_v2_v2(data->smax, data->max); } @@ -327,7 +330,7 @@ static SlideMarkerData *create_slide_marker_data(SpaceClip *sc, MovieTrackingTra data->width= width; data->height= height; - if(action==SLIDE_ACTION_SIZE) + if (action==SLIDE_ACTION_SIZE) data->lock= 1; return data; @@ -343,10 +346,11 @@ static int mouse_on_corner(SpaceClip *sc, MovieTrackingTrack *track, MovieTracki float min[2], max[2]; float crn[2], dx, dy, tdx, tdy; - if(area==TRACK_AREA_SEARCH) { + if (area==TRACK_AREA_SEARCH) { copy_v2_v2(min, track->search_min); copy_v2_v2(max, track->search_max); - } else { + } + else { copy_v2_v2(min, track->pat_min); copy_v2_v2(max, track->pat_max); } @@ -360,12 +364,13 @@ static int mouse_on_corner(SpaceClip *sc, MovieTrackingTrack *track, MovieTracki dx= MIN2(dx, (max[0]-min[0])/6.0f) + tdx; dy= MIN2(dy, (max[1]-min[1])/6.0f) + tdy; - if(corner==0) { + if (corner==0) { crn[0]= marker->pos[0]+max[0]; crn[1]= marker->pos[1]+min[1]; inside= co[0]>=crn[0]-dx && co[0]<=crn[0]+tdx && co[1]>=crn[1]-tdy && co[1]<=crn[1]+dy; - } else { + } + else { crn[0]= marker->pos[0]+min[0]; crn[1]= marker->pos[1]+max[1]; @@ -417,37 +422,37 @@ static void *slide_marker_customdata(bContext *C, wmEvent *event) ED_space_clip_size(sc, &width, &height); - if(width==0 || height==0) + if (width==0 || height==0) return NULL; ED_clip_mouse_pos(C, event, co); track= tracksbase->first; - while(track) { - if(TRACK_VIEW_SELECTED(sc, track) && (track->flag&TRACK_LOCKED)==0) { + while (track) { + if (TRACK_VIEW_SELECTED(sc, track) && (track->flag&TRACK_LOCKED)==0) { MovieTrackingMarker *marker= BKE_tracking_get_marker(track, sc->user.framenr); - if((marker->flag&MARKER_DISABLED)==0) { - if(!customdata) - if(mouse_on_offset(sc, track, marker, co, width, height)) + if ((marker->flag&MARKER_DISABLED)==0) { + if (!customdata) + if (mouse_on_offset(sc, track, marker, co, width, height)) customdata= create_slide_marker_data(sc, track, marker, event, TRACK_AREA_POINT, SLIDE_ACTION_POS, width, height); - if(sc->flag&SC_SHOW_MARKER_SEARCH) { - if(mouse_on_corner(sc, track, marker, TRACK_AREA_SEARCH, co, 1, width, height)) + if (sc->flag&SC_SHOW_MARKER_SEARCH) { + if (mouse_on_corner(sc, track, marker, TRACK_AREA_SEARCH, co, 1, width, height)) customdata= create_slide_marker_data(sc, track, marker, event, TRACK_AREA_SEARCH, SLIDE_ACTION_OFFSET, width, height); - else if(mouse_on_corner(sc, track, marker, TRACK_AREA_SEARCH, co, 0, width, height)) + else if (mouse_on_corner(sc, track, marker, TRACK_AREA_SEARCH, co, 0, width, height)) customdata= create_slide_marker_data(sc, track, marker, event, TRACK_AREA_SEARCH, SLIDE_ACTION_SIZE, width, height); } - if(!customdata && sc->flag&SC_SHOW_MARKER_PATTERN) { - if(mouse_on_corner(sc, track, marker, TRACK_AREA_PAT, co, 1, width, height)) + if (!customdata && sc->flag&SC_SHOW_MARKER_PATTERN) { + if (mouse_on_corner(sc, track, marker, TRACK_AREA_PAT, co, 1, width, height)) customdata= create_slide_marker_data(sc, track, marker, event, TRACK_AREA_PAT, SLIDE_ACTION_OFFSET, width, height); - if(!customdata && mouse_on_corner(sc, track, marker, TRACK_AREA_PAT, co, 0, width, height)) + if (!customdata && mouse_on_corner(sc, track, marker, TRACK_AREA_PAT, co, 0, width, height)) customdata= create_slide_marker_data(sc, track, marker, event, TRACK_AREA_PAT, SLIDE_ACTION_SIZE, width, height); } - if(customdata) + if (customdata) break; } } @@ -462,7 +467,7 @@ static int slide_marker_invoke(bContext *C, wmOperator *op, wmEvent *event) { SlideMarkerData *slidedata= slide_marker_customdata(C, event); - if(slidedata) { + if (slidedata) { SpaceClip *sc= CTX_wm_space_clip(C); MovieClip *clip= ED_space_clip(sc); MovieTracking *tracking= &clip->tracking; @@ -485,19 +490,21 @@ static int slide_marker_invoke(bContext *C, wmOperator *op, wmEvent *event) static void cancel_mouse_slide(SlideMarkerData *data) { /* cancel sliding */ - if(data->area == TRACK_AREA_POINT) { - if(data->action==SLIDE_ACTION_OFFSET) + if (data->area == TRACK_AREA_POINT) { + if (data->action==SLIDE_ACTION_OFFSET) copy_v2_v2(data->offset, data->soff); else copy_v2_v2(data->pos, data->spos); - } else { - if(data->action==SLIDE_ACTION_SIZE) { + } + else { + if (data->action==SLIDE_ACTION_SIZE) { copy_v2_v2(data->min, data->smin); copy_v2_v2(data->max, data->smax); - } else { + } + else { int a; - for(a= 0; atrack->markersnr; a++) + for (a= 0; atrack->markersnr; a++) copy_v2_v2(data->track->markers[a].pos, data->smarkers[a]); copy_v2_v2(data->offset, data->soff); @@ -507,7 +514,7 @@ static void cancel_mouse_slide(SlideMarkerData *data) static void free_slide_data(SlideMarkerData *data) { - if(data->smarkers) MEM_freeN(data->smarkers); + if (data->smarkers) MEM_freeN(data->smarkers); MEM_freeN(data); } @@ -522,11 +529,11 @@ static int slide_marker_modal(bContext *C, wmOperator *op, wmEvent *event) case RIGHTCTRLKEY: case LEFTSHIFTKEY: case RIGHTSHIFTKEY: - if(data->action==SLIDE_ACTION_SIZE) - if(ELEM(event->type, LEFTCTRLKEY, RIGHTCTRLKEY)) + if (data->action==SLIDE_ACTION_SIZE) + if (ELEM(event->type, LEFTCTRLKEY, RIGHTCTRLKEY)) data->lock= event->val==KM_RELEASE; - if(ELEM(event->type, LEFTSHIFTKEY, RIGHTSHIFTKEY)) + if (ELEM(event->type, LEFTSHIFTKEY, RIGHTSHIFTKEY)) data->accurate= event->val==KM_PRESS; /* no break! update area size */ @@ -537,19 +544,20 @@ static int slide_marker_modal(bContext *C, wmOperator *op, wmEvent *event) dx= mdelta[0]/data->width/sc->zoom; - if(data->lock) dy= -dx/data->height*data->width; + if (data->lock) dy= -dx/data->height*data->width; else dy= mdelta[1]/data->height/sc->zoom; - if(data->accurate) { + if (data->accurate) { dx/= 5; dy/= 5; } - if(data->area==TRACK_AREA_POINT) { - if(data->action==SLIDE_ACTION_OFFSET) { + if (data->area==TRACK_AREA_POINT) { + if (data->action==SLIDE_ACTION_OFFSET) { data->offset[0]= data->soff[0]+dx; data->offset[1]= data->soff[1]+dy; - } else { + } + else { data->pos[0]= data->spos[0]+dx; data->pos[1]= data->spos[1]+dy; @@ -558,32 +566,35 @@ static int slide_marker_modal(bContext *C, wmOperator *op, wmEvent *event) WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, NULL); DAG_id_tag_update(&sc->clip->id, 0); - } else { - if(data->action==SLIDE_ACTION_SIZE) { + } + else { + if (data->action==SLIDE_ACTION_SIZE) { data->min[0]= data->smin[0]-dx; data->max[0]= data->smax[0]+dx; data->min[1]= data->smin[1]+dy; data->max[1]= data->smax[1]-dy; - if(data->area==TRACK_AREA_SEARCH) BKE_tracking_clamp_track(data->track, CLAMP_SEARCH_DIM); + if (data->area==TRACK_AREA_SEARCH) BKE_tracking_clamp_track(data->track, CLAMP_SEARCH_DIM); else BKE_tracking_clamp_track(data->track, CLAMP_PAT_DIM); - } else { + } + else { float d[2]={dx, dy}; - if(data->area==TRACK_AREA_SEARCH) { + if (data->area==TRACK_AREA_SEARCH) { add_v2_v2v2(data->min, data->smin, d); add_v2_v2v2(data->max, data->smax, d); - } else { + } + else { int a; - for(a= 0; atrack->markersnr; a++) + for (a= 0; atrack->markersnr; a++) add_v2_v2v2(data->track->markers[a].pos, data->smarkers[a], d); sub_v2_v2v2(data->offset, data->soff, d); } - if(data->area==TRACK_AREA_SEARCH) + if (data->area==TRACK_AREA_SEARCH) BKE_tracking_clamp_track(data->track, CLAMP_SEARCH_POS); } } @@ -593,7 +604,7 @@ static int slide_marker_modal(bContext *C, wmOperator *op, wmEvent *event) break; case LEFTMOUSE: - if(event->val==KM_RELEASE) { + if (event->val==KM_RELEASE) { free_slide_data(op->customdata); show_cursor(C); @@ -642,8 +653,8 @@ void CLIP_OT_slide_marker(wmOperatorType *ot) static int mouse_on_side(float co[2], float x1, float y1, float x2, float y2, float epsx, float epsy) { - if(x1>x2) SWAP(float, x1, x2); - if(y1>y2) SWAP(float, y1, y2); + if (x1>x2) SWAP(float, x1, x2); + if (y1>y2) SWAP(float, y1, y2); return (co[0]>=x1-epsx && co[0]<=x2+epsx) && (co[1]>=y1-epsy && co[1]<=y2+epsy); } @@ -672,19 +683,19 @@ static int track_mouse_area(SpaceClip *sc, float co[2], MovieTrackingTrack *trac epsx= MAX2(epsx, 2.0f / width); epsy= MAX2(epsy, 2.0f / height); - if(sc->flag&SC_SHOW_MARKER_SEARCH) - if(mouse_on_rect(co, marker->pos, track->search_min, track->search_max, epsx, epsy)) + if (sc->flag&SC_SHOW_MARKER_SEARCH) + if (mouse_on_rect(co, marker->pos, track->search_min, track->search_max, epsx, epsy)) return TRACK_AREA_SEARCH; - if((marker->flag&MARKER_DISABLED)==0) { - if(sc->flag&SC_SHOW_MARKER_PATTERN) - if(mouse_on_rect(co, marker->pos, track->pat_min, track->pat_max, epsx, epsy)) + if ((marker->flag&MARKER_DISABLED)==0) { + if (sc->flag&SC_SHOW_MARKER_PATTERN) + if (mouse_on_rect(co, marker->pos, track->pat_min, track->pat_max, epsx, epsy)) return TRACK_AREA_PAT; epsx= 12.0f/width; epsy= 12.0f/height; - if(fabsf(co[0]-marker->pos[0]-track->offset[0])< epsx && fabsf(co[1]-marker->pos[1]-track->offset[1])<=epsy) + if (fabsf(co[0]-marker->pos[0]-track->offset[0])< epsx && fabsf(co[1]-marker->pos[1]-track->offset[1])<=epsy) return TRACK_AREA_POINT; } @@ -712,27 +723,27 @@ static MovieTrackingTrack *find_nearest_track(SpaceClip *sc, ListBase *tracksbas float mindist= 0.0f; cur= tracksbase->first; - while(cur) { + while (cur) { MovieTrackingMarker *marker= BKE_tracking_get_marker(cur, sc->user.framenr); - if(((cur->flag&TRACK_HIDDEN)==0) && MARKER_VISIBLE(sc, marker)) { + if (((cur->flag&TRACK_HIDDEN)==0) && MARKER_VISIBLE(sc, marker)) { float dist, d1, d2=FLT_MAX, d3=FLT_MAX; d1= sqrtf((co[0]-marker->pos[0]-cur->offset[0])*(co[0]-marker->pos[0]-cur->offset[0])+ (co[1]-marker->pos[1]-cur->offset[1])*(co[1]-marker->pos[1]-cur->offset[1])); /* distance to marker point */ /* distance to pattern boundbox */ - if(sc->flag&SC_SHOW_MARKER_PATTERN) + if (sc->flag&SC_SHOW_MARKER_PATTERN) d2= dist_to_rect(co, marker->pos, cur->pat_min, cur->pat_max); /* distance to search boundbox */ - if(sc->flag&SC_SHOW_MARKER_SEARCH && TRACK_VIEW_SELECTED(sc, cur)) + if (sc->flag&SC_SHOW_MARKER_SEARCH && TRACK_VIEW_SELECTED(sc, cur)) d3= dist_to_rect(co, marker->pos, cur->search_min, cur->search_max); /* choose minimal distance. useful for cases of overlapped markers. */ dist= MIN3(d1, d2, d3); - if(track==NULL || disttracking.act_track= track; - } else { - if(area==TRACK_AREA_POINT) + } + else { + if (area==TRACK_AREA_POINT) area= TRACK_AREA_ALL; BKE_tracking_select_track(tracksbase, track, area, extend); @@ -775,7 +787,7 @@ static int mouse_select(bContext *C, float co[2], int extend) } } - if(!extend) { + if (!extend) { sc->xlockof= 0.0f; sc->ylockof= 0.0f; } @@ -801,10 +813,10 @@ static int select_invoke(bContext *C, wmOperator *op, wmEvent *event) float co[2]; int extend= RNA_boolean_get(op->ptr, "extend"); - if(!extend) { + if (!extend) { SlideMarkerData *slidedata= slide_marker_customdata(C, event); - if(slidedata) { + if (slidedata) { SpaceClip *sc= CTX_wm_space_clip(C); MovieClip *clip= ED_space_clip(sc); @@ -872,15 +884,15 @@ static int border_select_exec(bContext *C, wmOperator *op) /* do actual selection */ track= tracksbase->first; - while(track) { - if((track->flag&TRACK_HIDDEN)==0) { + while (track) { + if ((track->flag&TRACK_HIDDEN)==0) { MovieTrackingMarker *marker= BKE_tracking_get_marker(track, sc->user.framenr); - if(MARKER_VISIBLE(sc, marker)) { - if(BLI_in_rctf(&rectf, marker->pos[0], marker->pos[1])) { + if (MARKER_VISIBLE(sc, marker)) { + if (BLI_in_rctf(&rectf, marker->pos[0], marker->pos[1])) { BKE_tracking_track_flag(track, TRACK_AREA_ALL, SELECT, mode!=GESTURE_MODAL_SELECT); } - else if(!extend) { + else if (!extend) { BKE_tracking_track_flag(track, TRACK_AREA_ALL, SELECT, 1); } @@ -891,7 +903,7 @@ static int border_select_exec(bContext *C, wmOperator *op) track= track->next; } - if(change) { + if (change) { WM_event_add_notifier(C, NC_GEOM|ND_SELECT, NULL); return OPERATOR_FINISHED; @@ -961,11 +973,11 @@ static int circle_select_exec(bContext *C, wmOperator *op) /* do selection */ track= tracksbase->first; - while(track) { - if((track->flag&TRACK_HIDDEN)==0) { + while (track) { + if ((track->flag&TRACK_HIDDEN)==0) { MovieTrackingMarker *marker= BKE_tracking_get_marker(track, sc->user.framenr); - if(MARKER_VISIBLE(sc, marker) && marker_inside_ellipse(marker, offset, ellipse)) { + if (MARKER_VISIBLE(sc, marker) && marker_inside_ellipse(marker, offset, ellipse)) { BKE_tracking_track_flag(track, TRACK_AREA_ALL, SELECT, mode!=GESTURE_MODAL_SELECT); change= 1; @@ -975,7 +987,7 @@ static int circle_select_exec(bContext *C, wmOperator *op) track= track->next; } - if(change) { + if (change) { WM_event_add_notifier(C, NC_GEOM|ND_SELECT, NULL); return OPERATOR_FINISHED; @@ -1020,14 +1032,14 @@ static int select_all_exec(bContext *C, wmOperator *op) int framenr= sc->user.framenr; int has_selection= 0; - if(action == SEL_TOGGLE){ + if (action == SEL_TOGGLE) { action= SEL_SELECT; track= tracksbase->first; - while(track) { - if(TRACK_VIEW_SELECTED(sc, track)) { + while (track) { + if (TRACK_VIEW_SELECTED(sc, track)) { marker= BKE_tracking_get_marker(track, framenr); - if(MARKER_VISIBLE(sc, marker)) { + if (MARKER_VISIBLE(sc, marker)) { action= SEL_DESELECT; break; } @@ -1038,11 +1050,11 @@ static int select_all_exec(bContext *C, wmOperator *op) } track= tracksbase->first; - while(track) { - if((track->flag&TRACK_HIDDEN)==0) { + while (track) { + if ((track->flag&TRACK_HIDDEN)==0) { marker= BKE_tracking_get_marker(track, framenr); - if(MARKER_VISIBLE(sc, marker)) { + if (MARKER_VISIBLE(sc, marker)) { switch (action) { case SEL_SELECT: track->flag|= SELECT; @@ -1063,13 +1075,13 @@ static int select_all_exec(bContext *C, wmOperator *op) } } - if(TRACK_VIEW_SELECTED(sc, track)) + if (TRACK_VIEW_SELECTED(sc, track)) has_selection= 1; track= track->next; } - if(!has_selection) + if (!has_selection) sc->flag&= ~SC_LOCK_SELECTION; WM_event_add_notifier(C, NC_GEOM|ND_SELECT, NULL); @@ -1107,44 +1119,44 @@ static int select_groped_exec(bContext *C, wmOperator *op) int group= RNA_enum_get(op->ptr, "group"); track= tracksbase->first; - while(track) { + while (track) { int ok= 0; marker= BKE_tracking_get_marker(track, sc->user.framenr); - if(group==0) { /* Keyframed */ + if (group==0) { /* Keyframed */ ok= marker->framenr==sc->user.framenr && (marker->flag&MARKER_TRACKED)==0; } - else if(group==1) { /* Estimated */ + else if (group==1) { /* Estimated */ ok= marker->framenr!=sc->user.framenr; } - else if(group==2) { /* tracked */ + else if (group==2) { /* tracked */ ok= marker->framenr==sc->user.framenr && (marker->flag&MARKER_TRACKED); } - else if(group==3) { /* locked */ + else if (group==3) { /* locked */ ok= track->flag&TRACK_LOCKED; } - else if(group==4) { /* disabled */ + else if (group==4) { /* disabled */ ok= marker->flag&MARKER_DISABLED; } - else if(group==5) { /* color */ + else if (group==5) { /* color */ MovieTrackingTrack *act_track= BKE_tracking_active_track(tracking); - if(act_track) { + if (act_track) { ok= (track->flag&TRACK_CUSTOMCOLOR) == (act_track->flag&TRACK_CUSTOMCOLOR); - if(ok && track->flag&TRACK_CUSTOMCOLOR) + if (ok && track->flag&TRACK_CUSTOMCOLOR) ok= equals_v3v3(track->color, act_track->color); } } - else if(group==6) { /* failed */ + else if (group==6) { /* failed */ ok= (track->flag&TRACK_HAS_BUNDLE) == 0; } - if(ok) { + if (ok) { track->flag|= SELECT; - if(sc->flag&SC_SHOW_MARKER_PATTERN) track->pat_flag|= SELECT; - if(sc->flag&SC_SHOW_MARKER_SEARCH) track->search_flag|= SELECT; + if (sc->flag&SC_SHOW_MARKER_PATTERN) track->pat_flag|= SELECT; + if (sc->flag&SC_SHOW_MARKER_SEARCH) track->search_flag|= SELECT; } track= track->next; @@ -1211,8 +1223,8 @@ static int track_count_markers(SpaceClip *sc, MovieClip *clip) int framenr= sc->user.framenr; track= tracksbase->first; - while(track) { - if(TRACK_VIEW_SELECTED(sc, track) && (track->flag&TRACK_LOCKED)==0) { + while (track) { + if (TRACK_VIEW_SELECTED(sc, track) && (track->flag&TRACK_LOCKED)==0) { MovieTrackingMarker *marker= BKE_tracking_get_marker(track, framenr); if (!marker || (marker->flag&MARKER_DISABLED) == 0) @@ -1239,7 +1251,7 @@ static void clear_invisible_track_selection(SpaceClip *sc, MovieClip *clip) if (hidden) { MovieTrackingTrack *track = tracksbase->first; - while(track) { + while (track) { if ((track->flag & TRACK_HIDDEN) == 0) BKE_tracking_track_flag(track, hidden, SELECT, 1); @@ -1258,13 +1270,13 @@ static void track_init_markers(SpaceClip *sc, MovieClip *clip, int *frames_limit clear_invisible_track_selection(sc, clip); track= tracksbase->first; - while(track) { - if(TRACK_VIEW_SELECTED(sc, track)) { - if((track->flag&TRACK_HIDDEN)==0 && (track->flag&TRACK_LOCKED)==0) { + while (track) { + if (TRACK_VIEW_SELECTED(sc, track)) { + if ((track->flag&TRACK_HIDDEN)==0 && (track->flag&TRACK_LOCKED)==0) { BKE_tracking_ensure_marker(track, framenr); - if(track->frames_limit) { - if(frames_limit==0) + if (track->frames_limit) { + if (frames_limit==0) frames_limit= track->frames_limit; else frames_limit= MIN2(frames_limit, track->frames_limit); @@ -1280,11 +1292,11 @@ static void track_init_markers(SpaceClip *sc, MovieClip *clip, int *frames_limit static int track_markers_check_direction(int backwards, int curfra, int efra) { - if(backwards) { - if(curfraefra) return 0; + if (curfra>efra) return 0; } return 1; @@ -1304,21 +1316,21 @@ static int track_markers_initjob(bContext *C, TrackMarkersJob *tmj, int backward tmj->clip= clip; tmj->backwards= backwards; - if(backwards) tmj->efra= SFRA; + if (backwards) tmj->efra= SFRA; else tmj->efra= EFRA; /* limit frames to be tracked by user setting */ - if(frames_limit) { - if(backwards) tmj->efra= MAX2(tmj->efra, tmj->sfra-frames_limit); + if (frames_limit) { + if (backwards) tmj->efra= MAX2(tmj->efra, tmj->sfra-frames_limit); else tmj->efra= MIN2(tmj->efra, tmj->sfra+frames_limit); } - if(settings->speed!=TRACKING_SPEED_FASTEST) { + if (settings->speed!=TRACKING_SPEED_FASTEST) { tmj->delay= 1.0f/scene->r.frs_sec*1000.0f; - if(settings->speed==TRACKING_SPEED_HALF) tmj->delay*= 2; - else if(settings->speed==TRACKING_SPEED_QUARTER) tmj->delay*= 4; - else if(settings->speed==TRACKING_SPEED_DOUBLE) tmj->delay/= 2; + if (settings->speed==TRACKING_SPEED_HALF) tmj->delay*= 2; + else if (settings->speed==TRACKING_SPEED_QUARTER) tmj->delay*= 4; + else if (settings->speed==TRACKING_SPEED_DOUBLE) tmj->delay/= 2; } tmj->context= BKE_tracking_context_new(clip, &sc->user, backwards, 1); @@ -1345,8 +1357,8 @@ static void track_markers_startjob(void *tmv, short *stop, short *do_update, flo int framenr= tmj->sfra; //double t= PIL_check_seconds_timer(); - while(framenr != tmj->efra) { - if(tmj->delay>0) { + while (framenr != tmj->efra) { + if (tmj->delay>0) { /* tracking should happen with fixed fps. Calculate time * using current timer value before tracking frame and after. * @@ -1355,24 +1367,25 @@ static void track_markers_startjob(void *tmv, short *stop, short *do_update, flo double start_time= PIL_check_seconds_timer(), exec_time; - if(!BKE_tracking_next(tmj->context)) + if (!BKE_tracking_next(tmj->context)) break; exec_time= PIL_check_seconds_timer()-start_time; - if(tmj->delay > (float)exec_time) + if (tmj->delay > (float)exec_time) PIL_sleep_ms(tmj->delay-(float)exec_time); - } else if(!BKE_tracking_next(tmj->context)) + } + else if (!BKE_tracking_next(tmj->context)) break; *do_update= 1; *progress=(float)(framenr-tmj->sfra) / (tmj->efra-tmj->sfra); - if(tmj->backwards) framenr--; + if (tmj->backwards) framenr--; else framenr++; tmj->lastfra= framenr; - if(*stop || track_markers_testbreak()) + if (*stop || track_markers_testbreak()) break; } @@ -1414,34 +1427,34 @@ static int track_markers_exec(bContext *C, wmOperator *op) int sequence= RNA_boolean_get(op->ptr, "sequence"); int frames_limit; - if(track_count_markers(sc, clip)==0) + if (track_count_markers(sc, clip)==0) return OPERATOR_CANCELLED; track_init_markers(sc, clip, &frames_limit); - if(backwards) efra= SFRA; + if (backwards) efra= SFRA; else efra= EFRA; /* limit frames to be tracked by user setting */ - if(frames_limit) { - if(backwards) efra= MAX2(efra, sfra-frames_limit); + if (frames_limit) { + if (backwards) efra= MAX2(efra, sfra-frames_limit); else efra= MIN2(efra, sfra+frames_limit); } - if(!track_markers_check_direction(backwards, framenr, efra)) + if (!track_markers_check_direction(backwards, framenr, efra)) return OPERATOR_CANCELLED; /* do not disable tracks due to threshold when tracking frame-by-frame */ context= BKE_tracking_context_new(clip, &sc->user, backwards, sequence); - while(framenr != efra) { - if(!BKE_tracking_next(context)) + while (framenr != efra) { + if (!BKE_tracking_next(context)) break; - if(backwards) framenr--; + if (backwards) framenr--; else framenr++; - if(!sequence) + if (!sequence) break; } @@ -1467,22 +1480,22 @@ static int track_markers_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(eve int backwards= RNA_boolean_get(op->ptr, "backwards"); int sequence= RNA_boolean_get(op->ptr, "sequence"); - if(WM_jobs_test(CTX_wm_manager(C), CTX_wm_area(C))) { + if (WM_jobs_test(CTX_wm_manager(C), CTX_wm_area(C))) { /* only one tracking is allowed at a time */ return OPERATOR_CANCELLED; } - if(clip->tracking_context) + if (clip->tracking_context) return OPERATOR_CANCELLED; - if(track_count_markers(sc, clip)==0) + if (track_count_markers(sc, clip)==0) return OPERATOR_CANCELLED; - if(!sequence) + if (!sequence) return track_markers_exec(C, op); tmj= MEM_callocN(sizeof(TrackMarkersJob), "TrackMarkersJob data"); - if(!track_markers_initjob(C, tmj, backwards)) { + if (!track_markers_initjob(C, tmj, backwards)) { track_markers_freejob(tmj); return OPERATOR_CANCELLED; @@ -1496,7 +1509,7 @@ static int track_markers_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(eve * with fixed FPS. To deal with editor refresh we have to synchronize * tracks from job and tracks in clip. Do this in timer callback * to prevent threading conflicts. */ - if(tmj->delay>0) WM_jobs_timer(steve, tmj->delay/1000.0f, NC_MOVIECLIP|NA_EVALUATED, 0); + if (tmj->delay>0) WM_jobs_timer(steve, tmj->delay/1000.0f, NC_MOVIECLIP|NA_EVALUATED, 0); else WM_jobs_timer(steve, 0.2, NC_MOVIECLIP|NA_EVALUATED, 0); WM_jobs_callbacks(steve, track_markers_startjob, NULL, track_markers_updatejob, NULL); @@ -1515,7 +1528,7 @@ static int track_markers_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(eve static int track_markers_modal(bContext *C, wmOperator *UNUSED(op), wmEvent *event) { /* no running tracking, remove handler and pass through */ - if(0==WM_jobs_test(CTX_wm_manager(C), CTX_wm_area(C))) + if (0==WM_jobs_test(CTX_wm_manager(C), CTX_wm_area(C))) return OPERATOR_FINISHED|OPERATOR_PASS_THROUGH; /* running tracking */ @@ -1573,7 +1586,7 @@ static int solve_camera_initjob(bContext *C, SolveCameraJob *scj, wmOperator *op MovieTrackingObject *object= BKE_tracking_active_object(tracking); int width, height; - if(!BKE_tracking_can_reconstruct(tracking, object, error_msg, max_error)) + if (!BKE_tracking_can_reconstruct(tracking, object, error_msg, max_error)) return 0; /* could fail if footage uses images with different sizes */ @@ -1616,7 +1629,7 @@ static void solve_camera_freejob(void *scv) MovieClip *clip= scj->clip; int solved; - if(!scj->context) { + if (!scj->context) { /* job weren't fully initialized due to some error */ MEM_freeN(scj); return; @@ -1624,20 +1637,20 @@ static void solve_camera_freejob(void *scv) solved= BKE_tracking_finish_reconstruction(scj->context, tracking); - if(!solved) + if (!solved) BKE_report(scj->reports, RPT_WARNING, "Some data failed to reconstruct, see console for details"); else BKE_reportf(scj->reports, RPT_INFO, "Average re-projection error %.3f", tracking->reconstruction.error); /* set currently solved clip as active for scene */ - if(scene->clip) + if (scene->clip) id_us_min(&clip->id); scene->clip= clip; id_us_plus(&clip->id); /* set blender camera focal length so result would look fine there */ - if(scene->camera) { + if (scene->camera) { Camera *camera= (Camera*)scene->camera->data; int width, height; @@ -1669,8 +1682,8 @@ static int solve_camera_exec(bContext *C, wmOperator *op) char error_msg[256]= "\0"; scj= MEM_callocN(sizeof(SolveCameraJob), "SolveCameraJob data"); - if(!solve_camera_initjob(C, scj, op, error_msg, sizeof(error_msg))) { - if(error_msg[0]) + if (!solve_camera_initjob(C, scj, op, error_msg, sizeof(error_msg))) { + if (error_msg[0]) BKE_report(op->reports, RPT_ERROR, error_msg); solve_camera_freejob(scj); @@ -1696,14 +1709,14 @@ static int solve_camera_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(even wmJob *steve; char error_msg[256]= "\0"; - if(WM_jobs_test(CTX_wm_manager(C), CTX_wm_area(C))) { + if (WM_jobs_test(CTX_wm_manager(C), CTX_wm_area(C))) { /* only one solve is allowed at a time */ return OPERATOR_CANCELLED; } scj= MEM_callocN(sizeof(SolveCameraJob), "SolveCameraJob data"); - if(!solve_camera_initjob(C, scj, op, error_msg, sizeof(error_msg))) { - if(error_msg[0]) + if (!solve_camera_initjob(C, scj, op, error_msg, sizeof(error_msg))) { + if (error_msg[0]) BKE_report(op->reports, RPT_ERROR, error_msg); solve_camera_freejob(scj); @@ -1737,7 +1750,7 @@ static int solve_camera_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(even static int solve_camera_modal(bContext *C, wmOperator *UNUSED(op), wmEvent *event) { /* no running solver, remove handler and pass through */ - if(0==WM_jobs_test(CTX_wm_manager(C), CTX_wm_area(C))) + if (0==WM_jobs_test(CTX_wm_manager(C), CTX_wm_area(C))) return OPERATOR_FINISHED|OPERATOR_PASS_THROUGH; /* running tracking */ @@ -1778,13 +1791,13 @@ static int clear_solution_exec(bContext *C, wmOperator *UNUSED(op)) MovieTrackingReconstruction *reconstruction= BKE_tracking_get_reconstruction(tracking); MovieTrackingTrack *track= tracksbase->first; - while(track) { + while (track) { track->flag&= ~TRACK_HAS_BUNDLE; track= track->next; } - if(reconstruction->cameras) + if (reconstruction->cameras) MEM_freeN(reconstruction->cameras); reconstruction->cameras= NULL; @@ -1832,8 +1845,8 @@ static int clear_track_path_exec(bContext *C, wmOperator *op) } else { track= tracksbase->first; - while(track) { - if(TRACK_VIEW_SELECTED(sc, track)) + while (track) { + if (TRACK_VIEW_SELECTED(sc, track)) BKE_tracking_clear_path(track, sc->user.framenr, action); track= track->next; @@ -1882,12 +1895,12 @@ static int disable_markers_exec(bContext *C, wmOperator *op) MovieTrackingTrack *track= tracksbase->first; int action= RNA_enum_get(op->ptr, "action"); - while(track) { - if(TRACK_VIEW_SELECTED(sc, track) && (track->flag&TRACK_LOCKED)==0) { + while (track) { + if (TRACK_VIEW_SELECTED(sc, track) && (track->flag&TRACK_LOCKED)==0) { MovieTrackingMarker *marker= BKE_tracking_ensure_marker(track, sc->user.framenr); - if(action==0) marker->flag|= MARKER_DISABLED; - else if(action==1) marker->flag&= ~MARKER_DISABLED; + if (action==0) marker->flag|= MARKER_DISABLED; + else if (action==1) marker->flag&= ~MARKER_DISABLED; else marker->flag^= MARKER_DISABLED; } @@ -1933,13 +1946,13 @@ static Object *get_camera_with_movieclip(Scene *scene, MovieClip *clip) Object *camera= scene->camera; Base *base; - if(camera && object_get_movieclip(scene, camera, 0)==clip) + if (camera && object_get_movieclip(scene, camera, 0)==clip) return camera; base= scene->base.first; - while(base) { - if(base->object->type == OB_CAMERA) { - if(object_get_movieclip(scene, base->object, 0)==clip) { + while (base) { + if (base->object->type == OB_CAMERA) { + if (object_get_movieclip(scene, base->object, 0)==clip) { camera= base->object; break; } @@ -1960,14 +1973,14 @@ static Object *get_orientation_object(bContext *C) MovieTrackingObject *tracking_object= BKE_tracking_active_object(tracking); Object *object= NULL; - if(tracking_object->flag&TRACKING_OBJECT_CAMERA) { + if (tracking_object->flag&TRACKING_OBJECT_CAMERA) { object= get_camera_with_movieclip(scene, clip); } else { object= OBACT; } - if(object && object->parent) + if (object && object->parent) object= object->parent; return object; @@ -1975,14 +1988,14 @@ static Object *get_orientation_object(bContext *C) static int set_orientation_poll(bContext *C) { - if(space_clip_frame_poll(C)) { + if (space_clip_frame_poll(C)) { Scene *scene= CTX_data_scene(C); SpaceClip *sc= CTX_wm_space_clip(C); MovieClip *clip= ED_space_clip(sc); MovieTracking *tracking= &clip->tracking; MovieTrackingObject *tracking_object= BKE_tracking_active_object(tracking); - if(tracking_object->flag&TRACKING_OBJECT_CAMERA) { + if (tracking_object->flag&TRACKING_OBJECT_CAMERA) { return 1; } else { @@ -2002,8 +2015,8 @@ static int count_selected_bundles(bContext *C) int tot= 0; track= tracksbase->first; - while(track) { - if(TRACK_VIEW_SELECTED(sc, track) && (track->flag&TRACK_HAS_BUNDLE)) + while (track) { + if (TRACK_VIEW_SELECTED(sc, track) && (track->flag&TRACK_HAS_BUNDLE)) tot++; track= track->next; @@ -2020,13 +2033,13 @@ static void object_solver_inverted_matrix(Scene *scene, Object *ob, float invmat for (con= ob->constraints.first; con; con=con->next) { bConstraintTypeInfo *cti= constraint_get_typeinfo(con); - if(!cti) + if (!cti) continue; - if(cti->type==CONSTRAINT_TYPE_OBJECTSOLVER) { + if (cti->type==CONSTRAINT_TYPE_OBJECTSOLVER) { bObjectSolverConstraint *data= (bObjectSolverConstraint *)con->data; - if(!found) { + if (!found) { Object *cam= data->camera ? data->camera : scene->camera; where_is_object_mat(scene, cam, invmat); @@ -2038,7 +2051,7 @@ static void object_solver_inverted_matrix(Scene *scene, Object *ob, float invmat } } - if(found) + if (found) invert_m4(invmat); else unit_m4(invmat); @@ -2051,10 +2064,10 @@ static Object *object_solver_camera(Scene *scene, Object *ob) for (con= ob->constraints.first; con; con=con->next) { bConstraintTypeInfo *cti= constraint_get_typeinfo(con); - if(!cti) + if (!cti) continue; - if(cti->type==CONSTRAINT_TYPE_OBJECTSOLVER) { + if (cti->type==CONSTRAINT_TYPE_OBJECTSOLVER) { bObjectSolverConstraint *data= (bObjectSolverConstraint *)con->data; return data->camera ? data->camera : scene->camera; @@ -2078,14 +2091,14 @@ static int set_origin_exec(bContext *C, wmOperator *op) float mat[4][4], vec[3], median[3]; int selected_count= count_selected_bundles(C); - if(selected_count==0) { + if (selected_count==0) { BKE_report(op->reports, RPT_ERROR, "At least one track with bundle should be selected to define origin position"); return OPERATOR_CANCELLED; } object= get_orientation_object(C); - if(!object) { + if (!object) { BKE_report(op->reports, RPT_ERROR, "No object to apply orientation on"); return OPERATOR_CANCELLED; @@ -2097,8 +2110,8 @@ static int set_origin_exec(bContext *C, wmOperator *op) track= tracksbase->first; zero_v3(median); - while(track) { - if(TRACK_VIEW_SELECTED(sc, track) && (track->flag&TRACK_HAS_BUNDLE)) { + while (track) { + if (TRACK_VIEW_SELECTED(sc, track) && (track->flag&TRACK_HAS_BUNDLE)) { add_v3_v3(median, track->bundle_pos); } @@ -2110,7 +2123,7 @@ static int set_origin_exec(bContext *C, wmOperator *op) mul_v3_m4v3(vec, mat, median); - if(tracking_object->flag&TRACKING_OBJECT_CAMERA) { + if (tracking_object->flag&TRACKING_OBJECT_CAMERA) { sub_v3_v3(object->loc, vec); } else { @@ -2162,7 +2175,7 @@ static void set_axis(Scene *scene, Object *ob, MovieClip *clip, MovieTrackingOb mul_v3_m4v3(vec, mat, track->bundle_pos); copy_v3_v3(dvec, vec); - if(!is_camera) { + if (!is_camera) { float imat[4][4]; object_solver_inverted_matrix(scene, ob, imat); @@ -2174,22 +2187,23 @@ static void set_axis(Scene *scene, Object *ob, MovieClip *clip, MovieTrackingOb sub_v3_v3(vec, obmat[3]); } - if(len_v2(vec) < 1e-3f) + if (len_v2(vec) < 1e-3f) return; unit_m4(mat); - if(axis=='X') { - if(fabsf(dvec[1])<1e-3f) { + if (axis=='X') { + if (fabsf(dvec[1])<1e-3f) { flip= 1; mat[0][0]= -1.0f; mat[0][1]= 0.0f; mat[0][2]= 0.0f; mat[1][0]= 0.0f; mat[1][1]= -1.0f; mat[1][2]= 0.0f; mat[2][0]= 0.0f; mat[2][1]= 0.0f; mat[2][2]= 1.0f; - } else { + } + else { copy_v3_v3(mat[0], vec); - if(is_camera || fabsf(vec[2])<1e-3f) { + if (is_camera || fabsf(vec[2])<1e-3f) { mat[0][2]= 0.0f; mat[2][0]= 0.0f; mat[2][1]= 0.0f; mat[2][2]= 1.0f; cross_v3_v3v3(mat[1], mat[2], mat[0]); @@ -2201,17 +2215,19 @@ static void set_axis(Scene *scene, Object *ob, MovieClip *clip, MovieTrackingOb cross_v3_v3v3(mat[2], mat[0], mat[1]); } } - } else { - if(fabsf(dvec[0])<1e-3f) { + } + else { + if (fabsf(dvec[0])<1e-3f) { flip= 1; mat[0][0]= -1.0f; mat[0][1]= 0.0f; mat[0][2]= 0.0f; mat[1][0]= 0.0f; mat[1][1]= -1.0f; mat[1][2]= 0.0f; mat[2][0]= 0.0f; mat[2][1]= 0.0f; mat[2][2]= 1.0f; - } else { + } + else { copy_v3_v3(mat[1], vec); - if(is_camera || fabsf(vec[2])<1e-3f) { + if (is_camera || fabsf(vec[2])<1e-3f) { mat[1][2]= 0.0f; mat[2][0]= 0.0f; mat[2][1]= 0.0f; mat[2][2]= 1.0f; cross_v3_v3v3(mat[0], mat[1], mat[2]); @@ -2229,13 +2245,13 @@ static void set_axis(Scene *scene, Object *ob, MovieClip *clip, MovieTrackingOb normalize_v3(mat[1]); normalize_v3(mat[2]); - if(is_camera) { + if (is_camera) { invert_m4(mat); mult_m4_m4m4(mat, mat, obmat); } else { - if(!flip) { + if (!flip) { float lmat[4][4], ilmat[4][4], rmat[3][3]; object_rot_to_mat3(ob, rmat); @@ -2275,7 +2291,7 @@ static int set_plane_exec(bContext *C, wmOperator *op) {1.0f, 0.0f, 0.0f, 0.0f}, {0.0f, 0.0f, 0.0f, 1.0f}}; /* 90 degrees Y-axis rotation matrix */ - if(count_selected_bundles(C)!=3) { + if (count_selected_bundles(C)!=3) { BKE_report(op->reports, RPT_ERROR, "Three tracks with bundles are needed to orient the floor"); return OPERATOR_CANCELLED; @@ -2286,7 +2302,7 @@ static int set_plane_exec(bContext *C, wmOperator *op) act_track= BKE_tracking_active_track(tracking); object= get_orientation_object(C); - if(!object) { + if (!object) { BKE_report(op->reports, RPT_ERROR, "No object to apply orientation on"); return OPERATOR_CANCELLED; @@ -2296,11 +2312,11 @@ static int set_plane_exec(bContext *C, wmOperator *op) /* get 3 bundles to use as reference */ track= tracksbase->first; - while(track && tot<3) { - if(track->flag&TRACK_HAS_BUNDLE && TRACK_VIEW_SELECTED(sc, track)) { + while (track && tot<3) { + if (track->flag&TRACK_HAS_BUNDLE && TRACK_VIEW_SELECTED(sc, track)) { mul_v3_m4v3(vec[tot], mat, track->bundle_pos); - if(tot==0 || track==act_track) + if (tot==0 || track==act_track) copy_v3_v3(orig, vec[tot]); else axis_track= track; @@ -2337,7 +2353,7 @@ static int set_plane_exec(bContext *C, wmOperator *op) mat[3][1]= orig[1]; mat[3][2]= orig[2]; - if(tracking_object->flag&TRACKING_OBJECT_CAMERA) { + if (tracking_object->flag&TRACKING_OBJECT_CAMERA) { invert_m4(mat); object_to_mat4(object, obmat); @@ -2346,7 +2362,7 @@ static int set_plane_exec(bContext *C, wmOperator *op) object_apply_mat4(object, newmat, 0, 0); /* make camera have positive z-coordinate */ - if(object->loc[2]<0) { + if (object->loc[2]<0) { invert_m4(rot); mult_m4_m4m4(newmat, rot, mat); object_apply_mat4(object, newmat, 0, 0); @@ -2406,14 +2422,14 @@ static int set_axis_exec(bContext *C, wmOperator *op) ListBase *tracksbase; int axis= RNA_enum_get(op->ptr, "axis"); - if(count_selected_bundles(C)!=1) { + if (count_selected_bundles(C)!=1) { BKE_report(op->reports, RPT_ERROR, "Single track with bundle should be selected to define axis"); return OPERATOR_CANCELLED; } object= get_orientation_object(C); - if(!object) { + if (!object) { BKE_report(op->reports, RPT_ERROR, "No object to apply orientation on"); return OPERATOR_CANCELLED; @@ -2422,8 +2438,8 @@ static int set_axis_exec(bContext *C, wmOperator *op) tracksbase= BKE_tracking_object_tracks(tracking, tracking_object); track=tracksbase->first; - while(track) { - if(TRACK_VIEW_SELECTED(sc, track)) + while (track) { + if (TRACK_VIEW_SELECTED(sc, track)) break; track= track->next; @@ -2481,14 +2497,14 @@ static int do_set_scale(bContext *C, wmOperator *op, int scale_solution) float vec[2][3], mat[4][4], scale; float dist= RNA_float_get(op->ptr, "distance"); - if(count_selected_bundles(C)!=2) { + if (count_selected_bundles(C)!=2) { BKE_report(op->reports, RPT_ERROR, "Two tracks with bundles should be selected to set scale"); return OPERATOR_CANCELLED; } object= get_orientation_object(C); - if(!object) { + if (!object) { BKE_report(op->reports, RPT_ERROR, "No object to apply orientation on"); return OPERATOR_CANCELLED; @@ -2497,8 +2513,8 @@ static int do_set_scale(bContext *C, wmOperator *op, int scale_solution) BKE_get_tracking_mat(scene, camera, mat); track= tracksbase->first; - while(track) { - if(TRACK_VIEW_SELECTED(sc, track)) { + while (track) { + if (TRACK_VIEW_SELECTED(sc, track)) { mul_v3_m4v3(vec[tot], mat, track->bundle_pos); tot++; } @@ -2508,19 +2524,19 @@ static int do_set_scale(bContext *C, wmOperator *op, int scale_solution) sub_v3_v3(vec[0], vec[1]); - if(len_v3(vec[0])>1e-5f) { + if (len_v3(vec[0])>1e-5f) { scale= dist / len_v3(vec[0]); - if(tracking_object->flag&TRACKING_OBJECT_CAMERA) { + if (tracking_object->flag&TRACKING_OBJECT_CAMERA) { mul_v3_fl(object->size, scale); mul_v3_fl(object->loc, scale); } - else if(!scale_solution){ + else if (!scale_solution) { Object *solver_camera= object_solver_camera(scene, object); object->size[0]= object->size[1]= object->size[2]= 1.0f/scale; - if(solver_camera) { + if (solver_camera) { object->size[0]/= solver_camera->size[0]; object->size[1]/= solver_camera->size[1]; object->size[2]/= solver_camera->size[2]; @@ -2532,7 +2548,7 @@ static int do_set_scale(bContext *C, wmOperator *op, int scale_solution) DAG_id_tag_update(&clip->id, 0); - if(object) + if (object) DAG_id_tag_update(&object->id, OB_RECALC_OB); WM_event_add_notifier(C, NC_MOVIECLIP|NA_EVALUATED, clip); @@ -2552,7 +2568,7 @@ static int set_scale_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) SpaceClip *sc= CTX_wm_space_clip(C); MovieClip *clip= ED_space_clip(sc); - if(!RNA_struct_property_is_set(op->ptr, "distance")) + if (!RNA_struct_property_is_set(op->ptr, "distance")) RNA_float_set(op->ptr, "distance", clip->tracking.settings.dist); return set_scale_exec(C, op); @@ -2582,7 +2598,7 @@ void CLIP_OT_set_scale(wmOperatorType *ot) static int set_solution_scale_poll(bContext *C) { - if(space_clip_frame_poll(C)) { + if (space_clip_frame_poll(C)) { SpaceClip *sc= CTX_wm_space_clip(C); MovieClip *clip= ED_space_clip(sc); MovieTracking *tracking= &clip->tracking; @@ -2604,7 +2620,7 @@ static int set_solution_scale_invoke(bContext *C, wmOperator *op, wmEvent *UNUSE SpaceClip *sc= CTX_wm_space_clip(C); MovieClip *clip= ED_space_clip(sc); - if(!RNA_struct_property_is_set(op->ptr, "distance")) + if (!RNA_struct_property_is_set(op->ptr, "distance")) RNA_float_set(op->ptr, "distance", clip->tracking.settings.object_distance); return set_solution_scale_exec(C, op); @@ -2640,7 +2656,7 @@ static int set_center_principal_exec(bContext *C, wmOperator *UNUSED(op)) BKE_movieclip_get_size(clip, &sc->user, &width, &height); - if(width==0 || height==0) + if (width==0 || height==0) return OPERATOR_CANCELLED; clip->tracking.camera.principal[0]= ((float)width)/2.0f; @@ -2681,20 +2697,21 @@ static int hide_tracks_exec(bContext *C, wmOperator *op) unselected= RNA_boolean_get(op->ptr, "unselected"); track= tracksbase->first; - while(track) { - if(unselected==0 && TRACK_VIEW_SELECTED(sc, track)) { + while (track) { + if (unselected==0 && TRACK_VIEW_SELECTED(sc, track)) { track->flag|= TRACK_HIDDEN; - } else if(unselected==1 && !TRACK_VIEW_SELECTED(sc, track)) { + } + else if (unselected==1 && !TRACK_VIEW_SELECTED(sc, track)) { track->flag|= TRACK_HIDDEN; } track= track->next; } - if(act_track && act_track->flag&TRACK_HIDDEN) + if (act_track && act_track->flag&TRACK_HIDDEN) clip->tracking.act_track= NULL; - if(unselected==0) { + if (unselected==0) { /* no selection on screen now, unlock view so it can be scrolled nice again */ sc->flag&= ~SC_LOCK_SELECTION; } @@ -2732,7 +2749,7 @@ static int hide_tracks_clear_exec(bContext *C, wmOperator *UNUSED(op)) MovieTrackingTrack *track; track= tracksbase->first; - while(track) { + while (track) { track->flag&= ~TRACK_HIDDEN; track= track->next; @@ -2764,12 +2781,12 @@ static bGPDlayer *detect_get_layer(MovieClip *clip) { bGPDlayer *layer; - if(!clip->gpd) + if (!clip->gpd) return NULL; layer= clip->gpd->layers.first; - while(layer) { - if(layer->flag&GP_LAYER_ACTIVE) + while (layer) { + if (layer->flag&GP_LAYER_ACTIVE) return layer; layer= layer->next; @@ -2794,13 +2811,13 @@ static int detect_features_exec(bContext *C, wmOperator *op) int place_outside_layer= 0; bGPDlayer *layer= NULL; - if(placement!=0) { + if (placement!=0) { layer= detect_get_layer(clip); place_outside_layer= placement==2; } /* deselect existing tracks */ - while(track) { + while (track) { track->flag&= ~SELECT; track->pat_flag&= ~SELECT; track->search_flag&= ~SELECT; @@ -2857,25 +2874,25 @@ static int frame_jump_exec(bContext *C, wmOperator *op) int pos= RNA_enum_get(op->ptr, "position"); int delta; - if(pos<=1) { /* jump to path */ + if (pos<=1) { /* jump to path */ track= BKE_tracking_active_track(&clip->tracking); - if(!track) + if (!track) return OPERATOR_CANCELLED; delta= pos == 1 ? 1 : -1; - while(sc->user.framenr+delta >= SFRA && sc->user.framenr+delta <= EFRA) { + while (sc->user.framenr+delta >= SFRA && sc->user.framenr+delta <= EFRA) { MovieTrackingMarker *marker= BKE_tracking_exact_marker(track, sc->user.framenr+delta); - if(!marker || marker->flag&MARKER_DISABLED) + if (!marker || marker->flag&MARKER_DISABLED) break; sc->user.framenr+= delta; } } else { /* to to failed frame */ - if(clip->tracking.reconstruction.flag&TRACKING_RECONSTRUCTED) { + if (clip->tracking.reconstruction.flag&TRACKING_RECONSTRUCTED) { int a= sc->user.framenr; MovieTracking *tracking= &clip->tracking; MovieTrackingObject *object= BKE_tracking_active_object(tracking); @@ -2884,12 +2901,12 @@ static int frame_jump_exec(bContext *C, wmOperator *op) a+= delta; - while(a+delta >= SFRA && a+delta <= EFRA) { + while (a+delta >= SFRA && a+delta <= EFRA) { MovieReconstructedCamera *cam; cam= BKE_tracking_get_reconstructed_camera(tracking, object, a); - if(!cam) { + if (!cam) { sc->user.framenr= a; break; @@ -2900,7 +2917,7 @@ static int frame_jump_exec(bContext *C, wmOperator *op) } } - if(CFRA!=sc->user.framenr) { + if (CFRA!=sc->user.framenr) { CFRA= sc->user.framenr; sound_seek_scene(CTX_data_main(C), CTX_data_scene(C)); @@ -2950,19 +2967,19 @@ static int join_tracks_exec(bContext *C, wmOperator *op) act_track= BKE_tracking_active_track(tracking); - if(!act_track) { + if (!act_track) { BKE_report(op->reports, RPT_ERROR, "No active track to join to"); return OPERATOR_CANCELLED; } track= tracksbase->first; - while(track) { + while (track) { next= track->next; - if(TRACK_VIEW_SELECTED(sc, track) && track!=act_track) { + if (TRACK_VIEW_SELECTED(sc, track) && track!=act_track) { BKE_tracking_join_tracks(act_track, track); - if(tracking->stabilization.rot_track == track) + if (tracking->stabilization.rot_track == track) tracking->stabilization.rot_track= act_track; BKE_tracking_free_track(track); @@ -3003,10 +3020,10 @@ static int lock_tracks_exec(bContext *C, wmOperator *op) MovieTrackingTrack *track= tracksbase->first; int action= RNA_enum_get(op->ptr, "action"); - while(track) { - if(TRACK_VIEW_SELECTED(sc, track)) { - if(action==0) track->flag|= TRACK_LOCKED; - else if(action==1) track->flag&= ~TRACK_LOCKED; + while (track) { + if (TRACK_VIEW_SELECTED(sc, track)) { + if (action==0) track->flag|= TRACK_LOCKED; + else if (action==1) track->flag&= ~TRACK_LOCKED; else track->flag^= TRACK_LOCKED; } @@ -3053,15 +3070,15 @@ static int track_copy_color_exec(bContext *C, wmOperator *UNUSED(op)) ListBase *tracksbase= BKE_tracking_get_tracks(tracking); MovieTrackingTrack *track, *act_track= BKE_tracking_active_track(tracking); - if(!act_track) + if (!act_track) return OPERATOR_CANCELLED; track= tracksbase->first; - while(track) { - if(TRACK_VIEW_SELECTED(sc, track) && track!=act_track) { + while (track) { + if (TRACK_VIEW_SELECTED(sc, track) && track!=act_track) { track->flag&= ~TRACK_CUSTOMCOLOR; - if(act_track->flag&TRACK_CUSTOMCOLOR) { + if (act_track->flag&TRACK_CUSTOMCOLOR) { copy_v3_v3(track->color, act_track->color); track->flag|= TRACK_CUSTOMCOLOR; } @@ -3103,8 +3120,8 @@ static int stabilize_2d_add_exec(bContext *C, wmOperator *UNUSED(op)) int update= 0; track= tracksbase->first; - while(track) { - if(TRACK_VIEW_SELECTED(sc, track) && (track->flag&TRACK_USE_2D_STAB)==0) { + while (track) { + if (TRACK_VIEW_SELECTED(sc, track) && (track->flag&TRACK_USE_2D_STAB)==0) { track->flag|= TRACK_USE_2D_STAB; stab->tot_track++; @@ -3114,7 +3131,7 @@ static int stabilize_2d_add_exec(bContext *C, wmOperator *UNUSED(op)) track= track->next; } - if(update) { + if (update) { stab->ok= 0; DAG_id_tag_update(&clip->id, 0); @@ -3152,15 +3169,15 @@ static int stabilize_2d_remove_exec(bContext *C, wmOperator *UNUSED(op)) int a= 0, update= 0; track= tracksbase->first; - while(track) { - if(track->flag&TRACK_USE_2D_STAB) { - if(a==stab->act_track) { + while (track) { + if (track->flag&TRACK_USE_2D_STAB) { + if (a==stab->act_track) { track->flag&= ~TRACK_USE_2D_STAB; stab->act_track--; stab->tot_track--; - if(stab->act_track<0) + if (stab->act_track<0) stab->act_track= 0; update= 1; @@ -3174,7 +3191,7 @@ static int stabilize_2d_remove_exec(bContext *C, wmOperator *UNUSED(op)) track= track->next; } - if(update) { + if (update) { stab->ok= 0; DAG_id_tag_update(&clip->id, 0); @@ -3211,8 +3228,8 @@ static int stabilize_2d_select_exec(bContext *C, wmOperator *UNUSED(op)) int update= 0; track= tracksbase->first; - while(track) { - if(track->flag&TRACK_USE_2D_STAB) { + while (track) { + if (track->flag&TRACK_USE_2D_STAB) { BKE_tracking_track_flag(track, TRACK_AREA_ALL, SELECT, 0); update= 1; @@ -3221,7 +3238,7 @@ static int stabilize_2d_select_exec(bContext *C, wmOperator *UNUSED(op)) track= track->next; } - if(update) + if (update) WM_event_add_notifier(C, NC_MOVIECLIP|ND_SELECT, clip); return OPERATOR_FINISHED; @@ -3251,7 +3268,7 @@ static int stabilize_2d_set_rotation_exec(bContext *C, wmOperator *UNUSED(op)) MovieTracking *tracking= &clip->tracking; MovieTrackingTrack *act_track= BKE_tracking_active_track(tracking); - if(act_track) { + if (act_track) { MovieTrackingStabilization *stab= &tracking->stabilization; stab->rot_track= act_track; @@ -3288,53 +3305,53 @@ static int is_track_clean(MovieTrackingTrack *track, int frames, int del) int start_disabled= 0; int markersnr= track->markersnr; - if(del) + if (del) new_markers= MEM_callocN(markersnr*sizeof(MovieTrackingMarker), "track cleaned markers"); - for(a= 0; a= 0) { + if (prev >= 0) { end= a == markersnr-1; end|= (a < markersnr-1) && (markers[a].framenr != markers[a+1].framenr-1 || markers[a].flag&MARKER_DISABLED); } - if(end) { + if (end) { int segok= 1, len= 0; - if(a != prev && markers[a].framenr != markers[a-1].framenr+1) + if (a != prev && markers[a].framenr != markers[a-1].framenr+1) len= a-prev; - else if(markers[a].flag&MARKER_DISABLED) + else if (markers[a].flag&MARKER_DISABLED) len= a-prev; else len= a-prev+1; - if(frames) { - if(len < frames) { + if (frames) { + if (len < frames) { segok= 0; ok= 0; - if(!del) + if (!del) break; } } - if(del) { - if(segok) { + if (del) { + if (segok) { int t= len; - if(markers[a].flag&MARKER_DISABLED) + if (markers[a].flag&MARKER_DISABLED) t++; /* place disabled marker in front of current segment */ - if(start_disabled) { + if (start_disabled) { memcpy(new_markers+count, markers+prev, sizeof(MovieTrackingMarker)); new_markers[count].framenr--; new_markers[count].flag|= MARKER_DISABLED; @@ -3346,7 +3363,7 @@ static int is_track_clean(MovieTrackingTrack *track, int frames, int del) memcpy(new_markers+count, markers+prev, t*sizeof(MovieTrackingMarker)); count+= t; } - else if(markers[a].flag&MARKER_DISABLED) { + else if (markers[a].flag&MARKER_DISABLED) { /* current segment which would be deleted was finished by disabled marker, * so next segment should be started from disabled marker */ start_disabled= 1; @@ -3357,10 +3374,10 @@ static int is_track_clean(MovieTrackingTrack *track, int frames, int del) } } - if(del) { + if (del) { MEM_freeN(track->markers); - if(count) { + if (count) { track->markers= new_markers; } else { @@ -3385,25 +3402,25 @@ static int clean_tracks_exec(bContext *C, wmOperator *op) int action= RNA_enum_get(op->ptr, "action"); float error= RNA_float_get(op->ptr, "error"); - if(error && action==TRACKING_CLEAN_DELETE_SEGMENT) + if (error && action==TRACKING_CLEAN_DELETE_SEGMENT) action= TRACKING_CLEAN_DELETE_TRACK; track= tracksbase->first; - while(track) { + while (track) { next= track->next; - if((track->flag&TRACK_HIDDEN)==0 && (track->flag&TRACK_LOCKED)==0) { + if ((track->flag&TRACK_HIDDEN)==0 && (track->flag&TRACK_LOCKED)==0) { int ok= 1; ok= (is_track_clean(track, frames, action==TRACKING_CLEAN_DELETE_SEGMENT)) && (error == 0.0f || (track->flag&TRACK_HAS_BUNDLE)==0 || track->error < error); - if(!ok) { - if(action==TRACKING_CLEAN_SELECT) { + if (!ok) { + if (action==TRACKING_CLEAN_SELECT) { BKE_tracking_track_flag(track, TRACK_AREA_ALL, SELECT, 0); } - else if(action==TRACKING_CLEAN_DELETE_TRACK) { - if(track==act_track) + else if (action==TRACKING_CLEAN_DELETE_TRACK) { + if (track==act_track) clip->tracking.act_track= NULL; BKE_tracking_free_track(track); @@ -3412,8 +3429,8 @@ static int clean_tracks_exec(bContext *C, wmOperator *op) } /* happens when all tracking segments are not long enough */ - if(track && track->markersnr==0) { - if(track==act_track) + if (track && track->markersnr==0) { + if (track==act_track) clip->tracking.act_track= NULL; BKE_tracking_free_track(track); @@ -3435,13 +3452,13 @@ static int clean_tracks_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(even SpaceClip *sc= CTX_wm_space_clip(C); MovieClip *clip= ED_space_clip(sc); - if(!RNA_struct_property_is_set(op->ptr, "frames")) + if (!RNA_struct_property_is_set(op->ptr, "frames")) RNA_int_set(op->ptr, "frames", clip->tracking.settings.clean_frames); - if(!RNA_struct_property_is_set(op->ptr, "error")) + if (!RNA_struct_property_is_set(op->ptr, "error")) RNA_float_set(op->ptr, "error", clip->tracking.settings.clean_error); - if(!RNA_struct_property_is_set(op->ptr, "action")) + if (!RNA_struct_property_is_set(op->ptr, "action")) RNA_enum_set(op->ptr, "action", clip->tracking.settings.clean_action); return clean_tracks_exec(C, op); @@ -3516,7 +3533,7 @@ static int tracking_object_remove_exec(bContext *C, wmOperator *op) object= BKE_tracking_active_object(tracking); - if(object->flag&TRACKING_OBJECT_CAMERA) { + if (object->flag&TRACKING_OBJECT_CAMERA) { BKE_report(op->reports, RPT_WARNING, "Object used for camera tracking can't be deleted"); return OPERATOR_CANCELLED; } diff --git a/source/blender/editors/space_console/console_draw.c b/source/blender/editors/space_console/console_draw.c index a57b0e7e066..1bfdcee1aae 100644 --- a/source/blender/editors/space_console/console_draw.c +++ b/source/blender/editors/space_console/console_draw.c @@ -153,7 +153,7 @@ static int console_textview_line_color(struct TextViewContext *tvc, unsigned cha ConsoleLine *cl_iter= (ConsoleLine *)tvc->iter; /* annoying hack, to draw the prompt */ - if(tvc->iter_index == 0) { + if (tvc->iter_index == 0) { const SpaceConsole *sc= (SpaceConsole *)tvc->arg1; const ConsoleLine *cl= (ConsoleLine *)sc->history.last; const int prompt_len= strlen(sc->prompt); @@ -163,7 +163,7 @@ static int console_textview_line_color(struct TextViewContext *tvc, unsigned cha xy[1] += tvc->lheight/6; /* account for wrapping */ - if(cl->len < tvc->console_width) { + if (cl->len < tvc->console_width) { /* simple case, no wrapping */ pen[0]= tvc->cwidth * cursor_loc; pen[1]= -2; diff --git a/source/blender/editors/space_console/console_ops.c b/source/blender/editors/space_console/console_ops.c index ab473b2ec4d..1ca3ac1ec9a 100644 --- a/source/blender/editors/space_console/console_ops.c +++ b/source/blender/editors/space_console/console_ops.c @@ -94,7 +94,7 @@ static void console_scrollback_limit(SpaceConsole *sc) if (U.scrollback < 32) U.scrollback= 256; // XXX - save in user defaults - for(tot= BLI_countlist(&sc->scrollback); tot > U.scrollback; tot--) + for (tot= BLI_countlist(&sc->scrollback); tot > U.scrollback; tot--) console_scrollback_free(sc, sc->scrollback.first); } @@ -102,11 +102,11 @@ static ConsoleLine * console_history_find(SpaceConsole *sc, const char *str, Con { ConsoleLine *cl; - for(cl= sc->history.last; cl; cl= cl->prev) { + for (cl= sc->history.last; cl; cl= cl->prev) { if (cl==cl_ignore) continue; - if(strcmp(str, cl->line)==0) + if (strcmp(str, cl->line)==0) return cl; } @@ -136,7 +136,7 @@ static void console_lb_debug__internal(ListBase *lb) ConsoleLine *cl; printf("%d: ", BLI_countlist(lb)); - for(cl= lb->first; cl; cl= cl->next) + for (cl= lb->first; cl; cl= cl->next) printf("<%s> ", cl->line); printf("\n"); @@ -155,14 +155,15 @@ static ConsoleLine *console_lb_add__internal(ListBase *lb, ConsoleLine *from) { ConsoleLine *ci= MEM_callocN(sizeof(ConsoleLine), "ConsoleLine Add"); - if(from) { + if (from) { ci->line= BLI_strdup(from->line); ci->len= strlen(ci->line); ci->len_alloc= ci->len; ci->cursor= from->cursor; ci->type= from->type; - } else { + } + else { ci->line= MEM_callocN(64, "console-in-line"); ci->len_alloc= 64; ci->len= 0; @@ -191,7 +192,7 @@ static ConsoleLine *console_scrollback_add(const bContext *C, ConsoleLine *from) static ConsoleLine *console_lb_add_str__internal(ListBase *lb, char *str, int own) { ConsoleLine *ci= MEM_callocN(sizeof(ConsoleLine), "ConsoleLine Add"); - if(own) ci->line= str; + if (own) ci->line= str; else ci->line= BLI_strdup(str); ci->len = ci->len_alloc = strlen(str); @@ -214,7 +215,7 @@ 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(C, NULL); return ci; @@ -224,7 +225,7 @@ ConsoleLine *console_history_verify(const bContext *C) static void console_line_verify_length(ConsoleLine *ci, int len) { /* resize the buffer if needed */ - if(len >= ci->len_alloc) { + if (len >= ci->len_alloc) { int new_len= len * 2; /* new length */ char *new_line= MEM_callocN(new_len, "console line"); memcpy(new_line, ci->line, ci->len); @@ -239,12 +240,12 @@ static int console_line_insert(ConsoleLine *ci, char *str) { int len = strlen(str); - if(len>0 && str[len-1]=='\n') {/* stop new lines being pasted at the end of lines */ + if (len>0 && str[len-1]=='\n') {/* stop new lines being pasted at the end of lines */ str[len-1]= '\0'; len--; } - if(len==0) + if (len==0) return 0; console_line_verify_length(ci, len + ci->len); @@ -326,7 +327,7 @@ static int console_move_exec(bContext *C, wmOperator *op) break; } - if(done) { + if (done) { ScrArea *sa= CTX_wm_area(C); ARegion *ar= CTX_wm_region(C); @@ -363,7 +364,7 @@ static int console_insert_exec(bContext *C, wmOperator *op) int len; // XXX, alligned tab key hack - if(str[0]=='\t' && str[1]=='\0') { + if (str[0]=='\t' && str[1]=='\0') { len= TAB_LENGTH - (ci->cursor % TAB_LENGTH); MEM_freeN(str); str= MEM_mallocN(len + 1, "insert_exec"); @@ -375,7 +376,7 @@ static int console_insert_exec(bContext *C, wmOperator *op) MEM_freeN(str); - if(len==0) { + if (len==0) { return OPERATOR_CANCELLED; } else { @@ -393,9 +394,9 @@ static int console_insert_exec(bContext *C, wmOperator *op) static int console_insert_invoke(bContext *C, wmOperator *op, wmEvent *event) { // if(!RNA_struct_property_is_set(op->ptr, "text")) { /* always set from keymap XXX */ - if(!RNA_string_length(op->ptr, "text")) { + if (!RNA_string_length(op->ptr, "text")) { /* if alt/ctrl/super are pressed pass through */ - if(event->ctrl || event->oskey) { + if (event->ctrl || event->oskey) { return OPERATOR_PASS_THROUGH; } else { @@ -445,20 +446,20 @@ static int console_delete_exec(bContext *C, wmOperator *op) const short type= RNA_enum_get(op->ptr, "type"); int done = 0; - if(ci->len==0) { + if (ci->len==0) { return OPERATOR_CANCELLED; } switch(type) { case DEL_NEXT_CHAR: - if(ci->cursor < ci->len) { + if (ci->cursor < ci->len) { memmove(ci->line + ci->cursor, ci->line + ci->cursor+1, (ci->len - ci->cursor)+1); ci->len--; done= 1; } break; case DEL_PREV_CHAR: - if(ci->cursor > 0) { + if (ci->cursor > 0) { ci->cursor--; /* same as above */ memmove(ci->line + ci->cursor, ci->line + ci->cursor+1, (ci->len - ci->cursor)+1); ci->len--; @@ -467,7 +468,7 @@ static int console_delete_exec(bContext *C, wmOperator *op) break; } - if(!done) { + if (!done) { return OPERATOR_CANCELLED; } else { @@ -510,12 +511,12 @@ static int console_clear_exec(bContext *C, wmOperator *op) /*ConsoleLine *ci= */ console_history_verify(C); - if(scrollback) { /* last item in mistory */ + if (scrollback) { /* last item in mistory */ while(sc->scrollback.first) console_scrollback_free(sc, sc->scrollback.first); } - if(history) { + if (history) { while(sc->history.first) console_history_free(sc, sc->history.first); } @@ -556,14 +557,14 @@ static int console_history_cycle_exec(bContext *C, wmOperator *op) /* keep a copy of the line above so when history is cycled * this is the only function that needs to know about the double-up */ - if(ci->prev) { + if (ci->prev) { ConsoleLine *ci_prev= (ConsoleLine *)ci->prev; - if(strcmp(ci->line, ci_prev->line)==0) + if (strcmp(ci->line, ci_prev->line)==0) console_history_free(sc, ci_prev); } - if(reverse) { /* last item in mistory */ + if (reverse) { /* last item in mistory */ ci= sc->history.last; BLI_remlink(&sc->history, ci); BLI_addhead(&sc->history, ci); @@ -622,13 +623,13 @@ static int console_history_append_exec(bContext *C, wmOperator *op) short rem_dupes= RNA_boolean_get(op->ptr, "remove_duplicates"); int prev_len= ci->len; - if(rem_dupes) { + if (rem_dupes) { ConsoleLine *cl; while((cl= console_history_find(sc, ci->line, ci))) console_history_free(sc, cl); - if(strcmp(str, ci->line)==0) { + if (strcmp(str, ci->line)==0) { MEM_freeN(str); return OPERATOR_FINISHED; } @@ -686,7 +687,7 @@ static int console_scrollback_append_exec(bContext *C, wmOperator *op) /* 'ar' can be null depending on the operator that runs * rendering with invoke default for eg causes this */ - if(ar) { + if (ar) { console_textview_update_rect(sc, ar); } @@ -735,22 +736,22 @@ static int console_copy_exec(bContext *C, wmOperator *UNUSED(op)) #if 0 /* copy whole file */ - for(cl= sc->scrollback.first; cl; cl= cl->next) { + for (cl= sc->scrollback.first; cl; cl= cl->next) { BLI_dynstr_append(buf_dyn, cl->line); BLI_dynstr_append(buf_dyn, "\n"); } #endif - if(sc->sel_start == sc->sel_end) + if (sc->sel_start == sc->sel_end) return OPERATOR_CANCELLED; console_scrollback_prompt_begin(sc, &cl_dummy); - for(cl= sc->scrollback.first; cl; cl= cl->next) { + for (cl= sc->scrollback.first; cl; cl= cl->next) { offset += cl->len + 1; } - if(offset==0) { + if (offset==0) { console_scrollback_prompt_end(sc, &cl_dummy); return OPERATOR_CANCELLED; } @@ -759,12 +760,12 @@ static int console_copy_exec(bContext *C, wmOperator *UNUSED(op)) sel[0]= offset - sc->sel_end; sel[1]= offset - sc->sel_start; - for(cl= sc->scrollback.first; cl; cl= cl->next) { - if(sel[0] <= cl->len && sel[1] >= 0) { + for (cl= sc->scrollback.first; cl; cl= cl->next) { + if (sel[0] <= cl->len && sel[1] >= 0) { int sta= MAX2(sel[0], 0); int end= MIN2(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); @@ -809,19 +810,19 @@ static int console_paste_exec(bContext *C, wmOperator *UNUSED(op)) char *buf_str= WM_clipboard_text_get(0); char *buf_step, *buf_next; - if(buf_str==NULL) + if (buf_str==NULL) return OPERATOR_CANCELLED; buf_step= buf_str; while((buf_next=buf_step) && buf_next[0] != '\0') { buf_step= strchr(buf_next, '\n'); - if(buf_step) { + if (buf_step) { *buf_step= '\0'; buf_step++; } - if(buf_next != buf_str) { + if (buf_next != buf_str) { WM_operator_name_call(C, "CONSOLE_OT_execute", WM_OP_EXEC_DEFAULT, NULL); ci= console_history_verify(C); } @@ -864,7 +865,7 @@ static void console_cursor_set_to_pos(SpaceConsole *sc, ARegion *ar, SetConsoleC int pos; pos= console_char_pick(sc, ar, mval); - if(scu->sel_init == INT_MAX) { + if (scu->sel_init == INT_MAX) { scu->sel_init= pos; sc->sel_start = sc->sel_end = pos; return; @@ -900,7 +901,7 @@ static void console_modal_select_apply(bContext *C, wmOperator *op, wmEvent *eve console_cursor_set_to_pos(sc, ar, scu, mval, TRUE); /* only redraw if the selection changed */ - if(sel_prev[0] != sc->sel_start || sel_prev[1] != sc->sel_end) { + if (sel_prev[0] != sc->sel_start || sel_prev[1] != sc->sel_end) { ED_area_tag_redraw(CTX_wm_area(C)); } } @@ -911,7 +912,7 @@ static void console_cursor_set_exit(bContext *UNUSED(C), wmOperator *op) SetConsoleCursor *scu= op->customdata; #if 0 - if(txt_has_sel(text)) { + if (txt_has_sel(text)) { buffer = txt_sel_to_buf(text); WM_clipboard_text_set(buffer, 1); MEM_freeN(buffer); diff --git a/source/blender/editors/space_console/space_console.c b/source/blender/editors/space_console/space_console.c index 6000784b4b6..1867f93b1ef 100644 --- a/source/blender/editors/space_console/space_console.c +++ b/source/blender/editors/space_console/space_console.c @@ -101,10 +101,10 @@ 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); } @@ -141,7 +141,7 @@ static void console_main_area_init(wmWindowManager *wm, ARegion *ar) UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_CUSTOM, ar->winx, ar->winy); /* always keep the bottom part of the view aligned, less annoying */ - if(prev_y_min != ar->v2d.cur.ymin) { + if (prev_y_min != ar->v2d.cur.ymin) { const float cur_y_range= ar->v2d.cur.ymax - ar->v2d.cur.ymin; ar->v2d.cur.ymin = prev_y_min; ar->v2d.cur.ymax = prev_y_min + cur_y_range; @@ -163,7 +163,7 @@ static void console_main_area_init(wmWindowManager *wm, ARegion *ar) static int id_drop_poll(bContext *UNUSED(C), wmDrag *drag, wmEvent *UNUSED(event)) { // SpaceConsole *sc= CTX_wm_space_console(C); - if(drag->type==WM_DRAG_ID) + if (drag->type==WM_DRAG_ID) return 1; return 0; } @@ -185,7 +185,7 @@ static void id_drop_copy(wmDrag *drag, wmDropBox *drop) static int path_drop_poll(bContext *UNUSED(C), wmDrag *drag, wmEvent *UNUSED(event)) { // SpaceConsole *sc= CTX_wm_space_console(C); - if(drag->type==WM_DRAG_PATH) + if (drag->type==WM_DRAG_PATH) return 1; return 0; } @@ -216,7 +216,7 @@ static void console_main_area_draw(const bContext *C, ARegion *ar) View2D *v2d= &ar->v2d; View2DScrollers *scrollers; - if(sc->scrollback.first==NULL) + if (sc->scrollback.first==NULL) WM_operator_name_call((bContext *)C, "CONSOLE_OT_banner", WM_OP_EXEC_DEFAULT, NULL); /* clear and setup matrix */ @@ -357,7 +357,7 @@ static void console_main_area_listener(ARegion *ar, wmNotifier *wmn) /* context changes */ switch(wmn->category) { case NC_SPACE: - if(wmn->data == ND_SPACE_CONSOLE) { /* generic redraw request */ + if (wmn->data == ND_SPACE_CONSOLE) { /* generic redraw request */ ED_region_tag_redraw(ar); } break; diff --git a/source/blender/editors/space_file/file_draw.c b/source/blender/editors/space_file/file_draw.c index 1faa69d60e0..4d764bff311 100644 --- a/source/blender/editors/space_file/file_draw.c +++ b/source/blender/editors/space_file/file_draw.c @@ -157,7 +157,8 @@ void file_draw_buttons(const bContext *C, ARegion *ar) if (available_w <= loadbutton + separator + input_minw || params->title[0] == 0) { loadbutton = 0; - } else { + } + else { line1_w -= (loadbutton + separator); line2_w = line1_w; } @@ -166,7 +167,8 @@ void file_draw_buttons(const bContext *C, ARegion *ar) fnumbuttons = 2 * btn_fn_w; if (!loadbutton || line2_w <= fnumbuttons + separator + input_minw) { fnumbuttons = 0; - } else { + } + else { line2_w -= (fnumbuttons + separator); } @@ -183,7 +185,7 @@ void file_draw_buttons(const bContext *C, ARegion *ar) uiButSetCompleteFunc(but, autocomplete_directory, NULL); uiButSetFlag(but, UI_BUT_NO_UTF8); - if((params->flag & FILE_DIRSEL_ONLY) == 0) { + if ((params->flag & FILE_DIRSEL_ONLY) == 0) { but = uiDefBut(block, TEX, B_FS_FILENAME, "", min_x, line2_y, line2_w-chan_offs, btn_h, params->file, 0.0, (float)FILE_MAXFILE, 0, 0, @@ -193,7 +195,7 @@ void file_draw_buttons(const bContext *C, ARegion *ar) uiButClearFlag(but, UI_BUT_UNDO); /* operator button above does this automatic */ /* check if this overrides a file and if the operator option is used */ - if(overwrite_alert) { + if (overwrite_alert) { uiButSetFlag(but, UI_BUT_REDALERT); } } @@ -220,7 +222,7 @@ void file_draw_buttons(const bContext *C, ARegion *ar) } /* Execute / cancel buttons. */ - if(loadbutton) { + if (loadbutton) { uiDefButO(block, BUT, "FILE_OT_execute", WM_OP_EXEC_REGION_WIN, IFACE_(params->title), max_x - loadbutton, line1_y, loadbutton, btn_h, TIP_(params->title)); @@ -247,7 +249,7 @@ static int get_file_icon(struct direntry *file) if ( strcmp(file->relname, "..") == 0) { return ICON_FILE_PARENT; } - if(file->flags & BLENDERFILE) { + if (file->flags & BLENDERFILE) { return ICON_FILE_BLEND; } return ICON_FILE_FOLDER; @@ -343,7 +345,8 @@ static void file_draw_preview(uiBlock *block, struct direntry *file, int sx, int scaledx = ( (float)imb->x/(float)imb->y )*layout->prv_h; scale = scaledy/imb->y; } - } else { + } + else { scaledx = (float)imb->x; scaledy = (float)imb->y; scale = 1.0; @@ -396,7 +399,7 @@ static void renamebutton_cb(bContext *C, void *UNUSED(arg1), char *oldname) BLI_strncpy(filename, sfile->params->renameedit, sizeof(filename)); BLI_make_file_string(G.main->name, newname, sfile->params->dir, filename); - if( strcmp(orgname, newname) != 0 ) { + if ( strcmp(orgname, newname) != 0 ) { if (!BLI_exists(newname)) { BLI_rename(orgname, newname); /* to make sure we show what is on disk */ @@ -477,7 +480,8 @@ void file_draw_list(const bContext *C, ARegion *ar) /* adjust, so the next row is already drawn when scrolling */ if (layout->flag & FILE_LAYOUT_HOR) { numfiles_layout += layout->rows; - } else { + } + else { numfiles_layout += layout->columns; } @@ -515,7 +519,8 @@ void file_draw_list(const bContext *C, ARegion *ar) } file_draw_preview(block, file, sx, sy, imb, layout, !is_icon && (file->flags & IMAGEFILE)); - } else { + } + else { file_draw_icon(block, file->path, sx, sy-(UI_UNIT_Y / 6), get_file_icon(file), ICON_DEFAULT_WIDTH_SCALE, ICON_DEFAULT_HEIGHT_SCALE); sx += ICON_DEFAULT_WIDTH_SCALE + 4; } @@ -544,7 +549,8 @@ void file_draw_list(const bContext *C, ARegion *ar) file_draw_string(sx, sy, file->size, layout->column_widths[COLUMN_SIZE], layout->tile_h, align); sx += (int)layout->column_widths[COLUMN_SIZE] + 12; } - } else if (params->display == FILE_LONGDISPLAY) { + } + else if (params->display == FILE_LONGDISPLAY) { sx += (int)layout->column_widths[COLUMN_NAME] + 12; #ifndef WIN32 diff --git a/source/blender/editors/space_file/file_ops.c b/source/blender/editors/space_file/file_ops.c index 269a3a8fa0d..62b7aafb187 100644 --- a/source/blender/editors/space_file/file_ops.c +++ b/source/blender/editors/space_file/file_ops.c @@ -170,7 +170,7 @@ static FileSelect file_select_do(bContext* C, int selected_idx) { params->active_file = selected_idx; - if(S_ISDIR(file->type)) { + if (S_ISDIR(file->type)) { /* the path is too long and we are not going up! */ if (strcmp(file->relname, "..") && strlen(params->dir) + strlen(file->relname) >= FILE_MAX ) { // XXX error("Path too long, cannot enter this directory"); @@ -240,7 +240,7 @@ static int file_border_select_modal(bContext *C, wmOperator *op, wmEvent *event) result= WM_border_select_modal(C, op, event); - if(result==OPERATOR_RUNNING_MODAL) { + if (result==OPERATOR_RUNNING_MODAL) { rect.xmin = RNA_int_get(op->ptr, "xmin"); rect.ymin = RNA_int_get(op->ptr, "ymin"); @@ -257,7 +257,8 @@ static int file_border_select_modal(bContext *C, wmOperator *op, wmEvent *event) } params->sel_first = sel.first; params->sel_last = sel.last; - }else { + } + else { params->active_file = -1; params->sel_first = params->sel_last = -1; file_deselect_all(sfile, HILITED_FILE); @@ -280,7 +281,7 @@ static int file_border_select_exec(bContext *C, wmOperator *op) rect.xmax = RNA_int_get(op->ptr, "xmax"); rect.ymax = RNA_int_get(op->ptr, "ymax"); - if(!extend) { + if (!extend) { SpaceFile *sfile= CTX_wm_space_file(C); file_deselect_all(sfile, SELECTED_FILE); @@ -291,7 +292,8 @@ static int file_border_select_exec(bContext *C, wmOperator *op) ret = file_select(C, &rect, select ? FILE_SEL_ADD : FILE_SEL_REMOVE, 0); if (FILE_SELECT_DIR == ret) { WM_event_add_notifier(C, NC_SPACE|ND_SPACE_FILE_LIST, NULL); - } else if (FILE_SELECT_FILE == ret) { + } + else if (FILE_SELECT_FILE == ret) { WM_event_add_notifier(C, NC_SPACE|ND_SPACE_FILE_PARAMS, NULL); } return OPERATOR_FINISHED; @@ -324,13 +326,13 @@ static int file_select_invoke(bContext *C, wmOperator *op, wmEvent *event) int extend = RNA_boolean_get(op->ptr, "extend"); int fill = RNA_boolean_get(op->ptr, "fill"); - if(ar->regiontype != RGN_TYPE_WINDOW) + if (ar->regiontype != RGN_TYPE_WINDOW) return OPERATOR_CANCELLED; rect.xmin = rect.xmax = event->mval[0]; rect.ymin = rect.ymax = event->mval[1]; - if(!BLI_in_rcti(&ar->v2d.mask, rect.xmin, rect.ymin)) + if (!BLI_in_rcti(&ar->v2d.mask, rect.xmin, rect.ymin)) return OPERATOR_CANCELLED; /* single select, deselect all selected first */ @@ -417,7 +419,7 @@ static int bookmark_select_exec(bContext *C, wmOperator *op) { SpaceFile *sfile= CTX_wm_space_file(C); - if(RNA_struct_find_property(op->ptr, "dir")) { + if (RNA_struct_find_property(op->ptr, "dir")) { char entry[256]; FileSelectParams* params = sfile->params; @@ -483,7 +485,7 @@ static int bookmark_delete_exec(bContext *C, wmOperator *op) struct FSMenu* fsmenu = fsmenu_get(); int nentries = fsmenu_get_nentries(fsmenu, FS_CATEGORY_BOOKMARKS); - if(RNA_struct_find_property(op->ptr, "index")) { + if (RNA_struct_find_property(op->ptr, "index")) { int index = RNA_int_get(op->ptr, "index"); if ( (index >-1) && (index < nentries)) { char name[FILE_MAX]; @@ -518,7 +520,7 @@ int file_hilight_set(SpaceFile *sfile, ARegion *ar, int mx, int my) FileSelectParams* params; int numfiles, origfile; - if(sfile==NULL || sfile->files==NULL) return 0; + if (sfile==NULL || sfile->files==NULL) return 0; numfiles = filelist_numfiles(sfile->files); params = ED_fileselect_get_params(sfile); @@ -528,7 +530,7 @@ int file_hilight_set(SpaceFile *sfile, ARegion *ar, int mx, int my) mx -= ar->winrct.xmin; my -= ar->winrct.ymin; - if(BLI_in_rcti(&ar->v2d.mask, mx, my)) { + if (BLI_in_rcti(&ar->v2d.mask, mx, my)) { float fx, fy; int active_file; @@ -536,7 +538,7 @@ int file_hilight_set(SpaceFile *sfile, ARegion *ar, int mx, int my) active_file = ED_fileselect_layout_offset(sfile->layout, (int)(v2d->tot.xmin + fx), (int)(v2d->tot.ymax - fy)); - if((active_file >= 0) && (active_file < numfiles)) + if ((active_file >= 0) && (active_file < numfiles)) params->active_file=active_file; else params->active_file= -1; @@ -552,7 +554,7 @@ static int file_highlight_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *e ARegion *ar= CTX_wm_region(C); SpaceFile *sfile= CTX_wm_space_file(C); - if(!file_hilight_set(sfile, ar, event->x, event->y)) + if (!file_hilight_set(sfile, ar, event->x, event->y)) return OPERATOR_CANCELLED; ED_area_tag_redraw(CTX_wm_area(C)); @@ -610,19 +612,19 @@ void FILE_OT_cancel(struct wmOperatorType *ot) void file_sfile_to_operator(wmOperator *op, SpaceFile *sfile, char *filepath) { BLI_join_dirfile(filepath, FILE_MAX, sfile->params->dir, sfile->params->file); /* XXX, not real length */ - if(RNA_struct_find_property(op->ptr, "relative_path")) { - if(RNA_boolean_get(op->ptr, "relative_path")) { + if (RNA_struct_find_property(op->ptr, "relative_path")) { + if (RNA_boolean_get(op->ptr, "relative_path")) { BLI_path_rel(filepath, G.main->name); } } - if(RNA_struct_find_property(op->ptr, "filename")) { + if (RNA_struct_find_property(op->ptr, "filename")) { RNA_string_set(op->ptr, "filename", sfile->params->file); } - if(RNA_struct_find_property(op->ptr, "directory")) { + if (RNA_struct_find_property(op->ptr, "directory")) { RNA_string_set(op->ptr, "directory", sfile->params->dir); } - if(RNA_struct_find_property(op->ptr, "filepath")) { + if (RNA_struct_find_property(op->ptr, "filepath")) { RNA_string_set(op->ptr, "filepath", filepath); } @@ -635,7 +637,7 @@ void file_sfile_to_operator(wmOperator *op, SpaceFile *sfile, char *filepath) PropertyRNA *prop_dirs= RNA_struct_find_property(op->ptr, "dirs"); int i, numfiles = filelist_numfiles(sfile->files); - if(prop_files) { + if (prop_files) { RNA_property_collection_clear(op->ptr, prop_files); for (i=0; ifiles, i, CHECK_FILES)) { @@ -646,7 +648,7 @@ void file_sfile_to_operator(wmOperator *op, SpaceFile *sfile, char *filepath) } } - if(prop_dirs) { + if (prop_dirs) { RNA_property_collection_clear(op->ptr, prop_dirs); for (i=0; ifiles, i, CHECK_DIRS)) { @@ -666,16 +668,16 @@ void file_operator_to_sfile(SpaceFile *sfile, wmOperator *op) PropertyRNA *prop; /* If neither of the above are set, split the filepath back */ - if((prop= RNA_struct_find_property(op->ptr, "filepath"))) { + if ((prop= RNA_struct_find_property(op->ptr, "filepath"))) { char filepath[FILE_MAX]; RNA_property_string_get(op->ptr, prop, filepath); BLI_split_dirfile(filepath, sfile->params->dir, sfile->params->file, sizeof(sfile->params->dir), sizeof(sfile->params->file)); } else { - if((prop= RNA_struct_find_property(op->ptr, "filename"))) { + if ((prop= RNA_struct_find_property(op->ptr, "filename"))) { RNA_property_string_get(op->ptr, prop, sfile->params->file); } - if((prop= RNA_struct_find_property(op->ptr, "directory"))) { + if ((prop= RNA_struct_find_property(op->ptr, "directory"))) { RNA_property_string_get(op->ptr, prop, sfile->params->dir); } } @@ -691,13 +693,13 @@ void file_draw_check_cb(bContext *C, void *UNUSED(arg1), void *UNUSED(arg2)) { SpaceFile *sfile= CTX_wm_space_file(C); wmOperator *op= sfile->op; - if(op) { /* fail on reload */ - if(op->type->check) { + if (op) { /* fail on reload */ + if (op->type->check) { char filepath[FILE_MAX]; file_sfile_to_operator(op, sfile, filepath); /* redraw */ - if(op->type->check(C, op)) { + if (op->type->check(C, op)) { file_operator_to_sfile(sfile, op); /* redraw, else the changed settings wont get updated */ @@ -709,12 +711,12 @@ void file_draw_check_cb(bContext *C, void *UNUSED(arg1), void *UNUSED(arg2)) int file_draw_check_exists(SpaceFile *sfile) { - if(sfile->op) { /* fails on reload */ - if(RNA_struct_find_property(sfile->op->ptr, "check_existing")) { - if(RNA_boolean_get(sfile->op->ptr, "check_existing")) { + if (sfile->op) { /* fails on reload */ + if (RNA_struct_find_property(sfile->op->ptr, "check_existing")) { + if (RNA_boolean_get(sfile->op->ptr, "check_existing")) { char filepath[FILE_MAX]; BLI_join_dirfile(filepath, sizeof(filepath), sfile->params->dir, sfile->params->file); - if(BLI_is_file(filepath)) { + if (BLI_is_file(filepath)) { return TRUE; } } @@ -730,7 +732,7 @@ int file_exec(bContext *C, wmOperator *exec_op) SpaceFile *sfile= CTX_wm_space_file(C); char filepath[FILE_MAX]; - if(sfile->op) { + if (sfile->op) { wmOperator *op= sfile->op; /* when used as a macro, for doubleclick, @@ -739,7 +741,7 @@ int file_exec(bContext *C, wmOperator *exec_op) int i, active=0; for (i=0; ifiles); i++) { - if(filelist_is_selected(sfile->files, i, CHECK_ALL)) { + if (filelist_is_selected(sfile->files, i, CHECK_ALL)) { active=1; break; } @@ -787,7 +789,7 @@ int file_parent_exec(bContext *C, wmOperator *UNUSED(unused)) { SpaceFile *sfile= CTX_wm_space_file(C); - if(sfile->params) { + if (sfile->params) { if (BLI_has_parent(sfile->params->dir)) { BLI_parent_dir(sfile->params->dir); BLI_cleanup_dir(G.main->name, sfile->params->dir); @@ -842,7 +844,7 @@ int file_previous_exec(bContext *C, wmOperator *UNUSED(unused)) { SpaceFile *sfile= CTX_wm_space_file(C); - if(sfile->params) { + if (sfile->params) { if (!sfile->folders_next) sfile->folders_next = folderlist_new(); @@ -872,7 +874,7 @@ void FILE_OT_next(struct wmOperatorType *ot) int file_next_exec(bContext *C, wmOperator *UNUSED(unused)) { SpaceFile *sfile= CTX_wm_space_file(C); - if(sfile->params) { + if (sfile->params) { if (!sfile->folders_next) sfile->folders_next = folderlist_new(); @@ -902,7 +904,7 @@ static int file_smoothscroll_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent int i; /* escape if not our timer */ - if(sfile->smoothscroll_timer==NULL || sfile->smoothscroll_timer!=event->customdata) + if (sfile->smoothscroll_timer==NULL || sfile->smoothscroll_timer!=event->customdata) return OPERATOR_PASS_THROUGH; numfiles = filelist_numfiles(sfile->files); @@ -939,7 +941,8 @@ static int file_smoothscroll_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent if (sfile->layout->flag & FILE_LAYOUT_HOR) { sfile->scroll_offset = (edit_idx/sfile->layout->rows)*sfile->layout->rows; if (sfile->scroll_offset <= offset) sfile->scroll_offset -= sfile->layout->rows; - } else { + } + else { sfile->scroll_offset = (edit_idx/sfile->layout->columns)*sfile->layout->columns; if (sfile->scroll_offset <= offset) sfile->scroll_offset -= sfile->layout->columns; } @@ -962,14 +965,17 @@ static int file_smoothscroll_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent if (sfile->scroll_offset < offset) { if (sfile->layout->flag & FILE_LAYOUT_HOR) { WM_operator_name_call(C, "VIEW2D_OT_scroll_left", 0, NULL); - } else { + } + else { WM_operator_name_call(C, "VIEW2D_OT_scroll_up", 0, NULL); } - } else { + } + else { if (sfile->layout->flag & FILE_LAYOUT_HOR) { WM_operator_name_call(C, "VIEW2D_OT_scroll_right", 0, NULL); - } else { + } + else { WM_operator_name_call(C, "VIEW2D_OT_scroll_down", 0, NULL); } } @@ -1028,14 +1034,14 @@ int file_directory_new_exec(bContext *C, wmOperator *op) SpaceFile *sfile= CTX_wm_space_file(C); - if(!sfile->params) { + if (!sfile->params) { BKE_report(op->reports,RPT_WARNING, "No parent directory given"); return OPERATOR_CANCELLED; } path[0] = '\0'; - if(RNA_struct_find_property(op->ptr, "directory")) { + if (RNA_struct_find_property(op->ptr, "directory")) { RNA_string_get(op->ptr, "directory", path); if (path[0] != '\0') generate_name= 0; } @@ -1092,7 +1098,7 @@ static void file_expand_directory(bContext *C) { SpaceFile *sfile= CTX_wm_space_file(C); - if(sfile->params) { + if (sfile->params) { if ( sfile->params->dir[0] == '~' ) { char tmpstr[sizeof(sfile->params->dir)-1]; BLI_strncpy(tmpstr, sfile->params->dir+1, sizeof(tmpstr)); @@ -1126,7 +1132,7 @@ static int file_directory_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(ev { SpaceFile *sfile= CTX_wm_space_file(C); - if(sfile->params) { + if (sfile->params) { file_expand_directory(C); if (!BLI_exists(sfile->params->dir)) { @@ -1145,7 +1151,7 @@ int file_directory_exec(bContext *C, wmOperator *UNUSED(unused)) { SpaceFile *sfile= CTX_wm_space_file(C); - if(sfile->params) { + if (sfile->params) { file_expand_directory(C); if (!BLI_exists(sfile->params->dir)) { @@ -1153,7 +1159,7 @@ int file_directory_exec(bContext *C, wmOperator *UNUSED(unused)) } /* special case, user may have pasted a filepath into the directory */ - if(BLI_is_file(sfile->params->dir)) { + if (BLI_is_file(sfile->params->dir)) { char path[sizeof(sfile->params->dir)]; BLI_strncpy(path, sfile->params->dir, sizeof(path)); BLI_split_dirfile(path, sfile->params->dir, sfile->params->file, sizeof(sfile->params->dir), sizeof(sfile->params->file)); @@ -1222,7 +1228,7 @@ static int file_hidedot_exec(bContext *C, wmOperator *UNUSED(unused)) { SpaceFile *sfile= CTX_wm_space_file(C); - if(sfile->params) { + if (sfile->params) { sfile->params->flag ^= FILE_HIDE_DOT; ED_fileselect_clear(C, sfile); WM_event_add_notifier(C, NC_SPACE|ND_SPACE_FILE_LIST, NULL); @@ -1248,17 +1254,17 @@ struct ARegion *file_buttons_region(struct ScrArea *sa) { ARegion *ar, *arnew; - for(ar= sa->regionbase.first; ar; ar= ar->next) - if(ar->regiontype==RGN_TYPE_CHANNELS) + for (ar= sa->regionbase.first; ar; ar= ar->next) + if (ar->regiontype==RGN_TYPE_CHANNELS) return ar; /* add subdiv level; after header */ - for(ar= sa->regionbase.first; ar; ar= ar->next) - if(ar->regiontype==RGN_TYPE_HEADER) + for (ar= sa->regionbase.first; ar; ar= ar->next) + if (ar->regiontype==RGN_TYPE_HEADER) break; /* is error! */ - if(ar==NULL) return NULL; + if (ar==NULL) return NULL; arnew= MEM_callocN(sizeof(ARegion), "buttons for file panels"); @@ -1276,7 +1282,7 @@ static int file_bookmark_toggle_exec(bContext *C, wmOperator *UNUSED(unused)) ScrArea *sa= CTX_wm_area(C); ARegion *ar= file_buttons_region(sa); - if(ar) + if (ar) ED_region_toggle_hidden(C, ar); return OPERATOR_FINISHED; @@ -1301,7 +1307,7 @@ static int file_filenum_exec(bContext *C, wmOperator *op) ScrArea *sa= CTX_wm_area(C); int inc = RNA_int_get(op->ptr, "increment"); - if(sfile->params && (inc != 0)) { + if (sfile->params && (inc != 0)) { BLI_newname(sfile->params->file, inc); ED_area_tag_redraw(sa); file_draw_check_cb(C, NULL, NULL); @@ -1332,7 +1338,7 @@ static int file_rename_exec(bContext *C, wmOperator *UNUSED(op)) ScrArea *sa= CTX_wm_area(C); SpaceFile *sfile= (SpaceFile*)CTX_wm_space_data(C); - if(sfile->params) { + if (sfile->params) { int idx = sfile->params->active_file; int numfiles = filelist_numfiles(sfile->files); if ( (0<=idx) && (idxparams) { if (sfile->params->active_file < 0) { poll= 0; - } else { + } + else { char dir[FILE_MAX], group[FILE_MAX]; if (filelist_islibrary(sfile->files, dir, group)) poll= 0; } @@ -1388,7 +1395,8 @@ static int file_delete_poll(bContext *C) if (sfile && sfile->params) { if (sfile->params->active_file < 0) { poll= 0; - } else { + } + else { char dir[FILE_MAX], group[FILE_MAX]; if (filelist_islibrary(sfile->files, dir, group)) poll= 0; file = filelist_file(sfile->files, sfile->params->active_file); diff --git a/source/blender/editors/space_file/file_panels.c b/source/blender/editors/space_file/file_panels.c index ca0e7646a85..596721bff07 100644 --- a/source/blender/editors/space_file/file_panels.c +++ b/source/blender/editors/space_file/file_panels.c @@ -80,7 +80,7 @@ static void file_panel_category(const bContext *C, Panel *pa, FSMenuCategory cat *nr= -1; /* hide if no entries */ - if(nentries == 0) + if (nentries == 0) return; /* layout */ @@ -100,8 +100,8 @@ static void file_panel_category(const bContext *C, Panel *pa, FSMenuCategory cat entry = fsmenu_get_entry(fsmenu, category, i); /* set this list item as active if we have a match */ - if(sfile->params) { - if(BLI_path_cmp(sfile->params->dir, entry) == 0) { + if (sfile->params) { + if (BLI_path_cmp(sfile->params->dir, entry) == 0) { *nr= i; } } @@ -112,7 +112,7 @@ static void file_panel_category(const bContext *C, Panel *pa, FSMenuCategory cat BLI_getlastdir(temp, dir, FILE_MAX); BLI_del_slash(dir); - if(dir[0] == 0) + if (dir[0] == 0) BLI_strncpy(dir, entry, FILE_MAX); /* create list item */ @@ -121,7 +121,7 @@ static void file_panel_category(const bContext *C, Panel *pa, FSMenuCategory cat uiButSetFlag(but, UI_ICON_LEFT|UI_TEXT_LEFT); /* create delete button */ - if(allow_delete && fsmenu_can_save(fsmenu, category, i)) { + if (allow_delete && fsmenu_can_save(fsmenu, category, i)) { uiBlockSetEmboss(block, UI_EMBOSSN); uiItemIntO(layout, "", ICON_X, "FILE_OT_delete_bookmark", "index", i); uiBlockSetEmboss(block, UI_EMBOSS); @@ -133,7 +133,7 @@ static void file_panel_system(const bContext *C, Panel *pa) { SpaceFile *sfile= CTX_wm_space_file(C); - if(sfile) + if (sfile) file_panel_category(C, pa, FS_CATEGORY_SYSTEM, &sfile->systemnr, ICON_DISK_DRIVE, 0, 0); } @@ -142,7 +142,7 @@ static void file_panel_bookmarks(const bContext *C, Panel *pa) SpaceFile *sfile= CTX_wm_space_file(C); uiLayout *row; - if(sfile) { + if (sfile) { row= uiLayoutRow(pa->layout, 0); uiItemO(row, IFACE_("Add"), ICON_ZOOMIN, "file.bookmark_add"); uiItemL(row, NULL, ICON_NONE); @@ -155,7 +155,7 @@ static void file_panel_recent(const bContext *C, Panel *pa) { SpaceFile *sfile= CTX_wm_space_file(C); - if(sfile) { + if (sfile) { if ( !(U.uiflag & USER_HIDE_RECENT) ) { file_panel_category(C, pa, FS_CATEGORY_RECENT, &sfile->recentnr, ICON_FILE_FOLDER, 0, 1); } diff --git a/source/blender/editors/space_file/filelist.c b/source/blender/editors/space_file/filelist.c index 5bc62620dfa..202a82be4b4 100644 --- a/source/blender/editors/space_file/filelist.c +++ b/source/blender/editors/space_file/filelist.c @@ -158,24 +158,26 @@ static int compare_name(const void *a1, const void *a2) /* type is equal to stat.st_mode */ - if (S_ISDIR(entry1->type)){ + if (S_ISDIR(entry1->type)) { if (S_ISDIR(entry2->type)==0) return (-1); - } else{ + } + else { if (S_ISDIR(entry2->type)) return (1); } - if (S_ISREG(entry1->type)){ + if (S_ISREG(entry1->type)) { if (S_ISREG(entry2->type)==0) return (-1); - } else{ + } + else { if (S_ISREG(entry2->type)) return (1); } if ((entry1->type & S_IFMT) < (entry2->type & S_IFMT)) return (-1); if ((entry1->type & S_IFMT) > (entry2->type & S_IFMT)) return (1); /* make sure "." and ".." are always first */ - if( strcmp(entry1->relname, ".")==0 ) return (-1); - if( strcmp(entry2->relname, ".")==0 ) return (1); - if( strcmp(entry1->relname, "..")==0 ) return (-1); - if( strcmp(entry2->relname, "..")==0 ) return (1); + if ( strcmp(entry1->relname, ".")==0 ) return (-1); + if ( strcmp(entry2->relname, ".")==0 ) return (1); + if ( strcmp(entry1->relname, "..")==0 ) return (-1); + if ( strcmp(entry2->relname, "..")==0 ) return (1); return (BLI_natstrcmp(entry1->relname,entry2->relname)); } @@ -186,24 +188,26 @@ static int compare_date(const void *a1, const void *a2) /* type is equal to stat.st_mode */ - if (S_ISDIR(entry1->type)){ + if (S_ISDIR(entry1->type)) { if (S_ISDIR(entry2->type)==0) return (-1); - } else{ + } + else { if (S_ISDIR(entry2->type)) return (1); } - if (S_ISREG(entry1->type)){ + if (S_ISREG(entry1->type)) { if (S_ISREG(entry2->type)==0) return (-1); - } else{ + } + else { if (S_ISREG(entry2->type)) return (1); } if ((entry1->type & S_IFMT) < (entry2->type & S_IFMT)) return (-1); if ((entry1->type & S_IFMT) > (entry2->type & S_IFMT)) return (1); /* make sure "." and ".." are always first */ - if( strcmp(entry1->relname, ".")==0 ) return (-1); - if( strcmp(entry2->relname, ".")==0 ) return (1); - if( strcmp(entry1->relname, "..")==0 ) return (-1); - if( strcmp(entry2->relname, "..")==0 ) return (1); + if ( strcmp(entry1->relname, ".")==0 ) return (-1); + if ( strcmp(entry2->relname, ".")==0 ) return (1); + if ( strcmp(entry1->relname, "..")==0 ) return (-1); + if ( strcmp(entry2->relname, "..")==0 ) return (1); if ( entry1->s.st_mtime < entry2->s.st_mtime) return 1; if ( entry1->s.st_mtime > entry2->s.st_mtime) return -1; @@ -217,24 +221,26 @@ static int compare_size(const void *a1, const void *a2) /* type is equal to stat.st_mode */ - if (S_ISDIR(entry1->type)){ + if (S_ISDIR(entry1->type)) { if (S_ISDIR(entry2->type)==0) return (-1); - } else{ + } + else { if (S_ISDIR(entry2->type)) return (1); } - if (S_ISREG(entry1->type)){ + if (S_ISREG(entry1->type)) { if (S_ISREG(entry2->type)==0) return (-1); - } else{ + } + else { if (S_ISREG(entry2->type)) return (1); } if ((entry1->type & S_IFMT) < (entry2->type & S_IFMT)) return (-1); if ((entry1->type & S_IFMT) > (entry2->type & S_IFMT)) return (1); /* make sure "." and ".." are always first */ - if( strcmp(entry1->relname, ".")==0 ) return (-1); - if( strcmp(entry2->relname, ".")==0 ) return (1); - if( strcmp(entry1->relname, "..")==0 ) return (-1); - if( strcmp(entry2->relname, "..")==0 ) return (1); + if ( strcmp(entry1->relname, ".")==0 ) return (-1); + if ( strcmp(entry2->relname, ".")==0 ) return (1); + if ( strcmp(entry1->relname, "..")==0 ) return (-1); + if ( strcmp(entry2->relname, "..")==0 ) return (1); if ( entry1->s.st_size < entry2->s.st_size) return 1; if ( entry1->s.st_size > entry2->s.st_size) return -1; @@ -256,24 +262,26 @@ static int compare_extension(const void *a1, const void *a2) /* type is equal to stat.st_mode */ - if (S_ISDIR(entry1->type)){ + if (S_ISDIR(entry1->type)) { if (S_ISDIR(entry2->type)==0) return (-1); - } else{ + } + else { if (S_ISDIR(entry2->type)) return (1); } - if (S_ISREG(entry1->type)){ + if (S_ISREG(entry1->type)) { if (S_ISREG(entry2->type)==0) return (-1); - } else{ + } + else { if (S_ISREG(entry2->type)) return (1); } if ((entry1->type & S_IFMT) < (entry2->type & S_IFMT)) return (-1); if ((entry1->type & S_IFMT) > (entry2->type & S_IFMT)) return (1); /* make sure "." and ".." are always first */ - if( strcmp(entry1->relname, ".")==0 ) return (-1); - if( strcmp(entry2->relname, ".")==0 ) return (1); - if( strcmp(entry1->relname, "..")==0 ) return (-1); - if( strcmp(entry2->relname, "..")==0 ) return (1); + if ( strcmp(entry1->relname, ".")==0 ) return (-1); + if ( strcmp(entry2->relname, ".")==0 ) return (1); + if ( strcmp(entry1->relname, "..")==0 ) return (-1); + if ( strcmp(entry2->relname, "..")==0 ) return (1); return (BLI_strcasecmp(sufix1, sufix2)); } @@ -283,17 +291,20 @@ static int is_hidden_file(const char* filename, short hide_dot) int is_hidden=0; if (hide_dot) { - if(filename[0]=='.' && filename[1]!='.' && filename[1]!=0) { + if (filename[0]=='.' && filename[1]!='.' && filename[1]!=0) { is_hidden=1; /* ignore .file */ - } else if (((filename[0] == '.') && (filename[1] == 0) )) { + } + else if (((filename[0] == '.') && (filename[1] == 0) )) { is_hidden=1; /* ignore . */ - } else { + } + else { int len=strlen(filename); - if( (len>0) && (filename[len-1]=='~') ) { + if ( (len>0) && (filename[len-1]=='~') ) { is_hidden=1; /* ignore file~ */ } } - } else { + } + else { if (((filename[0] == '.') && (filename[1] == 0) )) { is_hidden=1; /* ignore . */ } @@ -307,12 +318,14 @@ static int is_filtered_file(struct direntry* file, const char* UNUSED(dir), unsi if (filter) { if (file->flags & filter) { is_filtered=1; - } else if (file->type & S_IFDIR) { + } + else if (file->type & S_IFDIR) { if (filter & FOLDERFILE) { is_filtered = 1; } } - } else { + } + else { is_filtered = 1; } return is_filtered && !is_hidden_file(file->relname, hide_dot); @@ -324,7 +337,8 @@ static int is_filtered_lib(struct direntry* file, const char* dir, unsigned int char tdir[FILE_MAX], tgroup[GROUP_MAX]; if (BLO_is_a_library(dir, tdir, tgroup)) { is_filtered = !is_hidden_file(file->relname, hide_dot); - } else { + } + else { is_filtered = is_filtered_file(file, dir, filter, hide_dot); } return is_filtered; @@ -415,13 +429,13 @@ void folderlist_popdir(struct ListBase* folderlist, char *dir) struct FolderList *folder; folder = folderlist->last; - if(folder){ + if (folder) { // remove the current directory MEM_freeN(folder->foldername); BLI_freelinkN(folderlist, folder); folder = folderlist->last; - if(folder){ + if (folder) { prev_dir = folder->foldername; BLI_strncpy(dir, prev_dir, FILE_MAXDIR); } @@ -435,8 +449,8 @@ void folderlist_pushdir(ListBase* folderlist, const char *dir) previous_folder = folderlist->last; // check if already exists - if(previous_folder && previous_folder->foldername){ - if(BLI_path_cmp(previous_folder->foldername, dir)==0){ + if (previous_folder && previous_folder->foldername) { + if (BLI_path_cmp(previous_folder->foldername, dir)==0) { return; } } @@ -472,9 +486,9 @@ int folderlist_clear_next(struct SpaceFile *sfile) /* not listbase itself */ void folderlist_free(ListBase* folderlist) { - if (folderlist){ + if (folderlist) { FolderList *folder; - for(folder= folderlist->first; folder; folder= folder->next) + for (folder= folderlist->first; folder; folder= folder->next) MEM_freeN(folder->foldername); BLI_freelistN(folderlist); } @@ -489,7 +503,7 @@ ListBase *folderlist_duplicate(ListBase* folderlist) BLI_duplicatelist(folderlistn, folderlist); - for(folder= folderlistn->first; folder; folder= folder->next) { + for (folder= folderlistn->first; folder; folder= folder->next) { folder->foldername= MEM_dupallocN(folder->foldername); } return folderlistn; @@ -564,7 +578,7 @@ void filelist_free(struct FileList* filelist) void filelist_freelib(struct FileList* filelist) { - if(filelist->libfiledata) + if (filelist->libfiledata) BLO_blendhandle_close(filelist->libfiledata); filelist->libfiledata= NULL; } @@ -626,28 +640,37 @@ struct ImBuf * filelist_geticon(struct FileList* filelist, int index) if (file->type & S_IFDIR) { if ( strcmp(filelist->filelist[fidx].relname, "..") == 0) { ibuf = gSpecialFileImages[SPECIAL_IMG_PARENT]; - } else if ( strcmp(filelist->filelist[fidx].relname, ".") == 0) { + } + else if ( strcmp(filelist->filelist[fidx].relname, ".") == 0) { ibuf = gSpecialFileImages[SPECIAL_IMG_REFRESH]; - } else { + } + else { ibuf = gSpecialFileImages[SPECIAL_IMG_FOLDER]; } - } else { + } + else { ibuf = gSpecialFileImages[SPECIAL_IMG_UNKNOWNFILE]; } if (file->flags & BLENDERFILE) { ibuf = gSpecialFileImages[SPECIAL_IMG_BLENDFILE]; - } else if ( (file->flags & MOVIEFILE) || (file->flags & MOVIEFILE_ICON) ) { + } + else if ( (file->flags & MOVIEFILE) || (file->flags & MOVIEFILE_ICON) ) { ibuf = gSpecialFileImages[SPECIAL_IMG_MOVIEFILE]; - } else if (file->flags & SOUNDFILE) { + } + else if (file->flags & SOUNDFILE) { ibuf = gSpecialFileImages[SPECIAL_IMG_SOUNDFILE]; - } else if (file->flags & PYSCRIPTFILE) { + } + else if (file->flags & PYSCRIPTFILE) { ibuf = gSpecialFileImages[SPECIAL_IMG_PYTHONFILE]; - } else if (file->flags & FTFONTFILE) { + } + else if (file->flags & FTFONTFILE) { ibuf = gSpecialFileImages[SPECIAL_IMG_FONTFILE]; - } else if (file->flags & TEXTFILE) { + } + else if (file->flags & TEXTFILE) { ibuf = gSpecialFileImages[SPECIAL_IMG_TEXTFILE]; - } else if (file->flags & IMAGEFILE) { + } + else if (file->flags & IMAGEFILE) { ibuf = gSpecialFileImages[SPECIAL_IMG_LOADING]; } @@ -715,17 +738,17 @@ static int file_is_blend_backup(const char *str) a= strlen(str); b= 7; - if(a==0 || b>=a); + if (a==0 || b>=a); else { char *loc; - if(a > b+1) + if (a > b+1) b++; /* allow .blend1 .blend2 .blend32 */ loc= BLI_strcasestr(str+a-b, ".blend"); - if(loc) + if (loc) retval= 1; } @@ -735,32 +758,41 @@ static int file_is_blend_backup(const char *str) static int file_extension_type(const char *relname) { - if(BLO_has_bfile_extension(relname)) { + if (BLO_has_bfile_extension(relname)) { return BLENDERFILE; - } else if(file_is_blend_backup(relname)) { + } + else if (file_is_blend_backup(relname)) { return BLENDERFILE_BACKUP; - } else if(BLI_testextensie(relname, ".py")) { + } + else if (BLI_testextensie(relname, ".py")) { return PYSCRIPTFILE; - } else if(BLI_testextensie(relname, ".txt") + } + else if (BLI_testextensie(relname, ".txt") || BLI_testextensie(relname, ".glsl") || BLI_testextensie(relname, ".data")) { return TEXTFILE; - } else if( BLI_testextensie(relname, ".ttf") + } + else if ( BLI_testextensie(relname, ".ttf") || BLI_testextensie(relname, ".ttc") || BLI_testextensie(relname, ".pfb") || BLI_testextensie(relname, ".otf") || BLI_testextensie(relname, ".otc")) { return FTFONTFILE; - } else if(BLI_testextensie(relname, ".btx")) { + } + else if (BLI_testextensie(relname, ".btx")) { return BTXFILE; - } else if(BLI_testextensie(relname, ".dae")) { + } + else if (BLI_testextensie(relname, ".dae")) { return COLLADAFILE; - } else if(BLI_testextensie_array(relname, imb_ext_image) + } + else if (BLI_testextensie_array(relname, imb_ext_image) || (G.have_quicktime && BLI_testextensie_array(relname, imb_ext_image_qt))) { return IMAGEFILE; - } else if(BLI_testextensie_array(relname, imb_ext_movie)) { + } + else if (BLI_testextensie_array(relname, imb_ext_movie)) { return MOVIEFILE; - } else if(BLI_testextensie_array(relname, imb_ext_audio)) { + } + else if (BLI_testextensie_array(relname, imb_ext_audio)) { return SOUNDFILE; } return 0; @@ -797,7 +829,7 @@ static void filelist_setfiletypes(struct FileList* filelist) file= filelist->filelist; - for(num=0; numnumfiles; num++, file++) { + for (num=0; numnumfiles; num++, file++) { file->type= file->s.st_mode; /* restore the mess below */ /* Don't check extensions for directories */ @@ -806,7 +838,7 @@ static void filelist_setfiletypes(struct FileList* filelist) } file->flags = file_extension_type(file->relname); - if(filelist->filter_glob + if (filelist->filter_glob && BLI_testextensie_glob(file->relname, filelist->filter_glob)) { file->flags= OPERATORFILE; } @@ -827,7 +859,7 @@ static void filelist_read_dir(struct FileList* filelist) BLI_cleanup_dir(G.main->name, filelist->dir); filelist->numfiles = BLI_dir_contents(filelist->dir, &(filelist->filelist)); - if(!chdir(wdir)) {} /* fix warning about not checking return value */ + if (!chdir(wdir)) {} /* fix warning about not checking return value */ filelist_setfiletypes(filelist); filelist_filter(filelist); } @@ -843,15 +875,15 @@ static void filelist_read_library(struct FileList* filelist) if (!filelist) return; BLI_cleanup_dir(G.main->name, filelist->dir); filelist_from_library(filelist); - if(!filelist->libfiledata) { + if (!filelist->libfiledata) { int num; struct direntry *file; BLI_make_exist(filelist->dir); filelist_read_dir(filelist); file = filelist->filelist; - for(num=0; numnumfiles; num++, file++) { - if(BLO_has_bfile_extension(file->relname)) { + for (num=0; numnumfiles; num++, file++) { + if (BLO_has_bfile_extension(file->relname)) { char name[FILE_MAX]; BLI_join_dirfile(name, sizeof(name), filelist->dir, file->relname); @@ -994,7 +1026,7 @@ void filelist_from_library(struct FileList* filelist) ok= filelist_islibrary(filelist, dir, group); if (!ok) { /* free */ - if(filelist->libfiledata) BLO_blendhandle_close(filelist->libfiledata); + if (filelist->libfiledata) BLO_blendhandle_close(filelist->libfiledata); filelist->libfiledata= NULL; return; } @@ -1005,7 +1037,7 @@ void filelist_from_library(struct FileList* filelist) /* for the time being only read filedata when libfiledata==0 */ if (filelist->libfiledata == NULL) { filelist->libfiledata= BLO_blendhandle_from_file(dir, NULL); - if(filelist->libfiledata == NULL) return; + if (filelist->libfiledata == NULL) return; } idcode= groupname_to_code(group); @@ -1019,7 +1051,8 @@ void filelist_from_library(struct FileList* filelist) BLO_blendhandle_close(filelist->libfiledata); filelist->libfiledata= BLO_blendhandle_from_file(dir, NULL); - } else { + } + else { previews= NULL; nprevs= 0; names= BLO_blendhandle_get_linkable_groups(filelist->libfiledata); @@ -1039,15 +1072,16 @@ void filelist_from_library(struct FileList* filelist) filelist->filelist[i + 1].relname= BLI_strdup(blockname); if (idcode) { filelist->filelist[i + 1].type |= S_IFREG; - } else { + } + else { filelist->filelist[i + 1].type |= S_IFDIR; } } - if(previews && (nnames != nprevs)) { + if (previews && (nnames != nprevs)) { printf("filelist_from_library: error, found %d items, %d previews\n", nnames, nprevs); } - else if(previews) { + else if (previews) { for (i=0, l= previews; inext) { PreviewImage *img= l->link; @@ -1092,20 +1126,20 @@ void filelist_from_main(struct FileList *filelist) // filelist->type = FILE_MAIN; // XXXXX TODO: add modes to filebrowser - if(filelist->dir[0]=='/') filelist->dir[0]= 0; + if (filelist->dir[0]=='/') filelist->dir[0]= 0; - if(filelist->dir[0]) { + if (filelist->dir[0]) { idcode= groupname_to_code(filelist->dir); - if(idcode==0) filelist->dir[0]= 0; + if (idcode==0) filelist->dir[0]= 0; } - if( filelist->dir[0]==0) { + if ( filelist->dir[0]==0) { /* make directories */ filelist->numfiles= 24; filelist->filelist= (struct direntry *)malloc(filelist->numfiles * sizeof(struct direntry)); - for(a=0; anumfiles; a++) { + for (a=0; anumfiles; a++) { memset( &(filelist->filelist[a]), 0 , sizeof(struct direntry)); filelist->filelist[a].type |= S_IFDIR; } @@ -1141,7 +1175,7 @@ void filelist_from_main(struct FileList *filelist) idcode= groupname_to_code(filelist->dir); lb= which_libbase(G.main, idcode ); - if(lb == NULL) return; + if (lb == NULL) return; id= lb->first; filelist->numfiles= 0; @@ -1172,10 +1206,10 @@ void filelist_from_main(struct FileList *filelist) while(id) { ok = 1; - if(ok) { + if (ok) { if (!filelist->hide_dot || id->name[2] != '.') { memset( files, 0 , sizeof(struct direntry)); - if(id->lib==NULL) + if (id->lib==NULL) files->relname= BLI_strdup(id->name+2); else { files->relname= MEM_mallocN(FILE_MAX+32, "filename for lib"); @@ -1183,28 +1217,28 @@ void filelist_from_main(struct FileList *filelist) } files->type |= S_IFREG; #if 0 // XXXXX TODO show the selection status of the objects - if(!filelist->has_func) { /* F4 DATA BROWSE */ - if(idcode==ID_OB) { - if( ((Object *)id)->flag & SELECT) files->selflag |= SELECTED_FILE; + if (!filelist->has_func) { /* F4 DATA BROWSE */ + if (idcode==ID_OB) { + if ( ((Object *)id)->flag & SELECT) files->selflag |= SELECTED_FILE; } - else if(idcode==ID_SCE) { - if( ((Scene *)id)->r.scemode & R_BG_RENDER) files->selflag |= SELECTED_FILE; + else if (idcode==ID_SCE) { + if ( ((Scene *)id)->r.scemode & R_BG_RENDER) files->selflag |= SELECTED_FILE; } } #endif files->nr= totbl+1; files->poin= id; fake= id->flag & LIB_FAKEUSER; - if(idcode == ID_MA || idcode == ID_TE || idcode == ID_LA || idcode == ID_WO || idcode == ID_IM) { + if (idcode == ID_MA || idcode == ID_TE || idcode == ID_LA || idcode == ID_WO || idcode == ID_IM) { files->flags |= IMAGEFILE; } - if(id->lib && fake) BLI_snprintf(files->extra, sizeof(files->extra), "LF %d", id->us); - else if(id->lib) BLI_snprintf(files->extra, sizeof(files->extra), "L %d", id->us); - else if(fake) BLI_snprintf(files->extra, sizeof(files->extra), "F %d", id->us); + if (id->lib && fake) BLI_snprintf(files->extra, sizeof(files->extra), "LF %d", id->us); + else if (id->lib) BLI_snprintf(files->extra, sizeof(files->extra), "L %d", id->us); + else if (fake) BLI_snprintf(files->extra, sizeof(files->extra), "F %d", id->us); else BLI_snprintf(files->extra, sizeof(files->extra), " %d", id->us); - if(id->lib) { - if(totlib==0) firstlib= files; + if (id->lib) { + if (totlib==0) firstlib= files; totlib++; } @@ -1217,7 +1251,7 @@ void filelist_from_main(struct FileList *filelist) } /* only qsort of library blocks */ - if(totlib>1) { + if (totlib>1) { qsort(firstlib, totlib, sizeof(struct direntry), compare_name); } } @@ -1230,7 +1264,7 @@ static void thumbnail_joblist_free(ThumbnailJob *tj) FileImage* limg = tj->loadimages.first; /* free the images not yet copied to the filelist -> these will get freed with the filelist */ - for( ; limg; limg= limg->next) { + for ( ; limg; limg= limg->next) { if ((limg->img) && (!limg->done)) { IMB_freeImBuf(limg->img); } @@ -1249,9 +1283,11 @@ static void thumbnails_startjob(void *tjv, short *stop, short *do_update, float while ( (*stop==0) && (limg) ) { if ( limg->flags & IMAGEFILE ) { limg->img = IMB_thumb_manage(limg->path, THB_NORMAL, THB_SOURCE_IMAGE); - } else if ( limg->flags & BLENDERFILE ) { + } + else if ( limg->flags & BLENDERFILE ) { limg->img = IMB_thumb_manage(limg->path, THB_NORMAL, THB_SOURCE_BLEND); - } else if ( limg->flags & MOVIEFILE ) { + } + else if ( limg->flags & MOVIEFILE ) { limg->img = IMB_thumb_manage(limg->path, THB_NORMAL, THB_SOURCE_MOVIE); if (!limg->img) { /* remember that file can't be loaded via IMB_open_anim */ diff --git a/source/blender/editors/space_file/filesel.c b/source/blender/editors/space_file/filesel.c index fa2874f4842..3ed3c0690a2 100644 --- a/source/blender/editors/space_file/filesel.c +++ b/source/blender/editors/space_file/filesel.c @@ -125,7 +125,7 @@ short ED_fileselect_set_params(SpaceFile *sfile) BLI_strncpy(params->title, op->type->name, sizeof(params->title)); - if(RNA_struct_find_property(op->ptr, "filemode")) + if (RNA_struct_find_property(op->ptr, "filemode")) params->type = RNA_int_get(op->ptr, "filemode"); else params->type = FILE_SPECIAL; @@ -152,12 +152,12 @@ short ED_fileselect_set_params(SpaceFile *sfile) } } - if(params->dir[0]) { + if (params->dir[0]) { BLI_cleanup_dir(G.main->name, params->dir); BLI_path_abs(params->dir, G.main->name); } - if(is_directory==TRUE && is_filename==FALSE && is_filepath==FALSE && is_files==FALSE) { + if (is_directory==TRUE && is_filename==FALSE && is_filepath==FALSE && is_files==FALSE) { params->flag |= FILE_DIRSEL_ONLY; } else { @@ -165,27 +165,27 @@ short ED_fileselect_set_params(SpaceFile *sfile) } params->filter = 0; - if(RNA_struct_find_property(op->ptr, "filter_blender")) + if (RNA_struct_find_property(op->ptr, "filter_blender")) params->filter |= RNA_boolean_get(op->ptr, "filter_blender") ? BLENDERFILE : 0; - if(RNA_struct_find_property(op->ptr, "filter_image")) + if (RNA_struct_find_property(op->ptr, "filter_image")) params->filter |= RNA_boolean_get(op->ptr, "filter_image") ? IMAGEFILE : 0; - if(RNA_struct_find_property(op->ptr, "filter_movie")) + if (RNA_struct_find_property(op->ptr, "filter_movie")) params->filter |= RNA_boolean_get(op->ptr, "filter_movie") ? MOVIEFILE : 0; - if(RNA_struct_find_property(op->ptr, "filter_text")) + if (RNA_struct_find_property(op->ptr, "filter_text")) params->filter |= RNA_boolean_get(op->ptr, "filter_text") ? TEXTFILE : 0; - if(RNA_struct_find_property(op->ptr, "filter_python")) + if (RNA_struct_find_property(op->ptr, "filter_python")) params->filter |= RNA_boolean_get(op->ptr, "filter_python") ? PYSCRIPTFILE : 0; - if(RNA_struct_find_property(op->ptr, "filter_font")) + if (RNA_struct_find_property(op->ptr, "filter_font")) params->filter |= RNA_boolean_get(op->ptr, "filter_font") ? FTFONTFILE : 0; - if(RNA_struct_find_property(op->ptr, "filter_sound")) + if (RNA_struct_find_property(op->ptr, "filter_sound")) params->filter |= RNA_boolean_get(op->ptr, "filter_sound") ? SOUNDFILE : 0; - if(RNA_struct_find_property(op->ptr, "filter_text")) + if (RNA_struct_find_property(op->ptr, "filter_text")) params->filter |= RNA_boolean_get(op->ptr, "filter_text") ? TEXTFILE : 0; - if(RNA_struct_find_property(op->ptr, "filter_folder")) + if (RNA_struct_find_property(op->ptr, "filter_folder")) params->filter |= RNA_boolean_get(op->ptr, "filter_folder") ? FOLDERFILE : 0; - if(RNA_struct_find_property(op->ptr, "filter_btx")) + if (RNA_struct_find_property(op->ptr, "filter_btx")) params->filter |= RNA_boolean_get(op->ptr, "filter_btx") ? BTXFILE : 0; - if(RNA_struct_find_property(op->ptr, "filter_collada")) + if (RNA_struct_find_property(op->ptr, "filter_collada")) params->filter |= RNA_boolean_get(op->ptr, "filter_collada") ? COLLADAFILE : 0; if (RNA_struct_find_property(op->ptr, "filter_glob")) { RNA_string_get(op->ptr, "filter_glob", params->filter_glob); @@ -198,14 +198,16 @@ short ED_fileselect_set_params(SpaceFile *sfile) if (params->filter != 0) { if (U.uiflag & USER_FILTERFILEEXTS) { params->flag |= FILE_FILTER; - } else { + } + else { params->flag &= ~FILE_FILTER; } } if (U.uiflag & USER_HIDE_DOT) { params->flag |= FILE_HIDE_DOT; - } else { + } + else { params->flag &= ~FILE_HIDE_DOT; } @@ -216,16 +218,17 @@ short ED_fileselect_set_params(SpaceFile *sfile) params->flag |= RNA_boolean_get(op->ptr, "active_layer") ? FILE_ACTIVELAY : 0; } - if(RNA_struct_find_property(op->ptr, "display_type")) + if (RNA_struct_find_property(op->ptr, "display_type")) params->display= RNA_enum_get(op->ptr, "display_type"); - if(params->display==FILE_DEFAULTDISPLAY) { + if (params->display==FILE_DEFAULTDISPLAY) { if (U.uiflag & USER_SHOW_THUMBNAILS) { - if(params->filter & (IMAGEFILE|MOVIEFILE)) + if (params->filter & (IMAGEFILE|MOVIEFILE)) params->display= FILE_IMGDISPLAY; else params->display= FILE_SHORTDISPLAY; - } else { + } + else { params->display= FILE_SHORTDISPLAY; } } @@ -276,7 +279,8 @@ int ED_fileselect_layout_numfiles(FileLayout* layout, struct ARegion *ar) int width = (int)(ar->v2d.cur.xmax - ar->v2d.cur.xmin - 2*layout->tile_border_x); numfiles = (int)((float)width / (float)layout->tile_w + 0.5f); return numfiles*layout->rows; - } else { + } + else { int height = (int)(ar->v2d.cur.ymax - ar->v2d.cur.ymin - 2*layout->tile_border_y); numfiles = (int)((float)height/(float)layout->tile_h + 0.5f); return numfiles*layout->columns; @@ -312,7 +316,8 @@ FileSelection ED_fileselect_layout_offset_rect(FileLayout* layout, const rcti* r if ( (colmin > layout->columns-1) || (rowmin > layout->rows-1) ) { sel.first = -1; - } else { + } + else { if (layout->flag & FILE_LAYOUT_HOR) sel.first = layout->rows*colmin + rowmin; else @@ -320,7 +325,8 @@ FileSelection ED_fileselect_layout_offset_rect(FileLayout* layout, const rcti* r } if ( (colmax > layout->columns-1) || (rowmax > layout->rows-1) ) { sel.last = -1; - } else { + } + else { if (layout->flag & FILE_LAYOUT_HOR) sel.last = layout->rows*colmax + rowmax; else @@ -356,7 +362,8 @@ void ED_fileselect_layout_tilepos(FileLayout* layout, int tile, int *x, int *y) if (layout->flag == FILE_LAYOUT_HOR) { *x = layout->tile_border_x + (tile/layout->rows)*(layout->tile_w+2*layout->tile_border_x); *y = layout->tile_border_y + (tile%layout->rows)*(layout->tile_h+2*layout->tile_border_y); - } else { + } + else { *x = layout->tile_border_x + ((tile)%layout->columns)*(layout->tile_w+2*layout->tile_border_x); *y = layout->tile_border_y + ((tile)/layout->columns)*(layout->tile_h+2*layout->tile_border_y); } @@ -393,7 +400,8 @@ float file_shorten_string(char* string, float w, int front) temp[slen+4] = '\0'; BLI_strncpy(string, temp, slen+4); } - } else { + } + else { char *s = string; while (sw>w) { int slen = strlen(string); @@ -482,7 +490,8 @@ void ED_fileselect_init_layout(struct SpaceFile *sfile, struct ARegion *ar) if (sfile->layout == NULL) { sfile->layout = MEM_callocN(sizeof(struct FileLayout), "file_layout"); sfile->layout->dirty = TRUE; - } else if (sfile->layout->dirty == FALSE) { + } + else if (sfile->layout->dirty == FALSE) { return; } @@ -502,7 +511,7 @@ void ED_fileselect_init_layout(struct SpaceFile *sfile, struct ARegion *ar) layout->tile_h = layout->prv_h + 2*layout->prv_border_y + textheight; layout->width= (int)(v2d->cur.xmax - v2d->cur.xmin - 2*layout->tile_border_x); layout->columns= layout->width / (layout->tile_w + 2*layout->tile_border_x); - if(layout->columns > 0) + if (layout->columns > 0) layout->rows= numfiles/layout->columns + 1; // XXX dirty, modulo is zero else { layout->columns = 1; @@ -510,7 +519,8 @@ void ED_fileselect_init_layout(struct SpaceFile *sfile, struct ARegion *ar) } layout->height= sfile->layout->rows*(layout->tile_h+2*layout->tile_border_y) + layout->tile_border_y*2; layout->flag = FILE_LAYOUT_VER; - } else { + } + else { layout->prv_w = 0; layout->prv_h = 0; layout->tile_border_x = 8; @@ -527,7 +537,8 @@ void ED_fileselect_init_layout(struct SpaceFile *sfile, struct ARegion *ar) maxlen = ICON_DEFAULT_WIDTH_SCALE + 4 + (int)layout->column_widths[COLUMN_NAME] + 12 + (int)layout->column_widths[COLUMN_SIZE] + 12; - } else { + } + else { maxlen = ICON_DEFAULT_WIDTH_SCALE + 4 + (int)layout->column_widths[COLUMN_NAME] + 12 + #ifndef WIN32 @@ -542,7 +553,7 @@ void ED_fileselect_init_layout(struct SpaceFile *sfile, struct ARegion *ar) } layout->tile_w = maxlen; - if(layout->rows > 0) + if (layout->rows > 0) layout->columns = numfiles/layout->rows + 1; // XXX dirty, modulo is zero else { layout->rows = 1; @@ -570,13 +581,13 @@ void file_change_dir(bContext *C, int checkdir) ED_fileselect_clear(C, sfile); - if(checkdir && BLI_is_dir(sfile->params->dir)==0) { + if (checkdir && BLI_is_dir(sfile->params->dir)==0) { BLI_strncpy(sfile->params->dir, filelist_dir(sfile->files), sizeof(sfile->params->dir)); /* could return but just refresh the current dir */ } filelist_setdir(sfile->files, sfile->params->dir); - if(folderlist_clear_next(sfile)) + if (folderlist_clear_next(sfile)) folderlist_free(sfile->folders_next); folderlist_pushdir(sfile->folders_prev, sfile->params->dir); @@ -608,7 +619,7 @@ void autocomplete_directory(struct bContext *C, char *str, void *UNUSED(arg_v)) SpaceFile *sfile= CTX_wm_space_file(C); /* search if str matches the beginning of name */ - if(str[0] && sfile->files) { + if (str[0] && sfile->files) { char dirname[FILE_MAX]; DIR *dir; @@ -618,7 +629,7 @@ void autocomplete_directory(struct bContext *C, char *str, void *UNUSED(arg_v)) dir = opendir(dirname); - if(dir) { + if (dir) { AutoComplete *autocpl= autocomplete_begin(str, FILE_MAX); while ((de = readdir(dir)) != NULL) { @@ -643,7 +654,8 @@ void autocomplete_directory(struct bContext *C, char *str, void *UNUSED(arg_v)) autocomplete_end(autocpl, str); if (BLI_exists(str)) { BLI_add_slash(str); - } else { + } + else { BLI_strncpy(sfile->params->dir, str, sizeof(sfile->params->dir)); } } @@ -655,12 +667,12 @@ void autocomplete_file(struct bContext *C, char *str, void *UNUSED(arg_v)) SpaceFile *sfile= CTX_wm_space_file(C); /* search if str matches the beginning of name */ - if(str[0] && sfile->files) { + if (str[0] && sfile->files) { AutoComplete *autocpl= autocomplete_begin(str, FILE_MAX); int nentries = filelist_numfiles(sfile->files); int i; - for(i= 0; ifiles, i); if (file && S_ISREG(file->type)) { autocomplete_do_name(autocpl, file->relname); @@ -685,8 +697,8 @@ void ED_fileselect_clear(struct bContext *C, struct SpaceFile *sfile) void ED_fileselect_exit(struct bContext *C, struct SpaceFile *sfile) { - if(!sfile) return; - if(sfile->op) { + if (!sfile) return; + if (sfile->op) { WM_event_fileselect_event(C, sfile->op, EVT_FILESELECT_EXTERNAL_CANCEL); sfile->op = NULL; } diff --git a/source/blender/editors/space_file/fsmenu.c b/source/blender/editors/space_file/fsmenu.c index 8b98b942f42..ddd4b31d145 100644 --- a/source/blender/editors/space_file/fsmenu.c +++ b/source/blender/editors/space_file/fsmenu.c @@ -177,7 +177,8 @@ void fsmenu_insert_entry(struct FSMenu* fsmenu, FSMenuCategory category, const c else if (sorted && cmp_ret < 0) { break; } - } else { + } + else { // if we're bookmarking this, file should come // before the last separator, only automatically added // current dir go after the last sep. @@ -194,7 +195,8 @@ void fsmenu_insert_entry(struct FSMenu* fsmenu, FSMenuCategory category, const c if (prev) { fsme->next= prev->next; prev->next= fsme; - } else { + } + else { fsme->next= fsms; fsmenu_set_category(fsmenu, category, fsme); } @@ -217,7 +219,8 @@ void fsmenu_remove_entry(struct FSMenu* fsmenu, FSMenuCategory category, int idx /* remove fsme from list */ if (prev) { prev->next= fsme->next; - } else { + } + else { fsms= fsme->next; fsmenu_set_category(fsmenu, category, fsms); } @@ -267,11 +270,13 @@ void fsmenu_read_bookmarks(struct FSMenu* fsmenu, const char *filename) while ( fgets ( line, 256, fp ) != NULL ) /* read a line */ { - if (strncmp(line, "[Bookmarks]", 11)==0){ + if (strncmp(line, "[Bookmarks]", 11)==0) { category = FS_CATEGORY_BOOKMARKS; - } else if (strncmp(line, "[Recent]", 8)==0){ + } + else if (strncmp(line, "[Recent]", 8)==0) { category = FS_CATEGORY_RECENT; - } else { + } + else { int len = strlen(line); if (len>0) { if (line[len-1] == '\n') { @@ -344,7 +349,7 @@ void fsmenu_read_system(struct FSMenu* fsmenu) * assume they are the standard ones * TODO : replace hardcoded paths with proper BLI_get_folder calls */ home = getenv("HOME"); - if(home) { + if (home) { BLI_snprintf(line, 256, "%s/", home); fsmenu_insert_entry(fsmenu, FS_CATEGORY_BOOKMARKS, line, 1, 0); BLI_snprintf(line, 256, "%s/Desktop/", home); @@ -465,7 +470,7 @@ void fsmenu_read_system(struct FSMenu* fsmenu) { const char *home= getenv("HOME"); - if(home) { + if (home) { BLI_snprintf(line, FILE_MAXDIR, "%s/", home); fsmenu_insert_entry(fsmenu, FS_CATEGORY_BOOKMARKS, line, 1, 0); BLI_snprintf(line, FILE_MAXDIR, "%s/Desktop/", home); @@ -489,11 +494,11 @@ void fsmenu_read_system(struct FSMenu* fsmenu) else { while ((mnt = getmntent (fp))) { /* not sure if this is right, but seems to give the relevant mnts */ - if(strncmp(mnt->mnt_fsname, "/dev", 4)) + if (strncmp(mnt->mnt_fsname, "/dev", 4)) continue; len= strlen(mnt->mnt_dir); - if(len && mnt->mnt_dir[len-1] != '/') { + if (len && mnt->mnt_dir[len-1] != '/') { BLI_snprintf(line, FILE_MAXDIR, "%s/", mnt->mnt_dir); fsmenu_insert_entry(fsmenu, FS_CATEGORY_SYSTEM, line, 1, 0); } @@ -509,7 +514,7 @@ void fsmenu_read_system(struct FSMenu* fsmenu) #endif /* fallback */ - if(!found) + if (!found) fsmenu_insert_entry(fsmenu, FS_CATEGORY_SYSTEM, "/", 1, 0); } } diff --git a/source/blender/editors/space_file/space_file.c b/source/blender/editors/space_file/space_file.c index 8d156aed6b7..0cf15c22efa 100644 --- a/source/blender/editors/space_file/space_file.c +++ b/source/blender/editors/space_file/space_file.c @@ -113,7 +113,7 @@ static void file_free(SpaceLink *sl) { SpaceFile *sfile= (SpaceFile *) sl; - if(sfile->files) { + if (sfile->files) { // XXXXX would need to do thumbnails_stop here, but no context available filelist_freelib(sfile->files); filelist_free(sfile->files); @@ -121,13 +121,13 @@ static void file_free(SpaceLink *sl) sfile->files= NULL; } - if(sfile->folders_prev) { + if (sfile->folders_prev) { folderlist_free(sfile->folders_prev); MEM_freeN(sfile->folders_prev); sfile->folders_prev= NULL; } - if(sfile->folders_next) { + if (sfile->folders_next) { folderlist_free(sfile->folders_next); MEM_freeN(sfile->folders_next); sfile->folders_next= NULL; @@ -151,7 +151,7 @@ static void file_init(struct wmWindowManager *UNUSED(wm), ScrArea *sa) SpaceFile *sfile= (SpaceFile*)sa->spacedata.first; //printf("file_init\n"); - if(sfile->layout) sfile->layout->dirty= TRUE; + if (sfile->layout) sfile->layout->dirty= TRUE; } @@ -169,10 +169,10 @@ static SpaceLink *file_duplicate(SpaceLink *sl) filelist_setdir(sfilen->files, sfilen->params->dir); } - if(sfileo->folders_prev) + if (sfileo->folders_prev) sfilen->folders_prev = folderlist_duplicate(sfileo->folders_prev); - if(sfileo->folders_next) + if (sfileo->folders_next) sfilen->folders_next = folderlist_duplicate(sfileo->folders_next); if (sfileo->layout) { @@ -200,26 +200,29 @@ static void file_refresh(const bContext *C, ScrArea *UNUSED(sa)) if (filelist_empty(sfile->files)) { thumbnails_stop(sfile->files, C); filelist_readdir(sfile->files); - if(params->sort!=FILE_SORT_NONE) { + if (params->sort!=FILE_SORT_NONE) { filelist_sort(sfile->files, params->sort); } BLI_strncpy(params->dir, filelist_dir(sfile->files), FILE_MAX); - if(params->display == FILE_IMGDISPLAY) { + if (params->display == FILE_IMGDISPLAY) { thumbnails_start(sfile->files, C); } - } else { - if(params->sort!=FILE_SORT_NONE) { + } + else { + if (params->sort!=FILE_SORT_NONE) { thumbnails_stop(sfile->files, C); filelist_sort(sfile->files, params->sort); - if(params->display == FILE_IMGDISPLAY) { + if (params->display == FILE_IMGDISPLAY) { thumbnails_start(sfile->files, C); } - } else { - if(params->display == FILE_IMGDISPLAY) { + } + else { + if (params->display == FILE_IMGDISPLAY) { if (!thumbnails_running(sfile->files,C)) { thumbnails_start(sfile->files, C); } - } else { + } + else { /* stop any running thumbnail jobs if we're not * displaying them - speedup for NFS */ thumbnails_stop(sfile->files, C); @@ -333,7 +336,7 @@ static void file_main_area_draw(const bContext *C, ARegion *ar) /* XXX this happens on scaling down Screen (like from startup.blend) */ /* view2d has no type specific for filewindow case, which doesnt scroll vertically */ - if(v2d->cur.ymax < 0) { + if (v2d->cur.ymax < 0) { v2d->cur.ymin -= v2d->cur.ymax; v2d->cur.ymax = 0; } diff --git a/source/blender/editors/space_graph/graph_buttons.c b/source/blender/editors/space_graph/graph_buttons.c index 51b29deab81..4d2fe2cd568 100644 --- a/source/blender/editors/space_graph/graph_buttons.c +++ b/source/blender/editors/space_graph/graph_buttons.c @@ -108,12 +108,12 @@ static int graph_panel_context(const bContext *C, bAnimListElem **ale, FCurve ** /* try to find 'active' F-Curve */ elem= get_active_fcurve_channel(&ac); - if(elem == NULL) + if (elem == NULL) return 0; - if(fcu) + if (fcu) *fcu= (FCurve*)elem->data; - if(ale) + if (ale) *ale= elem; else MEM_freeN(elem); @@ -452,7 +452,7 @@ static int graph_panel_drivers_poll(const bContext *C, PanelType *UNUSED(pt)) { SpaceIpo *sipo= CTX_wm_space_graph(C); - if(sipo->mode != SIPO_MODE_DRIVERS) + if (sipo->mode != SIPO_MODE_DRIVERS) return 0; return graph_panel_context(C, NULL, NULL); @@ -831,7 +831,7 @@ static int graph_properties(bContext *C, wmOperator *UNUSED(op)) ScrArea *sa= CTX_wm_area(C); ARegion *ar= graph_has_buttons_region(sa); - if(ar) + if (ar) ED_region_toggle_hidden(C, ar); return OPERATOR_FINISHED; diff --git a/source/blender/editors/space_graph/graph_draw.c b/source/blender/editors/space_graph/graph_draw.c index fd0fa538d81..279e6ce0400 100644 --- a/source/blender/editors/space_graph/graph_draw.c +++ b/source/blender/editors/space_graph/graph_draw.c @@ -499,7 +499,7 @@ static void draw_fcurve_curve (bAnimContext *ac, ID *id, FCurve *fcu, View2D *v2 /* when opening a blend file on a different sized screen or while dragging the toolbar this can happen * best just bail out in this case */ UI_view2d_grid_size(grid, &dx, &dy); - if(dx <= 0.0f) + if (dx <= 0.0f) return; diff --git a/source/blender/editors/space_graph/graph_edit.c b/source/blender/editors/space_graph/graph_edit.c index 8b8cdc32ebb..c0cd2a882c8 100644 --- a/source/blender/editors/space_graph/graph_edit.c +++ b/source/blender/editors/space_graph/graph_edit.c @@ -1074,7 +1074,7 @@ static float fcurve_samplingcb_sound (FCurve *UNUSED(fcu), void *data, float eva tSoundBakeInfo *sbi= (tSoundBakeInfo *)data; int position = evaltime - sbi->cfra; - if((position < 0) || (position >= sbi->length)) + if ((position < 0) || (position >= sbi->length)) return 0.0f; return sbi->samples[position]; diff --git a/source/blender/editors/space_graph/space_graph.c b/source/blender/editors/space_graph/space_graph.c index 6294e0ecd25..37cdbd4963a 100644 --- a/source/blender/editors/space_graph/space_graph.c +++ b/source/blender/editors/space_graph/space_graph.c @@ -70,7 +70,7 @@ ARegion *graph_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 main */ ar= BKE_area_find_region_type(sa, RGN_TYPE_WINDOW); @@ -400,7 +400,7 @@ static void graph_region_listener(ARegion *ar, wmNotifier *wmn) ED_region_tag_redraw(ar); break; case ND_MODIFIER: - if(wmn->action == NA_RENAME) + if (wmn->action == NA_RENAME) ED_region_tag_redraw(ar); break; } @@ -414,11 +414,11 @@ static void graph_region_listener(ARegion *ar, wmNotifier *wmn) } break; case NC_ID: - if(wmn->action == NA_RENAME) + if (wmn->action == NA_RENAME) ED_region_tag_redraw(ar); break; default: - if(wmn->data==ND_KEYS) + if (wmn->data==ND_KEYS) ED_region_tag_redraw(ar); } @@ -474,13 +474,13 @@ static void graph_listener(ScrArea *sa, wmNotifier *wmn) } break; case NC_SPACE: - if(wmn->data == ND_SPACE_GRAPH) + if (wmn->data == ND_SPACE_GRAPH) ED_area_tag_redraw(sa); break; // XXX: restore the case below if not enough updates occur... //default: - // if(wmn->data==ND_KEYS) + // if (wmn->data==ND_KEYS) // ED_area_tag_redraw(sa); } } diff --git a/source/blender/editors/space_image/image_buttons.c b/source/blender/editors/space_image/image_buttons.c index 054d342ce4b..dbee8f207ec 100644 --- a/source/blender/editors/space_image/image_buttons.c +++ b/source/blender/editors/space_image/image_buttons.c @@ -101,15 +101,15 @@ static void image_info(Scene *scene, ImageUser *iuser, Image *ima, ImBuf *ibuf, str[0]= 0; - if(ima==NULL) return; + if (ima==NULL) return; - if(ibuf==NULL) { + if (ibuf==NULL) { ofs+= sprintf(str, "Can't Load Image"); } else { - if(ima->source==IMA_SRC_MOVIE) { + if (ima->source==IMA_SRC_MOVIE) { ofs+= sprintf(str, "Movie"); - if(ima->anim) + if (ima->anim) ofs+= sprintf(str+ofs, "%d frs", IMB_anim_get_duration(ima->anim, IMB_TC_RECORD_RUN)); } else @@ -117,34 +117,34 @@ static void image_info(Scene *scene, ImageUser *iuser, Image *ima, ImBuf *ibuf, ofs+= sprintf(str+ofs, ": size %d x %d,", ibuf->x, ibuf->y); - if(ibuf->rect_float) { - if(ibuf->channels!=4) { + if (ibuf->rect_float) { + if (ibuf->channels!=4) { ofs+= sprintf(str+ofs, "%d float channel(s)", ibuf->channels); } - else if(ibuf->planes == R_IMF_PLANES_RGBA) + else if (ibuf->planes == R_IMF_PLANES_RGBA) ofs+= sprintf(str+ofs, " RGBA float"); else ofs+= sprintf(str+ofs, " RGB float"); } else { - if(ibuf->planes == R_IMF_PLANES_RGBA) + if (ibuf->planes == R_IMF_PLANES_RGBA) ofs+= sprintf(str+ofs, " RGBA byte"); else ofs+= sprintf(str+ofs, " RGB byte"); } - if(ibuf->zbuf || ibuf->zbuf_float) + if (ibuf->zbuf || ibuf->zbuf_float) ofs+= sprintf(str+ofs, " + Z"); - if(ima->source==IMA_SRC_SEQUENCE) { + if (ima->source==IMA_SRC_SEQUENCE) { char *file= BLI_last_slash(ibuf->name); - if(file==NULL) file= ibuf->name; + if (file==NULL) file= ibuf->name; else file++; ofs+= sprintf(str+ofs, ", %s", file); } } /* the frame number, even if we cant */ - if(ima->source==IMA_SRC_SEQUENCE) { + if (ima->source==IMA_SRC_SEQUENCE) { /* don't use iuser->framenr directly because it may not be updated if auto-refresh is off */ const int framenr= BKE_image_user_get_frame(iuser, CFRA, 0); ofs+= sprintf(str+ofs, ", Frame: %d", framenr); @@ -158,10 +158,10 @@ 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; } @@ -196,8 +196,8 @@ static void image_panel_curves(const bContext *C, Panel *pa) ibuf= ED_space_image_acquire_buffer(sima, &lock); - if(ibuf) { - if(sima->cumap==NULL) + if (ibuf) { + if (sima->cumap==NULL) sima->cumap= curvemapping_add(4, 0.0f, 0.0f, 1.0f, 1.0f); /* curvemap black/white levels only works for RGBA */ @@ -220,12 +220,12 @@ void image_preview_event(int event) { int exec= 0; - if(event==0) { + if (event==0) { G.scene->r.scemode &= ~R_COMP_CROP; exec= 1; } else { - if(image_preview_active(curarea, NULL, NULL)) { + if (image_preview_active(curarea, NULL, NULL)) { G.scene->r.scemode |= R_COMP_CROP; exec= 1; } @@ -233,7 +233,7 @@ void image_preview_event(int event) G.scene->r.scemode &= ~R_COMP_CROP; } - if(exec && G.scene->nodetree) { + if (exec && G.scene->nodetree) { /* should work when no node editor in screen..., so we execute right away */ ntreeCompositTagGenerators(G.scene->nodetree); @@ -267,7 +267,7 @@ static void preview_cb(struct ScrArea *sa, struct uiBlock *block) int winy= (G.scene->r.size*G.scene->r.ysch)/100; int mval[2]; - if(G.scene->r.mode & R_BORDER) { + if (G.scene->r.mode & R_BORDER) { winx*= (G.scene->r.border.xmax - G.scene->r.border.xmin); winy*= (G.scene->r.border.ymax - G.scene->r.border.ymin); } @@ -308,14 +308,14 @@ static int is_preview_allowed(ScrArea *cur) ScrArea *sa; /* check if another areawindow has preview set */ - for(sa=G.curscreen->areabase.first; sa; sa= sa->next) { - if(sa!=cur && sa->spacetype==SPACE_IMAGE) { - if(image_preview_active(sa, NULL, NULL)) + for (sa=G.curscreen->areabase.first; sa; sa= sa->next) { + if (sa!=cur && sa->spacetype==SPACE_IMAGE) { + if (image_preview_active(sa, NULL, NULL)) return 0; } } /* check image type */ - if(sima->image==NULL || sima->image->type!=IMA_TYPE_COMPOSITE) + if (sima->image==NULL || sima->image->type!=IMA_TYPE_COMPOSITE) return 0; return 1; @@ -328,7 +328,7 @@ static void image_panel_preview(ScrArea *sa, short cntrl) // IMAGE_HANDLER_PREVI SpaceImage *sima= sa->spacedata.first; int ofsx, ofsy; - if(is_preview_allowed(sa)==0) { + if (is_preview_allowed(sa)==0) { rem_blockhandler(sa, IMAGE_HANDLER_PREVIEW); G.scene->r.scemode &= ~R_COMP_CROP; /* quite weak */ return; @@ -340,7 +340,7 @@ static void image_panel_preview(ScrArea *sa, short cntrl) // IMAGE_HANDLER_PREVI ofsx= -150+(sa->winx/2)/sima->blockscale; ofsy= -100+(sa->winy/2)/sima->blockscale; - if(uiNewPanel(C, ar, block, "Preview", "Image", ofsx, ofsy, 300, 200)==0) return; + if (uiNewPanel(C, ar, block, "Preview", "Image", ofsx, ofsy, 300, 200)==0) return; uiBlockSetDrawExtraFunc(block, preview_cb); @@ -360,7 +360,7 @@ static char *slot_menu(void) strcpy(str, "Slot %t"); a= strlen(str); - for(slot=0; slotrectf) { + if (rr->rectf) { a+= sprintf(str+a, "|Composite %%x0"); nr= 1; } - else if(rr->rect32) { + else if (rr->rect32) { a+= sprintf(str+a, "|Sequence %%x0"); nr= 1; } - for(rl= rr->layers.first; rl; rl= rl->next, nr++) { + for (rl= rr->layers.first; rl; rl= rl->next, nr++) { a+= sprintf(str+a, "|%s %%x%d", rl->name, nr); } @@ -407,16 +407,16 @@ static char *pass_menu(RenderLayer *rl, short *curpass) a= strlen(str); /* rendered results don't have a Combined pass */ - if(rl==NULL || rl->rectf) { + if (rl==NULL || rl->rectf) { a+= sprintf(str+a, "|Combined %%x0"); nr= 1; } - if(rl) - for(rpass= rl->passes.first; rpass; rpass= rpass->next, nr++) + if (rl) + for (rpass= rl->passes.first; rpass; rpass= rpass->next, nr++) a+= sprintf(str+a, "|%s %%x%d", rpass->name, nr); - if(*curpass >= nr) + if (*curpass >= nr) *curpass= 0; return str; @@ -428,7 +428,7 @@ static void set_frames_cb(bContext *C, void *ima_v, void *iuser_v) Image *ima= ima_v; ImageUser *iuser= iuser_v; - if(ima->anim) { + if (ima->anim) { iuser->frames = IMB_anim_get_duration(ima->anim, IMB_TC_RECORD_RUN); BKE_image_user_calc_frame(iuser, scene->r.cfra, 0); } @@ -448,10 +448,10 @@ static void image_multi_inclay_cb(bContext *C, void *rr_v, void *iuser_v) ImageUser *iuser= iuser_v; int tot= BLI_countlist(&rr->layers); - if(rr->rectf || rr->rect32) + if (rr->rectf || rr->rect32) tot++; /* fake compo/sequencer layer */ - if(iuser->layerlayerlayer++; BKE_image_multilayer_index(rr, iuser); WM_event_add_notifier(C, NC_IMAGE|ND_DRAW, NULL); @@ -461,7 +461,7 @@ static void image_multi_declay_cb(bContext *C, void *rr_v, void *iuser_v) { ImageUser *iuser= iuser_v; - if(iuser->layer>0) { + if (iuser->layer>0) { iuser->layer--; BKE_image_multilayer_index(rr_v, iuser); WM_event_add_notifier(C, NC_IMAGE|ND_DRAW, NULL); @@ -473,13 +473,13 @@ static void image_multi_incpass_cb(bContext *C, void *rr_v, void *iuser_v) ImageUser *iuser= iuser_v; RenderLayer *rl= BLI_findlink(&rr->layers, iuser->layer); - if(rl) { + if (rl) { int tot= BLI_countlist(&rl->passes); - if(rr->rectf || rr->rect32) + if (rr->rectf || rr->rect32) tot++; /* fake compo/sequencer layer */ - if(iuser->passpasspass++; BKE_image_multilayer_index(rr, iuser); WM_event_add_notifier(C, NC_IMAGE|ND_DRAW, NULL); @@ -490,7 +490,7 @@ static void image_multi_decpass_cb(bContext *C, void *rr_v, void *iuser_v) { ImageUser *iuser= iuser_v; - if(iuser->pass>0) { + if (iuser->pass>0) { iuser->pass--; BKE_image_multilayer_index(rr_v, iuser); WM_event_add_notifier(C, NC_IMAGE|ND_DRAW, NULL); @@ -530,21 +530,21 @@ static void uiblock_layer_pass_buttons(uiLayout *layout, RenderResult *rr, Image wmenu3= (3*w)/6; /* menu buts */ - if(render_slot) { + if (render_slot) { strp= slot_menu(); but = uiDefButS(block, MENU, 0, strp, 0, 0, wmenu1, UI_UNIT_Y, render_slot, 0,0,0,0, "Select Slot"); uiButSetFunc(but, image_multi_cb, rr, iuser); MEM_freeN(strp); } - if(rr) { + if (rr) { strp= layer_menu(rr, &iuser->layer); but = uiDefButS(block, MENU, 0, strp, 0, 0, wmenu2, UI_UNIT_Y, &iuser->layer, 0,0,0,0, "Select Layer"); uiButSetFunc(but, image_multi_cb, rr, iuser); MEM_freeN(strp); layer = iuser->layer; - if(rr->rectf || rr->rect32) + if (rr->rectf || rr->rect32) layer--; /* fake compo/sequencer layer */ rl= BLI_findlink(&rr->layers, layer); /* return NULL is meant to be */ @@ -564,9 +564,9 @@ static void uiblock_layer_pass_arrow_buttons(uiLayout *layout, RenderResult *rr, row= uiLayoutRow(layout, 1); - if(rr==NULL || iuser==NULL) + if (rr==NULL || iuser==NULL) return; - if(rr->layers.first==NULL) { + if (rr->layers.first==NULL) { uiItemL(row, "No Layers in Render Result", ICON_NONE); return; } @@ -626,17 +626,17 @@ void uiTemplateImage(uiLayout *layout, bContext *C, PointerRNA *ptr, const char char str[128]; void *lock; - if(!ptr->data) + if (!ptr->data) return; prop= RNA_struct_find_property(ptr, propname); - if(!prop) { + if (!prop) { printf("%s: property not found: %s.%s\n", __func__, RNA_struct_identifier(ptr->type), propname); return; } - if(RNA_property_type(prop) != PROP_POINTER) { + if (RNA_property_type(prop) != PROP_POINTER) { printf("%s: expected pointer property for %s.%s\n", __func__, RNA_struct_identifier(ptr->type), propname); return; @@ -655,13 +655,13 @@ void uiTemplateImage(uiLayout *layout, bContext *C, PointerRNA *ptr, const char uiLayoutSetContextPointer(layout, "edit_image", &imaptr); - if(!compact) + if (!compact) uiTemplateID(layout, C, ptr, propname, "IMAGE_OT_new", "IMAGE_OT_open", NULL); - if(ima) { + if (ima) { uiBlockSetNFunc(block, rna_update_cb, MEM_dupallocN(cb), NULL); - if(ima->source == IMA_SRC_VIEWER) { + if (ima->source == IMA_SRC_VIEWER) { ibuf= BKE_image_acquire_ibuf(ima, iuser, &lock); image_info(scene, iuser, ima, ibuf, str); BKE_image_release_ibuf(ima, lock); @@ -669,18 +669,18 @@ void uiTemplateImage(uiLayout *layout, bContext *C, PointerRNA *ptr, const char uiItemL(layout, ima->id.name+2, ICON_NONE); uiItemL(layout, str, ICON_NONE); - if(ima->type==IMA_TYPE_COMPOSITE) { + if (ima->type==IMA_TYPE_COMPOSITE) { // XXX not working yet #if 0 iuser= ntree_get_active_iuser(scene->nodetree); - if(iuser) { + if (iuser) { uiBlockBeginAlign(block); uiDefIconTextBut(block, BUT, B_SIMA_RECORD, ICON_REC, "Record", 10,120,100,20, 0, 0, 0, 0, 0, ""); uiDefIconTextBut(block, BUT, B_SIMA_PLAY, ICON_PLAY, "Play", 110,120,100,20, 0, 0, 0, 0, 0, ""); but = uiDefBut(block, BUT, B_NOP, "Free Cache", 210,120,100,20, 0, 0, 0, 0, 0, ""); uiButSetFunc(but, image_freecache_cb, ima, NULL); - if(iuser->frames) + if (iuser->frames) BLI_snprintf(str, sizeof(str), "(%d) Frames:", iuser->framenr); else strcpy(str, "Frames:"); uiBlockBeginAlign(block); @@ -689,7 +689,7 @@ void uiTemplateImage(uiLayout *layout, bContext *C, PointerRNA *ptr, const char } #endif } - else if(ima->type==IMA_TYPE_R_RESULT) { + else if (ima->type==IMA_TYPE_R_RESULT) { /* browse layer/passes */ Render *re= RE_GetRender(scene->id.name); RenderResult *rr= RE_AcquireResultRead(re); @@ -700,7 +700,7 @@ void uiTemplateImage(uiLayout *layout, bContext *C, PointerRNA *ptr, const char else { uiItemR(layout, &imaptr, "source", 0, NULL, ICON_NONE); - if(ima->source != IMA_SRC_GENERATED) { + if (ima->source != IMA_SRC_GENERATED) { row= uiLayoutRow(layout, 1); if (ima->packedfile) uiItemO(row, "", ICON_PACKAGE, "image.unpack"); @@ -716,8 +716,8 @@ void uiTemplateImage(uiLayout *layout, bContext *C, PointerRNA *ptr, const char // XXX what was this for? #if 0 /* check for re-render, only buttons */ - if(imagechanged==B_IMAGECHANGED) { - if(iuser->flag & IMA_ANIM_REFRESHED) { + if (imagechanged==B_IMAGECHANGED) { + if (iuser->flag & IMA_ANIM_REFRESHED) { iuser->flag &= ~IMA_ANIM_REFRESHED; WM_event_add_notifier(C, NC_IMAGE, ima); } @@ -725,11 +725,11 @@ void uiTemplateImage(uiLayout *layout, bContext *C, PointerRNA *ptr, const char #endif /* multilayer? */ - if(ima->type==IMA_TYPE_MULTILAYER && ima->rr) { + if (ima->type==IMA_TYPE_MULTILAYER && ima->rr) { uiblock_layer_pass_arrow_buttons(layout, ima->rr, iuser, NULL); } - else if(ima->source != IMA_SRC_GENERATED) { - if(compact == 0) { + else if (ima->source != IMA_SRC_GENERATED) { + if (compact == 0) { ibuf= BKE_image_acquire_ibuf(ima, iuser, &lock); image_info(scene, iuser, ima, ibuf, str); BKE_image_release_ibuf(ima, lock); @@ -737,8 +737,8 @@ void uiTemplateImage(uiLayout *layout, bContext *C, PointerRNA *ptr, const char } } - if(ima->source != IMA_SRC_GENERATED) { - if(compact == 0) { /* background image view doesnt need these */ + if (ima->source != IMA_SRC_GENERATED) { + if (compact == 0) { /* background image view doesnt need these */ uiItemS(layout); split= uiLayoutSplit(layout, 0, 0); @@ -755,7 +755,7 @@ void uiTemplateImage(uiLayout *layout, bContext *C, PointerRNA *ptr, const char } } - if(ELEM(ima->source, IMA_SRC_MOVIE, IMA_SRC_SEQUENCE)) { + if (ELEM(ima->source, IMA_SRC_MOVIE, IMA_SRC_SEQUENCE)) { uiItemS(layout); split= uiLayoutSplit(layout, 0, 0); @@ -764,7 +764,7 @@ void uiTemplateImage(uiLayout *layout, bContext *C, PointerRNA *ptr, const char BLI_snprintf(str, sizeof(str), "(%d) Frames", iuser->framenr); uiItemR(col, userptr, "frame_duration", 0, str, ICON_NONE); - if(ima->anim) { + if (ima->anim) { block= uiLayoutGetBlock(col); but = uiDefBut(block, BUT, 0, "Match Movie Length", 0, 0, UI_UNIT_X*2, UI_UNIT_Y, NULL, 0, 0, 0, 0, "Set the number of frames to match the movie or sequence"); uiButSetFunc(but, set_frames_cb, ima, iuser); @@ -780,7 +780,7 @@ void uiTemplateImage(uiLayout *layout, bContext *C, PointerRNA *ptr, const char uiItemR(col, userptr, "use_auto_refresh", 0, NULL, ICON_NONE); uiItemR(col, userptr, "use_cyclic", 0, NULL, ICON_NONE); } - else if(ima->source==IMA_SRC_GENERATED) { + else if (ima->source==IMA_SRC_GENERATED) { split= uiLayoutSplit(layout, 0, 0); col= uiLayoutColumn(split, 1); @@ -818,7 +818,7 @@ void uiTemplateImageSettings(uiLayout *layout, PointerRNA *imfptr) uiItemR(sub, imfptr, "color_mode", UI_ITEM_R_EXPAND, "Color", ICON_NONE); /* only display depth setting if multiple depths can be used */ - if((ELEM6(depth_ok, + if ((ELEM6(depth_ok, R_IMF_CHAN_DEPTH_1, R_IMF_CHAN_DEPTH_8, R_IMF_CHAN_DEPTH_12, @@ -877,7 +877,7 @@ void uiTemplateImageLayers(uiLayout *layout, bContext *C, Image *ima, ImageUser RenderResult *rr; /* render layers and passes */ - if(ima && iuser) { + if (ima && iuser) { const float dpi_fac= UI_DPI_FAC; rr= BKE_image_acquire_renderresult(scene, ima); uiblock_layer_pass_buttons(layout, rr, iuser, 160 * dpi_fac, (ima->type==IMA_TYPE_R_RESULT)? &ima->render_slot: NULL); @@ -909,7 +909,7 @@ static int image_properties(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; @@ -933,7 +933,7 @@ static int image_scopes(bContext *C, wmOperator *UNUSED(op)) ScrArea *sa= CTX_wm_area(C); ARegion *ar= image_has_scope_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 3c2ebea5c28..59ca1925abf 100644 --- a/source/blender/editors/space_image/image_draw.c +++ b/source/blender/editors/space_image/image_draw.c @@ -85,9 +85,9 @@ static void image_verify_buffer_float(Image *ima, ImBuf *ibuf, int color_manage) * NOTE: if float buffer changes, we have to manually remove the rect */ - if(ibuf->rect_float && (ibuf->rect==NULL || (ibuf->userflags & IB_RECT_INVALID)) ) { - if(color_manage) { - if(ima && ima->source == IMA_SRC_VIEWER) + if (ibuf->rect_float && (ibuf->rect==NULL || (ibuf->userflags & IB_RECT_INVALID)) ) { + if (color_manage) { + if (ima && ima->source == IMA_SRC_VIEWER) ibuf->profile = IB_PROFILE_LINEAR_RGB; } else @@ -103,7 +103,7 @@ static void draw_render_info(Scene *scene, Image *ima, ARegion *ar) rr= BKE_image_acquire_renderresult(scene, ima); - if(rr && rr->text) { + if (rr && rr->text) { ED_region_info_draw(ar, rr->text, 1, 0.25); } @@ -147,14 +147,14 @@ void ED_image_draw_info(ARegion *ar, int color_manage, int channels, int x, int BLF_draw_ascii(blf_mono_font, str, sizeof(str)); dx += BLF_width(blf_mono_font, str); - if(zp) { + if (zp) { glColor3ub(255, 255, 255); BLI_snprintf(str, sizeof(str), " Z:%-.4f |", 0.5f+0.5f*(((float)*zp)/(float)0x7fffffff)); BLF_position(blf_mono_font, dx, 6, 0); BLF_draw_ascii(blf_mono_font, str, sizeof(str)); dx += BLF_width(blf_mono_font, str); } - if(zpf) { + if (zpf) { glColor3ub(255, 255, 255); BLI_snprintf(str, sizeof(str), " Z:%-.3f |", *zpf); BLF_position(blf_mono_font, dx, 6, 0); @@ -162,7 +162,7 @@ void ED_image_draw_info(ARegion *ar, int color_manage, int channels, int x, int dx += BLF_width(blf_mono_font, str); } - if(channels >= 3) { + if (channels >= 3) { glColor3ubv(red); if (fp) BLI_snprintf(str, sizeof(str), " R:%-.4f", fp[0]); @@ -196,7 +196,7 @@ void ED_image_draw_info(ARegion *ar, int color_manage, int channels, int x, int BLF_draw_ascii(blf_mono_font, str, sizeof(str)); dx += BLF_width(blf_mono_font, str); - if(channels == 4) { + if (channels == 4) { glColor3ub(255, 255, 255); if (fp) BLI_snprintf(str, sizeof(str), " A:%-.4f", fp[3]); @@ -278,7 +278,7 @@ void ED_image_draw_info(ARegion *ar, int color_manage, int channels, int x, int dx += 35; glColor3ub(255, 255, 255); - if(channels == 1) { + if (channels == 1) { if (fp) { rgb_to_hsv(fp[0], fp[0], fp[0], &hue, &sat, &val); rgb_to_yuv(fp[0], fp[0], fp[0], &lum, &u, &v); @@ -298,7 +298,7 @@ void ED_image_draw_info(ARegion *ar, int color_manage, int channels, int x, int BLF_draw_ascii(blf_mono_font, str, sizeof(str)); dx += BLF_width(blf_mono_font, str); } - else if(channels >= 3) { + else if (channels >= 3) { if (fp) { rgb_to_hsv(fp[0], fp[1], fp[2], &hue, &sat, &val); rgb_to_yuv(fp[0], fp[1], fp[2], &lum, &u, &v); @@ -349,16 +349,16 @@ static void draw_image_grid(ARegion *ar, float zoomx, float zoomy) /* gridsize adapted to zoom level */ gridsize= 0.5f*(zoomx+zoomy); - if(gridsize<=0.0f) return; + if (gridsize<=0.0f) return; - if(gridsize<1.0f) { - while(gridsize<1.0f) { + if (gridsize<1.0f) { + while (gridsize<1.0f) { gridsize*= 4.0f; gridstep*= 4.0f; } } else { - while(gridsize>=4.0f) { + while (gridsize>=4.0f) { gridsize/= 4.0f; gridstep/= 4.0f; } @@ -371,7 +371,7 @@ static void draw_image_grid(ARegion *ar, float zoomx, float zoomy) fac= 0.0f; glBegin(GL_LINES); - while(fac<1.0f) { + while (fac<1.0f) { glVertex2f(x1, y1*(1.0f-fac) + y2*fac); glVertex2f(x2, y1*(1.0f-fac) + y2*fac); glVertex2f(x1*(1.0f-fac) + x2*fac, y1); @@ -383,7 +383,7 @@ static void draw_image_grid(ARegion *ar, float zoomx, float zoomy) UI_ThemeColor(TH_BACK); fac= 0.0f; - while(fac<1.0f) { + while (fac<1.0f) { glVertex2f(x1, y1*(1.0f-fac) + y2*fac); glVertex2f(x2, y1*(1.0f-fac) + y2*fac); glVertex2f(x1*(1.0f-fac) + x2*fac, y1); @@ -421,7 +421,7 @@ static void sima_draw_alpha_pixels(float x1, float y1, int rectx, int recty, uns { /* swap bytes, so alpha is most significant one, then just draw it as luminance int */ - if(ENDIAN_ORDER == B_ENDIAN) + if (ENDIAN_ORDER == B_ENDIAN) glPixelStorei(GL_UNPACK_SWAP_BYTES, 1); glaDrawPixelsSafe(x1, y1, rectx, recty, rectx, GL_LUMINANCE, GL_UNSIGNED_INT, recti); @@ -433,7 +433,7 @@ static void sima_draw_alpha_pixelsf(float x1, float y1, int rectx, int recty, fl float *trectf= MEM_mallocN(rectx*recty*4, "temp"); int a, b; - for(a= rectx*recty -1, b= 4*a+3; a>=0; a--, b-=4) + for (a= rectx*recty -1, b= 4*a+3; a>=0; a--, b-=4) trectf[a]= rectf[b]; glaDrawPixelsSafe(x1, y1, rectx, recty, rectx, GL_LUMINANCE, GL_FLOAT, trectf); @@ -473,7 +473,7 @@ static void sima_draw_zbuffloat_pixels(Scene *scene, float x1, float y1, int rec float bias, scale, *rectf, clipend; int a; - if(scene->camera && scene->camera->type==OB_CAMERA) { + if (scene->camera && scene->camera->type==OB_CAMERA) { bias= ((Camera *)scene->camera->data)->clipsta; clipend= ((Camera *)scene->camera->data)->clipend; scale= 1.0f/(clipend-bias); @@ -485,10 +485,10 @@ static void sima_draw_zbuffloat_pixels(Scene *scene, float x1, float y1, int rec } rectf= MEM_mallocN(rectx*recty*4, "temp"); - for(a= rectx*recty -1; a>=0; a--) { - if(rect_float[a]>clipend) + for (a= rectx*recty -1; a>=0; a--) { + if (rect_float[a]>clipend) rectf[a]= 0.0f; - else if(rect_float[a]v2d, fx, fy, &x, &y); /* this part is generic image display */ - if(sima->flag & SI_SHOW_ALPHA) { - if(ibuf->rect) + if (sima->flag & SI_SHOW_ALPHA) { + if (ibuf->rect) sima_draw_alpha_pixels(x, y, ibuf->x, ibuf->y, ibuf->rect); - else if(ibuf->rect_float && ibuf->channels==4) + else if (ibuf->rect_float && ibuf->channels==4) sima_draw_alpha_pixelsf(x, y, ibuf->x, ibuf->y, ibuf->rect_float); } - else if(sima->flag & SI_SHOW_ZBUF && (ibuf->zbuf || ibuf->zbuf_float || (ibuf->channels==1))) { - if(ibuf->zbuf) + else if (sima->flag & SI_SHOW_ZBUF && (ibuf->zbuf || ibuf->zbuf_float || (ibuf->channels==1))) { + if (ibuf->zbuf) sima_draw_zbuf_pixels(x, y, ibuf->x, ibuf->y, ibuf->zbuf); - else if(ibuf->zbuf_float) + else if (ibuf->zbuf_float) sima_draw_zbuffloat_pixels(scene, x, y, ibuf->x, ibuf->y, ibuf->zbuf_float); - else if(ibuf->channels==1) + else if (ibuf->channels==1) sima_draw_zbuffloat_pixels(scene, x, y, ibuf->x, ibuf->y, ibuf->rect_float); } else { - if(sima->flag & SI_USE_ALPHA) { + if (sima->flag & SI_USE_ALPHA) { unsigned char col1[3]= {100, 100, 100}, col2[3]= {160, 160, 160}; sima_draw_alpha_backdrop(x, y, ibuf->x, ibuf->y, zoomx, zoomy, col1, col2); @@ -539,14 +539,14 @@ static void draw_image_buffer(SpaceImage *sima, ARegion *ar, Scene *scene, Image * convert them, and optionally apply curves */ image_verify_buffer_float(ima, ibuf, color_manage); - if(ibuf->rect) + if (ibuf->rect) glaDrawPixelsSafe(x, y, ibuf->x, ibuf->y, ibuf->x, GL_RGBA, GL_UNSIGNED_BYTE, ibuf->rect); #if 0 else glaDrawPixelsSafe(x, y, ibuf->x, ibuf->y, ibuf->x, GL_RGBA, GL_FLOAT, ibuf->rect_float); #endif - if(sima->flag & SI_USE_ALPHA) + if (sima->flag & SI_USE_ALPHA) glDisable(GL_BLEND); } @@ -568,7 +568,7 @@ static unsigned int *get_part_from_ibuf(ImBuf *ibuf, short startx, short starty, rp=rectmain= MEM_mallocN(heigth*len*sizeof(int), "rect"); - for(y=0; yx; rp+= len; @@ -583,12 +583,12 @@ static void draw_image_buffer_tiled(SpaceImage *sima, ARegion *ar, Scene *scene, int color_manage = scene->r.color_mgt_flag & R_COLOR_MANAGEMENT; /* verify valid values, just leave this a while */ - if(ima->xrep<1) return; - if(ima->yrep<1) return; + if (ima->xrep<1) return; + if (ima->yrep<1) return; glPixelZoom(zoomx, zoomy); - if(sima->curtile >= ima->xrep*ima->yrep) + if (sima->curtile >= ima->xrep*ima->yrep) sima->curtile = ima->xrep*ima->yrep - 1; /* create char buffer from float if needed */ @@ -602,8 +602,8 @@ static void draw_image_buffer_tiled(SpaceImage *sima, ARegion *ar, Scene *scene, rect= get_part_from_ibuf(ibuf, sx, sy, sx+dx, sy+dy); /* draw repeated */ - for(sy=0; sy+dy<=ibuf->y; sy+= dy) { - for(sx=0; sx+dx<=ibuf->x; sx+= dx) { + for (sy=0; sy+dy<=ibuf->y; sy+= dy) { + for (sx=0; sx+dx<=ibuf->x; sx+= dx) { UI_view2d_to_region_no_clip(&ar->v2d, fx + (float)sx/(float)ibuf->x, fy + (float)sy/(float)ibuf->y, &x, &y); glaDrawPixelsSafe(x, y, dx, dy, dx, GL_RGBA, GL_UNSIGNED_BYTE, rect); @@ -626,16 +626,16 @@ static void draw_image_buffer_repeated(SpaceImage *sima, ARegion *ar, Scene *sce int x; - for(x=xmin; xtpageflag & IMA_TILES)) + for (y=ymin; ytpageflag & IMA_TILES)) draw_image_buffer_tiled(sima, ar, scene, ima, ibuf, x, y, zoomx, zoomy); else draw_image_buffer(sima, ar, scene, ima, 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; } } @@ -679,15 +679,15 @@ static void draw_image_view_tool(Scene *scene) float radius; int draw= 0; - if(brush) { - if(settings->imapaint.flag & IMAGEPAINT_DRAWING) { - if(settings->imapaint.flag & IMAGEPAINT_DRAW_TOOL_DRAWING) + if (brush) { + if (settings->imapaint.flag & IMAGEPAINT_DRAWING) { + if (settings->imapaint.flag & IMAGEPAINT_DRAW_TOOL_DRAWING) draw= 1; } - else if(settings->imapaint.flag & IMAGEPAINT_DRAW_TOOL) + else if (settings->imapaint.flag & IMAGEPAINT_DRAW_TOOL) draw= 1; - if(draw) { + if (draw) { getmouseco_areawin(mval); radius= brush_size(brush)*G.sima->zoom; @@ -709,16 +709,16 @@ static unsigned char *get_alpha_clone_image(Scene *scene, int *width, int *heigh unsigned int size, alpha; unsigned char *rect, *cp; - if(!brush || !brush->clone.image) + if (!brush || !brush->clone.image) return NULL; ibuf= BKE_image_get_ibuf(brush->clone.image, NULL); - if(!ibuf || !ibuf->rect) + if (!ibuf || !ibuf->rect) return NULL; rect= MEM_dupallocN(ibuf->rect); - if(!rect) + if (!rect) return NULL; *width= ibuf->x; @@ -728,7 +728,7 @@ static unsigned char *get_alpha_clone_image(Scene *scene, int *width, int *heigh alpha= (unsigned char)255*brush->clone.alpha; cp= rect; - while(size-- > 0) { + while (size-- > 0) { cp[3]= alpha; cp += 4; } @@ -744,12 +744,12 @@ static void draw_image_paint_helpers(ARegion *ar, Scene *scene, float zoomx, flo brush= paint_brush(&scene->toolsettings->imapaint.paint); - if(brush && (brush->imagepaint_tool == PAINT_TOOL_CLONE)) { + if (brush && (brush->imagepaint_tool == PAINT_TOOL_CLONE)) { /* this is not very efficient, but glDrawPixels doesn't allow * drawing with alpha */ clonerect= get_alpha_clone_image(scene, &w, &h); - if(clonerect) { + if (clonerect) { UI_view2d_to_region_no_clip(&ar->v2d, brush->clone.offset[0], brush->clone.offset[1], &x, &y); glPixelZoom(zoomx, zoomy); @@ -780,13 +780,13 @@ void draw_image_main(SpaceImage *sima, ARegion *ar, Scene *scene) #if 0 what_image(sima); - if(sima->image) { + if (sima->image) { ED_image_aspect(sima->image, &xuser_asp, &yuser_asp); /* UGLY hack? until now iusers worked fine... but for flipbook viewer we need this */ - if(sima->image->type==IMA_TYPE_COMPOSITE) { + if (sima->image->type==IMA_TYPE_COMPOSITE) { ImageUser *iuser= ntree_get_active_iuser(scene->nodetree); - if(iuser) { + if (iuser) { BKE_image_user_calc_imanr(iuser, scene->r.cfra, 0); sima->iuser= *iuser; } @@ -805,26 +805,26 @@ void draw_image_main(SpaceImage *sima, ARegion *ar, Scene *scene) show_render= (show_viewer && ima->type == IMA_TYPE_R_RESULT); /* draw the image or grid */ - if(ibuf==NULL) + if (ibuf==NULL) draw_image_grid(ar, zoomx, zoomy); - else if(sima->flag & SI_DRAW_TILE) + else if (sima->flag & SI_DRAW_TILE) draw_image_buffer_repeated(sima, ar, scene, ima, ibuf, zoomx, zoomy); - else if(ima && (ima->tpageflag & IMA_TILES)) + else if (ima && (ima->tpageflag & IMA_TILES)) draw_image_buffer_tiled(sima, ar, scene, ima, ibuf, 0.0f, 0.0, zoomx, zoomy); else draw_image_buffer(sima, ar, scene, ima, ibuf, 0.0f, 0.0f, zoomx, zoomy); /* paint helpers */ - if(sima->flag & SI_DRAWTOOL) + if (sima->flag & SI_DRAWTOOL) draw_image_paint_helpers(ar, scene, zoomx, zoomy); /* XXX integrate this code */ #if 0 - if(ibuf) { + if (ibuf) { float xoffs=0.0f, yoffs= 0.0f; - if(image_preview_active(sa, &xim, &yim)) { + if (image_preview_active(sa, &xim, &yim)) { xoffs= scene->r.disprect.xmin; yoffs= scene->r.disprect.ymin; glColor3ub(0,0,0); @@ -839,7 +839,7 @@ void draw_image_main(SpaceImage *sima, ARegion *ar, Scene *scene) ED_space_image_release_buffer(sima, lock); /* render info */ - if(ima && show_render) + if (ima && show_render) draw_render_info(scene, ima, ar); } diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c index 6d4aa63a770..5de0dd3fccd 100644 --- a/source/blender/editors/space_image/image_ops.c +++ b/source/blender/editors/space_image/image_ops.c @@ -96,15 +96,15 @@ static void sima_zoom_set(SpaceImage *sima, ARegion *ar, float zoom, float locat width *= sima->zoom; height *= sima->zoom; - if((width < 4) && (height < 4)) + if ((width < 4) && (height < 4)) sima->zoom= oldzoom; - else if((ar->winrct.xmax - ar->winrct.xmin) <= sima->zoom) + else if ((ar->winrct.xmax - ar->winrct.xmin) <= sima->zoom) sima->zoom= oldzoom; - else if((ar->winrct.ymax - ar->winrct.ymin) <= sima->zoom) + else if ((ar->winrct.ymax - ar->winrct.ymin) <= sima->zoom) sima->zoom= oldzoom; } - if((U.uiflag & USER_ZOOM_TO_MOUSEPOS) && location) { + if ((U.uiflag & USER_ZOOM_TO_MOUSEPOS) && location) { float aspx, aspy, w, h; ED_space_image_size(sima, &width, &height); @@ -133,15 +133,15 @@ static int image_poll(bContext *C) static int space_image_buffer_exists_poll(bContext *C) { SpaceImage *sima= CTX_wm_space_image(C); - if(sima && sima->spacetype==SPACE_IMAGE) - if(ED_space_image_has_buffer(sima)) + if (sima && sima->spacetype==SPACE_IMAGE) + if (ED_space_image_has_buffer(sima)) return 1; return 0; } static int space_image_file_exists_poll(bContext *C) { - if(space_image_buffer_exists_poll(C)) { + if (space_image_buffer_exists_poll(C)) { Main *bmain= CTX_data_main(C); SpaceImage *sima= CTX_wm_space_image(C); ImBuf *ibuf; @@ -150,11 +150,11 @@ static int space_image_file_exists_poll(bContext *C) char name[FILE_MAX]; ibuf= ED_space_image_acquire_buffer(sima, &lock); - if(ibuf) { + if (ibuf) { BLI_strncpy(name, ibuf->name, FILE_MAX); BLI_path_abs(name, bmain->name); - if(BLI_exists(name) == FALSE) { + if (BLI_exists(name) == FALSE) { CTX_wm_operator_poll_msg_set(C, "image file not found"); } else if (BLI_file_is_writable(name) == FALSE) { @@ -174,7 +174,7 @@ static int space_image_file_exists_poll(bContext *C) static int space_image_poll(bContext *C) { SpaceImage *sima= CTX_wm_space_image(C); - if(sima && sima->spacetype==SPACE_IMAGE && sima->image) + if (sima && sima->spacetype==SPACE_IMAGE && sima->image) return 1; return 0; } @@ -184,7 +184,7 @@ int space_image_main_area_poll(bContext *C) SpaceImage *sima= CTX_wm_space_image(C); // XXX ARegion *ar= CTX_wm_region(C); - if(sima) + if (sima) return 1; // XXX (ar && ar->type->regionid == RGN_TYPE_WINDOW); return 0; @@ -196,7 +196,7 @@ int space_image_main_area_not_uv_brush_poll(bContext *C) SpaceImage *sima= CTX_wm_space_image(C); ToolSettings *toolsettings = CTX_data_scene(C)->toolsettings; - if(sima && !toolsettings->uvsculpt) + if (sima && !toolsettings->uvsculpt) return 1; return 0; @@ -208,8 +208,8 @@ static int space_image_image_sample_poll(bContext *C) Object *obedit= CTX_data_edit_object(C); ToolSettings *toolsettings = CTX_data_scene(C)->toolsettings; - if(obedit){ - if(ED_space_image_show_uvedit(sima, obedit) && (toolsettings->use_uv_sculpt)) + if (obedit) { + if (ED_space_image_show_uvedit(sima, obedit) && (toolsettings->use_uv_sculpt)) return 0; } return space_image_main_area_poll(C); @@ -244,7 +244,7 @@ static void image_view_pan_exit(bContext *C, wmOperator *op, int cancel) SpaceImage *sima= CTX_wm_space_image(C); ViewPanData *vpd= op->customdata; - if(cancel) { + if (cancel) { sima->xof= vpd->xof; sima->yof= vpd->yof; ED_region_tag_redraw(CTX_wm_region(C)); @@ -267,7 +267,7 @@ static int image_view_pan_exec(bContext *C, wmOperator *op) /* XXX notifier? */ #if 0 - if(image_preview_active(curarea, NULL, NULL)) { + if (image_preview_active(curarea, NULL, NULL)) { /* recalculates new preview rect */ scrarea_do_windraw(curarea); image_preview_event(2); @@ -312,7 +312,7 @@ static int image_view_pan_modal(bContext *C, wmOperator *op, wmEvent *event) image_view_pan_exec(C, op); break; default: - if(event->type==vpd->event_type && event->val==KM_RELEASE) { + if (event->type==vpd->event_type && event->val==KM_RELEASE) { image_view_pan_exit(C, op, 0); return OPERATOR_FINISHED; } @@ -382,7 +382,7 @@ static void image_view_zoom_exit(bContext *C, wmOperator *op, int cancel) SpaceImage *sima= CTX_wm_space_image(C); ViewZoomData *vpd= op->customdata; - if(cancel) { + if (cancel) { sima->zoom= vpd->zoom; ED_region_tag_redraw(CTX_wm_region(C)); } @@ -402,7 +402,7 @@ static int image_view_zoom_exec(bContext *C, wmOperator *op) /* XXX notifier? */ #if 0 - if(image_preview_active(curarea, NULL, NULL)) { + if (image_preview_active(curarea, NULL, NULL)) { /* recalculates new preview rect */ scrarea_do_windraw(curarea); image_preview_event(2); @@ -449,7 +449,7 @@ static int image_view_zoom_modal(bContext *C, wmOperator *op, wmEvent *event) ED_region_tag_redraw(CTX_wm_region(C)); break; default: - if(event->type==vpd->event_type && event->val==KM_RELEASE) { + if (event->type==vpd->event_type && event->val==KM_RELEASE) { image_view_zoom_exit(C, op, 0); return OPERATOR_FINISHED; } @@ -570,7 +570,7 @@ static int image_view_all_exec(bContext *C, wmOperator *UNUSED(op)) width = ar->winrct.xmax - ar->winrct.xmin + 1; height = ar->winrct.ymax - ar->winrct.ymin + 1; - if((w >= width || h >= height) && (width > 0 && height > 0)) { + if ((w >= width || h >= height) && (width > 0 && height > 0)) { /* find the zoom value that will fit the image in the image space */ zoomx= width/w; zoomy= height/h; @@ -623,7 +623,7 @@ static int image_view_selected_exec(bContext *C, wmOperator *UNUSED(op)) height= height*aspy; /* get bounds */ - if(!ED_uvedit_minmax(scene, ima, obedit, min, max)) + if (!ED_uvedit_minmax(scene, ima, obedit, min, max)) return OPERATOR_CANCELLED; /* adjust offset and zoom */ @@ -634,7 +634,7 @@ static int image_view_selected_exec(bContext *C, wmOperator *UNUSED(op)) d[1]= max[1] - min[1]; size= 0.5f*MAX2(d[0], d[1])*MAX2(width, height)/256.0f; - if(size<=0.01f) size= 0.01f; + if (size<=0.01f) size= 0.01f; sima_zoom_set(sima, ar, 0.7f/size, NULL); ED_region_tag_redraw(CTX_wm_region(C)); @@ -757,7 +757,7 @@ static int image_view_zoom_ratio_exec(bContext *C, wmOperator *op) /* XXX notifier? */ #if 0 - if(image_preview_active(curarea, NULL, NULL)) { + if (image_preview_active(curarea, NULL, NULL)) { /* recalculates new preview rect */ scrarea_do_windraw(curarea); image_preview_event(2); @@ -826,19 +826,19 @@ static int image_open_exec(bContext *C, wmOperator *op) ima= BKE_add_image_file(str); - if(!ima) { - if(op->customdata) MEM_freeN(op->customdata); + if (!ima) { + if (op->customdata) MEM_freeN(op->customdata); BKE_reportf(op->reports, RPT_ERROR, "Can't read: \"%s\", %s", str, errno ? strerror(errno) : "Unsupported image format"); return OPERATOR_CANCELLED; } - if(!op->customdata) + if (!op->customdata) image_open_init(C, op); /* hook into UI */ pprop= op->customdata; - if(pprop->prop) { + if (pprop->prop) { /* when creating new ID blocks, use is already 1, but RNA * pointer se also increases user, so this compensates it */ ima->id.us--; @@ -847,19 +847,19 @@ static int image_open_exec(bContext *C, wmOperator *op) RNA_property_pointer_set(&pprop->ptr, pprop->prop, idptr); RNA_property_update(C, &pprop->ptr, pprop->prop); } - else if(sima) { + else if (sima) { ED_space_image_set(sima, scene, obedit, ima); iuser= &sima->iuser; } else { Tex *tex= CTX_data_pointer_get_type(C, "texture", &RNA_Texture).data; - if(tex && tex->type==TEX_IMAGE) + if (tex && tex->type==TEX_IMAGE) iuser= &tex->iuser; } /* initialize because of new image */ - if(iuser) { + if (iuser) { iuser->sfra= 1; iuser->offset= 0; iuser->fie_ima= 2; @@ -882,20 +882,20 @@ static int image_open_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event) char *path=U.textudir; Image *ima= NULL; - if(sima) { + if (sima) { ima= sima->image; } 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) + 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); @@ -932,7 +932,7 @@ 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); @@ -958,13 +958,13 @@ static int image_replace_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(eve { 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", (strncmp(sima->image->name, "//", 2))==0); image_filesel(C, op, sima->image->name); @@ -1035,13 +1035,13 @@ static int save_image_options_init(SaveImageOptions *simopts, SpaceImage *sima, void *lock; ImBuf *ibuf= ED_space_image_acquire_buffer(sima, &lock); - if(ibuf) { + if (ibuf) { Image *ima= sima->image; short is_depth_set= FALSE; simopts->im_format.planes= ibuf->planes; - if(ELEM(ima->type, IMA_TYPE_R_RESULT, IMA_TYPE_COMPOSITE)) { + if (ELEM(ima->type, IMA_TYPE_R_RESULT, IMA_TYPE_COMPOSITE)) { /* imtype */ simopts->im_format= scene->r.im_format; is_depth_set= TRUE; @@ -1075,10 +1075,11 @@ static int save_image_options_init(SaveImageOptions *simopts, SpaceImage *sima, } /* check for empty path */ - if(guess_path && simopts->filepath[0]==0) { + if (guess_path && simopts->filepath[0]==0) { if ( (G.ima[0] == '/') && (G.ima[1] == '/') && (G.ima[2] == '\0') ) { BLI_strncpy(simopts->filepath, "//untitled", FILE_MAX); - } else { + } + else { BLI_strncpy(simopts->filepath, G.ima, FILE_MAX); } BLI_path_abs(simopts->filepath, G.main->name); @@ -1130,27 +1131,27 @@ static void save_image_doit(bContext *C, SpaceImage *sima, wmOperator *op, SaveI WM_cursor_wait(1); - if(ima->type == IMA_TYPE_R_RESULT) { + if (ima->type == IMA_TYPE_R_RESULT) { /* enforce user setting for RGB or RGBA, but skip BW */ - if(simopts->im_format.planes==R_IMF_PLANES_RGBA) { + if (simopts->im_format.planes==R_IMF_PLANES_RGBA) { ibuf->planes= R_IMF_PLANES_RGBA; } - else if(simopts->im_format.planes==R_IMF_PLANES_RGB) { + else if (simopts->im_format.planes==R_IMF_PLANES_RGB) { ibuf->planes= R_IMF_PLANES_RGB; } } else { /* TODO, better solution, if a 24bit image is painted onto it may contain alpha */ - if(ibuf->userflags & IB_BITMAPDIRTY) { /* it has been painted onto */ + if (ibuf->userflags & IB_BITMAPDIRTY) { /* it has been painted onto */ /* checks each pixel, not ideal */ ibuf->planes= BKE_alphatest_ibuf(ibuf) ? 32 : 24; } } - if(simopts->im_format.imtype==R_IMF_IMTYPE_MULTILAYER) { + if (simopts->im_format.imtype==R_IMF_IMTYPE_MULTILAYER) { Scene *scene= CTX_data_scene(C); RenderResult *rr= BKE_image_acquire_renderresult(scene, ima); - if(rr) { + if (rr) { RE_WriteRenderResult(op->reports, rr, simopts->filepath, simopts->im_format.quality); ok= TRUE; } @@ -1166,8 +1167,8 @@ static void save_image_doit(bContext *C, SpaceImage *sima, wmOperator *op, SaveI } if (ok) { - if(!save_copy) { - if(do_newpath) { + if (!save_copy) { + if (do_newpath) { BLI_strncpy(ibuf->name, simopts->filepath, sizeof(ibuf->name)); BLI_strncpy(ima->name, simopts->filepath, sizeof(ima->name)); } @@ -1175,28 +1176,28 @@ static void save_image_doit(bContext *C, SpaceImage *sima, wmOperator *op, SaveI ibuf->userflags &= ~IB_BITMAPDIRTY; /* change type? */ - if(ima->type==IMA_TYPE_R_RESULT) { + if (ima->type==IMA_TYPE_R_RESULT) { ima->type= IMA_TYPE_IMAGE; /* 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)) { + if ( ELEM(ima->source, IMA_SRC_GENERATED, IMA_SRC_VIEWER)) { ima->source= IMA_SRC_FILE; ima->type= IMA_TYPE_IMAGE; } /* only image path, never ibuf */ - if(relative) { + if (relative) { BLI_path_rel(ima->name, relbase); /* only after saving */ } } @@ -1247,7 +1248,7 @@ static int image_save_as_check(bContext *UNUSED(C), wmOperator *op) ImageFormatData *imf= op->customdata; char filepath[FILE_MAX]; RNA_string_get(op->ptr, "filepath", filepath); - if(BKE_add_image_extension(filepath, imf->imtype)) { + if (BKE_add_image_extension(filepath, imf->imtype)) { RNA_string_set(op->ptr, "filepath", filepath); return TRUE; } @@ -1261,7 +1262,7 @@ static int image_save_as_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(eve Scene *scene= CTX_data_scene(C); SaveImageOptions simopts; - 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); if (save_image_options_init(&simopts, sima, scene, TRUE) == 0) @@ -1269,7 +1270,7 @@ static int image_save_as_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(eve save_image_options_to_op(&simopts, op); /* enable save_copy by default for render results */ - if(ELEM(ima->type, IMA_TYPE_R_RESULT, IMA_TYPE_COMPOSITE) && !RNA_struct_property_is_set(op->ptr, "copy")) { + if (ELEM(ima->type, IMA_TYPE_R_RESULT, IMA_TYPE_COMPOSITE) && !RNA_struct_property_is_set(op->ptr, "copy")) { RNA_boolean_set(op->ptr, "copy", TRUE); } @@ -1387,32 +1388,32 @@ static int image_save_sequence_exec(bContext *C, wmOperator *op) int tot= 0; char di[FILE_MAX], fi[FILE_MAX]; - if(sima->image==NULL) + if (sima->image==NULL) return OPERATOR_CANCELLED; - if(sima->image->source!=IMA_SRC_SEQUENCE) { + if (sima->image->source!=IMA_SRC_SEQUENCE) { BKE_report(op->reports, RPT_ERROR, "Can only save sequence on image sequences"); return OPERATOR_CANCELLED; } - if(sima->image->type==IMA_TYPE_MULTILAYER) { + if (sima->image->type==IMA_TYPE_MULTILAYER) { BKE_report(op->reports, RPT_ERROR, "Can't save multilayer sequences"); return OPERATOR_CANCELLED; } /* get total */ - for(ibuf= sima->image->ibufs.first; ibuf; ibuf= ibuf->next) - if(ibuf->userflags & IB_BITMAPDIRTY) + for (ibuf= sima->image->ibufs.first; ibuf; ibuf= ibuf->next) + if (ibuf->userflags & IB_BITMAPDIRTY) tot++; - if(tot==0) { + if (tot==0) { BKE_report(op->reports, RPT_WARNING, "No images have been changed"); return OPERATOR_CANCELLED; } /* get a filename for menu */ - for(ibuf= sima->image->ibufs.first; ibuf; ibuf= ibuf->next) - if(ibuf->userflags & IB_BITMAPDIRTY) + for (ibuf= sima->image->ibufs.first; ibuf; ibuf= ibuf->next) + if (ibuf->userflags & IB_BITMAPDIRTY) break; BLI_strncpy(di, ibuf->name, FILE_MAX); @@ -1420,14 +1421,14 @@ static int image_save_sequence_exec(bContext *C, wmOperator *op) BKE_reportf(op->reports, RPT_INFO, "%d Image(s) will be saved in %s", tot, di); - for(ibuf= sima->image->ibufs.first; ibuf; ibuf= ibuf->next) { - if(ibuf->userflags & IB_BITMAPDIRTY) { + for (ibuf= sima->image->ibufs.first; ibuf; ibuf= ibuf->next) { + if (ibuf->userflags & IB_BITMAPDIRTY) { char name[FILE_MAX]; BLI_strncpy(name, ibuf->name, sizeof(name)); BLI_path_abs(name, bmain->name); - if(0 == IMB_saveiff(ibuf, name, IB_rect | IB_zbuf | IB_zbuffloat)) { + if (0 == IMB_saveiff(ibuf, name, IB_rect | IB_zbuf | IB_zbuffloat)) { BKE_reportf(op->reports, RPT_ERROR, "Could not write image %s", name); break; } @@ -1461,7 +1462,7 @@ 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 */ @@ -1518,18 +1519,18 @@ static int image_new_exec(bContext *C, wmOperator *op) if (!floatbuf && scene->r.color_mgt_flag & R_COLOR_MANAGEMENT) linearrgb_to_srgb_v3_v3(color, color); - if(!alpha) + if (!alpha) color[3]= 1.0f; ima = BKE_add_image_size(width, height, name, alpha ? 32 : 24, floatbuf, uvtestgrid, color); - if(!ima) + if (!ima) return OPERATOR_CANCELLED; /* hook into UI */ uiIDContextProperty(C, &ptr, &prop); - if(prop) { + if (prop) { /* when creating new ID blocks, use is already 1, but RNA * pointer se also increases user, so this compensates it */ ima->id.us--; @@ -1538,7 +1539,7 @@ static int image_new_exec(bContext *C, wmOperator *op) RNA_property_pointer_set(&ptr, prop, idptr); RNA_property_update(C, &ptr, prop); } - else if(sima) + else if (sima) ED_space_image_set(sima, scene, obedit, ima); // XXX other users? @@ -1589,7 +1590,7 @@ static int image_invert_poll(bContext *C) Image *ima= CTX_data_edit_image(C); ImBuf *ibuf= BKE_image_get_ibuf(ima, NULL); - if( ibuf != NULL ) + if ( ibuf != NULL ) return 1; return 0; } @@ -1607,32 +1608,32 @@ static int image_invert_exec(bContext *C, wmOperator *op) int i; - if( ibuf == NULL) // TODO: this should actually never happen, but does for render-results -> cleanup + if ( ibuf == NULL) // TODO: this should actually never happen, but does for render-results -> cleanup return OPERATOR_CANCELLED; /* TODO: make this into an IMB_invert_channels(ibuf,r,g,b,a) method!? */ if (ibuf->rect_float) { float *fp = (float *) ibuf->rect_float; - for( i = 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]; + for ( i = 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(ibuf->rect) { + if (ibuf->rect) { IMB_rect_from_float(ibuf); } } - else if(ibuf->rect) { + else if (ibuf->rect) { char *cp = (char *) ibuf->rect; - for( i = 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]; + for ( i = 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]; } } else { @@ -1640,7 +1641,7 @@ static int image_invert_exec(bContext *C, wmOperator *op) } ibuf->userflags |= IB_BITMAPDIRTY; - if(ibuf->mipmap[0]) + if (ibuf->mipmap[0]) ibuf->userflags |= IB_MIPMAP_INVALID; WM_event_add_notifier(C, NC_IMAGE|NA_EDITED, ima); @@ -1674,12 +1675,12 @@ static int image_pack_test(bContext *C, wmOperator *op) Image *ima= CTX_data_edit_image(C); int as_png= RNA_boolean_get(op->ptr, "as_png"); - if(!ima) + if (!ima) return 0; - if(!as_png && ima->packedfile) + if (!as_png && ima->packedfile) return 0; - if(ima->source==IMA_SRC_SEQUENCE || ima->source==IMA_SRC_MOVIE) { + if (ima->source==IMA_SRC_SEQUENCE || ima->source==IMA_SRC_MOVIE) { BKE_report(op->reports, RPT_ERROR, "Packing movies or image sequences not supported"); return 0; } @@ -1694,15 +1695,15 @@ static int image_pack_exec(bContext *C, wmOperator *op) ImBuf *ibuf= BKE_image_get_ibuf(ima, NULL); int 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))) { + if (!as_png && (ibuf && (ibuf->userflags & IB_BITMAPDIRTY))) { BKE_report(op->reports, RPT_ERROR, "Can't pack edited image from disk, only as internal PNG"); return OPERATOR_CANCELLED; } - if(as_png) + if (as_png) BKE_image_memorypack(ima); else ima->packedfile= newPackedFile(op->reports, ima->name, ID_BLEND_PATH(bmain, &ima->id)); @@ -1720,10 +1721,10 @@ static int image_pack_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event) uiLayout *layout; int 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))) { + if (!as_png && (ibuf && (ibuf->userflags & IB_BITMAPDIRTY))) { pup= uiPupMenuBegin(C, "OK", ICON_QUESTION); layout= uiPupMenuLayout(pup); uiItemBooleanO(layout, "Can't pack edited image from disk. Pack as internal PNG?", ICON_NONE, op->idname, "as_png", 1); @@ -1768,15 +1769,15 @@ static int image_unpack_exec(bContext *C, wmOperator *op) if (!ima) ima = CTX_data_edit_image(C); } - if(!ima || !ima->packedfile) + if (!ima || !ima->packedfile) return OPERATOR_CANCELLED; - if(ima->source==IMA_SRC_SEQUENCE || ima->source==IMA_SRC_MOVIE) { + 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_AUTOPACK) + if (G.fileflags & G_AUTOPACK) BKE_report(op->reports, RPT_WARNING, "AutoPack is enabled, so image will be packed again on file save"); /* XXX unpackImage frees image buffers */ @@ -1793,18 +1794,18 @@ static int image_unpack_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(even { 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 || !ima->packedfile) + if (!ima || !ima->packedfile) return OPERATOR_CANCELLED; - if(ima->source==IMA_SRC_SEQUENCE || ima->source==IMA_SRC_MOVIE) { + 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_AUTOPACK) + if (G.fileflags & G_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", ima->packedfile); @@ -1855,7 +1856,7 @@ typedef struct ImageSampleInfo { static void image_sample_draw(const bContext *UNUSED(C), ARegion *ar, void *arg_info) { ImageSampleInfo *info= arg_info; - if(info->draw) { + if (info->draw) { /* no color management needed for images (color_manage=0) */ ED_image_draw_info(ar, 0, info->channels, info->x, info->y, info->colp, info->colfp, info->zp, info->zfp); } @@ -1870,14 +1871,14 @@ static void image_sample_apply(bContext *C, wmOperator *op, wmEvent *event) ImageSampleInfo *info= op->customdata; float fx, fy; - if(ibuf == NULL) { + if (ibuf == NULL) { ED_space_image_release_buffer(sima, lock); return; } UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], &fx, &fy); - if(fx>=0.0f && fy>=0.0f && fx<1.0f && fy<1.0f) { + if (fx>=0.0f && fy>=0.0f && fx<1.0f && fy<1.0f) { float *fp; unsigned char *cp; int x= (int)(fx*ibuf->x), y= (int)(fy*ibuf->y); @@ -1895,7 +1896,7 @@ static void image_sample_apply(bContext *C, wmOperator *op, wmEvent *event) info->zp= NULL; info->zfp= NULL; - if(ibuf->rect) { + if (ibuf->rect) { cp= (unsigned char *)(ibuf->rect + y*ibuf->x + x); info->col[0]= cp[0]; @@ -1910,7 +1911,7 @@ static void image_sample_apply(bContext *C, wmOperator *op, wmEvent *event) info->colf[3]= (float)cp[3]/255.0f; info->colfp= info->colf; } - if(ibuf->rect_float) { + if (ibuf->rect_float) { fp= (ibuf->rect_float + (ibuf->channels)*(y*ibuf->x + x)); info->colf[0]= fp[0]; @@ -1920,28 +1921,28 @@ static void image_sample_apply(bContext *C, wmOperator *op, wmEvent *event) info->colfp= info->colf; } - if(ibuf->zbuf) { + if (ibuf->zbuf) { info->z= ibuf->zbuf[y*ibuf->x + x]; info->zp= &info->z; } - if(ibuf->zbuf_float) { + if (ibuf->zbuf_float) { info->zf= ibuf->zbuf_float[y*ibuf->x + x]; info->zfp= &info->zf; } - if(sima->cumap && ibuf->channels==4) { + if (sima->cumap && ibuf->channels==4) { /* we reuse this callback for set curves point operators */ - if(RNA_struct_find_property(op->ptr, "point")) { + if (RNA_struct_find_property(op->ptr, "point")) { int point= RNA_enum_get(op->ptr, "point"); - if(point == 1) { + if (point == 1) { curvemapping_set_black_white(sima->cumap, NULL, info->colfp); - if(ibuf->rect_float) + if (ibuf->rect_float) curvemapping_do_ibuf(sima->cumap, ibuf); } - else if(point == 0) { + else if (point == 0) { curvemapping_set_black_white(sima->cumap, info->colfp, NULL); - if(ibuf->rect_float) + if (ibuf->rect_float) curvemapping_do_ibuf(sima->cumap, ibuf); } } @@ -1953,8 +1954,8 @@ static void image_sample_apply(bContext *C, wmOperator *op, wmEvent *event) ScrArea *sa, *cur= curarea; node_curvemap_sample(fp); /* sends global to node editor */ - for(sa= G.curscreen->areabase.first; sa; sa= sa->next) { - if(sa->spacetype==SPACE_NODE) { + for (sa= G.curscreen->areabase.first; sa; sa= sa->next) { + if (sa->spacetype==SPACE_NODE) { areawinset(sa->win); scrarea_do_windraw(sa); } @@ -1986,7 +1987,7 @@ static int image_sample_invoke(bContext *C, wmOperator *op, wmEvent *event) ARegion *ar= CTX_wm_region(C); ImageSampleInfo *info; - if(!ED_space_image_has_buffer(sima)) + if (!ED_space_image_has_buffer(sima)) return OPERATOR_CANCELLED; info= MEM_callocN(sizeof(ImageSampleInfo), "ImageSampleInfo"); @@ -2089,7 +2090,8 @@ static int image_sample_line_exec(bContext *C, wmOperator *op) if (x<0 || y<0 || x>=ibuf->x || y>=ibuf->y) { hist->data_luma[i] = hist->data_r[i] = hist->data_g[i]= hist->data_b[i] = 0.0f; - } else { + } + else { if (ibuf->rect_float) { fp= (ibuf->rect_float + (ibuf->channels)*(y*ibuf->x + x)); @@ -2124,7 +2126,7 @@ static int image_sample_line_invoke(bContext *C, wmOperator *op, wmEvent *event) { SpaceImage *sima= CTX_wm_space_image(C); - 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); @@ -2203,7 +2205,7 @@ static int image_record_composite_apply(bContext *C, wmOperator *op) ibuf= BKE_image_get_ibuf(sima->image, &sima->iuser); /* save memory in flipbooks */ - if(ibuf) + if (ibuf) imb_freerectfloatImBuf(ibuf); scene->r.cfra++; @@ -2217,9 +2219,9 @@ static int image_record_composite_init(bContext *C, wmOperator *op) Scene *scene= CTX_data_scene(C); RecordCompositeData *rcd; - if(sima->iuser.frames < 2) + if (sima->iuser.frames < 2) return 0; - if(scene->nodetree == NULL) + if (scene->nodetree == NULL) return 0; op->customdata= rcd= MEM_callocN(sizeof(RecordCompositeData), "ImageRecordCompositeData"); @@ -2242,7 +2244,7 @@ static void image_record_composite_exit(bContext *C, wmOperator *op) WM_cursor_restore(CTX_wm_window(C)); - if(rcd->timer) + if (rcd->timer) WM_event_remove_timer(CTX_wm_manager(C), CTX_wm_window(C), rcd->timer); WM_event_add_notifier(C, NC_IMAGE|NA_EDITED, sima->image); @@ -2255,7 +2257,7 @@ static void image_record_composite_exit(bContext *C, wmOperator *op) static int image_record_composite_exec(bContext *C, wmOperator *op) { - if(!image_record_composite_init(C, op)) + if (!image_record_composite_init(C, op)) return OPERATOR_CANCELLED; while(image_record_composite_apply(C, op)) @@ -2270,14 +2272,14 @@ static int image_record_composite_invoke(bContext *C, wmOperator *op, wmEvent *U { RecordCompositeData *rcd; - if(!image_record_composite_init(C, op)) + if (!image_record_composite_init(C, op)) return OPERATOR_CANCELLED; rcd= op->customdata; rcd->timer= WM_event_add_timer(CTX_wm_manager(C), CTX_wm_window(C), TIMER, 0.0f); WM_event_add_modal_handler(C, op); - if(!image_record_composite_apply(C, op)) + if (!image_record_composite_apply(C, op)) return OPERATOR_FINISHED; return OPERATOR_RUNNING_MODAL; @@ -2289,8 +2291,8 @@ static int image_record_composite_modal(bContext *C, wmOperator *op, wmEvent *ev switch(event->type) { case TIMER: - if(rcd->timer == event->customdata) { - if(!image_record_composite_apply(C, op)) { + if (rcd->timer == event->customdata) { + if (!image_record_composite_apply(C, op)) { image_record_composite_exit(C, op); return OPERATOR_FINISHED; } @@ -2339,27 +2341,27 @@ static int image_cycle_render_slot_exec(bContext *C, wmOperator *op) int a, slot, cur= ima->render_slot; const short use_reverse= RNA_boolean_get(op->ptr, "reverse"); - for(a=1; arenders[slot] || slot == ima->last_render_slot) { + if (ima->renders[slot] || slot == ima->last_render_slot) { ima->render_slot= slot; break; } - else if((slot - 1) == ima->last_render_slot && slot < IMA_MAX_RENDER_SLOT) { + else if ((slot - 1) == ima->last_render_slot && slot < IMA_MAX_RENDER_SLOT) { ima->render_slot= slot; break; } } - if(a == IMA_MAX_RENDER_SLOT) + if (a == IMA_MAX_RENDER_SLOT) ima->render_slot= ((cur == 1)? 0: 1); WM_event_add_notifier(C, NC_IMAGE|ND_DRAW, NULL); /* no undo push for browsing existing */ - if(ima->renders[ima->render_slot] || ima->render_slot==ima->last_render_slot) + if (ima->renders[ima->render_slot] || ima->render_slot==ima->last_render_slot) return OPERATOR_CANCELLED; return OPERATOR_FINISHED; @@ -2394,42 +2396,42 @@ void ED_image_update_frame(const Main *mainp, int cfra) Tex *tex; /* texture users */ - for(tex= mainp->tex.first; tex; tex= tex->id.next) { - if(tex->type==TEX_IMAGE && tex->ima) { - if(ELEM(tex->ima->source, IMA_SRC_MOVIE, IMA_SRC_SEQUENCE)) { - if(tex->iuser.flag & IMA_ANIM_ALWAYS) + for (tex= mainp->tex.first; tex; tex= tex->id.next) { + if (tex->type==TEX_IMAGE && tex->ima) { + if (ELEM(tex->ima->source, IMA_SRC_MOVIE, IMA_SRC_SEQUENCE)) { + if (tex->iuser.flag & IMA_ANIM_ALWAYS) BKE_image_user_calc_frame(&tex->iuser, cfra, 0); } } } /* image window, compo node users */ - for(wm=mainp->wm.first; wm; wm= wm->id.next) { /* only 1 wm */ - for(win= wm->windows.first; win; win= win->next) { + for (wm=mainp->wm.first; wm; wm= wm->id.next) { /* only 1 wm */ + for (win= wm->windows.first; win; win= win->next) { ScrArea *sa; - for(sa= win->screen->areabase.first; sa; sa= sa->next) { - if(sa->spacetype==SPACE_VIEW3D) { + for (sa= win->screen->areabase.first; sa; sa= sa->next) { + if (sa->spacetype==SPACE_VIEW3D) { View3D *v3d= sa->spacedata.first; BGpic *bgpic; - for(bgpic= v3d->bgpicbase.first; bgpic; bgpic= bgpic->next) - if(bgpic->iuser.flag & IMA_ANIM_ALWAYS) + for (bgpic= v3d->bgpicbase.first; bgpic; bgpic= bgpic->next) + if (bgpic->iuser.flag & IMA_ANIM_ALWAYS) BKE_image_user_calc_frame(&bgpic->iuser, cfra, 0); } - else if(sa->spacetype==SPACE_IMAGE) { + else if (sa->spacetype==SPACE_IMAGE) { SpaceImage *sima= sa->spacedata.first; - if(sima->iuser.flag & IMA_ANIM_ALWAYS) + if (sima->iuser.flag & IMA_ANIM_ALWAYS) BKE_image_user_calc_frame(&sima->iuser, cfra, 0); } - else if(sa->spacetype==SPACE_NODE) { + else if (sa->spacetype==SPACE_NODE) { SpaceNode *snode= sa->spacedata.first; - if((snode->treetype==NTREE_COMPOSIT) && (snode->nodetree)) { + if ((snode->treetype==NTREE_COMPOSIT) && (snode->nodetree)) { bNode *node; - for(node= snode->nodetree->nodes.first; node; node= node->next) { - if(node->id && node->type==CMP_NODE_IMAGE) { + for (node= snode->nodetree->nodes.first; node; node= node->next) { + if (node->id && node->type==CMP_NODE_IMAGE) { Image *ima= (Image *)node->id; ImageUser *iuser= node->storage; - if(ELEM(ima->source, IMA_SRC_MOVIE, IMA_SRC_SEQUENCE)) - if(iuser->flag & IMA_ANIM_ALWAYS) + if (ELEM(ima->source, IMA_SRC_MOVIE, IMA_SRC_SEQUENCE)) + if (iuser->flag & IMA_ANIM_ALWAYS) BKE_image_user_calc_frame(iuser, cfra, 0); } } diff --git a/source/blender/editors/space_image/space_image.c b/source/blender/editors/space_image/space_image.c index 5005e0de9c5..f1967477d7a 100644 --- a/source/blender/editors/space_image/space_image.c +++ b/source/blender/editors/space_image/space_image.c @@ -92,16 +92,16 @@ void ED_space_image_set(SpaceImage *sima, Scene *scene, Object *obedit, Image *i * to check if the face is displayed in UV-localview */ sima->image= ima; - if(ima == NULL || ima->type==IMA_TYPE_R_RESULT || ima->type==IMA_TYPE_COMPOSITE) + if (ima == NULL || ima->type==IMA_TYPE_R_RESULT || ima->type==IMA_TYPE_COMPOSITE) sima->flag &= ~SI_DRAWTOOL; - if(sima->image) + if (sima->image) BKE_image_signal(sima->image, &sima->iuser, IMA_SIGNAL_USER_NEW_IMAGE); - if(sima->image && sima->image->id.us==0) + if (sima->image && sima->image->id.us==0) sima->image->id.us= 1; - if(obedit) + if (obedit) WM_main_add_notifier(NC_GEOM|ND_DATA, obedit->data); WM_main_add_notifier(NC_SPACE|ND_SPACE_IMAGE, NULL); @@ -111,15 +111,15 @@ ImBuf *ED_space_image_acquire_buffer(SpaceImage *sima, void **lock_r) { ImBuf *ibuf; - if(sima && sima->image) { + if (sima && sima->image) { #if 0 - if(sima->image->type==IMA_TYPE_R_RESULT && BIF_show_render_spare()) + if (sima->image->type==IMA_TYPE_R_RESULT && BIF_show_render_spare()) return BIF_render_spare_imbuf(); else #endif ibuf= BKE_image_acquire_ibuf(sima->image, &sima->iuser, lock_r); - if(ibuf && (ibuf->rect || ibuf->rect_float)) + if (ibuf && (ibuf->rect || ibuf->rect_float)) return ibuf; } @@ -128,7 +128,7 @@ ImBuf *ED_space_image_acquire_buffer(SpaceImage *sima, void **lock_r) void ED_space_image_release_buffer(SpaceImage *sima, void *lock) { - if(sima && sima->image) + if (sima && sima->image) BKE_image_release_ibuf(sima->image, lock); } @@ -150,10 +150,10 @@ void ED_image_size(Image *ima, int *width, int *height) ImBuf *ibuf= NULL; void *lock; - if(ima) + if (ima) ibuf= BKE_image_acquire_ibuf(ima, NULL, &lock); - if(ibuf && ibuf->x > 0 && ibuf->y > 0) { + if (ibuf && ibuf->x > 0 && ibuf->y > 0) { *width= ibuf->x; *height= ibuf->y; } @@ -162,7 +162,7 @@ void ED_image_size(Image *ima, int *width, int *height) *height= 256; } - if(ima) + if (ima) BKE_image_release_ibuf(ima, lock); } @@ -174,23 +174,23 @@ void ED_space_image_size(SpaceImage *sima, int *width, int *height) ibuf= ED_space_image_acquire_buffer(sima, &lock); - if(ibuf && ibuf->x > 0 && ibuf->y > 0) { + if (ibuf && ibuf->x > 0 && ibuf->y > 0) { *width= ibuf->x; *height= ibuf->y; } - else if(sima->image && sima->image->type==IMA_TYPE_R_RESULT && scene) { + else if (sima->image && sima->image->type==IMA_TYPE_R_RESULT && scene) { /* not very important, just nice */ *width= (scene->r.xsch*scene->r.size)/100; *height= (scene->r.ysch*scene->r.size)/100; - if((scene->r.mode & R_BORDER) && (scene->r.mode & R_CROP)) { + if ((scene->r.mode & R_BORDER) && (scene->r.mode & R_CROP)) { *width *= (scene->r.border.xmax - scene->r.border.xmin); *height *= (scene->r.border.ymax - scene->r.border.ymin); } } /* I know a bit weak... but preview uses not actual image size */ - // XXX else if(image_preview_active(sima, width, height)); + // XXX else if (image_preview_active(sima, width, height)); else { *width= 256; *height= 256; @@ -203,7 +203,7 @@ void ED_image_aspect(Image *ima, float *aspx, float *aspy) { *aspx= *aspy= 1.0; - if((ima == NULL) || (ima->type == IMA_TYPE_R_RESULT) || (ima->type == IMA_TYPE_COMPOSITE) || + if ((ima == NULL) || (ima->type == IMA_TYPE_R_RESULT) || (ima->type == IMA_TYPE_COMPOSITE) || (ima->aspx==0.0f || ima->aspy==0.0f)) return; @@ -236,7 +236,7 @@ void ED_space_image_uv_aspect(SpaceImage *sima, float *aspx, float *aspy) *aspx *= (float)w; *aspy *= (float)h; - if(*aspx < *aspy) { + if (*aspx < *aspy) { *aspy= *aspy / *aspx; *aspx= 1.0f; } @@ -264,7 +264,7 @@ int ED_space_image_show_render(SpaceImage *sima) int ED_space_image_show_paint(SpaceImage *sima) { - if(ED_space_image_show_render(sima)) + if (ED_space_image_show_render(sima)) return 0; return (sima->flag & SI_DRAWTOOL); @@ -272,10 +272,10 @@ int ED_space_image_show_paint(SpaceImage *sima) int ED_space_image_show_uvedit(SpaceImage *sima, Object *obedit) { - if(sima && (ED_space_image_show_render(sima) || ED_space_image_show_paint(sima))) + if (sima && (ED_space_image_show_render(sima) || ED_space_image_show_paint(sima))) return 0; - if(obedit && obedit->type == OB_MESH) { + if (obedit && obedit->type == OB_MESH) { struct BMEditMesh *em = BMEdit_FromObject(obedit); int ret; @@ -289,11 +289,11 @@ int ED_space_image_show_uvedit(SpaceImage *sima, Object *obedit) int ED_space_image_show_uvshadow(SpaceImage *sima, Object *obedit) { - if(ED_space_image_show_render(sima)) + if (ED_space_image_show_render(sima)) return 0; - if(ED_space_image_show_paint(sima)) - if(obedit && obedit->type == OB_MESH) { + if (ED_space_image_show_paint(sima)) + if (obedit && obedit->type == OB_MESH) { struct BMEditMesh *em = BMEdit_FromObject(obedit); int ret; @@ -328,13 +328,13 @@ 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"); @@ -352,13 +352,13 @@ ARegion *image_has_scope_region(ScrArea *sa) ARegion *ar, *arnew; ar= BKE_area_find_region_type(sa, RGN_TYPE_PREVIEW); - 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"); @@ -429,7 +429,7 @@ static void image_free(SpaceLink *sl) { SpaceImage *simage= (SpaceImage*) sl; - if(simage->cumap) + if (simage->cumap) curvemapping_free(simage->cumap); scopes_free(&simage->scopes); } @@ -450,7 +450,7 @@ static SpaceLink *image_duplicate(SpaceLink *sl) SpaceImage *simagen= MEM_dupallocN(sl); /* clear or remove stuff from old */ - if(simagen->cumap) + if (simagen->cumap) simagen->cumap= curvemapping_copy(simagen->cumap); scopes_new(&simagen->scopes); @@ -548,8 +548,8 @@ static void image_keymap(struct wmKeyConfig *keyconf) /* dropboxes */ static int image_drop_poll(bContext *UNUSED(C), wmDrag *drag, wmEvent *UNUSED(event)) { - if(drag->type==WM_DRAG_PATH) - if(ELEM3(drag->icon, 0, ICON_FILE_IMAGE, ICON_FILE_BLANK)) /* rule might not work? */ + if (drag->type==WM_DRAG_PATH) + if (ELEM3(drag->icon, 0, ICON_FILE_IMAGE, ICON_FILE_BLANK)) /* rule might not work? */ return 1; return 0; } @@ -579,25 +579,25 @@ static void image_refresh(const bContext *C, ScrArea *UNUSED(sa)) ima= ED_space_image(sima); - if(sima->iuser.flag & IMA_ANIM_ALWAYS) + if (sima->iuser.flag & IMA_ANIM_ALWAYS) BKE_image_user_calc_frame(&sima->iuser, scene->r.cfra, 0); /* check if we have to set the image from the editmesh */ - if(ima && (ima->source==IMA_SRC_VIEWER || sima->pin)); - else if(obedit && obedit->type == OB_MESH) { + if (ima && (ima->source==IMA_SRC_VIEWER || sima->pin)); + else if (obedit && obedit->type == OB_MESH) { Mesh *me= (Mesh*)obedit->data; struct BMEditMesh *em= me->edit_btmesh; int sloppy= 1; /* partially selected face is ok */ - if(scene_use_new_shading_nodes(scene)) { + if (scene_use_new_shading_nodes(scene)) { /* new shading system, get image from material */ BMFace *efa = BM_active_face_get(em->bm, sloppy); - if(efa) { + if (efa) { Image *node_ima; ED_object_get_active_image(obedit, efa->mat_nr, &node_ima, NULL, NULL); - if(node_ima) + if (node_ima) sima->image= node_ima; } } @@ -605,16 +605,16 @@ static void image_refresh(const bContext *C, ScrArea *UNUSED(sa)) /* old shading system, we set texface */ MTexPoly *tf; - if(em && EDBM_texFaceCheck(em)) { + if (em && EDBM_texFaceCheck(em)) { sima->image= NULL; tf = EDBM_get_active_mtexpoly(em, NULL, TRUE); /* partially selected face is ok */ - if(tf) { + if (tf) { /* don't need to check for pin here, see above */ sima->image= tf->tpage; - if(sima->flag & SI_EDITTILE); + if (sima->flag & SI_EDITTILE); else sima->curtile= tf->tile; } } @@ -653,7 +653,7 @@ static void image_listener(ScrArea *sa, wmNotifier *wmn) } break; case NC_SPACE: - if(wmn->data == ND_SPACE_IMAGE) { + if (wmn->data == ND_SPACE_IMAGE) { image_scopes_tag_refresh(sa); ED_area_tag_redraw(sa); } @@ -673,7 +673,7 @@ static void image_listener(ScrArea *sa, wmNotifier *wmn) switch(wmn->data) { case ND_TRANSFORM: case ND_MODIFIER: - if(ob && (ob->mode & OB_MODE_EDIT) && sima->lock && (sima->flag & SI_DRAWSHADOW)) { + if (ob && (ob->mode & OB_MODE_EDIT) && sima->lock && (sima->flag & SI_DRAWSHADOW)) { ED_area_tag_refresh(sa); ED_area_tag_redraw(sa); } @@ -689,10 +689,10 @@ static int image_context(const bContext *C, const char *member, bContextDataResu { SpaceImage *sima= CTX_wm_space_image(C); - if(CTX_data_dir(member)) { + if (CTX_data_dir(member)) { CTX_data_dir_set(result, image_context_dir); } - else if(CTX_data_equals(member, "edit_image")) { + else if (CTX_data_equals(member, "edit_image")) { CTX_data_id_pointer_set(result, (ID*)ED_space_image(sima)); return 1; } @@ -710,7 +710,7 @@ static void image_main_area_set_view2d(SpaceImage *sima, ARegion *ar) int width, height, winx, winy; #if 0 - if(image_preview_active(curarea, &width, &height)); + if (image_preview_active(curarea, &width, &height)); else #endif ED_space_image_size(sima, &width, &height); @@ -718,7 +718,7 @@ static void image_main_area_set_view2d(SpaceImage *sima, ARegion *ar) w= width; h= height; - if(ima) + if (ima) h *= ima->aspy/ima->aspx; winx= ar->winrct.xmax - ar->winrct.xmin + 1; @@ -869,7 +869,7 @@ static void image_buttons_area_listener(ARegion *ar, wmNotifier *wmn) ED_region_tag_redraw(ar); break; case NC_BRUSH: - if(wmn->action==NA_EDITED) + if (wmn->action==NA_EDITED) ED_region_tag_redraw(ar); break; case NC_TEXTURE: @@ -900,7 +900,7 @@ static void image_scope_area_draw(const bContext *C, ARegion *ar) Scene *scene= CTX_data_scene(C); void *lock; ImBuf *ibuf= ED_space_image_acquire_buffer(sima, &lock); - if(ibuf) { + if (ibuf) { scopes_update(&sima->scopes, ibuf, scene->r.color_mgt_flag & R_COLOR_MANAGEMENT ); } ED_space_image_release_buffer(sima, lock); diff --git a/source/blender/editors/space_info/info_draw.c b/source/blender/editors/space_info/info_draw.c index 19bbc33e606..c06a778951d 100644 --- a/source/blender/editors/space_info/info_draw.c +++ b/source/blender/editors/space_info/info_draw.c @@ -65,9 +65,9 @@ static void info_report_color(unsigned char *fg, unsigned char *bg, Report *report, int bool) { - if(report->flag & SELECT) { + if (report->flag & SELECT) { fg[0]=255; fg[1]=255; fg[2]=255; - if(bool) { + if (bool) { bg[0]=96; bg[1]=128; bg[2]=255; } else { @@ -114,7 +114,7 @@ static void report_textview_init__internal(TextViewContext *tvc) const char *str= report->message; const char *next_str= strchr(str + tvc->iter_char, '\n'); - if(next_str) { + if (next_str) { tvc->iter_char_next= (int)(next_str - str); } else { @@ -151,7 +151,7 @@ static int report_textview_begin(TextViewContext *tvc) #ifdef USE_INFO_NEWLINE tvc->iter_tmp= 0; - if(tvc->iter && report_textview_skip__internal(tvc)) { + if (tvc->iter && report_textview_skip__internal(tvc)) { /* init the newline iterator */ tvc->iter_char= 0; report_textview_init__internal(tvc); @@ -177,9 +177,9 @@ static int report_textview_step(TextViewContext *tvc) /* simple case, but no newline support */ Report *report= (Report *)tvc->iter; - if(report->len <= tvc->iter_char_next) { + if (report->len <= tvc->iter_char_next) { tvc->iter= (void *)((Link *)tvc->iter)->prev; - if(tvc->iter && report_textview_skip__internal(tvc)) { + if (tvc->iter && report_textview_skip__internal(tvc)) { tvc->iter_tmp++; tvc->iter_char= 0; /* reset start */ diff --git a/source/blender/editors/space_info/info_ops.c b/source/blender/editors/space_info/info_ops.c index bceb7c3d747..3157b920ff0 100644 --- a/source/blender/editors/space_info/info_ops.c +++ b/source/blender/editors/space_info/info_ops.c @@ -85,16 +85,16 @@ static int pack_all_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) ImBuf *ibuf; // first check for dirty images - for(ima=bmain->image.first; ima; ima=ima->id.next) { - if(ima->ibufs.first) { /* XXX FIX */ + for (ima=bmain->image.first; ima; ima=ima->id.next) { + if (ima->ibufs.first) { /* XXX FIX */ ibuf= BKE_image_get_ibuf(ima, NULL); - if(ibuf && (ibuf->userflags & IB_BITMAPDIRTY)) + if (ibuf && (ibuf->userflags & IB_BITMAPDIRTY)) break; } } - if(ima) { + if (ima) { uiPupMenuOkee(C, "FILE_OT_pack_all", "Some images are painted on. These changes will be lost. Continue?"); return OPERATOR_CANCELLED; } @@ -132,7 +132,7 @@ 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_AUTOPACK; return OPERATOR_FINISHED; @@ -148,13 +148,13 @@ static int unpack_all_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event) count = countPackedFiles(bmain); - if(!count) { + if (!count) { BKE_report(op->reports, RPT_WARNING, "No packed files. Autopack disabled"); G.fileflags &= ~G_AUTOPACK; return OPERATOR_CANCELLED; } - if(count == 1) + if (count == 1) strcpy(title, "Unpack 1 file"); else BLI_snprintf(title, sizeof(title), "Unpack %d files", count); @@ -193,7 +193,7 @@ static int make_paths_relative_exec(bContext *C, wmOperator *op) { Main *bmain= CTX_data_main(C); - if(!G.relbase_valid) { + if (!G.relbase_valid) { BKE_report(op->reports, RPT_WARNING, "Can't set relative paths with an unsaved blend file"); return OPERATOR_CANCELLED; } @@ -225,7 +225,7 @@ static int make_paths_absolute_exec(bContext *C, wmOperator *op) { Main *bmain= CTX_data_main(C); - if(!G.relbase_valid) { + if (!G.relbase_valid) { BKE_report(op->reports, RPT_WARNING, "Can't set absolute paths with an unsaved blend file"); return OPERATOR_CANCELLED; } @@ -339,7 +339,7 @@ static int update_reports_display_invoke(bContext *C, wmOperator *UNUSED(op), wm int send_note= 0; /* escape if not our timer */ - if( (reports->reporttimer==NULL) || + if ( (reports->reporttimer==NULL) || (reports->reporttimer != event->customdata) || ((report= BKE_reports_last_displayable(reports))==NULL) /* may have been deleted */ ) { @@ -363,15 +363,17 @@ static int update_reports_display_invoke(bContext *C, wmOperator *UNUSED(op), wm if (rti->widthfac == 0.0f) { /* initialize colors based on report type */ - if(report->type & RPT_ERROR_ALL) { + if (report->type & RPT_ERROR_ALL) { rti->col[0] = 1.0; rti->col[1] = 0.2; rti->col[2] = 0.0; - } else if(report->type & RPT_WARNING_ALL) { + } + else if (report->type & RPT_WARNING_ALL) { rti->col[0] = 1.0; rti->col[1] = 1.0; rti->col[2] = 0.0; - } else if(report->type & RPT_INFO_ALL) { + } + else if (report->type & RPT_INFO_ALL) { rti->col[0] = 0.3; rti->col[1] = 0.45; rti->col[2] = 0.7; @@ -384,7 +386,7 @@ static int update_reports_display_invoke(bContext *C, wmOperator *UNUSED(op), wm color_progress = (float)reports->reporttimer->duration / color_timeout; /* save us from too many draws */ - if(color_progress <= 1.0f) { + if (color_progress <= 1.0f) { send_note= 1; /* fade colors out sharply according to progress through fade-out duration */ @@ -399,7 +401,7 @@ static int update_reports_display_invoke(bContext *C, wmOperator *UNUSED(op), wm send_note= 1; } - if(send_note) { + if (send_note) { WM_event_add_notifier(C, NC_SPACE|ND_SPACE_INFO, NULL); } diff --git a/source/blender/editors/space_info/info_report.c b/source/blender/editors/space_info/info_report.c index 17b1c3fa269..4e6ccf2f2b1 100644 --- a/source/blender/editors/space_info/info_report.c +++ b/source/blender/editors/space_info/info_report.c @@ -53,11 +53,11 @@ int info_report_mask(SpaceInfo *UNUSED(sinfo)) #if 0 int report_mask = 0; - if(sinfo->rpt_mask & INFO_RPT_DEBUG) report_mask |= RPT_DEBUG_ALL; - if(sinfo->rpt_mask & INFO_RPT_INFO) report_mask |= RPT_INFO_ALL; - if(sinfo->rpt_mask & INFO_RPT_OP) report_mask |= RPT_OPERATOR_ALL; - if(sinfo->rpt_mask & INFO_RPT_WARN) report_mask |= RPT_WARNING_ALL; - if(sinfo->rpt_mask & INFO_RPT_ERR) report_mask |= RPT_ERROR_ALL; + if (sinfo->rpt_mask & INFO_RPT_DEBUG) report_mask |= RPT_DEBUG_ALL; + if (sinfo->rpt_mask & INFO_RPT_INFO) report_mask |= RPT_INFO_ALL; + if (sinfo->rpt_mask & INFO_RPT_OP) report_mask |= RPT_OPERATOR_ALL; + if (sinfo->rpt_mask & INFO_RPT_WARN) report_mask |= RPT_WARNING_ALL; + if (sinfo->rpt_mask & INFO_RPT_ERR) report_mask |= RPT_ERROR_ALL; return report_mask; #endif @@ -76,8 +76,8 @@ static int report_replay_exec(bContext *C, wmOperator *UNUSED(op)) #if 0 sc->type= CONSOLE_TYPE_PYTHON; - for(report=reports->list.last; report; report=report->prev) { - if((report->type & report_mask) && (report->type & RPT_OPERATOR_ALL) && (report->flag & SELECT)) { + for (report=reports->list.last; report; report=report->prev) { + if ((report->type & report_mask) && (report->type & RPT_OPERATOR_ALL) && (report->flag & SELECT)) { console_history_add_str(sc, report->message, 0); WM_operator_name_call(C, "CONSOLE_OT_execute", WM_OP_EXEC_DEFAULT, NULL); @@ -114,7 +114,7 @@ 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 */ @@ -172,22 +172,22 @@ static int report_select_all_toggle_exec(bContext *C, wmOperator *UNUSED(op)) Report *report; - for(report=reports->list.last; report; report=report->prev) { - if((report->type & report_mask) && (report->flag & SELECT)) { + for (report=reports->list.last; report; report=report->prev) { + if ((report->type & report_mask) && (report->flag & SELECT)) { deselect= 1; break; } } - if(deselect) { - for(report=reports->list.last; report; report=report->prev) - if(report->type & report_mask) + if (deselect) { + for (report=reports->list.last; report; report=report->prev) + if (report->type & report_mask) report->flag &= ~SELECT; } else { - for(report=reports->list.last; report; report=report->prev) - if(report->type & report_mask) + for (report=reports->list.last; report; report=report->prev) + if (report->type & report_mask) report->flag |= SELECT; } @@ -245,10 +245,10 @@ static int borderselect_exec(bContext *C, wmOperator *op) UI_view2d_region_to_view(v2d, mval[0], mval[1], &rectf.xmax, &rectf.ymax); #endif - if(!extend) { - for(report= reports->list.first; report; report= report->next) { + if (!extend) { + for (report= reports->list.first; report; report= report->next) { - if((report->type & report_mask)==0) + if ((report->type & report_mask)==0) continue; report->flag &= ~SELECT; @@ -259,35 +259,35 @@ static int borderselect_exec(bContext *C, wmOperator *op) report_max= info_text_pick(sinfo, ar, reports, rect.ymin); /* get the first report if none found */ - if(report_min==NULL) { + if (report_min==NULL) { // printf("find_min\n"); - for(report=reports->list.first; report; report=report->next) { - if(report->type & report_mask) { + for (report=reports->list.first; report; report=report->next) { + if (report->type & report_mask) { report_min= report; break; } } } - if(report_max==NULL) { + if (report_max==NULL) { // printf("find_max\n"); - for(report=reports->list.last; report; report=report->prev) { - if(report->type & report_mask) { + for (report=reports->list.last; report; report=report->prev) { + if (report->type & report_mask) { report_max= report; break; } } } - if(report_min==NULL || report_max==NULL) + if (report_min==NULL || report_max==NULL) return OPERATOR_CANCELLED; - for(report= report_min; (report != report_max->next); report= report->next) { + for (report= report_min; (report != report_max->next); report= report->next) { - if((report->type & report_mask)==0) + if ((report->type & report_mask)==0) continue; - if(selecting) + if (selecting) report->flag |= SELECT; else report->flag &= ~SELECT; @@ -333,11 +333,11 @@ static int report_delete_exec(bContext *C, wmOperator *UNUSED(op)) Report *report, *report_next; - for(report=reports->list.first; report; ) { + for (report=reports->list.first; report; ) { report_next=report->next; - if((report->type & report_mask) && (report->flag & SELECT)) { + if ((report->type & report_mask) && (report->flag & SELECT)) { BLI_remlink(&reports->list, report); MEM_freeN((void *)report->message); MEM_freeN(report); @@ -380,8 +380,8 @@ static int report_copy_exec(bContext *C, wmOperator *UNUSED(op)) DynStr *buf_dyn= BLI_dynstr_new(); char *buf_str; - for(report=reports->list.first; report; report= report->next) { - if((report->type & report_mask) && (report->flag & SELECT)) { + for (report=reports->list.first; report; report= report->next) { + if ((report->type & report_mask) && (report->flag & SELECT)) { BLI_dynstr_append(buf_dyn, report->message); BLI_dynstr_append(buf_dyn, "\n"); } diff --git a/source/blender/editors/space_info/info_stats.c b/source/blender/editors/space_info/info_stats.c index ea28057968a..59e4a1aaf04 100644 --- a/source/blender/editors/space_info/info_stats.c +++ b/source/blender/editors/space_info/info_stats.c @@ -76,7 +76,7 @@ static void stats_object(Object *ob, int sel, int totob, SceneStats *stats) stats->totmesh +=totob; - if(dm) { + if (dm) { totvert = dm->getNumVerts(dm); totedge = dm->getNumEdges(dm); totface = dm->getNumPolys(dm); @@ -85,7 +85,7 @@ static void stats_object(Object *ob, int sel, int totob, SceneStats *stats) stats->totedge += totedge*totob; stats->totface += totface*totob; - if(sel) { + if (sel) { stats->totvertsel += totvert; stats->totfacesel += totface; } @@ -102,7 +102,7 @@ static void stats_object(Object *ob, int sel, int totob, SceneStats *stats) stats->totcurve += totob; - if(ob->disp.first) + if (ob->disp.first) count_displist(&ob->disp, &tot, &totf); tot *= totob; @@ -111,7 +111,7 @@ static void stats_object(Object *ob, int sel, int totob, SceneStats *stats) stats->totvert+= tot; stats->totface+= totf; - if(sel) { + if (sel) { stats->totvertsel += tot; stats->totfacesel += totf; } @@ -128,7 +128,7 @@ static void stats_object(Object *ob, int sel, int totob, SceneStats *stats) stats->totvert += tot; stats->totface += totf; - if(sel) { + if (sel) { stats->totvertsel += tot; stats->totfacesel += totf; } @@ -139,7 +139,7 @@ static void stats_object(Object *ob, int sel, int totob, SceneStats *stats) static void stats_object_edit(Object *obedit, SceneStats *stats) { - if(obedit->type==OB_MESH) { + if (obedit->type==OB_MESH) { BMEditMesh *em = BMEdit_FromObject(obedit); stats->totvert = em->bm->totvert; @@ -151,26 +151,26 @@ static void stats_object_edit(Object *obedit, SceneStats *stats) stats->totface = em->bm->totface; stats->totfacesel = em->bm->totfacesel; } - else if(obedit->type==OB_ARMATURE){ + else if (obedit->type==OB_ARMATURE) { /* Armature Edit */ bArmature *arm= obedit->data; EditBone *ebo; - for(ebo=arm->edbo->first; ebo; ebo=ebo->next){ + 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) && ebo->parent && (ebo->parent->flag & BONE_TIPSEL)) + if ((ebo->flag & BONE_CONNECTED)&& (ebo->flag & BONE_ROOTSEL) && ebo->parent && (ebo->parent->flag & BONE_TIPSEL)) stats->totvertsel--; stats->totvert+=2; @@ -185,40 +185,40 @@ static void stats_object_edit(Object *obedit, SceneStats *stats) int a; ListBase *nurbs= curve_editnurbs(cu); - for(nu=nurbs->first; nu; nu=nu->next) { - if(nu->type == CU_BEZIER) { + for (nu=nurbs->first; nu; nu=nu->next) { + if (nu->type == CU_BEZIER) { bezt= nu->bezt; a= nu->pntsu; - while(a--) { + while (a--) { stats->totvert+=3; - if(bezt->f1) stats->totvertsel++; - if(bezt->f2) stats->totvertsel++; - if(bezt->f3) stats->totvertsel++; + if (bezt->f1) stats->totvertsel++; + if (bezt->f2) stats->totvertsel++; + if (bezt->f3) stats->totvertsel++; bezt++; } } else { bp= nu->bp; a= nu->pntsu*nu->pntsv; - while(a--) { + while (a--) { stats->totvert++; - if(bp->f1 & SELECT) stats->totvertsel++; + if (bp->f1 & SELECT) stats->totvertsel++; bp++; } } } } - else if(obedit->type==OB_MBALL) { + else if (obedit->type==OB_MBALL) { /* MetaBall Edit */ MetaBall *mball= obedit->data; MetaElem *ml; - for(ml= mball->editelems->first; ml; ml=ml->next) { + 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) { + else if (obedit->type==OB_LATTICE) { /* Lattice Edit */ Lattice *lt= obedit->data; Lattice *editlatt= lt->editlatt->latt; @@ -228,9 +228,9 @@ static void stats_object_edit(Object *obedit, SceneStats *stats) bp= editlatt->def; a= editlatt->pntsu*editlatt->pntsv*editlatt->pntsw; - while(a--) { + while (a--) { stats->totvert++; - if(bp->f1 & SELECT) stats->totvertsel++; + if (bp->f1 & SELECT) stats->totvertsel++; bp++; } } @@ -238,14 +238,14 @@ static void stats_object_edit(Object *obedit, SceneStats *stats) static void stats_object_pose(Object *ob, SceneStats *stats) { - if(ob->pose) { + if (ob->pose) { bArmature *arm= ob->data; bPoseChannel *pchan; - for(pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) { + 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++; } } @@ -253,28 +253,28 @@ static void stats_object_pose(Object *ob, SceneStats *stats) static void stats_dupli_object(Base *base, Object *ob, SceneStats *stats) { - if(base->flag & SELECT) stats->totobjsel++; + if (base->flag & SELECT) stats->totobjsel++; - if(ob->transflag & OB_DUPLIPARTS) { + if (ob->transflag & OB_DUPLIPARTS) { /* Dupli Particles */ ParticleSystem *psys; ParticleSettings *part; - for(psys=ob->particlesystem.first; psys; psys=psys->next){ + for (psys=ob->particlesystem.first; psys; psys=psys->next) { part=psys->part; - if(part->draw_as==PART_DRAW_OB && part->dup_ob){ + if (part->draw_as==PART_DRAW_OB && part->dup_ob) { int tot=count_particles(psys); stats_object(part->dup_ob, 0, tot, stats); } - else if(part->draw_as==PART_DRAW_GR && part->dup_group){ + else if (part->draw_as==PART_DRAW_GR && part->dup_group) { GroupObject *go; int tot, totgroup=0, cur=0; - for(go= part->dup_group->gobject.first; go; go=go->next) + for (go= part->dup_group->gobject.first; go; go=go->next) totgroup++; - for(go= part->dup_group->gobject.first; go; go=go->next) { + for (go= part->dup_group->gobject.first; go; go=go->next) { tot=count_particles_mod(psys,totgroup,cur); stats_object(go->ob, 0, tot, stats); cur++; @@ -285,19 +285,19 @@ static void stats_dupli_object(Base *base, Object *ob, SceneStats *stats) stats_object(ob, base->flag & SELECT, 1, stats); stats->totobj++; } - else if(ob->parent && (ob->parent->transflag & (OB_DUPLIVERTS|OB_DUPLIFACES))) { + else if (ob->parent && (ob->parent->transflag & (OB_DUPLIVERTS|OB_DUPLIFACES))) { /* Dupli Verts/Faces */ int tot= count_duplilist(ob->parent); stats->totobj+=tot; stats_object(ob, base->flag & SELECT, tot, stats); } - else if(ob->transflag & OB_DUPLIFRAMES) { + else if (ob->transflag & OB_DUPLIFRAMES) { /* Dupli Frames */ int tot= count_duplilist(ob); stats->totobj+=tot; stats_object(ob, base->flag & SELECT, tot, stats); } - else if((ob->transflag & OB_DUPLIGROUP) && ob->dup_group) { + else if ((ob->transflag & OB_DUPLIGROUP) && ob->dup_group) { /* Dupli Group */ int tot= count_duplilist(ob); stats->totobj+=tot; @@ -317,22 +317,22 @@ static void stats_update(Scene *scene) Object *ob= (scene->basact)? scene->basact->object: NULL; Base *base; - if(scene->obedit) { + if (scene->obedit) { /* Edit Mode */ stats_object_edit(scene->obedit, &stats); } - else if(ob && (ob->mode & OB_MODE_POSE)) { + else if (ob && (ob->mode & OB_MODE_POSE)) { /* Pose Mode */ stats_object_pose(ob, &stats); } else { /* Objects */ - for(base= scene->base.first; base; base=base->next) - if(scene->lay & base->lay) + for (base= scene->base.first; base; base=base->next) + if (scene->lay & base->lay) stats_dupli_object(base, base->object, &stats); } - if(!scene->stats) + if (!scene->stats) scene->stats= MEM_callocN(sizeof(SceneStats), "SceneStats"); *(scene->stats)= stats; @@ -351,28 +351,28 @@ static void stats_string(Scene *scene) /* get memory statistics */ s= memstr + sprintf(memstr, " | Mem:%.2fM", (double)((mem_in_use-mmap_in_use)>>10)/1024.0); - if(mmap_in_use) + if (mmap_in_use) sprintf(s, " (%.2fM)", (double)((mmap_in_use)>>10)/1024.0); s= stats->infostr; s+= sprintf(s, "%s | ", versionstr); - if(scene->obedit) { - if(ob_get_keyblock(scene->obedit)) + if (scene->obedit) { + if (ob_get_keyblock(scene->obedit)) s+= sprintf(s, "(Key) "); - if(scene->obedit->type==OB_MESH) { - if(scene->toolsettings->selectmode & SCE_SELECT_VERTEX) + if (scene->obedit->type==OB_MESH) { + if (scene->toolsettings->selectmode & SCE_SELECT_VERTEX) s+= sprintf(s, "Ve:%d-%d | Ed:%d-%d | Fa:%d-%d", stats->totvertsel, stats->totvert, stats->totedgesel, stats->totedge, stats->totfacesel, stats->totface); - else if(scene->toolsettings->selectmode & SCE_SELECT_EDGE) + else if (scene->toolsettings->selectmode & SCE_SELECT_EDGE) s+= sprintf(s, "Ed:%d-%d | Fa:%d-%d", stats->totedgesel, stats->totedge, stats->totfacesel, stats->totface); else s+= sprintf(s, "Fa:%d-%d", stats->totfacesel, stats->totface); } - else if(scene->obedit->type==OB_ARMATURE) { + else if (scene->obedit->type==OB_ARMATURE) { s+= sprintf(s, "Ve:%d-%d | Bo:%d-%d", stats->totvertsel, stats->totvert, stats->totbonesel, stats->totbone); } else { @@ -381,7 +381,7 @@ static void stats_string(Scene *scene) strcat(s, memstr); } - else if(ob && (ob->mode & OB_MODE_POSE)) { + else if (ob && (ob->mode & OB_MODE_POSE)) { s += sprintf(s, "Bo:%d-%d %s", stats->totbonesel, stats->totbone, memstr); } @@ -390,13 +390,13 @@ static void stats_string(Scene *scene) stats->totvert, stats->totface, stats->totobjsel, stats->totobj, stats->totlamp, memstr); } - if(ob) + if (ob) sprintf(s, " | %s", ob->id.name+2); } void ED_info_stats_clear(Scene *scene) { - if(scene->stats) { + if (scene->stats) { MEM_freeN(scene->stats); scene->stats= NULL; } @@ -404,7 +404,7 @@ void ED_info_stats_clear(Scene *scene) const char *ED_info_stats_string(Scene *scene) { - if(!scene->stats) + if (!scene->stats) stats_update(scene); stats_string(scene); diff --git a/source/blender/editors/space_info/space_info.c b/source/blender/editors/space_info/space_info.c index 2d3eb68c84d..9dc58537145 100644 --- a/source/blender/editors/space_info/space_info.c +++ b/source/blender/editors/space_info/space_info.c @@ -155,7 +155,7 @@ static void info_main_area_draw(const bContext *C, ARegion *ar) glClear(GL_COLOR_BUFFER_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); @@ -233,7 +233,7 @@ static void info_main_area_listener(ARegion *ar, wmNotifier *wmn) /* context changes */ switch(wmn->category) { case NC_SPACE: - if(wmn->data == ND_SPACE_INFO_REPORT) { + if (wmn->data == ND_SPACE_INFO_REPORT) { /* redraw also but only for report view, could do less redraws by checking the type */ ED_region_tag_redraw(ar); } @@ -246,23 +246,23 @@ static void info_header_listener(ARegion *ar, wmNotifier *wmn) /* context changes */ switch(wmn->category) { case NC_SCREEN: - if(ELEM(wmn->data, ND_SCREENCAST, ND_ANIMPLAY)) + if (ELEM(wmn->data, ND_SCREENCAST, ND_ANIMPLAY)) ED_region_tag_redraw(ar); 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); } @@ -274,10 +274,11 @@ static void recent_files_menu_draw(const bContext *UNUSED(C), Menu *menu) uiLayout *layout= menu->layout; uiLayoutSetOperatorContext(layout, WM_OP_EXEC_REGION_WIN); if (G.recent_files.first) { - for(recent = G.recent_files.first; (recent); recent = recent->next) { + for (recent = G.recent_files.first; (recent); recent = recent->next) { uiItemStringO(layout, BLI_path_basename(recent->filepath), ICON_FILE_BLEND, "WM_OT_open_mainfile", "filepath", recent->filepath); } - } else { + } + else { uiItemL(layout, IFACE_("No Recent Files"), ICON_NONE); } } diff --git a/source/blender/editors/space_info/textview.c b/source/blender/editors/space_info/textview.c index 5b461d8a518..04bb97ee431 100644 --- a/source/blender/editors/space_info/textview.c +++ b/source/blender/editors/space_info/textview.c @@ -65,7 +65,7 @@ typedef struct ConsoleDrawContext { static void console_draw_sel(int sel[2], int xy[2], int str_len_draw, int cwidth, int lheight) { - if(sel[0] <= str_len_draw && sel[1] >= 0) { + if (sel[0] <= str_len_draw && sel[1] >= 0) { int sta = MAX2(sel[0], 0); int end = MIN2(sel[1], str_len_draw); @@ -95,19 +95,20 @@ static int console_draw_string(ConsoleDrawContext *cdc, const char *str, int str const int mono= blf_mono_font; /* just advance the height */ - if(cdc->draw==0) { - if(cdc->pos_pick && (cdc->mval[1] != INT_MAX)) { - if(cdc->xy[1] <= cdc->mval[1]) { - if((y_next >= cdc->mval[1])) { + if (cdc->draw==0) { + if (cdc->pos_pick && (cdc->mval[1] != INT_MAX)) { + if (cdc->xy[1] <= cdc->mval[1]) { + if ((y_next >= cdc->mval[1])) { int ofs = (int)floor(((float)cdc->mval[0] / (float)cdc->cwidth)); /* wrap */ - if(str_len > cdc->console_width) + if (str_len > cdc->console_width) ofs += (cdc->console_width * ((int)((((float)(y_next - cdc->mval[1]) / (float)(y_next-cdc->xy[1])) * tot_lines)))); CLAMP(ofs, 0, str_len); *cdc->pos_pick += str_len - ofs; - } else + } + else *cdc->pos_pick += str_len + 1; } } @@ -120,14 +121,14 @@ static int console_draw_string(ConsoleDrawContext *cdc, const char *str, int str cdc->xy[1]= y_next; /* adjust selection even if not drawing */ - if(cdc->sel[0] != cdc->sel[1]) { + if (cdc->sel[0] != cdc->sel[1]) { STEP_SEL(-(str_len + 1)); } return 1; } - if(str_len > cdc->console_width) { /* wrap? */ + if (str_len > cdc->console_width) { /* wrap? */ const int initial_offset= ((tot_lines-1) * cdc->console_width); const char *line_stride= str + initial_offset; /* advance to the last line and draw it first */ @@ -138,7 +139,7 @@ static int console_draw_string(ConsoleDrawContext *cdc, const char *str, int str cdc->sel[0] = str_len - sel_orig[1]; cdc->sel[1] = str_len - sel_orig[0]; - if(bg) { + if (bg) { glColor3ubv(bg); glRecti(0, cdc->xy[1]-rct_ofs, cdc->winx, (cdc->xy[1]+(cdc->lheight*tot_lines))+rct_ofs); } @@ -149,7 +150,7 @@ static int console_draw_string(ConsoleDrawContext *cdc, const char *str, int str BLF_position(mono, cdc->xy[0], cdc->xy[1], 0); BLF_draw(mono, line_stride, str_len - initial_offset); - if(cdc->sel[0] != cdc->sel[1]) { + if (cdc->sel[0] != cdc->sel[1]) { STEP_SEL(-initial_offset); // glColor4ub(255, 0, 0, 96); // debug console_draw_sel(cdc->sel, cdc->xy, str_len % cdc->console_width, cdc->cwidth, cdc->lheight); @@ -161,11 +162,11 @@ static int console_draw_string(ConsoleDrawContext *cdc, const char *str, int str line_stride -= cdc->console_width; - for(; line_stride >= str; line_stride -= cdc->console_width) { + for (; line_stride >= str; line_stride -= cdc->console_width) { BLF_position(mono, cdc->xy[0], cdc->xy[1], 0); BLF_draw(mono, line_stride, cdc->console_width); - if(cdc->sel[0] != cdc->sel[1]) { + if (cdc->sel[0] != cdc->sel[1]) { // glColor4ub(0, 255, 0, 96); // debug console_draw_sel(cdc->sel, cdc->xy, cdc->console_width, cdc->cwidth, cdc->lheight); STEP_SEL(cdc->console_width); @@ -175,7 +176,7 @@ static int console_draw_string(ConsoleDrawContext *cdc, const char *str, int str cdc->xy[1] += cdc->lheight; /* check if were out of view bounds */ - if(cdc->xy[1] > cdc->ymax) + if (cdc->xy[1] > cdc->ymax) return 0; } @@ -184,7 +185,7 @@ static int console_draw_string(ConsoleDrawContext *cdc, const char *str, int str } else { /* simple, no wrap */ - if(bg) { + if (bg) { glColor3ubv(bg); glRecti(0, cdc->xy[1]-rct_ofs, cdc->winx, cdc->xy[1]+cdc->lheight-rct_ofs); } @@ -194,7 +195,7 @@ static int console_draw_string(ConsoleDrawContext *cdc, const char *str, int str BLF_position(mono, cdc->xy[0], cdc->xy[1], 0); BLF_draw(mono, str, str_len); - if(cdc->sel[0] != cdc->sel[1]) { + if (cdc->sel[0] != cdc->sel[1]) { int isel[2]; isel[0]= str_len - cdc->sel[1]; @@ -207,7 +208,7 @@ static int console_draw_string(ConsoleDrawContext *cdc, const char *str, int str cdc->xy[1] += cdc->lheight; - if(cdc->xy[1] > cdc->ymax) + if (cdc->xy[1] > cdc->ymax) return 0; } @@ -232,10 +233,10 @@ int textview_draw(TextViewContext *tvc, int draw, int mval[2], void **mouse_pick 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 */ @@ -258,12 +259,12 @@ int textview_draw(TextViewContext *tvc, int draw, int mval[2], void **mouse_pick tvc->console_width= cdc.console_width; tvc->iter_index= 0; - if(tvc->sel_start != tvc->sel_end) { + if (tvc->sel_start != tvc->sel_end) { sel[0]= tvc->sel_start; sel[1]= tvc->sel_end; } - if(tvc->begin(tvc)) { + if (tvc->begin(tvc)) { do { const char *ext_line; @@ -272,19 +273,19 @@ int textview_draw(TextViewContext *tvc, int draw, int mval[2], void **mouse_pick y_prev= xy[1]; - if(draw) + if (draw) color_flag= tvc->line_color(tvc, fg, bg); tvc->line_get(tvc, &ext_line, &ext_len); - if(!console_draw_string(&cdc, ext_line, ext_len, (color_flag & TVC_LINE_FG) ? fg : NULL, (color_flag & TVC_LINE_BG) ? bg : NULL)) { + if (!console_draw_string(&cdc, ext_line, ext_len, (color_flag & TVC_LINE_FG) ? fg : NULL, (color_flag & TVC_LINE_BG) ? bg : NULL)) { /* when drawing, if we pass v2d->cur.ymax, then quit */ - if(draw) { + if (draw) { break; /* past the y limits */ } } - if((mval[1] != INT_MAX) && (mval[1] >= y_prev && mval[1] <= xy[1])) { + if ((mval[1] != INT_MAX) && (mval[1] >= y_prev && mval[1] <= xy[1])) { *mouse_pick= (void *)tvc->iter; break; } diff --git a/source/blender/editors/space_logic/logic_buttons.c b/source/blender/editors/space_logic/logic_buttons.c index 4117e07063d..b98e6995f46 100644 --- a/source/blender/editors/space_logic/logic_buttons.c +++ b/source/blender/editors/space_logic/logic_buttons.c @@ -108,7 +108,7 @@ static int logic_properties(bContext *C, wmOperator *UNUSED(op)) ScrArea *sa= CTX_wm_area(C); ARegion *ar= logic_has_buttons_region(sa); - if(ar) + if (ar) ED_region_toggle_hidden(C, ar); return OPERATOR_FINISHED; @@ -142,10 +142,10 @@ static int cut_links_intersect(uiLinkLine *line, float mcoords[][2], int tot) rectlink.xmax = (int) (line->to->x1 + line->to->x2) / 2; rectlink.ymax = (int) (line->to->y1 + line->to->y2) / 2; - if(ui_link_bezier_points(&rectlink, coord_array, LINK_RESOL)){ - for(i=0; i 0) + if (ui_link_bezier_points(&rectlink, coord_array, LINK_RESOL)) { + for (i=0; i 0) return 1; } return 0; @@ -164,7 +164,7 @@ static int cut_links_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; @@ -172,15 +172,15 @@ static int cut_links_exec(bContext *C, wmOperator *op) uiBlock *block; uiLinkLine *line, *nline; uiBut *but; - for(block= ar->uiblocks.first; block; block= block->next) + for (block= ar->uiblocks.first; block; block= block->next) { but= block->buttons.first; - while(but) { - if(but->type==LINK && but->link) { - for(line= but->link->lines.first; line; line= nline) { + while (but) { + if (but->type==LINK && but->link) { + for (line= but->link->lines.first; line; line= nline) { nline= line->next; - if(cut_links_intersect(line, mcoords, i)) { + if (cut_links_intersect(line, mcoords, i)) { ui_delete_linkline(line, but); } } diff --git a/source/blender/editors/space_logic/logic_ops.c b/source/blender/editors/space_logic/logic_ops.c index 08f4ae669d7..cac4fe04765 100644 --- a/source/blender/editors/space_logic/logic_ops.c +++ b/source/blender/editors/space_logic/logic_ops.c @@ -293,7 +293,7 @@ static int sensor_add_exec(bContext *C, wmOperator *op) prop = RNA_struct_find_property(&sens_ptr, "type"); RNA_string_get(op->ptr, "name", name); - if(BLI_strnlen(name, MAX_NAME) < 1){ + if (BLI_strnlen(name, MAX_NAME) < 1) { RNA_property_enum_name(C, &sens_ptr, prop, RNA_property_enum_get(&sens_ptr, prop), &sens_name); BLI_strncpy(sens->name, sens_name, sizeof(sens->name)); } @@ -386,7 +386,7 @@ static int controller_add_exec(bContext *C, wmOperator *op) int type= RNA_enum_get(op->ptr, "type"); ob= edit_object_property_get(C, op); - if(!ob) + if (!ob) return OPERATOR_CANCELLED; cont= new_controller(type); @@ -397,7 +397,7 @@ static int controller_add_exec(bContext *C, wmOperator *op) prop = RNA_struct_find_property(&cont_ptr, "type"); RNA_string_get(op->ptr, "name", name); - if(BLI_strnlen(name, MAX_NAME) < 1){ + if (BLI_strnlen(name, MAX_NAME) < 1) { RNA_property_enum_name(C, &cont_ptr, prop, RNA_property_enum_get(&cont_ptr, prop), &cont_name); BLI_strncpy(cont->name, cont_name, sizeof(cont->name)); } @@ -499,7 +499,7 @@ static int actuator_add_exec(bContext *C, wmOperator *op) int type= RNA_enum_get(op->ptr, "type"); ob= edit_object_property_get(C, op); - if(!ob) + if (!ob) return OPERATOR_CANCELLED; act= new_actuator(type); @@ -510,7 +510,7 @@ static int actuator_add_exec(bContext *C, wmOperator *op) prop = RNA_struct_find_property(&act_ptr, "type"); RNA_string_get(op->ptr, "name", name); - if (BLI_strnlen(name, MAX_NAME) < 1){ + if (BLI_strnlen(name, MAX_NAME) < 1) { RNA_property_enum_name(C, &act_ptr, prop, RNA_property_enum_get(&act_ptr, prop), &act_name); BLI_strncpy(act->name, act_name, sizeof(act->name)); } diff --git a/source/blender/editors/space_logic/logic_window.c b/source/blender/editors/space_logic/logic_window.c index d6742341ae1..23272a5d93a 100644 --- a/source/blender/editors/space_logic/logic_window.c +++ b/source/blender/editors/space_logic/logic_window.c @@ -132,15 +132,15 @@ void make_unique_prop_names(bContext *C, char *str) /* for each object, make properties and sca names unique */ /* count total names */ - for(a=0; aprop); propcount+= BLI_countlist(&ob->sensors); propcount+= BLI_countlist(&ob->controllers); propcount+= BLI_countlist(&ob->actuators); } - if(propcount==0) { - if(idar) MEM_freeN(idar); + if (propcount==0) { + if (idar) MEM_freeN(idar); return; } @@ -149,7 +149,7 @@ void make_unique_prop_names(bContext *C, char *str) /* count total names */ nr= 0; - for(a=0; aprop.first; while(prop) { @@ -177,8 +177,8 @@ void make_unique_prop_names(bContext *C, char *str) /* now we check for double names, and change them */ - for(nr=0; nr0) { + if (val>0) { /* now find out which object has this ... */ base= FIRSTBASE; while(base) { sens= base->object->sensors.first; while(sens) { - if(sens == sens_to_delete) break; + if (sens == sens_to_delete) break; sens= sens->next; } - if(sens) { - if( val==1 && sens->prev) { + if (sens) { + if ( val==1 && sens->prev) { for (tmp=sens->prev; tmp; tmp=tmp->prev) { if (tmp->flag & SENS_VISIBLE) break; @@ -230,7 +230,7 @@ static void old_sca_move_sensor(bContext *C, void *datav, void *move_up) BLI_insertlinkbefore(&base->object->sensors, tmp, sens); } } - else if( val==2 && sens->next) { + else if ( val==2 && sens->next) { for (tmp=sens->next; tmp; tmp=tmp->next) { if (tmp->flag & SENS_VISIBLE) break; @@ -261,23 +261,23 @@ static void old_sca_move_controller(bContext *C, void *datav, void *move_up) //val= pupmenu("Move up%x1|Move down %x2"); val = move_up ? 1:2; - if(val>0) { + if (val>0) { /* now find out which object has this ... */ base= FIRSTBASE; while(base) { cont= base->object->controllers.first; while(cont) { - if(cont == controller_to_del) break; + if (cont == controller_to_del) break; cont= cont->next; } - if(cont) { - if( val==1 && cont->prev) { + if (cont) { + if ( val==1 && cont->prev) { /* locate the controller that has the same state mask but is earlier in the list */ tmp = cont->prev; while(tmp) { - if(tmp->state_mask & cont->state_mask) + if (tmp->state_mask & cont->state_mask) break; tmp = tmp->prev; } @@ -286,10 +286,10 @@ static void old_sca_move_controller(bContext *C, void *datav, void *move_up) BLI_insertlinkbefore(&base->object->controllers, tmp, cont); } } - else if( val==2 && cont->next) { + else if ( val==2 && cont->next) { tmp = cont->next; while(tmp) { - if(tmp->state_mask & cont->state_mask) + if (tmp->state_mask & cont->state_mask) break; tmp = tmp->next; } @@ -317,19 +317,19 @@ static void old_sca_move_actuator(bContext *C, void *datav, void *move_up) //val= pupmenu("Move up%x1|Move down %x2"); val = move_up ? 1:2; - if(val>0) { + if (val>0) { /* now find out which object has this ... */ base= FIRSTBASE; while(base) { act= base->object->actuators.first; while(act) { - if(act == actuator_to_move) break; + if (act == actuator_to_move) break; act= act->next; } - if(act) { - if( val==1 && act->prev) { + if (act) { + if ( val==1 && act->prev) { /* locate the first visible actuators before this one */ for (tmp = act->prev; tmp; tmp=tmp->prev) { if (tmp->flag & ACT_VISIBLE) @@ -340,7 +340,7 @@ static void old_sca_move_actuator(bContext *C, void *datav, void *move_up) BLI_insertlinkbefore(&base->object->actuators, tmp, act); } } - else if( val==2 && act->next) { + else if ( val==2 && act->next) { for (tmp=act->next; tmp; tmp=tmp->next) { if (tmp->flag & ACT_VISIBLE) break; @@ -369,7 +369,7 @@ static void do_logic_buts(bContext *C, void *UNUSED(arg), int event) int didit, bit; ob= CTX_data_active_object(C); - if(ob==NULL) return; + if (ob==NULL) return; switch(event) { @@ -385,8 +385,8 @@ static void do_logic_buts(bContext *C, void *UNUSED(arg), int event) break; case B_ADD_SENS: - for(ob=bmain->object.first; ob; ob=ob->id.next) { - if(ob->scaflag & OB_ADDSENS) { + for (ob=bmain->object.first; ob; ob=ob->id.next) { + if (ob->scaflag & OB_ADDSENS) { ob->scaflag &= ~OB_ADDSENS; sens= new_sensor(SENS_ALWAYS); BLI_addtail(&(ob->sensors), sens); @@ -399,10 +399,10 @@ static void do_logic_buts(bContext *C, void *UNUSED(arg), int event) break; case B_CHANGE_SENS: - for(ob=bmain->object.first; ob; ob=ob->id.next) { + for (ob=bmain->object.first; ob; ob=ob->id.next) { sens= ob->sensors.first; while(sens) { - if(sens->type != sens->otype) { + if (sens->type != sens->otype) { init_sensor(sens); sens->otype= sens->type; break; @@ -413,10 +413,10 @@ static void do_logic_buts(bContext *C, void *UNUSED(arg), int event) break; case B_DEL_SENS: - for(ob=bmain->object.first; ob; ob=ob->id.next) { + for (ob=bmain->object.first; ob; ob=ob->id.next) { sens= ob->sensors.first; while(sens) { - if(sens->flag & SENS_DEL) { + if (sens->flag & SENS_DEL) { BLI_remlink(&(ob->sensors), sens); free_sensor(sens); break; @@ -428,8 +428,8 @@ static void do_logic_buts(bContext *C, void *UNUSED(arg), int event) break; case B_ADD_CONT: - for(ob=bmain->object.first; ob; ob=ob->id.next) { - if(ob->scaflag & OB_ADDCONT) { + for (ob=bmain->object.first; ob; ob=ob->id.next) { + if (ob->scaflag & OB_ADDCONT) { ob->scaflag &= ~OB_ADDCONT; cont= new_controller(CONT_LOGIC_AND); make_unique_prop_names(C, cont->name); @@ -453,8 +453,8 @@ static void do_logic_buts(bContext *C, void *UNUSED(arg), int event) break; case B_SET_STATE_BIT: - for(ob=bmain->object.first; ob; ob=ob->id.next) { - if(ob->scaflag & OB_ALLSTATE) { + for (ob=bmain->object.first; ob; ob=ob->id.next) { + if (ob->scaflag & OB_ALLSTATE) { ob->scaflag &= ~OB_ALLSTATE; ob->state = 0x3FFFFFFF; } @@ -462,8 +462,8 @@ static void do_logic_buts(bContext *C, void *UNUSED(arg), int event) break; case B_INIT_STATE_BIT: - for(ob=bmain->object.first; ob; ob=ob->id.next) { - if(ob->scaflag & OB_INITSTBIT) { + for (ob=bmain->object.first; ob; ob=ob->id.next) { + if (ob->scaflag & OB_INITSTBIT) { ob->scaflag &= ~OB_INITSTBIT; ob->state = ob->init_state; if (!ob->state) @@ -473,10 +473,10 @@ static void do_logic_buts(bContext *C, void *UNUSED(arg), int event) break; case B_CHANGE_CONT: - for(ob=bmain->object.first; ob; ob=ob->id.next) { + for (ob=bmain->object.first; ob; ob=ob->id.next) { cont= ob->controllers.first; while(cont) { - if(cont->type != cont->otype) { + if (cont->type != cont->otype) { init_controller(cont); cont->otype= cont->type; break; @@ -488,10 +488,10 @@ static void do_logic_buts(bContext *C, void *UNUSED(arg), int event) case B_DEL_CONT: - for(ob=bmain->object.first; ob; ob=ob->id.next) { + for (ob=bmain->object.first; ob; ob=ob->id.next) { cont= ob->controllers.first; while(cont) { - if(cont->flag & CONT_DEL) { + if (cont->flag & CONT_DEL) { BLI_remlink(&(ob->controllers), cont); unlink_controller(cont); free_controller(cont); @@ -504,8 +504,8 @@ static void do_logic_buts(bContext *C, void *UNUSED(arg), int event) break; case B_ADD_ACT: - for(ob=bmain->object.first; ob; ob=ob->id.next) { - if(ob->scaflag & OB_ADDACT) { + for (ob=bmain->object.first; ob; ob=ob->id.next) { + if (ob->scaflag & OB_ADDACT) { ob->scaflag &= ~OB_ADDACT; act= new_actuator(ACT_OBJECT); make_unique_prop_names(C, act->name); @@ -517,10 +517,10 @@ static void do_logic_buts(bContext *C, void *UNUSED(arg), int event) break; case B_CHANGE_ACT: - for(ob=bmain->object.first; ob; ob=ob->id.next) { + for (ob=bmain->object.first; ob; ob=ob->id.next) { act= ob->actuators.first; while(act) { - if(act->type != act->otype) { + if (act->type != act->otype) { init_actuator(act); act->otype= act->type; break; @@ -531,10 +531,10 @@ static void do_logic_buts(bContext *C, void *UNUSED(arg), int event) break; case B_DEL_ACT: - for(ob=bmain->object.first; ob; ob=ob->id.next) { + for (ob=bmain->object.first; ob; ob=ob->id.next) { act= ob->actuators.first; while(act) { - if(act->flag & ACT_DEL) { + if (act->flag & ACT_DEL) { BLI_remlink(&(ob->actuators), act); unlink_actuator(act); free_actuator(act); @@ -549,19 +549,19 @@ static void do_logic_buts(bContext *C, void *UNUSED(arg), int event) case B_SOUNDACT_BROWSE: /* since we don't know which... */ didit= 0; - for(ob=bmain->object.first; ob; ob=ob->id.next) { + for (ob=bmain->object.first; ob; ob=ob->id.next) { act= ob->actuators.first; while(act) { - if(act->type==ACT_SOUND) + if (act->type==ACT_SOUND) { bSoundActuator *sa= act->data; - if(sa->sndnr) + if (sa->sndnr) { ID *sound= bmain->sound.first; int nr= 1; - if(sa->sndnr == -2) { + if (sa->sndnr == -2) { // XXX activate_databrowse((ID *)bmain->sound.first, ID_SO, 0, B_SOUNDACT_BROWSE, // &sa->sndnr, do_logic_buts); break; @@ -569,18 +569,18 @@ static void do_logic_buts(bContext *C, void *UNUSED(arg), int event) while(sound) { - if(nr==sa->sndnr) + if (nr==sa->sndnr) break; nr++; sound= sound->next; } - if(sa->sound) + if (sa->sound) ((ID *)sa->sound)->us--; sa->sound= (struct bSound *)sound; - if(sound) + if (sound) sound->us++; sa->sndnr= 0; @@ -589,7 +589,7 @@ static void do_logic_buts(bContext *C, void *UNUSED(arg), int event) } act= act->next; } - if(didit) + if (didit) break; } @@ -788,7 +788,7 @@ static ID **get_selected_and_linked_obs(bContext *C, short *count, short scavisf *count= 0; - if(scene==NULL) return NULL; + if (scene==NULL) return NULL; ob= bmain->object.first; while(ob) { @@ -802,24 +802,24 @@ static ID **get_selected_and_linked_obs(bContext *C, short *count, short scavisf base= FIRSTBASE; while(base) { - if(base->lay & lay) { - if(base->flag & SELECT) { - if(scavisflag & BUTS_SENS_SEL) base->object->scavisflag |= OB_VIS_SENS; - if(scavisflag & BUTS_CONT_SEL) base->object->scavisflag |= OB_VIS_CONT; - if(scavisflag & BUTS_ACT_SEL) base->object->scavisflag |= OB_VIS_ACT; + if (base->lay & lay) { + if (base->flag & SELECT) { + if (scavisflag & BUTS_SENS_SEL) base->object->scavisflag |= OB_VIS_SENS; + if (scavisflag & BUTS_CONT_SEL) base->object->scavisflag |= OB_VIS_CONT; + if (scavisflag & BUTS_ACT_SEL) base->object->scavisflag |= OB_VIS_ACT; } } base= base->next; } - if(obact) { - if(scavisflag & BUTS_SENS_ACT) obact->scavisflag |= OB_VIS_SENS; - if(scavisflag & BUTS_CONT_ACT) obact->scavisflag |= OB_VIS_CONT; - if(scavisflag & BUTS_ACT_ACT) obact->scavisflag |= OB_VIS_ACT; + if (obact) { + if (scavisflag & BUTS_SENS_ACT) obact->scavisflag |= OB_VIS_SENS; + if (scavisflag & BUTS_CONT_ACT) obact->scavisflag |= OB_VIS_CONT; + if (scavisflag & BUTS_ACT_ACT) obact->scavisflag |= OB_VIS_ACT; } /* BUTS_XXX_STATE are similar to BUTS_XXX_LINK for selecting the object */ - if(scavisflag & (BUTS_SENS_LINK|BUTS_CONT_LINK|BUTS_ACT_LINK|BUTS_SENS_STATE|BUTS_ACT_STATE)) { + if (scavisflag & (BUTS_SENS_LINK|BUTS_CONT_LINK|BUTS_ACT_LINK|BUTS_SENS_STATE|BUTS_ACT_STATE)) { doit= 1; while(doit) { doit= 0; @@ -828,51 +828,51 @@ static ID **get_selected_and_linked_obs(bContext *C, short *count, short scavisf while(ob) { /* 1st case: select sensor when controller selected */ - if((scavisflag & (BUTS_SENS_LINK|BUTS_SENS_STATE)) && (ob->scavisflag & OB_VIS_SENS)==0) { + if ((scavisflag & (BUTS_SENS_LINK|BUTS_SENS_STATE)) && (ob->scavisflag & OB_VIS_SENS)==0) { sens= ob->sensors.first; while(sens) { - for(a=0; atotlinks; a++) { - if(sens->links[a]) { + for (a=0; atotlinks; a++) { + if (sens->links[a]) { obt= (Object *)sens->links[a]->mynew; - if(obt && (obt->scavisflag & OB_VIS_CONT)) { + if (obt && (obt->scavisflag & OB_VIS_CONT)) { doit= 1; ob->scavisflag |= OB_VIS_SENS; break; } } } - if(doit) break; + if (doit) break; sens= sens->next; } } /* 2nd case: select cont when act selected */ - if((scavisflag & BUTS_CONT_LINK) && (ob->scavisflag & OB_VIS_CONT)==0) { + if ((scavisflag & BUTS_CONT_LINK) && (ob->scavisflag & OB_VIS_CONT)==0) { cont= ob->controllers.first; while(cont) { - for(a=0; atotlinks; a++) { - if(cont->links[a]) { + for (a=0; atotlinks; a++) { + if (cont->links[a]) { obt= (Object *)cont->links[a]->mynew; - if(obt && (obt->scavisflag & OB_VIS_ACT)) { + if (obt && (obt->scavisflag & OB_VIS_ACT)) { doit= 1; ob->scavisflag |= OB_VIS_CONT; break; } } } - if(doit) break; + if (doit) break; cont= cont->next; } } /* 3rd case: select controller when sensor selected */ - if((scavisflag & BUTS_CONT_LINK) && (ob->scavisflag & OB_VIS_SENS)) { + if ((scavisflag & BUTS_CONT_LINK) && (ob->scavisflag & OB_VIS_SENS)) { sens= ob->sensors.first; while(sens) { - for(a=0; atotlinks; a++) { - if(sens->links[a]) { + for (a=0; atotlinks; a++) { + if (sens->links[a]) { obt= (Object *)sens->links[a]->mynew; - if(obt && (obt->scavisflag & OB_VIS_CONT)==0) { + if (obt && (obt->scavisflag & OB_VIS_CONT)==0) { doit= 1; obt->scavisflag |= OB_VIS_CONT; } @@ -883,13 +883,13 @@ static ID **get_selected_and_linked_obs(bContext *C, short *count, short scavisf } /* 4th case: select actuator when controller selected */ - if( (scavisflag & (BUTS_ACT_LINK|BUTS_ACT_STATE)) && (ob->scavisflag & OB_VIS_CONT)) { + if ( (scavisflag & (BUTS_ACT_LINK|BUTS_ACT_STATE)) && (ob->scavisflag & OB_VIS_CONT)) { cont= ob->controllers.first; while(cont) { - for(a=0; atotlinks; a++) { - if(cont->links[a]) { + for (a=0; atotlinks; a++) { + if (cont->links[a]) { obt= (Object *)cont->links[a]->mynew; - if(obt && (obt->scavisflag & OB_VIS_ACT)==0) { + if (obt && (obt->scavisflag & OB_VIS_ACT)==0) { doit= 1; obt->scavisflag |= OB_VIS_ACT; } @@ -907,12 +907,12 @@ static ID **get_selected_and_linked_obs(bContext *C, short *count, short scavisf /* now we count */ ob= bmain->object.first; while(ob) { - if( ob->scavisflag ) (*count)++; + if ( ob->scavisflag ) (*count)++; ob= ob->id.next; } - if(*count==0) return NULL; - if(*count>24) *count= 24; /* temporal */ + if (*count==0) return NULL; + if (*count>24) *count= 24; /* temporal */ idar= MEM_callocN( (*count)*sizeof(void *), "idar"); @@ -926,11 +926,11 @@ static ID **get_selected_and_linked_obs(bContext *C, short *count, short scavisf } while(ob) { - if( (ob->scavisflag) && (ob != obact)) { + if ( (ob->scavisflag) && (ob != obact)) { idar[nr]= (ID *)ob; nr++; } - if(nr>=24) break; + if (nr>=24) break; ob= ob->id.next; } @@ -975,8 +975,8 @@ static void verify_logicbutton_func(bContext *UNUSED(C), void *data1, void *data { bSensor *sens= (bSensor*)data1; - if(sens->level && sens->tap) { - if(data2 == &(sens->level)) + if (sens->level && sens->tap) { + if (data2 == &(sens->level)) sens->tap= 0; else sens->level= 0; @@ -991,7 +991,7 @@ static void test_scriptpoin_but(struct bContext *C, const char *name, ID **idpp) static void test_actionpoin_but(struct bContext *C, const char *name, ID **idpp) { *idpp= BLI_findstring(&CTX_data_main(C)->action, name, offsetof(ID, name) + 2); - if(*idpp) + if (*idpp) id_us_plus(*idpp); } @@ -999,28 +999,28 @@ static void test_actionpoin_but(struct bContext *C, const char *name, ID **idpp) static void test_obpoin_but(struct bContext *C, const char *name, ID **idpp) { *idpp= BLI_findstring(&CTX_data_main(C)->object, name, offsetof(ID, name) + 2); - if(*idpp) + if (*idpp) id_lib_extern(*idpp); /* checks lib data, sets correct flag for saving then */ } static void test_meshpoin_but(struct bContext *C, const char *name, ID **idpp) { *idpp= BLI_findstring(&CTX_data_main(C)->mesh, name, offsetof(ID, name) + 2); - if(*idpp) + if (*idpp) id_us_plus(*idpp); } static void test_matpoin_but(struct bContext *C, const char *name, ID **idpp) { *idpp= BLI_findstring(&CTX_data_main(C)->mat, name, offsetof(ID, name) + 2); - if(*idpp) + if (*idpp) id_us_plus(*idpp); } static void test_scenepoin_but(struct bContext *C, const char *name, ID **idpp) { *idpp= BLI_findstring(&CTX_data_main(C)->scene, name, offsetof(ID, name) + 2); - if(*idpp) + if (*idpp) id_us_plus(*idpp); } @@ -1028,11 +1028,11 @@ static void test_keyboard_event(struct bContext *UNUSED(C), void *arg_ks, void * { bKeyboardSensor *ks= (bKeyboardSensor*)arg_ks; - if(!ISKEYBOARD(ks->key)) + if (!ISKEYBOARD(ks->key)) ks->key= 0; - if(!ISKEYBOARD(ks->qual)) + if (!ISKEYBOARD(ks->qual)) ks->qual= 0; - if(!ISKEYBOARD(ks->qual2)) + if (!ISKEYBOARD(ks->qual2)) ks->qual2= 0; } @@ -1090,9 +1090,9 @@ static void get_armature_bone_constraint(Object *ob, const char *posechannel, co /* check that bone exist in the active object */ if (ob->type == OB_ARMATURE && ob->pose) { bPoseChannel *pchan= get_pose_channel(ob->pose, posechannel); - if(pchan) { + if (pchan) { bConstraint *con= BLI_findstring(&pchan->constraints, constraint_name, offsetof(bConstraint, name)); - if(con) { + if (con) { *constraint= con; } } @@ -1218,7 +1218,8 @@ static short draw_sensorbuttons(Object *ob, bSensor *sens, uiBlock *block, short uiDefBut(block, TEX, 1, "Material:", (short)(xco + 10 + 0.40 * (width-20)), (short)(yco-44), (short)(0.6*(width-20)), 19, &cs->materialName, 0, MAX_NAME, 0, 0, "Only look for Objects with this material"); - } else { + } + else { uiDefBut(block, TEX, 1, "Property:", (short)(xco + 10 + 0.40 * (width-20)), (short)(yco-44), (short)(0.6*(width-20)), 19, &cs->name, 0, MAX_NAME, 0, 0, "Only look for Objects with this property"); @@ -1352,14 +1353,14 @@ static short draw_sensorbuttons(Object *ob, bSensor *sens, uiBlock *block, short ps->name, 0, MAX_NAME, 0, 0, "Property name"); } - if(ps->type == SENS_PROP_INTERVAL) + if (ps->type == SENS_PROP_INTERVAL) { uiDefBut(block, TEX, 1, "Min: ", xco,yco-92,width/2, 19, ps->value, 0, MAX_NAME, 0, 0, "check for min value"); uiDefBut(block, TEX, 1, "Max: ", xco+width/2,yco-92,width/2, 19, ps->maxvalue, 0, MAX_NAME, 0, 0, "check for max value"); } - else if(ps->type == SENS_PROP_CHANGED) { + else if (ps->type == SENS_PROP_CHANGED) { /* pass */ } else { @@ -1469,7 +1470,7 @@ static short draw_sensorbuttons(Object *ob, bSensor *sens, uiBlock *block, short &ms->type, 0, 31, 0, 0, "Specify the type of event this mouse sensor should trigger on"); - if(ms->type==32) { + if (ms->type==32) { uiDefButBitS(block, TOG, SENS_MOUSE_FOCUS_PULSE, B_REDR, "Pulse",(short)(xco + 10) + (width*0.8f)-20,(short)(yco - 44), (short)(0.20 * (width-20)), 19, &ms->flag, 0.0, 0.0, 0, 0, "Moving the mouse over a different object generates a pulse"); @@ -1599,7 +1600,8 @@ static short draw_sensorbuttons(Object *ob, bSensor *sens, uiBlock *block, short str = "All Hat Events"; break; } - } else { + } + else { str = "All"; } @@ -1608,7 +1610,7 @@ static short draw_sensorbuttons(Object *ob, bSensor *sens, uiBlock *block, short &joy->flag, 0, 0, 0, 0, "Triggered by all events on this joysticks current type (axis/button/hat)"); } - if(joy->type == SENS_JOY_BUTTON) + if (joy->type == SENS_JOY_BUTTON) { if ((joy->flag & SENS_JOY_ANY_EVENT)==0) { uiDefButI(block, NUM, 1, "Number:", xco+10 + 0.6 * (width-20), yco-68, 0.4 * (width-20), 19, @@ -1616,7 +1618,7 @@ static short draw_sensorbuttons(Object *ob, bSensor *sens, uiBlock *block, short "Specify which button to use"); } } - else if(joy->type == SENS_JOY_AXIS) { + else if (joy->type == SENS_JOY_AXIS) { uiDefButS(block, NUM, 1, "Number:", xco+10, yco-68, 0.46 * (width-20), 19, &joy->axis, 1, 8.0, 100, 0, "Specify which axis pair to use, 1 is useually the main direction input"); @@ -1689,7 +1691,7 @@ static short draw_controllerbuttons(bController *cont, uiBlock *block, short xco case CONT_PYTHON: ysize= 28; - if(cont->data==NULL) init_controller(cont); + if (cont->data==NULL) init_controller(cont); pc= cont->data; UI_ThemeColor(TH_PANEL); @@ -1699,7 +1701,7 @@ static short draw_controllerbuttons(bController *cont, uiBlock *block, short xco uiBlockBeginAlign(block); uiDefButI(block, MENU, B_REDR, "Execution Method%t|Script%x0|Module%x1", xco+4,yco-23, 66, 19, &pc->mode, 0, 0, 0, 0, "Python script type (textblock or module - faster)"); - if(pc->mode==0) + if (pc->mode==0) uiDefIDPoinBut(block, test_scriptpoin_but, ID_TXT, 1, "", xco+70,yco-23,width-74, 19, &pc->text, "Blender textblock to run as a script"); else { uiDefBut(block, TEX, 1, "", xco+70,yco-23,(width-70)-25, 19, pc->module, 0, sizeof(pc->module), 0, 0, "Module name and function to run e.g. \"someModule.main\". Internal texts and external python files can be used"); @@ -1945,7 +1947,8 @@ static short draw_actuatorbuttons(Main *bmain, Object *ob, bActuator *act, uiBlo uiDefButBitS(block, TOG, ACT_ADD_LIN_VEL, 0, "use_additive",xco+45+3*wval+15, yco-129, 35, 19, &oa->flag, 0.0, 0.0, 0, 0, "Toggles between ADD and SET linV"); } - } else if (oa->type == ACT_OBJECT_SERVO) + } + else if (oa->type == ACT_OBJECT_SERVO) { ysize= 195; @@ -2026,7 +2029,7 @@ static short draw_actuatorbuttons(Main *bmain, Object *ob, bActuator *act, uiBlo &aa->end_reset, 0.0, 0.0, 0, 0, "Restore last frame when switching on/off, otherwise play from the start each time"); - if(aa->type == ACT_ACTION_FROM_PROP) { + if (aa->type == ACT_ACTION_FROM_PROP) { uiDefBut(block, TEX, 0, "Prop: ",xco+10, yco-44, width-20, 19, aa->name, 0.0, MAX_NAME, 0, 0, "Use this property to define the Action position"); } else { @@ -2084,7 +2087,7 @@ static short draw_actuatorbuttons(Main *bmain, Object *ob, bActuator *act, uiBlo "Let the ipo acts in local coordinates, used in Force and Add mode"); } - if(ia->type==ACT_IPO_FROM_PROP) { + if (ia->type==ACT_IPO_FROM_PROP) { uiDefBut(block, TEX, 0, "Prop: ", xco+10, yco-44, width-80, 19, ia->name, 0.0, MAX_NAME, 0, 0, @@ -2127,11 +2130,11 @@ static short draw_actuatorbuttons(Main *bmain, Object *ob, bActuator *act, uiBlo uiDefBut(block, TEX, 1, "Prop: ", xco+30,yco-44,width-60, 19, pa->name, 0, MAX_NAME, 0, 0, "Property name"); - if(pa->type==ACT_PROP_TOGGLE) { + if (pa->type==ACT_PROP_TOGGLE) { /* no ui */ ysize -= 22; } - else if(pa->type==ACT_PROP_COPY) { + else if (pa->type==ACT_PROP_COPY) { uiDefIDPoinBut(block, test_obpoin_but, ID_OB, 1, "OB:", xco+10, yco-64, (width-20)/2, 19, &(pa->ob), "Copy from this Object"); uiDefBut(block, TEX, 1, "Prop: ", xco+10+(width-20)/2, yco-64, (width-20)/2, 19, pa->value, 0, MAX_NAME, 0, 0, "Copy this property"); } @@ -2147,7 +2150,7 @@ static short draw_actuatorbuttons(Main *bmain, Object *ob, bActuator *act, uiBlo sa = act->data; sa->sndnr = 0; - if(sa->flag & ACT_SND_3D_SOUND) + if (sa->flag & ACT_SND_3D_SOUND) ysize = 180; else ysize = 92; @@ -2156,7 +2159,7 @@ static short draw_actuatorbuttons(Main *bmain, Object *ob, bActuator *act, uiBlo glRects(xco, yco-ysize, xco+width, yco); uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); - if(bmain->sound.first) { + if (bmain->sound.first) { IDnames_to_pupstring(&str, "Sound files", NULL, &(bmain->sound), (ID *)sa->sound, &(sa->sndnr)); /* reset this value, it is for handling the event */ sa->sndnr = 0; @@ -2164,7 +2167,7 @@ static short draw_actuatorbuttons(Main *bmain, Object *ob, bActuator *act, uiBlo uiDefButO(block, BUT, "sound.open", 0, "Load Sound", xco+wval+10, yco-22, wval, 19, "Load a sound file (remember to set caching on for small sounds that are played often)"); - if(sa->sound) { + if (sa->sound) { char dummy_str[] = "Sound mode %t|Play Stop %x0|Play End %x1|Loop Stop %x2|" "Loop End %x3|Loop Ping Pong Stop %x5|Loop Ping Pong %x4"; uiDefBut(block, TEX, B_IDNAME, "SO:",xco+30,yco-22,wval-20,19, @@ -2177,7 +2180,7 @@ static short draw_actuatorbuttons(Main *bmain, Object *ob, bActuator *act, uiBlo 12.0, 0, 0, "Sets the pitch of this sound"); uiDefButS(block, TOG | BIT, 0, "3D Sound", xco+10, yco-88, width-20, 19, &sa->flag, 0.0, 1.0, 0.0, 0.0, "Plays the sound positioned in 3D space"); - if(sa->flag & ACT_SND_3D_SOUND) { + if (sa->flag & ACT_SND_3D_SOUND) { uiDefButF(block, NUM, 0, "Minimum Gain: ", xco+10, yco-110, wval, 19, &sa->sound3D.min_gain, 0.0, 1.0, 0.0, 0.0, "The minimum gain of the sound, no matter how far it is away"); @@ -2229,7 +2232,7 @@ static short draw_actuatorbuttons(Main *bmain, Object *ob, bActuator *act, uiBlo uiDefButF(block, NUM, 0, "Min:", xco+10, yco-44, (width-60)/2, 19, &ca->min, 0.0, 20.0, 0, 0, ""); - if(ca->axis==0) ca->axis= 'x'; + if (ca->axis==0) ca->axis= 'x'; uiDefButS(block, ROW, 0, "X", xco+10+(width-60)/2, yco-44, 20, 19, &ca->axis, 4.0, (float)'x', 0, 0, "Camera tries to get behind the X axis"); uiDefButS(block, ROW, 0, "Y", xco+30+(width-60)/2, yco-44, 20, 19, &ca->axis, 4.0, (float)'y', 0, 0, "Camera tries to get behind the Y axis"); @@ -2243,7 +2246,7 @@ static short draw_actuatorbuttons(Main *bmain, Object *ob, bActuator *act, uiBlo eoa= act->data; - if(eoa->type==ACT_EDOB_ADD_OBJECT) { + if (eoa->type==ACT_EDOB_ADD_OBJECT) { ysize = 92; glRects(xco, yco-ysize, xco+width, yco); uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); @@ -2287,12 +2290,12 @@ static short draw_actuatorbuttons(Main *bmain, Object *ob, bActuator *act, uiBlo } - else if(eoa->type==ACT_EDOB_END_OBJECT) { + else if (eoa->type==ACT_EDOB_END_OBJECT) { ysize= 28; glRects(xco, yco-ysize, xco+width, yco); uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); } - else if(eoa->type==ACT_EDOB_REPLACE_MESH) { + else if (eoa->type==ACT_EDOB_REPLACE_MESH) { ysize= 48; glRects(xco, yco-ysize, xco+width, yco); uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); @@ -2302,7 +2305,7 @@ static short draw_actuatorbuttons(Main *bmain, Object *ob, bActuator *act, uiBlo uiDefButBitS(block, TOGN, ACT_EDOB_REPLACE_MESH_NOGFX, 0, "Gfx", xco+40 + (width-80)/2, yco-44, (width-80)/4, 19, &eoa->flag, 0, 0, 0, 0, "Replace the display mesh"); uiDefButBitS(block, TOG, ACT_EDOB_REPLACE_MESH_PHYS, 0, "Phys", xco+40 + (width-80)/2 +(width-80)/4, yco-44, (width-80)/4, 19, &eoa->flag, 0, 0, 0, 0, "Replace the physics mesh (triangle bounds only. compound shapes not supported)"); } - else if(eoa->type==ACT_EDOB_TRACK_TO) { + else if (eoa->type==ACT_EDOB_TRACK_TO) { ysize= 48; glRects(xco, yco-ysize, xco+width, yco); uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); @@ -2311,14 +2314,14 @@ static short draw_actuatorbuttons(Main *bmain, Object *ob, bActuator *act, uiBlo uiDefButI(block, NUM, 0, "Time:", xco+10+(width-20)/2, yco-44, (width-20)/2-40, 19, &eoa->time, 0.0, 2000.0, 0, 0, "Duration the tracking takes"); uiDefButS(block, TOG, 0, "3D", xco+width-50, yco-44, 40, 19, &eoa->flag, 0.0, 0.0, 0, 0, "Enable 3D tracking"); } - else if(eoa->type==ACT_EDOB_DYNAMICS) { + else if (eoa->type==ACT_EDOB_DYNAMICS) { ysize= 69; glRects(xco, yco-ysize, xco+width, yco); uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); str= "Dynamic Operation %t|Restore Dynamics %x0|Suspend Dynamics %x1|Enable Rigid Body %x2|Disable Rigid Body %x3|Set Mass %x4"; uiDefButS(block, MENU, B_REDR, str, xco+40, yco-44, (width-80), 19, &(eoa->dyn_operation), 0.0, 0.0, 0, 0, ""); - if(eoa->dyn_operation==4) { + if (eoa->dyn_operation==4) { uiDefButF(block, NUM, 0, "", xco+40, yco-63, width-80, 19, &eoa->mass, 0.0, 10000.0, 10, 0, "Mass for object"); @@ -2351,16 +2354,17 @@ static short draw_actuatorbuttons(Main *bmain, Object *ob, bActuator *act, uiBlo uiDefBut(block, LABEL, 0, "Min", xco+80, yco-45, (width-90)/2, 19, NULL, 0.0, 0.0, 0, 0, ""); uiDefBut(block, LABEL, 0, "Max", xco+80+(width-90)/2, yco-45, (width-90)/2, 19, NULL, 0.0, 0.0, 0, 0, ""); - if(coa->flag & ACT_CONST_LOCX) fp= coa->minloc; - else if(coa->flag & ACT_CONST_LOCY) fp= coa->minloc+1; - else if(coa->flag & ACT_CONST_LOCZ) fp= coa->minloc+2; - else if(coa->flag & ACT_CONST_ROTX) fp= coa->minrot; - else if(coa->flag & ACT_CONST_ROTY) fp= coa->minrot+1; + if (coa->flag & ACT_CONST_LOCX) fp= coa->minloc; + else if (coa->flag & ACT_CONST_LOCY) fp= coa->minloc+1; + else if (coa->flag & ACT_CONST_LOCZ) fp= coa->minloc+2; + else if (coa->flag & ACT_CONST_ROTX) fp= coa->minrot; + else if (coa->flag & ACT_CONST_ROTY) fp= coa->minrot+1; else fp= coa->minrot+2; uiDefButF(block, NUM, 0, "", xco+80, yco-65, (width-90)/2, 19, fp, -2000.0, 2000.0, 10, 0, ""); uiDefButF(block, NUM, 0, "", xco+80+(width-90)/2, yco-65, (width-90)/2, 19, fp+3, -2000.0, 2000.0, 10, 0, ""); - } else if (coa->type == ACT_CONST_TYPE_DIST) { + } + else if (coa->type == ACT_CONST_TYPE_DIST) { ysize= 106; glRects(xco, yco-ysize, xco+width, yco); @@ -2375,8 +2379,8 @@ static short draw_actuatorbuttons(Main *bmain, Object *ob, bActuator *act, uiBlo uiDefButBitS(block, TOG, ACT_CONST_LOCAL, 0, "L", xco+80+(width-115), yco-45, 25, 19, &coa->flag, 0.0, 0.0, 0, 0, "Set ray along object's axis or global axis"); - if(coa->mode & (ACT_CONST_DIRPX|ACT_CONST_DIRNX)) fp= coa->minloc; - else if(coa->mode & (ACT_CONST_DIRPY|ACT_CONST_DIRNY)) fp= coa->minloc+1; + if (coa->mode & (ACT_CONST_DIRPX|ACT_CONST_DIRNX)) fp= coa->minloc; + else if (coa->mode & (ACT_CONST_DIRPY|ACT_CONST_DIRNY)) fp= coa->minloc+1; else fp= coa->minloc+2; uiDefButF(block, NUM, 0, "", xco+80, yco-65, (width-115)/2, 19, fp+3, 0.0, 2000.0, 10, 0, "Maximum length of ray"); @@ -2400,7 +2404,8 @@ static short draw_actuatorbuttons(Main *bmain, Object *ob, bActuator *act, uiBlo &coa->flag, 0.0, 0.0, 0, 0, "Persistent actuator: stays active even if ray does not reach target"); uiDefButS(block, NUM, 0, "time", xco+50, yco-103, (width-60)/2, 19, &(coa->time), 0.0, 1000.0, 0, 0, "Maximum activation time in frame, 0 for unlimited"); uiDefButS(block, NUM, 0, "rotDamp", xco+50+(width-60)/2, yco-103, (width-60)/2, 19, &(coa->rotdamp), 0.0, 100.0, 0, 0, "Use a different damping for orientation"); - } else if (coa->type == ACT_CONST_TYPE_ORI) { + } + else if (coa->type == ACT_CONST_TYPE_ORI) { ysize= 87; glRects(xco, yco-ysize, xco+width, yco); @@ -2421,7 +2426,8 @@ static short draw_actuatorbuttons(Main *bmain, Object *ob, bActuator *act, uiBlo uiDefButS(block, NUM, 0, "time", xco+10, yco-84, 70, 19, &(coa->time), 0.0, 1000.0, 0, 0, "Maximum activation time in frame, 0 for unlimited"); uiDefButF(block, NUM, 0, "min", xco+80, yco-84, (width-115)/2, 19, &(coa->minloc[0]), 0.0, 180.0, 10, 1, "Minimum angle (in degree) to maintain with target direction. No correction is done if angle with target direction is between min and max"); uiDefButF(block, NUM, 0, "max", xco+80+(width-115)/2, yco-84, (width-115)/2, 19, &(coa->maxloc[0]), 0.0, 180.0, 10, 1, "Maximum angle (in degree) allowed with target direction. No correction is done if angle with target direction is between min and max"); - } else if (coa->type == ACT_CONST_TYPE_FH) { + } + else if (coa->type == ACT_CONST_TYPE_FH) { ysize= 106; glRects(xco, yco-ysize, xco+width, yco); @@ -2430,8 +2436,8 @@ static short draw_actuatorbuttons(Main *bmain, Object *ob, bActuator *act, uiBlo str= "Direction %t|None %x0|X axis %x1|Y axis %x2|Z axis %x4|-X axis %x8|-Y axis %x16|-Z axis %x32"; uiDefButS(block, MENU, B_REDR, str, xco+10, yco-65, 70, 19, &coa->mode, 0.0, 0.0, 0, 0, "Set the direction of the ray (in world coordinate)"); - if(coa->mode & (ACT_CONST_DIRPX|ACT_CONST_DIRNX)) fp= coa->minloc; - else if(coa->mode & (ACT_CONST_DIRPY|ACT_CONST_DIRNY)) fp= coa->minloc+1; + if (coa->mode & (ACT_CONST_DIRPX|ACT_CONST_DIRNX)) fp= coa->minloc; + else if (coa->mode & (ACT_CONST_DIRPY|ACT_CONST_DIRNY)) fp= coa->minloc+1; else fp= coa->minloc+2; uiDefButF(block, NUM, 0, "damp", xco+10, yco-45, (width-70)/2, 19, &coa->maxrot[0], 0.0, 1.0, 1, 0, "Damping factor of the Fh spring force"); @@ -2466,12 +2472,12 @@ static short draw_actuatorbuttons(Main *bmain, Object *ob, bActuator *act, uiBlo case ACT_SCENE: sca= act->data; - if(sca->type==ACT_SCENE_RESTART) { + if (sca->type==ACT_SCENE_RESTART) { ysize= 28; glRects(xco, yco-ysize, xco+width, yco); uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); } - else if(sca->type==ACT_SCENE_CAMERA) { + else if (sca->type==ACT_SCENE_CAMERA) { ysize= 48; glRects(xco, yco-ysize, xco+width, yco); @@ -2479,7 +2485,7 @@ static short draw_actuatorbuttons(Main *bmain, Object *ob, bActuator *act, uiBlo uiDefIDPoinBut(block, test_obpoin_but, ID_OB, 1, "OB:", xco+40, yco-44, (width-80), 19, &(sca->camera), "Set this Camera. Leave empty to refer to self object"); } - else if(sca->type==ACT_SCENE_SET) { + else if (sca->type==ACT_SCENE_SET) { ysize= 48; glRects(xco, yco-ysize, xco+width, yco); @@ -2487,7 +2493,7 @@ static short draw_actuatorbuttons(Main *bmain, Object *ob, bActuator *act, uiBlo uiDefIDPoinBut(block, test_scenepoin_but, ID_SCE, 1, "SCE:", xco+40, yco-44, (width-80), 19, &(sca->scene), "Set this Scene"); } - else if(sca->type==ACT_SCENE_ADD_FRONT) { + else if (sca->type==ACT_SCENE_ADD_FRONT) { ysize= 48; glRects(xco, yco-ysize, xco+width, yco); @@ -2495,7 +2501,7 @@ static short draw_actuatorbuttons(Main *bmain, Object *ob, bActuator *act, uiBlo uiDefIDPoinBut(block, test_scenepoin_but, ID_SCE, 1, "SCE:", xco+40, yco-44, (width-80), 19, &(sca->scene), "Add an Overlay Scene"); } - else if(sca->type==ACT_SCENE_ADD_BACK) { + else if (sca->type==ACT_SCENE_ADD_BACK) { ysize= 48; glRects(xco, yco-ysize, xco+width, yco); @@ -2503,7 +2509,7 @@ static short draw_actuatorbuttons(Main *bmain, Object *ob, bActuator *act, uiBlo uiDefIDPoinBut(block, test_scenepoin_but, ID_SCE, 1, "SCE:", xco+40, yco-44, (width-80), 19, &(sca->scene), "Add a Background Scene"); } - else if(sca->type==ACT_SCENE_REMOVE) { + else if (sca->type==ACT_SCENE_REMOVE) { ysize= 48; glRects(xco, yco-ysize, xco+width, yco); @@ -2511,7 +2517,7 @@ static short draw_actuatorbuttons(Main *bmain, Object *ob, bActuator *act, uiBlo uiDefIDPoinBut(block, test_scenepoin_but, ID_SCE, 1, "SCE:", xco+40, yco-44, (width-80), 19, &(sca->scene), "Remove a Scene"); } - else if(sca->type==ACT_SCENE_SUSPEND) { + else if (sca->type==ACT_SCENE_SUSPEND) { ysize= 48; glRects(xco, yco-ysize, xco+width, yco); @@ -2519,7 +2525,7 @@ static short draw_actuatorbuttons(Main *bmain, Object *ob, bActuator *act, uiBlo uiDefIDPoinBut(block, test_scenepoin_but, ID_SCE, 1, "SCE:", xco+40, yco-44, (width-80), 19, &(sca->scene), "Pause a Scene"); } - else if(sca->type==ACT_SCENE_RESUME) { + else if (sca->type==ACT_SCENE_RESUME) { ysize= 48; glRects(xco, yco-ysize, xco+width, yco); @@ -2578,11 +2584,11 @@ static short draw_actuatorbuttons(Main *bmain, Object *ob, bActuator *act, uiBlo str= "GroupKey types %t|Set Key %x6|Play %x0|Ping Pong %x1|Flipper %x2|Loop Stop %x3|Loop End %x4|Property %x5"; uiDefButS(block, MENU, 1, str, xco+20, yco-24, width-40, 19, &ga->type, 0, 0, 0, 0, ""); - if(ga->type==ACT_GROUP_SET) { + if (ga->type==ACT_GROUP_SET) { uiDefBut(block, TEX, 0, "Key: ", xco+20, yco-44, (width-10)/2, 19, ga->name, 0.0, MAX_NAME, 0, 0, "This name defines groupkey to be set"); uiDefButI(block, NUM, 0, "Frame:", xco+20+(width-10)/2, yco-44, (width-70)/2, 19, &ga->sta, 0.0, 2500.0, 0, 0, "Set this frame"); } - else if(ga->type==ACT_GROUP_FROM_PROP) { + else if (ga->type==ACT_GROUP_FROM_PROP) { uiDefBut(block, TEX, 0, "Prop: ", xco+20, yco-44, width-40, 19, ga->name, 0.0, MAX_NAME, 0, 0, "Use this property to define the Group position"); } else { @@ -2860,7 +2866,7 @@ static short draw_actuatorbuttons(Main *bmain, Object *ob, bActuator *act, uiBlo case ACT_PARENT: parAct = act->data; - if(parAct->type==ACT_PARENT_SET) { + if (parAct->type==ACT_PARENT_SET) { ysize= 48; glRects(xco, yco-ysize, xco+width, yco); @@ -2879,7 +2885,7 @@ static short draw_actuatorbuttons(Main *bmain, Object *ob, bActuator *act, uiBlo "Make this object ghost while parented (only if not compound)"); uiBlockEndAlign(block); } - else if(parAct->type==ACT_PARENT_REMOVE) { + else if (parAct->type==ACT_PARENT_REMOVE) { ysize= 28; glRects(xco, yco-ysize, xco+width, yco); @@ -2958,23 +2964,23 @@ static void do_sensor_menu(bContext *C, void *UNUSED(arg), int event) idar= get_selected_and_linked_obs(C, &count, slogic->scaflag); - for(a=0; ascaflag |= OB_SHOWSENS; - else if(event==1) ob->scaflag &= ~OB_SHOWSENS; + if (event==0 || event==2) ob->scaflag |= OB_SHOWSENS; + else if (event==1) ob->scaflag &= ~OB_SHOWSENS; } - for(a=0; asensors.first; while(sens) { - if(event==2) sens->flag |= SENS_SHOW; - else if(event==3) sens->flag &= ~SENS_SHOW; + if (event==2) sens->flag |= SENS_SHOW; + else if (event==3) sens->flag &= ~SENS_SHOW; sens= sens->next; } } - if(idar) MEM_freeN(idar); + if (idar) MEM_freeN(idar); } static uiBlock *sensor_menu(bContext *C, ARegion *ar, void *UNUSED(arg)) @@ -3007,23 +3013,23 @@ static void do_controller_menu(bContext *C, void *UNUSED(arg), int event) idar= get_selected_and_linked_obs(C, &count, slogic->scaflag); - for(a=0; ascaflag |= OB_SHOWCONT; - else if(event==1) ob->scaflag &= ~OB_SHOWCONT; + if (event==0 || event==2) ob->scaflag |= OB_SHOWCONT; + else if (event==1) ob->scaflag &= ~OB_SHOWCONT; } - for(a=0; acontrollers.first; while(cont) { - if(event==2) cont->flag |= CONT_SHOW; - else if(event==3) cont->flag &= ~CONT_SHOW; + if (event==2) cont->flag |= CONT_SHOW; + else if (event==3) cont->flag &= ~CONT_SHOW; cont= cont->next; } } - if(idar) MEM_freeN(idar); + if (idar) MEM_freeN(idar); } static uiBlock *controller_menu(bContext *C, ARegion *ar, void *UNUSED(arg)) @@ -3056,23 +3062,23 @@ static void do_actuator_menu(bContext *C, void *UNUSED(arg), int event) idar= get_selected_and_linked_obs(C, &count, slogic->scaflag); - for(a=0; ascaflag |= OB_SHOWACT; - else if(event==1) ob->scaflag &= ~OB_SHOWACT; + if (event==0 || event==2) ob->scaflag |= OB_SHOWACT; + else if (event==1) ob->scaflag &= ~OB_SHOWACT; } - for(a=0; aactuators.first; while(act) { - if(event==2) act->flag |= ACT_SHOW; - else if(event==3) act->flag &= ~ACT_SHOW; + if (event==2) act->flag |= ACT_SHOW; + else if (event==3) act->flag &= ~ACT_SHOW; act= act->next; } } - if(idar) MEM_freeN(idar); + if (idar) MEM_freeN(idar); } static uiBlock *actuator_menu(bContext *C, ARegion *ar, void *UNUSED(arg)) @@ -3212,10 +3218,11 @@ static void draw_sensor_header(uiLayout *layout, PointerRNA *ptr, PointerRNA *lo row= uiLayoutRow(box, 0); uiItemR(row, ptr, "show_expanded", UI_ITEM_R_NO_BG, "", ICON_NONE); - if(RNA_boolean_get(ptr, "show_expanded")) { + if (RNA_boolean_get(ptr, "show_expanded")) { uiItemR(row, ptr, "type", 0, "", ICON_NONE); uiItemR(row, ptr, "name", 0, "", ICON_NONE); - } else { + } + else { uiItemL(row, sensor_name(sens->type), ICON_NONE); uiItemL(row, sens->name, ICON_NONE); } @@ -3225,7 +3232,7 @@ static void draw_sensor_header(uiLayout *layout, PointerRNA *ptr, PointerRNA *lo && RNA_boolean_get(ptr, "show_expanded")) || RNA_boolean_get(ptr, "pin"))); uiItemR(sub, ptr, "pin", UI_ITEM_R_NO_BG, "", ICON_NONE); - if(RNA_boolean_get(ptr, "show_expanded")==0) { + if (RNA_boolean_get(ptr, "show_expanded")==0) { sub= uiLayoutRow(row, 1); uiItemEnumO(sub, "LOGIC_OT_sensor_move", "", ICON_TRIA_UP, "direction", 1); // up uiItemEnumO(sub, "LOGIC_OT_sensor_move", "", ICON_TRIA_DOWN, "direction", 2); // down @@ -3276,7 +3283,7 @@ static void draw_sensor_armature(uiLayout *layout, PointerRNA *ptr) PropertyRNA *bones_prop= NULL; uiLayout *row; - if(ob->type != OB_ARMATURE){ + if (ob->type != OB_ARMATURE) { uiItemL(layout, "Sensor only available for armatures", ICON_NONE); return; } @@ -3569,12 +3576,13 @@ static void draw_controller_header(uiLayout *layout, PointerRNA *ptr, int xco, i row= uiLayoutRow(box, 0); uiItemR(row, ptr, "show_expanded", UI_ITEM_R_NO_BG, "", ICON_NONE); - if(RNA_boolean_get(ptr, "show_expanded")) { + if (RNA_boolean_get(ptr, "show_expanded")) { uiItemR(row, ptr, "type", 0, "", ICON_NONE); uiItemR(row, ptr, "name", 0, "", ICON_NONE); /* XXX provisory for Blender 2.50Beta */ uiDefBlockBut(uiLayoutGetBlock(layout), controller_state_mask_menu, cont, state, (short)(xco+width-44), yco, 22+22, UI_UNIT_Y, "Set controller state index (from 1 to 30)"); - } else { + } + else { uiItemL(row, controller_name(cont->type), ICON_NONE); uiItemL(row, cont->name, ICON_NONE); uiItemL(row, state, ICON_NONE); @@ -3582,7 +3590,7 @@ static void draw_controller_header(uiLayout *layout, PointerRNA *ptr, int xco, i uiItemR(row, ptr, "use_priority", 0, "", ICON_NONE); - if(RNA_boolean_get(ptr, "show_expanded")==0) { + if (RNA_boolean_get(ptr, "show_expanded")==0) { sub= uiLayoutRow(row, 1); uiItemEnumO(sub, "LOGIC_OT_controller_move", "", ICON_TRIA_UP, "direction", 1); // up uiItemEnumO(sub, "LOGIC_OT_controller_move", "", ICON_TRIA_DOWN, "direction", 2); // down @@ -3659,10 +3667,11 @@ static void draw_actuator_header(uiLayout *layout, PointerRNA *ptr, PointerRNA * row= uiLayoutRow(box, 0); uiItemR(row, ptr, "show_expanded", UI_ITEM_R_NO_BG, "", ICON_NONE); - if(RNA_boolean_get(ptr, "show_expanded")) { + if (RNA_boolean_get(ptr, "show_expanded")) { uiItemR(row, ptr, "type", 0, "", ICON_NONE); uiItemR(row, ptr, "name", 0, "", ICON_NONE); - } else { + } + else { uiItemL(row, actuator_name(act->type), ICON_NONE); uiItemL(row, act->name, ICON_NONE); } @@ -3672,7 +3681,7 @@ static void draw_actuator_header(uiLayout *layout, PointerRNA *ptr, PointerRNA * && RNA_boolean_get(ptr, "show_expanded")) || RNA_boolean_get(ptr, "pin"))); uiItemR(sub, ptr, "pin", UI_ITEM_R_NO_BG, "", ICON_NONE); - if(RNA_boolean_get(ptr, "show_expanded")==0) { + if (RNA_boolean_get(ptr, "show_expanded")==0) { sub= uiLayoutRow(row, 1); uiItemEnumO(sub, "LOGIC_OT_actuator_move", "", ICON_TRIA_UP, "direction", 1); // up uiItemEnumO(sub, "LOGIC_OT_actuator_move", "", ICON_TRIA_DOWN, "direction", 2); // down @@ -3704,7 +3713,7 @@ static void draw_actuator_action(uiLayout *layout, PointerRNA *ptr) uiItemR(row, ptr, "use_continue_last_frame", 0, NULL, ICON_NONE); row= uiLayoutRow(layout, 0); - if((RNA_enum_get(ptr, "play_mode") == ACT_ACTION_FROM_PROP)) + if ((RNA_enum_get(ptr, "play_mode") == ACT_ACTION_FROM_PROP)) uiItemPointerR(row, ptr, "property", &settings_ptr, "properties", NULL, ICON_NONE); else { @@ -3738,7 +3747,7 @@ static void draw_actuator_armature(uiLayout *layout, PointerRNA *ptr) PointerRNA pose_ptr, pchan_ptr; PropertyRNA *bones_prop = NULL; - if(ob->type != OB_ARMATURE){ + if (ob->type != OB_ARMATURE) { uiItemL(layout, "Actuator only available for armatures", ICON_NONE); return; } @@ -3945,7 +3954,7 @@ static void draw_actuator_edit_object(uiLayout *layout, PointerRNA *ptr) case ACT_EDOB_END_OBJECT: break; case ACT_EDOB_REPLACE_MESH: - if(ob->type != OB_MESH) { + if (ob->type != OB_MESH) { uiItemL(layout, "Mode only available for mesh objects", ICON_NONE); break; } @@ -3963,7 +3972,7 @@ static void draw_actuator_edit_object(uiLayout *layout, PointerRNA *ptr) uiItemR(sub, ptr, "use_3d_tracking", UI_ITEM_R_TOGGLE, NULL, ICON_NONE); break; case ACT_EDOB_DYNAMICS: - if(ob->type != OB_MESH) { + if (ob->type != OB_MESH) { uiItemL(layout, "Mode only available for mesh objects", ICON_NONE); break; } @@ -4022,7 +4031,7 @@ static void draw_actuator_message(uiLayout *layout, PointerRNA *ptr, bContext *C row= uiLayoutRow(layout, 1); uiItemR(row, ptr, "body_type", 0, NULL, ICON_NONE); - if(RNA_enum_get(ptr, "body_type") == ACT_MESG_MESG) + if (RNA_enum_get(ptr, "body_type") == ACT_MESG_MESG) uiItemR(row, ptr, "body_message", 0, "", ICON_NONE); else // mode == ACT_MESG_PROP uiItemPointerR(row, ptr, "body_property", &settings_ptr, "properties", "", ICON_NONE); @@ -4199,7 +4208,7 @@ static void draw_actuator_random(uiLayout *layout, PointerRNA *ptr) row = uiLayoutRow(layout, 0); - switch (RNA_enum_get(ptr, "distribution")){ + switch (RNA_enum_get(ptr, "distribution")) { case ACT_RANDOM_BOOL_CONST: uiItemR(row, ptr, "use_always_true", UI_ITEM_R_TOGGLE, NULL, ICON_NONE); break; @@ -4267,7 +4276,7 @@ static void draw_actuator_shape_action(uiLayout *layout, PointerRNA *ptr) PointerRNA settings_ptr; uiLayout *row; - if(ob->type != OB_MESH){ + if (ob->type != OB_MESH) { uiItemL(layout, "Actuator only available for mesh objects", ICON_NONE); return; } @@ -4280,7 +4289,7 @@ static void draw_actuator_shape_action(uiLayout *layout, PointerRNA *ptr) uiItemR(row, ptr, "use_continue_last_frame", 0, NULL, ICON_NONE); row= uiLayoutRow(layout, 0); - if((RNA_enum_get(ptr, "mode") == ACT_ACTION_FROM_PROP)) + if ((RNA_enum_get(ptr, "mode") == ACT_ACTION_FROM_PROP)) uiItemPointerR(row, ptr, "property", &settings_ptr, "properties", NULL, ICON_NONE); else { @@ -4481,7 +4490,7 @@ static void logic_buttons_new(bContext *C, ARegion *ar) short a, count; int xco, yco, width; - if(ob==NULL) return; + if (ob==NULL) return; RNA_pointer_create(NULL, &RNA_SpaceLogicEditor, slogic, &logic_ptr); idar= get_selected_and_linked_obs(C, &count, slogic->scaflag); @@ -4491,7 +4500,7 @@ static void logic_buttons_new(bContext *C, ARegion *ar) uiBlockSetHandleFunc(block, do_logic_buts, NULL); /* loop over all objects and set visible/linked flags for the logic bricks */ - for(a=0; ascavisflag & OB_VIS_CONT) == 0) continue; + if ( (ob->scavisflag & OB_VIS_CONT) == 0) continue; /* Drawing the Controller Header common to all Selected Objects */ @@ -4595,7 +4604,7 @@ static void logic_buttons_new(bContext *C, ARegion *ar) uiItemS(layout); - for(cont= ob->controllers.first; cont; cont=cont->next) { + for (cont= ob->controllers.first; cont; cont=cont->next) { RNA_pointer_create((ID *)ob, &RNA_Controller, cont, &ptr); if (!(ob->scaflag & OB_ALLSTATE) && !(ob->state & cont->state_mask)) @@ -4647,14 +4656,14 @@ static void logic_buttons_new(bContext *C, ARegion *ar) uiItemR(row, &logic_ptr, "show_sensors_linked_controller", 0, "Link", ICON_NONE); uiItemR(row, &logic_ptr, "show_sensors_active_states", 0, "State", ICON_NONE); - for(a=0; ascavisflag & OB_VIS_SENS) == 0) continue; + if ((ob->scavisflag & OB_VIS_SENS) == 0) continue; row = uiLayoutRow(layout, 1); uiDefButBitS(block, TOG, OB_SHOWSENS, B_REDR, ob->id.name+2,(short)(xco-10), yco, (short)(width-30), UI_UNIT_Y, &ob->scaflag, 0, 31, 0, 0, "Object name, click to show/hide sensors"); @@ -4665,7 +4674,7 @@ static void logic_buttons_new(bContext *C, ARegion *ar) uiItemS(layout); - for(sens= ob->sensors.first; sens; sens=sens->next) { + for (sens= ob->sensors.first; sens; sens=sens->next) { RNA_pointer_create((ID *)ob, &RNA_Sensor, sens, &ptr); if ((ob->scaflag & OB_ALLSTATE) || @@ -4713,14 +4722,14 @@ static void logic_buttons_new(bContext *C, ARegion *ar) uiItemR(row, &logic_ptr, "show_actuators_linked_controller", 0, "Link", ICON_NONE); uiItemR(row, &logic_ptr, "show_actuators_active_states", 0, "State", ICON_NONE); - for(a=0; ascavisflag & OB_VIS_ACT) == 0) continue; + if ( (ob->scavisflag & OB_VIS_ACT) == 0) continue; row = uiLayoutRow(layout, 1); uiDefButBitS(block, TOG, OB_SHOWACT, B_REDR, ob->id.name+2,(short)(xco-10), yco, (short)(width-30), UI_UNIT_Y, &ob->scaflag, 0, 31, 0, 0, "Object name, click to show/hide actuators"); @@ -4731,7 +4740,7 @@ static void logic_buttons_new(bContext *C, ARegion *ar) uiItemS(layout); - for(act= ob->actuators.first; act; act=act->next) { + for (act= ob->actuators.first; act; act=act->next) { RNA_pointer_create((ID *)ob, &RNA_Actuator, act, &ptr); @@ -4773,7 +4782,7 @@ static void logic_buttons_new(bContext *C, ARegion *ar) uiEndBlock(C, block); uiDrawBlock(C, block); - if(idar) MEM_freeN(idar); + if (idar) MEM_freeN(idar); } void logic_buttons(bContext *C, ARegion *ar) @@ -4801,7 +4810,7 @@ void logic_buttons(bContext *C, ARegion *ar) return; } - if(ob==NULL) return; + if (ob==NULL) return; // uiSetButLock(object_is_libdata(ob), ERROR_LIBDATA_MESSAGE); BLI_snprintf(numstr, sizeof(numstr), "buttonswin %p", (void *)ar); @@ -4814,7 +4823,7 @@ void logic_buttons(bContext *C, ARegion *ar) /* clean ACT_LINKED and ACT_VISIBLE of all potentially visible actuators so that * we can determine which is actually linked/visible */ - for(a=0; aactuators.first; while(act) { @@ -4841,19 +4850,19 @@ void logic_buttons(bContext *C, ARegion *ar) uiDefButBitS(block, TOG, BUTS_CONT_LINK, B_REDR, "Link", xco+110+2*(width-100)/3, yco+35, (width-100)/3, UI_UNIT_Y, &slogic->scaflag, 0, 0, 0, 0, "Show linked Objects to Sensor/Actuator"); uiBlockEndAlign(block); - for(a=0; ascavisflag & OB_VIS_CONT) == 0) continue; + if ( (ob->scavisflag & OB_VIS_CONT) == 0) continue; /* presume it is only objects for now */ uiBlockBeginAlign(block); -// if(ob->controllers.first) uiSetCurFont(block, UI_HELVB); +// if (ob->controllers.first) uiSetCurFont(block, UI_HELVB); uiDefButBitS(block, TOG, OB_SHOWCONT, B_REDR, ob->id.name+2,(short)(xco-10), yco, (short)(width-30), UI_UNIT_Y, &ob->scaflag, 0, 0, 0, 0, "Active Object name"); -// if(ob->controllers.first) uiSetCurFont(block, UI_HELV); +// if (ob->controllers.first) uiSetCurFont(block, UI_HELV); uiDefButBitS(block, TOG, OB_ADDCONT, B_ADD_CONT, "Add",(short)(xco+width-40), yco, 50, UI_UNIT_Y, &ob->scaflag, 0, 0, 0, 0, "Add a new Controller"); uiBlockEndAlign(block); yco-=20; @@ -4872,7 +4881,7 @@ void logic_buttons(bContext *C, ARegion *ar) cont = cont->next; } - if(ob->scaflag & OB_SHOWCONT) { + if (ob->scaflag & OB_SHOWCONT) { /* first show the state */ uiDefBlockBut(block, object_state_mask_menu, ob, "State", (short)(xco-10), (short)(yco-10), 36, UI_UNIT_Y, "Object state menu: store and retrieve initial state"); @@ -4924,7 +4933,7 @@ void logic_buttons(bContext *C, ARegion *ar) sprintf(numstr, "%d", first_bit(cont->state_mask)+1); uiDefBlockBut(block, controller_state_mask_menu, cont, numstr, (short)(xco+width-44), yco, 22, UI_UNIT_Y, "Set controller state index (from 1 to 30)"); - if(cont->flag & CONT_SHOW) { + if (cont->flag & CONT_SHOW) { cont->otype= cont->type; uiDefButS(block, MENU, B_CHANGE_CONT, controller_pup(),(short)(xco+22), yco, 70, UI_UNIT_Y, &cont->type, 0, 0, 0, 0, "Controller type"); but = uiDefBut(block, TEX, 1, "", (short)(xco+92), yco, (short)(width-158), UI_UNIT_Y, cont->name, 0, MAX_NAME, 0, 0, "Controller name"); @@ -4932,7 +4941,7 @@ void logic_buttons(bContext *C, ARegion *ar) ycoo= yco; yco= draw_controllerbuttons(cont, block, xco, yco, width); - if(yco-6 < ycoo) ycoo= (yco+ycoo-20)/2; + if (yco-6 < ycoo) ycoo= (yco+ycoo-20)/2; } else { cpack(0x999999); @@ -4980,23 +4989,23 @@ void logic_buttons(bContext *C, ARegion *ar) uiDefButBitS(block, TOG, BUTS_SENS_STATE, B_REDR, "State", xco+80+3*(width-70)/4, yco+35, (width-70)/4, UI_UNIT_Y, &slogic->scaflag, 0, 0, 0, 0, "Show only sensors connected to active states"); uiBlockEndAlign(block); - for(a=0; ascavisflag & OB_VIS_SENS) == 0) continue; + if ( (ob->scavisflag & OB_VIS_SENS) == 0) continue; /* presume it is only objects for now */ uiBlockBeginAlign(block); -// if(ob->sensors.first) uiSetCurFont(block, UI_HELVB); +// if (ob->sensors.first) uiSetCurFont(block, UI_HELVB); uiDefButBitS(block, TOG, OB_SHOWSENS, B_REDR, ob->id.name+2,(short)(xco-10), yco, (short)(width-30), UI_UNIT_Y, &ob->scaflag, 0, 31, 0, 0, "Object name, click to show/hide sensors"); -// if(ob->sensors.first) uiSetCurFont(block, UI_HELV); +// if (ob->sensors.first) uiSetCurFont(block, UI_HELV); uiDefButBitS(block, TOG, OB_ADDSENS, B_ADD_SENS, "Add",(short)(xco+width-40), yco, 50, UI_UNIT_Y, &ob->scaflag, 0, 0, 0, 0, "Add a new Sensor"); uiBlockEndAlign(block); yco-=20; - if(ob->scaflag & OB_SHOWSENS) { + if (ob->scaflag & OB_SHOWSENS) { sens= ob->sensors.first; while(sens) { @@ -5023,7 +5032,7 @@ void logic_buttons(bContext *C, ARegion *ar) sens->otype= sens->type; yco= draw_sensorbuttons(ob, sens, block, xco, yco, width); - if(yco-6 < ycoo) ycoo= (yco+ycoo-20)/2; + if (yco-6 < ycoo) ycoo= (yco+ycoo-20)/2; } else { set_col_sensor(sens->type, 1); @@ -5061,22 +5070,22 @@ void logic_buttons(bContext *C, ARegion *ar) uiDefButBitS(block, TOG, BUTS_ACT_LINK, B_REDR, "Link", xco+110+2*(width-100)/4, yco+35, (width-100)/4, UI_UNIT_Y, &slogic->scaflag, 0, 0, 0, 0, "Show linked Objects to Controller"); uiDefButBitS(block, TOG, BUTS_ACT_STATE, B_REDR, "State", xco+110+3*(width-100)/4, yco+35, (width-100)/4, UI_UNIT_Y, &slogic->scaflag, 0, 0, 0, 0, "Show only actuators connected to active states"); uiBlockEndAlign(block); - for(a=0; ascavisflag & OB_VIS_ACT) == 0) continue; + if ( (ob->scavisflag & OB_VIS_ACT) == 0) continue; /* presume it is only objects for now */ uiBlockBeginAlign(block); -// if(ob->actuators.first) uiSetCurFont(block, UI_HELVB); +// if (ob->actuators.first) uiSetCurFont(block, UI_HELVB); uiDefButBitS(block, TOG, OB_SHOWACT, B_REDR, ob->id.name+2,(short)(xco-10), yco,(short)(width-30), UI_UNIT_Y, &ob->scaflag, 0, 31, 0, 0, "Object name, click to show/hide actuators"); -// if(ob->actuators.first) uiSetCurFont(block, UI_HELV); +// if (ob->actuators.first) uiSetCurFont(block, UI_HELV); uiDefButBitS(block, TOG, OB_ADDACT, B_ADD_ACT, "Add",(short)(xco+width-40), yco, 50, UI_UNIT_Y, &ob->scaflag, 0, 0, 0, 0, "Add a new Actuator"); uiBlockEndAlign(block); yco-=20; - if(ob->scaflag & OB_SHOWACT) { + if (ob->scaflag & OB_SHOWACT) { act= ob->actuators.first; while(act) { @@ -5093,7 +5102,7 @@ void logic_buttons(bContext *C, ARegion *ar) uiDefIconButBitS(block, ICONTOG, ACT_PIN, B_REDR, ICON_PINNED, (short)(xco+width-44), yco, 22, UI_UNIT_Y, &act->flag, 0, 0, 0, 0, "Display when not linked to a visible states controller"); uiDefIconButBitS(block, ICONTOG, ACT_SHOW, B_REDR, ICON_RIGHTARROW, (short)(xco+width-22), yco, 22, UI_UNIT_Y, &act->flag, 0, 0, 0, 0, "Display the actuator"); - if(act->flag & ACT_SHOW) { + if (act->flag & ACT_SHOW) { act->otype= act->type; uiDefButS(block, MENU, B_CHANGE_ACT, actuator_pup(ob), (short)(xco+22), yco, 90, UI_UNIT_Y, &act->type, 0, 0, 0, 0, "Actuator type"); but = uiDefBut(block, TEX, 1, "", (short)(xco+112), yco, (short)(width-(pin?156:134)), UI_UNIT_Y, act->name, 0, MAX_NAME, 0, 0, "Actuator name"); @@ -5101,7 +5110,7 @@ void logic_buttons(bContext *C, ARegion *ar) ycoo= yco; yco= draw_actuatorbuttons(bmain, ob, act, block, xco, yco, width); - if(yco-6 < ycoo) ycoo= (yco+ycoo-20)/2; + if (yco-6 < ycoo) ycoo= (yco+ycoo-20)/2; } else { set_col_actuator(act->type, 1); @@ -5136,7 +5145,7 @@ void logic_buttons(bContext *C, ARegion *ar) uiEndBlock(C, block); uiDrawBlock(C, block); - if(idar) MEM_freeN(idar); + if (idar) MEM_freeN(idar); } diff --git a/source/blender/editors/space_logic/space_logic.c b/source/blender/editors/space_logic/space_logic.c index c58fd072887..1b6d72cbc3e 100644 --- a/source/blender/editors/space_logic/space_logic.c +++ b/source/blender/editors/space_logic/space_logic.c @@ -63,13 +63,13 @@ ARegion *logic_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"); @@ -151,7 +151,7 @@ static void logic_free(SpaceLink *UNUSED(sl)) { // Spacelogic *slogic= (SpaceLogic*) sl; -// if(slogic->gpd) +// if (slogic->gpd) // XXX free_gpencil_data(slogic->gpd); } @@ -213,7 +213,7 @@ static void logic_listener(ARegion *ar, wmNotifier *wmn) case NC_OBJECT: 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_nla/nla_buttons.c b/source/blender/editors/space_nla/nla_buttons.c index a3a84e4113c..de42e4a783d 100644 --- a/source/blender/editors/space_nla/nla_buttons.c +++ b/source/blender/editors/space_nla/nla_buttons.c @@ -518,7 +518,7 @@ static int nla_properties(bContext *C, wmOperator *UNUSED(op)) ScrArea *sa= CTX_wm_area(C); ARegion *ar= nla_has_buttons_region(sa); - if(ar) + if (ar) ED_region_toggle_hidden(C, ar); return OPERATOR_FINISHED; diff --git a/source/blender/editors/space_nla/nla_channels.c b/source/blender/editors/space_nla/nla_channels.c index 205691c69b5..c242a1c1323 100644 --- a/source/blender/editors/space_nla/nla_channels.c +++ b/source/blender/editors/space_nla/nla_channels.c @@ -454,7 +454,7 @@ static int nlaedit_delete_tracks_exec (bContext *C, wmOperator *UNUSED(op)) /* delete tracks */ for (ale= anim_data.first; ale; ale= ale->next) { - if(ale->type == ANIMTYPE_NLATRACK) { + if (ale->type == ANIMTYPE_NLATRACK) { NlaTrack *nlt= (NlaTrack *)ale->data; AnimData *adt= ale->adt; diff --git a/source/blender/editors/space_nla/space_nla.c b/source/blender/editors/space_nla/space_nla.c index 4d126984529..4dc3aef7d2c 100644 --- a/source/blender/editors/space_nla/space_nla.c +++ b/source/blender/editors/space_nla/space_nla.c @@ -69,7 +69,7 @@ ARegion *nla_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 main */ ar= BKE_area_find_region_type(sa, RGN_TYPE_WINDOW); @@ -371,7 +371,7 @@ static void nla_region_listener(ARegion *ar, wmNotifier *wmn) } break; default: - if(wmn->data==ND_KEYS) + if (wmn->data==ND_KEYS) ED_region_tag_redraw(ar); break; } @@ -413,11 +413,11 @@ static void nla_main_area_listener(ARegion *ar, wmNotifier *wmn) } break; case NC_ID: - if(wmn->action == NA_RENAME) + if (wmn->action == NA_RENAME) ED_region_tag_redraw(ar); break; default: - if(wmn->data==ND_KEYS) + if (wmn->data==ND_KEYS) ED_region_tag_redraw(ar); } } @@ -446,12 +446,12 @@ static void nla_channel_area_listener(ARegion *ar, wmNotifier *wmn) } break; case NC_ID: - if(wmn->action == NA_RENAME) + if (wmn->action == NA_RENAME) ED_region_tag_redraw(ar); break; default: - if(wmn->data==ND_KEYS) + if (wmn->data==ND_KEYS) ED_region_tag_redraw(ar); } } @@ -487,7 +487,7 @@ static void nla_listener(ScrArea *sa, wmNotifier *wmn) } break; case NC_SPACE: - if(wmn->data == ND_SPACE_NLA) + if (wmn->data == ND_SPACE_NLA) ED_area_tag_redraw(sa); break; } diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c index b76eb6a4879..7176c86cb11 100644 --- a/source/blender/editors/space_node/drawnode.c +++ b/source/blender/editors/space_node/drawnode.c @@ -85,7 +85,7 @@ static void node_sync_cb(bContext *UNUSED(C), void *snode_v, void *node_v) { SpaceNode *snode= snode_v; - if(snode->treetype==NTREE_SHADER) { + if (snode->treetype==NTREE_SHADER) { nodeShaderSynchronizeID(node_v, 1); // allqueue(REDRAWBUTSSHADING, 0); } @@ -283,7 +283,7 @@ static void node_draw_socket_new(bNodeSocket *sock, float size) glColor3ub(180, 180, 180); glBegin(GL_POLYGON); - for(a=0; a<16; a++) + for (a=0; a<16; a++) glVertex2f(x+size*si[a], y+size*co[a]); glEnd(); @@ -291,7 +291,7 @@ static void node_draw_socket_new(bNodeSocket *sock, float size) glEnable(GL_BLEND); glEnable( GL_LINE_SMOOTH ); glBegin(GL_LINE_LOOP); - for(a=0; a<16; a++) + for (a=0; a<16; a++) glVertex2f(x+size*si[a], y+size*co[a]); glEnd(); glDisable( GL_LINE_SMOOTH ); @@ -336,7 +336,7 @@ static void node_buts_mix_rgb(uiLayout *layout, bContext *UNUSED(C), PointerRNA row= uiLayoutRow(layout, 1); uiItemR(row, ptr, "blend_type", 0, "", ICON_NONE); - if(ntree->type == NTREE_COMPOSIT) + if (ntree->type == NTREE_COMPOSIT) uiItemR(row, ptr, "use_alpha", 0, "", ICON_IMAGE_RGB_ALPHA); } @@ -348,9 +348,9 @@ static void node_buts_time(uiLayout *layout, bContext *UNUSED(C), PointerRNA *pt bNode *node= ptr->data; CurveMapping *cumap= node->storage; - if(cumap) { + if (cumap) { cumap->flag |= CUMA_DRAW_CFRA; - if(node->custom1custom2) + if (node->custom1custom2) cumap->sample[0]= (float)(CFRA - node->custom1)/(float)(node->custom2-node->custom1); } #endif @@ -385,7 +385,7 @@ static void node_buts_curvecol(uiLayout *layout, bContext *UNUSED(C), PointerRNA bNode *node= ptr->data; CurveMapping *cumap= node->storage; - if(_sample_col) { + if (_sample_col) { cumap->flag |= CUMA_DRAW_SAMPLE; copy_v3_v3(cumap->sample, _sample_col); } @@ -427,9 +427,9 @@ static void node_browse_tex_cb(bContext *C, void *ntree_v, void *node_v) bNode *node= node_v; Tex *tex; - if(node->menunr<1) return; + if (node->menunr<1) return; - if(node->id) { + if (node->id) { node->id->us--; node->id= NULL; } @@ -441,7 +441,7 @@ static void node_browse_tex_cb(bContext *C, void *ntree_v, void *node_v) nodeSetActive(ntree, node); - if( ntree->type == NTREE_TEXTURE ) + if ( ntree->type == NTREE_TEXTURE ) ntreeTexCheckCyclics( ntree ); // allqueue(REDRAWBUTSSHADING, 0); @@ -496,7 +496,7 @@ static void node_buts_texture(uiLayout *layout, bContext *UNUSED(C), PointerRNA uiItemR(layout, ptr, "texture", 0, "", ICON_NONE); - if(multi) { + if (multi) { /* Number Drawing not optimal here, better have a list*/ uiItemR(layout, ptr, "node_output", 0, "", ICON_NONE); } @@ -559,8 +559,8 @@ static void node_update_group(const bContext *C, bNodeTree *ntree, bNode *gnode) rect->ymin = rect->ymax = locy; counter= 1; - for(node= ngroup->nodes.first; node; node= node->next) { - if(counter) { + for (node= ngroup->nodes.first; node; node= node->next) { + if (counter) { *rect= node->totr; counter= 0; } @@ -994,9 +994,9 @@ static void node_browse_text_cb(bContext *C, void *ntree_v, void *node_v) bNode *node= node_v; /* ID *oldid; */ /* UNUSED */ - if(node->menunr<1) return; + if (node->menunr<1) return; - if(node->id) { + if (node->id) { node->id->us--; } /* oldid= node->id; */ /* UNUSED */ @@ -1021,7 +1021,7 @@ static void node_shader_buts_material(uiLayout *layout, bContext *C, PointerRNA uiTemplateID(layout, C, ptr, "material", "MATERIAL_OT_new", NULL, NULL); - if(!node->id) return; + if (!node->id) return; col= uiLayoutColumn(layout, 0); uiItemR(col, ptr, "use_diffuse", 0, NULL, ICON_NONE); @@ -1066,7 +1066,7 @@ static void node_shader_buts_geometry(uiLayout *layout, bContext *C, PointerRNA col= uiLayoutColumn(layout, 0); - if(obptr.data && RNA_enum_get(&obptr, "type") == OB_MESH) { + if (obptr.data && RNA_enum_get(&obptr, "type") == OB_MESH) { PointerRNA dataptr= RNA_pointer_get(&obptr, "data"); uiItemPointerR(col, ptr, "uv_layer", &dataptr, "uv_textures", "", ICON_NONE); @@ -1146,7 +1146,7 @@ static void node_shader_buts_dynamic(uiLayout *layout, bContext *C, PointerRNA * int xoff=0; /* B_NODE_EXEC is handled in butspace.c do_node_buts */ - if(!node->id) { + if (!node->id) { const char *strp; IDnames_to_pupstring(&strp, NULL, "", &(bmain->text), NULL, NULL); node->menunr= 0; @@ -1155,7 +1155,7 @@ static void node_shader_buts_dynamic(uiLayout *layout, bContext *C, PointerRNA * &node->menunr, 0, 0, 0, 0, "Browses existing choices"); uiButSetFunc(bt, node_browse_text_cb, ntree, node); xoff=19; - if(strp) MEM_freeN((void *)strp); + if (strp) MEM_freeN((void *)strp); } else { bt = uiDefBut(block, BUT, B_NOP, "Update", @@ -1269,7 +1269,7 @@ static void node_composit_buts_image(uiLayout *layout, bContext *C, PointerRNA * uiTemplateID(layout, C, ptr, "image", NULL, "IMAGE_OT_open", NULL); - if(!node->id) return; + if (!node->id) return; prop = RNA_struct_find_property(ptr, "image"); if (!prop || RNA_property_type(prop) != PROP_POINTER) return; @@ -1281,7 +1281,7 @@ static void node_composit_buts_image(uiLayout *layout, bContext *C, PointerRNA * source= RNA_enum_get(&imaptr, "source"); - if(source == IMA_SRC_SEQUENCE) { + if (source == IMA_SRC_SEQUENCE) { /* don't use iuser->framenr directly because it may not be updated if auto-refresh is off */ Scene *scene= CTX_data_scene(C); ImageUser *iuser= node->storage; @@ -1321,7 +1321,7 @@ static void node_composit_buts_renderlayers(uiLayout *layout, bContext *C, Point uiTemplateID(layout, C, ptr, "scene", NULL, NULL, NULL); - if(!node->id) return; + if (!node->id) return; col= uiLayoutColumn(layout, 0); row = uiLayoutRow(col, 0); @@ -1534,12 +1534,13 @@ static void node_composit_buts_crop(uiLayout *layout, bContext *UNUSED(C), Point uiItemR(layout, ptr, "relative", 0, NULL, ICON_NONE); col= uiLayoutColumn(layout, 1); - if (RNA_boolean_get(ptr, "relative")){ + if (RNA_boolean_get(ptr, "relative")) { uiItemR(col, ptr, "rel_min_x", 0, "Left", ICON_NONE); uiItemR(col, ptr, "rel_max_x", 0, "Right", ICON_NONE); uiItemR(col, ptr, "rel_min_y", 0, "Up", ICON_NONE); uiItemR(col, ptr, "rel_max_y", 0, "Down", ICON_NONE); - } else { + } + else { uiItemR(col, ptr, "min_x", 0, "Left", ICON_NONE); uiItemR(col, ptr, "max_x", 0, "Right", ICON_NONE); uiItemR(col, ptr, "min_y", 0, "Up", ICON_NONE); @@ -1652,7 +1653,7 @@ static void node_composit_buts_color_spill(uiLayout *layout, bContext *UNUSED(C) col= uiLayoutColumn(layout, 0); uiItemR(col, ptr, "limit_method", 0, NULL, ICON_NONE); - if(RNA_enum_get(ptr, "limit_method")==0) { + if (RNA_enum_get(ptr, "limit_method")==0) { uiItemL(col, "Limiting Channel:", ICON_NONE); row=uiLayoutRow(col,0); uiItemR(row, ptr, "limit_channel", UI_ITEM_R_EXPAND, NULL, ICON_NONE); @@ -1707,7 +1708,7 @@ static void node_composit_buts_channel_matte(uiLayout *layout, bContext *UNUSED( col = uiLayoutColumn(layout, 0); uiItemR(col, ptr, "limit_method", 0, NULL, ICON_NONE); - if(RNA_enum_get(ptr, "limit_method")==0) { + if (RNA_enum_get(ptr, "limit_method")==0) { uiItemL(col, "Limiting Channel:", ICON_NONE); row=uiLayoutRow(col,0); uiItemR(row, ptr, "limit_channel", UI_ITEM_R_EXPAND, NULL, ICON_NONE); @@ -1843,7 +1844,8 @@ static void node_composit_buts_colorbalance(uiLayout *layout, bContext *UNUSED(C row = uiLayoutRow(col, 0); uiItemR(row, ptr, "gain", 0, NULL, ICON_NONE); - } else { + } + else { split = uiLayoutSplit(layout, 0, 0); col = uiLayoutColumn(split, 0); @@ -1877,7 +1879,8 @@ static void node_composit_buts_colorbalance_but(uiLayout *layout, bContext *UNUS uiTemplateColorWheel(layout, ptr, "gain", 1, 1, 1, 1); uiItemR(layout, ptr, "gain", 0, NULL, ICON_NONE); - } else { + } + else { uiTemplateColorWheel(layout, ptr, "offset", 1, 1, 0, 1); uiItemR(layout, ptr, "offset", 0, NULL, ICON_NONE); @@ -1911,7 +1914,7 @@ static void node_composit_buts_stabilize2d(uiLayout *layout, bContext *C, Pointe uiTemplateID(layout, C, ptr, "clip", NULL, "CLIP_OT_open", NULL); - if(!node->id) + if (!node->id) return; uiItemR(layout, ptr, "filter_type", 0, "", 0); @@ -1928,7 +1931,7 @@ static void node_composit_buts_moviedistortion(uiLayout *layout, bContext *C, Po uiTemplateID(layout, C, ptr, "clip", NULL, "CLIP_OT_open", NULL); - if(!node->id) + if (!node->id) return; uiItemR(layout, ptr, "distortion_type", 0, "", 0); @@ -2194,7 +2197,7 @@ static void node_texture_buts_proc(uiLayout *layout, bContext *UNUSED(C), Pointe break; case TEX_VORONOI: uiItemR(col, &tex_ptr, "distance_metric", 0, "", ICON_NONE); - if(tex->vn_distm == TEX_MINKOVSKY) { + if (tex->vn_distm == TEX_MINKOVSKY) { uiItemR(col, &tex_ptr, "minkovsky_exponent", 0, NULL, ICON_NONE); } uiItemR(col, &tex_ptr, "color_mode", 0, "", ICON_NONE); @@ -2216,7 +2219,7 @@ static void node_texture_buts_output(uiLayout *layout, bContext *UNUSED(C), Poin static void node_texture_set_butfunc(bNodeType *ntype) { ntype->uifuncbut = NULL; - if( ntype->type >= TEX_NODE_PROC && ntype->type < TEX_NODE_PROC_MAX ) { + if ( ntype->type >= TEX_NODE_PROC && ntype->type < TEX_NODE_PROC_MAX ) { ntype->uifunc = node_texture_buts_proc; } else switch(ntype->type) { @@ -2329,11 +2332,11 @@ void ED_init_node_butfuncs(void) void draw_nodespace_back_pix(ARegion *ar, SpaceNode *snode, int color_manage) { - if((snode->flag & SNODE_BACKDRAW) && snode->treetype==NTREE_COMPOSIT) { + if ((snode->flag & SNODE_BACKDRAW) && snode->treetype==NTREE_COMPOSIT) { Image *ima= BKE_image_verify_viewer(IMA_TYPE_COMPOSITE, "Viewer Node"); void *lock; ImBuf *ibuf= BKE_image_acquire_ibuf(ima, NULL, &lock); - if(ibuf) { + if (ibuf) { float x, y; glMatrixMode(GL_PROJECTION); @@ -2342,7 +2345,7 @@ void draw_nodespace_back_pix(ARegion *ar, SpaceNode *snode, int color_manage) glPushMatrix(); /* keep this, saves us from a version patch */ - if(snode->zoom==0.0f) snode->zoom= 1.0f; + if (snode->zoom==0.0f) snode->zoom= 1.0f; /* somehow the offset has to be calculated inverse */ @@ -2353,26 +2356,27 @@ void draw_nodespace_back_pix(ARegion *ar, SpaceNode *snode, int color_manage) x = (ar->winx-snode->zoom*ibuf->x)/2 + snode->xof; y = (ar->winy-snode->zoom*ibuf->y)/2 + snode->yof; - if(!ibuf->rect) { - if(color_manage) + if (!ibuf->rect) { + if (color_manage) ibuf->profile = IB_PROFILE_LINEAR_RGB; else ibuf->profile = IB_PROFILE_NONE; IMB_rect_from_float(ibuf); } - if(ibuf->rect) { + if (ibuf->rect) { if (snode->flag & SNODE_SHOW_ALPHA) { glPixelZoom(snode->zoom, snode->zoom); /* swap bytes, so alpha is most significant one, then just draw it as luminance int */ - if(ENDIAN_ORDER == B_ENDIAN) + if (ENDIAN_ORDER == B_ENDIAN) glPixelStorei(GL_UNPACK_SWAP_BYTES, 1); glaDrawPixelsSafe(x, y, ibuf->x, ibuf->y, ibuf->x, GL_LUMINANCE, GL_UNSIGNED_INT, ibuf->rect); glPixelStorei(GL_UNPACK_SWAP_BYTES, 0); glPixelZoom(1.0f, 1.0f); - } else if (snode->flag & SNODE_USE_ALPHA) { + } + else if (snode->flag & SNODE_USE_ALPHA) { glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glPixelZoom(snode->zoom, snode->zoom); @@ -2381,7 +2385,8 @@ void draw_nodespace_back_pix(ARegion *ar, SpaceNode *snode, int color_manage) glPixelZoom(1.0f, 1.0f); glDisable(GL_BLEND); - } else { + } + else { glPixelZoom(snode->zoom, snode->zoom); glaDrawPixelsSafe(x, y, ibuf->x, ibuf->y, ibuf->x, GL_RGBA, GL_UNSIGNED_BYTE, ibuf->rect); @@ -2407,10 +2412,10 @@ static void draw_nodespace_back_tex(ScrArea *sa, SpaceNode *snode) draw_nodespace_grid(snode); - if(snode->flag & SNODE_BACKDRAW) { + if (snode->flag & SNODE_BACKDRAW) { Image *ima= BKE_image_verify_viewer(IMA_TYPE_COMPOSITE, "Viewer Node"); ImBuf *ibuf= BKE_image_get_ibuf(ima, NULL); - if(ibuf) { + if (ibuf) { int x, y; float zoom = 1.0; @@ -2421,7 +2426,7 @@ static void draw_nodespace_back_tex(ScrArea *sa, SpaceNode *snode) glaDefine2DArea(&sa->winrct); - if(ibuf->x > sa->winx || ibuf->y > sa->winy) { + if (ibuf->x > sa->winx || ibuf->y > sa->winy) { float zoomx, zoomy; zoomx= (float)sa->winx/ibuf->x; zoomy= (float)sa->winy/ibuf->y; @@ -2434,9 +2439,9 @@ static void draw_nodespace_back_tex(ScrArea *sa, SpaceNode *snode) glPixelZoom(zoom, zoom); glColor4f(1.0, 1.0, 1.0, 1.0); - if(ibuf->rect) + if (ibuf->rect) glaDrawPixelsTex(x, y, ibuf->x, ibuf->y, GL_UNSIGNED_BYTE, ibuf->rect); - else if(ibuf->channels==4) + else if (ibuf->channels==4) glaDrawPixelsTex(x, y, ibuf->x, ibuf->y, GL_FLOAT, ibuf->rect_float); glPixelZoom(1.0, 1.0); @@ -2456,21 +2461,21 @@ int node_link_bezier_points(View2D *v2d, SpaceNode *snode, bNodeLink *link, floa float dist, vec[4][2]; /* in v0 and v3 we put begin/end points */ - if(link->fromsock) { + if (link->fromsock) { vec[0][0]= link->fromsock->locx; vec[0][1]= link->fromsock->locy; } else { - if(snode==NULL) return 0; + if (snode==NULL) return 0; vec[0][0]= snode->mx; vec[0][1]= snode->my; } - if(link->tosock) { + if (link->tosock) { vec[3][0]= link->tosock->locx; vec[3][1]= link->tosock->locy; } else { - if(snode==NULL) return 0; + if (snode==NULL) return 0; vec[3][0]= snode->mx; vec[3][1]= snode->my; } @@ -2484,7 +2489,7 @@ int node_link_bezier_points(View2D *v2d, SpaceNode *snode, bNodeLink *link, floa vec[2][0]= vec[3][0]-dist; vec[2][1]= vec[3][1]; - if(v2d && MIN4(vec[0][0], vec[1][0], vec[2][0], vec[3][0]) > v2d->cur.xmax); /* clipped */ + if (v2d && MIN4(vec[0][0], vec[1][0], vec[2][0], vec[3][0]) > v2d->cur.xmax); /* clipped */ else if (v2d && MAX4(vec[0][0], vec[1][0], vec[2][0], vec[3][0]) < v2d->cur.xmin); /* clipped */ else { @@ -2502,7 +2507,7 @@ void node_draw_link_bezier(View2D *v2d, SpaceNode *snode, bNodeLink *link, int t { float coord_array[LINK_RESOL+1][2]; - if(node_link_bezier_points(v2d, snode, link, coord_array, LINK_RESOL)) { + if (node_link_bezier_points(v2d, snode, link, coord_array, LINK_RESOL)) { float dist, spline_step = 0.0f; int i; @@ -2515,12 +2520,12 @@ void node_draw_link_bezier(View2D *v2d, SpaceNode *snode, bNodeLink *link, int t glEnable(GL_LINE_SMOOTH); - if(do_triple) { + if (do_triple) { UI_ThemeColorShadeAlpha(th_col3, -80, -120); glLineWidth(4.0f); glBegin(GL_LINE_STRIP); - for(i=0; i<=LINK_RESOL; i++) { + for (i=0; i<=LINK_RESOL; i++) { glVertex2fv(coord_array[i]); } glEnd(); @@ -2531,9 +2536,9 @@ void node_draw_link_bezier(View2D *v2d, SpaceNode *snode, bNodeLink *link, int t * changing color in begin/end blocks. */ glLineWidth(1.5f); - if(do_shaded) { + if (do_shaded) { glBegin(GL_LINES); - for(i=0; ifromsock) { + if (link->fromsock) { coord_array[0][0]= link->fromsock->locx; coord_array[0][1]= link->fromsock->locy; } else { - if(snode==NULL) return; + if (snode==NULL) return; coord_array[0][0]= snode->mx; coord_array[0][1]= snode->my; } - if(link->tosock) { + if (link->tosock) { coord_array[1][0]= link->tosock->locx; coord_array[1][1]= link->tosock->locy; } else { - if(snode==NULL) return; + if (snode==NULL) return; coord_array[1][0]= snode->mx; coord_array[1][1]= snode->my; } @@ -2595,7 +2600,7 @@ void node_draw_link_straight(View2D *v2d, SpaceNode *snode, bNodeLink *link, int glEnable(GL_LINE_SMOOTH); - if(do_triple) { + if (do_triple) { UI_ThemeColorShadeAlpha(th_col3, -80, -120); glLineWidth(4.0f); @@ -2612,7 +2617,7 @@ void node_draw_link_straight(View2D *v2d, SpaceNode *snode, bNodeLink *link, int * for Intel hardware, this breaks with GL_LINE_STRIP and * changing color in begin/end blocks. */ - if(do_shaded) { + if (do_shaded) { glBegin(GL_LINES); for (i=0; i < LINK_RESOL-1; ++i) { float t= (float)i/(float)(LINK_RESOL-1); @@ -2646,38 +2651,38 @@ void node_draw_link(View2D *v2d, SpaceNode *snode, bNodeLink *link) int do_shaded= 0, th_col1= TH_HEADER, th_col2= TH_HEADER; int do_triple= 0, 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) { + if (!link->fromsock || !link->tosock) { th_col1 = TH_ACTIVE; do_triple = 1; } 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; /* a bit ugly... but thats how we detect the internal group links */ - if(!link->fromnode || !link->tonode) { + if (!link->fromnode || !link->tonode) { UI_ThemeColorBlend(TH_BACK, TH_WIRE, 0.5f); do_shaded= 0; } else { /* check cyclic */ - if((link->fromnode->level >= link->tonode->level && link->tonode->level!=0xFFF) && (link->flag & NODE_LINK_VALID)) { + if ((link->fromnode->level >= link->tonode->level && link->tonode->level!=0xFFF) && (link->flag & NODE_LINK_VALID)) { /* special indicated link, on drop-node */ - if(link->flag & NODE_LINKFLAG_HILITE) { + if (link->flag & NODE_LINKFLAG_HILITE) { th_col1= th_col2= TH_ACTIVE; } else { /* regular link */ - if(link->fromnode->flag & SELECT) + if (link->fromnode->flag & SELECT) th_col1= TH_EDGE_SELECT; - if(link->tonode->flag & SELECT) + if (link->tonode->flag & SELECT) th_col2= TH_EDGE_SELECT; } do_shaded= 1; diff --git a/source/blender/editors/space_node/node_buttons.c b/source/blender/editors/space_node/node_buttons.c index fce4c6d3504..19eebe4d320 100644 --- a/source/blender/editors/space_node/node_buttons.c +++ b/source/blender/editors/space_node/node_buttons.c @@ -142,10 +142,10 @@ 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) { + for (sock=node->inputs.first; sock; sock=sock->next) { BLI_snprintf(name, sizeof(name), "%s:", sock->name); split = uiLayoutSplit(layout, 0.35f, 0); @@ -187,7 +187,7 @@ static int node_properties(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 8cb2aea953e..23b700e5b64 100644 --- a/source/blender/editors/space_node/node_draw.c +++ b/source/blender/editors/space_node/node_draw.c @@ -90,7 +90,7 @@ void ED_node_tree_update(SpaceNode *snode, Scene *scene) { snode_set_context(snode, scene); - if(snode->nodetree && snode->nodetree->id.us==0) + if (snode->nodetree && snode->nodetree->id.us==0) snode->nodetree->id.us= 1; } @@ -101,28 +101,28 @@ void ED_node_changed_update(ID *id, bNode *node) node_tree_from_ID(id, &nodetree, &edittree, &treetype); - if(treetype==NTREE_SHADER) { + if (treetype==NTREE_SHADER) { DAG_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_DRAW, id); - else if(GS(id->name) == ID_LA) + else if (GS(id->name) == ID_LA) WM_main_add_notifier(NC_LAMP|ND_LIGHTING_DRAW, id); - else if(GS(id->name) == ID_WO) + else if (GS(id->name) == ID_WO) WM_main_add_notifier(NC_WORLD|ND_WORLD_DRAW, id); } - else if(treetype==NTREE_COMPOSIT) { - if(node) + else if (treetype==NTREE_COMPOSIT) { + if (node) nodeUpdate(edittree, node); /* don't use NodeTagIDChanged, it gives far too many recomposites for image, scene layers, ... */ node= node_tree_get_editgroup(nodetree); - if(node) + if (node) nodeUpdateID(nodetree, node->id); WM_main_add_notifier(NC_SCENE|ND_NODES, id); } - else if(treetype==NTREE_TEXTURE) { + else if (treetype==NTREE_TEXTURE) { DAG_id_tag_update(id, 0); WM_main_add_notifier(NC_TEXTURE|ND_NODES, id); } @@ -132,12 +132,12 @@ static int has_nodetree(bNodeTree *ntree, bNodeTree *lookup) { bNode *node; - if(ntree == lookup) + if (ntree == lookup) return 1; - for(node=ntree->nodes.first; node; node=node->next) - if(node->type == NODE_GROUP && node->id) - if(has_nodetree((bNodeTree*)node->id, lookup)) + for (node=ntree->nodes.first; node; node=node->next) + if (node->type == NODE_GROUP && node->id) + if (has_nodetree((bNodeTree*)node->id, lookup)) return 1; return 0; @@ -163,15 +163,15 @@ void ED_node_generic_update(Main *bmain, bNodeTree *ntree, bNode *node) /* look through all datablocks, to support groups */ tti->foreach_nodetree(bmain, &cd, node_generic_update_cb); - if(ntree->type == NTREE_TEXTURE) + if (ntree->type == NTREE_TEXTURE) ntreeTexCheckCyclics(ntree); } static void do_node_internal_buttons(bContext *C, void *node_v, int event) { - if(event==B_NODE_EXEC) { + if (event==B_NODE_EXEC) { SpaceNode *snode= CTX_wm_space_node(C); - if(snode && snode->id) + if (snode && snode->id) ED_node_changed_update(snode->id, node_v); } } @@ -230,12 +230,12 @@ 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 */ - for(nsock= node->outputs.first; nsock; nsock= nsock->next) { - if(!nodeSocketIsHidden(nsock)) { + for (nsock= node->outputs.first; nsock; nsock= nsock->next) { + if (!nodeSocketIsHidden(nsock)) { nsock->locx= locx + node->width; nsock->locy= dy - NODE_DYS; dy-= NODE_DY; @@ -246,20 +246,20 @@ static void node_update_basis(const bContext *C, bNodeTree *ntree, bNode *node) node->prvr.xmax = locx + node->width- NODE_DYS; /* preview rect? */ - if(node->flag & NODE_PREVIEW) { + if (node->flag & NODE_PREVIEW) { /* only recalculate size when there's a preview actually, otherwise we use stored result */ BLI_lock_thread(LOCK_PREVIEW); - if(node->preview && node->preview->rect) { + if (node->preview && node->preview->rect) { float aspect= 1.0f; - if(node->preview && node->preview->xsize && node->preview->ysize) + if (node->preview && 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_DY); else { float dx= (node->width - NODE_DYS) - (node->width- NODE_DYS)/aspect; /* width correction of image */ @@ -273,12 +273,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); } else { float oldh= node->prvr.ymax - node->prvr.ymin; - if(oldh==0.0f) + if (oldh==0.0f) oldh= 0.6f*node->width-NODE_DY; dy-= NODE_DYS/2; node->prvr.ymax = dy; @@ -290,7 +290,7 @@ static void node_update_basis(const bContext *C, bNodeTree *ntree, bNode *node) } /* buttons rect? */ - if((node->flag & NODE_OPTIONS) && node->typeinfo->uifunc) { + if ((node->flag & NODE_OPTIONS) && node->typeinfo->uifunc) { dy-= NODE_DYS/2; /* set this for uifunc() that don't use layout engine yet */ @@ -313,8 +313,8 @@ 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)) { + for (nsock= node->inputs.first; nsock; nsock= nsock->next) { + if (!nodeSocketIsHidden(nsock)) { nsock->locx= locx; nsock->locy= dy - NODE_DYS; dy-= NODE_DY; @@ -322,7 +322,7 @@ static void node_update_basis(const bContext *C, bNodeTree *ntree, bNode *node) } /* 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; @@ -352,15 +352,15 @@ static void node_update_hidden(bNode *node) nodeSpaceCoords(node, &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) { + if (tot>4) { hiddenrad += 5.0f*(float)(tot-4); } @@ -372,8 +372,8 @@ static void node_update_hidden(bNode *node) /* output sockets */ rad=drad= (float)M_PI/(1.0f + (float)totout); - for(nsock= node->outputs.first; nsock; nsock= nsock->next) { - if(!nodeSocketIsHidden(nsock)) { + for (nsock= node->outputs.first; nsock; nsock= nsock->next) { + if (!nodeSocketIsHidden(nsock)) { nsock->locx= node->totr.xmax - hiddenrad + (float)sin(rad)*hiddenrad; nsock->locy= node->totr.ymin + hiddenrad + (float)cos(rad)*hiddenrad; rad+= drad; @@ -383,8 +383,8 @@ static void node_update_hidden(bNode *node) /* input sockets */ rad=drad= - (float)M_PI/(1.0f + (float)totin); - for(nsock= node->inputs.first; nsock; nsock= nsock->next) { - if(!nodeSocketIsHidden(nsock)) { + for (nsock= node->inputs.first; nsock; nsock= nsock->next) { + if (!nodeSocketIsHidden(nsock)) { nsock->locx= node->totr.xmin + hiddenrad + (float)sin(rad)*hiddenrad; nsock->locy= node->totr.ymin + hiddenrad + (float)cos(rad)*hiddenrad; rad+= drad; @@ -403,7 +403,7 @@ 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 node_update_basis(C, ntree, node); @@ -411,19 +411,19 @@ void node_update_default(const bContext *C, bNodeTree *ntree, bNode *node) static int node_get_colorid(bNode *node) { - if(node->typeinfo->nclass==NODE_CLASS_INPUT) + if (node->typeinfo->nclass==NODE_CLASS_INPUT) return TH_NODE_IN_OUT; - if(node->typeinfo->nclass==NODE_CLASS_OUTPUT) { - if(node->flag & NODE_DO_OUTPUT) + if (node->typeinfo->nclass==NODE_CLASS_OUTPUT) { + if (node->flag & NODE_DO_OUTPUT) return TH_NODE_IN_OUT; else return TH_NODE; } - if(node->typeinfo->nclass==NODE_CLASS_CONVERTOR) + if (node->typeinfo->nclass==NODE_CLASS_CONVERTOR) return TH_NODE_CONVERTOR; - if(ELEM3(node->typeinfo->nclass, NODE_CLASS_OP_COLOR, NODE_CLASS_OP_VECTOR, NODE_CLASS_OP_FILTER)) + if (ELEM3(node->typeinfo->nclass, NODE_CLASS_OP_COLOR, NODE_CLASS_OP_VECTOR, NODE_CLASS_OP_FILTER)) return TH_NODE_OPERATOR; - if(node->typeinfo->nclass==NODE_CLASS_GROUP) + if (node->typeinfo->nclass==NODE_CLASS_GROUP) return TH_NODE_GROUP; return TH_NODE; } @@ -436,7 +436,7 @@ static void node_draw_mute_line(View2D *v2d, SpaceNode *snode, bNode *node) ListBase links; bNodeLink *link; - if(node->typeinfo->internal_connect == NULL) + if (node->typeinfo->internal_connect == NULL) return; /* Get default muting links. */ @@ -445,7 +445,7 @@ static void node_draw_mute_line(View2D *v2d, SpaceNode *snode, bNode *node) glEnable(GL_BLEND); glEnable(GL_LINE_SMOOTH); - for(link = links.first; link; link = link->next) + for (link = links.first; link; link = link->next) node_draw_link_bezier(v2d, snode, link, TH_REDALERT, 0, TH_WIRE, 0, TH_WIRE); glDisable(GL_BLEND); @@ -476,7 +476,7 @@ static void node_circle_draw(float x, float y, float size, char *col, int highli glColor3ub(col[0], col[1], col[2]); glBegin(GL_POLYGON); - for(a=0; a<16; a++) + for (a=0; a<16; a++) glVertex2f(x+size*si[a], y+size*co[a]); glEnd(); @@ -490,7 +490,7 @@ static void node_circle_draw(float x, float y, float size, char *col, int highli glEnable(GL_BLEND); glEnable( GL_LINE_SMOOTH ); glBegin(GL_LINE_LOOP); - for(a=0; a<16; a++) + for (a=0; a<16; a++) glVertex2f(x+size*si[a], y+size*co[a]); glEnd(); glDisable( GL_LINE_SMOOTH ); @@ -519,25 +519,25 @@ static void node_draw_preview(bNodePreview *preview, rctf *prv) glRectf(prv->xmin, prv->ymin, prv->xmax, prv->ymax); glColor3ub(160, 160, 160); - for(y=prv->ymin; yymax; y+=tile*2) { - for(x=prv->xmin; xxmax; x+=tile*2) { + for (y=prv->ymin; yymax; y+=tile*2) { + for (x=prv->xmin; xxmax; x+=tile*2) { float tilex= tile, tiley= tile; - if(x+tile > prv->xmax) + if (x+tile > prv->xmax) tilex= prv->xmax-x; - if(y+tile > prv->ymax) + if (y+tile > prv->ymax) tiley= prv->ymax-y; glRectf(x, y, x + tilex, y + tiley); } } - for(y=prv->ymin+tile; yymax; y+=tile*2) { - for(x=prv->xmin+tile; xxmax; x+=tile*2) { + for (y=prv->ymin+tile; yymax; y+=tile*2) { + for (x=prv->xmin+tile; xxmax; x+=tile*2) { float tilex= tile, tiley= tile; - if(x+tile > prv->xmax) + if (x+tile > prv->xmax) tilex= prv->xmax-x; - if(y+tile > prv->ymax) + if (y+tile > prv->ymax) tiley= prv->ymax-y; glRectf(x, y, x + tilex, y + tiley); @@ -584,7 +584,7 @@ static void node_draw_basis(const bContext *C, ARegion *ar, SpaceNode *snode, bN View2D *v2d = &ar->v2d; /* hurmf... another candidate for callback, have to see how this works first */ - if(node->id && node->block && snode->treetype==NTREE_SHADER) + if (node->id && node->block && snode->treetype==NTREE_SHADER) nodeShaderSynchronizeID(node, 0); /* skip if out of view */ @@ -600,12 +600,12 @@ static void node_draw_basis(const bContext *C, ARegion *ar, SpaceNode *snode, bN ui_dropshadow(rct, BASIS_RAD, snode->aspect, node->flag & SELECT); /* header */ - if(color_id==TH_NODE) + if (color_id==TH_NODE) UI_ThemeColorShade(color_id, -20); else UI_ThemeColor(color_id); - if(node->flag & NODE_MUTED) + if (node->flag & NODE_MUTED) UI_ThemeColorBlend(color_id, TH_REDALERT, 0.5f); uiSetRoundBox(UI_CNR_TOP_LEFT | UI_CNR_TOP_RIGHT); @@ -615,7 +615,7 @@ static void node_draw_basis(const bContext *C, ARegion *ar, SpaceNode *snode, bN iconofs= rct->xmax - 7.0f; /* preview */ - if(node->typeinfo->flag & NODE_PREVIEW) { + if (node->typeinfo->flag & NODE_PREVIEW) { uiBut *but; iconofs-=iconbutw; uiBlockSetEmboss(node->block, UI_EMBOSSN); @@ -631,7 +631,7 @@ static void node_draw_basis(const bContext *C, ARegion *ar, SpaceNode *snode, bN uiBlockSetEmboss(node->block, UI_EMBOSS); } /* group edit */ - if(node->type == NODE_GROUP) { + if (node->type == NODE_GROUP) { uiBut *but; iconofs-=iconbutw; uiBlockSetEmboss(node->block, UI_EMBOSSN); @@ -642,7 +642,7 @@ static void node_draw_basis(const bContext *C, ARegion *ar, SpaceNode *snode, bN } /* title */ - if(node->flag & SELECT) + if (node->flag & SELECT) UI_ThemeColor(TH_TEXT_HI); else UI_ThemeColorBlendShade(TH_TEXT, color_id, 0.4f, 10); @@ -664,7 +664,7 @@ static void node_draw_basis(const bContext *C, ARegion *ar, SpaceNode *snode, bN /* this isn't doing anything for the label, so commenting out */ #if 0 - if(node->flag & SELECT) + if (node->flag & SELECT) UI_ThemeColor(TH_TEXT_HI); else UI_ThemeColor(TH_TEXT); @@ -689,11 +689,11 @@ static void node_draw_basis(const bContext *C, ARegion *ar, SpaceNode *snode, bN node_scaling_widget(TH_NODE, snode->aspect, rct->xmax-BASIS_RAD*snode->aspect, rct->ymin, rct->xmax, rct->ymin+BASIS_RAD*snode->aspect); /* outline active and selected emphasis */ - if( node->flag & (NODE_ACTIVE|SELECT) ) { + if ( node->flag & (NODE_ACTIVE|SELECT) ) { glEnable(GL_BLEND); glEnable( GL_LINE_SMOOTH ); /* using different shades of TH_TEXT_HI for the empasis, like triangle */ - if( node->flag & NODE_ACTIVE ) + if ( node->flag & NODE_ACTIVE ) UI_ThemeColorShadeAlpha(TH_TEXT_HI, 0, -40); else UI_ThemeColorShadeAlpha(TH_TEXT_HI, -20, -120); @@ -705,15 +705,15 @@ 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); /* socket inputs, buttons */ - for(sock= node->inputs.first; sock; sock= sock->next) { + for (sock= node->inputs.first; sock; sock= sock->next) { bNodeSocketType *stype= ntreeGetSocketType(sock->type); - if(nodeSocketIsHidden(sock)) + if (nodeSocketIsHidden(sock)) continue; node_socket_circle_draw(ntree, sock, NODE_SOCKSIZE); @@ -723,12 +723,12 @@ static void node_draw_basis(const bContext *C, ARegion *ar, SpaceNode *snode, bN } /* socket outputs */ - for(sock= node->outputs.first; sock; sock= sock->next) { + for (sock= node->outputs.first; sock; sock= sock->next) { PointerRNA sockptr; RNA_pointer_create((ID*)ntree, &RNA_NodeSocket, sock, &sockptr); - if(nodeSocketIsHidden(sock)) + if (nodeSocketIsHidden(sock)) continue; node_socket_circle_draw(ntree, sock, NODE_SOCKSIZE); @@ -739,7 +739,7 @@ static void node_draw_basis(const bContext *C, ARegion *ar, SpaceNode *snode, bN int ofs = 0; UI_ThemeColor(TH_TEXT); slen= snode->aspect*UI_GetStringWidth(name); - while(slen > node->width) { + while (slen > node->width) { ofs++; slen= snode->aspect*UI_GetStringWidth(name+ofs); } @@ -749,9 +749,9 @@ static void node_draw_basis(const bContext *C, ARegion *ar, SpaceNode *snode, bN } /* preview */ - if(node->flag & NODE_PREVIEW) { + if (node->flag & NODE_PREVIEW) { BLI_lock_thread(LOCK_PREVIEW); - if(node->preview && node->preview->rect && !BLI_rctf_is_empty(&node->prvr)) + if (node->preview && node->preview->rect && !BLI_rctf_is_empty(&node->prvr)) node_draw_preview(node->preview, &node->prvr); BLI_unlock_thread(LOCK_PREVIEW); } @@ -779,16 +779,16 @@ static void node_draw_hidden(const bContext *C, ARegion *ar, SpaceNode *snode, b /* body */ UI_ThemeColor(color_id); - if(node->flag & NODE_MUTED) + if (node->flag & NODE_MUTED) UI_ThemeColorBlend(color_id, TH_REDALERT, 0.5f); uiRoundBox(rct->xmin, rct->ymin, rct->xmax, rct->ymax, hiddenrad); /* outline active and selected emphasis */ - if( node->flag & (NODE_ACTIVE|SELECT) ) { + if ( node->flag & (NODE_ACTIVE|SELECT) ) { glEnable(GL_BLEND); glEnable( GL_LINE_SMOOTH ); /* using different shades of TH_TEXT_HI for the empasis, like triangle */ - if( node->flag & NODE_ACTIVE ) + if ( node->flag & NODE_ACTIVE ) UI_ThemeColorShadeAlpha(TH_TEXT_HI, 0, -40); else UI_ThemeColorShadeAlpha(TH_TEXT_HI, -20, -120); @@ -798,7 +798,7 @@ static void node_draw_hidden(const bContext *C, ARegion *ar, SpaceNode *snode, b } /* title */ - if(node->flag & SELECT) + if (node->flag & SELECT) UI_ThemeColor(TH_TEXT_HI); else UI_ThemeColorBlendShade(TH_TEXT, color_id, 0.4f, 10); @@ -819,15 +819,15 @@ 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->flag & SELECT) + if (node->flag & SELECT) UI_ThemeColor(TH_TEXT_HI); else UI_ThemeColor(TH_TEXT); - if(node->miniwidth>0.0f) { + if (node->miniwidth>0.0f) { BLI_strncpy(showname, nodeLabel(node), sizeof(showname)); //if(node->flag & NODE_MUTED) @@ -849,13 +849,13 @@ static void node_draw_hidden(const bContext *C, ARegion *ar, SpaceNode *snode, b fdrawline(rct->xmax-dx-3.0f*snode->aspect, centy-4.0f, rct->xmax-dx-3.0f*snode->aspect, centy+4.0f); /* sockets */ - for(sock= node->inputs.first; sock; sock= sock->next) { - if(!nodeSocketIsHidden(sock)) + for (sock= node->inputs.first; sock; sock= sock->next) { + if (!nodeSocketIsHidden(sock)) node_socket_circle_draw(snode->nodetree, sock, socket_size); } - for(sock= node->outputs.first; sock; sock= sock->next) { - if(!nodeSocketIsHidden(sock)) + for (sock= node->outputs.first; sock; sock= sock->next) { + if (!nodeSocketIsHidden(sock)) node_socket_circle_draw(snode->nodetree, sock, socket_size); } @@ -866,7 +866,7 @@ static void node_draw_hidden(const bContext *C, ARegion *ar, SpaceNode *snode, b void node_draw_default(const bContext *C, ARegion *ar, SpaceNode *snode, bNodeTree *ntree, bNode *node) { - if(node->flag & NODE_HIDDEN) + if (node->flag & NODE_HIDDEN) node_draw_hidden(C, ar, snode, node); else node_draw_basis(C, ar, snode, ntree, node); @@ -882,7 +882,7 @@ void node_update_nodetree(const bContext *C, bNodeTree *ntree, float offsetx, fl { bNode *node; - for(node= ntree->nodes.first; node; node= node->next) { + for (node= ntree->nodes.first; node; node= node->next) { /* XXX little hack */ node->locx += offsetx; node->locy += offsety; @@ -906,18 +906,18 @@ 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... */ /* node lines */ glEnable(GL_BLEND); glEnable(GL_LINE_SMOOTH); - for(link= ntree->links.first; link; link= link->next) + for (link= ntree->links.first; link; link= link->next) node_draw_link(&ar->v2d, snode, link); glDisable(GL_LINE_SMOOTH); glDisable(GL_BLEND); /* draw nodes, last nodes in front */ - for(a=0, node= ntree->nodes.first; node; node=node->next, a++) { + for (a=0, node= ntree->nodes.first; node; node=node->next, a++) { node->nr= a; /* index of node in list, used for exec event code */ node_draw(C, ar, snode, ntree, node); } @@ -953,7 +953,7 @@ void drawnodespace(const bContext *C, ARegion *ar, View2D *v2d) /* nodes */ snode_set_context(snode, CTX_data_scene(C)); - if(snode->nodetree) { + if (snode->nodetree) { bNode *node; node_uiblocks_init(C, snode->nodetree); @@ -961,8 +961,8 @@ void drawnodespace(const bContext *C, ARegion *ar, View2D *v2d) /* uiBlocks must be initialized in drawing order for correct event clipping. * Node group internal blocks added after the main group block. */ - for(node= snode->nodetree->nodes.first; node; node= node->next) { - if(node->flag & NODE_GROUP_EDIT) + for (node= snode->nodetree->nodes.first; node; node= node->next) { + if (node->flag & NODE_GROUP_EDIT) node_uiblocks_init(C, (bNodeTree *)node->id); } @@ -971,8 +971,8 @@ void drawnodespace(const bContext *C, ARegion *ar, View2D *v2d) #if 0 /* active group */ - for(node= snode->nodetree->nodes.first; node; node= node->next) { - if(node->flag & NODE_GROUP_EDIT) + for (node= snode->nodetree->nodes.first; node; node= node->next) { + if (node->flag & NODE_GROUP_EDIT) node_draw_group(C, ar, snode, snode->nodetree, node); } #endif @@ -981,7 +981,7 @@ void drawnodespace(const bContext *C, ARegion *ar, View2D *v2d) /* temporary links */ glEnable(GL_BLEND); glEnable(GL_LINE_SMOOTH); - for(nldrag= snode->linkdrag.first; nldrag; nldrag= nldrag->next) + for (nldrag= snode->linkdrag.first; nldrag; nldrag= nldrag->next) node_draw_link(&ar->v2d, snode, nldrag->link); glDisable(GL_LINE_SMOOTH); glDisable(GL_BLEND); diff --git a/source/blender/editors/space_node/node_edit.c b/source/blender/editors/space_node/node_edit.c index 5a3d9160b58..189d2307a7e 100644 --- a/source/blender/editors/space_node/node_edit.c +++ b/source/blender/editors/space_node/node_edit.c @@ -132,7 +132,7 @@ static void compo_freejob(void *cjv) { CompoJob *cj= cjv; - if(cj->localtree) { + if (cj->localtree) { ntreeLocalMerge(cj->localtree, cj->ntree); } MEM_freeN(cj); @@ -169,7 +169,7 @@ static void compo_startjob(void *cjv, short *stop, short *do_update, float *prog CompoJob *cj= cjv; bNodeTree *ntree= cj->localtree; - if(cj->scene->use_nodes==0) + if (cj->scene->use_nodes==0) return; cj->stop= stop; @@ -220,9 +220,9 @@ void snode_composite_job(const bContext *C, ScrArea *sa) /* operator poll callback */ static int composite_node_active(bContext *C) { - if( ED_operator_node_active(C)) { + if ( ED_operator_node_active(C)) { SpaceNode *snode= CTX_wm_space_node(C); - if(snode->treetype==NTREE_COMPOSIT) + if (snode->treetype==NTREE_COMPOSIT) return 1; } return 0; @@ -234,10 +234,10 @@ static bNode *editnode_get_active(bNodeTree *ntree) bNode *node; /* check for edited group */ - for(node= ntree->nodes.first; node; node= node->next) - if(nodeGroupEditGet(node)) + for (node= ntree->nodes.first; node; node= node->next) + if (nodeGroupEditGet(node)) break; - if(node) + if (node) return nodeGetActive((bNodeTree *)node->id); else return nodeGetActive(ntree); @@ -252,11 +252,11 @@ void snode_notify(bContext *C, SpaceNode *snode) { WM_event_add_notifier(C, NC_NODE|NA_EDITED, NULL); - if(snode->treetype==NTREE_SHADER) + if (snode->treetype==NTREE_SHADER) WM_event_add_notifier(C, NC_MATERIAL|ND_NODES, snode->id); - else if(snode->treetype==NTREE_COMPOSIT) + else if (snode->treetype==NTREE_COMPOSIT) WM_event_add_notifier(C, NC_SCENE|ND_NODES, snode->id); - else if(snode->treetype==NTREE_TEXTURE) + else if (snode->treetype==NTREE_TEXTURE) WM_event_add_notifier(C, NC_TEXTURE|ND_NODES, snode->id); } @@ -265,8 +265,8 @@ bNode *node_tree_get_editgroup(bNodeTree *nodetree) bNode *gnode; /* get the groupnode */ - for(gnode= nodetree->nodes.first; gnode; gnode= gnode->next) - if(nodeGroupEditGet(gnode)) + for (gnode= nodetree->nodes.first; gnode; gnode= gnode->next) + if (nodeGroupEditGet(gnode)) break; return gnode; } @@ -289,7 +289,7 @@ void ED_node_shader_default(Scene *scene, ID *id) Material *ma= (Material*)id; ma->nodetree = ntree; - if(scene_use_new_shading_nodes(scene)) { + if (scene_use_new_shading_nodes(scene)) { output_type = SH_NODE_OUTPUT_MATERIAL; shader_type = SH_NODE_BSDF_DIFFUSE; } @@ -321,7 +321,7 @@ void ED_node_shader_default(Scene *scene, 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 strength= 1.0f; @@ -347,11 +347,11 @@ void ED_node_shader_default(Scene *scene, ID *id) nodeAddLink(ntree, in, fromsock, out, tosock); /* default values */ - if(scene_use_new_shading_nodes(scene)) { + if (scene_use_new_shading_nodes(scene)) { sock= in->inputs.first; copy_v3_v3(((bNodeSocketValueRGBA*)sock->default_value)->value, color); - if(strength != 0.0f) { + if (strength != 0.0f) { sock= in->inputs.last; ((bNodeSocketValueFloat*)sock->default_value)->value= strength; } @@ -369,7 +369,7 @@ void ED_node_composit_default(Scene *sce) bNodeTemplate ntemp; /* but lets check it anyway */ - if(sce->nodetree) { + if (sce->nodetree) { if (G.f & G_DEBUG) printf("error in composite initialize\n"); return; @@ -409,7 +409,7 @@ void ED_node_texture_default(Tex *tx) bNodeTemplate ntemp; /* but lets check it anyway */ - if(tx->nodetree) { + if (tx->nodetree) { if (G.f & G_DEBUG) printf("error in texture initialize\n"); return; @@ -440,43 +440,43 @@ void node_tree_from_ID(ID *id, bNodeTree **ntree, bNodeTree **edittree, int *tre bNode *node= NULL; short idtype= GS(id->name); - if(idtype == ID_NT) { + if (idtype == ID_NT) { *ntree= (bNodeTree*)id; - if(treetype) *treetype= (*ntree)->type; + if (treetype) *treetype= (*ntree)->type; } - else if(idtype == ID_MA) { + else if (idtype == ID_MA) { *ntree= ((Material*)id)->nodetree; - if(treetype) *treetype= NTREE_SHADER; + if (treetype) *treetype= NTREE_SHADER; } - else if(idtype == ID_LA) { + else if (idtype == ID_LA) { *ntree= ((Lamp*)id)->nodetree; - if(treetype) *treetype= NTREE_SHADER; + if (treetype) *treetype= NTREE_SHADER; } - else if(idtype == ID_WO) { + else if (idtype == ID_WO) { *ntree= ((World*)id)->nodetree; - if(treetype) *treetype= NTREE_SHADER; + if (treetype) *treetype= NTREE_SHADER; } - else if(idtype == ID_SCE) { + else if (idtype == ID_SCE) { *ntree= ((Scene*)id)->nodetree; - if(treetype) *treetype= NTREE_COMPOSIT; + if (treetype) *treetype= NTREE_COMPOSIT; } - else if(idtype == ID_TE) { + else if (idtype == ID_TE) { *ntree= ((Tex*)id)->nodetree; - if(treetype) *treetype= NTREE_TEXTURE; + if (treetype) *treetype= NTREE_TEXTURE; } else { - if(treetype) *treetype= 0; + if (treetype) *treetype= 0; return; } /* find editable group */ - if(edittree) { - if(*ntree) - for(node= (*ntree)->nodes.first; node; node= node->next) - if(nodeGroupEditGet(node)) + if (edittree) { + if (*ntree) + for (node= (*ntree)->nodes.first; node; node= node->next) + if (nodeGroupEditGet(node)) break; - if(node && node->id) + if (node && node->id) *edittree= (bNodeTree *)node->id; else *edittree= *ntree; @@ -485,7 +485,7 @@ void node_tree_from_ID(ID *id, bNodeTree **ntree, bNodeTree **edittree, int *tre else { *ntree= NULL; *edittree= NULL; - if(treetype) *treetype= 0; + if (treetype) *treetype= 0; } } @@ -496,17 +496,17 @@ void snode_set_context(SpaceNode *snode, Scene *scene) snode->id= snode->from= NULL; - if(snode->treetype==NTREE_SHADER) { + if (snode->treetype==NTREE_SHADER) { /* need active object, or we allow pinning... */ - if(snode->shaderfrom == SNODE_SHADER_OBJECT) { - if(ob) { - if(ob->type == OB_LAMP) { + if (snode->shaderfrom == SNODE_SHADER_OBJECT) { + if (ob) { + if (ob->type == OB_LAMP) { snode->from= &ob->id; snode->id= ob->data; } else { Material *ma= give_current_material(ob, ob->actcol); - if(ma) { + if (ma) { snode->from= &ob->id; snode->id= &ma->id; } @@ -514,26 +514,26 @@ void snode_set_context(SpaceNode *snode, Scene *scene) } } else { /* SNODE_SHADER_WORLD */ - if(scene->world) { + if (scene->world) { snode->from= NULL; snode->id= &scene->world->id; } } } - else if(snode->treetype==NTREE_COMPOSIT) { + else if (snode->treetype==NTREE_COMPOSIT) { snode->id= &scene->id; /* update output sockets based on available layers */ ntreeCompositForceHidden(scene->nodetree, scene); } - else if(snode->treetype==NTREE_TEXTURE) { + else if (snode->treetype==NTREE_TEXTURE) { Tex *tx= NULL; - if(snode->texfrom==SNODE_TEX_OBJECT) { - if(ob) { + if (snode->texfrom==SNODE_TEX_OBJECT) { + if (ob) { tx= give_current_object_texture(ob); - if(ob->type == OB_LAMP) + if (ob->type == OB_LAMP) snode->from= (ID*)ob->data; else snode->from= (ID*)give_current_material(ob, ob->actcol); @@ -542,7 +542,7 @@ void snode_set_context(SpaceNode *snode, Scene *scene) snode->id= &tx->id; } } - else if(snode->texfrom==SNODE_TEX_WORLD) { + else if (snode->texfrom==SNODE_TEX_WORLD) { tx= give_current_world_texture(scene->world); snode->from= (ID *)scene->world; snode->id= &tx->id; @@ -550,7 +550,7 @@ void snode_set_context(SpaceNode *snode, Scene *scene) else { struct Brush *brush= NULL; - if(ob && (ob->mode & OB_MODE_SCULPT)) + if (ob && (ob->mode & OB_MODE_SCULPT)) brush= paint_brush(&scene->toolsettings->sculpt->paint); else brush= paint_brush(&scene->toolsettings->imapaint.paint); @@ -581,7 +581,7 @@ static void snode_update(SpaceNode *snode, bNode *node) /* if inside group, tag entire group */ gnode= node_tree_get_editgroup(snode->nodetree); - if(gnode) + if (gnode) nodeUpdateID(snode->nodetree, gnode->id); } @@ -589,12 +589,12 @@ static int has_nodetree(bNodeTree *ntree, bNodeTree *lookup) { bNode *node; - if(ntree == lookup) + if (ntree == lookup) return 1; - for(node=ntree->nodes.first; node; node=node->next) - if(node->type == NODE_GROUP && node->id) - if(has_nodetree((bNodeTree*)node->id, lookup)) + for (node=ntree->nodes.first; node; node=node->next) + if (node->type == NODE_GROUP && node->id) + if (has_nodetree((bNodeTree*)node->id, lookup)) return 1; return 0; @@ -606,72 +606,72 @@ void ED_node_set_active(Main *bmain, bNodeTree *ntree, bNode *node) nodeSetActive(ntree, node); - if(node->type!=NODE_GROUP) { + if (node->type!=NODE_GROUP) { int was_output= (node->flag & NODE_DO_OUTPUT); /* tree specific activate calls */ - if(ntree->type==NTREE_SHADER) { + if (ntree->type==NTREE_SHADER) { /* when we select a material, active texture is cleared, for buttons */ - if(node->id && ELEM3(GS(node->id->name), ID_MA, ID_LA, ID_WO)) + if (node->id && ELEM3(GS(node->id->name), ID_MA, ID_LA, ID_WO)) nodeClearActiveID(ntree, ID_TE); - if(node->type==SH_NODE_OUTPUT) { + if (node->type==SH_NODE_OUTPUT) { bNode *tnode; - for(tnode= ntree->nodes.first; tnode; tnode= tnode->next) - if( tnode->type==SH_NODE_OUTPUT) + for (tnode= ntree->nodes.first; tnode; tnode= tnode->next) + if ( tnode->type==SH_NODE_OUTPUT) tnode->flag &= ~NODE_DO_OUTPUT; node->flag |= NODE_DO_OUTPUT; - if(was_output==0) + if (was_output==0) ED_node_generic_update(bmain, ntree, node); } /* if active texture changed, free glsl materials */ - if((node->flag & NODE_ACTIVE_TEXTURE) && !was_active_texture) { + if ((node->flag & NODE_ACTIVE_TEXTURE) && !was_active_texture) { Material *ma; - for(ma=bmain->mat.first; ma; ma=ma->id.next) - if(ma->nodetree && ma->use_nodes && has_nodetree(ma->nodetree, ntree)) + for (ma=bmain->mat.first; ma; ma=ma->id.next) + if (ma->nodetree && ma->use_nodes && has_nodetree(ma->nodetree, ntree)) GPU_material_free(ma); } WM_main_add_notifier(NC_MATERIAL|ND_NODES, node->id); } - else if(ntree->type==NTREE_COMPOSIT) { + else if (ntree->type==NTREE_COMPOSIT) { /* make active viewer, currently only 1 supported... */ - if( ELEM(node->type, CMP_NODE_VIEWER, CMP_NODE_SPLITVIEWER)) { + if ( ELEM(node->type, CMP_NODE_VIEWER, CMP_NODE_SPLITVIEWER)) { 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_generic_update(bmain, ntree, node); /* addnode() doesnt link this yet... */ node->id= (ID *)BKE_image_verify_viewer(IMA_TYPE_COMPOSITE, "Viewer Node"); } - else if(node->type==CMP_NODE_R_LAYERS) { + else if (node->type==CMP_NODE_R_LAYERS) { Scene *scene; - for(scene=bmain->scene.first; scene; scene=scene->id.next) { - if(scene->nodetree && scene->use_nodes && has_nodetree(scene->nodetree, ntree)) { - if(node->id==NULL || node->id==(ID *)scene) { + for (scene=bmain->scene.first; scene; scene=scene->id.next) { + if (scene->nodetree && scene->use_nodes && has_nodetree(scene->nodetree, ntree)) { + if (node->id==NULL || node->id==(ID *)scene) { scene->r.actlay= node->custom1; } } } } - else if(node->type==CMP_NODE_COMPOSITE) { + else if (node->type==CMP_NODE_COMPOSITE) { 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; @@ -679,10 +679,10 @@ void ED_node_set_active(Main *bmain, bNodeTree *ntree, bNode *node) } } } - else if(ntree->type==NTREE_TEXTURE) { + else if (ntree->type==NTREE_TEXTURE) { // XXX #if 0 - if(node->id) + if (node->id) ; // XXX BIF_preview_changed(-1); // allqueue(REDRAWBUTSSHADING, 1); // allqueue(REDRAWIPO, 0); @@ -811,12 +811,12 @@ void snode_make_group_editable(SpaceNode *snode, bNode *gnode) bNode *node; /* make sure nothing has group editing on */ - for(node=snode->nodetree->nodes.first; node; node=node->next) + for (node=snode->nodetree->nodes.first; node; node=node->next) nodeGroupEditClear(node); - if(gnode==NULL) { + if (gnode==NULL) { /* with NULL argument we do a toggle */ - if(snode->edittree==snode->nodetree) + if (snode->edittree==snode->nodetree) gnode= nodeGetActive(snode->nodetree); } @@ -824,7 +824,7 @@ void snode_make_group_editable(SpaceNode *snode, bNode *gnode) snode->edittree = nodeGroupEditSet(gnode, 1); /* deselect all other nodes, so we can also do grabbing of entire subtree */ - for(node= snode->nodetree->nodes.first; node; node= node->next) + for (node= snode->nodetree->nodes.first; node; node= node->next) node_deselect(node); node_select(gnode); } @@ -858,7 +858,7 @@ static int node_group_edit_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(e /* XXX callback? */ if (snode->nodetree==snode->edittree) { gnode = nodeGetActive(snode->edittree); - if(gnode && gnode->id && GS(gnode->id->name)==ID_NT && gnode->id->lib) { + if (gnode && gnode->id && GS(gnode->id->name)==ID_NT && gnode->id->lib) { uiPupMenuOkee(C, op->type->idname, "Make group local?"); return OPERATOR_CANCELLED; } @@ -1138,18 +1138,18 @@ static int node_group_ungroup_exec(bContext *C, wmOperator *op) /* are we inside of a group? */ gnode= node_tree_get_editgroup(snode->nodetree); - if(gnode) + if (gnode) snode_make_group_editable(snode, NULL); gnode= nodeGetActive(snode->edittree); - if(gnode==NULL) + if (gnode==NULL) return OPERATOR_CANCELLED; - if(gnode->type!=NODE_GROUP) { + if (gnode->type!=NODE_GROUP) { BKE_report(op->reports, RPT_WARNING, "Not a group"); return OPERATOR_CANCELLED; } - else if(!node_group_ungroup(snode->edittree, gnode)) { + else if (!node_group_ungroup(snode->edittree, gnode)) { BKE_report(op->reports, RPT_WARNING, "Can't ungroup"); return OPERATOR_CANCELLED; } @@ -1182,8 +1182,8 @@ static bNode *visible_node(SpaceNode *snode, rctf *rct) { bNode *node; - for(node=snode->edittree->nodes.last; node; node=node->prev) { - if(BLI_isect_rctf(&node->totr, rct, NULL)) + for (node=snode->edittree->nodes.last; node; node=node->prev) { + if (BLI_isect_rctf(&node->totr, rct, NULL)) break; } return node; @@ -1245,7 +1245,7 @@ static int snode_bg_viewmove_invoke(bContext *C, wmOperator *op, wmEvent *event) ima= BKE_image_verify_viewer(IMA_TYPE_COMPOSITE, "Viewer Node"); ibuf= BKE_image_acquire_ibuf(ima, NULL, &lock); - if(ibuf == NULL) { + if (ibuf == NULL) { BKE_image_release_ibuf(ima, lock); return OPERATOR_CANCELLED; } @@ -1362,11 +1362,11 @@ static void sample_apply(bContext *C, wmOperator *op, wmEvent *event) ima= BKE_image_verify_viewer(IMA_TYPE_COMPOSITE, "Viewer Node"); ibuf= BKE_image_acquire_ibuf(ima, NULL, &lock); - if(!ibuf) + if (!ibuf) return; - if(!ibuf->rect) { - if(info->color_manage) + if (!ibuf->rect) { + if (info->color_manage) ibuf->profile = IB_PROFILE_LINEAR_RGB; else ibuf->profile = IB_PROFILE_NONE; @@ -1379,7 +1379,7 @@ static void sample_apply(bContext *C, wmOperator *op, wmEvent *event) fx = (bufx > 0.0f ? ((float)event->mval[0] - 0.5f*ar->winx - snode->xof) / bufx + 0.5f : 0.0f); fy = (bufy > 0.0f ? ((float)event->mval[1] - 0.5f*ar->winy - snode->yof) / bufy + 0.5f : 0.0f); - if(fx>=0.0f && fy>=0.0f && fx<1.0f && fy<1.0f) { + if (fx>=0.0f && fy>=0.0f && fx<1.0f && fy<1.0f) { float *fp; char *cp; int x= (int)(fx*ibuf->x), y= (int)(fy*ibuf->y); @@ -1392,7 +1392,7 @@ static void sample_apply(bContext *C, wmOperator *op, wmEvent *event) info->draw= 1; info->channels= ibuf->channels; - if(ibuf->rect) { + if (ibuf->rect) { cp= (char *)(ibuf->rect + y*ibuf->x + x); info->col[0]= cp[0]; @@ -1405,7 +1405,7 @@ static void sample_apply(bContext *C, wmOperator *op, wmEvent *event) info->colf[2]= (float)cp[2]/255.0f; info->colf[3]= (float)cp[3]/255.0f; } - if(ibuf->rect_float) { + if (ibuf->rect_float) { fp= (ibuf->rect_float + (ibuf->channels)*(y*ibuf->x + x)); info->colf[0]= fp[0]; @@ -1437,7 +1437,7 @@ static int sample_invoke(bContext *C, wmOperator *op, wmEvent *event) ARegion *ar= CTX_wm_region(C); ImageSampleInfo *info; - if(snode->treetype!=NTREE_COMPOSIT || !(snode->flag & SNODE_BACKDRAW)) + if (snode->treetype!=NTREE_COMPOSIT || !(snode->flag & SNODE_BACKDRAW)) return OPERATOR_CANCELLED; info= MEM_callocN(sizeof(ImageSampleInfo), "ImageSampleInfo"); @@ -1512,7 +1512,7 @@ static int node_resize_modal(bContext *C, wmOperator *op, wmEvent *event) &mx, &my); if (node) { - if(node->flag & NODE_HIDDEN) { + if (node->flag & NODE_HIDDEN) { node->miniwidth= nsw->oldminiwidth + mx - nsw->mxstart; CLAMP(node->miniwidth, 0.0f, 100.0f); } @@ -1550,12 +1550,12 @@ static int node_resize_invoke(bContext *C, wmOperator *op, wmEvent *event) ARegion *ar= CTX_wm_region(C); bNode *node= editnode_get_active(snode->edittree); - if(node) { + if (node) { /* convert mouse coordinates to v2d space */ UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], &snode->mx, &snode->my); - if(node->typeinfo->resize_area_func(node, snode->mx, snode->my)) { + if (node->typeinfo->resize_area_func(node, snode->mx, snode->my)) { NodeSizeWidget *nsw= MEM_callocN(sizeof(NodeSizeWidget), "size widget op data"); op->customdata= nsw; @@ -1607,11 +1607,11 @@ int node_has_hidden_sockets(bNode *node, short flag) { bNodeSocket *sock; - for(sock= node->inputs.first; sock; sock= sock->next) - if(sock->flag & flag) + for (sock= node->inputs.first; sock; sock= sock->next) + if (sock->flag & flag) return 1; - for(sock= node->outputs.first; sock; sock= sock->next) - if(sock->flag & flag) + for (sock= node->outputs.first; sock; sock= sock->next) + if (sock->flag & flag) return 1; return 0; } @@ -1620,20 +1620,20 @@ void node_set_hidden_sockets(SpaceNode *snode, bNode *node, short flag, int set) { bNodeSocket *sock; - if(set==0) { - for(sock= node->inputs.first; sock; sock= sock->next) + if (set==0) { + for (sock= node->inputs.first; sock; sock= sock->next) sock->flag &= ~flag; - for(sock= node->outputs.first; sock; sock= sock->next) + for (sock= node->outputs.first; sock; sock= sock->next) sock->flag &= ~flag; } else { /* hide unused sockets */ - for(sock= node->inputs.first; sock; sock= sock->next) { - if(sock->link==NULL) + for (sock= node->inputs.first; sock; sock= sock->next) { + if (sock->link==NULL) sock->flag |= flag; } - for(sock= node->outputs.first; sock; sock= sock->next) { - if(nodeCountSocketLinks(snode->edittree, sock)==0) + for (sock= node->outputs.first; sock; sock= sock->next) { + if (nodeCountSocketLinks(snode->edittree, sock)==0) sock->flag |= flag; } } @@ -1647,20 +1647,20 @@ static int node_link_viewer(const bContext *C, bNode *tonode) bNodeSocket *sock; /* context check */ - if(tonode==NULL || tonode->outputs.first==NULL) + if (tonode==NULL || tonode->outputs.first==NULL) 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) { - if( ELEM(node->type, CMP_NODE_VIEWER, CMP_NODE_SPLITVIEWER)) { + if (node==NULL) { + for (node= snode->edittree->nodes.first; node; node= node->next) { + if ( ELEM(node->type, CMP_NODE_VIEWER, CMP_NODE_SPLITVIEWER)) { node->flag |= NODE_DO_OUTPUT; break; } @@ -1672,32 +1672,32 @@ 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) { + 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; } } /* find a socket starting from the first socket */ - if(!sock) { - for(sock= tonode->outputs.first; sock; sock= sock->next) - if(!nodeSocketIsHidden(sock)) + if (!sock) { + for (sock= tonode->outputs.first; sock; sock= sock->next) + if (!nodeSocketIsHidden(sock)) break; } - if(sock) { + if (sock) { /* add a new viewer if none exists yet */ - if(!node) { + if (!node) { Main *bmain = CTX_data_main(C); Scene *scene = CTX_data_scene(C); bNodeTemplate ntemp; @@ -1712,12 +1712,12 @@ static int node_link_viewer(const bContext *C, bNode *tonode) } 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) { + if (link==NULL) { nodeAddLink(snode->edittree, tonode, sock, node, node->inputs.first); } else { @@ -1739,7 +1739,7 @@ static int node_active_link_viewer(bContext *C, wmOperator *UNUSED(op)) node= editnode_get_active(snode->edittree); - if(!node) + if (!node) return OPERATOR_CANCELLED; ED_preview_kill_jobs(C); @@ -1779,17 +1779,17 @@ static int UNUSED_FUNCTION(node_mouse_groupheader)(SpaceNode *snode) // XXX int mval[2]; gnode= node_tree_get_editgroup(snode->nodetree); - if(gnode==NULL) return 0; + if (gnode==NULL) return 0; // XXX getmouseco_areawin(mval); // XXX areamouseco_to_ipoco(G.v2d, mval, &mx, &my); /* click in header or outside? */ - if(BLI_in_rctf(&gnode->totr, mx, my)==0) { + if (BLI_in_rctf(&gnode->totr, mx, my)==0) { rctf rect= gnode->totr; rect.ymax += NODE_DY; - if(BLI_in_rctf(&rect, mx, my)==0) + if (BLI_in_rctf(&rect, mx, my)==0) snode_make_group_editable(snode, NULL); /* toggles, so exits editmode */ // else // XXX transform_nodes(snode->nodetree, 'g', "Move group"); @@ -1811,7 +1811,7 @@ int node_find_indicated_socket(SpaceNode *snode, bNode **nodep, bNodeSocket **so *sockp= NULL; /* check if we click in a socket */ - for(node= snode->edittree->nodes.first; node; node= node->next) { + for (node= snode->edittree->nodes.first; node; node= node->next) { rect.xmin = snode->mx - (NODE_SOCKSIZE+4); rect.ymin = snode->my - (NODE_SOCKSIZE+4); @@ -1823,17 +1823,18 @@ int node_find_indicated_socket(SpaceNode *snode, bNode **nodep, bNodeSocket **so if (in_out == SOCK_IN) { rect.xmax += NODE_SOCKSIZE; rect.xmin -= NODE_SOCKSIZE*4; - } else if (in_out == SOCK_OUT) { + } + else if (in_out == SOCK_OUT) { rect.xmax += NODE_SOCKSIZE*4; rect.xmin -= NODE_SOCKSIZE; } } - if(in_out & SOCK_IN) { - for(sock= node->inputs.first; sock; sock= sock->next) { - if(!nodeSocketIsHidden(sock)) { - if(BLI_in_rctf(&rect, sock->locx, sock->locy)) { - if(node == visible_node(snode, &rect)) { + if (in_out & SOCK_IN) { + for (sock= node->inputs.first; sock; sock= sock->next) { + if (!nodeSocketIsHidden(sock)) { + if (BLI_in_rctf(&rect, sock->locx, sock->locy)) { + if (node == visible_node(snode, &rect)) { *nodep= node; *sockp= sock; return 1; @@ -1842,11 +1843,11 @@ int node_find_indicated_socket(SpaceNode *snode, bNode **nodep, bNodeSocket **so } } } - if(in_out & SOCK_OUT) { - for(sock= node->outputs.first; sock; sock= sock->next) { - if(!nodeSocketIsHidden(sock)) { - if(BLI_in_rctf(&rect, sock->locx, sock->locy)) { - if(node == visible_node(snode, &rect)) { + if (in_out & SOCK_OUT) { + for (sock= node->outputs.first; sock; sock= sock->next) { + if (!nodeSocketIsHidden(sock)) { + if (BLI_in_rctf(&rect, sock->locx, sock->locy)) { + if (node == visible_node(snode, &rect)) { *nodep= node; *sockp= sock; return 1; @@ -1860,10 +1861,10 @@ int node_find_indicated_socket(SpaceNode *snode, bNode **nodep, bNodeSocket **so /* check group sockets * NB: using ngroup->outputs as input sockets and vice versa here! */ - if(in_out & SOCK_IN) { - for(sock= snode->edittree->outputs.first; sock; sock= sock->next) { - if(!nodeSocketIsHidden(sock)) { - if(BLI_in_rctf(&rect, sock->locx, sock->locy)) { + if (in_out & SOCK_IN) { + for (sock= snode->edittree->outputs.first; sock; sock= sock->next) { + if (!nodeSocketIsHidden(sock)) { + if (BLI_in_rctf(&rect, sock->locx, sock->locy)) { *nodep= NULL; /* NULL node pointer indicates group socket */ *sockp= sock; return 1; @@ -1871,10 +1872,10 @@ int node_find_indicated_socket(SpaceNode *snode, bNode **nodep, bNodeSocket **so } } } - if(in_out & SOCK_OUT) { - for(sock= snode->edittree->inputs.first; sock; sock= sock->next) { - if(!nodeSocketIsHidden(sock)) { - if(BLI_in_rctf(&rect, sock->locx, sock->locy)) { + if (in_out & SOCK_OUT) { + for (sock= snode->edittree->inputs.first; sock; sock= sock->next) { + if (!nodeSocketIsHidden(sock)) { + if (BLI_in_rctf(&rect, sock->locx, sock->locy)) { *nodep= NULL; /* NULL node pointer indicates group socket */ *sockp= sock; return 1; @@ -2031,8 +2032,8 @@ void snode_autoconnect(SpaceNode *snode, int allow_multiple, int replace) bNode *node; int i, numlinks=0; - for(node= ntree->nodes.first; node; node= node->next) { - if(node->flag & NODE_SELECT) { + for (node= ntree->nodes.first; node; node= node->next) { + if (node->flag & NODE_SELECT) { nli = MEM_mallocN(sizeof(bNodeListItem), "temporary node list item"); nli->node = node; BLI_addtail(nodelist, nli); @@ -2112,13 +2113,13 @@ bNode *node_add_node(SpaceNode *snode, Main *bmain, Scene *scene, bNodeTemplate node = nodeAddNode(snode->edittree, ntemp); /* generics */ - if(node) { + if (node) { node->locx= locx; node->locy= locy + 60.0f; // arbitrary.. so its visible, (0,0) is top of node node_select(node); gnode= node_tree_get_editgroup(snode->nodetree); - if(gnode) { + if (gnode) { node->locx -= gnode->locx; node->locy -= gnode->locy; } @@ -2126,24 +2127,24 @@ bNode *node_add_node(SpaceNode *snode, Main *bmain, Scene *scene, bNodeTemplate ntreeUpdateTree(snode->edittree); ED_node_set_active(bmain, snode->edittree, node); - if(snode->nodetree->type==NTREE_COMPOSIT) { - if(ELEM4(node->type, CMP_NODE_R_LAYERS, CMP_NODE_COMPOSITE, CMP_NODE_DEFOCUS, CMP_NODE_OUTPUT_FILE)) { + if (snode->nodetree->type==NTREE_COMPOSIT) { + if (ELEM4(node->type, CMP_NODE_R_LAYERS, CMP_NODE_COMPOSITE, CMP_NODE_DEFOCUS, CMP_NODE_OUTPUT_FILE)) { node->id = &scene->id; } - else if(ELEM3(node->type, CMP_NODE_MOVIECLIP, CMP_NODE_MOVIEDISTORTION, CMP_NODE_STABILIZE2D)) { + else if (ELEM3(node->type, CMP_NODE_MOVIECLIP, CMP_NODE_MOVIEDISTORTION, CMP_NODE_STABILIZE2D)) { node->id = (ID *)scene->clip; } ntreeCompositForceHidden(snode->edittree, scene); } - if(node->id) + if (node->id) id_us_plus(node->id); snode_update(snode, node); } - if(snode->nodetree->type==NTREE_TEXTURE) { + if (snode->nodetree->type==NTREE_TEXTURE) { ntreeTexCheckCyclics(snode->edittree); } @@ -2163,11 +2164,11 @@ static int node_duplicate_exec(bContext *C, wmOperator *op) ED_preview_kill_jobs(C); lastnode = ntree->nodes.last; - for(node= ntree->nodes.first; node; node= node->next) { - if(node->flag & SELECT) { + for (node= ntree->nodes.first; node; node= node->next) { + if (node->flag & SELECT) { newnode = nodeCopyNode(ntree, node); - if(newnode->id) { + if (newnode->id) { /* simple id user adjustment, node internal functions don't touch this * but operators and readfile.c do. */ id_us_plus(newnode->id); @@ -2214,8 +2215,8 @@ static int node_duplicate_exec(bContext *C, wmOperator *op) } /* deselect old nodes, select the copies instead */ - for(node= ntree->nodes.first; node; node= node->next) { - if(node->flag & SELECT) { + for (node= ntree->nodes.first; node; node= node->next) { + if (node->flag & SELECT) { /* has been set during copy above */ newnode = node->new_node; @@ -2261,22 +2262,22 @@ static void node_remove_extra_links(SpaceNode *snode, bNodeSocket *tsock, bNodeL bNodeLink *tlink; bNodeSocket *sock; - if(tsock && nodeCountSocketLinks(snode->edittree, link->tosock) > tsock->limit) { + if (tsock && nodeCountSocketLinks(snode->edittree, link->tosock) > tsock->limit) { - for(tlink= snode->edittree->links.first; tlink; tlink= tlink->next) { - if(link!=tlink && tlink->tosock==link->tosock) + for (tlink= snode->edittree->links.first; tlink; tlink= tlink->next) { + if (link!=tlink && tlink->tosock==link->tosock) break; } - if(tlink) { + if (tlink) { /* try to move the existing link to the next available socket */ if (tlink->tonode) { /* is there a free input socket with the target type? */ - for(sock= tlink->tonode->inputs.first; sock; sock= sock->next) { - if(sock->type==tlink->tosock->type) - if(nodeCountSocketLinks(snode->edittree, sock) < sock->limit) + for (sock= tlink->tonode->inputs.first; sock; sock= sock->next) { + if (sock->type==tlink->tosock->type) + if (nodeCountSocketLinks(snode->edittree, sock) < sock->limit) break; } - if(sock) { + if (sock) { tlink->tosock= sock; sock->flag &= ~(SOCK_HIDDEN|SOCK_AUTO_HIDDEN); } @@ -2315,13 +2316,13 @@ static int node_link_modal(bContext *C, wmOperator *op, wmEvent *event) switch (event->type) { case MOUSEMOVE: - if(in_out==SOCK_OUT) { + if (in_out==SOCK_OUT) { /* only target socket becomes hilighted */ node_deselect_all_input_sockets(snode, 0); - if(node_find_indicated_socket(snode, &tnode, &tsock, SOCK_IN)) { - if(nodeFindLink(snode->edittree, sock, tsock)==NULL) { - if( link->tosock!= tsock && (!tnode || (tnode!=node && link->tonode!=tnode)) ) { + if (node_find_indicated_socket(snode, &tnode, &tsock, SOCK_IN)) { + if (nodeFindLink(snode->edittree, sock, tsock)==NULL) { + if ( link->tosock!= tsock && (!tnode || (tnode!=node && link->tonode!=tnode)) ) { link->tonode= tnode; link->tosock= tsock; if (link->prev==NULL && link->next==NULL) { @@ -2352,10 +2353,10 @@ static int node_link_modal(bContext *C, wmOperator *op, wmEvent *event) /* only target socket becomes hilighted */ node_deselect_all_output_sockets(snode, 0); - if(node_find_indicated_socket(snode, &tnode, &tsock, SOCK_OUT)) { - if(nodeFindLink(snode->edittree, sock, tsock)==NULL) { - if(nodeCountSocketLinks(snode->edittree, tsock) < tsock->limit) { - if( link->fromsock!= tsock && (!tnode || (tnode!=node && link->fromnode!=tnode)) ) { + if (node_find_indicated_socket(snode, &tnode, &tsock, SOCK_OUT)) { + if (nodeFindLink(snode->edittree, sock, tsock)==NULL) { + if (nodeCountSocketLinks(snode->edittree, tsock) < tsock->limit) { + if ( link->fromsock!= tsock && (!tnode || (tnode!=node && link->fromnode!=tnode)) ) { link->fromnode= tnode; link->fromsock= tsock; if (link->prev==NULL && link->next==NULL) { @@ -2389,12 +2390,12 @@ static int node_link_modal(bContext *C, wmOperator *op, wmEvent *event) case LEFTMOUSE: case RIGHTMOUSE: case MIDDLEMOUSE: - if(link->tosock && link->fromsock) { + if (link->tosock && link->fromsock) { /* send changed events for original tonode and new */ snode_update(snode, link->tonode); /* we might need to remove a link */ - if(in_out==SOCK_OUT) + if (in_out==SOCK_OUT) node_remove_extra_links(snode, link->tosock, link); /* deselect sockets after successful linking */ @@ -2453,16 +2454,16 @@ static int node_link_init(SpaceNode *snode, bNodeLinkDrag *nldrag) int in_out = 0; /* output indicated? */ - if(node_find_indicated_socket(snode, &nldrag->node, &nldrag->sock, SOCK_OUT)) { - if(nodeCountSocketLinks(snode->edittree, nldrag->sock) < nldrag->sock->limit) + if (node_find_indicated_socket(snode, &nldrag->node, &nldrag->sock, SOCK_OUT)) { + if (nodeCountSocketLinks(snode->edittree, nldrag->sock) < nldrag->sock->limit) in_out = SOCK_OUT; else { /* find if we break a link */ - for(link= snode->edittree->links.first; link; link= link->next) { - if(link->fromsock==nldrag->sock) + for (link= snode->edittree->links.first; link; link= link->next) { + if (link->fromsock==nldrag->sock) break; } - if(link) { + if (link) { nldrag->node= link->tonode; nldrag->sock= link->tosock; nodeRemLink(snode->edittree, link); @@ -2475,18 +2476,18 @@ static int node_link_init(SpaceNode *snode, bNodeLinkDrag *nldrag) node_socket_select(nldrag->node, nldrag->sock); } /* or an input? */ - else if(node_find_indicated_socket(snode, &nldrag->node, &nldrag->sock, SOCK_IN)) { - if(nodeCountSocketLinks(snode->edittree, nldrag->sock) < nldrag->sock->limit) + else if (node_find_indicated_socket(snode, &nldrag->node, &nldrag->sock, SOCK_IN)) { + if (nodeCountSocketLinks(snode->edittree, nldrag->sock) < nldrag->sock->limit) in_out = SOCK_IN; else { /* find if we break a link */ - for(link= snode->edittree->links.first; link; link= link->next) { - if(link->tosock==nldrag->sock) + for (link= snode->edittree->links.first; link; link= link->next) { + if (link->tosock==nldrag->sock) break; } - if(link) { + if (link) { /* send changed event to original tonode */ - if(link->tonode) + if (link->tonode) snode_update(snode, link->tonode); nldrag->node= link->fromnode; @@ -2518,11 +2519,11 @@ static int node_link_invoke(bContext *C, wmOperator *op, wmEvent *event) nldrag->in_out= node_link_init(snode, nldrag); - if(nldrag->in_out) { + if (nldrag->in_out) { op->customdata= nldrag; /* we make a temporal link */ - if(nldrag->in_out==SOCK_OUT) { + if (nldrag->in_out==SOCK_OUT) { nldrag->link= MEM_callocN(sizeof(bNodeLink), "link"); nldrag->link->fromnode= nldrag->node; nldrag->link->fromsock= nldrag->sock; @@ -2626,11 +2627,11 @@ static int cut_links_intersect(bNodeLink *link, float mcoords[][2], int tot) float coord_array[LINK_RESOL+1][2]; int i, b; - if(node_link_bezier_points(NULL, NULL, link, coord_array, LINK_RESOL)) { + if (node_link_bezier_points(NULL, NULL, link, coord_array, LINK_RESOL)) { - for(i=0; i 0) + for (i=0; i 0) return 1; } return 0; @@ -2650,19 +2651,19 @@ static int cut_links_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; - if(i>1) { + if (i>1) { bNodeLink *link, *next; ED_preview_kill_jobs(C); - for(link= snode->edittree->links.first; link; link= next) { + for (link= snode->edittree->links.first; link; link= next) { next= link->next; - if(cut_links_intersect(link, mcoords, i)) { + if (cut_links_intersect(link, mcoords, i)) { snode_update(snode, link->tonode); nodeRemLink(snode->edittree, link); } @@ -2711,8 +2712,8 @@ static int detach_links_exec(bContext *C, wmOperator *UNUSED(op)) ED_preview_kill_jobs(C); - for(node= ntree->nodes.first; node; node= node->next) { - if(node->flag & SELECT) { + for (node= ntree->nodes.first; node; node= node->next) { + if (node->flag & SELECT) { nodeInternalRelink(ntree, node); } } @@ -2751,8 +2752,8 @@ static bNodeSocket *socket_best_match(ListBase *sockets) /* try all types, starting from 'highest' (i.e. colors, vectors, values) */ for (type=maxtype; type >= 0; --type) { - for(sock= sockets->first; sock; sock= sock->next) { - if(!nodeSocketIsHidden(sock) && type==sock->type) { + for (sock= sockets->first; sock; sock= sock->next) { + if (!nodeSocketIsHidden(sock) && type==sock->type) { return sock; } } @@ -2760,8 +2761,8 @@ static bNodeSocket *socket_best_match(ListBase *sockets) /* no visible sockets, unhide first of highest type */ for (type=maxtype; type >= 0; --type) { - for(sock= sockets->first; sock; sock= sock->next) { - if(type==sock->type) { + for (sock= sockets->first; sock; sock= sock->next) { + if (type==sock->type) { sock->flag &= ~(SOCK_HIDDEN|SOCK_AUTO_HIDDEN); return sock; } @@ -2779,27 +2780,27 @@ static SpaceNode *ed_node_link_conditions(ScrArea *sa, bNode **select) bNodeLink *link; /* no unlucky accidents */ - if(sa==NULL || sa->spacetype!=SPACE_NODE) return NULL; + if (sa==NULL || sa->spacetype!=SPACE_NODE) return NULL; *select= NULL; - for(node= snode->edittree->nodes.first; node; node= node->next) { - if(node->flag & SELECT) { - if(*select) + for (node= snode->edittree->nodes.first; node; node= node->next) { + if (node->flag & SELECT) { + if (*select) break; else *select= node; } } /* only one selected */ - if(node || *select==NULL) return NULL; + if (node || *select==NULL) return NULL; /* correct node */ - if((*select)->inputs.first==NULL || (*select)->outputs.first==NULL) return NULL; + if ((*select)->inputs.first==NULL || (*select)->outputs.first==NULL) return NULL; /* test node for links */ - for(link= snode->edittree->links.first; link; link=link->next) { - if(link->tonode == *select || link->fromnode == *select) + for (link= snode->edittree->links.first; link; link=link->next) { + if (link->tonode == *select || link->fromnode == *select) return NULL; } @@ -2814,14 +2815,14 @@ void ED_node_link_insert(ScrArea *sa) bNodeLink *link; bNodeSocket *sockto; - if(snode==NULL) return; + if (snode==NULL) 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) { + if (link) { node= link->tonode; sockto= link->tosock; @@ -2845,13 +2846,13 @@ void ED_node_link_intersect_test(ScrArea *sa, int test) bNodeLink *link, *selink=NULL; float mcoords[6][2]; - if(snode==NULL) return; + if (snode==NULL) 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; /* okay, there's 1 node, without links, now intersect */ mcoords[0][0]= select->totr.xmin; @@ -2869,16 +2870,16 @@ void ED_node_link_intersect_test(ScrArea *sa, int test) /* we only tag a single link for intersect now */ /* idea; use header dist when more? */ - for(link= snode->edittree->links.first; link; link=link->next) { + for (link= snode->edittree->links.first; link; link=link->next) { - if(cut_links_intersect(link, mcoords, 5)) { /* intersect code wants edges */ - if(selink) + if (cut_links_intersect(link, mcoords, 5)) { /* intersect code wants edges */ + if (selink) break; selink= link; } } - if(link==NULL && selink) + if (link==NULL && selink) selink->flag |= NODE_LINKFLAG_HILITE; } @@ -2898,13 +2899,13 @@ static int node_read_renderlayers_exec(bContext *C, wmOperator *UNUSED(op)) ED_preview_kill_jobs(C); /* first tag scenes unread */ - for(scene= bmain->scene.first; scene; scene= scene->id.next) + for (scene= bmain->scene.first; scene; scene= scene->id.next) scene->id.flag |= LIB_DOIT; - for(node= snode->edittree->nodes.first; node; node= node->next) { - if(node->type==CMP_NODE_R_LAYERS) { + for (node= snode->edittree->nodes.first; node; node= node->next) { + if (node->type==CMP_NODE_R_LAYERS) { ID *id= node->id; - if(id->flag & LIB_DOIT) { + if (id->flag & LIB_DOIT) { RE_ReadRenderResult(curscene, (Scene *)id); ntreeCompositTagRender((Scene *)id); id->flag &= ~LIB_DOIT; @@ -2970,15 +2971,15 @@ int node_render_changed_exec(bContext *C, wmOperator *UNUSED(op)) Scene *sce= CTX_data_scene(C); bNode *node; - for(node= sce->nodetree->nodes.first; node; node= node->next) { - if(node->id==(ID *)sce && node->need_exec) { + for (node= sce->nodetree->nodes.first; node; node= node->next) { + if (node->id==(ID *)sce && node->need_exec) { break; } } - if(node) { + if (node) { SceneRenderLayer *srl= BLI_findlink(&sce->r.layers, node->custom1); - if(srl) { + if (srl) { PointerRNA op_ptr; WM_operator_properties_create(&op_ptr, "RENDER_OT_render"); @@ -3021,20 +3022,20 @@ static int node_group_make_exec(bContext *C, wmOperator *op) SpaceNode *snode = CTX_wm_space_node(C); bNode *gnode; - if(snode->edittree!=snode->nodetree) { + if (snode->edittree!=snode->nodetree) { BKE_report(op->reports, RPT_WARNING, "Can not add a new Group in a Group"); return OPERATOR_CANCELLED; } /* for time being... is too complex to handle */ - if(snode->treetype==NTREE_COMPOSIT) { - for(gnode=snode->nodetree->nodes.first; gnode; gnode= gnode->next) { - if(gnode->flag & SELECT) - if(gnode->type==CMP_NODE_R_LAYERS) + if (snode->treetype==NTREE_COMPOSIT) { + for (gnode=snode->nodetree->nodes.first; gnode; gnode= gnode->next) { + if (gnode->flag & SELECT) + if (gnode->type==CMP_NODE_R_LAYERS) break; } - if(gnode) { + if (gnode) { BKE_report(op->reports, RPT_WARNING, "Can not add RenderLayer in a Group"); return OPERATOR_CANCELLED; } @@ -3043,7 +3044,7 @@ static int node_group_make_exec(bContext *C, wmOperator *op) ED_preview_kill_jobs(C); gnode= node_group_make_from_selected(snode->nodetree); - if(gnode==NULL) { + if (gnode==NULL) { BKE_report(op->reports, RPT_WARNING, "Can not make Group"); return OPERATOR_CANCELLED; } @@ -3084,29 +3085,29 @@ static void node_flag_toggle_exec(SpaceNode *snode, int toggle_flag) * If the flag is set on all nodes it is unset. * If the flag is not set on all nodes, it is set. */ - for(node= snode->edittree->nodes.first; node; node= node->next) { - if(node->flag & SELECT) { + 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->flag & NODE_OPTIONS)==0) + if (toggle_flag== NODE_OPTIONS && (node->typeinfo->flag & NODE_OPTIONS)==0) continue; - if(node->flag & toggle_flag) + if (node->flag & toggle_flag) tot_eq++; else tot_neq++; } } - for(node= snode->edittree->nodes.first; node; node= node->next) { - if(node->flag & SELECT) { + 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->flag & NODE_OPTIONS)==0) + if (toggle_flag== NODE_OPTIONS && (node->typeinfo->flag & NODE_OPTIONS)==0) continue; - if( (tot_eq && tot_neq) || tot_eq==0) { + if ( (tot_eq && tot_neq) || tot_eq==0) { node->flag |= toggle_flag; /* hide/unhide node also toggles unlinked socket display */ @@ -3129,7 +3130,7 @@ 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); @@ -3159,7 +3160,7 @@ 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(C); @@ -3191,7 +3192,7 @@ 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); @@ -3223,24 +3224,24 @@ 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(C); /* Toggle for all selected nodes */ hidden = 0; - for(node= snode->edittree->nodes.first; node; node= node->next) { - if(node->flag & SELECT) { - if(node_has_hidden_sockets(node, SOCK_HIDDEN)) { + for (node= snode->edittree->nodes.first; node; node= node->next) { + if (node->flag & SELECT) { + if (node_has_hidden_sockets(node, SOCK_HIDDEN)) { hidden= 1; break; } } } - for(node= snode->edittree->nodes.first; node; node= node->next) { - if(node->flag & SELECT) { + for (node= snode->edittree->nodes.first; node; node= node->next) { + if (node->flag & SELECT) { node_set_hidden_sockets(snode, node, SOCK_HIDDEN, !hidden); } } @@ -3276,7 +3277,7 @@ static int node_mute_exec(bContext *C, wmOperator *UNUSED(op)) ED_preview_kill_jobs(C); - for(node= snode->edittree->nodes.first; node; node= node->next) { + for (node= snode->edittree->nodes.first; node; node= node->next) { /* Only allow muting of nodes having a mute func! */ if ((node->flag & SELECT) && node->typeinfo->internal_connect) { node->flag ^= NODE_MUTED; @@ -3314,11 +3315,11 @@ static int node_delete_exec(bContext *C, wmOperator *UNUSED(op)) ED_preview_kill_jobs(C); - for(node= snode->edittree->nodes.first; node; node= next) { + for (node= snode->edittree->nodes.first; node; node= next) { next= node->next; - if(node->flag & SELECT) { + if (node->flag & SELECT) { /* check id user here, nodeFreeNode is called for free dbase too */ - if(node->id) + if (node->id) node->id->us--; nodeFreeNode(snode->edittree, node); } @@ -3355,13 +3356,13 @@ static int node_delete_reconnect_exec(bContext *C, wmOperator *UNUSED(op)) ED_preview_kill_jobs(C); - for(node= snode->edittree->nodes.first; node; node= next) { + for (node= snode->edittree->nodes.first; node; node= next) { next= node->next; - if(node->flag & SELECT) { + if (node->flag & SELECT) { nodeInternalRelink(snode->edittree, node); /* check id user here, nodeFreeNode is called for free dbase too */ - if(node->id) + if (node->id) node->id->us--; nodeFreeNode(snode->edittree, node); } @@ -3438,17 +3439,17 @@ static int node_add_file_exec(bContext *C, wmOperator *op) ima= BKE_add_image_file(path); - if(!ima) { + if (!ima) { BKE_reportf(op->reports, RPT_ERROR, "Can't read: \"%s\", %s", path, errno ? strerror(errno) : "Unsupported image format"); return OPERATOR_CANCELLED; } } - else if(RNA_struct_property_is_set(op->ptr, "name")) { + else if (RNA_struct_property_is_set(op->ptr, "name")) { char name[MAX_ID_NAME-2]; RNA_string_get(op->ptr, "name", name); ima= (Image *)find_id("IM", name); - if(!ima) { + if (!ima) { BKE_reportf(op->reports, RPT_ERROR, "Image named \"%s\", not found", name); return OPERATOR_CANCELLED; } @@ -3544,13 +3545,13 @@ static int new_node_tree_exec(bContext *C, wmOperator *op) RNA_string_get(op->ptr, "name", treename); ntree = ntreeAddTree(treename, treetype, 0); - if(!ntree) + if (!ntree) return OPERATOR_CANCELLED; /* hook into UI */ uiIDContextProperty(C, &ptr, &prop); - if(prop) { + if (prop) { RNA_id_pointer_create(&ntree->id, &idptr); RNA_property_pointer_set(&ptr, prop, idptr); /* RNA_property_pointer_set increases the user count, @@ -3559,7 +3560,7 @@ static int new_node_tree_exec(bContext *C, wmOperator *op) --ntree->id.us; RNA_property_update(C, &ptr, prop); } - else if(snode) { + else if (snode) { Scene *scene= CTX_data_scene(C); snode->nodetree = ntree; diff --git a/source/blender/editors/space_node/node_header.c b/source/blender/editors/space_node/node_header.c index f450356b288..7ddc4bdf857 100644 --- a/source/blender/editors/space_node/node_header.c +++ b/source/blender/editors/space_node/node_header.c @@ -75,33 +75,33 @@ static void do_node_add(bContext *C, bNodeTemplate *ntemp) bNode *node; /* get location to add node at mouse */ - for(ar=sa->regionbase.first; ar; ar=ar->next) { - if(ar->regiontype == RGN_TYPE_WINDOW) { + for (ar=sa->regionbase.first; ar; ar=ar->next) { + if (ar->regiontype == RGN_TYPE_WINDOW) { wmWindow *win= CTX_wm_window(C); int x= win->eventstate->x - ar->winrct.xmin; int y= win->eventstate->y - ar->winrct.ymin; - if(y < 60) y+= 60; + if (y < 60) y+= 60; UI_view2d_region_to_view(&ar->v2d, x, y, &snode->mx, &snode->my); } } /* store selection in temp test flag */ - for(node= snode->edittree->nodes.first; node; node= node->next) { - if(node->flag & NODE_SELECT) node->flag |= NODE_TEST; + for (node= snode->edittree->nodes.first; node; node= node->next) { + if (node->flag & NODE_SELECT) node->flag |= NODE_TEST; else node->flag &= ~NODE_TEST; } /* node= */ node_add_node(snode, bmain, scene, ntemp, snode->mx, snode->my); /* select previous selection before autoconnect */ - for(node= snode->edittree->nodes.first; node; node= node->next) { - if(node->flag & NODE_TEST) node->flag |= NODE_SELECT; + for (node= snode->edittree->nodes.first; node; node= node->next) { + if (node->flag & NODE_TEST) node->flag |= NODE_SELECT; } /* deselect after autoconnection */ - for(node= snode->edittree->nodes.first; node; node= node->next) { - if(node->flag & NODE_TEST) node->flag &= ~NODE_SELECT; + for (node= snode->edittree->nodes.first; node; node= node->next) { + if (node->flag & NODE_TEST) node->flag &= ~NODE_SELECT; } snode_notify(C, snode); @@ -195,13 +195,13 @@ static void node_add_menu(bContext *C, uiLayout *layout, void *arg_nodeclass) ntree = snode->nodetree; - if(!ntree) { + if (!ntree) { uiItemS(layout); return; } - if(ntree->type == NTREE_SHADER) { - if(scene_use_new_shading_nodes(scene)) + if (ntree->type == NTREE_SHADER) { + if (scene_use_new_shading_nodes(scene)) compatibility= NODE_NEW_SHADING; else compatibility= NODE_OLD_SHADING; @@ -221,7 +221,7 @@ static void node_add_menu(bContext *C, uiLayout *layout, void *arg_nodeclass) uiItemV(layout, IFACE_("New While Loop"), 0, -NODE_WHILELOOP); uiItemS(layout); - for(ngroup=bmain->nodetree.first, event=0; ngroup; ngroup= ngroup->id.next, ++event) { + for (ngroup=bmain->nodetree.first, event=0; ngroup; ngroup= ngroup->id.next, ++event) { /* only use group trees */ if (ngroup->type==ntree->type && ELEM3(ngroup->nodetype, NODE_GROUP, NODE_FORLOOP, NODE_WHILELOOP)) { uiItemV(layout, ngroup->id.name+2, 0, event); @@ -257,10 +257,10 @@ static void node_menu_add(const bContext *C, Menu *menu) uiLayout *layout= menu->layout; bNodeTreeType *ntreetype= ntreeGetType(snode->treetype); - if(!snode->nodetree) + if (!snode->nodetree) uiLayoutSetActive(layout, 0); - if(ntreetype && ntreetype->foreach_nodeclass) + if (ntreetype && ntreetype->foreach_nodeclass) ntreetype->foreach_nodeclass(scene, layout, node_menu_add_foreach_cb); } diff --git a/source/blender/editors/space_node/node_select.c b/source/blender/editors/space_node/node_select.c index da8fa577656..15d7986a5c4 100644 --- a/source/blender/editors/space_node/node_select.c +++ b/source/blender/editors/space_node/node_select.c @@ -62,7 +62,7 @@ static bNode *node_under_mouse(bNodeTree *ntree, int mx, int my) { bNode *node; - for(node=ntree->nodes.last; node; node=node->prev) { + for (node=ntree->nodes.last; node; node=node->prev) { /* node body (header and scale are in other operators) */ if (BLI_in_rctf(&node->totr, mx, my)) return node; @@ -247,7 +247,7 @@ 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) node_deselect(node); } @@ -561,14 +561,14 @@ static int node_borderselect_exec(bContext *C, wmOperator *op) rect.ymax = RNA_int_get(op->ptr, "ymax"); UI_view2d_region_to_view(&ar->v2d, rect.xmax, rect.ymax, &rectf.xmax, &rectf.ymax); - for(node= snode->edittree->nodes.first; node; node= node->next) { - if(BLI_isect_rctf(&rectf, &node->totr, NULL)) { - if(gesture_mode==GESTURE_MODAL_SELECT) + for (node= snode->edittree->nodes.first; node; node= node->next) { + if (BLI_isect_rctf(&rectf, &node->totr, NULL)) { + if (gesture_mode==GESTURE_MODAL_SELECT) node_select(node); else node_deselect(node); } - else if(!extend) { + else if (!extend) { node_deselect(node); } } @@ -632,16 +632,16 @@ static int node_select_all_exec(bContext *C, wmOperator *UNUSED(op)) bNode *node; int count= 0; - for(node=first; node; node=node->next) - if(node->flag & NODE_SELECT) + for (node=first; node; node=node->next) + if (node->flag & NODE_SELECT) count++; - if(count) { - for(node=first; node; node=node->next) + if (count) { + for (node=first; node; node=node->next) node_deselect(node); } else { - for(node=first; node; node=node->next) + for (node=first; node; node=node->next) node_select(node); } @@ -716,16 +716,16 @@ 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(link->fromnode && link->tonode && (link->tonode->flag & NODE_SELECT)) + for (link=snode->edittree->links.first; link; link=link->next) { + 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) + for (node=snode->edittree->nodes.first; node; node=node->next) { + if (node->flag & NODE_TEST) node_select(node); } diff --git a/source/blender/editors/space_node/node_state.c b/source/blender/editors/space_node/node_state.c index 2ab24141c7d..5463d4a8ff0 100644 --- a/source/blender/editors/space_node/node_state.c +++ b/source/blender/editors/space_node/node_state.c @@ -71,9 +71,9 @@ static void snode_home(ScrArea *UNUSED(sa), ARegion *ar, SpaceNode* snode) cur->xmax=ar->winx; cur->ymax=ar->winy; - if(snode->edittree) { - for(node= snode->edittree->nodes.first; node; node= node->next) { - if(first) { + if (snode->edittree) { + for (node= snode->edittree->nodes.first; node; node= node->next) { + if (first) { first= 0; ar->v2d.cur= node->totr; } @@ -88,7 +88,7 @@ static void snode_home(ScrArea *UNUSED(sa), ARegion *ar, SpaceNode* snode) width= cur->xmax - cur->xmin; height= cur->ymax- cur->ymin; - if(width > height) { + if (width > height) { float newheight; newheight= oldheight * width/oldwidth; cur->ymin = cur->ymin - newheight/4; diff --git a/source/blender/editors/space_node/node_templates.c b/source/blender/editors/space_node/node_templates.c index 298867c18af..3d841b05632 100644 --- a/source/blender/editors/space_node/node_templates.c +++ b/source/blender/editors/space_node/node_templates.c @@ -67,13 +67,13 @@ 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); } @@ -81,13 +81,13 @@ 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); } @@ -96,28 +96,28 @@ static void node_remove_linked(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) { + for (node=ntree->nodes.first; node; node=next) { next = node->next; - if(node->flag & NODE_TEST) { - if(node->id) + if (node->flag & NODE_TEST) { + if (node->id) node->id->us--; nodeFreeNode(ntree, node); } @@ -127,7 +127,7 @@ static void node_remove_linked(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); @@ -141,7 +141,7 @@ 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(ntree, sock_to->link->fromnode); @@ -160,31 +160,31 @@ static void node_socket_add_replace(Main *bmain, bNodeTree *ntree, bNode *node_t bNode *node_prev = NULL; /* unlink existing node */ - if(sock_to->link) { + if (sock_to->link) { node_prev = sock_to->link->fromnode; nodeRemLink(ntree, sock_to->link); } /* find existing node that we can use */ - for(node_from=ntree->nodes.first; node_from; node_from=node_from->next) - if(node_from->type == ntemp->type) + for (node_from=ntree->nodes.first; node_from; node_from=node_from->next) + if (node_from->type == ntemp->type) break; - if(node_from) - if(!(node_from->inputs.first == NULL && !(node_from->typeinfo->flag & NODE_OPTIONS))) + if (node_from) + if (!(node_from->inputs.first == NULL && !(node_from->typeinfo->flag & NODE_OPTIONS))) node_from = NULL; - if(node_prev && node_prev->type == ntemp->type && + if (node_prev && node_prev->type == ntemp->type && (ntemp->type != NODE_GROUP || node_prev->id == &ntemp->ngroup->id)) { /* keep the previous node if it's the same type */ node_from = node_prev; } - else if(!node_from) { + else if (!node_from) { node_from= nodeAddNode(ntree, ntemp); node_from->locx = node_to->locx - (node_from->typeinfo->width + 50); node_from->locy = node_to->locy; - if(node_from->id) + if (node_from->id) id_us_plus(node_from->id); } @@ -195,18 +195,18 @@ static void node_socket_add_replace(Main *bmain, bNodeTree *ntree, bNode *node_t nodeAddLink(ntree, node_from, sock_from, node_to, sock_to); /* copy input sockets from previous node */ - if(node_prev && node_from != node_prev) { + if (node_prev && node_from != node_prev) { bNodeSocket *sock_prev, *sock_from; - 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) { + 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) continue; - if(strcmp(sock_prev->name, sock_from->name) == 0 && sock_prev->type == sock_from->type) { + if (strcmp(sock_prev->name, sock_from->name) == 0 && sock_prev->type == sock_from->type) { bNodeLink *link = sock_prev->link; - if(link && link->fromnode) { + if (link && link->fromnode) { nodeAddLink(ntree, link->fromnode, link->fromsock, node_from, sock_from); nodeRemLink(ntree, link); } @@ -219,7 +219,7 @@ static void node_socket_add_replace(Main *bmain, bNodeTree *ntree, bNode *node_t } /* also preserve mapping for texture nodes */ - if(node_from->typeinfo->nclass == NODE_CLASS_TEXTURE && + if (node_from->typeinfo->nclass == NODE_CLASS_TEXTURE && node_prev->typeinfo->nclass == NODE_CLASS_TEXTURE) memcpy(node_from->storage, node_prev->storage, sizeof(NodeTexBase)); @@ -267,9 +267,9 @@ static void ui_node_link(bContext *C, void *arg_p, void *event_p) ntemp.type = arg->type; ntemp.ngroup = arg->ngroup; - 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 node_socket_add_replace(bmain, ntree, node_to, sock_to, &ntemp, arg->output); @@ -279,11 +279,11 @@ static void ui_node_link(bContext *C, void *arg_p, void *event_p) static void ui_node_sock_name(bNodeSocket *sock, char name[UI_MAX_NAME_STR]) { - if(sock->link && sock->link->fromnode) { + if (sock->link && sock->link->fromnode) { bNode *node = sock->link->fromnode; char node_name[UI_MAX_NAME_STR]; - if(node->type == NODE_GROUP) { + if (node->type == NODE_GROUP) { if (node->id) BLI_strncpy(node_name, node->id->name+2, UI_MAX_NAME_STR); else @@ -292,14 +292,14 @@ static void ui_node_sock_name(bNodeSocket *sock, char name[UI_MAX_NAME_STR]) else BLI_strncpy(node_name, node->typeinfo->name, UI_MAX_NAME_STR); - if(node->inputs.first == NULL && + if (node->inputs.first == NULL && node->outputs.first != node->outputs.last && !(node->typeinfo->flag & NODE_OPTIONS)) BLI_snprintf(name, UI_MAX_NAME_STR, "%s | %s", node_name, sock->link->fromsock->name); else BLI_strncpy(name, node_name, UI_MAX_NAME_STR); } - else if(sock->type == SOCK_SHADER) + else if (sock->type == SOCK_SHADER) BLI_strncpy(name, "None", UI_MAX_NAME_STR); else BLI_strncpy(name, "Default", UI_MAX_NAME_STR); @@ -325,31 +325,31 @@ static void ui_node_menu_column(NodeLinkArg *arg, int nclass, const char *cname) int first = 1; int compatibility= 0; - if(ntree->type == NTREE_SHADER) { - if(scene_use_new_shading_nodes(arg->scene)) + if (ntree->type == NTREE_SHADER) { + if (scene_use_new_shading_nodes(arg->scene)) compatibility= NODE_NEW_SHADING; else compatibility= NODE_OLD_SHADING; } - if(nclass == NODE_CLASS_GROUP) { - for(ngroup=bmain->nodetree.first; ngroup; ngroup=ngroup->id.next) { + if (nclass == NODE_CLASS_GROUP) { + for (ngroup=bmain->nodetree.first; ngroup; ngroup=ngroup->id.next) { bNodeSocket *gsock; char name[UI_MAX_NAME_STR]; int i, j, num = 0; - if(ngroup->type != ntree->type) + if (ngroup->type != ntree->type) continue; - for(gsock=ngroup->inputs.first; gsock; gsock=gsock->next) - if(ui_compatible_sockets(gsock->type, sock->type)) + for (gsock=ngroup->inputs.first; gsock; gsock=gsock->next) + if (ui_compatible_sockets(gsock->type, sock->type)) num++; - for(i=0, j=0, gsock=ngroup->outputs.first; gsock; gsock=gsock->next, i++) { - if(!ui_compatible_sockets(gsock->type, sock->type)) + for (i=0, j=0, gsock=ngroup->outputs.first; gsock; gsock=gsock->next, i++) { + if (!ui_compatible_sockets(gsock->type, sock->type)) continue; - if(first) { + if (first) { column= uiLayoutColumn(layout, 0); uiBlockSetCurLayout(block, column); @@ -360,8 +360,8 @@ static void ui_node_menu_column(NodeLinkArg *arg, int nclass, const char *cname) first = 0; } - if(num > 1) { - if(j == 0) { + if (num > 1) { + if (j == 0) { uiItemL(column, ngroup->id.name+2, ICON_NODE); but= block->buttons.last; but->flag= UI_TEXT_LEFT; @@ -387,26 +387,26 @@ static void ui_node_menu_column(NodeLinkArg *arg, int nclass, const char *cname) else { bNodeTreeType *ttype= ntreeGetType(ntree->type); - for(ntype=ttype->node_types.first; ntype; ntype=ntype->next) { + for (ntype=ttype->node_types.first; ntype; ntype=ntype->next) { bNodeSocketTemplate *stemp; char name[UI_MAX_NAME_STR]; int i, j, num = 0; - if(compatibility && !(ntype->compatibility & compatibility)) + if (compatibility && !(ntype->compatibility & compatibility)) continue; - if(ntype->nclass != nclass) + if (ntype->nclass != nclass) continue; - for(i=0, stemp=ntype->outputs; stemp && stemp->type != -1; stemp++, i++) - if(ui_compatible_sockets(stemp->type, sock->type)) + for (i=0, stemp=ntype->outputs; stemp && stemp->type != -1; stemp++, i++) + if (ui_compatible_sockets(stemp->type, sock->type)) num++; - for(i=0, j=0, stemp=ntype->outputs; stemp && stemp->type != -1; stemp++, i++) { - if(!ui_compatible_sockets(stemp->type, sock->type)) + for (i=0, j=0, stemp=ntype->outputs; stemp && stemp->type != -1; stemp++, i++) { + if (!ui_compatible_sockets(stemp->type, sock->type)) continue; - if(first) { + if (first) { column= uiLayoutColumn(layout, 0); uiBlockSetCurLayout(block, column); @@ -417,8 +417,8 @@ static void ui_node_menu_column(NodeLinkArg *arg, int nclass, const char *cname) first = 0; } - if(num > 1) { - if(j == 0) { + if (num > 1) { + if (j == 0) { uiItemL(column, ntype->name, ICON_NODE); but= block->buttons.last; but->flag= UI_TEXT_LEFT; @@ -446,7 +446,7 @@ 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); } @@ -468,13 +468,13 @@ 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, 0); uiBlockSetCurLayout(block, column); - if(sock->link) { + if (sock->link) { uiItemL(column, "Link", ICON_NONE); but= block->buttons.last; but->flag= UI_TEXT_LEFT; @@ -506,7 +506,7 @@ void uiTemplateNodeLink(uiLayout *layout, bNodeTree *ntree, bNode *node, bNodeSo uiBlockSetCurLayout(block, layout); - if(sock->link || sock->type == SOCK_SHADER || (sock->flag & SOCK_HIDE_VALUE)) { + if (sock->link || sock->type == SOCK_SHADER || (sock->flag & SOCK_HIDE_VALUE)) { char name[UI_MAX_NAME_STR]; ui_node_sock_name(sock, name); but = uiDefMenuBut(block, ui_template_node_link_menu, NULL, name, 0, 0, UI_UNIT_X*4, UI_UNIT_Y, ""); @@ -519,8 +519,8 @@ 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; } @@ -537,8 +537,8 @@ static void ui_node_draw_node(uiLayout *layout, bContext *C, bNodeTree *ntree, b RNA_pointer_create(&ntree->id, &RNA_Node, node, &nodeptr); - if(node->typeinfo->uifunc) { - if(node->type != NODE_GROUP) { + if (node->typeinfo->uifunc) { + if (node->type != NODE_GROUP) { split = uiLayoutSplit(layout, 0.35f, 0); col = uiLayoutColumn(split, 0); col = uiLayoutColumn(split, 0); @@ -547,7 +547,7 @@ 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); } @@ -562,7 +562,7 @@ static void ui_node_draw_input(uiLayout *layout, bContext *C, bNodeTree *ntree, int 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 */ @@ -570,7 +570,7 @@ static void ui_node_draw_input(uiLayout *layout, bContext *C, bNodeTree *ntree, 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 */ @@ -586,10 +586,10 @@ static void ui_node_draw_input(uiLayout *layout, bContext *C, bNodeTree *ntree, row = uiLayoutRow(split, 1); - if(depth > 0) { + if (depth > 0) { uiBlockSetEmboss(block, UI_EMBOSSN); - if(lnode && (lnode->inputs.first || (lnode->typeinfo->uifunc && lnode->type != NODE_GROUP))) { + if (lnode && (lnode->inputs.first || (lnode->typeinfo->uifunc && lnode->type != NODE_GROUP))) { 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); } @@ -606,16 +606,16 @@ static void ui_node_draw_input(uiLayout *layout, bContext *C, bNodeTree *ntree, bt= block->buttons.last; bt->flag= UI_TEXT_LEFT; - if(dependency_loop) { + if (dependency_loop) { row = uiLayoutRow(split, 0); uiItemL(row, "Dependency Loop", ICON_ERROR); } - else if(lnode) { + else if (lnode) { /* input linked to a node */ uiTemplateNodeLink(split, ntree, node, input); - if(!(input->flag & SOCK_COLLAPSED)) { - if(depth == 0) + if (!(input->flag & SOCK_COLLAPSED)) { + if (depth == 0) uiItemS(layout); ui_node_draw_node(layout, C, ntree, lnode, depth); @@ -623,8 +623,8 @@ static void ui_node_draw_input(uiLayout *layout, bContext *C, bNodeTree *ntree, } else { /* input not linked, show value */ - if(input->type != SOCK_SHADER && !(input->flag & SOCK_HIDE_VALUE)) { - if(input->type == SOCK_VECTOR) { + if (input->type != SOCK_SHADER && !(input->flag & SOCK_HIDE_VALUE)) { + if (input->type == SOCK_VECTOR) { row = uiLayoutRow(split, 0); col = uiLayoutColumn(row, 0); @@ -649,14 +649,14 @@ 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 ui_node_draw_node(layout, C, ntree, node, 0); diff --git a/source/blender/editors/space_node/space_node.c b/source/blender/editors/space_node/space_node.c index fc5965535b1..fca9927b0f5 100644 --- a/source/blender/editors/space_node/space_node.c +++ b/source/blender/editors/space_node/space_node.c @@ -72,13 +72,13 @@ 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"); @@ -183,8 +183,8 @@ static void node_area_listener(ScrArea *sa, wmNotifier *wmn) ED_area_tag_redraw(sa); break; case ND_TRANSFORM_DONE: - if(type==NTREE_COMPOSIT) { - if(snode->flag & SNODE_AUTO_RENDER) { + if (type==NTREE_COMPOSIT) { + if (snode->flag & SNODE_AUTO_RENDER) { snode->recalc= 1; ED_area_tag_refresh(sa); } @@ -193,48 +193,48 @@ static void node_area_listener(ScrArea *sa, wmNotifier *wmn) } break; case NC_WM: - if(wmn->data==ND_FILEREAD) + if (wmn->data==ND_FILEREAD) ED_area_tag_refresh(sa); break; /* future: add ID checks? */ case NC_MATERIAL: - if(type==NTREE_SHADER) { - if(wmn->data==ND_SHADING) + if (type==NTREE_SHADER) { + 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->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(type==NTREE_SHADER || type==NTREE_TEXTURE) { - if(wmn->data==ND_NODES) + if (type==NTREE_SHADER || type==NTREE_TEXTURE) { + if (wmn->data==ND_NODES) ED_area_tag_refresh(sa); } break; case NC_WORLD: - if(type==NTREE_SHADER && shader_type==SNODE_SHADER_WORLD) { + if (type==NTREE_SHADER && shader_type==SNODE_SHADER_WORLD) { ED_area_tag_refresh(sa); } break; case NC_OBJECT: - if(type==NTREE_SHADER) { - if(wmn->data==ND_OB_SHADING) + if (type==NTREE_SHADER) { + if (wmn->data==ND_OB_SHADING) ED_area_tag_refresh(sa); } break; case NC_TEXT: /* pynodes */ - if(wmn->data==ND_SHADING) + if (wmn->data==ND_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: @@ -253,11 +253,11 @@ static void node_area_listener(ScrArea *sa, wmNotifier *wmn) case NC_IMAGE: if (wmn->action == NA_EDITED) { - if(type==NTREE_COMPOSIT) { + if (type==NTREE_COMPOSIT) { /* 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); } } @@ -272,29 +272,29 @@ static void node_area_refresh(const struct bContext *C, struct ScrArea *sa) snode_set_context(snode, CTX_data_scene(C)); - if(snode->nodetree) { - if(snode->treetype==NTREE_SHADER) { - if(GS(snode->id->name) == ID_MA) { + if (snode->nodetree) { + if (snode->treetype==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) { + else if (GS(snode->id->name) == ID_LA) { Lamp *la= (Lamp *)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) { + 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->treetype==NTREE_COMPOSIT) { + else if (snode->treetype==NTREE_COMPOSIT) { Scene *scene= (Scene *)snode->id; - if(scene->use_nodes) { + if (scene->use_nodes) { /* recalc is set on 3d view changes for auto compo */ - if(snode->recalc) { + if (snode->recalc) { snode->recalc= 0; node_render_changed_exec((struct bContext*)C, NULL); } @@ -302,9 +302,9 @@ static void node_area_refresh(const struct bContext *C, struct ScrArea *sa) snode_composite_job(C, sa); } } - else if(snode->treetype==NTREE_TEXTURE) { + else if (snode->treetype==NTREE_TEXTURE) { Tex *tex= (Tex *)snode->id; - if(tex->use_nodes) { + if (tex->use_nodes) { ED_preview_shader_job(C, sa, snode->id, NULL, NULL, 100, 100, PR_NODE_RENDER); } } @@ -372,13 +372,13 @@ static void node_main_area_draw(const bContext *C, ARegion *ar) static int node_drop_poll(bContext *UNUSED(C), wmDrag *drag, wmEvent *UNUSED(event)) { - if(drag->type==WM_DRAG_ID) { + if (drag->type==WM_DRAG_ID) { ID *id= (ID *)drag->poin; - if( GS(id->name)==ID_IM ) + if ( GS(id->name)==ID_IM ) return 1; } - else if(drag->type==WM_DRAG_PATH){ - if(ELEM(drag->icon, 0, ICON_FILE_IMAGE)) /* rule might not work? */ + else if (drag->type==WM_DRAG_PATH) { + if (ELEM(drag->icon, 0, ICON_FILE_IMAGE)) /* rule might not work? */ return 1; } return 0; @@ -388,7 +388,7 @@ static void node_id_path_drop_copy(wmDrag *drag, wmDropBox *drop) { ID *id= (ID *)drag->poin; - if(id) { + if (id) { RNA_string_set(drop->ptr, "name", id->name+2); } if (drag->path[0]) { @@ -431,11 +431,11 @@ static void node_region_listener(ARegion *ar, wmNotifier *wmn) /* context changes */ switch(wmn->category) { case NC_SPACE: - if(wmn->data==ND_SPACE_NODE) + if (wmn->data==ND_SPACE_NODE) ED_region_tag_redraw(ar); break; case NC_SCREEN: - if(wmn->data == ND_GPENCIL) + if (wmn->data == ND_GPENCIL) ED_region_tag_redraw(ar); break; case NC_SCENE: @@ -445,11 +445,11 @@ static void node_region_listener(ARegion *ar, wmNotifier *wmn) 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; } @@ -461,16 +461,16 @@ static int node_context(const bContext *C, const char *member, bContextDataResul { SpaceNode *snode= CTX_wm_space_node(C); - if(CTX_data_dir(member)) { + if (CTX_data_dir(member)) { CTX_data_dir_set(result, node_context_dir); return 1; } - else if(CTX_data_equals(member, "selected_nodes")) { + else if (CTX_data_equals(member, "selected_nodes")) { bNode *node; - if(snode->edittree) { - for(node=snode->edittree->nodes.last; node; node=node->prev) { - if(node->flag & NODE_SELECT) { + if (snode->edittree) { + for (node=snode->edittree->nodes.last; node; node=node->prev) { + if (node->flag & NODE_SELECT) { CTX_data_list_add(result, &snode->edittree->id, &RNA_Node, node); } } @@ -478,12 +478,12 @@ static int node_context(const bContext *C, const char *member, bContextDataResul CTX_data_type_set(result, CTX_DATA_TYPE_COLLECTION); return 1; } - else if(CTX_data_equals(member, "active_node")) { + else if (CTX_data_equals(member, "active_node")) { bNode *node; - if(snode->edittree) { - for(node=snode->edittree->nodes.last; node; node=node->prev) { - if(node->flag & NODE_ACTIVE) { + if (snode->edittree) { + for (node=snode->edittree->nodes.last; node; node=node->prev) { + if (node->flag & NODE_ACTIVE) { CTX_data_pointer_set(result, &snode->edittree->id, &RNA_Node, node); break; } diff --git a/source/blender/editors/space_outliner/outliner_draw.c b/source/blender/editors/space_outliner/outliner_draw.c index 5cc09bf7d97..1c58c4152f0 100644 --- a/source/blender/editors/space_outliner/outliner_draw.c +++ b/source/blender/editors/space_outliner/outliner_draw.c @@ -97,7 +97,7 @@ static void outliner_height(SpaceOops *soops, ListBase *lb, int *h) TreeElement *te= lb->first; while(te) { TreeStoreElem *tselem= TREESTORE(te); - if(TSELEM_OPEN(tselem,soops)) + if (TSELEM_OPEN(tselem,soops)) outliner_height(soops, &te->subtree, h); (*h) += UI_UNIT_Y; te= te->next; @@ -112,7 +112,7 @@ static void outliner_width(SpaceOops *soops, ListBase *lb, int *w) // TreeStoreElem *tselem= TREESTORE(te); // XXX fixme... te->xend is not set yet - if(!TSELEM_OPEN(tselem,soops)) { + if (!TSELEM_OPEN(tselem,soops)) { if (te->xend > *w) *w = te->xend; } @@ -129,15 +129,15 @@ static void outliner_rna_width(SpaceOops *soops, ListBase *lb, int *w, int start TreeStoreElem *tselem= TREESTORE(te); // XXX fixme... (currently, we're using a fixed length of 100)! #if 0 - if(te->xend) { - if(te->xend > *w) + if (te->xend) { + if (te->xend > *w) *w = te->xend; } #endif - if(startx+100 > *w) + if (startx+100 > *w) *w = startx+100; - if(TSELEM_OPEN(tselem,soops)) + if (TSELEM_OPEN(tselem,soops)) outliner_rna_width(soops, &te->subtree, w, startx+UI_UNIT_X); te= te->next; } @@ -150,7 +150,7 @@ static void restrictbutton_view_cb(bContext *C, void *poin, void *poin2) Scene *scene = (Scene *)poin; Object *ob = (Object *)poin2; - if(!common_restrict_check(C, ob)) return; + if (!common_restrict_check(C, ob)) return; /* deselect objects that are invisible */ if (ob->restrictflag & OB_RESTRICT_VIEW) { @@ -167,7 +167,7 @@ static void restrictbutton_sel_cb(bContext *C, void *poin, void *poin2) Scene *scene = (Scene *)poin; Object *ob = (Object *)poin2; - if(!common_restrict_check(C, ob)) return; + if (!common_restrict_check(C, ob)) return; /* if select restriction has just been turned on */ if (ob->restrictflag & OB_RESTRICT_SELECT) { @@ -201,7 +201,7 @@ static void restrictbutton_modifier_cb(bContext *C, void *UNUSED(poin), void *po static void restrictbutton_bone_cb(bContext *C, void *UNUSED(poin), void *poin2) { Bone *bone= (Bone *)poin2; - if(bone && (bone->flag & BONE_HIDDEN_P)) + if (bone && (bone->flag & BONE_HIDDEN_P)) bone->flag &= ~(BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL); WM_event_add_notifier(C, NC_OBJECT|ND_POSE, NULL); } @@ -209,7 +209,7 @@ static void restrictbutton_bone_cb(bContext *C, void *UNUSED(poin), void *poin2) static void restrictbutton_ebone_cb(bContext *C, void *UNUSED(poin), void *poin2) { EditBone *ebone= (EditBone *)poin2; - if(ebone && (ebone->flag & BONE_HIDDEN_A)) + if (ebone && (ebone->flag & BONE_HIDDEN_A)) ebone->flag &= ~(BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL); WM_event_add_notifier(C, NC_OBJECT|ND_POSE, NULL); @@ -219,8 +219,8 @@ static int group_restrict_flag(Group *gr, int flag) { GroupObject *gob; - for(gob= gr->gobject.first; gob; gob= gob->next) { - if((gob->ob->restrictflag & flag) == 0) + for (gob= gr->gobject.first; gob; gob= gob->next) { + if ((gob->ob->restrictflag & flag) == 0) return 0; } @@ -231,8 +231,8 @@ static int group_select_flag(Group *gr) { GroupObject *gob; - for(gob= gr->gobject.first; gob; gob= gob->next) - if((gob->ob->flag & SELECT)) + for (gob= gr->gobject.first; gob; gob= gob->next) + if ((gob->ob->flag & SELECT)) return 1; return 0; @@ -244,23 +244,23 @@ void restrictbutton_gr_restrict_flag(void *poin, void *poin2, int flag) GroupObject *gob; Group *gr = (Group *)poin2; - if(group_restrict_flag(gr, flag)) { - for(gob= gr->gobject.first; gob; gob= gob->next) { + if (group_restrict_flag(gr, flag)) { + for (gob= gr->gobject.first; gob; gob= gob->next) { gob->ob->restrictflag &= ~flag; - if(flag==OB_RESTRICT_VIEW) - if(gob->ob->flag & SELECT) + if (flag==OB_RESTRICT_VIEW) + if (gob->ob->flag & SELECT) ED_base_object_select(object_in_scene(gob->ob, scene), BA_DESELECT); } } else { - for(gob= gr->gobject.first; gob; gob= gob->next) { + for (gob= gr->gobject.first; gob; gob= gob->next) { /* not in editmode */ - if(scene->obedit!=gob->ob) { + if (scene->obedit!=gob->ob) { gob->ob->restrictflag |= flag; - if(flag==OB_RESTRICT_VIEW) - if((gob->ob->flag & SELECT) == 0) + if (flag==OB_RESTRICT_VIEW) + if ((gob->ob->flag & SELECT) == 0) ED_base_object_select(object_in_scene(gob->ob, scene), BA_SELECT); } } @@ -292,10 +292,10 @@ static void namebutton_cb(bContext *C, void *tsep, char *oldname) TreeStore *ts= soops->treestore; TreeStoreElem *tselem= tsep; - if(ts && tselem) { + if (ts && tselem) { TreeElement *te= outliner_find_tse(soops, tselem); - if(tselem->type==0) { + if (tselem->type==0) { test_idbutton(tselem->id->name+2); // library.c, unique name and alpha sort switch(GS(tselem->id->name)) { @@ -335,7 +335,7 @@ static void namebutton_cb(bContext *C, void *tsep, char *oldname) case TSE_EBONE: { bArmature *arm= (bArmature *)tselem->id; - if(arm->edbo) { + if (arm->edbo) { EditBone *ebone= te->directdata; char newname[sizeof(ebone->name)]; @@ -407,11 +407,11 @@ static void outliner_draw_restrictbuts(uiBlock *block, Scene *scene, ARegion *ar Object *ob = NULL; Group *gr = NULL; - for(te= lb->first; te; te= te->next) { + for (te= lb->first; te; te= te->next) { tselem= TREESTORE(te); - if(te->ys+2*UI_UNIT_Y >= ar->v2d.cur.ymin && te->ys <= ar->v2d.cur.ymax) { + if (te->ys+2*UI_UNIT_Y >= ar->v2d.cur.ymin && te->ys <= ar->v2d.cur.ymax) { /* objects have toggle-able restriction flags */ - if(tselem->type==0 && te->idcode==ID_OB) { + if (tselem->type==0 && te->idcode==ID_OB) { PointerRNA ptr; ob = (Object *)tselem->id; @@ -436,7 +436,7 @@ static void outliner_draw_restrictbuts(uiBlock *block, Scene *scene, ARegion *ar uiBlockSetEmboss(block, UI_EMBOSS); } - if(tselem->type==0 && te->idcode==ID_GR){ + if (tselem->type==0 && te->idcode==ID_GR) { int restrict_bool; gr = (Group *)tselem->id; @@ -457,7 +457,7 @@ static void outliner_draw_restrictbuts(uiBlock *block, Scene *scene, ARegion *ar uiBlockSetEmboss(block, UI_EMBOSS); } /* scene render layers and passes have toggle-able flags too! */ - else if(tselem->type==TSE_R_LAYER) { + else if (tselem->type==TSE_R_LAYER) { uiBlockSetEmboss(block, UI_EMBOSSN); bt= uiDefIconButBitI(block, ICONTOGN, SCE_LAY_DISABLE, 0, ICON_CHECKBOX_HLT-1, @@ -466,7 +466,7 @@ static void outliner_draw_restrictbuts(uiBlock *block, Scene *scene, ARegion *ar uiBlockSetEmboss(block, UI_EMBOSS); } - else if(tselem->type==TSE_R_PASS) { + else if (tselem->type==TSE_R_PASS) { int *layflag= te->directdata; int passflag= 1<nr; @@ -478,14 +478,14 @@ static void outliner_draw_restrictbuts(uiBlock *block, Scene *scene, ARegion *ar uiButSetFunc(bt, restrictbutton_r_lay_cb, tselem->id, NULL); layflag++; /* is lay_xor */ - if(ELEM8(passflag, SCE_PASS_SPEC, SCE_PASS_SHADOW, SCE_PASS_AO, SCE_PASS_REFLECT, SCE_PASS_REFRACT, SCE_PASS_INDIRECT, SCE_PASS_EMIT, SCE_PASS_ENVIRONMENT)) + if (ELEM8(passflag, SCE_PASS_SPEC, SCE_PASS_SHADOW, SCE_PASS_AO, SCE_PASS_REFLECT, SCE_PASS_REFRACT, SCE_PASS_INDIRECT, SCE_PASS_EMIT, SCE_PASS_ENVIRONMENT)) bt= uiDefIconButBitI(block, TOG, passflag, 0, (*layflag & passflag)?ICON_DOT:ICON_BLANK1, (int)ar->v2d.cur.xmax-OL_TOG_RESTRICT_SELECTX, (int)te->ys, UI_UNIT_X-1, UI_UNIT_Y-1, layflag, 0, 0, 0, 0, "Exclude this Pass from Combined"); uiButSetFunc(bt, restrictbutton_r_lay_cb, tselem->id, NULL); uiBlockSetEmboss(block, UI_EMBOSS); } - else if(tselem->type==TSE_MODIFIER) { + else if (tselem->type==TSE_MODIFIER) { ModifierData *md= (ModifierData *)te->directdata; ob = (Object *)tselem->id; @@ -498,7 +498,7 @@ static void outliner_draw_restrictbuts(uiBlock *block, Scene *scene, ARegion *ar (int)ar->v2d.cur.xmax-OL_TOG_RESTRICT_RENDERX, (int)te->ys, UI_UNIT_X-1, UI_UNIT_Y-1, &(md->mode), 0, 0, 0, 0, "Restrict/Allow renderability"); uiButSetFunc(bt, restrictbutton_modifier_cb, scene, ob); } - else if(tselem->type==TSE_POSE_CHANNEL) { + else if (tselem->type==TSE_POSE_CHANNEL) { bPoseChannel *pchan= (bPoseChannel *)te->directdata; Bone *bone = pchan->bone; @@ -511,7 +511,7 @@ static void outliner_draw_restrictbuts(uiBlock *block, Scene *scene, ARegion *ar (int)ar->v2d.cur.xmax-OL_TOG_RESTRICT_SELECTX, (int)te->ys, UI_UNIT_X-1, UI_UNIT_Y-1, &(bone->flag), 0, 0, 0, 0, "Restrict/Allow selection in the 3D View"); uiButSetFunc(bt, restrictbutton_bone_cb, NULL, NULL); } - else if(tselem->type==TSE_EBONE) { + else if (tselem->type==TSE_EBONE) { EditBone *ebone= (EditBone *)te->directdata; uiBlockSetEmboss(block, UI_EMBOSSN); @@ -525,7 +525,7 @@ static void outliner_draw_restrictbuts(uiBlock *block, Scene *scene, ARegion *ar } } - if(TSELEM_OPEN(tselem,soops)) outliner_draw_restrictbuts(block, scene, ar, soops, &te->subtree); + if (TSELEM_OPEN(tselem,soops)) outliner_draw_restrictbuts(block, scene, ar, soops, &te->subtree); } } @@ -534,7 +534,7 @@ static void outliner_draw_rnacols(ARegion *ar, int sizex) View2D *v2d= &ar->v2d; float miny = v2d->cur.ymin-V2D_SCROLL_HEIGHT; - if(minytot.ymin) miny = v2d->tot.ymin; + if (minytot.ymin) miny = v2d->tot.ymin; UI_ThemeColorShadeAlpha(TH_BACK, -15, -200); @@ -559,17 +559,17 @@ static void outliner_draw_rnabuts(uiBlock *block, Scene *scene, ARegion *ar, Spa uiBlockSetEmboss(block, UI_EMBOSST); - for(te= lb->first; te; te= te->next) { + for (te= lb->first; te; te= te->next) { tselem= TREESTORE(te); - if(te->ys+2*UI_UNIT_Y >= ar->v2d.cur.ymin && te->ys <= ar->v2d.cur.ymax) { - if(tselem->type == TSE_RNA_PROPERTY) { + if (te->ys+2*UI_UNIT_Y >= ar->v2d.cur.ymin && te->ys <= ar->v2d.cur.ymax) { + if (tselem->type == TSE_RNA_PROPERTY) { ptr= &te->rnaptr; prop= te->directdata; - if(!(RNA_property_type(prop) == PROP_POINTER && (TSELEM_OPEN(tselem,soops))) ) + if (!(RNA_property_type(prop) == PROP_POINTER && (TSELEM_OPEN(tselem,soops))) ) uiDefAutoButR(block, ptr, prop, -1, "", ICON_NONE, sizex, (int)te->ys, OL_RNA_COL_SIZEX, UI_UNIT_Y-1); } - else if(tselem->type == TSE_RNA_ARRAY_ELEM) { + else if (tselem->type == TSE_RNA_ARRAY_ELEM) { ptr= &te->rnaptr; prop= te->directdata; @@ -577,7 +577,7 @@ static void outliner_draw_rnabuts(uiBlock *block, Scene *scene, ARegion *ar, Spa } } - if(TSELEM_OPEN(tselem,soops)) outliner_draw_rnabuts(block, scene, ar, soops, sizex, &te->subtree); + if (TSELEM_OPEN(tselem,soops)) outliner_draw_rnabuts(block, scene, ar, soops, sizex, &te->subtree); } } @@ -586,7 +586,7 @@ static void operator_call_cb(struct bContext *UNUSED(C), void *arg_kmi, void *ar wmOperatorType *ot= arg2; wmKeyMapItem *kmi = arg_kmi; - if(ot) + if (ot) BLI_strncpy(kmi->idname, ot->idname, OP_MAX_TYPENAME); } @@ -594,16 +594,16 @@ static void operator_search_cb(const struct bContext *UNUSED(C), void *UNUSED(ar { GHashIterator *iter= WM_operatortype_iter(); - for( ; !BLI_ghashIterator_isDone(iter); BLI_ghashIterator_step(iter)) { + for ( ; !BLI_ghashIterator_isDone(iter); BLI_ghashIterator_step(iter)) { wmOperatorType *ot= BLI_ghashIterator_getValue(iter); - if(BLI_strcasestr(ot->idname, str)) { + if (BLI_strcasestr(ot->idname, str)) { char name[OP_MAX_TYPENAME]; /* display name for menu */ WM_operator_py_idname(name, ot->idname); - if(0==uiSearchItemAdd(items, name, ot, 0)) + if (0==uiSearchItemAdd(items, name, ot, 0)) break; } } @@ -654,9 +654,9 @@ static uiBlock *operator_search_menu(bContext *C, ARegion *ar, void *arg_kmi) static short keymap_menu_type(short type) { - if(ISKEYBOARD(type)) return OL_KM_KEYBOARD; - if(ISTWEAK(type)) return OL_KM_TWEAK; - if(ISMOUSE(type)) return OL_KM_MOUSE; + if (ISKEYBOARD(type)) return OL_KM_KEYBOARD; + if (ISTWEAK(type)) return OL_KM_TWEAK; + if (ISMOUSE(type)) return OL_KM_MOUSE; // return OL_KM_SPECIALS; return 0; } @@ -738,7 +738,7 @@ static void keymap_type_cb(bContext *C, void *kmi_v, void *UNUSED(arg_v)) wmKeyMapItem *kmi = kmi_v; short maptype= keymap_menu_type(kmi->type); - if(maptype!=kmi->maptype) { + if (maptype!=kmi->maptype) { switch(kmi->maptype) { case OL_KM_KEYBOARD: kmi->type= AKEY; @@ -767,9 +767,9 @@ static void outliner_draw_keymapbuts(uiBlock *block, ARegion *ar, SpaceOops *soo uiBlockSetEmboss(block, UI_EMBOSST); - for(te= lb->first; te; te= te->next) { + for (te= lb->first; te; te= te->next) { tselem= TREESTORE(te); - if(te->ys+2*UI_UNIT_Y >= ar->v2d.cur.ymin && te->ys <= ar->v2d.cur.ymax) { + if (te->ys+2*UI_UNIT_Y >= ar->v2d.cur.ymin && te->ys <= ar->v2d.cur.ymax) { uiBut *but; const char *str; int xstart= 240; @@ -777,11 +777,11 @@ static void outliner_draw_keymapbuts(uiBlock *block, ARegion *ar, SpaceOops *soo int butw2= 90; /* event type, menus */ int butw3= 43; /* modifiers */ - if(tselem->type == TSE_KEYMAP_ITEM) { + if (tselem->type == TSE_KEYMAP_ITEM) { wmKeyMapItem *kmi = te->directdata; /* modal map? */ - if(kmi->propvalue); + if (kmi->propvalue); else { uiDefBlockBut(block, operator_search_menu, kmi, "", xstart, (int)te->ys+1, butw1, UI_UNIT_Y-1, "Assign new Operator"); } @@ -826,7 +826,7 @@ static void outliner_draw_keymapbuts(uiBlock *block, ARegion *ar, SpaceOops *soo xstart+= butw3+5; /* rna property */ - if(kmi->ptr && kmi->ptr->data) { + if (kmi->ptr && kmi->ptr->data) { uiDefBut(block, LABEL, 0, "(RNA property)", xstart, (int)te->ys+1, butw2, UI_UNIT_Y-1, &kmi->oskey, 0, 0, 0, 0, ""); xstart+= butw2; } @@ -834,7 +834,7 @@ static void outliner_draw_keymapbuts(uiBlock *block, ARegion *ar, SpaceOops *soo } } - if(TSELEM_OPEN(tselem,soops)) outliner_draw_keymapbuts(block, ar, soops, &te->subtree); + if (TSELEM_OPEN(tselem,soops)) outliner_draw_keymapbuts(block, ar, soops, &te->subtree); } } @@ -846,38 +846,38 @@ static void outliner_buttons(const bContext *C, uiBlock *block, ARegion *ar, Spa TreeStoreElem *tselem; int spx, dx, len; - for(te= lb->first; te; te= te->next) { + for (te= lb->first; te; te= te->next) { tselem= TREESTORE(te); - if(te->ys+2*UI_UNIT_Y >= ar->v2d.cur.ymin && te->ys <= ar->v2d.cur.ymax) { + if (te->ys+2*UI_UNIT_Y >= ar->v2d.cur.ymin && te->ys <= ar->v2d.cur.ymax) { - if(tselem->flag & TSE_TEXTBUT) { + if (tselem->flag & TSE_TEXTBUT) { /* If we add support to rename Sequence. * need change this. */ - if(tselem->type == TSE_POSE_BASE) continue; // prevent crash when trying to rename 'pose' entry of armature + if (tselem->type == TSE_POSE_BASE) continue; // prevent crash when trying to rename 'pose' entry of armature - if(tselem->type==TSE_EBONE) len = sizeof(((EditBone*) 0)->name); + 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 if (tselem->id && GS(tselem->id->name)==ID_LI) len = sizeof(((Library*) 0)->name); else len= MAX_ID_NAME-2; dx= (int)UI_GetStringWidth(te->name); - if(dx<100) dx= 100; + if (dx<100) dx= 100; spx=te->xs+2*UI_UNIT_X-4; - if(spx+dx+10>ar->v2d.cur.xmax) dx = ar->v2d.cur.xmax-spx-10; + if (spx+dx+10>ar->v2d.cur.xmax) dx = ar->v2d.cur.xmax-spx-10; bt= uiDefBut(block, TEX, OL_NAMEBUTTON, "", spx, (int)te->ys, dx+10, UI_UNIT_Y-1, (void *)te->name, 1.0, (float)len, 0, 0, ""); uiButSetRenameFunc(bt, namebutton_cb, tselem); /* returns false if button got removed */ - if( 0 == uiButActiveOnly(C, block, bt) ) + if ( 0 == uiButActiveOnly(C, block, bt) ) tselem->flag &= ~TSE_TEXTBUT; } } - if(TSELEM_OPEN(tselem,soops)) outliner_buttons(C, block, ar, soops, &te->subtree); + if (TSELEM_OPEN(tselem,soops)) outliner_buttons(C, block, ar, soops, &te->subtree); } } @@ -895,16 +895,17 @@ struct DrawIconArg { static void tselem_draw_icon_uibut(struct DrawIconArg *arg, int icon) { /* restrict column clip... it has been coded by simply overdrawing, doesnt work for buttons */ - if(arg->x >= arg->xmax) { + if (arg->x >= arg->xmax) { glEnable(GL_BLEND); UI_icon_draw_aspect(arg->x, arg->y, icon, 1.0f, arg->alpha); glDisable(GL_BLEND); - } else { + } + else { /* XXX investigate: button placement of icons is way different than UI_icon_draw? */ float ufac= UI_UNIT_X/20.0f; uiBut *but = uiDefIconBut(arg->block, LABEL, 0, icon, arg->x-3.0f*ufac, arg->y, UI_UNIT_X-4.0f*ufac, UI_UNIT_Y-4.0f*ufac, NULL, 0.0, 0.0, 1.0, arg->alpha, (arg->id && arg->id->lib) ? arg->id->lib->name : ""); - if(arg->id) + if (arg->id) uiButSetDragID(but, arg->id); } @@ -922,7 +923,7 @@ static void tselem_draw_icon(uiBlock *block, int xmax, float x, float y, TreeSto arg.y= y; arg.alpha= alpha; - if(tselem->type) { + if (tselem->type) { switch( tselem->type) { case TSE_ANIM_DATA: UI_icon_draw(x, y, ICON_ANIM_DATA); break; // xxx @@ -1052,15 +1053,15 @@ static void tselem_draw_icon(uiBlock *block, int xmax, float x, float y, TreeSto case TSE_POSEGRP_BASE: UI_icon_draw(x, y, ICON_VERTEXSEL); break; case TSE_SEQUENCE: - if(te->idcode==SEQ_MOVIE) + if (te->idcode==SEQ_MOVIE) UI_icon_draw(x, y, ICON_SEQUENCE); - else if(te->idcode==SEQ_META) + else if (te->idcode==SEQ_META) UI_icon_draw(x, y, ICON_DOT); - else if(te->idcode==SEQ_SCENE) + else if (te->idcode==SEQ_SCENE) UI_icon_draw(x, y, ICON_SCENE); - else if(te->idcode==SEQ_SOUND) + else if (te->idcode==SEQ_SOUND) UI_icon_draw(x, y, ICON_SOUND); - else if(te->idcode==SEQ_IMAGE) + else if (te->idcode==SEQ_IMAGE) UI_icon_draw(x, y, ICON_IMAGE_COL); else UI_icon_draw(x, y, ICON_PARTICLES); @@ -1072,7 +1073,7 @@ static void tselem_draw_icon(uiBlock *block, int xmax, float x, float y, TreeSto UI_icon_draw(x, y, ICON_OBJECT_DATA); break; case TSE_RNA_STRUCT: - if(RNA_struct_is_ID(te->rnaptr.type)) { + if (RNA_struct_is_ID(te->rnaptr.type)) { arg.id= (ID *)te->rnaptr.data; tselem_draw_icon_uibut(&arg, RNA_struct_ui_icon(te->rnaptr.type)); } @@ -1180,26 +1181,26 @@ static void outliner_draw_iconrow(bContext *C, uiBlock *block, Scene *scene, Spa TreeStoreElem *tselem; int active; - for(te= lb->first; te; te= te->next) { + for (te= lb->first; te; te= te->next) { /* exit drawing early */ - if((*offsx) - UI_UNIT_X > xmax) + if ((*offsx) - UI_UNIT_X > xmax) break; tselem= TREESTORE(te); /* object hierarchy always, further constrained on level */ - if(level<1 || (tselem->type==0 && te->idcode==ID_OB)) { + if (level<1 || (tselem->type==0 && te->idcode==ID_OB)) { /* active blocks get white circle */ - if(tselem->type==0) { - if(te->idcode==ID_OB) active= (OBACT==(Object *)tselem->id); - else if(scene->obedit && scene->obedit->data==tselem->id) active= 1; // XXX use context? + if (tselem->type==0) { + if (te->idcode==ID_OB) active= (OBACT==(Object *)tselem->id); + else if (scene->obedit && scene->obedit->data==tselem->id) active= 1; // XXX use context? else active= tree_element_active(C, scene, soops, te, 0); } else active= tree_element_type_active(NULL, scene, soops, te, tselem, 0); - if(active) { + if (active) { float ufac= UI_UNIT_X/20.0f; uiSetRoundBox(UI_CNR_ALL); @@ -1218,7 +1219,7 @@ static void outliner_draw_iconrow(bContext *C, uiBlock *block, Scene *scene, Spa } /* this tree element always has same amount of branches, so don't draw */ - if(tselem->type!=TSE_R_LAYER) + if (tselem->type!=TSE_R_LAYER) outliner_draw_iconrow(C, block, scene, soops, &te->subtree, level+1, xmax, offsx, ys); } @@ -1233,7 +1234,7 @@ static void outliner_set_coord_tree_element(SpaceOops *soops, TreeElement *te, i te->xs= (float)startx; te->ys= (float)(*starty); - for(ten= te->subtree.first; ten; ten= ten->next) { + for (ten= te->subtree.first; ten; ten= ten->next) { outliner_set_coord_tree_element(soops, ten, startx+UI_UNIT_X, starty); } } @@ -1248,11 +1249,11 @@ static void outliner_draw_tree_element(bContext *C, uiBlock *block, Scene *scene tselem= TREESTORE(te); - if(*starty+2*UI_UNIT_Y >= ar->v2d.cur.ymin && *starty<= ar->v2d.cur.ymax) { + if (*starty+2*UI_UNIT_Y >= ar->v2d.cur.ymin && *starty<= ar->v2d.cur.ymax) { int xmax= ar->v2d.cur.xmax; /* 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; glEnable(GL_BLEND); @@ -1272,17 +1273,17 @@ static void outliner_draw_tree_element(bContext *C, uiBlock *block, Scene *scene } /* colors for active/selected data */ - if(tselem->type==0) { - if(te->idcode==ID_SCE) { - if(tselem->id == (ID *)scene) { + if (tselem->type==0) { + if (te->idcode==ID_SCE) { + if (tselem->id == (ID *)scene) { glColor4ub(255, 255, 255, 100); active= 2; } } - else if(te->idcode==ID_GR) { + else if (te->idcode==ID_GR) { Group *gr = (Group *)tselem->id; - if(group_select_flag(gr)) { + if (group_select_flag(gr)) { char col[4]; UI_GetThemeColorType4ubv(TH_SELECT, SPACE_VIEW3D, col); col[3]= 100; @@ -1291,24 +1292,24 @@ static void outliner_draw_tree_element(bContext *C, uiBlock *block, Scene *scene active= 2; } } - else if(te->idcode==ID_OB) { + else if (te->idcode==ID_OB) { Object *ob= (Object *)tselem->id; - if(ob==OBACT || (ob->flag & SELECT)) { + if (ob==OBACT || (ob->flag & SELECT)) { char col[4]= {0, 0, 0, 0}; /* outliner active ob: always white text, circle color now similar to view3d */ active= 2; /* means it draws a color circle */ - if(ob==OBACT) { - if(ob->flag & SELECT) { + if (ob==OBACT) { + if (ob->flag & SELECT) { UI_GetThemeColorType4ubv(TH_ACTIVE, SPACE_VIEW3D, col); col[3]= 100; } active= 1; /* means it draws white text */ } - else if(ob->flag & SELECT) { + else if (ob->flag & SELECT) { UI_GetThemeColorType4ubv(TH_SELECT, SPACE_VIEW3D, col); col[3]= 100; } @@ -1317,24 +1318,24 @@ static void outliner_draw_tree_element(bContext *C, uiBlock *block, Scene *scene } } - else if(scene->obedit && scene->obedit->data==tselem->id) { + else if (scene->obedit && scene->obedit->data==tselem->id) { glColor4ub(255, 255, 255, 100); active= 2; } else { - if(tree_element_active(C, scene, soops, te, 0)) { + if (tree_element_active(C, scene, soops, te, 0)) { glColor4ub(220, 220, 255, 100); active= 2; } } } else { - if( tree_element_type_active(NULL, scene, soops, te, tselem, 0) ) active= 2; + if ( tree_element_type_active(NULL, scene, soops, te, tselem, 0) ) active= 2; glColor4ub(220, 220, 255, 100); } /* active circle */ - if(active) { + if (active) { uiSetRoundBox(UI_CNR_ALL); uiRoundBox( (float)startx+UI_UNIT_Y-1.5f*ufac, (float)*starty+2.0f*ufac, (float)startx+2.0f*UI_UNIT_Y-4.0f*ufac, (float)*starty+UI_UNIT_Y-1.0f*ufac, UI_UNIT_Y/2.0f-2.0f*ufac); glEnable(GL_BLEND); /* roundbox disables it */ @@ -1343,15 +1344,15 @@ static void outliner_draw_tree_element(bContext *C, uiBlock *block, Scene *scene } /* open/close icon, only when sublevels, except for scene */ - if(te->subtree.first || (tselem->type==0 && te->idcode==ID_SCE) || (te->flag & TE_LAZY_CLOSED)) { + if (te->subtree.first || (tselem->type==0 && te->idcode==ID_SCE) || (te->flag & TE_LAZY_CLOSED)) { int icon_x; - if(tselem->type==0 && ELEM(te->idcode, ID_OB, ID_SCE)) + if (tselem->type==0 && ELEM(te->idcode, ID_OB, ID_SCE)) icon_x = startx; else icon_x = startx+5*ufac; // icons a bit higher - if(TSELEM_OPEN(tselem,soops)) + if (TSELEM_OPEN(tselem,soops)) UI_icon_draw((float)icon_x, (float)*starty+2*ufac, ICON_DISCLOSURE_TRI_DOWN); else UI_icon_draw((float)icon_x, (float)*starty+2*ufac, ICON_DISCLOSURE_TRI_RIGHT); @@ -1360,7 +1361,7 @@ static void outliner_draw_tree_element(bContext *C, uiBlock *block, Scene *scene /* datatype icon */ - if(!(ELEM(tselem->type, TSE_RNA_PROPERTY, TSE_RNA_ARRAY_ELEM))) { + if (!(ELEM(tselem->type, TSE_RNA_PROPERTY, TSE_RNA_ARRAY_ELEM))) { // icons a bit higher tselem_draw_icon(block, xmax, (float)startx+offsx - 0.5f*ufac, (float)*starty+2.0f*ufac, tselem, te, 1.0f); @@ -1369,9 +1370,9 @@ static void outliner_draw_tree_element(bContext *C, uiBlock *block, Scene *scene else offsx+= 2*ufac; - if(tselem->type==0 && tselem->id->lib) { + if (tselem->type==0 && tselem->id->lib) { glPixelTransferf(GL_ALPHA_SCALE, 0.5f); - if(tselem->id->flag & LIB_INDIRECT) + if (tselem->id->flag & LIB_INDIRECT) UI_icon_draw((float)startx+offsx, (float)*starty+2*ufac, ICON_LIBRARY_DATA_INDIRECT); else UI_icon_draw((float)startx+offsx, (float)*starty+2*ufac, ICON_LIBRARY_DATA_DIRECT); @@ -1381,8 +1382,8 @@ static void outliner_draw_tree_element(bContext *C, uiBlock *block, Scene *scene glDisable(GL_BLEND); /* name */ - if(active==1) UI_ThemeColor(TH_TEXT_HI); - else if(ELEM(tselem->type, TSE_RNA_PROPERTY, TSE_RNA_ARRAY_ELEM)) UI_ThemeColorBlend(TH_BACK, TH_TEXT, 0.75f); + if (active==1) UI_ThemeColor(TH_TEXT_HI); + else if (ELEM(tselem->type, TSE_RNA_PROPERTY, TSE_RNA_ARRAY_ELEM)) UI_ThemeColorBlend(TH_BACK, TH_TEXT, 0.75f); else UI_ThemeColor(TH_TEXT); UI_DrawString(startx+offsx, *starty+5*ufac, te->name); @@ -1390,10 +1391,10 @@ static void outliner_draw_tree_element(bContext *C, uiBlock *block, Scene *scene offsx+= (int)(UI_UNIT_X + UI_GetStringWidth(te->name)); /* closed item, we draw the icons, not when it's a scene, or master-server list though */ - if(!TSELEM_OPEN(tselem,soops)) { - if(te->subtree.first) { - if(tselem->type==0 && te->idcode==ID_SCE); - else if(tselem->type!=TSE_R_LAYER) { /* this tree element always has same amount of branches, so don't draw */ + if (!TSELEM_OPEN(tselem,soops)) { + if (te->subtree.first) { + if (tselem->type==0 && te->idcode==ID_SCE); + else if (tselem->type!=TSE_R_LAYER) { /* this tree element always has same amount of branches, so don't draw */ int tempx= startx+offsx; // divider @@ -1416,14 +1417,14 @@ static void outliner_draw_tree_element(bContext *C, uiBlock *block, Scene *scene te->ys= (float)*starty; te->xend= startx+offsx; - if(TSELEM_OPEN(tselem,soops)) { + if (TSELEM_OPEN(tselem,soops)) { *starty-= UI_UNIT_Y; - for(ten= te->subtree.first; ten; ten= ten->next) + for (ten= te->subtree.first; ten; ten= ten->next) outliner_draw_tree_element(C, block, scene, ar, soops, ten, startx+UI_UNIT_X, starty); } else { - for(ten= te->subtree.first; ten; ten= ten->next) + for (ten= te->subtree.first; ten; ten= ten->next) outliner_set_coord_tree_element(soops, te, startx, starty); *starty-= UI_UNIT_Y; @@ -1436,28 +1437,28 @@ static void outliner_draw_hierarchy(SpaceOops *soops, ListBase *lb, int startx, TreeStoreElem *tselem; int y1, y2; - if(lb->first==NULL) return; + if (lb->first==NULL) return; y1=y2= *starty; /* for vertical lines between objects */ - for(te=lb->first; te; te= te->next) { + for (te=lb->first; te; te= te->next) { y2= *starty; tselem= TREESTORE(te); /* horizontal line? */ - if(tselem->type==0 && (te->idcode==ID_OB || te->idcode==ID_SCE)) + if (tselem->type==0 && (te->idcode==ID_OB || te->idcode==ID_SCE)) glRecti(startx, *starty, startx+UI_UNIT_X, *starty-1); *starty-= UI_UNIT_Y; - if(TSELEM_OPEN(tselem,soops)) + if (TSELEM_OPEN(tselem,soops)) outliner_draw_hierarchy(soops, &te->subtree, startx+UI_UNIT_X, starty); } /* vertical line */ te= lb->last; - if(te->parent || lb->first!=lb->last) { + if (te->parent || lb->first!=lb->last) { tselem= TREESTORE(te); - if(tselem->type==0 && te->idcode==ID_OB) { + if (tselem->type==0 && te->idcode==ID_OB) { glRecti(startx, y1+UI_UNIT_Y, startx+1, y2); } @@ -1469,18 +1470,18 @@ static void outliner_draw_struct_marks(ARegion *ar, SpaceOops *soops, ListBase * TreeElement *te; TreeStoreElem *tselem; - for(te= lb->first; te; te= te->next) { + for (te= lb->first; te; te= te->next) { tselem= TREESTORE(te); /* selection status */ - if(TSELEM_OPEN(tselem,soops)) - if(tselem->type == TSE_RNA_STRUCT) + if (TSELEM_OPEN(tselem,soops)) + if (tselem->type == TSE_RNA_STRUCT) glRecti(0, *starty+1, (int)ar->v2d.cur.xmax+V2D_SCROLL_WIDTH, *starty+UI_UNIT_Y-1); *starty-= UI_UNIT_Y; - if(TSELEM_OPEN(tselem,soops)) { + if (TSELEM_OPEN(tselem,soops)) { outliner_draw_struct_marks(ar, soops, &te->subtree, starty); - if(tselem->type == TSE_RNA_STRUCT) + if (tselem->type == TSE_RNA_STRUCT) fdrawline(0, (float)*starty+UI_UNIT_Y, ar->v2d.cur.xmax+V2D_SCROLL_WIDTH, (float)*starty+UI_UNIT_Y); } } @@ -1491,15 +1492,15 @@ static void outliner_draw_selection(ARegion *ar, SpaceOops *soops, ListBase *lb, TreeElement *te; TreeStoreElem *tselem; - for(te= lb->first; te; te= te->next) { + for (te= lb->first; te; te= te->next) { tselem= TREESTORE(te); /* selection status */ - if(tselem->flag & TSE_SELECTED) { + if (tselem->flag & TSE_SELECTED) { glRecti(0, *starty+1, (int)ar->v2d.cur.xmax, *starty+UI_UNIT_Y-1); } *starty-= UI_UNIT_Y; - if(TSELEM_OPEN(tselem,soops)) outliner_draw_selection(ar, soops, &te->subtree, starty); + if (TSELEM_OPEN(tselem,soops)) outliner_draw_selection(ar, soops, &te->subtree, starty); } } @@ -1535,7 +1536,7 @@ static void outliner_draw_tree(bContext *C, uiBlock *block, Scene *scene, ARegio // items themselves starty= (int)ar->v2d.tot.ymax-UI_UNIT_Y-OL_Y_OFFSET; startx= 0; - for(te= soops->tree.first; te; te= te->next) { + for (te= soops->tree.first; te; te= te->next) { outliner_draw_tree_element(C, block, scene, ar, soops, te, startx, &starty); } } @@ -1660,12 +1661,12 @@ void draw_outliner(const bContext *C) block= uiBeginBlock(C, ar, __func__, UI_EMBOSS); outliner_draw_tree((bContext *)C, block, scene, ar, soops); - if(ELEM(soops->outlinevis, SO_DATABLOCKS, SO_USERDEF)) { + if (ELEM(soops->outlinevis, SO_DATABLOCKS, SO_USERDEF)) { /* draw rna buttons */ outliner_draw_rnacols(ar, sizex_rna); outliner_draw_rnabuts(block, scene, ar, soops, sizex_rna, &soops->tree); } - else if(soops->outlinevis == SO_KEYMAP) { + else if (soops->outlinevis == SO_KEYMAP) { outliner_draw_keymapbuts(block, ar, soops, &soops->tree); } else if (!(soops->flag & SO_HIDE_RESTRICTCOLS)) { diff --git a/source/blender/editors/space_outliner/outliner_edit.c b/source/blender/editors/space_outliner/outliner_edit.c index cdd566f6da9..c59cd626a93 100644 --- a/source/blender/editors/space_outliner/outliner_edit.c +++ b/source/blender/editors/space_outliner/outliner_edit.c @@ -158,24 +158,24 @@ static void outliner_open_reveal(SpaceOops *soops, ListBase *lb, TreeElement *te static int do_outliner_item_openclose(bContext *C, SpaceOops *soops, TreeElement *te, int all, const float mval[2]) { - if(mval[1]>te->ys && mval[1]ys+UI_UNIT_Y) { + if (mval[1]>te->ys && mval[1]ys+UI_UNIT_Y) { TreeStoreElem *tselem= TREESTORE(te); /* all below close/open? */ - if(all) { + if (all) { tselem->flag &= ~TSE_CLOSED; outliner_set_flag(soops, &te->subtree, TSE_CLOSED, !outliner_has_one_flag(soops, &te->subtree, TSE_CLOSED, 1)); } else { - if(tselem->flag & TSE_CLOSED) 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)) + for (te= te->subtree.first; te; te= te->next) { + if (do_outliner_item_openclose(C, soops, te, all, mval)) return 1; } return 0; @@ -193,8 +193,8 @@ static int outliner_item_openclose(bContext *C, wmOperator *op, wmEvent *event) UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], fmval, fmval+1); - for(te= soops->tree.first; te; te= te->next) { - if(do_outliner_item_openclose(C, soops, te, all, fmval)) + for (te= soops->tree.first; te; te= te->next) { + if (do_outliner_item_openclose(C, soops, te, all, fmval)) break; } @@ -221,21 +221,21 @@ void OUTLINER_OT_item_openclose(wmOperatorType *ot) static void do_item_rename(ARegion *ar, TreeElement *te, TreeStoreElem *tselem, ReportList *reports) { /* can't rename rna datablocks entries */ - if(ELEM3(tselem->type, TSE_RNA_STRUCT, TSE_RNA_PROPERTY, TSE_RNA_ARRAY_ELEM)) { + if (ELEM3(tselem->type, TSE_RNA_STRUCT, TSE_RNA_PROPERTY, TSE_RNA_ARRAY_ELEM)) { /* do nothing */; } - else if(ELEM10(tselem->type, TSE_ANIM_DATA, TSE_NLA, TSE_DEFGROUP_BASE, TSE_CONSTRAINT_BASE, TSE_MODIFIER_BASE, + else if (ELEM10(tselem->type, TSE_ANIM_DATA, TSE_NLA, TSE_DEFGROUP_BASE, TSE_CONSTRAINT_BASE, TSE_MODIFIER_BASE, TSE_SCRIPT_BASE, TSE_POSE_BASE, TSE_POSEGRP_BASE, TSE_R_LAYER_BASE, TSE_R_PASS)) { BKE_report(reports, RPT_WARNING, "Cannot edit builtin name"); } - else if(ELEM3(tselem->type, TSE_SEQUENCE, TSE_SEQ_STRIP, TSE_SEQUENCE_DUP)) { + else if (ELEM3(tselem->type, TSE_SEQUENCE, TSE_SEQ_STRIP, TSE_SEQUENCE_DUP)) { BKE_report(reports, RPT_WARNING, "Cannot edit sequence name"); } - else if(tselem->id->lib) { + else if (tselem->id->lib) { // XXX error_libdata(); } - else if(te->idcode == ID_LI && te->parent) { + else if (te->idcode == ID_LI && te->parent) { BKE_report(reports, RPT_WARNING, "Cannot edit the path of an indirectly linked library"); } else { @@ -255,19 +255,19 @@ static int do_outliner_item_rename(bContext *C, ARegion *ar, SpaceOops *soops, T { ReportList *reports= CTX_wm_reports(C); // XXX - if(mval[1]>te->ys && mval[1]ys+UI_UNIT_Y) { + if (mval[1]>te->ys && mval[1]ys+UI_UNIT_Y) { TreeStoreElem *tselem= TREESTORE(te); /* name and first icon */ - if(mval[0]>te->xs+UI_UNIT_X && mval[0]xend) { + if (mval[0]>te->xs+UI_UNIT_X && mval[0]xend) { do_item_rename(ar, te, tselem, reports); } return 1; } - for(te= te->subtree.first; te; te= te->next) { - if(do_outliner_item_rename(C, ar, soops, te, mval)) return 1; + for (te= te->subtree.first; te; te= te->next) { + if (do_outliner_item_rename(C, ar, soops, te, mval)) return 1; } return 0; } @@ -281,8 +281,8 @@ static int outliner_item_rename(bContext *C, wmOperator *UNUSED(op), wmEvent *ev UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], fmval, fmval+1); - for(te= soops->tree.first; te; te= te->next) { - if(do_outliner_item_rename(C, ar, soops, te, fmval)) break; + for (te= soops->tree.first; te; te= te->next) { + if (do_outliner_item_rename(C, ar, soops, te, fmval)) break; } return OPERATOR_FINISHED; @@ -313,10 +313,10 @@ static int outliner_count_levels(SpaceOops *soops, ListBase *lb, int curlevel) TreeElement *te; int level=curlevel, lev; - for(te= lb->first; te; te= te->next) { + for (te= lb->first; te; te= te->next) { lev= outliner_count_levels(soops, &te->subtree, curlevel+1); - if(lev>level) level= lev; + if (lev>level) level= lev; } return level; } @@ -327,12 +327,12 @@ int outliner_has_one_flag(SpaceOops *soops, ListBase *lb, short flag, short curl TreeStoreElem *tselem; int level; - for(te= lb->first; te; te= te->next) { + 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_has_one_flag(soops, &te->subtree, flag, curlevel+1); - if(level) return level; + if (level) return level; } return 0; } @@ -342,9 +342,9 @@ void outliner_set_flag(SpaceOops *soops, ListBase *lb, short flag, short set) TreeElement *te; TreeStoreElem *tselem; - for(te= lb->first; te; te= te->next) { + for (te= lb->first; te; te= te->next) { tselem= TREESTORE(te); - if(set==0) tselem->flag &= ~flag; + if (set==0) tselem->flag &= ~flag; else tselem->flag |= flag; outliner_set_flag(soops, &te->subtree, flag, set); } @@ -385,10 +385,10 @@ void object_toggle_visibility_cb(bContext *C, Scene *scene, TreeElement *te, Tre Object *ob = (Object *)tselem->id; /* add check for edit mode */ - if(!common_restrict_check(C, ob)) return; + if (!common_restrict_check(C, ob)) return; - if(base || (base= object_in_scene(ob, scene))) { - if((base->object->restrictflag ^= OB_RESTRICT_VIEW)) { + if (base || (base= object_in_scene(ob, scene))) { + if ((base->object->restrictflag ^= OB_RESTRICT_VIEW)) { ED_base_object_select(base, BA_DESELECT); } } @@ -434,8 +434,8 @@ void object_toggle_selectability_cb(bContext *UNUSED(C), Scene *scene, TreeEleme { Base *base= (Base *)te->directdata; - if(base==NULL) base= object_in_scene((Object *)tselem->id, scene); - if(base) { + if (base==NULL) base= object_in_scene((Object *)tselem->id, scene); + if (base) { base->object->restrictflag^=OB_RESTRICT_SELECT; } } @@ -480,8 +480,8 @@ void object_toggle_renderability_cb(bContext *UNUSED(C), Scene *scene, TreeEleme { Base *base= (Base *)te->directdata; - if(base==NULL) base= object_in_scene((Object *)tselem->id, scene); - if(base) { + if (base==NULL) base= object_in_scene((Object *)tselem->id, scene); + if (base) { base->object->restrictflag^=OB_RESTRICT_RENDER; } } @@ -648,10 +648,10 @@ static int outliner_scroll_page_exec(bContext *C, wmOperator *op) int dy= ar->v2d.mask.ymax - ar->v2d.mask.ymin; 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; @@ -691,9 +691,9 @@ static void outliner_set_coordinates_element(SpaceOops *soops, TreeElement *te, te->ys= (float)(*starty); *starty-= UI_UNIT_Y; - if(TSELEM_OPEN(tselem,soops)) { + if (TSELEM_OPEN(tselem,soops)) { TreeElement *ten; - for(ten= te->subtree.first; ten; ten= ten->next) { + for (ten= te->subtree.first; ten; ten= ten->next) { outliner_set_coordinates_element(soops, ten, startx+UI_UNIT_X, starty); } } @@ -707,7 +707,7 @@ static void outliner_set_coordinates(ARegion *ar, SpaceOops *soops) int starty= (int)(ar->v2d.tot.ymax)-UI_UNIT_Y; int startx= 0; - for(te= soops->tree.first; te; te= te->next) { + for (te= soops->tree.first; te; te= te->next) { outliner_set_coordinates_element(soops, te, startx, &starty); } } @@ -720,7 +720,7 @@ static TreeElement *outliner_find_named(SpaceOops *soops, ListBase *lb, char *na for (te= lb->first; te; te= te->next) { int found = outliner_filter_has_name(te, name, flags); - if(found) { + if (found) { /* name is right, but is element the previous one? */ if (prev) { if ((te != prev) && (*prevFound)) @@ -734,7 +734,7 @@ static TreeElement *outliner_find_named(SpaceOops *soops, ListBase *lb, char *na } tes= outliner_find_named(soops, &te->subtree, name, flags, prev, prevFound); - if(tes) return tes; + if (tes) return tes; } /* nothing valid found */ @@ -781,7 +781,7 @@ static void outliner_find_panel(Scene *UNUSED(scene), ARegion *ar, SpaceOops *so tselem= TREESTORE(te); if (tselem) { /* expand branches so that it will be visible, we need to get correct coordinates */ - if( outliner_open_back(soops, te)) + if ( outliner_open_back(soops, te)) outliner_set_coordinates(ar, soops); /* deselect all visible, and select found element */ @@ -790,7 +790,7 @@ static void outliner_find_panel(Scene *UNUSED(scene), ARegion *ar, SpaceOops *so /* make te->ys center of view */ ytop= (int)(te->ys + (ar->v2d.mask.ymax-ar->v2d.mask.ymin)/2); - if(ytop>0) ytop= 0; + if (ytop>0) ytop= 0; ar->v2d.cur.ymax = (float)ytop; ar->v2d.cur.ymin = (float)(ytop-(ar->v2d.mask.ymax-ar->v2d.mask.ymin)); @@ -824,14 +824,14 @@ static void outliner_openclose_level(SpaceOops *soops, ListBase *lb, int curleve TreeElement *te; TreeStoreElem *tselem; - for(te= lb->first; te; te= te->next) { + for (te= lb->first; te; te= te->next) { tselem= TREESTORE(te); - if(open) { - if(curlevel<=level) tselem->flag &= ~TSE_CLOSED; + if (open) { + 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(soops, &te->subtree, curlevel+1, level, open); @@ -846,12 +846,12 @@ static int outliner_one_level_exec(bContext *C, wmOperator *op) int level; level= outliner_has_one_flag(soops, &soops->tree, TSE_CLOSED, 1); - if(add==1) { - if(level) outliner_openclose_level(soops, &soops->tree, 1, level, 1); + if (add==1) { + if (level) outliner_openclose_level(soops, &soops->tree, 1, level, 1); } else { - if(level==0) level= outliner_count_levels(soops, &soops->tree, 0); - if(level) outliner_openclose_level(soops, &soops->tree, 1, level-1, 0); + if (level==0) level= outliner_count_levels(soops, &soops->tree, 0); + if (level) outliner_openclose_level(soops, &soops->tree, 1, level-1, 0); } ED_region_tag_redraw(ar); @@ -884,10 +884,10 @@ static int subtree_has_objects(SpaceOops *soops, ListBase *lb) TreeElement *te; TreeStoreElem *tselem; - for(te= lb->first; te; te= te->next) { + 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(soops, &te->subtree)) return 1; + if (tselem->type==0 && te->idcode==ID_OB) return 1; + if ( subtree_has_objects(soops, &te->subtree)) return 1; } return 0; } @@ -899,22 +899,22 @@ static void tree_element_show_hierarchy(Scene *scene, SpaceOops *soops, ListBase TreeStoreElem *tselem; /* open all object elems, close others */ - for(te= lb->first; te; te= te->next) { + for (te= lb->first; te; te= te->next) { tselem= TREESTORE(te); - if(tselem->type==0) { - if(te->idcode==ID_SCE) { - if(tselem->id!=(ID *)scene) tselem->flag |= TSE_CLOSED; + if (tselem->type==0) { + if (te->idcode==ID_SCE) { + if (tselem->id!=(ID *)scene) tselem->flag |= TSE_CLOSED; else tselem->flag &= ~TSE_CLOSED; } - else if(te->idcode==ID_OB) { - if(subtree_has_objects(soops, &te->subtree)) tselem->flag &= ~TSE_CLOSED; + else if (te->idcode==ID_OB) { + if (subtree_has_objects(soops, &te->subtree)) tselem->flag &= ~TSE_CLOSED; else tselem->flag |= TSE_CLOSED; } } else tselem->flag |= TSE_CLOSED; - if(TSELEM_OPEN(tselem,soops)) tree_element_show_hierarchy(scene, soops, &te->subtree); + if (TSELEM_OPEN(tselem,soops)) tree_element_show_hierarchy(scene, soops, &te->subtree); } } @@ -1013,12 +1013,12 @@ static void tree_element_to_path(SpaceOops *soops, TreeElement *te, TreeStoreEle /* just 'append' property to path * - to prevent memory leaks, we must write to newpath not path, then free old path + swap them */ - if(tse->type == TSE_RNA_PROPERTY) { - if(RNA_property_type(prop) == PROP_POINTER) { + if (tse->type == TSE_RNA_PROPERTY) { + if (RNA_property_type(prop) == PROP_POINTER) { /* for pointer we just append property name */ newpath= RNA_path_append(*path, ptr, prop, 0, NULL); } - else if(RNA_property_type(prop) == PROP_COLLECTION) { + else if (RNA_property_type(prop) == PROP_COLLECTION) { char buf[128], *name; temnext= (TreeElement*)(ld->next->data); @@ -1027,19 +1027,19 @@ static void tree_element_to_path(SpaceOops *soops, TreeElement *te, TreeStoreEle nextptr= &temnext->rnaptr; name= RNA_struct_name_get_alloc(nextptr, buf, sizeof(buf), NULL); - if(name) { + if (name) { /* 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); @@ -1049,7 +1049,7 @@ static void tree_element_to_path(SpaceOops *soops, TreeElement *te, TreeStoreEle } } - if(newpath) { + if (newpath) { if (*path) MEM_freeN(*path); *path= newpath; newpath= NULL; @@ -1059,11 +1059,11 @@ static void tree_element_to_path(SpaceOops *soops, TreeElement *te, TreeStoreEle /* no ID, so check if entry is RNA-struct, and if that RNA-struct is an ID datablock to extract info from */ if (tse->type == TSE_RNA_STRUCT) { /* ptr->data not ptr->id.data seems to be the one we want, since ptr->data is sometimes the owner of this ID? */ - if(RNA_struct_is_ID(ptr->type)) { + if (RNA_struct_is_ID(ptr->type)) { *id= (ID *)ptr->data; /* clear path */ - if(*path) { + if (*path) { MEM_freeN(*path); path= NULL; } @@ -1508,7 +1508,7 @@ static int parent_drop_invoke(bContext *C, wmOperator *op, wmEvent *event) if (te_found) break; } - if(te_found) { + if (te_found) { RNA_string_set(op->ptr, "parent", te_found->name); /* Identify parent and child */ RNA_string_get(op->ptr, "child", childname); diff --git a/source/blender/editors/space_outliner/outliner_select.c b/source/blender/editors/space_outliner/outliner_select.c index 8270d26d974..e64804b6090 100644 --- a/source/blender/editors/space_outliner/outliner_select.c +++ b/source/blender/editors/space_outliner/outliner_select.c @@ -159,11 +159,11 @@ static int tree_element_active_renderlayer(bContext *C, TreeElement *te, TreeSto Scene *sce; /* paranoia check */ - if(te->idcode!=ID_SCE) + if (te->idcode!=ID_SCE) return 0; sce= (Scene *)tselem->id; - if(set) { + if (set) { sce->r.actlay= tselem->nr; WM_event_add_notifier(C, NC_SCENE|ND_RENDER_OPTIONS, sce); } @@ -181,25 +181,25 @@ static int tree_element_set_active_object(bContext *C, Scene *scene, SpaceOops Object *ob= NULL; /* if id is not object, we search back */ - if(te->idcode==ID_OB) ob= (Object *)tselem->id; + if (te->idcode==ID_OB) ob= (Object *)tselem->id; else { ob= (Object *)outliner_search_back(soops, te, ID_OB); - if(ob==OBACT) return 0; + if (ob==OBACT) return 0; } - if(ob==NULL) return 0; + if (ob==NULL) return 0; sce= (Scene *)outliner_search_back(soops, te, ID_SCE); - if(sce && scene != sce) { + if (sce && scene != sce) { ED_screen_set_scene(C, CTX_wm_screen(C), sce); } /* find associated base in current scene */ base= object_in_scene(ob, scene); - if(base) { - if(set==2) { + if (base) { + if (set==2) { /* swap select */ - if(base->flag & SELECT) + if (base->flag & SELECT) ED_base_object_select(base, BA_DESELECT); else ED_base_object_select(base, BA_SELECT); @@ -209,13 +209,13 @@ static int tree_element_set_active_object(bContext *C, Scene *scene, SpaceOops scene_deselect_all(scene); ED_base_object_select(base, BA_SELECT); } - if(C) { + if (C) { ED_base_object_activate(C, base); /* adds notifier */ WM_event_add_notifier(C, NC_SCENE|ND_OB_SELECT, scene); } } - if(ob!=scene->obedit) + if (ob!=scene->obedit) ED_object_exit_editmode(C, EM_FREEDATA|EM_FREEUNDO|EM_WAITCURSOR|EM_DO_UNDO); return 1; @@ -229,32 +229,32 @@ static int tree_element_active_material(bContext *C, Scene *scene, SpaceOops *so /* we search for the object parent */ ob= (Object *)outliner_search_back(soops, te, ID_OB); // note: ob->matbits can be NULL when a local object points to a library mesh. - if(ob==NULL || ob!=OBACT || ob->matbits==NULL) return 0; // just paranoia + if (ob==NULL || ob!=OBACT || ob->matbits==NULL) return 0; // just paranoia /* searching in ob mat array? */ tes= te->parent; - if(tes->idcode==ID_OB) { - if(set) { + if (tes->idcode==ID_OB) { + if (set) { ob->actcol= te->index+1; ob->matbits[te->index]= 1; // make ob material active too } else { - if(ob->actcol == te->index+1) - if(ob->matbits[te->index]) return 1; + if (ob->actcol == te->index+1) + if (ob->matbits[te->index]) return 1; } } /* or we search for obdata material */ else { - if(set) { + if (set) { ob->actcol= te->index+1; ob->matbits[te->index]= 0; // make obdata material active too } else { - if(ob->actcol == te->index+1) - if(ob->matbits[te->index]==0) return 1; + if (ob->actcol == te->index+1) + if (ob->matbits[te->index]==0) return 1; } } - if(set) { + if (set) { WM_event_add_notifier(C, NC_MATERIAL|ND_SHADING, NULL); } return 0; @@ -267,7 +267,7 @@ static int tree_element_active_texture(bContext *C, Scene *scene, SpaceOops *soo Object *ob=OBACT; SpaceButs *sbuts=NULL; - if(ob==NULL) return 0; // no active object + if (ob==NULL) return 0; // no active object /*tselem= TREESTORE(te);*/ /*UNUSED*/ @@ -278,25 +278,25 @@ static int tree_element_active_texture(bContext *C, Scene *scene, SpaceOops *soo tep= te->parent; tselemp= TREESTORE(tep); - if(tep->idcode==ID_WO) { + if (tep->idcode==ID_WO) { World *wrld= (World *)tselemp->id; - if(set) { - if(sbuts) { + if (set) { + if (sbuts) { // XXX sbuts->tabo= TAB_SHADING_TEX; // hack from header_buttonswin.c // XXX sbuts->texfrom= 1; } // XXX extern_set_butspace(F6KEY, 0); // force shading buttons texture wrld->texact= te->index; } - else if(tselemp->id == (ID *)(scene->world)) { - if(wrld->texact==te->index) return 1; + else if (tselemp->id == (ID *)(scene->world)) { + if (wrld->texact==te->index) return 1; } } - else if(tep->idcode==ID_LA) { + else if (tep->idcode==ID_LA) { Lamp *la= (Lamp *)tselemp->id; - if(set) { - if(sbuts) { + if (set) { + if (sbuts) { // XXX sbuts->tabo= TAB_SHADING_TEX; // hack from header_buttonswin.c // XXX sbuts->texfrom= 2; } @@ -304,15 +304,15 @@ static int tree_element_active_texture(bContext *C, Scene *scene, SpaceOops *soo la->texact= te->index; } else { - if(tselemp->id == ob->data) { - if(la->texact==te->index) return 1; + if (tselemp->id == ob->data) { + if (la->texact==te->index) return 1; } } } - else if(tep->idcode==ID_MA) { + else if (tep->idcode==ID_MA) { Material *ma= (Material *)tselemp->id; - if(set) { - if(sbuts) { + if (set) { + if (sbuts) { //sbuts->tabo= TAB_SHADING_TEX; // hack from header_buttonswin.c // XXX sbuts->texfrom= 0; } @@ -322,12 +322,12 @@ static int tree_element_active_texture(bContext *C, Scene *scene, SpaceOops *soo /* also set active material */ ob->actcol= tep->index+1; } - else if(tep->flag & TE_ACTIVE) { // this is active material - if(ma->texact==te->index) return 1; + else if (tep->flag & TE_ACTIVE) { // this is active material + if (ma->texact==te->index) return 1; } } - if(set) + if (set) WM_event_add_notifier(C, NC_TEXTURE, NULL); return 0; @@ -340,9 +340,9 @@ static int tree_element_active_lamp(bContext *UNUSED(C), Scene *scene, SpaceOops /* we search for the object parent */ ob= (Object *)outliner_search_back(soops, te, ID_OB); - if(ob==NULL || ob!=OBACT) return 0; // just paranoia + if (ob==NULL || ob!=OBACT) return 0; // just paranoia - if(set) { + if (set) { // XXX extern_set_butspace(F5KEY, 0); } else return 1; @@ -354,7 +354,7 @@ static int tree_element_active_camera(bContext *UNUSED(C), Scene *scene, SpaceOo { Object *ob= (Object *)outliner_search_back(soops, te, ID_OB); - if(set) + if (set) return 0; return scene->camera == ob; @@ -367,19 +367,19 @@ static int tree_element_active_world(bContext *C, Scene *scene, SpaceOops *soops Scene *sce=NULL; tep= te->parent; - if(tep) { + if (tep) { tselem= TREESTORE(tep); sce= (Scene *)tselem->id; } - if(set) { // make new scene active - if(sce && scene != sce) { + if (set) { // make new scene active + if (sce && scene != sce) { ED_screen_set_scene(C, CTX_wm_screen(C), sce); } } - if(tep==NULL || tselem->id == (ID *)scene) { - if(set) { + if (tep==NULL || tselem->id == (ID *)scene) { + if (set) { // XXX extern_set_butspace(F8KEY, 0); } else { @@ -395,7 +395,7 @@ static int tree_element_active_defgroup(bContext *C, Scene *scene, TreeElement * /* id in tselem is object */ ob= (Object *)tselem->id; - if(set) { + if (set) { BLI_assert(te->index+1 >= 0); ob->actdef= te->index+1; @@ -403,8 +403,8 @@ static int tree_element_active_defgroup(bContext *C, Scene *scene, TreeElement * WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, ob); } else { - if(ob==OBACT) - if(ob->actdef== te->index+1) return 1; + if (ob==OBACT) + if (ob->actdef== te->index+1) return 1; } return 0; } @@ -413,14 +413,14 @@ static int tree_element_active_posegroup(bContext *C, Scene *scene, TreeElement { Object *ob= (Object *)tselem->id; - if(set) { + if (set) { if (ob->pose) { ob->pose->active_group= te->index+1; WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob); } } else { - if(ob==OBACT && ob->pose) { + if (ob==OBACT && ob->pose) { if (ob->pose->active_group== te->index+1) return 1; } } @@ -433,15 +433,16 @@ static int tree_element_active_posechannel(bContext *C, Scene *scene, TreeElemen bArmature *arm= ob->data; bPoseChannel *pchan= te->directdata; - if(set) { - if(!(pchan->bone->flag & BONE_HIDDEN_P)) { + if (set) { + if (!(pchan->bone->flag & BONE_HIDDEN_P)) { - if(set==2) ED_pose_deselectall(ob, 2); // 2 = clear active tag + if (set==2) ED_pose_deselectall(ob, 2); // 2 = clear active tag else ED_pose_deselectall(ob, 0); // 0 = deselect - if(set==2 && (pchan->bone->flag & BONE_SELECTED)) { + if (set==2 && (pchan->bone->flag & BONE_SELECTED)) { pchan->bone->flag &= ~BONE_SELECTED; - } else { + } + else { pchan->bone->flag |= BONE_SELECTED; arm->act_bone= pchan->bone; } @@ -451,7 +452,7 @@ static int tree_element_active_posechannel(bContext *C, Scene *scene, TreeElemen } } else { - if(ob==OBACT && ob->pose) { + if (ob==OBACT && ob->pose) { if (pchan->bone->flag & BONE_SELECTED) return 1; } } @@ -463,14 +464,15 @@ static int tree_element_active_bone(bContext *C, Scene *scene, TreeElement *te, bArmature *arm= (bArmature *)tselem->id; Bone *bone= te->directdata; - if(set) { - if(!(bone->flag & BONE_HIDDEN_P)) { - if(set==2) ED_pose_deselectall(OBACT, 2); // 2 is clear active tag + if (set) { + if (!(bone->flag & BONE_HIDDEN_P)) { + if (set==2) ED_pose_deselectall(OBACT, 2); // 2 is clear active tag else ED_pose_deselectall(OBACT, 0); - if(set==2 && (bone->flag & BONE_SELECTED)) { + if (set==2 && (bone->flag & BONE_SELECTED)) { bone->flag &= ~BONE_SELECTED; - } else { + } + else { bone->flag |= BONE_SELECTED; arm->act_bone= bone; } @@ -481,7 +483,7 @@ static int tree_element_active_bone(bContext *C, Scene *scene, TreeElement *te, else { Object *ob= OBACT; - if(ob && ob->data==arm) { + if (ob && ob->data==arm) { if (bone->flag & BONE_SELECTED) return 1; } } @@ -492,16 +494,16 @@ static int tree_element_active_bone(bContext *C, Scene *scene, TreeElement *te, /* ebones only draw in editmode armature */ static void tree_element_active_ebone__sel(bContext *C, Scene *scene, bArmature *arm, EditBone *ebone, short sel) { - if(sel) { + if (sel) { 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, scene->obedit); @@ -511,16 +513,16 @@ static int tree_element_active_ebone(bContext *C, Scene *scene, TreeElement *te, bArmature *arm= scene->obedit->data; EditBone *ebone= te->directdata; - if(set==1) { - if(!(ebone->flag & BONE_HIDDEN_A)) { + if (set==1) { + if (!(ebone->flag & BONE_HIDDEN_A)) { ED_armature_deselect_all(scene->obedit, 0); // deselect tree_element_active_ebone__sel(C, scene, arm, ebone, TRUE); return 1; } } else if (set==2) { - if(!(ebone->flag & BONE_HIDDEN_A)) { - if(!(ebone->flag & BONE_SELECTED)) { + if (!(ebone->flag & BONE_HIDDEN_A)) { + if (!(ebone->flag & BONE_SELECTED)) { tree_element_active_ebone__sel(C, scene, arm, ebone, TRUE); return 1; } @@ -539,7 +541,7 @@ static int tree_element_active_ebone(bContext *C, Scene *scene, TreeElement *te, static int tree_element_active_modifier(bContext *C, TreeElement *UNUSED(te), TreeStoreElem *tselem, int set) { - if(set) { + if (set) { Object *ob= (Object *)tselem->id; WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, ob); @@ -552,7 +554,7 @@ static int tree_element_active_modifier(bContext *C, TreeElement *UNUSED(te), Tr static int tree_element_active_psys(bContext *C, Scene *UNUSED(scene), TreeElement *UNUSED(te), TreeStoreElem *tselem, int set) { - if(set) { + if (set) { Object *ob= (Object *)tselem->id; WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE|NA_EDITED, ob); @@ -565,7 +567,7 @@ static int tree_element_active_psys(bContext *C, Scene *UNUSED(scene), TreeEleme static int tree_element_active_constraint(bContext *C, TreeElement *UNUSED(te), TreeStoreElem *tselem, int set) { - if(set) { + if (set) { Object *ob= (Object *)tselem->id; WM_event_add_notifier(C, NC_OBJECT|ND_CONSTRAINT, ob); @@ -586,17 +588,17 @@ static int tree_element_active_pose(bContext *C, Scene *scene, TreeElement *UNUS Object *ob= (Object *)tselem->id; Base *base= object_in_scene(ob, scene); - if(set) { - if(scene->obedit) + if (set) { + if (scene->obedit) ED_object_exit_editmode(C, EM_FREEDATA|EM_FREEUNDO|EM_WAITCURSOR|EM_DO_UNDO); - if(ob->mode & OB_MODE_POSE) + if (ob->mode & OB_MODE_POSE) ED_armature_exit_posemode(C, base); else ED_armature_enter_posemode(C, base); } else { - if(ob->mode & OB_MODE_POSE) return 1; + if (ob->mode & OB_MODE_POSE) return 1; } return 0; } @@ -605,11 +607,11 @@ static int tree_element_active_sequence(TreeElement *te, TreeStoreElem *UNUSED(t { Sequence *seq= (Sequence*) te->directdata; - if(set) { + if (set) { // XXX select_single_seq(seq, 1); } else { - if(seq->flag & SELECT) + if (seq->flag & SELECT) return(1); } return(0); @@ -621,8 +623,8 @@ static int tree_element_active_sequence_dup(Scene *scene, TreeElement *te, TreeS Editing *ed= seq_give_editing(scene, FALSE); seq= (Sequence*)te->directdata; - if(set==0) { - if(seq->flag & SELECT) + if (set==0) { + if (seq->flag & SELECT) return(1); return(0); } @@ -630,12 +632,12 @@ static int tree_element_active_sequence_dup(Scene *scene, TreeElement *te, TreeS // XXX select_single_seq(seq, 1); p= ed->seqbasep->first; while(p) { - if((!p->strip) || (!p->strip->stripdata) || (!p->strip->stripdata->name)) { + if ((!p->strip) || (!p->strip->stripdata) || (!p->strip->stripdata->name)) { p= p->next; continue; } -// if(!strcmp(p->strip->stripdata->name, seq->strip->stripdata->name)) +// if (!strcmp(p->strip->stripdata->name, seq->strip->stripdata->name)) // XXX select_single_seq(p, 0); p= p->next; } @@ -646,8 +648,8 @@ static int tree_element_active_keymap_item(bContext *UNUSED(C), TreeElement *te, { wmKeyMapItem *kmi = te->directdata; - if(set==0) { - if(kmi->flag & KMI_INACTIVE) return 0; + if (set==0) { + if (kmi->flag & KMI_INACTIVE) return 0; return 1; } else { @@ -695,8 +697,8 @@ int tree_element_type_active(bContext *C, Scene *scene, SpaceOops *soops, TreeEl case TSE_MODIFIER: return tree_element_active_modifier(C, te, tselem, set); case TSE_LINKED_OB: - if(set) tree_element_set_active_object(C, scene, soops, te, set); - else if(tselem->id==(ID *)OBACT) return 1; + if (set) tree_element_set_active_object(C, scene, soops, te, set); + else if (tselem->id==(ID *)OBACT) return 1; break; case TSE_LINKED_PSYS: return tree_element_active_psys(C, scene, te, tselem, set); @@ -726,24 +728,24 @@ int tree_element_type_active(bContext *C, Scene *scene, SpaceOops *soops, TreeEl static int do_outliner_item_activate(bContext *C, Scene *scene, ARegion *ar, SpaceOops *soops, TreeElement *te, int extend, const float mval[2]) { - if(mval[1]>te->ys && mval[1]ys+UI_UNIT_Y) { + if (mval[1]>te->ys && mval[1]ys+UI_UNIT_Y) { TreeStoreElem *tselem= TREESTORE(te); int openclose= 0; /* open close icon */ - if((te->flag & TE_ICONROW)==0) { // hidden icon, no open/close - if( mval[0]>te->xs && mval[0]xs+UI_UNIT_X) + if ((te->flag & TE_ICONROW)==0) { // hidden icon, no open/close + if ( mval[0]>te->xs && mval[0]xs+UI_UNIT_X) openclose= 1; } - if(openclose) { + if (openclose) { /* all below close/open? */ - if(extend) { + if (extend) { tselem->flag &= ~TSE_CLOSED; outliner_set_flag(soops, &te->subtree, TSE_CLOSED, !outliner_has_one_flag(soops, &te->subtree, TSE_CLOSED, 1)); } else { - if(tselem->flag & TSE_CLOSED) tselem->flag &= ~TSE_CLOSED; + if (tselem->flag & TSE_CLOSED) tselem->flag &= ~TSE_CLOSED; else tselem->flag |= TSE_CLOSED; } @@ -751,50 +753,51 @@ static int do_outliner_item_activate(bContext *C, Scene *scene, ARegion *ar, Spa return 1; } /* name and first icon */ - else if(mval[0]>te->xs+UI_UNIT_X && mval[0]xend) { + else if (mval[0]>te->xs+UI_UNIT_X && mval[0]xend) { /* always makes active object */ - if(tselem->type!=TSE_SEQUENCE && tselem->type!=TSE_SEQ_STRIP && tselem->type!=TSE_SEQUENCE_DUP) + if (tselem->type!=TSE_SEQUENCE && tselem->type!=TSE_SEQ_STRIP && tselem->type!=TSE_SEQUENCE_DUP) tree_element_set_active_object(C, scene, soops, te, 1 + (extend!=0 && tselem->type==0)); - if(tselem->type==0) { // the lib blocks + if (tselem->type==0) { // the lib blocks /* editmode? */ - if(te->idcode==ID_SCE) { - if(scene!=(Scene *)tselem->id) { + if (te->idcode==ID_SCE) { + if (scene!=(Scene *)tselem->id) { ED_screen_set_scene(C, CTX_wm_screen(C), (Scene *)tselem->id); } } - else if(te->idcode==ID_GR) { + else if (te->idcode==ID_GR) { Group *gr= (Group *)tselem->id; GroupObject *gob; - if(extend) { + if (extend) { int sel= BA_SELECT; - for(gob= gr->gobject.first; gob; gob= gob->next) { - if(gob->ob->flag & SELECT) { + for (gob= gr->gobject.first; gob; gob= gob->next) { + if (gob->ob->flag & SELECT) { sel= BA_DESELECT; break; } } - for(gob= gr->gobject.first; gob; gob= gob->next) { + for (gob= gr->gobject.first; gob; gob= gob->next) { ED_base_object_select(object_in_scene(gob->ob, scene), sel); } } else { scene_deselect_all(scene); - for(gob= gr->gobject.first; gob; gob= gob->next) { - if((gob->ob->flag & SELECT) == 0) + for (gob= gr->gobject.first; gob; gob= gob->next) { + if ((gob->ob->flag & SELECT) == 0) ED_base_object_select(object_in_scene(gob->ob, scene), BA_SELECT); } } WM_event_add_notifier(C, NC_SCENE|ND_OB_SELECT, scene); } - else if(ELEM5(te->idcode, ID_ME, ID_CU, ID_MB, ID_LT, ID_AR)) { + else if (ELEM5(te->idcode, ID_ME, ID_CU, ID_MB, ID_LT, ID_AR)) { WM_operator_name_call(C, "OBJECT_OT_editmode_toggle", WM_OP_INVOKE_REGION_WIN, NULL); - } else { // rest of types + } + else { // rest of types tree_element_active(C, scene, soops, te, 1); } @@ -805,8 +808,8 @@ static int do_outliner_item_activate(bContext *C, Scene *scene, ARegion *ar, Spa } } - for(te= te->subtree.first; te; te= te->next) { - if(do_outliner_item_activate(C, scene, ar, soops, te, extend, mval)) return 1; + for (te= te->subtree.first; te; te= te->next) { + if (do_outliner_item_activate(C, scene, ar, soops, te, extend, mval)) return 1; } return 0; } @@ -830,11 +833,11 @@ static int outliner_item_activate(bContext *C, wmOperator *op, wmEvent *event) return OPERATOR_CANCELLED; } - for(te= soops->tree.first; te; te= te->next) { - if(do_outliner_item_activate(C, scene, ar, soops, te, extend, fmval)) break; + for (te= soops->tree.first; te; te= te->next) { + if (do_outliner_item_activate(C, scene, ar, soops, te, extend, fmval)) break; } - if(te) { + if (te) { ED_undo_push(C, "Outliner click event"); } else { @@ -846,7 +849,7 @@ static int outliner_item_activate(bContext *C, wmOperator *op, wmEvent *event) fmval[0], fmval[1], NULL, &row); /* select relevant row */ - if(outliner_select(soops, &soops->tree, &row, &selecting)) { + if (outliner_select(soops, &soops->tree, &row, &selecting)) { soops->storeflag |= SO_TREESTORE_REDRAW; @@ -917,7 +920,7 @@ static int outliner_border_select_exec(bContext *C, wmOperator *op) rect.ymax = RNA_int_get(op->ptr, "ymax"); UI_view2d_region_to_view(&ar->v2d, rect.xmax, rect.ymax, &rectf.xmax, &rectf.ymax); - for(te= soops->tree.first; te; te= te->next) { + for (te= soops->tree.first; te; te= te->next) { outliner_item_border_select(scene, soops, &rectf, te, gesture_mode); } diff --git a/source/blender/editors/space_outliner/outliner_tools.c b/source/blender/editors/space_outliner/outliner_tools.c index b53d8ebc4a0..45830eed223 100644 --- a/source/blender/editors/space_outliner/outliner_tools.c +++ b/source/blender/editors/space_outliner/outliner_tools.c @@ -115,13 +115,13 @@ static void set_operation_types(SpaceOops *soops, ListBase *lb, TreeElement *te; TreeStoreElem *tselem; - for(te= lb->first; te; te= te->next) { + for (te= lb->first; te; te= te->next) { tselem= TREESTORE(te); - if(tselem->flag & TSE_SELECTED) { - if(tselem->type) { - if(*datalevel==0) + if (tselem->flag & TSE_SELECTED) { + if (tselem->type) { + if (*datalevel==0) *datalevel= tselem->type; - else if(*datalevel!=tselem->type) + else if (*datalevel!=tselem->type) *datalevel= -1; } else { @@ -139,13 +139,13 @@ static void set_operation_types(SpaceOops *soops, ListBase *lb, case ID_MA: case ID_TE: case ID_IP: case ID_IM: case ID_SO: case ID_KE: case ID_WO: case ID_AC: case ID_NLA: case ID_TXT: case ID_GR: - if(*idlevel==0) *idlevel= idcode; - else if(*idlevel!=idcode) *idlevel= -1; + if (*idlevel==0) *idlevel= idcode; + else if (*idlevel!=idcode) *idlevel= -1; break; } } } - if(TSELEM_OPEN(tselem,soops)) { + if (TSELEM_OPEN(tselem,soops)) { set_operation_types(soops, &te->subtree, scenelevel, objectlevel, idlevel, datalevel); } @@ -163,29 +163,29 @@ static void unlink_material_cb(bContext *UNUSED(C), Scene *UNUSED(scene), TreeEl Material **matar=NULL; int a, totcol=0; - if( GS(tsep->id->name)==ID_OB) { + if ( GS(tsep->id->name)==ID_OB) { Object *ob= (Object *)tsep->id; totcol= ob->totcol; matar= ob->mat; } - else if( GS(tsep->id->name)==ID_ME) { + else if ( GS(tsep->id->name)==ID_ME) { Mesh *me= (Mesh *)tsep->id; totcol= me->totcol; matar= me->mat; } - else if( GS(tsep->id->name)==ID_CU) { + else if ( GS(tsep->id->name)==ID_CU) { Curve *cu= (Curve *)tsep->id; totcol= cu->totcol; matar= cu->mat; } - else if( GS(tsep->id->name)==ID_MB) { + else if ( GS(tsep->id->name)==ID_MB) { MetaBall *mb= (MetaBall *)tsep->id; totcol= mb->totcol; matar= mb->mat; } - for(a=0; aindex && matar[a]) { + for (a=0; aindex && matar[a]) { matar[a]->id.us--; matar[a]= NULL; } @@ -197,23 +197,23 @@ static void unlink_texture_cb(bContext *UNUSED(C), Scene *UNUSED(scene), TreeEle MTex **mtex= NULL; int a; - if( GS(tsep->id->name)==ID_MA) { + if ( GS(tsep->id->name)==ID_MA) { Material *ma= (Material *)tsep->id; mtex= ma->mtex; } - else if( GS(tsep->id->name)==ID_LA) { + else if ( GS(tsep->id->name)==ID_LA) { Lamp *la= (Lamp *)tsep->id; mtex= la->mtex; } - else if( GS(tsep->id->name)==ID_WO) { + else if ( GS(tsep->id->name)==ID_WO) { World *wrld= (World *)tsep->id; mtex= wrld->mtex; } else return; - for(a=0; aindex && mtex[a]) { - if(mtex[a]->tex) { + for (a=0; aindex && mtex[a]) { + if (mtex[a]->tex) { mtex[a]->tex->id.us--; mtex[a]->tex= NULL; } @@ -225,8 +225,8 @@ static void unlink_group_cb(bContext *UNUSED(C), Scene *UNUSED(scene), TreeEleme { Group *group= (Group *)tselem->id; - if(tsep) { - if( GS(tsep->id->name)==ID_OB) { + if (tsep) { + if ( GS(tsep->id->name)==ID_OB) { Object *ob= (Object *)tsep->id; ob->dup_group= NULL; } @@ -252,15 +252,15 @@ static void outliner_do_libdata_operation(bContext *C, Scene *scene, SpaceOops * TreeElement *te; TreeStoreElem *tselem; - for(te=lb->first; te; te= te->next) { + for (te=lb->first; te; te= te->next) { tselem= TREESTORE(te); - if(tselem->flag & TSE_SELECTED) { - if(tselem->type==0) { + if (tselem->flag & TSE_SELECTED) { + if (tselem->type==0) { TreeStoreElem *tsep= TREESTORE(te->parent); operation_cb(C, scene, te, tsep, tselem); } } - if(TSELEM_OPEN(tselem,soops)) { + if (TSELEM_OPEN(tselem,soops)) { outliner_do_libdata_operation(C, scene, soops, &te->subtree, operation_cb); } } @@ -272,8 +272,8 @@ static void object_select_cb(bContext *UNUSED(C), Scene *scene, TreeElement *te, { Base *base= (Base *)te->directdata; - if(base==NULL) base= object_in_scene((Object *)tselem->id, scene); - if(base && ((base->object->restrictflag & OB_RESTRICT_VIEW)==0)) { + if (base==NULL) base= object_in_scene((Object *)tselem->id, scene); + if (base && ((base->object->restrictflag & OB_RESTRICT_VIEW)==0)) { base->flag |= SELECT; base->object->flag |= SELECT; } @@ -283,8 +283,8 @@ static void object_deselect_cb(bContext *UNUSED(C), Scene *scene, TreeElement *t { Base *base= (Base *)te->directdata; - if(base==NULL) base= object_in_scene((Object *)tselem->id, scene); - if(base) { + if (base==NULL) base= object_in_scene((Object *)tselem->id, scene); + if (base) { base->flag &= ~SELECT; base->object->flag &= ~SELECT; } @@ -294,11 +294,11 @@ static void object_delete_cb(bContext *C, Scene *scene, TreeElement *te, TreeSto { Base *base= (Base *)te->directdata; - if(base==NULL) + if (base==NULL) base= object_in_scene((Object *)tselem->id, scene); - if(base) { + if (base) { // check also library later - if(scene->obedit==base->object) + if (scene->obedit==base->object) ED_object_exit_editmode(C, EM_FREEDATA|EM_FREEUNDO|EM_WAITCURSOR|EM_DO_UNDO); ED_base_object_free_and_unlink(CTX_data_main(C), scene, base); @@ -378,12 +378,13 @@ static void group_linkobs2scene_cb(bContext *UNUSED(C), Scene *scene, TreeElemen GroupObject *gob; Base *base; - for(gob=group->gobject.first; gob; gob=gob->next) { + for (gob=group->gobject.first; gob; gob=gob->next) { base= object_in_scene(gob->ob, scene); if (base) { base->object->flag |= SELECT; base->flag |= SELECT; - } else { + } + else { /* link to scene */ base= MEM_callocN( sizeof(Base), "add_base"); BLI_addhead(&scene->base, base); @@ -402,13 +403,13 @@ void outliner_do_object_operation(bContext *C, Scene *scene_act, SpaceOops *soop TreeElement *te; TreeStoreElem *tselem; - for(te=lb->first; te; te= te->next) { + for (te=lb->first; te; te= te->next) { tselem= TREESTORE(te); - if(tselem->flag & TSE_SELECTED) { - if(tselem->type==0 && te->idcode==ID_OB) { + if (tselem->flag & TSE_SELECTED) { + if (tselem->type==0 && te->idcode==ID_OB) { // when objects selected in other scenes... dunno if that should be allowed Scene *scene_owner= (Scene *)outliner_search_back(soops, te, ID_SCE); - if(scene_owner && scene_act != scene_owner) { + if (scene_owner && scene_act != scene_owner) { ED_screen_set_scene(C, CTX_wm_screen(C), scene_owner); } /* important to use 'scene_owner' not scene_act else deleting objects can crash. @@ -417,7 +418,7 @@ void outliner_do_object_operation(bContext *C, Scene *scene_act, SpaceOops *soop operation_cb(C, scene_owner ? scene_owner : scene_act, te, NULL, tselem); } } - if(TSELEM_OPEN(tselem,soops)) { + if (TSELEM_OPEN(tselem,soops)) { outliner_do_object_operation(C, scene_act, soops, &te->subtree, operation_cb); } } @@ -459,15 +460,15 @@ static void pchan_cb(int event, TreeElement *te, TreeStoreElem *UNUSED(tselem)) { bPoseChannel *pchan= (bPoseChannel *)te->directdata; - if(event==1) + if (event==1) pchan->bone->flag |= BONE_SELECTED; - else if(event==2) + else if (event==2) pchan->bone->flag &= ~BONE_SELECTED; - else if(event==3) { + else if (event==3) { pchan->bone->flag |= BONE_HIDDEN_P; pchan->bone->flag &= ~BONE_SELECTED; } - else if(event==4) + else if (event==4) pchan->bone->flag &= ~BONE_HIDDEN_P; } @@ -475,15 +476,15 @@ static void bone_cb(int event, TreeElement *te, TreeStoreElem *UNUSED(tselem)) { Bone *bone= (Bone *)te->directdata; - if(event==1) + if (event==1) bone->flag |= BONE_SELECTED; - else if(event==2) + else if (event==2) bone->flag &= ~BONE_SELECTED; - else if(event==3) { + else if (event==3) { bone->flag |= BONE_HIDDEN_P; bone->flag &= ~BONE_SELECTED; } - else if(event==4) + else if (event==4) bone->flag &= ~BONE_HIDDEN_P; } @@ -491,22 +492,22 @@ static void ebone_cb(int event, TreeElement *te, TreeStoreElem *UNUSED(tselem)) { EditBone *ebone= (EditBone *)te->directdata; - if(event==1) + if (event==1) ebone->flag |= BONE_SELECTED; - else if(event==2) + else if (event==2) ebone->flag &= ~BONE_SELECTED; - else if(event==3) { + else if (event==3) { ebone->flag |= BONE_HIDDEN_A; ebone->flag &= ~BONE_SELECTED|BONE_TIPSEL|BONE_ROOTSEL; } - else if(event==4) + else if (event==4) ebone->flag &= ~BONE_HIDDEN_A; } static void sequence_cb(int event, TreeElement *UNUSED(te), TreeStoreElem *UNUSED(tselem)) { // Sequence *seq= (Sequence*) te->directdata; - if(event==1) { + if (event==1) { // XXX select_single_seq(seq, 1); } } @@ -517,14 +518,14 @@ static void outliner_do_data_operation(SpaceOops *soops, int type, int event, Li TreeElement *te; TreeStoreElem *tselem; - for(te=lb->first; te; te= te->next) { + for (te=lb->first; te; te= te->next) { tselem= TREESTORE(te); - if(tselem->flag & TSE_SELECTED) { - if(tselem->type==type) { + if (tselem->flag & TSE_SELECTED) { + if (tselem->type==type) { operation_cb(event, te, tselem); } } - if(TSELEM_OPEN(tselem,soops)) { + if (TSELEM_OPEN(tselem,soops)) { outliner_do_data_operation(soops, type, event, &te->subtree, operation_cb); } } @@ -557,22 +558,22 @@ static int outliner_object_operation_exec(bContext *C, wmOperator *op) event= RNA_enum_get(op->ptr, "type"); - if(event==1) { + if (event==1) { Scene *sce= scene; // to be able to delete, scenes are set... outliner_do_object_operation(C, scene, soops, &soops->tree, object_select_cb); - if(scene != sce) { + if (scene != sce) { ED_screen_set_scene(C, CTX_wm_screen(C), sce); } str= "Select Objects"; WM_event_add_notifier(C, NC_SCENE|ND_OB_SELECT, scene); } - else if(event==2) { + else if (event==2) { outliner_do_object_operation(C, scene, soops, &soops->tree, object_deselect_cb); str= "Deselect Objects"; WM_event_add_notifier(C, NC_SCENE|ND_OB_SELECT, scene); } - else if(event==4) { + else if (event==4) { outliner_do_object_operation(C, scene, soops, &soops->tree, object_delete_cb); /* XXX: tree management normally happens from draw_outliner(), but when @@ -586,26 +587,26 @@ static int outliner_object_operation_exec(bContext *C, wmOperator *op) str= "Delete Objects"; WM_event_add_notifier(C, NC_SCENE|ND_OB_ACTIVE, scene); } - else if(event==5) { /* disabled, see above enum (ton) */ + else if (event==5) { /* disabled, see above enum (ton) */ outliner_do_object_operation(C, scene, soops, &soops->tree, id_local_cb); str= "Localized Objects"; } - else if(event==6) { + else if (event==6) { outliner_do_object_operation(C, scene, soops, &soops->tree, object_toggle_visibility_cb); str= "Toggle Visibility"; WM_event_add_notifier(C, NC_SCENE|ND_OB_VISIBLE, scene); } - else if(event==7) { + else if (event==7) { outliner_do_object_operation(C, scene, soops, &soops->tree, object_toggle_selectability_cb); str= "Toggle Selectability"; WM_event_add_notifier(C, NC_SCENE|ND_OB_SELECT, scene); } - else if(event==8) { + else if (event==8) { outliner_do_object_operation(C, scene, soops, &soops->tree, object_toggle_renderability_cb); str= "Toggle Renderability"; WM_event_add_notifier(C, NC_SCENE|ND_OB_RENDER, scene); } - else if(event==9) { + else if (event==9) { outliner_do_object_operation(C, scene, soops, &soops->tree, item_rename_cb); str= "Rename Object"; } @@ -659,31 +660,31 @@ static int outliner_group_operation_exec(bContext *C, wmOperator *op) event= RNA_enum_get(op->ptr, "type"); - if(event==1) { + if (event==1) { outliner_do_libdata_operation(C, scene, soops, &soops->tree, unlink_group_cb); str= "Unlink group"; } - else if(event==2) { + else if (event==2) { outliner_do_libdata_operation(C, scene, soops, &soops->tree, id_local_cb); str= "Localized Data"; } - else if(event==3) { + else if (event==3) { outliner_do_libdata_operation(C, scene, soops, &soops->tree, group_linkobs2scene_cb); str= "Link Group Objects to Scene"; } - else if(event==4) { + else if (event==4) { outliner_do_libdata_operation(C, scene, soops, &soops->tree, group_toggle_visibility_cb); str= "Toggle Visibility"; } - else if(event==5) { + else if (event==5) { outliner_do_libdata_operation(C, scene, soops, &soops->tree, group_toggle_selectability_cb); str= "Toggle Selectability"; } - else if(event==6) { + else if (event==6) { outliner_do_libdata_operation(C, scene, soops, &soops->tree, group_toggle_renderability_cb); str= "Toggle Renderability"; } - else if(event==7) { + else if (event==7) { outliner_do_libdata_operation(C, scene, soops, &soops->tree, item_rename_cb); str= "Rename"; } @@ -894,7 +895,7 @@ static void outliner_do_id_set_operation(SpaceOops *soops, int type, ListBase *l for (te=lb->first; te; te= te->next) { tselem= TREESTORE(te); if (tselem->flag & TSE_SELECTED) { - if(tselem->type==type) { + if (tselem->type==type) { TreeStoreElem *tsep = TREESTORE(te->parent); operation_cb(te, tselem, tsep, newid); } @@ -1124,29 +1125,29 @@ static int outliner_data_operation_exec(bContext *C, wmOperator *op) event= RNA_enum_get(op->ptr, "type"); set_operation_types(soops, &soops->tree, &scenelevel, &objectlevel, &idlevel, &datalevel); - if(datalevel==TSE_POSE_CHANNEL) { - if(event>0) { + if (datalevel==TSE_POSE_CHANNEL) { + if (event>0) { outliner_do_data_operation(soops, datalevel, event, &soops->tree, pchan_cb); WM_event_add_notifier(C, NC_OBJECT|ND_POSE, NULL); ED_undo_push(C, "PoseChannel operation"); } } - else if(datalevel==TSE_BONE) { - if(event>0) { + else if (datalevel==TSE_BONE) { + if (event>0) { outliner_do_data_operation(soops, datalevel, event, &soops->tree, bone_cb); WM_event_add_notifier(C, NC_OBJECT|ND_POSE, NULL); ED_undo_push(C, "Bone operation"); } } - else if(datalevel==TSE_EBONE) { - if(event>0) { + else if (datalevel==TSE_EBONE) { + if (event>0) { outliner_do_data_operation(soops, datalevel, event, &soops->tree, ebone_cb); WM_event_add_notifier(C, NC_OBJECT|ND_POSE, NULL); ED_undo_push(C, "EditBone operation"); } } - else if(datalevel==TSE_SEQUENCE) { - if(event>0) { + else if (datalevel==TSE_SEQUENCE) { + if (event>0) { outliner_do_data_operation(soops, datalevel, event, &soops->tree, sequence_cb); } } @@ -1180,7 +1181,7 @@ static int do_outliner_operation_event(bContext *C, Scene *scene, ARegion *ar, S { ReportList *reports = CTX_wm_reports(C); // XXX... - if(mval[1]>te->ys && mval[1]ys+UI_UNIT_Y) { + if (mval[1]>te->ys && mval[1]ys+UI_UNIT_Y) { int scenelevel=0, objectlevel=0, idlevel=0, datalevel=0; TreeStoreElem *tselem= TREESTORE(te); @@ -1198,15 +1199,15 @@ static int do_outliner_operation_event(bContext *C, Scene *scene, ARegion *ar, S set_operation_types(soops, &soops->tree, &scenelevel, &objectlevel, &idlevel, &datalevel); - if(scenelevel) { + if (scenelevel) { //if(objectlevel || datalevel || idlevel) error("Mixed selection"); //else pupmenu("Scene Operations%t|Delete"); } - else if(objectlevel) { + else if (objectlevel) { WM_operator_name_call(C, "OUTLINER_OT_object_operation", WM_OP_INVOKE_REGION_WIN, NULL); } - else if(idlevel) { - if(idlevel==-1 || datalevel) BKE_report(reports, RPT_WARNING, "Mixed selection"); + else if (idlevel) { + if (idlevel==-1 || datalevel) BKE_report(reports, RPT_WARNING, "Mixed selection"); else { if (idlevel==ID_GR) WM_operator_name_call(C, "OUTLINER_OT_group_operation", WM_OP_INVOKE_REGION_WIN, NULL); @@ -1214,8 +1215,8 @@ static int do_outliner_operation_event(bContext *C, Scene *scene, ARegion *ar, S WM_operator_name_call(C, "OUTLINER_OT_id_operation", WM_OP_INVOKE_REGION_WIN, NULL); } } - else if(datalevel) { - if(datalevel==-1) BKE_report(reports, RPT_WARNING, "Mixed selection"); + else if (datalevel) { + if (datalevel==-1) BKE_report(reports, RPT_WARNING, "Mixed selection"); else { if (datalevel == TSE_ANIM_DATA) WM_operator_name_call(C, "OUTLINER_OT_animdata_operation", WM_OP_INVOKE_REGION_WIN, NULL); @@ -1231,8 +1232,8 @@ static int do_outliner_operation_event(bContext *C, Scene *scene, ARegion *ar, S return 1; } - for(te= te->subtree.first; te; te= te->next) { - if(do_outliner_operation_event(C, scene, ar, soops, te, event, mval)) + for (te= te->subtree.first; te; te= te->next) { + if (do_outliner_operation_event(C, scene, ar, soops, te, event, mval)) return 1; } return 0; @@ -1249,8 +1250,8 @@ static int outliner_operation(bContext *C, wmOperator *UNUSED(op), wmEvent *even UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], fmval, fmval+1); - for(te= soops->tree.first; te; te= te->next) { - if(do_outliner_operation_event(C, scene, ar, soops, te, event, fmval)) break; + for (te= soops->tree.first; te; te= te->next) { + if (do_outliner_operation_event(C, scene, ar, soops, te, event, fmval)) break; } return OPERATOR_FINISHED; diff --git a/source/blender/editors/space_outliner/outliner_tree.c b/source/blender/editors/space_outliner/outliner_tree.c index b702bea5168..e83fce0cf05 100644 --- a/source/blender/editors/space_outliner/outliner_tree.c +++ b/source/blender/editors/space_outliner/outliner_tree.c @@ -115,23 +115,23 @@ static void outliner_storage_cleanup(SpaceOops *soops) { TreeStore *ts= soops->treestore; - if(ts) { + if (ts) { TreeStoreElem *tselem; int a, unused= 0; /* each element used once, for ID blocks with more users to have each a treestore */ - for(a=0, tselem= ts->data; ausedelem; a++, tselem++) tselem->used= 0; + for (a=0, tselem= ts->data; ausedelem; a++, tselem++) tselem->used= 0; /* cleanup only after reading file or undo step, and always for * RNA datablocks view in order to save memory */ - if(soops->storeflag & SO_TREESTORE_CLEANUP) { + if (soops->storeflag & SO_TREESTORE_CLEANUP) { - for(a=0, tselem= ts->data; ausedelem; a++, tselem++) { - if(tselem->id==NULL) unused++; + for (a=0, tselem= ts->data; ausedelem; a++, tselem++) { + if (tselem->id==NULL) unused++; } - if(unused) { - if(ts->usedelem == unused) { + if (unused) { + if (ts->usedelem == unused) { MEM_freeN(ts->data); ts->data= NULL; ts->usedelem= ts->totelem= 0; @@ -140,8 +140,8 @@ static void outliner_storage_cleanup(SpaceOops *soops) TreeStoreElem *tsnewar, *tsnew; tsnew=tsnewar= MEM_mallocN((ts->usedelem-unused)*sizeof(TreeStoreElem), "new tselem"); - for(a=0, tselem= ts->data; ausedelem; a++, tselem++) { - if(tselem->id) { + for (a=0, tselem= ts->data; ausedelem; a++, tselem++) { + if (tselem->id) { *tsnew= *tselem; tsnew++; } @@ -163,16 +163,16 @@ static void check_persistent(SpaceOops *soops, TreeElement *te, ID *id, short ty int a; /* case 1; no TreeStore */ - if(soops->treestore==NULL) { + if (soops->treestore==NULL) { soops->treestore= MEM_callocN(sizeof(TreeStore), "treestore"); } ts= soops->treestore; /* check if 'te' is in treestore */ tselem= ts->data; - for(a=0; ausedelem; a++, tselem++) { - if(tselem->id==id && tselem->used==0) { - if((type==0 && tselem->type==0) ||(tselem->type==type && tselem->nr==nr)) { + for (a=0; ausedelem; a++, tselem++) { + if (tselem->id==id && tselem->used==0) { + if ((type==0 && tselem->type==0) ||(tselem->type==type && tselem->nr==nr)) { te->store_index= a; tselem->used= 1; return; @@ -181,11 +181,11 @@ static void check_persistent(SpaceOops *soops, TreeElement *te, ID *id, short ty } /* add 1 element to treestore */ - if(ts->usedelem==ts->totelem) { + if (ts->usedelem==ts->totelem) { TreeStoreElem *tsnew; tsnew= MEM_mallocN((ts->totelem+TS_CHUNK)*sizeof(TreeStoreElem), "treestore data"); - if(ts->data) { + if (ts->data) { memcpy(tsnew, ts->data, ts->totelem*sizeof(TreeStoreElem)); MEM_freeN(ts->data); } @@ -196,7 +196,7 @@ static void check_persistent(SpaceOops *soops, TreeElement *te, ID *id, short ty tselem= ts->data+ts->usedelem; tselem->type= type; - if(type) tselem->nr= nr; // we're picky! :) + if (type) tselem->nr= nr; // we're picky! :) else tselem->nr= 0; tselem->id= id; tselem->used = 0; @@ -211,13 +211,13 @@ static void check_persistent(SpaceOops *soops, TreeElement *te, ID *id, short ty void outliner_free_tree(ListBase *lb) { - while(lb->first) { + while (lb->first) { TreeElement *te= lb->first; outliner_free_tree(&te->subtree); BLI_remlink(lb, te); - if(te->flag & TE_FREE_NAME) MEM_freeN((void *)te->name); + if (te->flag & TE_FREE_NAME) MEM_freeN((void *)te->name); MEM_freeN(te); } } @@ -232,10 +232,10 @@ void outliner_cleanup_tree(SpaceOops *soops) static TreeElement *outliner_find_tree_element(ListBase *lb, int store_index) { TreeElement *te= lb->first, *tes; - while(te) { - if(te->store_index==store_index) return te; + while (te) { + if (te->store_index==store_index) return te; tes= outliner_find_tree_element(&te->subtree, store_index); - if(tes) return tes; + if (tes) return tes; te= te->next; } return NULL; @@ -248,18 +248,18 @@ TreeElement *outliner_find_tse(SpaceOops *soops, TreeStoreElem *tse) TreeStoreElem *tselem; int a; - if(tse->id==NULL) return NULL; + if (tse->id==NULL) return NULL; /* check if 'tse' is in treestore */ tselem= ts->data; - for(a=0; ausedelem; a++, tselem++) { - if((tse->type==0 && tselem->type==0) || (tselem->type==tse->type && tselem->nr==tse->nr)) { - if(tselem->id==tse->id) { + for (a=0; ausedelem; a++, tselem++) { + if ((tse->type==0 && tselem->type==0) || (tselem->type==tse->type && tselem->nr==tse->nr)) { + if (tselem->id==tse->id) { break; } } } - if(tselem) + if (tselem) return outliner_find_tree_element(&soops->tree, a); return NULL; @@ -271,14 +271,14 @@ TreeElement *outliner_find_id(SpaceOops *soops, ListBase *lb, ID *id) TreeElement *te, *tes; TreeStoreElem *tselem; - for(te= lb->first; te; te= te->next) { + for (te= lb->first; te; te= te->next) { tselem= TREESTORE(te); - if(tselem->type==0) { - if(tselem->id==id) return te; + if (tselem->type==0) { + if (tselem->id==id) return te; /* only deeper on scene or object */ - if( te->idcode==ID_OB || te->idcode==ID_SCE || (soops->outlinevis == SO_GROUPS && te->idcode==ID_GR)) { + if ( te->idcode==ID_OB || te->idcode==ID_SCE || (soops->outlinevis == SO_GROUPS && te->idcode==ID_GR)) { tes= outliner_find_id(soops, &te->subtree, id); - if(tes) return tes; + if (tes) return tes; } } } @@ -291,9 +291,9 @@ ID *outliner_search_back(SpaceOops *soops, TreeElement *te, short idcode) TreeStoreElem *tselem; te= te->parent; - while(te) { + 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; @@ -318,7 +318,7 @@ static void outliner_add_bone(SpaceOops *soops, ListBase *lb, ID *id, Bone *curB te->name= curBone->name; te->directdata= curBone; - for(curBone= curBone->childbase.first; curBone; curBone=curBone->next) { + for (curBone= curBone->childbase.first; curBone; curBone=curBone->next) { outliner_add_bone(soops, &te->subtree, id, curBone, te, a); } } @@ -341,7 +341,7 @@ static void outliner_add_passes(SpaceOops *soops, TreeElement *tenla, ID *id, Sc /* save cpu cycles, but we add the first to invoke an open/close triangle */ tselem = TREESTORE(tenla); - if(tselem->flag & TSE_CLOSED) + if (tselem->flag & TSE_CLOSED) return; te= outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_Z)); @@ -422,14 +422,14 @@ static void outliner_add_scene_contents(SpaceOops *soops, ListBase *lb, Scene *s int a; tenla->name= "RenderLayers"; - for(a=0, srl= sce->r.layers.first; srl; srl= srl->next, a++) { + for (a=0, srl= sce->r.layers.first; srl; srl= srl->next, a++) { TreeElement *tenlay= outliner_add_element(soops, &tenla->subtree, sce, te, TSE_R_LAYER, a); tenlay->name= srl->name; tenlay->directdata= &srl->passflag; - if(srl->light_override) + if (srl->light_override) outliner_add_element(soops, &tenlay->subtree, srl->light_override, tenlay, TSE_LINKED_LAMP, 0); - if(srl->mat_override) + if (srl->mat_override) outliner_add_element(soops, &tenlay->subtree, srl->mat_override, tenlay, TSE_LINKED_MAT, 0); outliner_add_passes(soops, tenlay, &sce->id, srl); @@ -469,13 +469,13 @@ static void outliner_add_object_contents(SpaceOops *soops, TreeElement *te, Tree if ((arm->edbo == NULL) && (ob->mode & OB_MODE_POSE)) { int a= 0, const_index= 1000; /* ensure unique id for bone constraints */ - for(pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next, a++) { + for (pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next, a++) { ten= outliner_add_element(soops, &tenla->subtree, ob, tenla, TSE_POSE_CHANNEL, a); ten->name= pchan->name; ten->directdata= pchan; pchan->temp= (void *)ten; - if(pchan->constraints.first) { + if (pchan->constraints.first) { //Object *target; bConstraint *con; TreeElement *ten1; @@ -483,12 +483,12 @@ static void outliner_add_object_contents(SpaceOops *soops, TreeElement *te, Tree //char *str; tenla1->name= "Constraints"; - for(con= pchan->constraints.first; con; con= con->next, const_index++) { + for (con= pchan->constraints.first; con; con= con->next, const_index++) { ten1= outliner_add_element(soops, &tenla1->subtree, ob, tenla1, TSE_CONSTRAINT, const_index); #if 0 /* disabled as it needs to be reworked for recoded constraints system */ target= get_constraint_target(con, &str); - if(str && str[0]) ten1->name= str; - else if(target) ten1->name= target->id.name+2; + if (str && str[0]) ten1->name= str; + else if (target) ten1->name= target->id.name+2; else ten1->name= con->name; #endif ten1->name= con->name; @@ -499,12 +499,12 @@ static void outliner_add_object_contents(SpaceOops *soops, TreeElement *te, Tree } /* make hierarchy */ ten= tenla->subtree.first; - while(ten) { + while (ten) { TreeElement *nten= ten->next, *par; tselem= TREESTORE(ten); - if(tselem->type==TSE_POSE_CHANNEL) { + if (tselem->type==TSE_POSE_CHANNEL) { pchan= (bPoseChannel *)ten->directdata; - if(pchan->parent) { + if (pchan->parent) { BLI_remlink(&tenla->subtree, ten); par= (TreeElement *)pchan->parent->temp; BLI_addtail(&par->subtree, ten); @@ -516,7 +516,7 @@ static void outliner_add_object_contents(SpaceOops *soops, TreeElement *te, Tree } /* Pose Groups */ - if(ob->pose->agroups.first) { + if (ob->pose->agroups.first) { bActionGroup *agrp; TreeElement *ten; TreeElement *tenla= outliner_add_element(soops, &te->subtree, ob, te, TSE_POSEGRP_BASE, 0); @@ -531,10 +531,10 @@ static void outliner_add_object_contents(SpaceOops *soops, TreeElement *te, Tree } } - for(a=0; atotcol; a++) + for (a=0; atotcol; a++) outliner_add_element(soops, &te->subtree, ob->mat[a], te, 0, a); - if(ob->constraints.first) { + if (ob->constraints.first) { //Object *target; bConstraint *con; TreeElement *ten; @@ -546,8 +546,8 @@ static void outliner_add_object_contents(SpaceOops *soops, TreeElement *te, Tree ten= outliner_add_element(soops, &tenla->subtree, ob, tenla, TSE_CONSTRAINT, a); #if 0 /* disabled due to constraints system targets recode... code here needs review */ target= get_constraint_target(con, &str); - if(str && str[0]) ten->name= str; - else if(target) ten->name= target->id.name+2; + if (str && str[0]) ten->name= str; + else if (target) ten->name= target->id.name+2; else ten->name= con->name; #endif ten->name= con->name; @@ -641,7 +641,7 @@ static void outliner_add_id_contents(SpaceOops *soops, TreeElement *te, TreeStor 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; atotcol; a++) + for (a=0; atotcol; 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... */ @@ -655,7 +655,7 @@ static void outliner_add_id_contents(SpaceOops *soops, TreeElement *te, TreeStor if (cu->adt) outliner_add_element(soops, &te->subtree, cu, te, TSE_ANIM_DATA, 0); - for(a=0; atotcol; a++) + for (a=0; atotcol; a++) outliner_add_element(soops, &te->subtree, cu->mat[a], te, 0, a); } break; @@ -667,7 +667,7 @@ static void outliner_add_id_contents(SpaceOops *soops, TreeElement *te, TreeStor if (mb->adt) outliner_add_element(soops, &te->subtree, mb, te, TSE_ANIM_DATA, 0); - for(a=0; atotcol; a++) + for (a=0; atotcol; a++) outliner_add_element(soops, &te->subtree, mb->mat[a], te, 0, a); } break; @@ -679,8 +679,8 @@ static void outliner_add_id_contents(SpaceOops *soops, TreeElement *te, TreeStor if (ma->adt) outliner_add_element(soops, &te->subtree, ma, te, TSE_ANIM_DATA, 0); - for(a=0; amtex[a]) outliner_add_element(soops, &te->subtree, ma->mtex[a]->tex, te, 0, a); + for (a=0; amtex[a]) outliner_add_element(soops, &te->subtree, ma->mtex[a]->tex, te, 0, a); } } break; @@ -710,8 +710,8 @@ static void outliner_add_id_contents(SpaceOops *soops, TreeElement *te, TreeStor if (la->adt) outliner_add_element(soops, &te->subtree, la, te, TSE_ANIM_DATA, 0); - for(a=0; amtex[a]) outliner_add_element(soops, &te->subtree, la->mtex[a]->tex, te, 0, a); + for (a=0; amtex[a]) outliner_add_element(soops, &te->subtree, la->mtex[a]->tex, te, 0, a); } } break; @@ -719,7 +719,7 @@ static void outliner_add_id_contents(SpaceOops *soops, TreeElement *te, TreeStor { Speaker *spk= (Speaker *)id; - if(spk->adt) + if (spk->adt) outliner_add_element(soops, &te->subtree, spk, te, TSE_ANIM_DATA, 0); } break; @@ -731,8 +731,8 @@ static void outliner_add_id_contents(SpaceOops *soops, TreeElement *te, TreeStor if (wrld->adt) outliner_add_element(soops, &te->subtree, wrld, te, TSE_ANIM_DATA, 0); - for(a=0; amtex[a]) outliner_add_element(soops, &te->subtree, wrld->mtex[a]->tex, te, 0, a); + for (a=0; amtex[a]) outliner_add_element(soops, &te->subtree, wrld->mtex[a]->tex, te, 0, a); } } break; @@ -758,7 +758,7 @@ static void outliner_add_id_contents(SpaceOops *soops, TreeElement *te, TreeStor if (arm->adt) outliner_add_element(soops, &te->subtree, arm, te, TSE_ANIM_DATA, 0); - if(arm->edbo) { + if (arm->edbo) { EditBone *ebone; TreeElement *ten; @@ -770,10 +770,10 @@ static void outliner_add_id_contents(SpaceOops *soops, TreeElement *te, TreeStor } /* make hierarchy */ ten= arm->edbo->first ? ((EditBone *)arm->edbo->first)->temp : NULL; - while(ten) { + while (ten) { TreeElement *nten= ten->next, *par; ebone= (EditBone *)ten->directdata; - if(ebone->parent) { + if (ebone->parent) { BLI_remlink(&te->subtree, ten); par= ebone->parent->temp; BLI_addtail(&par->subtree, ten); @@ -785,10 +785,10 @@ static void outliner_add_id_contents(SpaceOops *soops, TreeElement *te, TreeStor else { /* do not extend Armature when we have posemode */ tselem= TREESTORE(te->parent); - if( GS(tselem->id->name)==ID_OB && ((Object *)tselem->id)->mode & OB_MODE_POSE); + if ( GS(tselem->id->name)==ID_OB && ((Object *)tselem->id)->mode & OB_MODE_POSE); else { Bone *curBone; - for (curBone=arm->bonebase.first; curBone; curBone=curBone->next){ + for (curBone=arm->bonebase.first; curBone; curBone=curBone->next) { outliner_add_bone(soops, &te->subtree, id, curBone, te, &a); } } @@ -807,12 +807,12 @@ static TreeElement *outliner_add_element(SpaceOops *soops, ListBase *lb, void *i ID *id= idv; int a = 0; - if(ELEM3(type, TSE_RNA_STRUCT, TSE_RNA_PROPERTY, TSE_RNA_ARRAY_ELEM)) { + if (ELEM3(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; } - if(id==NULL) return NULL; + if (id==NULL) return NULL; te= MEM_callocN(sizeof(TreeElement), "tree elem"); /* add to the visual tree */ @@ -822,24 +822,24 @@ static TreeElement *outliner_add_element(SpaceOops *soops, ListBase *lb, void *i 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 arays - if(ELEM3(type, TSE_SEQUENCE, TSE_SEQ_STRIP, TSE_SEQUENCE_DUP)); - else if(ELEM3(type, TSE_RNA_STRUCT, TSE_RNA_PROPERTY, TSE_RNA_ARRAY_ELEM)); - else if(type==TSE_ANIM_DATA); + if (ELEM3(type, TSE_SEQUENCE, TSE_SEQ_STRIP, TSE_SEQUENCE_DUP)); + else if (ELEM3(type, TSE_RNA_STRUCT, TSE_RNA_PROPERTY, TSE_RNA_ARRAY_ELEM)); + else if (type==TSE_ANIM_DATA); else { te->name= id->name+2; // default, can be overridden by Library or non-ID data te->idcode= GS(id->name); } - if(type==0) { + if (type==0) { /* ID datablock */ outliner_add_id_contents(soops, te, tselem, id); } - else if(type==TSE_ANIM_DATA) { + else if (type==TSE_ANIM_DATA) { IdAdtTemplate *iat = (IdAdtTemplate *)idv; AnimData *adt= (AnimData *)iat->adt; @@ -897,12 +897,12 @@ static TreeElement *outliner_add_element(SpaceOops *soops, ListBase *lb, void *i 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; } } } } - else if(type==TSE_SEQUENCE) { + else if (type==TSE_SEQUENCE) { Sequence *seq= (Sequence*) idv; Sequence *p; @@ -914,25 +914,25 @@ static TreeElement *outliner_add_element(SpaceOops *soops, ListBase *lb, void *i te->idcode= seq->type; te->directdata= seq; - if(seq->type<7) { + if (seq->type<7) { /* * This work like the sequence. * If the sequence have a name (not default name) * show it, in other case put the filename. */ - if(strcmp(seq->name, "SQ")) + if (strcmp(seq->name, "SQ")) te->name= seq->name; else { - if((seq->strip) && (seq->strip->stripdata)) + if ((seq->strip) && (seq->strip->stripdata)) te->name= seq->strip->stripdata->name; else te->name= "SQ None"; } - if(seq->type==SEQ_META) { + if (seq->type==SEQ_META) { te->name= "Meta Strip"; p= seq->seqbase.first; - while(p) { + while (p) { outliner_add_element(soops, &te->subtree, (void*)p, te, TSE_SEQUENCE, index); p= p->next; } @@ -943,23 +943,23 @@ static TreeElement *outliner_add_element(SpaceOops *soops, ListBase *lb, void *i else te->name= "Effect"; } - else if(type==TSE_SEQ_STRIP) { + else if (type==TSE_SEQ_STRIP) { Strip *strip= (Strip *)idv; - if(strip->dir) + if (strip->dir) te->name= strip->dir; else te->name= "Strip None"; te->directdata= strip; } - else if(type==TSE_SEQUENCE_DUP) { + else if (type==TSE_SEQUENCE_DUP) { Sequence *seq= (Sequence*)idv; te->idcode= seq->type; te->directdata= seq; te->name= seq->strip->stripdata->name; } - else if(ELEM3(type, TSE_RNA_STRUCT, TSE_RNA_PROPERTY, TSE_RNA_ARRAY_ELEM)) { + else if (ELEM3(type, TSE_RNA_STRUCT, TSE_RNA_PROPERTY, TSE_RNA_ARRAY_ELEM)) { PointerRNA pptr, propptr, *ptr= (PointerRNA*)idv; PropertyRNA *prop, *iterprop; PropertyType proptype; @@ -967,39 +967,39 @@ static TreeElement *outliner_add_element(SpaceOops *soops, ListBase *lb, void *i /* we do lazy build, for speed and to avoid infinite recusion */ - if(ptr->data == NULL) { + if (ptr->data == NULL) { te->name= "(empty)"; } - else if(type == TSE_RNA_STRUCT) { + else if (type == TSE_RNA_STRUCT) { /* struct */ te->name= RNA_struct_name_get_alloc(ptr, NULL, 0, NULL); - if(te->name) + if (te->name) te->flag |= TE_FREE_NAME; 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); /* 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; asubtree, (void*)ptr, te, TSE_RNA_PROPERTY, a); } - else if(tot) + else if (tot) te->flag |= TE_LAZY_CLOSED; te->rnaptr= *ptr; } - else if(type == TSE_RNA_PROPERTY) { + else if (type == TSE_RNA_PROPERTY) { /* property */ iterprop= RNA_struct_iterator_property(ptr->type); RNA_property_collection_lookup_int(ptr, iterprop, index, &propptr); @@ -1012,42 +1012,42 @@ static TreeElement *outliner_add_element(SpaceOops *soops, ListBase *lb, void *i 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) { + if (proptype == PROP_POINTER) { pptr= RNA_property_pointer_get(ptr, prop); - if(pptr.data) { - if(TSELEM_OPEN(tselem,soops)) + if (pptr.data) { + if (TSELEM_OPEN(tselem,soops)) outliner_add_element(soops, &te->subtree, (void*)&pptr, te, TSE_RNA_STRUCT, -1); else te->flag |= TE_LAZY_CLOSED; } } - else if(proptype == PROP_COLLECTION) { + else if (proptype == PROP_COLLECTION) { tot= RNA_property_collection_length(ptr, prop); - if(TSELEM_OPEN(tselem,soops)) { - for(a=0; asubtree, (void*)&pptr, te, TSE_RNA_STRUCT, a); } } - else if(tot) + else if (tot) te->flag |= TE_LAZY_CLOSED; } - else if(ELEM3(proptype, PROP_BOOLEAN, PROP_INT, PROP_FLOAT)) { + else if (ELEM3(proptype, PROP_BOOLEAN, PROP_INT, PROP_FLOAT)) { tot= RNA_property_array_length(ptr, prop); - if(TSELEM_OPEN(tselem,soops)) { - for(a=0; asubtree, (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) { + else if (type == TSE_RNA_ARRAY_ELEM) { char c; prop= parent->directdata; @@ -1059,12 +1059,12 @@ static TreeElement *outliner_add_element(SpaceOops *soops, ListBase *lb, void *i c= RNA_property_array_item_char(prop, index); te->name= MEM_callocN(sizeof(char)*20, "OutlinerRNAArrayName"); - if(c) sprintf((char *)te->name, " %c", c); + if (c) sprintf((char *)te->name, " %c", c); else sprintf((char *)te->name, " %d", index+1); te->flag |= TE_FREE_NAME; } } - else if(type == TSE_KEYMAP) { + else if (type == TSE_KEYMAP) { wmKeyMap *km= (wmKeyMap *)idv; wmKeyMapItem *kmi; char opname[OP_MAX_TYPENAME]; @@ -1072,24 +1072,24 @@ static TreeElement *outliner_add_element(SpaceOops *soops, ListBase *lb, void *i te->directdata= idv; te->name= km->idname; - if(TSELEM_OPEN(tselem,soops)) { + if (TSELEM_OPEN(tselem,soops)) { a= 0; for (kmi = km->items.first; kmi; kmi = kmi->next, a++) { const char *key= WM_key_event_string(kmi->type); - if(key[0]) { + if (key[0]) { wmOperatorType *ot= NULL; - if(kmi->propvalue); + if (kmi->propvalue); else ot= WM_operatortype_find(kmi->idname, 0); - if(ot || kmi->propvalue) { + if (ot || kmi->propvalue) { TreeElement *ten= outliner_add_element(soops, &te->subtree, kmi, te, TSE_KEYMAP_ITEM, a); ten->directdata= kmi; - if(kmi->propvalue) { + if (kmi->propvalue) { ten->name= "Modal map, not yet"; } else { @@ -1116,7 +1116,7 @@ static int need_add_seq_dup(Sequence *seq) { Sequence *p; - if((!seq->strip) || (!seq->strip->stripdata) || (!seq->strip->stripdata->name)) + if ((!seq->strip) || (!seq->strip->stripdata) || (!seq->strip->stripdata->name)) return(1); /* @@ -1124,25 +1124,25 @@ static int need_add_seq_dup(Sequence *seq) * sequence before this, don't need it, just return. */ p= seq->prev; - while(p) { - if((!p->strip) || (!p->strip->stripdata) || (!p->strip->stripdata->name)) { + while (p) { + if ((!p->strip) || (!p->strip->stripdata) || (!p->strip->stripdata->name)) { p= p->prev; continue; } - if(!strcmp(p->strip->stripdata->name, seq->strip->stripdata->name)) + if (!strcmp(p->strip->stripdata->name, seq->strip->stripdata->name)) return(2); p= p->prev; } p= seq->next; - while(p) { - if((!p->strip) || (!p->strip->stripdata) || (!p->strip->stripdata->name)) { + while (p) { + if ((!p->strip) || (!p->strip->stripdata) || (!p->strip->stripdata->name)) { p= p->next; continue; } - if(!strcmp(p->strip->stripdata->name, seq->strip->stripdata->name)) + if (!strcmp(p->strip->stripdata->name, seq->strip->stripdata->name)) return(0); p= p->next; } @@ -1155,13 +1155,13 @@ static void outliner_add_seq_dup(SpaceOops *soops, Sequence *seq, TreeElement *t Sequence *p; p= seq; - while(p) { - if((!p->strip) || (!p->strip->stripdata) || (!p->strip->stripdata->name)) { + while (p) { + if ((!p->strip) || (!p->strip->stripdata) || (!p->strip->stripdata->name)) { p= p->next; continue; } - if(!strcmp(p->strip->stripdata->name, seq->strip->stripdata->name)) + if (!strcmp(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; } @@ -1181,18 +1181,18 @@ static void outliner_make_hierarchy(SpaceOops *soops, ListBase *lb) /* build hierarchy */ // XXX also, set extents here... te= lb->first; - while(te) { + while (te) { ten= te->next; tselem= TREESTORE(te); - if(tselem->type==0 && te->idcode==ID_OB) { + if (tselem->type==0 && te->idcode==ID_OB) { Object *ob= (Object *)tselem->id; - if(ob->parent && ob->parent->id.newid) { + if (ob->parent && ob->parent->id.newid) { BLI_remlink(lb, te); 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; @@ -1216,15 +1216,15 @@ static int treesort_alpha(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; - else if(comp==3) { + 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; @@ -1237,20 +1237,20 @@ static int treesort_obtype_alpha(const void *v1, const void *v2) const tTreeSort *x1= v1, *x2= v2; /* first put objects last (hierarchy) */ - if(x1->idcode==ID_OB && x2->idcode!=ID_OB) return 1; - else if(x2->idcode==ID_OB && x1->idcode!=ID_OB) return -1; + if (x1->idcode==ID_OB && x2->idcode!=ID_OB) return 1; + else if (x2->idcode==ID_OB && x1->idcode!=ID_OB) return -1; else { /* 2nd we check ob type */ - if(x1->idcode==ID_OB && x2->idcode==ID_OB) { - if( ((Object *)x1->id)->type > ((Object *)x2->id)->type) return 1; - else if( ((Object *)x1->id)->type > ((Object *)x2->id)->type) return -1; + if (x1->idcode==ID_OB && x2->idcode==ID_OB) { + if ( ((Object *)x1->id)->type > ((Object *)x2->id)->type) return 1; + else if ( ((Object *)x1->id)->type > ((Object *)x2->id)->type) return -1; else return 0; } else { int 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; } } @@ -1265,38 +1265,38 @@ static void outliner_sort(SpaceOops *soops, ListBase *lb) int totelem=0; te= lb->last; - if(te==NULL) return; + if (te==NULL) return; tselem= TREESTORE(te); /* sorting rules; only object lists or deformgroups */ - if( (tselem->type==TSE_DEFGROUP) || (tselem->type==0 && te->idcode==ID_OB)) { + if ( (tselem->type==TSE_DEFGROUP) || (tselem->type==0 && te->idcode==ID_OB)) { /* count first */ - for(te= lb->first; te; te= te->next) totelem++; + for (te= lb->first; te; te= te->next) totelem++; - if(totelem>1) { + if (totelem>1) { tTreeSort *tear= MEM_mallocN(totelem*sizeof(tTreeSort), "tree sort array"); tTreeSort *tp=tear; int skip= 0; - for(te= lb->first; te; te= te->next, tp++) { + for (te= lb->first; te; te= te->next, tp++) { tselem= TREESTORE(te); tp->te= te; tp->name= te->name; tp->idcode= te->idcode; - if(tselem->type && tselem->type!=TSE_DEFGROUP) tp->idcode= 0; // don't sort this + if (tselem->type && tselem->type!=TSE_DEFGROUP) tp->idcode= 0; // don't sort this tp->id= tselem->id; } /* keep beginning of list */ - for(tp= tear, skip=0; skipidcode) break; + for (tp= tear, skip=0; skipidcode) break; - if(skipfirst=lb->last= NULL; tp= tear; - while(totelem--) { + while (totelem--) { BLI_addtail(lb, tp->te); tp++; } @@ -1304,7 +1304,7 @@ static void outliner_sort(SpaceOops *soops, ListBase *lb) } } - for(te= lb->first; te; te= te->next) { + for (te= lb->first; te; te= te->next) { outliner_sort(soops, &te->subtree); } } @@ -1379,7 +1379,7 @@ static int outliner_filter_tree(SpaceOops *soops, ListBase *lb) outliner_free_tree(&te->subtree); BLI_remlink(lb, te); - if(te->flag & TE_FREE_NAME) MEM_freeN((void *)te->name); + if (te->flag & TE_FREE_NAME) MEM_freeN((void *)te->name); MEM_freeN(te); } } @@ -1414,35 +1414,35 @@ void outliner_build_tree(Main *mainvar, Scene *scene, SpaceOops *soops) /* 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_DATABLOCKS) + if (soops->search_string[0]!=0 && soops->outlinevis!=SO_DATABLOCKS) soops->search_flags |= SO_SEARCH_RECURSIVE; else soops->search_flags &= ~SO_SEARCH_RECURSIVE; - if(soops->tree.first && (soops->storeflag & SO_TREESTORE_REDRAW)) + if (soops->tree.first && (soops->storeflag & SO_TREESTORE_REDRAW)) return; outliner_free_tree(&soops->tree); outliner_storage_cleanup(soops); /* clear ob id.new flags */ - for(ob= mainvar->object.first; ob; ob= ob->id.next) ob->id.newid= NULL; + for (ob= mainvar->object.first; ob; ob= ob->id.next) ob->id.newid= NULL; /* options */ - if(soops->outlinevis == SO_LIBRARIES) { + if (soops->outlinevis == SO_LIBRARIES) { Library *lib; - for(lib= mainvar->library.first; lib; lib= lib->id.next) { + for (lib= mainvar->library.first; lib; lib= lib->id.next) { ten= outliner_add_element(soops, &soops->tree, lib, NULL, 0, 0); lib->id.newid= (ID *)ten; } /* make hierarchy */ ten= soops->tree.first; - while(ten) { + while (ten) { TreeElement *nten= ten->next, *par; tselem= TREESTORE(ten); lib= (Library *)tselem->id; - if(lib->parent) { + if (lib->parent) { BLI_remlink(&soops->tree, ten); par= (TreeElement *)lib->parent->id.newid; BLI_addtail(&par->subtree, ten); @@ -1451,67 +1451,67 @@ void outliner_build_tree(Main *mainvar, Scene *scene, SpaceOops *soops) ten= nten; } /* restore newid pointers */ - for(lib= mainvar->library.first; lib; lib= lib->id.next) + for (lib= mainvar->library.first; lib; lib= lib->id.next) lib->id.newid= NULL; } - else if(soops->outlinevis == SO_ALL_SCENES) { + else if (soops->outlinevis == SO_ALL_SCENES) { Scene *sce; - for(sce= mainvar->scene.first; sce; sce= sce->id.next) { + for (sce= mainvar->scene.first; sce; sce= sce->id.next) { te= outliner_add_element(soops, &soops->tree, sce, NULL, 0, 0); tselem= TREESTORE(te); - if(sce==scene && show_opened) + if (sce==scene && show_opened) tselem->flag &= ~TSE_CLOSED; - for(base= sce->base.first; base; base= base->next) { + for (base= sce->base.first; base; base= base->next) { ten= outliner_add_element(soops, &te->subtree, base->object, te, 0, 0); ten->directdata= base; } outliner_make_hierarchy(soops, &te->subtree); /* clear id.newid, to prevent objects be inserted in wrong scenes (parent in other scene) */ - for(base= sce->base.first; base; base= base->next) base->object->id.newid= NULL; + for (base= sce->base.first; base; base= base->next) base->object->id.newid= NULL; } } - else if(soops->outlinevis == SO_CUR_SCENE) { + else if (soops->outlinevis == SO_CUR_SCENE) { outliner_add_scene_contents(soops, &soops->tree, scene, NULL); - for(base= scene->base.first; base; base= base->next) { + for (base= scene->base.first; base; base= base->next) { ten= outliner_add_element(soops, &soops->tree, base->object, NULL, 0, 0); ten->directdata= base; } outliner_make_hierarchy(soops, &soops->tree); } - else if(soops->outlinevis == SO_VISIBLE) { - for(base= scene->base.first; base; base= base->next) { - if(base->lay & scene->lay) + else if (soops->outlinevis == SO_VISIBLE) { + for (base= scene->base.first; base; base= base->next) { + if (base->lay & scene->lay) outliner_add_element(soops, &soops->tree, base->object, NULL, 0, 0); } outliner_make_hierarchy(soops, &soops->tree); } - else if(soops->outlinevis == SO_GROUPS) { + else if (soops->outlinevis == SO_GROUPS) { Group *group; GroupObject *go; - for(group= mainvar->group.first; group; group= group->id.next) { - if(group->gobject.first) { + for (group= mainvar->group.first; group; group= group->id.next) { + if (group->gobject.first) { te= outliner_add_element(soops, &soops->tree, group, NULL, 0, 0); - for(go= group->gobject.first; go; go= go->next) { + for (go= group->gobject.first; go; go= go->next) { ten= outliner_add_element(soops, &te->subtree, go->ob, te, 0, 0); ten->directdata= NULL; /* eh, why? */ } outliner_make_hierarchy(soops, &te->subtree); /* clear id.newid, to prevent objects be inserted in wrong scenes (parent in other scene) */ - for(go= group->gobject.first; go; go= go->next) go->ob->id.newid= NULL; + for (go= group->gobject.first; go; go= go->next) go->ob->id.newid= NULL; } } } - else if(soops->outlinevis == SO_SAME_TYPE) { + else if (soops->outlinevis == SO_SAME_TYPE) { Object *ob= OBACT; - if(ob) { - for(base= scene->base.first; base; base= base->next) { - if(base->object->type==ob->type) { + if (ob) { + for (base= scene->base.first; base; base= base->next) { + if (base->object->type==ob->type) { ten= outliner_add_element(soops, &soops->tree, base->object, NULL, 0, 0); ten->directdata= base; } @@ -1519,10 +1519,10 @@ void outliner_build_tree(Main *mainvar, Scene *scene, SpaceOops *soops) outliner_make_hierarchy(soops, &soops->tree); } } - else if(soops->outlinevis == SO_SELECTED) { - for(base= scene->base.first; base; base= base->next) { - if(base->lay & scene->lay) { - if(base==BASACT || (base->flag & SELECT)) { + else if (soops->outlinevis == SO_SELECTED) { + for (base= scene->base.first; base; base= base->next) { + if (base->lay & scene->lay) { + if (base==BASACT || (base->flag & SELECT)) { ten= outliner_add_element(soops, &soops->tree, base->object, NULL, 0, 0); ten->directdata= base; } @@ -1530,65 +1530,65 @@ void outliner_build_tree(Main *mainvar, Scene *scene, SpaceOops *soops) } outliner_make_hierarchy(soops, &soops->tree); } - else if(soops->outlinevis==SO_SEQUENCE) { + else if (soops->outlinevis==SO_SEQUENCE) { Sequence *seq; Editing *ed= seq_give_editing(scene, FALSE); int op; - if(ed==NULL) + if (ed==NULL) return; seq= ed->seqbasep->first; - if(!seq) + if (!seq) return; - while(seq) { + while (seq) { op= need_add_seq_dup(seq); - if(op==1) { + if (op==1) { /* ten= */ outliner_add_element(soops, &soops->tree, (void*)seq, NULL, TSE_SEQUENCE, 0); } - else if(op==0) { + else if (op==0) { ten= outliner_add_element(soops, &soops->tree, (void*)seq, NULL, TSE_SEQUENCE_DUP, 0); outliner_add_seq_dup(soops, seq, ten, 0); } seq= seq->next; } } - else if(soops->outlinevis==SO_DATABLOCKS) { + else if (soops->outlinevis==SO_DATABLOCKS) { PointerRNA mainptr; RNA_main_pointer_create(mainvar, &mainptr); ten= outliner_add_element(soops, &soops->tree, (void*)&mainptr, NULL, TSE_RNA_STRUCT, -1); - if(show_opened) { + if (show_opened) { tselem= TREESTORE(ten); tselem->flag &= ~TSE_CLOSED; } } - else if(soops->outlinevis==SO_USERDEF) { + else if (soops->outlinevis==SO_USERDEF) { PointerRNA userdefptr; RNA_pointer_create(NULL, &RNA_UserPreferences, &U, &userdefptr); ten= outliner_add_element(soops, &soops->tree, (void*)&userdefptr, NULL, TSE_RNA_STRUCT, -1); - if(show_opened) { + if (show_opened) { tselem= TREESTORE(ten); tselem->flag &= ~TSE_CLOSED; } } - else if(soops->outlinevis==SO_KEYMAP) { + else if (soops->outlinevis==SO_KEYMAP) { wmWindowManager *wm= mainvar->wm.first; wmKeyMap *km; - for(km= wm->defaultconf->keymaps.first; km; km= km->next) { + for (km= wm->defaultconf->keymaps.first; km; km= km->next) { /* ten= */ outliner_add_element(soops, &soops->tree, (void*)km, NULL, TSE_KEYMAP, 0); } } else { ten= outliner_add_element(soops, &soops->tree, OBACT, NULL, 0, 0); - if(ten) ten->directdata= BASACT; + if (ten) ten->directdata= BASACT; } outliner_sort(soops, &soops->tree); diff --git a/source/blender/editors/space_outliner/space_outliner.c b/source/blender/editors/space_outliner/space_outliner.c index d55fe40653e..ed050b7f93d 100644 --- a/source/blender/editors/space_outliner/space_outliner.c +++ b/source/blender/editors/space_outliner/space_outliner.c @@ -83,15 +83,15 @@ static int outliner_parent_drop_poll(bContext *C, wmDrag *drag, wmEvent *event) float fmval[2]; UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], &fmval[0], &fmval[1]); - if(drag->type == WM_DRAG_ID) { + if (drag->type == WM_DRAG_ID) { ID *id = (ID *)drag->poin; - if( GS(id->name) == ID_OB ) { + if ( GS(id->name) == ID_OB ) { /* Ensure item under cursor is valid drop target */ /* Find object hovered over */ - for(te= soops->tree.first; te; te= te->next) { + for (te= soops->tree.first; te; te= te->next) { TreeElement *te_valid; te_valid= outliner_dropzone_parent(C, event, te, fmval); - if(te_valid) return 1; + if (te_valid) return 1; } } } @@ -114,20 +114,20 @@ static int outliner_parent_clear_poll(bContext *C, wmDrag *drag, wmEvent *event) UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], &fmval[0], &fmval[1]); - if(drag->type == WM_DRAG_ID) { + if (drag->type == WM_DRAG_ID) { ID *id = (ID *)drag->poin; - if( GS(id->name) == ID_OB ) { + if ( GS(id->name) == ID_OB ) { //TODO: Check if no parent? /* Ensure location under cursor is valid dropzone */ - for(te= soops->tree.first; te; te= te->next) { - if(outliner_dropzone_parent_clear(C, event, te, fmval)) return 1; + for (te= soops->tree.first; te; te= te->next) { + if (outliner_dropzone_parent_clear(C, event, te, fmval)) return 1; } /* Check if mouse cursor is below the tree */ te= soops->tree.last; - while(((te->flag & TE_LAZY_CLOSED)==0) && (te->subtree.last)) { + while (((te->flag & TE_LAZY_CLOSED)==0) && (te->subtree.last)) { te= te->subtree.last; } - if(fmval[1] < te->ys) return 1; + if (fmval[1] < te->ys) return 1; } } return 0; @@ -232,15 +232,15 @@ static void outliner_main_area_listener(ARegion *ar, wmNotifier *wmn) break; case NC_LAMP: /* For updating lamp icons, when changing lamp 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: @@ -269,7 +269,7 @@ static void outliner_main_area_listener(ARegion *ar, wmNotifier *wmn) 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; } @@ -301,11 +301,11 @@ static void outliner_header_area_listener(ARegion *ar, wmNotifier *wmn) /* 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; } @@ -349,8 +349,8 @@ static void outliner_free(SpaceLink *sl) SpaceOops *soutliner= (SpaceOops*)sl; outliner_free_tree(&soutliner->tree); - if(soutliner->treestore) { - if(soutliner->treestore->data) MEM_freeN(soutliner->treestore->data); + if (soutliner->treestore) { + if (soutliner->treestore->data) MEM_freeN(soutliner->treestore->data); MEM_freeN(soutliner->treestore); } diff --git a/source/blender/editors/space_script/script_edit.c b/source/blender/editors/space_script/script_edit.c index 2ef1076bc37..4ff0c7ba5b3 100644 --- a/source/blender/editors/space_script/script_edit.c +++ b/source/blender/editors/space_script/script_edit.c @@ -57,7 +57,7 @@ static int run_pyfile_exec(bContext *C, wmOperator *op) char path[512]; RNA_string_get(op->ptr, "filepath", path); #ifdef WITH_PYTHON - if(BPY_filepath_exec(C, path, op->reports)) { + if (BPY_filepath_exec(C, path, op->reports)) { ARegion *ar= CTX_wm_region(C); ED_region_tag_redraw(ar); return OPERATOR_FINISHED; diff --git a/source/blender/editors/space_sequencer/sequencer_add.c b/source/blender/editors/space_sequencer/sequencer_add.c index 818995bfa23..7c5f1a1543f 100644 --- a/source/blender/editors/space_sequencer/sequencer_add.c +++ b/source/blender/editors/space_sequencer/sequencer_add.c @@ -88,10 +88,10 @@ static void sequencer_generic_props__internal(wmOperatorType *ot, int flag) { - if(flag & SEQPROP_STARTFRAME) + if (flag & SEQPROP_STARTFRAME) RNA_def_int(ot->srna, "frame_start", 0, INT_MIN, INT_MAX, "Start Frame", "Start frame of the sequence strip", INT_MIN, INT_MAX); - if(flag & SEQPROP_ENDFRAME) + if (flag & SEQPROP_ENDFRAME) RNA_def_int(ot->srna, "frame_end", 0, INT_MIN, INT_MAX, "End Frame", "End frame for the color strip", INT_MIN, INT_MAX); /* not usual since most strips have a fixed length */ RNA_def_int(ot->srna, "channel", 1, 1, MAXSEQ, "Channel", "Channel to place this strip into", 1, MAXSEQ); @@ -103,10 +103,10 @@ static void sequencer_generic_props__internal(wmOperatorType *ot, int flag) static void sequencer_generic_invoke_path__internal(bContext *C, wmOperator *op, const char *identifier) { - if(RNA_struct_find_property(op->ptr, identifier)) { + if (RNA_struct_find_property(op->ptr, identifier)) { Scene *scene= CTX_data_scene(C); Sequence *last_seq= seq_active_get(scene); - if(last_seq && last_seq->strip && SEQ_HAS_PATH(last_seq)) { + if (last_seq && last_seq->strip && SEQ_HAS_PATH(last_seq)) { char path[sizeof(last_seq->strip->dir)]; BLI_strncpy(path, last_seq->strip->dir, sizeof(path)); BLI_path_abs(path, G.main->name); @@ -124,7 +124,7 @@ static void sequencer_generic_invoke_xy__internal(bContext *C, wmOperator *op, w UI_view2d_region_to_view(v2d, event->mval[0], event->mval[1], &mval_v2d[0], &mval_v2d[1]); /* effect strips don't need a channel initialized from the mouse */ - if(!(flag & SEQPROP_NOCHAN)) { + if (!(flag & SEQPROP_NOCHAN)) { RNA_int_set(op->ptr, "channel", (int)mval_v2d[1]+0.5f); } @@ -151,15 +151,16 @@ static void seq_load_operator_info(SeqLoadInfo *seq_load, wmOperator *op) seq_load->channel= RNA_int_get(op->ptr, "channel"); seq_load->len= 1; // images only, if endframe isn't set! - if(RNA_struct_find_property(op->ptr, "filepath")) { + if (RNA_struct_find_property(op->ptr, "filepath")) { RNA_string_get(op->ptr, "filepath", seq_load->path); /* full path, file is set by the caller */ is_file= 1; - } else if (RNA_struct_find_property(op->ptr, "directory")) { + } + else if (RNA_struct_find_property(op->ptr, "directory")) { RNA_string_get(op->ptr, "directory", seq_load->path); /* full path, file is set by the caller */ is_file= 0; } - if((is_file != -1) && relative) + if ((is_file != -1) && relative) BLI_path_rel(seq_load->path, G.main->name); @@ -180,10 +181,10 @@ static void seq_load_operator_info(SeqLoadInfo *seq_load, wmOperator *op) seq_load->flag |= SEQ_LOAD_FRAME_ADVANCE; - if(is_file==1) { + if (is_file==1) { BLI_strncpy(seq_load->name, BLI_path_basename(seq_load->path), sizeof(seq_load->name)); } - else if(RNA_struct_find_property(op->ptr, "files")) { + else if (RNA_struct_find_property(op->ptr, "files")) { /* used for image strip */ /* best guess, first images name */ RNA_BEGIN(op->ptr, itemptr, "files") { @@ -244,8 +245,8 @@ static int sequencer_add_scene_strip_exec(bContext *C, wmOperator *op) seq->flag |= SELECT; } - if(RNA_boolean_get(op->ptr, "overlap") == FALSE) { - if(seq_test_overlap(ed->seqbasep, seq)) shuffle_seq(ed->seqbasep, seq, scene); + if (RNA_boolean_get(op->ptr, "overlap") == FALSE) { + if (seq_test_overlap(ed->seqbasep, seq)) shuffle_seq(ed->seqbasep, seq, scene); } WM_event_add_notifier(C, NC_SCENE|ND_SEQUENCER, scene); @@ -256,12 +257,12 @@ static int sequencer_add_scene_strip_exec(bContext *C, wmOperator *op) static int sequencer_add_scene_strip_invoke(bContext *C, wmOperator *op, wmEvent *event) { - if(!ED_operator_sequencer_active(C)) { + if (!ED_operator_sequencer_active(C)) { BKE_report(op->reports, RPT_ERROR, "Sequencer area not active"); return OPERATOR_CANCELLED; } - 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, event, 0); @@ -340,8 +341,8 @@ static int sequencer_add_movieclip_strip_exec(bContext *C, wmOperator *op) seq->flag |= SELECT; } - if(RNA_boolean_get(op->ptr, "overlap") == FALSE) { - if(seq_test_overlap(ed->seqbasep, seq)) shuffle_seq(ed->seqbasep, seq, scene); + if (RNA_boolean_get(op->ptr, "overlap") == FALSE) { + if (seq_test_overlap(ed->seqbasep, seq)) shuffle_seq(ed->seqbasep, seq, scene); } WM_event_add_notifier(C, NC_SCENE|ND_SEQUENCER, scene); @@ -352,12 +353,12 @@ static int sequencer_add_movieclip_strip_exec(bContext *C, wmOperator *op) static int sequencer_add_movieclip_strip_invoke(bContext *C, wmOperator *op, wmEvent *event) { - if(!ED_operator_sequencer_active(C)) { + if (!ED_operator_sequencer_active(C)) { BKE_report(op->reports, RPT_ERROR, "Sequencer area not active"); return OPERATOR_CANCELLED; } - 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, event, 0); @@ -408,7 +409,7 @@ static int sequencer_add_generic_strip_exec(bContext *C, wmOperator *op, SeqLoad tot_files= RNA_property_collection_length(op->ptr, RNA_struct_find_property(op->ptr, "files")); - if(tot_files) { + if (tot_files) { /* multiple files */ char dir_only[FILE_MAX]; char file_only[FILE_MAX]; @@ -421,8 +422,8 @@ static int sequencer_add_generic_strip_exec(bContext *C, wmOperator *op, SeqLoad seq = seq_load_func(C, ed->seqbasep, &seq_load); if (seq) { - if(overlap == FALSE) { - if(seq_test_overlap(ed->seqbasep, seq)) shuffle_seq(ed->seqbasep, seq, scene); + if (overlap == FALSE) { + if (seq_test_overlap(ed->seqbasep, seq)) shuffle_seq(ed->seqbasep, seq, scene); } } } @@ -432,8 +433,8 @@ static int sequencer_add_generic_strip_exec(bContext *C, wmOperator *op, SeqLoad /* single file */ seq = seq_load_func(C, ed->seqbasep, &seq_load); if (seq) { - if(overlap == FALSE) { - if(seq_test_overlap(ed->seqbasep, seq)) shuffle_seq(ed->seqbasep, seq, scene); + if (overlap == FALSE) { + if (seq_test_overlap(ed->seqbasep, seq)) shuffle_seq(ed->seqbasep, seq, scene); } } } @@ -461,13 +462,13 @@ static int sequencer_add_movie_strip_exec(bContext *C, wmOperator *op) static int sequencer_add_movie_strip_invoke(bContext *C, wmOperator *op, wmEvent *event) { - if(!ED_operator_sequencer_active(C)) { + if (!ED_operator_sequencer_active(C)) { BKE_report(op->reports, RPT_ERROR, "Sequencer area not active"); return OPERATOR_CANCELLED; } /* This is for drag and drop */ - if((RNA_struct_property_is_set(op->ptr, "files") && RNA_collection_length(op->ptr, "files")) || + if ((RNA_struct_property_is_set(op->ptr, "files") && RNA_collection_length(op->ptr, "files")) || RNA_struct_property_is_set(op->ptr, "filepath")) { sequencer_generic_invoke_xy__internal(C, op, event, SEQPROP_NOPATHS); @@ -515,13 +516,13 @@ static int sequencer_add_sound_strip_exec(bContext *C, wmOperator *op) static int sequencer_add_sound_strip_invoke(bContext *C, wmOperator *op, wmEvent *event) { - if(!ED_operator_sequencer_active(C)) { + if (!ED_operator_sequencer_active(C)) { BKE_report(op->reports, RPT_ERROR, "Sequencer area not active"); return OPERATOR_CANCELLED; } /* This is for drag and drop */ - if((RNA_struct_property_is_set(op->ptr, "files") && RNA_collection_length(op->ptr, "files")) || + if ((RNA_struct_property_is_set(op->ptr, "files") && RNA_collection_length(op->ptr, "files")) || RNA_struct_property_is_set(op->ptr, "filepath")) { sequencer_generic_invoke_xy__internal(C, op, event, SEQPROP_NOPATHS); @@ -577,10 +578,10 @@ static int sequencer_add_image_strip_exec(bContext *C, wmOperator *op) /* images are unique in how they handle this - 1 per strip elem */ 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) deselect_all_seq(scene); @@ -597,8 +598,8 @@ static int sequencer_add_image_strip_exec(bContext *C, wmOperator *op) } RNA_END; - if(seq_load.len == 1) { - if(seq_load.start_frame < seq_load.end_frame) { + if (seq_load.len == 1) { + if (seq_load.start_frame < seq_load.end_frame) { seq->endstill= seq_load.end_frame - seq_load.start_frame; } } @@ -610,8 +611,8 @@ static int sequencer_add_image_strip_exec(bContext *C, wmOperator *op) /* last active name */ strncpy(ed->act_imagedir, strip->dir, FILE_MAXDIR-1); - if(RNA_boolean_get(op->ptr, "overlap") == FALSE) { - if(seq_test_overlap(ed->seqbasep, seq)) shuffle_seq(ed->seqbasep, seq, scene); + if (RNA_boolean_get(op->ptr, "overlap") == FALSE) { + if (seq_test_overlap(ed->seqbasep, seq)) shuffle_seq(ed->seqbasep, seq, scene); } WM_event_add_notifier(C, NC_SCENE|ND_SEQUENCER, scene); @@ -622,14 +623,14 @@ static int sequencer_add_image_strip_exec(bContext *C, wmOperator *op) static int sequencer_add_image_strip_invoke(bContext *C, wmOperator *op, wmEvent *event) { - if(!ED_operator_sequencer_active(C)) { + if (!ED_operator_sequencer_active(C)) { BKE_report(op->reports, RPT_ERROR, "Sequencer area not active"); return OPERATOR_CANCELLED; } /* drag drop has set the names */ - if(RNA_struct_property_is_set(op->ptr, "files") && RNA_collection_length(op->ptr, "files")) { + if (RNA_struct_property_is_set(op->ptr, "files") && RNA_collection_length(op->ptr, "files")) { sequencer_generic_invoke_xy__internal(C, op, event, SEQPROP_ENDFRAME|SEQPROP_NOPATHS); return sequencer_add_image_strip_exec(C, op); } @@ -685,7 +686,7 @@ static int sequencer_add_effect_strip_exec(bContext *C, wmOperator *op) type= RNA_enum_get(op->ptr, "type"); // XXX move to invoke - if(!seq_effect_find_selected(scene, NULL, type, &seq1, &seq2, &seq3, &error_msg)) { + if (!seq_effect_find_selected(scene, NULL, type, &seq1, &seq2, &seq3, &error_msg)) { BKE_report(op->reports, RPT_ERROR, error_msg); return OPERATOR_CANCELLED; } @@ -730,35 +731,37 @@ static int sequencer_add_effect_strip_exec(bContext *C, wmOperator *op) sh.init_plugin(seq, path); - if(seq->plugin==NULL) { + if (seq->plugin==NULL) { BLI_remlink(ed->seqbasep, seq); seq_free_sequence(scene, seq); BKE_reportf(op->reports, RPT_ERROR, "Sequencer plugin \"%s\" could not load", path); return OPERATOR_CANCELLED; } - } else if (seq->type == SEQ_COLOR) { + } + else if (seq->type == SEQ_COLOR) { SolidColorVars *colvars= (SolidColorVars *)seq->effectdata; RNA_float_get_array(op->ptr, "color", colvars->col); seq->blend_mode= SEQ_CROSS; /* so alpha adjustment fade to the strip below */ - } else if (seq->type == SEQ_ADJUSTMENT) { + } + else if (seq->type == SEQ_ADJUSTMENT) { seq->blend_mode= SEQ_CROSS; } /* an unset channel is a special case where we automatically go above * the other strips. */ - if(!RNA_struct_property_is_set(op->ptr, "channel")) { - if(seq->seq1) { + if (!RNA_struct_property_is_set(op->ptr, "channel")) { + if (seq->seq1) { int chan= MAX3( 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; } } - if(RNA_boolean_get(op->ptr, "overlap") == FALSE) { - if(seq_test_overlap(ed->seqbasep, seq)) shuffle_seq(ed->seqbasep, seq, scene); + if (RNA_boolean_get(op->ptr, "overlap") == FALSE) { + if (seq_test_overlap(ed->seqbasep, seq)) shuffle_seq(ed->seqbasep, seq, scene); } update_changed_seq_and_deps(scene, seq, 1, 1); /* runs calc_sequence */ @@ -787,19 +790,19 @@ static int sequencer_add_effect_strip_invoke(bContext *C, wmOperator *op, wmEven int type= -1; int prop_flag= SEQPROP_ENDFRAME; - if(!ED_operator_sequencer_active(C)) { + if (!ED_operator_sequencer_active(C)) { BKE_report(op->reports, RPT_ERROR, "Sequencer area not active"); return OPERATOR_CANCELLED; } - if(is_type_set) { + if (is_type_set) { type= RNA_enum_get(op->ptr, "type"); /* when invoking an effect strip which uses inputs, * skip initializing the channel from the mouse. * Instead leave the property unset so exec() initializes it to be * above the strips its applied to. */ - if(get_sequence_effect_num_inputs(type) != 0) { + if (get_sequence_effect_num_inputs(type) != 0) { prop_flag |= SEQPROP_NOCHAN; } } diff --git a/source/blender/editors/space_sequencer/sequencer_buttons.c b/source/blender/editors/space_sequencer/sequencer_buttons.c index d7fe12bb0c2..ee1a0a7ef6d 100644 --- a/source/blender/editors/space_sequencer/sequencer_buttons.c +++ b/source/blender/editors/space_sequencer/sequencer_buttons.c @@ -99,7 +99,7 @@ static int sequencer_properties(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 3adae356706..d29af06bbcd 100644 --- a/source/blender/editors/space_sequencer/sequencer_draw.c +++ b/source/blender/editors/space_sequencer/sequencer_draw.c @@ -101,7 +101,7 @@ static void get_seq_color3ubv(Scene *curscene, Sequence *seq, unsigned char col[ case SEQ_SCENE: UI_GetThemeColor3ubv(TH_SEQ_SCENE, col); - if(seq->scene==curscene) { + if (seq->scene==curscene) { UI_GetColorPtrShade3ubv(col, col, 20); } break; @@ -148,7 +148,8 @@ static void get_seq_color3ubv(Scene *curscene, Sequence *seq, unsigned char col[ case SEQ_COLOR: if (colvars->col) { rgb_float_to_uchar(col, colvars->col); - } else { + } + else { col[0] = col[1] = col[2] = 128; } break; @@ -160,7 +161,7 @@ static void get_seq_color3ubv(Scene *curscene, Sequence *seq, unsigned char col[ case SEQ_SOUND: 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; default: @@ -175,7 +176,7 @@ static void drawseqwave(Scene *scene, Sequence *seq, float x1, float y1, float x * x2 the end x value, same for y1 and y2 * stepsize is width of a pixel. */ - if(seq->flag & SEQ_AUDIO_DRAW_WAVEFORM) { + if (seq->flag & SEQ_AUDIO_DRAW_WAVEFORM) { int i, j, pos; int length = floor((x2-x1)/stepsize)+1; float ymid = (y1+y2)/2; @@ -186,34 +187,34 @@ static void drawseqwave(Scene *scene, Sequence *seq, float x1, float y1, float x SoundWaveform* waveform; - if(!seq->sound->waveform) + if (!seq->sound->waveform) sound_read_waveform(seq->sound); - if(!seq->sound->waveform) + if (!seq->sound->waveform) return; /* zero length sound */ waveform = seq->sound->waveform; - if(!waveform) + if (!waveform) return; startsample = floor((seq->startofs + seq->anim_startofs)/FPS * SOUND_WAVE_SAMPLES_PER_SECOND); endsample = ceil((seq->startofs + seq->anim_startofs + seq->enddisp - seq->startdisp)/FPS * SOUND_WAVE_SAMPLES_PER_SECOND); samplestep = (endsample-startsample) * stepsize / (x2-x1); - if(length > floor((waveform->length - startsample) / samplestep)) + if (length > floor((waveform->length - startsample) / samplestep)) length = floor((waveform->length - startsample) / samplestep); glBegin(GL_LINE_STRIP); - for(i = 0; i < length; i++) + for (i = 0; i < length; i++) { pos = startsample + i * samplestep; value = waveform->data[pos * 3]; - for(j = pos+1; (j < waveform->length) && (j < pos + samplestep); j++) + for (j = pos+1; (j < waveform->length) && (j < pos + samplestep); j++) { - if(value > waveform->data[j * 3]) + if (value > waveform->data[j * 3]) value = waveform->data[j * 3]; } @@ -222,15 +223,15 @@ static void drawseqwave(Scene *scene, Sequence *seq, float x1, float y1, float x glEnd(); glBegin(GL_LINE_STRIP); - for(i = 0; i < length; i++) + for (i = 0; i < length; i++) { pos = startsample + i * samplestep; value = waveform->data[pos * 3 + 1]; - for(j = pos+1; (j < waveform->length) && (j < pos + samplestep); j++) + for (j = pos+1; (j < waveform->length) && (j < pos + samplestep); j++) { - if(value < waveform->data[j * 3 + 1]) + if (value < waveform->data[j * 3 + 1]) value = waveform->data[j * 3 + 1]; } @@ -242,7 +243,7 @@ static void drawseqwave(Scene *scene, Sequence *seq, float x1, float y1, float x static void drawmeta_stipple(int value) { - if(value) { + if (value) { glEnable(GL_POLYGON_STIPPLE); glPolygonStipple(stipple_halftone); @@ -273,7 +274,7 @@ static void drawmeta_contents(Scene *scene, Sequence *seqm, float x1, float y1, glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - if(seqm->flag & SEQ_MUTE) + if (seqm->flag & SEQ_MUTE) drawmeta_stipple(1); for (seq= seqm->seqbase.first; seq; seq= seq->next) { @@ -287,13 +288,13 @@ static void drawmeta_contents(Scene *scene, Sequence *seqm, float x1, float y1, col[3]= 196; /* alpha, used for all meta children */ for (seq= seqm->seqbase.first; seq; seq= seq->next) { - if((seq->startdisp > x2 || seq->enddisp < x1) == 0) { + if ((seq->startdisp > x2 || seq->enddisp < x1) == 0) { float y_chan= (seq->machine - chan_min) / (float)(chan_range) * draw_range; float x1_chan= seq->startdisp; float x2_chan= seq->enddisp; float y1_chan, y2_chan; - if((seqm->flag & SEQ_MUTE) == 0 && (seq->flag & SEQ_MUTE)) + if ((seqm->flag & SEQ_MUTE) == 0 && (seq->flag & SEQ_MUTE)) drawmeta_stipple(1); get_seq_color3ubv(scene, seq, col); @@ -301,8 +302,8 @@ static void drawmeta_contents(Scene *scene, Sequence *seqm, float x1, float y1, glColor4ubv(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); @@ -313,7 +314,7 @@ static void drawmeta_contents(Scene *scene, Sequence *seqm, float x1, float y1, glColor4ubv(col); fdrawbox(x1_chan, y1_chan, x2_chan, y2_chan); - if((seqm->flag & SEQ_MUTE) == 0 && (seq->flag & SEQ_MUTE)) + if ((seqm->flag & SEQ_MUTE) == 0 && (seq->flag & SEQ_MUTE)) drawmeta_stipple(0); } } @@ -356,7 +357,8 @@ static void draw_seq_handle(View2D *v2d, Sequence *seq, float pixelx, short dire v3[0]= v2[0] + handsize/4; v3[1]= (y1+y2)/2.0f; whichsel = SEQ_LEFTSEL; - } else if (direction == SEQ_RIGHTHANDLE) { + } + else if (direction == SEQ_RIGHTHANDLE) { rx1 = x2-handsize*0.75f; rx2 = x2; @@ -368,19 +370,19 @@ static void draw_seq_handle(View2D *v2d, Sequence *seq, float pixelx, short dire } /* draw! */ - if(seq->type < SEQ_EFFECT || + if (seq->type < SEQ_EFFECT || get_sequence_effect_num_inputs(seq->type) == 0) { glEnable( GL_BLEND ); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - if(seq->flag & whichsel) glColor4ub(0, 0, 0, 80); + if (seq->flag & whichsel) glColor4ub(0, 0, 0, 80); else if (seq->flag & SELECT) glColor4ub(255, 255, 255, 30); else glColor4ub(0, 0, 0, 22); glRectf(rx1, y1, rx2, y2); - if(seq->flag & whichsel) glColor4ub(255, 255, 255, 200); + if (seq->flag & whichsel) glColor4ub(255, 255, 255, 200); else glColor4ub(0, 0, 0, 50); glEnable( GL_POLYGON_SMOOTH ); @@ -392,13 +394,14 @@ static void draw_seq_handle(View2D *v2d, Sequence *seq, float pixelx, short dire glDisable( GL_BLEND ); } - if(G.moving || (seq->flag & whichsel)) { + if (G.moving || (seq->flag & whichsel)) { const char col[4]= {255, 255, 255, 255}; if (direction == SEQ_LEFTHANDLE) { BLI_snprintf(numstr, sizeof(numstr),"%d", seq->startdisp); x1= rx1; y1 -= 0.45f; - } else { + } + else { BLI_snprintf(numstr, sizeof(numstr), "%d", seq->enddisp - 1); x1= x2 - handsize*0.75f; y1= y2 + 0.05f; @@ -413,7 +416,7 @@ static void draw_seq_extensions(Scene *scene, ARegion *ar, Sequence *seq) unsigned char col[3], blendcol[3]; View2D *v2d= &ar->v2d; - if(seq->type >= SEQ_EFFECT) return; + if (seq->type >= SEQ_EFFECT) return; x1= seq->startdisp; x2= seq->enddisp; @@ -423,11 +426,11 @@ static void draw_seq_extensions(Scene *scene, ARegion *ar, Sequence *seq) pixely = (v2d->cur.ymax - v2d->cur.ymin)/(v2d->mask.ymax - v2d->mask.ymin); - 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; - if(seq->startofs) { + if (seq->startofs) { glEnable( GL_BLEND ); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); @@ -436,7 +439,8 @@ static void draw_seq_extensions(Scene *scene, ARegion *ar, Sequence *seq) if (seq->flag & SELECT) { UI_GetColorPtrBlendShade3ubv(col, blendcol, col, 0.3, -40); glColor4ub(col[0], col[1], col[2], 170); - } else { + } + else { UI_GetColorPtrBlendShade3ubv(col, blendcol, col, 0.6, 0); glColor4ub(col[0], col[1], col[2], 110); } @@ -450,7 +454,7 @@ static void draw_seq_extensions(Scene *scene, ARegion *ar, Sequence *seq) glDisable( GL_BLEND ); } - if(seq->endofs) { + if (seq->endofs) { glEnable( GL_BLEND ); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); @@ -459,7 +463,8 @@ static void draw_seq_extensions(Scene *scene, ARegion *ar, Sequence *seq) if (seq->flag & SELECT) { UI_GetColorPtrBlendShade3ubv(col, blendcol, col, 0.3, -40); glColor4ub(col[0], col[1], col[2], 170); - } else { + } + else { UI_GetColorPtrBlendShade3ubv(col, blendcol, col, 0.6, 0); glColor4ub(col[0], col[1], col[2], 110); } @@ -473,7 +478,7 @@ static void draw_seq_extensions(Scene *scene, ARegion *ar, Sequence *seq) glDisable( GL_BLEND ); } - if(seq->startstill) { + if (seq->startstill) { get_seq_color3ubv(scene, seq, col); UI_GetColorPtrBlendShade3ubv(col, blendcol, col, 0.75, 40); glColor3ubv((GLubyte *)col); @@ -487,11 +492,11 @@ static void draw_seq_extensions(Scene *scene, ARegion *ar, Sequence *seq) glColor3ubv((GLubyte *)col); - for(a=y1; a< y2; a+= pixely * 2.0f) { + for (a=y1; a< y2; a+= pixely * 2.0f) { fdrawline(x1, a, (float)(seq->start), a); } } - if(seq->endstill) { + if (seq->endstill) { get_seq_color3ubv(scene, seq, col); UI_GetColorPtrBlendShade3ubv(col, blendcol, col, 0.75, 40); glColor3ubv((GLubyte *)col); @@ -505,7 +510,7 @@ static void draw_seq_extensions(Scene *scene, ARegion *ar, Sequence *seq) glColor3ubv((GLubyte *)col); - for(a=y1; a< y2; a+= pixely * 2.0f) { + for (a=y1; a< y2; a+= pixely * 2.0f) { fdrawline((float)(seq->start+seq->len), a, x2, a); } } @@ -520,17 +525,18 @@ static void draw_seq_text(View2D *v2d, Sequence *seq, float x1, float x2, float char col[4]; /* note, all strings should include 'name' */ - if(name[0]=='\0') + if (name[0]=='\0') name= give_seqname(seq); - if(seq->type == SEQ_META || seq->type == SEQ_ADJUSTMENT) { + if (seq->type == SEQ_META || seq->type == SEQ_ADJUSTMENT) { BLI_snprintf(str, sizeof(str), "%d | %s", seq->len, name); } - else if(seq->type == SEQ_SCENE) { - if(seq->scene) { - if(seq->scene_camera) { + else if (seq->type == SEQ_SCENE) { + if (seq->scene) { + if (seq->scene_camera) { BLI_snprintf(str, sizeof(str), "%d | %s: %s (%s)", seq->len, name, seq->scene->id.name+2, ((ID *)seq->scene_camera)->name+2); - } else { + } + else { BLI_snprintf(str, sizeof(str), "%d | %s: %s", seq->len, name, seq->scene->id.name+2); } } @@ -538,25 +544,25 @@ static void draw_seq_text(View2D *v2d, Sequence *seq, float x1, float x2, float BLI_snprintf(str, sizeof(str), "%d | %s", seq->len, name); } } - else if(seq->type == SEQ_MOVIECLIP) { - if(seq->clip && strcmp(name, seq->clip->id.name+2) != 0) { + else if (seq->type == SEQ_MOVIECLIP) { + if (seq->clip && strcmp(name, seq->clip->id.name+2) != 0) { BLI_snprintf(str, sizeof(str), "%d | %s: %s", seq->len, name, seq->clip->id.name+2); } else { BLI_snprintf(str, sizeof(str), "%d | %s", seq->len, name); } } - else if(seq->type == SEQ_MULTICAM) { + else if (seq->type == SEQ_MULTICAM) { BLI_snprintf(str, sizeof(str), "Cam | %s: %d", name, seq->multicam_source); } - else if(seq->type == SEQ_IMAGE) { + else if (seq->type == SEQ_IMAGE) { BLI_snprintf(str, sizeof(str), "%d | %s: %s%s", seq->len, name, seq->strip->dir, seq->strip->stripdata->name); } - else if(seq->type & SEQ_EFFECT) { + else if (seq->type & SEQ_EFFECT) { int can_float = (seq->type != SEQ_PLUGIN) || (seq->plugin && seq->plugin->version >= 4); - if(seq->seq3!=seq->seq2 && seq->seq1!=seq->seq3) + if (seq->seq3!=seq->seq2 && seq->seq1!=seq->seq3) BLI_snprintf(str, sizeof(str), "%d | %s: %d>%d (use %d)%s", seq->len, name, seq->seq1->machine, seq->seq2->machine, seq->seq3->machine, can_float ? "" : " No float, upgrade plugin!"); else if (seq->seq1 && seq->seq2) BLI_snprintf(str, sizeof(str), "%d | %s: %d>%d%s", seq->len, name, seq->seq1->machine, seq->seq2->machine, can_float ? "" : " No float, upgrade plugin!"); @@ -564,7 +570,7 @@ static void draw_seq_text(View2D *v2d, Sequence *seq, float x1, float x2, float BLI_snprintf(str, sizeof(str), "%d | %s", seq->len, name); } else if (seq->type == SEQ_SOUND) { - if(seq->sound) + if (seq->sound) BLI_snprintf(str, sizeof(str), "%d | %s: %s", seq->len, name, seq->sound->name); else BLI_snprintf(str, sizeof(str), "%d | %s", seq->len, name); @@ -573,11 +579,13 @@ static void draw_seq_text(View2D *v2d, Sequence *seq, float x1, float x2, float BLI_snprintf(str, sizeof(str), "%d | %s: %s%s", seq->len, name, seq->strip->dir, seq->strip->stripdata->name); } - if(seq->flag & SELECT){ + if (seq->flag & SELECT) { col[0]= col[1]= col[2]= 255; - }else if ((((int)background_col[0] + (int)background_col[1] + (int)background_col[2]) / 3) < 50){ + } + else if ((((int)background_col[0] + (int)background_col[1] + (int)background_col[2]) / 3) < 50) { col[0]= col[1]= col[2]= 80; /* use lighter text color for dark background */ - }else{ + } + else { col[0]= col[1]= col[2]= 0; } col[3]= 255; @@ -605,8 +613,8 @@ static void draw_shadedstrip(Sequence *seq, unsigned char col[3], float x1, floa glShadeModel(GL_SMOOTH); glBegin(GL_QUADS); - if(seq->flag & SEQ_INVALID_EFFECT) { col[0]= 255; col[1]= 0; col[2]= 255; } - else if(seq->flag & SELECT) UI_GetColorPtrShade3ubv(col, col, -50); + if (seq->flag & SEQ_INVALID_EFFECT) { col[0]= 255; col[1]= 0; col[2]= 255; } + else if (seq->flag & SELECT) UI_GetColorPtrShade3ubv(col, col, -50); /* else UI_GetColorPtrShade3ubv(col, col, 0); */ /* DO NOTHING */ glColor3ubv(col); @@ -614,8 +622,8 @@ static void draw_shadedstrip(Sequence *seq, unsigned char col[3], float x1, floa glVertex2f(x1,y1); glVertex2f(x2,y1); - if(seq->flag & SEQ_INVALID_EFFECT) { col[0]= 255; col[1]= 0; col[2]= 255; } - else if(seq->flag & SELECT) UI_GetColorPtrBlendShade3ubv(col, col, col, 0.0, 5); + if (seq->flag & SEQ_INVALID_EFFECT) { col[0]= 255; col[1]= 0; col[2]= 255; } + else if (seq->flag & SELECT) UI_GetColorPtrBlendShade3ubv(col, col, col, 0.0, 5); else UI_GetColorPtrShade3ubv(col, col, -5); glColor3ubv((GLubyte *)col); @@ -632,7 +640,7 @@ static void draw_shadedstrip(Sequence *seq, unsigned char col[3], float x1, floa glVertex2f(x1,ymid2); glVertex2f(x2,ymid2); - if(seq->flag & SELECT) UI_GetColorPtrShade3ubv(col, col, -15); + if (seq->flag & SELECT) UI_GetColorPtrShade3ubv(col, col, -15); else UI_GetColorPtrShade3ubv(col, col, 25); glColor3ubv((GLubyte *)col); @@ -662,10 +670,10 @@ static void draw_seq_strip(Scene *scene, ARegion *ar, Sequence *seq, int outline is_single_image = (char)seq_single_check(seq); /* body */ - if(seq->startstill) x1= seq->start; + if (seq->startstill) x1= seq->start; else x1= seq->startdisp; y1= seq->machine+SEQ_STRIP_OFSBOTTOM; - if(seq->endstill) x2= seq->start+seq->len; + if (seq->endstill) x2= seq->start+seq->len; else x2= seq->enddisp; y2= seq->machine+SEQ_STRIP_OFSTOP; @@ -692,10 +700,10 @@ static void draw_seq_strip(Scene *scene, ARegion *ar, Sequence *seq, int outline x2= seq->enddisp; /* draw sound wave */ - if(seq->type == SEQ_SOUND) drawseqwave(scene, seq, x1, y1, x2, y2, (ar->v2d.cur.xmax - ar->v2d.cur.xmin)/ar->winx); + if (seq->type == SEQ_SOUND) drawseqwave(scene, seq, x1, y1, x2, y2, (ar->v2d.cur.xmax - ar->v2d.cur.xmin)/ar->winx); /* draw lock */ - if(seq->flag & SEQ_LOCK) { + if (seq->flag & SEQ_LOCK) { glEnable(GL_POLYGON_STIPPLE); glEnable(GL_BLEND); @@ -715,7 +723,7 @@ static void draw_seq_strip(Scene *scene, ARegion *ar, Sequence *seq, int outline get_seq_color3ubv(scene, seq, col); if (G.moving && (seq->flag & SELECT)) { - if(seq->flag & SEQ_OVERLAP) { + if (seq->flag & SEQ_OVERLAP) { col[0]= 255; col[1]= col[2]= 40; } else @@ -737,20 +745,20 @@ static void draw_seq_strip(Scene *scene, ARegion *ar, Sequence *seq, int outline glDisable(GL_LINE_STIPPLE); } - if(seq->type==SEQ_META) drawmeta_contents(scene, seq, x1, y1, x2, y2); + if (seq->type==SEQ_META) drawmeta_contents(scene, seq, x1, y1, x2, y2); /* calculate if seq is long enough to print a name */ x1= seq->startdisp+seq->handsize; x2= seq->enddisp-seq->handsize; /* info text on the strip */ - if(x1cur.xmin) x1= v2d->cur.xmin; - else if(x1>v2d->cur.xmax) x1= v2d->cur.xmax; - if(x2cur.xmin) x2= v2d->cur.xmin; - else if(x2>v2d->cur.xmax) x2= v2d->cur.xmax; + if (x1cur.xmin) x1= v2d->cur.xmin; + else if (x1>v2d->cur.xmax) x1= v2d->cur.xmax; + if (x2cur.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) { + if ( (x2-x1) / pixelx > 32) { draw_seq_text(v2d, seq, x1, x2, y1, y2, background_col); } } @@ -762,7 +770,7 @@ static void UNUSED_FUNCTION(set_special_seq_update)(int val) // int x; /* if mouse over a sequence && LEFTMOUSE */ - if(val) { + if (val) { // XXX special_seq_update= find_nearest_seq(&x); } else special_seq_update= NULL; @@ -786,7 +794,8 @@ void draw_image_seq(const bContext* C, Scene *scene, ARegion *ar, SpaceSeq *sseq render_size = sseq->render_size; if (render_size == 0) { render_size = scene->r.size; - } else { + } + else { proxy_size = render_size; } if (render_size < 0) { @@ -805,7 +814,7 @@ void draw_image_seq(const bContext* C, Scene *scene, ARegion *ar, SpaceSeq *sseq viewrecty /= proxy_size / 100.0f; } - if(frame_ofs == 0) { + if (frame_ofs == 0) { UI_GetThemeColor3fv(TH_SEQ_PREVIEW, col); glClearColor(col[0], col[1], col[2], 0.0); glClear(GL_COLOR_BUFFER_BIT); @@ -818,7 +827,7 @@ void draw_image_seq(const bContext* C, Scene *scene, ARegion *ar, SpaceSeq *sseq UI_view2d_curRect_validate(v2d); /* only initialize the preview if a render is in progress */ - if(G.rendering) + if (G.rendering) return; context = seq_new_render_data(bmain, scene, rectx, recty, proxy_size); @@ -830,10 +839,10 @@ void draw_image_seq(const bContext* C, Scene *scene, ARegion *ar, SpaceSeq *sseq else ibuf= (ImBuf *)give_ibuf_seq_threaded(context, cfra + frame_ofs, sseq->chanshown); - if(ibuf==NULL) + if (ibuf==NULL) return; - if(ibuf->rect==NULL && ibuf->rect_float == NULL) + if (ibuf->rect==NULL && ibuf->rect_float == NULL) return; switch(sseq->mainb) { @@ -845,7 +854,8 @@ void draw_image_seq(const bContext* C, Scene *scene, ARegion *ar, SpaceSeq *sseq case SEQ_DRAW_IMG_WAVEFORM: if ((sseq->flag & SEQ_DRAW_COLOR_SEPARATED) != 0) { scope = make_sep_waveform_view_from_ibuf(ibuf); - } else { + } + else { scope = make_waveform_view_from_ibuf(ibuf); } break; @@ -862,7 +872,7 @@ void draw_image_seq(const bContext* C, Scene *scene, ARegion *ar, SpaceSeq *sseq ibuf = scope; } - if(ibuf->rect_float && ibuf->rect==NULL) { + if (ibuf->rect_float && ibuf->rect==NULL) { IMB_rect_from_float(ibuf); } @@ -881,7 +891,7 @@ void draw_image_seq(const bContext* C, Scene *scene, ARegion *ar, SpaceSeq *sseq glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, ibuf->x, ibuf->y, 0, GL_RGBA, GL_UNSIGNED_BYTE, ibuf->rect); glBegin(GL_QUADS); - if(frame_ofs) { + if (frame_ofs) { rctf tot_clip; tot_clip.xmin = v2d->tot.xmin + (ABS(v2d->tot.xmax - v2d->tot.xmin) * scene->ed->over_border.xmin); tot_clip.ymin = v2d->tot.ymin + (ABS(v2d->tot.ymax - v2d->tot.ymin) * scene->ed->over_border.ymin); @@ -904,7 +914,7 @@ void draw_image_seq(const bContext* C, Scene *scene, ARegion *ar, SpaceSeq *sseq glDisable(GL_TEXTURE_2D); glDeleteTextures(1, &texid); - if(sseq->mainb == SEQ_DRAW_IMG_IMBUF) { + if (sseq->mainb == SEQ_DRAW_IMG_IMBUF) { float x1 = v2d->tot.xmin; float y1 = v2d->tot.ymin; @@ -969,7 +979,8 @@ void drawprefetchseqspace(Scene *scene, ARegion *UNUSED(ar), SpaceSeq *sseq) int proxy_size = 100.0; if (render_size == 0) { render_size = scene->r.size; - } else { + } + else { proxy_size = render_size; } if (render_size < 0) { @@ -979,7 +990,7 @@ void drawprefetchseqspace(Scene *scene, ARegion *UNUSED(ar), SpaceSeq *sseq) rectx= (render_size*scene->r.xsch)/100; recty= (render_size*scene->r.ysch)/100; - if(sseq->mainb != SEQ_DRAW_SEQUENCE) { + if (sseq->mainb != SEQ_DRAW_SEQUENCE) { give_ibuf_prefetch_request( rectx, recty, (scene->r.cfra), sseq->chanshown, proxy_size); @@ -1151,7 +1162,7 @@ void draw_timeline_seq(const bContext *C, ARegion *ar) ANIM_draw_previewrange(C, v2d); /* overlap playhead */ - if(scene->ed && scene->ed->over_flag & SEQ_EDIT_OVERLAY_SHOW) { + if (scene->ed && scene->ed->over_flag & SEQ_EDIT_OVERLAY_SHOW) { int cfra_over= (scene->ed->over_flag & SEQ_EDIT_OVERLAY_ABS) ? scene->ed->over_cfra : scene->r.cfra + scene->ed->over_ofs; glColor3f(0.2, 0.2, 0.2); // glRectf(cfra_over, v2d->cur.ymin, scene->ed->over_ofs + scene->r.cfra + 1, v2d->cur.ymax); diff --git a/source/blender/editors/space_sequencer/sequencer_edit.c b/source/blender/editors/space_sequencer/sequencer_edit.c index 7fc807cf17f..2486875bc04 100644 --- a/source/blender/editors/space_sequencer/sequencer_edit.c +++ b/source/blender/editors/space_sequencer/sequencer_edit.c @@ -223,10 +223,10 @@ static void seq_proxy_build_job(const bContext *C) void seq_rectf(Sequence *seq, rctf *rectf) { - if(seq->startstill) rectf->xmin = seq->start; + 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; + if (seq->endstill) rectf->xmax = seq->start+seq->len; else rectf->xmax = seq->enddisp; rectf->ymax = seq->machine+SEQ_STRIP_OFSTOP; } @@ -237,7 +237,7 @@ static void UNUSED_FUNCTION(change_plugin_seq)(Scene *scene, char *str) /* calle struct SeqEffectHandle sh; Sequence *last_seq= seq_active_get(scene); - if(last_seq==NULL || last_seq->type != SEQ_PLUGIN) return; + if (last_seq==NULL || last_seq->type != SEQ_PLUGIN) return; sh = get_sequence_effect(last_seq); sh.free(last_seq); @@ -247,7 +247,7 @@ static void UNUSED_FUNCTION(change_plugin_seq)(Scene *scene, char *str) /* calle last_seq->seq2->machine, last_seq->seq3->machine); - if( seq_test_overlap(ed->seqbasep, last_seq) ) shuffle_seq(ed->seqbasep, last_seq, scene); + if ( seq_test_overlap(ed->seqbasep, last_seq) ) shuffle_seq(ed->seqbasep, last_seq, scene); } @@ -259,7 +259,7 @@ 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; @@ -267,11 +267,11 @@ void boundbox_seq(Scene *scene, rctf *rect) max[1]= 8.0; seq= ed->seqbasep->first; - while(seq) { + 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; } @@ -304,12 +304,12 @@ Sequence *find_neighboring_sequence(Scene *scene, Sequence *test, int lr, int se Sequence *seq; Editing *ed= seq_give_editing(scene, FALSE); - if(ed==NULL) return NULL; + if (ed==NULL) return NULL; if (sel>0) sel = SELECT; - for(seq= ed->seqbasep->first; seq; seq= seq->next) { - if( (seq!=test) && + for (seq= ed->seqbasep->first; seq; seq= seq->next) { + if ( (seq!=test) && (test->machine==seq->machine) && ((sel == -1) || (sel && (seq->flag & SELECT)) || (sel==0 && (seq->flag & SELECT)==0) )) { @@ -340,11 +340,11 @@ 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) { - if( (seq!=test) && + while (seq) { + if ( (seq!=test) && (test->machine==seq->machine) && (test->depth==seq->depth) && ((sel == -1) || (sel==(seq->flag & SELECT)))) @@ -367,7 +367,8 @@ static Sequence *find_next_prev_sequence(Scene *scene, Sequence *test, int lr, i if (dist==0) { best_seq = seq; break; - } else if (dist < best_dist) { + } + else if (dist < best_dist) { best_dist = dist; best_seq = seq; } @@ -389,7 +390,7 @@ 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 = (v2d->cur.xmax - v2d->cur.xmin)/(v2d->mask.xmax - v2d->mask.xmin); @@ -397,13 +398,13 @@ Sequence *find_nearest_seq(Scene *scene, View2D *v2d, int *hand, const int mval[ seq= ed->seqbasep->first; - while(seq) { - if(seq->machine == (int)y) { + while (seq) { + if (seq->machine == (int)y) { /* check for both normal strips, and strips that have been flipped horizontally */ - if( ((seq->startdisp < seq->enddisp) && (seq->startdisp<=x && seq->enddisp>=x)) || + if ( ((seq->startdisp < seq->enddisp) && (seq->startdisp<=x && seq->enddisp>=x)) || ((seq->startdisp > seq->enddisp) && (seq->startdisp>=x && seq->enddisp<=x)) ) { - if(seq_tx_test(seq)) { + if (seq_tx_test(seq)) { /* clamp handles to defined size in pixel space */ @@ -416,13 +417,14 @@ Sequence *find_nearest_seq(Scene *scene, View2D *v2d, int *hand, const int mval[ if ((displen/3) < 30*pixelx) { handsize = displen/3; - } else { + } + else { 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; } } @@ -443,11 +445,11 @@ static int seq_is_parent(Sequence *par, Sequence *seq) static int 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 == 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; } @@ -458,7 +460,7 @@ void deselect_all_seq(Scene *scene) Editing *ed= seq_give_editing(scene, FALSE); - if(ed==NULL) return; + if (ed==NULL) return; SEQP_BEGIN(ed, seq) { seq->flag &= ~SEQ_ALLSEL; @@ -472,13 +474,13 @@ void recurs_sel_seq(Sequence *seqm) Sequence *seq; seq= seqm->seqbase.first; - while(seq) { + while (seq) { - if(seqm->flag & (SEQ_LEFTSEL+SEQ_RIGHTSEL)) seq->flag &= ~SEQ_ALLSEL; - else if(seqm->flag & SELECT) seq->flag |= SELECT; + 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; } @@ -494,16 +496,16 @@ int seq_effect_find_selected(Scene *scene, Sequence *activeseq, int type, Sequen if (!activeseq) seq2= seq_active_get(scene); - for(seq=ed->seqbasep->first; seq; seq=seq->next) { - if(seq->flag & SELECT) { + for (seq=ed->seqbasep->first; seq; seq=seq->next) { + if (seq->flag & SELECT) { if (seq->type == SEQ_SOUND && get_sequence_effect_num_inputs(type) != 0) { *error_str= "Can't apply effects to audio sequence strips"; 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 ((seq != activeseq) && (seq != seq2)) { + if (seq2 == NULL) seq2= seq; + else if (seq1 == NULL) seq1= seq; + else if (seq3 == NULL) seq3= seq; else { *error_str= "Can't apply effect to more than 3 sequence strips"; return 0; @@ -526,18 +528,18 @@ int seq_effect_find_selected(Scene *scene, Sequence *activeseq, int type, Sequen *selseq1 = *selseq2 = *selseq3 = NULL; return 1; /* succsess */ case 1: - if(seq2==NULL) { + if (seq2==NULL) { *error_str= "Need at least one selected sequence strip"; return 0; } - if(seq1==NULL) seq1= seq2; - if(seq3==NULL) seq3= seq2; + if (seq1==NULL) seq1= seq2; + if (seq3==NULL) seq3= seq2; case 2: - if(seq1==NULL || seq2==NULL) { + if (seq1==NULL || seq2==NULL) { *error_str= "Need 2 selected sequence strips"; return 0; } - if(seq3 == NULL) seq3= seq2; + if (seq3 == NULL) seq3= seq2; } if (seq1==NULL && seq2==NULL && seq3==NULL) { @@ -559,18 +561,18 @@ 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_EFFECT)) + else if (!(seq->type & SEQ_EFFECT)) return ((seq->flag & SELECT)? NULL: seq); - else if(!(seq->flag & SELECT)) { + else if (!(seq->flag & SELECT)) { /* try to find replacement for effect inputs */ seq1= del_seq_find_replace_recurs(scene, seq->seq1); seq2= del_seq_find_replace_recurs(scene, seq->seq2); seq3= del_seq_find_replace_recurs(scene, seq->seq3); - if(seq1==seq->seq1 && seq2==seq->seq2 && seq3==seq->seq3); - else if(seq1 || seq2 || seq3) { + if (seq1==seq->seq1 && seq2==seq->seq2 && seq3==seq->seq3); + else if (seq1 || seq2 || seq3) { seq->seq1= (seq1)? seq1: (seq2)? seq2: seq3; seq->seq2= (seq2)? seq2: (seq1)? seq1: seq3; seq->seq3= (seq3)? seq3: (seq1)? seq1: seq2; @@ -582,9 +584,9 @@ static Sequence *del_seq_find_replace_recurs(Scene *scene, Sequence *seq) } 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; + 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 @@ -597,12 +599,12 @@ static void recurs_del_seq_flag(Scene *scene, ListBase *lb, short flag, short de Sequence *last_seq = seq_active_get(scene); seq= lb->first; - while(seq) { + while (seq) { seqn= seq->next; - if((seq->flag & flag) || deleteall) { + if ((seq->flag & flag) || deleteall) { BLI_remlink(lb, seq); - if(seq==last_seq) seq_active_set(scene, NULL); - if(seq->type==SEQ_META) recurs_del_seq_flag(scene, &seq->seqbase, flag, 1); + if (seq==last_seq) seq_active_set(scene, NULL); + if (seq->type==SEQ_META) recurs_del_seq_flag(scene, &seq->seqbase, flag, 1); seq_free_sequence(scene, seq); } seq= seqn; @@ -637,7 +639,8 @@ static Sequence *cut_seq_hard(Scene *scene, Sequence * seq, int cutframe) if (seq->type == SEQ_META) { skip_dup = TRUE; seq->startstill = seq->start - cutframe; - } else { + } + else { seq->start= cutframe -1; seq->startstill= cutframe -seq->startdisp -1; seq->anim_endofs += seq->len - 1; @@ -732,7 +735,8 @@ static Sequence *cut_seq_soft(Scene *scene, Sequence * seq, int cutframe) if (seq->type == SEQ_META) { skip_dup = TRUE; seq->startstill = seq->start - cutframe; - } else { + } + else { seq->start= cutframe -1; seq->startstill= cutframe -seq->startdisp -1; seq->endofs = seq->len - 1; @@ -803,21 +807,23 @@ static int cut_seq_list(Scene *scene, ListBase *old, ListBase *new, int cutframe seq= old->first; - while(seq) { + while (seq) { seq_next_iter = seq->next; /* we need this because we may remove seq */ seq->tmp= NULL; - if(seq->flag & SELECT) { - if(cutframe > seq->startdisp && + if (seq->flag & SELECT) { + if (cutframe > seq->startdisp && cutframe < seq->enddisp) { Sequence * seqn = cut_seq(scene, seq, cutframe); if (seqn) { BLI_addtail(new, seqn); } did_something = TRUE; - } else if (seq->enddisp <= cutframe) { + } + else if (seq->enddisp <= cutframe) { /* do nothing */ - } else if (seq->startdisp >= cutframe) { + } + else if (seq->startdisp >= cutframe) { /* move into new list */ BLI_remlink(old, seq); BLI_addtail(new, seq); @@ -836,10 +842,10 @@ static int insert_gap(Scene *scene, int gap, int cfra) /* all strips >= cfra are shifted */ - if(ed==NULL) return 0; + if (ed==NULL) return 0; SEQP_BEGIN(ed, seq) { - if(seq->startdisp >= cfra) { + if (seq->startdisp >= cfra) { seq->start+= gap; calc_sequence(scene, seq); done= 1; @@ -858,16 +864,16 @@ static void UNUSED_FUNCTION(touch_seq_files)(Scene *scene) /* touch all strips with movies */ - if(ed==NULL) return; + if (ed==NULL) return; // XXX25 if(okee("Touch and print selected movies")==0) return; WM_cursor_wait(1); SEQP_BEGIN(ed, seq) { - if(seq->flag & SELECT) { - if(seq->type==SEQ_MOVIE) { - if(seq->strip && seq->strip->stripdata) { + if (seq->flag & SELECT) { + if (seq->type==SEQ_MOVIE) { + if (seq->strip && seq->strip->stripdata) { BLI_make_file_string(G.main->name, str, seq->strip->dir, seq->strip->stripdata->name); BLI_file_touch(seq->name); } @@ -887,13 +893,13 @@ static void set_filter_seq(Scene *scene) Editing *ed= seq_give_editing(scene, FALSE); - if(ed==NULL) return; + if (ed==NULL) return; - if(okee("Set Deinterlace")==0) return; + if (okee("Set Deinterlace")==0) return; SEQP_BEGIN(ed, seq) { - if(seq->flag & SELECT) { - if(seq->type==SEQ_MOVIE) { + if (seq->flag & SELECT) { + if (seq->type==SEQ_MOVIE) { seq->flag |= SEQ_FILTERY; reload_sequence_new_file(scene, seq, FALSE); calc_sequence(scene, seq); @@ -912,7 +918,7 @@ 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)); @@ -927,8 +933,8 @@ static void UNUSED_FUNCTION(seq_remap_paths)(Scene *scene) return; SEQP_BEGIN(ed, seq) { - if(seq->flag & SELECT) { - if(strncmp(seq->strip->dir, from, strlen(from))==0) { + if (seq->flag & SELECT) { + if (strncmp(seq->strip->dir, from, strlen(from))==0) { printf("found %s\n", seq->strip->dir); /* strip off the beginning */ @@ -952,19 +958,19 @@ static void UNUSED_FUNCTION(no_gaps)(Scene *scene) int cfra, first= 0, done; - if(ed==NULL) return; + if (ed==NULL) return; - for(cfra= CFRA; cfra<=EFRA; cfra++) { - if(first==0) { - if( evaluate_seq_frame(scene, cfra) ) first= 1; + for (cfra= CFRA; cfra<=EFRA; cfra++) { + if (first==0) { + if ( evaluate_seq_frame(scene, cfra) ) first= 1; } else { done= 1; - while( evaluate_seq_frame(scene, cfra) == 0) { + while ( evaluate_seq_frame(scene, cfra) == 0) { done= insert_gap(scene, -1, cfra); - if(done==0) break; + if (done==0) break; } - if(done==0) break; + if (done==0) break; } } @@ -1027,18 +1033,20 @@ static int sequencer_snap_exec(bContext *C, wmOperator *op) snap_frame= RNA_int_get(op->ptr, "frame"); /* also check metas */ - for(seq= ed->seqbasep->first; seq; seq= seq->next) { + for (seq= ed->seqbasep->first; seq; seq= seq->next) { if (seq->flag & SELECT && !(seq->depth==0 && seq->flag & SEQ_LOCK) && seq_tx_test(seq)) { - if((seq->flag & (SEQ_LEFTSEL+SEQ_RIGHTSEL))==0) { + if ((seq->flag & (SEQ_LEFTSEL+SEQ_RIGHTSEL))==0) { /* simple but no anim update */ /* seq->start= snap_frame-seq->startofs+seq->startstill; */ seq_translate(scene, seq, (snap_frame-seq->startofs+seq->startstill) - seq->start); - } else { - if(seq->flag & SEQ_LEFTSEL) { + } + else { + if (seq->flag & SEQ_LEFTSEL) { seq_tx_set_final_left(seq, snap_frame); - } else { /* SEQ_RIGHTSEL */ + } + else { /* SEQ_RIGHTSEL */ seq_tx_set_final_right(seq, snap_frame); } seq_tx_handle_xlimits(seq, seq->flag & SEQ_LEFTSEL, seq->flag & SEQ_RIGHTSEL); @@ -1049,19 +1057,19 @@ static int sequencer_snap_exec(bContext *C, wmOperator *op) /* test for effects and overlap * don't use SEQP_BEGIN since that would be recursive */ - for(seq= ed->seqbasep->first; seq; seq= seq->next) { - if(seq->flag & SELECT && !(seq->depth==0 && seq->flag & SEQ_LOCK)) { + for (seq= ed->seqbasep->first; seq; seq= seq->next) { + if (seq->flag & SELECT && !(seq->depth==0 && seq->flag & SEQ_LOCK)) { seq->flag &= ~SEQ_OVERLAP; - if( seq_test_overlap(ed->seqbasep, seq) ) { + if ( seq_test_overlap(ed->seqbasep, seq) ) { shuffle_seq(ed->seqbasep, seq, scene); } } - else if(seq->type & SEQ_EFFECT) { - if(seq->seq1 && (seq->seq1->flag & SELECT)) + else if (seq->type & SEQ_EFFECT) { + if (seq->seq1 && (seq->seq1->flag & SELECT)) calc_sequence(scene, seq); - else if(seq->seq2 && (seq->seq2->flag & SELECT)) + else if (seq->seq2 && (seq->seq2->flag & SELECT)) calc_sequence(scene, seq); - else if(seq->seq3 && (seq->seq3->flag & SELECT)) + else if (seq->seq3 && (seq->seq3->flag & SELECT)) calc_sequence(scene, seq); } } @@ -1114,14 +1122,14 @@ static int sequencer_mute_exec(bContext *C, wmOperator *op) selected= !RNA_boolean_get(op->ptr, "unselected"); - for(seq= ed->seqbasep->first; seq; seq= seq->next) { + for (seq= ed->seqbasep->first; seq; seq= seq->next) { if ((seq->flag & SEQ_LOCK)==0) { - if(selected){ /* mute unselected */ - if(seq->flag & SELECT) + if (selected) { /* mute unselected */ + if (seq->flag & SELECT) seq->flag |= SEQ_MUTE; } else { - if((seq->flag & SELECT)==0) + if ((seq->flag & SELECT)==0) seq->flag |= SEQ_MUTE; } } @@ -1161,14 +1169,14 @@ static int sequencer_unmute_exec(bContext *C, wmOperator *op) selected= !RNA_boolean_get(op->ptr, "unselected"); - for(seq= ed->seqbasep->first; seq; seq= seq->next) { + for (seq= ed->seqbasep->first; seq; seq= seq->next) { if ((seq->flag & SEQ_LOCK)==0) { - if(selected){ /* unmute unselected */ - if(seq->flag & SELECT) + if (selected) { /* unmute unselected */ + if (seq->flag & SELECT) seq->flag &= ~SEQ_MUTE; } else { - if((seq->flag & SELECT)==0) + if ((seq->flag & SELECT)==0) seq->flag &= ~SEQ_MUTE; } } @@ -1205,7 +1213,7 @@ static int sequencer_lock_exec(bContext *C, wmOperator *UNUSED(op)) Editing *ed= seq_give_editing(scene, FALSE); Sequence *seq; - for(seq= ed->seqbasep->first; seq; seq= seq->next) { + for (seq= ed->seqbasep->first; seq; seq= seq->next) { if (seq->flag & SELECT) { seq->flag |= SEQ_LOCK; } @@ -1238,7 +1246,7 @@ static int sequencer_unlock_exec(bContext *C, wmOperator *UNUSED(op)) Editing *ed= seq_give_editing(scene, FALSE); Sequence *seq; - for(seq= ed->seqbasep->first; seq; seq= seq->next) { + for (seq= ed->seqbasep->first; seq; seq= seq->next) { if (seq->flag & SELECT) { seq->flag &= ~SEQ_LOCK; } @@ -1271,8 +1279,8 @@ static int sequencer_reload_exec(bContext *C, wmOperator *UNUSED(op)) Editing *ed= seq_give_editing(scene, FALSE); Sequence *seq; - for(seq= ed->seqbasep->first; seq; seq= seq->next) { - if(seq->flag & SELECT) { + for (seq= ed->seqbasep->first; seq; seq= seq->next) { + if (seq->flag & SELECT) { update_changed_seq_and_deps(scene, seq, 0, 1); } } @@ -1328,12 +1336,12 @@ static int sequencer_reassign_inputs_exec(bContext *C, wmOperator *op) Sequence *seq1, *seq2, *seq3, *last_seq = seq_active_get(scene); const char *error_msg; - if(!seq_effect_find_selected(scene, last_seq, last_seq->type, &seq1, &seq2, &seq3, &error_msg)) { + if (!seq_effect_find_selected(scene, last_seq, last_seq->type, &seq1, &seq2, &seq3, &error_msg)) { BKE_report(op->reports, RPT_ERROR, error_msg); return OPERATOR_CANCELLED; } /* see reassigning would create a cycle */ - if( seq_is_predecessor(seq1, last_seq) || + if ( seq_is_predecessor(seq1, last_seq) || seq_is_predecessor(seq2, last_seq) || seq_is_predecessor(seq3, last_seq) ) { @@ -1357,9 +1365,9 @@ static int sequencer_effect_poll(bContext *C) Scene *scene= CTX_data_scene(C); Editing *ed= seq_give_editing(scene, FALSE); - if(ed) { + if (ed) { Sequence *last_seq= seq_active_get(scene); - if(last_seq && (last_seq->type & SEQ_EFFECT)) { + if (last_seq && (last_seq->type & SEQ_EFFECT)) { return 1; } } @@ -1388,7 +1396,7 @@ static int sequencer_swap_inputs_exec(bContext *C, wmOperator *op) Scene *scene= CTX_data_scene(C); Sequence *seq, *last_seq = seq_active_get(scene); - if(last_seq->seq1==NULL || last_seq->seq2 == NULL) { + if (last_seq->seq1==NULL || last_seq->seq2 == NULL) { BKE_report(op->reports, RPT_ERROR, "No valid inputs to swap"); return OPERATOR_CANCELLED; } @@ -1443,7 +1451,8 @@ static int sequencer_cut_exec(bContext *C, wmOperator *op) if (cut_hard==SEQ_CUT_HARD) { changed = cut_seq_list(scene, ed->seqbasep, &newlist, cut_frame, cut_seq_hard); - } else { + } + else { changed = cut_seq_list(scene, ed->seqbasep, &newlist, cut_frame, cut_seq_soft); } @@ -1457,7 +1466,8 @@ static int sequencer_cut_exec(bContext *C, wmOperator *op) if ( seq->startdisp >= cut_frame ) { seq->flag &= ~SEQ_ALLSEL; } - } else { + } + else { if ( seq->enddisp <= cut_frame ) { seq->flag &= ~SEQ_ALLSEL; } @@ -1469,7 +1479,7 @@ static int sequencer_cut_exec(bContext *C, wmOperator *op) sort_seq(scene); } - if(changed) { + if (changed) { WM_event_add_notifier(C, NC_SCENE|ND_SEQUENCER, scene); return OPERATOR_FINISHED; } @@ -1538,17 +1548,17 @@ static int sequencer_add_duplicate_exec(bContext *C, wmOperator *UNUSED(op)) ListBase nseqbase= {NULL, NULL}; - if(ed==NULL) + if (ed==NULL) return OPERATOR_CANCELLED; seqbase_dupli_recursive(scene, NULL, &nseqbase, ed->seqbasep, SEQ_DUPE_CONTEXT); - if(nseqbase.first) { + if (nseqbase.first) { Sequence * seq= nseqbase.first; /* 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) seq_recursive_apply(seq, apply_unique_name_cb, scene); WM_event_add_notifier(C, NC_SCENE|ND_SEQUENCER, scene); @@ -1599,7 +1609,8 @@ static int sequencer_delete_exec(bContext *C, wmOperator *UNUSED(op)) seq=seq_active_get(scene); if (seq && seq->flag & SELECT) { /* avoid a loop since this is likely to be selected */ nothingSelected = FALSE; - } else { + } + else { for (seq = ed->seqbasep->first; seq; seq = seq->next) { if (seq->flag & SELECT) { nothingSelected = FALSE; @@ -1612,8 +1623,8 @@ static int sequencer_delete_exec(bContext *C, wmOperator *UNUSED(op)) return OPERATOR_FINISHED; /* for effects, try to find a replacement input */ - for(seq=ed->seqbasep->first; seq; seq=seq->next) - if((seq->type & SEQ_EFFECT) && !(seq->flag & SELECT)) + for (seq=ed->seqbasep->first; seq; seq=seq->next) + if ((seq->type & SEQ_EFFECT) && !(seq->flag & SELECT)) del_seq_find_replace_recurs(scene, seq); /* delete all selected strips */ @@ -1621,14 +1632,14 @@ static int sequencer_delete_exec(bContext *C, wmOperator *UNUSED(op)) /* updates lengths etc */ seq= ed->seqbasep->first; - while(seq) { + while (seq) { calc_sequence(scene, seq); seq= seq->next; } /* free parent metas */ ms= ed->metastack.last; - while(ms) { + while (ms) { calc_sequence(scene, ms->parseq); ms= ms->prev; } @@ -1665,22 +1676,22 @@ static int sequencer_offset_clear_exec(bContext *C, wmOperator *UNUSED(op)) Sequence *seq; /* for effects, try to find a replacement input */ - for(seq=ed->seqbasep->first; seq; seq=seq->next) { - if((seq->type & SEQ_EFFECT)==0 && (seq->flag & SELECT)) { + for (seq=ed->seqbasep->first; seq; seq=seq->next) { + if ((seq->type & SEQ_EFFECT)==0 && (seq->flag & SELECT)) { seq->startofs= seq->endofs= seq->startstill= seq->endstill= 0; } } /* updates lengths etc */ seq= ed->seqbasep->first; - while(seq) { + while (seq) { calc_sequence(scene, seq); seq= seq->next; } - for(seq=ed->seqbasep->first; seq; seq=seq->next) { - if((seq->type & SEQ_EFFECT)==0 && (seq->flag & SELECT)) { - if(seq_test_overlap(ed->seqbasep, seq)) { + for (seq=ed->seqbasep->first; seq; seq=seq->next) { + if ((seq->type & SEQ_EFFECT)==0 && (seq->flag & SELECT)) { + if (seq_test_overlap(ed->seqbasep, seq)) { shuffle_seq(ed->seqbasep, seq, scene); } } @@ -1724,7 +1735,7 @@ static int sequencer_separate_images_exec(bContext *C, wmOperator *op) seq= ed->seqbasep->first; /* poll checks this is valid */ while (seq) { - if((seq->flag & SELECT) && (seq->type == SEQ_IMAGE) && (seq->len > 1)) { + if ((seq->flag & SELECT) && (seq->type == SEQ_IMAGE) && (seq->len > 1)) { /* remove seq so overlap tests don't conflict, * see seq_free_sequence below for the real free'ing */ BLI_remlink(ed->seqbasep, seq); @@ -1755,7 +1766,7 @@ static int sequencer_separate_images_exec(bContext *C, wmOperator *op) BLI_strncpy(se_new->name, se->name, sizeof(se_new->name)); calc_sequence(scene, seq_new); - if(step > 1) { + if (step > 1) { seq_new->flag &= ~SEQ_OVERLAP; if (seq_test_overlap(ed->seqbasep, seq_new)) { shuffle_seq(ed->seqbasep, seq_new, scene); @@ -1770,7 +1781,8 @@ static int sequencer_separate_images_exec(bContext *C, wmOperator *op) seq_free_sequence(scene, seq); seq = seq->next; - } else { + } + else { seq = seq->next; } } @@ -1812,7 +1824,7 @@ static int sequencer_meta_toggle_exec(bContext *C, wmOperator *UNUSED(op)) Sequence *last_seq= seq_active_get(scene); MetaStack *ms; - if(last_seq && last_seq->type==SEQ_META && last_seq->flag & SELECT) { + if (last_seq && last_seq->type==SEQ_META && last_seq->flag & SELECT) { /* Enter Metastrip */ ms= MEM_mallocN(sizeof(MetaStack), "metastack"); BLI_addtail(&ed->metastack, ms); @@ -1829,7 +1841,7 @@ static int sequencer_meta_toggle_exec(bContext *C, wmOperator *UNUSED(op)) Sequence *seq; - if(ed->metastack.first==NULL) + if (ed->metastack.first==NULL) return OPERATOR_CANCELLED; ms= ed->metastack.last; @@ -1838,7 +1850,7 @@ static int sequencer_meta_toggle_exec(bContext *C, wmOperator *UNUSED(op)) ed->seqbasep= ms->oldbasep; /* 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) calc_sequence(scene, seq); seq_active_set(scene, ms->parseq); @@ -1881,7 +1893,7 @@ static int sequencer_meta_make_exec(bContext *C, wmOperator *op) Sequence *seq, *seqm, *next, *last_seq = seq_active_get(scene); int channel_max= 1; - if(seqbase_isolated_sel_check(ed->seqbasep)==FALSE) { + if (seqbase_isolated_sel_check(ed->seqbasep)==FALSE) { BKE_report(op->reports, RPT_ERROR, "Please select all related strips"); return OPERATOR_CANCELLED; } @@ -1894,9 +1906,9 @@ static int sequencer_meta_make_exec(bContext *C, wmOperator *op) seqm->flag= SELECT; seq= ed->seqbasep->first; - while(seq) { + while (seq) { next= seq->next; - if(seq!=seqm && (seq->flag & SELECT)) { + if (seq!=seqm && (seq->flag & SELECT)) { channel_max= MAX2(seq->machine, channel_max); BLI_remlink(ed->seqbasep, seq); BLI_addtail(&seqm->seqbase, seq); @@ -1911,7 +1923,7 @@ static int sequencer_meta_make_exec(bContext *C, wmOperator *op) seq_active_set(scene, seqm); - if( seq_test_overlap(ed->seqbasep, seqm) ) shuffle_seq(ed->seqbasep, seqm, scene); + if ( seq_test_overlap(ed->seqbasep, seqm) ) shuffle_seq(ed->seqbasep, seqm, scene); seq_update_muting(ed); @@ -1956,7 +1968,7 @@ static int sequencer_meta_separate_exec(bContext *C, wmOperator *UNUSED(op)) Sequence *seq, *last_seq = seq_active_get(scene); /* last_seq checks ed==NULL */ - if(last_seq==NULL || last_seq->type!=SEQ_META) + if (last_seq==NULL || last_seq->type!=SEQ_META) return OPERATOR_CANCELLED; BLI_movelisttolist(ed->seqbasep, &last_seq->seqbase); @@ -1968,18 +1980,18 @@ static int sequencer_meta_separate_exec(bContext *C, wmOperator *UNUSED(op)) seq_free_sequence(scene, last_seq); /* emtpy meta strip, delete all effects depending on it */ - for(seq=ed->seqbasep->first; seq; seq=seq->next) - if((seq->type & SEQ_EFFECT) && seq_depends_on_meta(seq, last_seq)) + for (seq=ed->seqbasep->first; seq; seq=seq->next) + if ((seq->type & SEQ_EFFECT) && seq_depends_on_meta(seq, last_seq)) seq->flag |= SEQ_FLAG_DELETE; recurs_del_seq_flag(scene, ed->seqbasep, SEQ_FLAG_DELETE, 0); /* test for effects and overlap * don't use SEQP_BEGIN since that would be recursive */ - for(seq= ed->seqbasep->first; seq; seq= seq->next) { - if(seq->flag & SELECT) { + for (seq= ed->seqbasep->first; seq; seq= seq->next) { + if (seq->flag & SELECT) { seq->flag &= ~SEQ_OVERLAP; - if(seq_test_overlap(ed->seqbasep, seq)) { + if (seq_test_overlap(ed->seqbasep, seq)) { shuffle_seq(ed->seqbasep, seq, scene); } } @@ -2201,11 +2213,11 @@ static int sequencer_view_selected_exec(bContext *C, wmOperator *UNUSED(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) { + for (seq=ed->seqbasep->first; seq; seq=seq->next) { + if (seq->flag & SELECT) { xmin= MIN2(xmin, seq->startdisp); xmax= MAX2(xmax, seq->enddisp); @@ -2270,9 +2282,9 @@ static int find_next_prev_edit(Scene *scene, int cfra, int side) int dist, best_dist; best_dist = MAXFRAME*2; - if(ed==NULL) return cfra; + if (ed==NULL) return cfra; - for(seq= ed->seqbasep->first; seq; seq= seq->next) { + for (seq= ed->seqbasep->first; seq; seq= seq->next) { dist = MAXFRAME*2; switch (side) { @@ -2284,7 +2296,8 @@ static int find_next_prev_edit(Scene *scene, int cfra, int side) case SEQ_SIDE_RIGHT: if (seq->startdisp > cfra) { dist = seq->startdisp - cfra; - } else if (seq->startdisp == cfra) { + } + else if (seq->startdisp == cfra) { frame_seq=seq; } break; @@ -2323,7 +2336,7 @@ static int sequencer_next_edit_exec(bContext *C, wmOperator *UNUSED(op)) { Scene *scene= CTX_data_scene(C); - if(!next_prev_edit_internal(scene, SEQ_SIDE_RIGHT)) + if (!next_prev_edit_internal(scene, SEQ_SIDE_RIGHT)) return OPERATOR_CANCELLED; WM_event_add_notifier(C, NC_SCENE|ND_FRAME, scene); @@ -2353,7 +2366,7 @@ static int sequencer_previous_edit_exec(bContext *C, wmOperator *UNUSED(op)) { Scene *scene= CTX_data_scene(C); - if(!next_prev_edit_internal(scene, SEQ_SIDE_LEFT)) + if (!next_prev_edit_internal(scene, SEQ_SIDE_LEFT)) return OPERATOR_CANCELLED; WM_event_add_notifier(C, NC_SCENE|ND_FRAME, scene); @@ -2394,9 +2407,9 @@ static Sequence* sequence_find_parent(Scene* scene, Sequence* child) Sequence *parent= NULL; Sequence *seq; - if(ed==NULL) return NULL; + if (ed==NULL) return NULL; - for(seq= ed->seqbasep->first; seq; seq= seq->next) { + for (seq= ed->seqbasep->first; seq; seq= seq->next) { if ( (seq != child) && seq_is_parent(seq, child) ) { parent = seq; break; @@ -2415,11 +2428,11 @@ 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) { + if (seq) { /* disallow effect strips */ if (get_sequence_effect_num_inputs(seq->type) >= 1 && (seq->effectdata || seq->seq1 || seq->seq2 || seq->seq3)) @@ -2437,17 +2450,17 @@ static int sequencer_swap_exec(bContext *C, wmOperator *op) } // XXX - should be a generic function - for(iseq= scene->ed->seqbasep->first; iseq; iseq= iseq->next) { - if((iseq->type & SEQ_EFFECT) && (seq_is_parent(iseq, active_seq) || seq_is_parent(iseq, seq))) { + for (iseq= scene->ed->seqbasep->first; iseq; iseq= iseq->next) { + if ((iseq->type & SEQ_EFFECT) && (seq_is_parent(iseq, active_seq) || seq_is_parent(iseq, seq))) { calc_sequence(scene, iseq); } } /* do this in a new loop since both effects need to be calculated first */ - for(iseq= scene->ed->seqbasep->first; iseq; iseq= iseq->next) { - if((iseq->type & SEQ_EFFECT) && (seq_is_parent(iseq, active_seq) || seq_is_parent(iseq, seq))) { + for (iseq= scene->ed->seqbasep->first; iseq; iseq= iseq->next) { + if ((iseq->type & SEQ_EFFECT) && (seq_is_parent(iseq, active_seq) || seq_is_parent(iseq, seq))) { /* this may now overlap */ - if( seq_test_overlap(ed->seqbasep, iseq) ) { + if ( seq_test_overlap(ed->seqbasep, iseq) ) { shuffle_seq(ed->seqbasep, iseq, scene); } } @@ -2490,7 +2503,7 @@ static int sequencer_rendersize_exec(bContext *C, wmOperator *UNUSED(op)) Sequence *active_seq = seq_active_get(scene); StripElem *se = NULL; - if(active_seq==NULL) + if (active_seq==NULL) return OPERATOR_CANCELLED; @@ -2543,13 +2556,13 @@ void SEQUENCER_OT_rendersize(wmOperatorType *ot) static void seq_copy_del_sound(Scene *scene, Sequence *seq) { - if(seq->type == SEQ_META) { + if (seq->type == SEQ_META) { Sequence *iseq; - for(iseq= seq->seqbase.first; iseq; iseq= iseq->next) { + for (iseq= seq->seqbase.first; iseq; iseq= iseq->next) { seq_copy_del_sound(scene, iseq); } } - else if(seq->scene_sound) { + else if (seq->scene_sound) { sound_remove_scene_sound(scene, seq->scene_sound); seq->scene_sound = NULL; } @@ -2566,7 +2579,7 @@ static int sequencer_copy_exec(bContext *C, wmOperator *op) seq_free_clipboard(); - if(seqbase_isolated_sel_check(ed->seqbasep)==FALSE) { + if (seqbase_isolated_sel_check(ed->seqbasep)==FALSE) { BKE_report(op->reports, RPT_ERROR, "Please select all related strips"); return OPERATOR_CANCELLED; } @@ -2576,17 +2589,17 @@ static int sequencer_copy_exec(bContext *C, wmOperator *op) /* To make sure the copied strips have unique names between each other add * them temporarily to the end of the original seqbase. (bug 25932) */ - if(nseqbase.first) { + if (nseqbase.first) { 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) seq_recursive_apply(seq, apply_unique_name_cb, scene); seqbase_clipboard.first = first_seq; seqbase_clipboard.last = ed->seqbasep->last; - if(first_seq->prev) { + if (first_seq->prev) { first_seq->prev->next = NULL; ed->seqbasep->last = first_seq->prev; first_seq->prev = NULL; @@ -2596,7 +2609,7 @@ static int sequencer_copy_exec(bContext *C, wmOperator *op) seqbase_clipboard_frame= scene->r.cfra; /* Need to remove anything that references the current scene */ - for(seq= seqbase_clipboard.first; seq; seq= seq->next) { + for (seq= seqbase_clipboard.first; seq; seq= seq->next) { seq_copy_del_sound(scene, seq); } @@ -2622,13 +2635,13 @@ void SEQUENCER_OT_copy(wmOperatorType *ot) static void seq_paste_add_sound(Scene *scene, Sequence *seq) { - if(seq->type == SEQ_META) { + if (seq->type == SEQ_META) { Sequence *iseq; - for(iseq= seq->seqbase.first; iseq; iseq= iseq->next) { + for (iseq= seq->seqbase.first; iseq; iseq= iseq->next) { seq_paste_add_sound(scene, iseq); } } - else if(seq->type == SEQ_SOUND) { + else if (seq->type == SEQ_SOUND) { seq->scene_sound = sound_add_scene_sound_defaults(scene, seq); } } @@ -2647,8 +2660,8 @@ static int sequencer_paste_exec(bContext *C, wmOperator *UNUSED(op)) seqbase_dupli_recursive(scene, NULL, &nseqbase, &seqbase_clipboard, SEQ_DUPE_UNIQUE_NAME); /* transform pasted strips before adding */ - if(ofs) { - for(iseq= nseqbase.first; iseq; iseq= iseq->next) { + if (ofs) { + for (iseq= nseqbase.first; iseq; iseq= iseq->next) { seq_translate(scene, iseq, ofs); seq_sound_init(scene, iseq); } @@ -2659,7 +2672,7 @@ static int sequencer_paste_exec(bContext *C, wmOperator *UNUSED(op)) BLI_movelisttolist(ed->seqbasep, &nseqbase); /* make sure the pasted strips have unique names between them */ - for(; iseq; iseq=iseq->next) { + for (; iseq; iseq=iseq->next) { seq_recursive_apply(iseq, apply_unique_name_cb, scene); /* restore valid sound_scene for newly added strips */ @@ -2695,12 +2708,12 @@ static int sequencer_swap_data_exec(bContext *C, wmOperator *op) Sequence *seq_other; const char *error_msg; - if(seq_active_pair_get(scene, &seq_act, &seq_other) == 0) { + if (seq_active_pair_get(scene, &seq_act, &seq_other) == 0) { BKE_report(op->reports, RPT_ERROR, "Must select 2 strips"); return OPERATOR_CANCELLED; } - if(seq_swap(seq_act, seq_other, &error_msg) == 0) { + if (seq_swap(seq_act, seq_other, &error_msg) == 0) { BKE_report(op->reports, RPT_ERROR, error_msg); return OPERATOR_CANCELLED; } @@ -2714,8 +2727,8 @@ static int sequencer_swap_data_exec(bContext *C, wmOperator *op) calc_sequence(scene, seq_act); calc_sequence(scene, seq_other); - if(seq_act->sound) sound_add_scene_sound_defaults(scene, seq_act); - if(seq_other->sound) sound_add_scene_sound_defaults(scene, seq_other); + if (seq_act->sound) sound_add_scene_sound_defaults(scene, seq_act); + if (seq_other->sound) sound_add_scene_sound_defaults(scene, seq_other); WM_event_add_notifier(C, NC_SCENE|ND_SEQUENCER, scene); @@ -2752,7 +2765,7 @@ static int view_ghost_border_exec(bContext *C, wmOperator *op) UI_view2d_region_to_view(v2d, RNA_int_get(op->ptr, "xmin"), RNA_int_get(op->ptr, "ymin"), &rect.xmin, &rect.ymin); UI_view2d_region_to_view(v2d, RNA_int_get(op->ptr, "xmax"), RNA_int_get(op->ptr, "ymax"), &rect.xmax, &rect.ymax); - if(ed==NULL) + if (ed==NULL) return OPERATOR_CANCELLED; rect.xmin /= (float)(ABS(v2d->tot.xmax - v2d->tot.xmin)); @@ -2855,7 +2868,7 @@ static int sequencer_change_effect_input_exec(bContext *C, wmOperator *op) break; } - if(*seq_1 == NULL || *seq_2 == NULL) { + if (*seq_1 == NULL || *seq_2 == NULL) { BKE_report(op->reports, RPT_ERROR, "One of the effect inputs is unset, can't swap"); return OPERATOR_CANCELLED; } @@ -2958,12 +2971,12 @@ static int sequencer_change_path_exec(bContext *C, wmOperator *op) Sequence *seq= seq_active_get(scene); const int is_relative_path= RNA_boolean_get(op->ptr, "relative_path"); - if(seq->type == SEQ_IMAGE) { + if (seq->type == SEQ_IMAGE) { char directory[FILE_MAX]; const int len= RNA_property_collection_length(op->ptr, RNA_struct_find_property(op->ptr, "files")); StripElem *se; - if(len==0) + if (len==0) return OPERATOR_CANCELLED; RNA_string_get(op->ptr, "directory", directory); @@ -2975,7 +2988,7 @@ static int sequencer_change_path_exec(bContext *C, wmOperator *op) } BLI_strncpy(seq->strip->dir, directory, sizeof(seq->strip->dir)); - if(seq->strip->stripdata) { + if (seq->strip->stripdata) { MEM_freeN(seq->strip->stripdata); } seq->strip->stripdata= se= MEM_callocN(len*sizeof(StripElem), "stripelem"); @@ -3027,7 +3040,7 @@ static int sequencer_change_path_invoke(bContext *C, wmOperator *op, wmEvent *UN RNA_string_set(op->ptr, "directory", seq->strip->dir); /* set default display depending on seq type */ - if(seq->type == SEQ_IMAGE) { + if (seq->type == SEQ_IMAGE) { RNA_boolean_set(op->ptr, "filter_movie", FALSE); } else { diff --git a/source/blender/editors/space_sequencer/sequencer_scopes.c b/source/blender/editors/space_sequencer/sequencer_scopes.c index c13a5202c19..2e36c233f8e 100644 --- a/source/blender/editors/space_sequencer/sequencer_scopes.c +++ b/source/blender/editors/space_sequencer/sequencer_scopes.c @@ -240,7 +240,8 @@ struct ImBuf *make_waveform_view_from_ibuf(struct ImBuf * ibuf) { if (ibuf->rect_float) { return make_waveform_view_from_ibuf_float(ibuf); - } else { + } + else { return make_waveform_view_from_ibuf_byte(ibuf); } } @@ -353,7 +354,8 @@ struct ImBuf *make_sep_waveform_view_from_ibuf(struct ImBuf * ibuf) { if (ibuf->rect_float) { return make_sep_waveform_view_from_ibuf_float(ibuf); - } else { + } + else { return make_sep_waveform_view_from_ibuf_byte(ibuf); } } @@ -426,7 +428,8 @@ struct ImBuf * make_zebra_view_from_ibuf(struct ImBuf * src, float perc) if (src->rect_float) { draw_zebra_float(src, ibuf, perc); - } else { + } + else { draw_zebra_byte(src, ibuf, perc); } return ibuf; @@ -508,7 +511,8 @@ static int get_bin_float(float f) { if (f < -0.25f) { f = -0.25f; - } else if (f > 1.25f) { + } + else if (f > 1.25f) { f = 1.25f; } @@ -561,7 +565,8 @@ struct ImBuf *make_histogram_view_from_ibuf(struct ImBuf * ibuf) { if (ibuf->rect_float) { return make_histogram_view_from_ibuf_float(ibuf); - } else { + } + else { return make_histogram_view_from_ibuf_byte(ibuf); } } @@ -696,7 +701,8 @@ struct ImBuf *make_vectorscope_view_from_ibuf(struct ImBuf * ibuf) { if (ibuf->rect_float) { return make_vectorscope_view_from_ibuf_float(ibuf); - } else { + } + else { return make_vectorscope_view_from_ibuf_byte(ibuf); } } diff --git a/source/blender/editors/space_sequencer/sequencer_select.c b/source/blender/editors/space_sequencer/sequencer_select.c index e93eb0e0a0e..c111870b5bb 100644 --- a/source/blender/editors/space_sequencer/sequencer_select.c +++ b/source/blender/editors/space_sequencer/sequencer_select.c @@ -89,8 +89,8 @@ static void select_active_side(ListBase *seqbase, int sel_side, int channel, int { Sequence *seq; - for(seq= seqbase->first; seq; seq=seq->next) { - if(channel==seq->machine) { + for (seq= seqbase->first; seq; seq=seq->next) { + if (channel==seq->machine) { switch(sel_side) { case SEQ_SIDE_LEFT: if (frame > (seq->startdisp)) { @@ -117,27 +117,27 @@ static void select_linked_time(ListBase *seqbase, Sequence *seq_link) { Sequence *seq; - for(seq= seqbase->first; seq; seq=seq->next) { - if(seq_link->machine != seq->machine) { + for (seq= seqbase->first; seq; seq=seq->next) { + if (seq_link->machine != seq->machine) { int left_match = (seq->startdisp == seq_link->startdisp) ? 1:0; int right_match = (seq->enddisp == seq_link->enddisp) ? 1:0; - if(left_match && right_match) { + if (left_match && right_match) { /* a direct match, copy the selection settinhs */ seq->flag &= ~(SELECT|SEQ_LEFTSEL|SEQ_RIGHTSEL); seq->flag |= seq_link->flag & (SELECT|SEQ_LEFTSEL|SEQ_RIGHTSEL); recurs_sel_seq(seq); } - else if(seq_link->flag & SELECT && (left_match || right_match)) { + else if (seq_link->flag & SELECT && (left_match || right_match)) { /* 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); @@ -163,16 +163,16 @@ static void UNUSED_FUNCTION(select_single_seq)(Scene *scene, Sequence *seq, int { Editing *ed= seq_give_editing(scene, FALSE); - if(deselect_all) + if (deselect_all) deselect_all_seq(scene); seq_active_set(scene, seq); - if((seq->type==SEQ_IMAGE) || (seq->type==SEQ_MOVIE)) { - if(seq->strip) + if ((seq->type==SEQ_IMAGE) || (seq->type==SEQ_MOVIE)) { + if (seq->strip) BLI_strncpy(ed->act_imagedir, seq->strip->dir, FILE_MAXDIR); } - else if(seq->type==SEQ_SOUND) { - if(seq->strip) + else if (seq->type==SEQ_SOUND) { + if (seq->strip) BLI_strncpy(ed->act_sounddir, seq->strip->dir, FILE_MAXDIR); } seq->flag|= SELECT; @@ -281,7 +281,7 @@ static int sequencer_select_inverse_exec(bContext *C, wmOperator *UNUSED(op)) Editing *ed= seq_give_editing(scene, FALSE); Sequence *seq; - for(seq= ed->seqbasep->first; seq; seq=seq->next) { + for (seq= ed->seqbasep->first; seq; seq=seq->next) { if (seq->flag & SELECT) { seq->flag &= ~SEQ_ALLSEL; } @@ -325,7 +325,7 @@ static int sequencer_select_invoke(bContext *C, wmOperator *op, wmEvent *event) 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 @@ -333,7 +333,7 @@ static int sequencer_select_invoke(bContext *C, wmOperator *op, wmEvent *event) 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) + if (seq && linked_time && left_right) left_right= FALSE; @@ -352,7 +352,8 @@ static int sequencer_select_invoke(bContext *C, wmOperator *op, wmEvent *event) marker->flag |= SELECT; } - } else if (left_right) { + } + else if (left_right) { /* use different logic for this */ float x; deselect_all_seq(scene); @@ -360,13 +361,13 @@ static int sequencer_select_invoke(bContext *C, wmOperator *op, wmEvent *event) SEQP_BEGIN(ed, seq) { if (x < CFRA) { - if(seq->enddisp < CFRA) { + if (seq->enddisp < CFRA) { seq->flag |= SELECT; recurs_sel_seq(seq); } } else { - if(seq->startdisp > CFRA) { + if (seq->startdisp > CFRA) { seq->flag |= SELECT; recurs_sel_seq(seq); } @@ -380,7 +381,7 @@ static int sequencer_select_invoke(bContext *C, wmOperator *op, wmEvent *event) TimeMarker *tmarker; for (tmarker= scene->markers.first; tmarker; tmarker= tmarker->next) { - if( ((x < CFRA) && tmarker->frame < CFRA) || + if ( ((x < CFRA) && tmarker->frame < CFRA) || ((x >= CFRA) && tmarker->frame >= CFRA) ) { tmarker->flag |= SELECT; @@ -391,29 +392,31 @@ static int sequencer_select_invoke(bContext *C, wmOperator *op, wmEvent *event) } } } - } else { + } + else { // seq= find_nearest_seq(scene, v2d, &hand, mval); act_orig= ed->act_seq; - if(extend == 0 && linked_handle==0) + if (extend == 0 && linked_handle==0) deselect_all_seq(scene); - if(seq) { + if (seq) { seq_active_set(scene, seq); if ((seq->type == SEQ_IMAGE) || (seq->type == SEQ_MOVIE)) { - if(seq->strip) { + if (seq->strip) { BLI_strncpy(ed->act_imagedir, seq->strip->dir, FILE_MAXDIR); } - } else + } + else if (seq->type == SEQ_SOUND) { - if(seq->strip) { + if (seq->strip) { BLI_strncpy(ed->act_sounddir, seq->strip->dir, FILE_MAXDIR); } } - if(extend && (seq->flag & SELECT) && ed->act_seq == act_orig ) { + if (extend && (seq->flag & SELECT) && ed->act_seq == act_orig ) { switch(hand) { case SEQ_SIDE_NONE: if (linked_handle==0) @@ -429,13 +432,13 @@ static int sequencer_select_invoke(bContext *C, wmOperator *op, wmEvent *event) } 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; } /* On Alt selection, select the strip and bordering handles */ if (linked_handle && !ELEM(hand, SEQ_SIDE_LEFT, SEQ_SIDE_RIGHT)) { - if(extend==0) deselect_all_seq(scene); + if (extend==0) deselect_all_seq(scene); seq->flag |= SELECT; select_surrounding_handles(scene, seq); } @@ -451,12 +454,13 @@ static int sequencer_select_invoke(bContext *C, wmOperator *op, wmEvent *event) switch (sel_side) { case SEQ_SIDE_LEFT: if ((seq->flag & SEQ_LEFTSEL) && (neighbor->flag & SEQ_RIGHTSEL)) { - if(extend==0) deselect_all_seq(scene); + if (extend==0) deselect_all_seq(scene); seq->flag |= SELECT; select_active_side(ed->seqbasep, SEQ_SIDE_LEFT, seq->machine, seq->startdisp); - } else { - if(extend==0) deselect_all_seq(scene); + } + else { + if (extend==0) deselect_all_seq(scene); seq->flag |= SELECT; neighbor->flag |= SELECT; @@ -467,12 +471,13 @@ static int sequencer_select_invoke(bContext *C, wmOperator *op, wmEvent *event) break; case SEQ_SIDE_RIGHT: if ((seq->flag & SEQ_RIGHTSEL) && (neighbor->flag & SEQ_LEFTSEL)) { - if(extend==0) deselect_all_seq(scene); + if (extend==0) deselect_all_seq(scene); seq->flag |= SELECT; select_active_side(ed->seqbasep, SEQ_SIDE_RIGHT, seq->machine, seq->startdisp); - } else { - if(extend==0) deselect_all_seq(scene); + } + else { + if (extend==0) deselect_all_seq(scene); seq->flag |= SELECT; neighbor->flag |= SELECT; @@ -482,14 +487,15 @@ static int sequencer_select_invoke(bContext *C, wmOperator *op, wmEvent *event) } break; } - } else { - if(extend==0) deselect_all_seq(scene); + } + else { + if (extend==0) deselect_all_seq(scene); select_active_side(ed->seqbasep, sel_side, seq->machine, seq->startdisp); } } recurs_sel_seq(seq); - if(linked_time) { + if (linked_time) { select_linked_time(ed->seqbasep, seq); } } @@ -505,7 +511,7 @@ static int sequencer_select_invoke(bContext *C, wmOperator *op, wmEvent *event) while(get_mbut()) { // getmouseco_areawin(mval); - if(abs(mval[0]-xo)+abs(mval[1]-yo) > 4) { + if (abs(mval[0]-xo)+abs(mval[1]-yo) > 4) { transform_markers('g', 0); return; } @@ -552,25 +558,26 @@ static int select_more_less_seq__internal(Scene *scene, int sel, int linked) int change=0; int isel; - if(ed==NULL) return 0; + if (ed==NULL) return 0; if (sel) { sel = SELECT; isel = 0; - } else { + } + else { sel = 0; isel = SELECT; } if (!linked) { /* if not linked we only want to touch each seq once, newseq */ - for(seq= ed->seqbasep->first; seq; seq= seq->next) { + for (seq= ed->seqbasep->first; seq; seq= seq->next) { seq->tmp = NULL; } } - for(seq= ed->seqbasep->first; seq; seq= seq->next) { - if((int)(seq->flag & SELECT) == sel) { + for (seq= ed->seqbasep->first; seq; seq= seq->next) { + if ((int)(seq->flag & SELECT) == sel) { if ((linked==0 && seq->tmp)==0) { /* only get unselected nabours */ neighbor = find_neighboring_sequence(scene, seq, SEQ_SIDE_LEFT, isel); @@ -601,7 +608,7 @@ static int sequencer_select_more_exec(bContext *C, wmOperator *UNUSED(op)) { Scene *scene= CTX_data_scene(C); - if(!select_more_less_seq__internal(scene, 0, 0)) + if (!select_more_less_seq__internal(scene, 0, 0)) return OPERATOR_CANCELLED; WM_event_add_notifier(C, NC_SCENE|ND_SEQUENCER|NA_SELECTED, scene); @@ -632,7 +639,7 @@ static int sequencer_select_less_exec(bContext *C, wmOperator *UNUSED(op)) { Scene *scene= CTX_data_scene(C); - if(!select_more_less_seq__internal(scene, 1, 0)) + if (!select_more_less_seq__internal(scene, 1, 0)) return OPERATOR_CANCELLED; WM_event_add_notifier(C, NC_SCENE|ND_SEQUENCER|NA_SELECTED, scene); @@ -752,7 +759,7 @@ static int sequencer_select_handles_exec(bContext *C, wmOperator *op) int sel_side= RNA_enum_get(op->ptr, "side"); - for(seq= ed->seqbasep->first; seq; seq=seq->next) { + for (seq= ed->seqbasep->first; seq; seq=seq->next) { if (seq->flag & SELECT) { switch(sel_side) { case SEQ_SIDE_LEFT: @@ -845,7 +852,7 @@ static int sequencer_borderselect_exec(bContext *C, wmOperator *op) int extend = RNA_boolean_get(op->ptr, "extend"); int mval[2]; - if(ed==NULL) + if (ed==NULL) return OPERATOR_CANCELLED; rect.xmin = RNA_int_get(op->ptr, "xmin"); @@ -860,15 +867,15 @@ static int sequencer_borderselect_exec(bContext *C, wmOperator *op) mval[1]= rect.ymax; UI_view2d_region_to_view(v2d, mval[0], mval[1], &rectf.xmax, &rectf.ymax); - for(seq= ed->seqbasep->first; seq; seq= seq->next) { + for (seq= ed->seqbasep->first; seq; seq= seq->next) { seq_rectf(seq, &rq); - if(BLI_isect_rctf(&rq, &rectf, NULL)) { - if(selecting) seq->flag |= SELECT; + if (BLI_isect_rctf(&rq, &rectf, NULL)) { + if (selecting) seq->flag |= SELECT; else seq->flag &= ~SEQ_ALLSEL; recurs_sel_seq(seq); } - else if(!extend) { + else if (!extend) { seq->flag &= ~SEQ_ALLSEL; recurs_sel_seq(seq); } @@ -1025,9 +1032,9 @@ static short select_grouped_effect(Editing *ed, Sequence *actseq) SEQP_BEGIN(ed, seq) { if (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; } } @@ -1069,7 +1076,7 @@ static short select_grouped_effect_link(Editing *ed, Sequence *actseq) actseq->tmp= SET_INT_IN_POINTER(TRUE); - for(seq_begin(ed, &iter, 1); iter.valid; seq_next(&iter)) { + for (seq_begin(ed, &iter, 1); iter.valid; seq_next(&iter)) { seq = iter.seq; /* Ignore all seqs already selected! */ @@ -1133,13 +1140,13 @@ static int sequencer_select_grouped_exec(bContext *C, wmOperator *op) SEQ_END; } - if(type==1) changed |= select_grouped_type(ed, actseq); - else if(type==2) changed |= select_grouped_type_basic(ed, actseq); - else if(type==3) changed |= select_grouped_type_effect(ed, actseq); - else if(type==4) changed |= select_grouped_data(ed, actseq); - else if(type==5) changed |= select_grouped_effect(ed, actseq); - else if(type==6) changed |= select_grouped_effect_link(ed, actseq); - else if(type==7) changed |= select_grouped_time_overlap(ed, actseq); + if (type==1) changed |= select_grouped_type(ed, actseq); + else if (type==2) changed |= select_grouped_type_basic(ed, actseq); + else if (type==3) changed |= select_grouped_type_effect(ed, actseq); + else if (type==4) changed |= select_grouped_data(ed, actseq); + else if (type==5) changed |= select_grouped_effect(ed, actseq); + else if (type==6) changed |= select_grouped_effect_link(ed, actseq); + else if (type==7) changed |= select_grouped_time_overlap(ed, actseq); if (changed) { WM_event_add_notifier(C, NC_SCENE|ND_SEQUENCER|NA_SELECTED, scene); diff --git a/source/blender/editors/space_sequencer/space_sequencer.c b/source/blender/editors/space_sequencer/space_sequencer.c index dd4315e6651..fe6ff40922e 100644 --- a/source/blender/editors/space_sequencer/space_sequencer.c +++ b/source/blender/editors/space_sequencer/space_sequencer.c @@ -65,13 +65,13 @@ 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"); @@ -88,8 +88,8 @@ 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; @@ -186,7 +186,7 @@ static void sequencer_free(SpaceLink *UNUSED(sl)) { // SpaceSeq *sseq= (SpaceSequencer*) sl; -// XXX if(sseq->gpd) free_gpencil_data(sseq->gpd); +// XXX if (sseq->gpd) free_gpencil_data(sseq->gpd); } @@ -273,7 +273,7 @@ static void sequencer_refresh(const bContext *C, ScrArea *sa) break; } - if(view_changed) { + if (view_changed) { ED_area_initialize(wm, window, sa); ED_area_tag_redraw(sa); } @@ -326,24 +326,24 @@ static void sequencer_main_area_draw(const bContext *C, ARegion *ar) static int image_drop_poll(bContext *UNUSED(C), wmDrag *drag, wmEvent *UNUSED(event)) { - if(drag->type==WM_DRAG_PATH) - if(ELEM(drag->icon, ICON_FILE_IMAGE, ICON_FILE_BLANK)) /* rule might not work? */ + if (drag->type==WM_DRAG_PATH) + if (ELEM(drag->icon, ICON_FILE_IMAGE, ICON_FILE_BLANK)) /* rule might not work? */ return 1; return 0; } static int movie_drop_poll(bContext *UNUSED(C), wmDrag *drag, wmEvent *UNUSED(event)) { - if(drag->type==WM_DRAG_PATH) - if(ELEM3(drag->icon, 0, ICON_FILE_MOVIE, ICON_FILE_BLANK)) /* rule might not work? */ + if (drag->type==WM_DRAG_PATH) + if (ELEM3(drag->icon, 0, ICON_FILE_MOVIE, ICON_FILE_BLANK)) /* rule might not work? */ return 1; return 0; } static int sound_drop_poll(bContext *UNUSED(C), wmDrag *drag, wmEvent *UNUSED(event)) { - if(drag->type==WM_DRAG_PATH) - if(ELEM(drag->icon, ICON_FILE_SOUND, ICON_FILE_BLANK)) /* rule might not work? */ + if (drag->type==WM_DRAG_PATH) + if (ELEM(drag->icon, ICON_FILE_SOUND, ICON_FILE_BLANK)) /* rule might not work? */ return 1; return 0; } @@ -351,10 +351,10 @@ static int sound_drop_poll(bContext *UNUSED(C), wmDrag *drag, wmEvent *UNUSED(ev 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")) { + if (RNA_struct_find_property(drop->ptr, "directory")) { PointerRNA itemptr; char dir[FILE_MAX], file[FILE_MAX]; @@ -407,11 +407,11 @@ static void sequencer_main_area_listener(ARegion *ar, wmNotifier *wmn) } 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; } @@ -443,15 +443,15 @@ static void sequencer_preview_area_draw(const bContext *C, ARegion *ar) draw_image_seq(C, scene, ar, sseq, scene->r.cfra, 0); - if(scene->ed && scene->ed->over_flag & SEQ_EDIT_OVERLAY_SHOW && sseq->mainb == SEQ_DRAW_IMG_IMBUF) { + if (scene->ed && scene->ed->over_flag & SEQ_EDIT_OVERLAY_SHOW && sseq->mainb == SEQ_DRAW_IMG_IMBUF) { 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 over_cfra= scene->r.cfra + scene->ed->over_ofs; - if(over_cfra != scene->r.cfra) + if (over_cfra != scene->r.cfra) draw_image_seq(C, scene, ar, sseq, scene->r.cfra, over_cfra - scene->r.cfra); } @@ -471,7 +471,7 @@ static void sequencer_preview_area_listener(ARegion *ar, wmNotifier *wmn) } 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: @@ -512,11 +512,11 @@ static void sequencer_buttons_area_listener(ARegion *ar, wmNotifier *wmn) } 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; } @@ -590,7 +590,7 @@ void ED_spacetype_sequencer(void) BKE_spacetype_register(st); /* set the sequencer callback when not in background mode */ - if(G.background==0) { + if (G.background==0) { sequencer_view3d_cb = ED_view3d_draw_offscreen_imbuf_simple; } } diff --git a/source/blender/editors/space_text/space_text.c b/source/blender/editors/space_text/space_text.c index d06a8139b6f..cc9ce10d017 100644 --- a/source/blender/editors/space_text/space_text.c +++ b/source/blender/editors/space_text/space_text.c @@ -129,7 +129,7 @@ static void text_listener(ScrArea *sa, wmNotifier *wmn) /* check if active text was changed, no need to redraw if text isn't active * reference==NULL means text was unlinked, should update anyway for this * case -- no way to know was text active before unlinking or not */ - if(wmn->reference && wmn->reference != st->text) + if (wmn->reference && wmn->reference != st->text) break; switch(wmn->data) { @@ -137,7 +137,7 @@ static void text_listener(ScrArea *sa, wmNotifier *wmn) ED_area_tag_redraw(sa); break; case ND_CURSOR: - if(st->text && st->text == wmn->reference) + if (st->text && st->text == wmn->reference) text_scroll_to_cursor(st, sa); ED_area_tag_redraw(sa); @@ -146,7 +146,7 @@ static void text_listener(ScrArea *sa, wmNotifier *wmn) switch(wmn->action) { case NA_EDITED: - if(st->text) { + if (st->text) { text_drawcache_tag_update(st, 1); text_update_edited(st->text); } @@ -158,7 +158,7 @@ static void text_listener(ScrArea *sa, wmNotifier *wmn) ED_area_tag_redraw(sa); break; case NA_SELECTED: - if(st->text && st->text == wmn->reference) + if (st->text && st->text == wmn->reference) text_scroll_to_cursor(st, sa); break; @@ -166,7 +166,7 @@ static void text_listener(ScrArea *sa, wmNotifier *wmn) break; case NC_SPACE: - if(wmn->data == ND_SPACE_TEXT) + if (wmn->data == ND_SPACE_TEXT) ED_area_tag_redraw(sa); break; } @@ -298,7 +298,7 @@ static void text_keymap(struct wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "TEXT_OT_copy", INSERTKEY, KM_PRESS, KM_CTRL, 0); WM_keymap_add_item(keymap, "TEXT_OT_paste", INSERTKEY, KM_PRESS, KM_SHIFT, 0); - if(U.uiflag & USER_MMB_PASTE) { // XXX not dynamic + if (U.uiflag & USER_MMB_PASTE) { // XXX not dynamic kmi = WM_keymap_add_item(keymap, "TEXT_OT_paste", MIDDLEMOUSE, KM_PRESS, 0, 0); RNA_boolean_set(kmi->ptr, "selection", TRUE); } @@ -388,11 +388,11 @@ static int text_context(const bContext *C, const char *member, bContextDataResul { SpaceText *st= CTX_wm_space_text(C); - if(CTX_data_dir(member)) { + if (CTX_data_dir(member)) { CTX_data_dir_set(result, text_context_dir); return 1; } - else if(CTX_data_equals(member, "edit_text")) { + else if (CTX_data_equals(member, "edit_text")) { CTX_data_id_pointer_set(result, &st->text->id); return 1; } @@ -452,8 +452,8 @@ static void text_cursor(wmWindow *win, ScrArea *UNUSED(sa), ARegion *UNUSED(ar)) static int text_drop_poll(bContext *UNUSED(C), wmDrag *drag, wmEvent *UNUSED(event)) { - if(drag->type==WM_DRAG_PATH) - if(ELEM(drag->icon, ICON_FILE_SCRIPT, ICON_FILE_BLANK)) /* rule might not work? */ + if (drag->type==WM_DRAG_PATH) + if (ELEM(drag->icon, ICON_FILE_SCRIPT, ICON_FILE_BLANK)) /* rule might not work? */ return 1; return 0; } diff --git a/source/blender/editors/space_text/text_draw.c b/source/blender/editors/space_text/text_draw.c index 20f2654971b..b2259aac035 100644 --- a/source/blender/editors/space_text/text_draw.c +++ b/source/blender/editors/space_text/text_draw.c @@ -111,7 +111,7 @@ static void flatten_string_append(FlattenString *fs, const char *c, int accum, i { int i; - if(fs->pos+len > fs->len) { + if (fs->pos+len > fs->len) { char *nbuf; int *naccum; fs->len*= 2; @@ -121,7 +121,7 @@ static void flatten_string_append(FlattenString *fs, const char *c, int accum, i memcpy(nbuf, fs->buf, fs->pos * sizeof(*fs->buf)); memcpy(naccum, fs->accum, fs->pos * sizeof(*fs->accum)); - if(fs->buf != fs->fixedbuf) { + if (fs->buf != fs->fixedbuf) { MEM_freeN(fs->buf); MEM_freeN(fs->accum); } @@ -148,12 +148,12 @@ int flatten_string(SpaceText *st, FlattenString *fs, const char *in) fs->accum= fs->fixedaccum; fs->len = sizeof(fs->fixedbuf); - for(r = 0, i = 0; *in; r++) { - if(*in=='\t') { + for (r = 0, i = 0; *in; r++) { + if (*in=='\t') { i= st->tabnumber - (total%st->tabnumber); total+= i; - while(i--) + while (i--) flatten_string_append(fs, " ", r, 1); in++; @@ -173,9 +173,9 @@ int flatten_string(SpaceText *st, FlattenString *fs, const char *in) void flatten_string_free(FlattenString *fs) { - if(fs->buf != fs->fixedbuf) + if (fs->buf != fs->fixedbuf) MEM_freeN(fs->buf); - if(fs->accum != fs->fixedaccum) + if (fs->accum != fs->fixedaccum) MEM_freeN(fs->accum); } @@ -195,25 +195,25 @@ static int find_builtinfunc(char *string) "is", "lambda", "not", "or", "pass", "print", "raise", "return", "try", "while", "yield", "with"}; - for(a=0; a < sizeof(builtinfuncs)/sizeof(builtinfuncs[0]); a++) { + for (a=0; a < sizeof(builtinfuncs)/sizeof(builtinfuncs[0]); a++) { i = 0; - while(1) { + while (1) { /* If we hit the end of a keyword... (eg. "def") */ - if(builtinfuncs[a][i]=='\0') { + if (builtinfuncs[a][i]=='\0') { /* If we still have identifier chars in the source (eg. "definate") */ - if(text_check_identifier(string[i])) + if (text_check_identifier(string[i])) i = -1; /* No match */ break; /* Next keyword if no match, otherwise we're done */ /* If chars mismatch, move on to next keyword */ } - else if(string[i]!=builtinfuncs[a][i]) { + else if (string[i]!=builtinfuncs[a][i]) { i = -1; break; /* Break inner loop, start next keyword */ } i++; } - if(i>0) break; /* If we have a match, we're done */ + if (i>0) break; /* If we have a match, we're done */ } return i; } @@ -229,22 +229,22 @@ static int find_specialvar(char *string) { int i = 0; /* Check for "def" */ - if(string[0]=='d' && string[1]=='e' && string[2]=='f') + if (string[0]=='d' && string[1]=='e' && string[2]=='f') i = 3; /* Check for "class" */ - else if(string[0]=='c' && string[1]=='l' && string[2]=='a' && string[3]=='s' && string[4]=='s') + else if (string[0]=='c' && string[1]=='l' && string[2]=='a' && string[3]=='s' && string[4]=='s') i = 5; /* If next source char is an identifier (eg. 'i' in "definate") no match */ - if(i==0 || text_check_identifier(string[i])) + if (i==0 || text_check_identifier(string[i])) return -1; return i; } static int find_decorator(char *string) { - if(string[0] == '@') { + if (string[0] == '@') { int i = 1; - while(text_check_identifier(string[i])) { + while (text_check_identifier(string[i])) { i++; } return i; @@ -256,16 +256,16 @@ static int find_bool(char *string) { int i = 0; /* Check for "False" */ - if(string[0]=='F' && string[1]=='a' && string[2]=='l' && string[3]=='s' && string[4]=='e') + if (string[0]=='F' && string[1]=='a' && string[2]=='l' && string[3]=='s' && string[4]=='e') i = 5; /* Check for "True" */ - else if(string[0]=='T' && string[1]=='r' && string[2]=='u' && string[3]=='e') + else if (string[0]=='T' && string[1]=='r' && string[2]=='u' && string[3]=='e') i = 4; /* Check for "None" */ - else if(string[0]=='N' && string[1]=='o' && string[2]=='n' && string[3]=='e') + else if (string[0]=='N' && string[1]=='o' && string[2]=='n' && string[3]=='e') i = 4; /* If next source char is an identifier (eg. 'i' in "definate") no match */ - if(i==0 || text_check_identifier(string[i])) + if (i==0 || text_check_identifier(string[i])) return -1; return i; } @@ -274,16 +274,16 @@ static int find_bool(char *string) * as needed. Allocation is done here, alone, to ensure consistency. */ static int text_check_format_len(TextLine *line, unsigned int len) { - if(line->format) { - if(strlen(line->format) < len) { + if (line->format) { + if (strlen(line->format) < len) { MEM_freeN(line->format); line->format = MEM_mallocN(len+2, "SyntaxFormat"); - if(!line->format) return 0; + if (!line->format) return 0; } } else { line->format = MEM_mallocN(len+2, "SyntaxFormat"); - if(!line->format) return 0; + if (!line->format) return 0; } return 1; @@ -310,14 +310,14 @@ static void txt_format_line(SpaceText *st, TextLine *line, int do_next) int len, i; /* Get continuation from previous line */ - if(line->prev && line->prev->format != NULL) { + if (line->prev && line->prev->format != NULL) { fmt= line->prev->format; cont = fmt[strlen(fmt)+1]; /* Just after the null-terminator */ } else cont = 0; /* Get original continuation from this line */ - if(line->format != NULL) { + if (line->format != NULL) { fmt= line->format; orig = fmt[strlen(fmt)+1]; /* Just after the null-terminator */ } @@ -325,26 +325,26 @@ static void txt_format_line(SpaceText *st, TextLine *line, int do_next) len = flatten_string(st, &fs, line->line); str = fs.buf; - if(!text_check_format_len(line, len)) { + if (!text_check_format_len(line, len)) { flatten_string_free(&fs); return; } fmt = line->format; - while(*str) { + while (*str) { /* Handle escape sequences by skipping both \ and next char */ - if(*str == '\\') { + if (*str == '\\') { *fmt = prev; fmt++; str++; - if(*str == '\0') break; + if (*str == '\0') break; *fmt = prev; fmt++; str += BLI_str_utf8_size(str); continue; } /* Handle continuations */ - else if(cont) { + else if (cont) { /* Triple strings ("""...""" or '''...''') */ - if(cont & TXT_TRISTR) { + if (cont & TXT_TRISTR) { find = (cont & TXT_DBLQUOTSTR) ? '"' : '\''; - if(*str==find && *(str+1)==find && *(str+2)==find) { + if (*str==find && *(str+1)==find && *(str+2)==find) { *fmt = 'l'; fmt++; str++; *fmt = 'l'; fmt++; str++; cont = 0; @@ -353,7 +353,7 @@ static void txt_format_line(SpaceText *st, TextLine *line, int do_next) } else { find = (cont & TXT_DBLQUOTSTR) ? '"' : '\''; - if(*str == find) cont = 0; + if (*str == find) cont = 0; } *fmt = 'l'; @@ -362,14 +362,15 @@ static void txt_format_line(SpaceText *st, TextLine *line, int do_next) /* Not in a string... */ else { /* Deal with comments first */ - if(prev == '#' || *str == '#') { + if (prev == '#' || *str == '#') { *fmt = '#'; str += BLI_str_utf8_size(str) - 1; - } else if(*str == '"' || *str == '\'') { + } + else if (*str == '"' || *str == '\'') { /* Strings */ find = *str; cont = (*str== '"') ? TXT_DBLQUOTSTR : TXT_SNGQUOTSTR; - if(*(str+1) == find && *(str+2) == find) { + if (*(str+1) == find && *(str+2) == find) { *fmt = 'l'; fmt++; str++; *fmt = 'l'; fmt++; str++; cont |= TXT_TRISTR; @@ -377,15 +378,15 @@ static void txt_format_line(SpaceText *st, TextLine *line, int do_next) *fmt = 'l'; } /* Whitespace (all ws. has been converted to spaces) */ - else if(*str == ' ') + else if (*str == ' ') *fmt = '_'; /* Numbers (digits not part of an identifier and periods followed by digits) */ - else if((prev != 'q' && text_check_digit(*str)) || (*str == '.' && text_check_digit(*(str+1)))) + else if ((prev != 'q' && text_check_digit(*str)) || (*str == '.' && text_check_digit(*(str+1)))) *fmt = 'n'; /* Booleans */ - else if(prev != 'q' && (i=find_bool(str)) != -1) - if(i>0) { - while(i>1) { + else if (prev != 'q' && (i=find_bool(str)) != -1) + if (i>0) { + while (i>1) { *fmt = 'n'; fmt++; str++; i--; } @@ -396,24 +397,24 @@ static void txt_format_line(SpaceText *st, TextLine *line, int do_next) *fmt = 'q'; } /* Punctuation */ - else if(text_check_delim(*str)) + else if (text_check_delim(*str)) *fmt = '!'; /* Identifiers and other text (no previous ws. or delims. so text continues) */ - else if(prev == 'q') { + else if (prev == 'q') { str += BLI_str_utf8_size(str) - 1; *fmt = 'q'; } /* Not ws, a digit, punct, or continuing text. Must be new, check for special words */ else { /* Special vars(v) or built-in keywords(b) */ - if((i=find_specialvar(str)) != -1) + if ((i=find_specialvar(str)) != -1) prev = 'v'; - else if((i=find_builtinfunc(str)) != -1) + else if ((i=find_builtinfunc(str)) != -1) prev = 'b'; - else if((i=find_decorator(str)) != -1) + else if ((i=find_decorator(str)) != -1) prev = 'v'; /* could have a new color for this */ - if(i>0) { - while(i>1) { + if (i>0) { + while (i>1) { *fmt = prev; fmt++; str++; i--; } @@ -435,7 +436,7 @@ static void txt_format_line(SpaceText *st, TextLine *line, int do_next) *fmt = cont; /* If continuation has changed and we're allowed, process the next line */ - if(cont!=orig && do_next && line->next) { + if (cont!=orig && do_next && line->next) { txt_format_line(st, line->next, do_next); } @@ -448,9 +449,9 @@ static void txt_format_text(SpaceText *st) { TextLine *linep; - if(!st->text) return; + if (!st->text) return; - for(linep=st->text->lines.first; linep; linep=linep->next) + for (linep=st->text->lines.first; linep; linep=linep->next) txt_format_line(st, linep, 0); } #endif @@ -532,27 +533,28 @@ void wrap_offset(SpaceText *st, ARegion *ar, TextLine *linein, int cursin, int * *offl= *offc= 0; - if(!st->text) return; - if(!st->wordwrap) return; + if (!st->text) return; + if (!st->wordwrap) return; text= st->text; /* Move pointer to first visible line (top) */ linep= text->lines.first; i= st->top; - while(i>0 && linep) { + while (i>0 && linep) { int lines= text_get_visible_lines(st, ar, linep->line); /* Line before top */ - if(linep == linein) { - if(lines <= i) + if (linep == linein) { + if (lines <= i) /* no visible part of line */ return; } if (i-lines<0) { break; - } else { + } + else { linep= linep->next; (*offl)+= lines-1; i-= lines; @@ -562,28 +564,28 @@ void wrap_offset(SpaceText *st, ARegion *ar, TextLine *linein, int cursin, int * max= wrap_width(st, ar); cursin = txt_utf8_offset_to_index(linein->line, cursin); - while(linep) { + while (linep) { start= 0; end= max; chop= 1; *offc= 0; - for(i=0, j=0; linep->line[j]; j+=BLI_str_utf8_size(linep->line+j)) { + for (i=0, j=0; linep->line[j]; j+=BLI_str_utf8_size(linep->line+j)) { int chars; /* Mimic replacement of tabs */ ch= linep->line[j]; - if(ch=='\t') { + if (ch=='\t') { chars= st->tabnumber-i%st->tabnumber; - if(linep==linein && i=max) { - if(chop && linep==linein && i >= cursin) { + while (chars--) { + if (i-start>=max) { + if (chop && linep==linein && i >= cursin) { if (i==cursin) { (*offl)++; *offc -= end-start; @@ -599,16 +601,16 @@ void wrap_offset(SpaceText *st, ARegion *ar, TextLine *linein, int cursin, int * end += max; chop= 1; } - else if(ch==' ' || ch=='-') { + else if (ch==' ' || ch=='-') { end = i+1; chop= 0; - if(linep==linein && i >= cursin) + if (linep==linein && i >= cursin) return; } i++; } } - if(linep==linein) break; + if (linep==linein) break; linep= linep->next; } } @@ -621,8 +623,8 @@ void wrap_offset_in_line(SpaceText *st, ARegion *ar, TextLine *linein, int cursi *offl= *offc= 0; - if(!st->text) return; - if(!st->wordwrap) return; + if (!st->text) return; + if (!st->wordwrap) return; max= wrap_width(st, ar); @@ -632,21 +634,21 @@ void wrap_offset_in_line(SpaceText *st, ARegion *ar, TextLine *linein, int cursi *offc= 0; cursin = txt_utf8_offset_to_index(linein->line, cursin); - for(i=0, j=0; linein->line[j]; j += BLI_str_utf8_size(linein->line + j)) { + for (i=0, j=0; linein->line[j]; j += BLI_str_utf8_size(linein->line + j)) { /* Mimic replacement of tabs */ ch= linein->line[j]; - if(ch=='\t') { + if (ch=='\t') { chars= st->tabnumber-i%st->tabnumber; - if(i=max) { - if(chop && i >= cursin) { + while (chars--) { + if (i-start>=max) { + if (chop && i >= cursin) { if (i==cursin) { (*offl)++; *offc -= end-start; @@ -662,10 +664,10 @@ void wrap_offset_in_line(SpaceText *st, ARegion *ar, TextLine *linein, int cursi end += max; chop= 1; } - else if(ch==' ' || ch=='-') { + else if (ch==' ' || ch=='-') { end = i+1; chop= 0; - if(i >= cursin) + if (i >= cursin) return; } i++; @@ -677,8 +679,8 @@ int text_get_char_pos(SpaceText *st, const char *line, int cur) { int a=0, i; - for(i=0; itabnumber-a%st->tabnumber; else a++; @@ -704,17 +706,17 @@ static int text_draw_wrapped(SpaceText *st, const char *str, int x, int y, int w flatten_string(st, &fs, str); str= fs.buf; max= w/st->cwidth; - if(max<8) max= 8; + if (max<8) max= 8; basex= x; lines= 1; start= 0; mstart= 0; end= max; mend= txt_utf8_get_nth(str, max) - str; - for(i=0, mi=0; str[mi]; i++, mi+=BLI_str_utf8_size(str+mi)) { - if(i-start >= max) { + for (i=0, mi=0; str[mi]; i++, mi+=BLI_str_utf8_size(str+mi)) { + if (i-start >= max) { /* skip hidden part of line */ - if(skip) { + if (skip) { skip--; start= end; mstart= mend; end += max; mend= txt_utf8_get_nth(str+mend, max) - str; @@ -722,8 +724,8 @@ static int text_draw_wrapped(SpaceText *st, const char *str, int x, int y, int w } /* Draw the visible portion of text on the overshot line */ - for(a=start, ma=mstart; ashowsyntax && format) format_draw_color(format[a]); + for (a=start, ma=mstart; ashowsyntax && format) format_draw_color(format[a]); x += text_font_draw_character_utf8(st, x, y, str + ma); } y -= st->lheight; @@ -732,16 +734,16 @@ static int text_draw_wrapped(SpaceText *st, const char *str, int x, int y, int w start= end; mstart= mend; end += max; mend= txt_utf8_get_nth(str+mend, max) - str; - if(y<=0) break; + if (y<=0) break; } - else if(str[mi]==' ' || str[mi]=='-') { + else if (str[mi]==' ' || str[mi]=='-') { end = i+1; mend = mi+1; } } /* Draw the remaining text */ - for(a=start, ma=mstart; str[ma] && y > 0; a++, ma+=BLI_str_utf8_size(str+ma)) { - if(st->showsyntax && format) + for (a=start, ma=mstart; str[ma] && y > 0; a++, ma+=BLI_str_utf8_size(str+ma)) { + if (st->showsyntax && format) format_draw_color(format[a]); x += text_font_draw_character_utf8(st, x, y, str+ma); @@ -759,7 +761,7 @@ static int text_draw(SpaceText *st, char *str, int cshift, int maxwidth, int dra const char *in; int w= flatten_string(st, &fs, str); - if(w < cshift) { + if (w < cshift) { flatten_string_free(&fs); return 0; /* String is shorter than shift */ } @@ -768,14 +770,14 @@ static int text_draw(SpaceText *st, char *str, int cshift, int maxwidth, int dra acc= fs.accum+cshift; w= w-cshift; - if(draw) { + if (draw) { int amount = maxwidth ? MIN2(w, maxwidth) : w; - if(st->showsyntax && format) { + if (st->showsyntax && format) { int a, str_shift= 0; format = format+cshift; - for(a = 0; a < amount; a++) { + for (a = 0; a < amount; a++) { format_draw_color(format[a]); x += text_font_draw_character_utf8(st, x, y, in + str_shift); str_shift += BLI_str_utf8_size(in + str_shift); @@ -784,15 +786,15 @@ static int text_draw(SpaceText *st, char *str, int cshift, int maxwidth, int dra else text_font_draw(st, x, y, in); } else { - while(w-- && *acc++ < maxwidth) + while (w-- && *acc++ < maxwidth) r+= st->cwidth; } flatten_string_free(&fs); - if(cshift && r==0) + if (cshift && r==0) return 0; - else if(st->showlinenrs) + else if (st->showlinenrs) return r+TXT_OFFSET+TEXTXLOC; else return r+TXT_OFFSET; @@ -832,7 +834,7 @@ static void text_update_drawcache(SpaceText *st, ARegion *ar) int full_update= 0, nlines= 0; Text *txt= st->text; - if(!st->drawcache) text_drawcache_init(st); + if (!st->drawcache) text_drawcache_init(st); text_update_character_width(st); @@ -848,15 +850,15 @@ static void text_update_drawcache(SpaceText *st, ARegion *ar) full_update|= drawcache->cwidth != st->cwidth; /* word-wrapping option was toggled */ full_update|= strncmp(drawcache->text_id, txt->id.name, MAX_ID_NAME); /* text datablock was changed */ - if(st->wordwrap) { + if (st->wordwrap) { /* update line heights */ - if(full_update || !drawcache->line_height) { + if (full_update || !drawcache->line_height) { drawcache->valid_head = 0; drawcache->valid_tail = 0; drawcache->update_flag = 1; } - if(drawcache->update_flag) { + if (drawcache->update_flag) { TextLine *line= st->text->lines.first; int lineno= 0, size, lines_count; int *fp= drawcache->line_height, *new_tail, *old_tail; @@ -864,7 +866,7 @@ static void text_update_drawcache(SpaceText *st, ARegion *ar) nlines= BLI_countlist(&txt->lines); size= sizeof(int)*nlines; - if(fp) fp= MEM_reallocN(fp, size); + if (fp) fp= MEM_reallocN(fp, size); else fp= MEM_callocN(size, "text drawcache line_height"); drawcache->valid_tail= drawcache->valid_head= 0; @@ -874,16 +876,18 @@ static void text_update_drawcache(SpaceText *st, ARegion *ar) drawcache->total_lines= 0; - if(st->showlinenrs) + if (st->showlinenrs) st->linenrs_tot= (int)floor(log10((float)nlines)) + 1; - while(line) { - if(drawcache->valid_head) { /* we're inside valid head lines */ + while (line) { + if (drawcache->valid_head) { /* we're inside valid head lines */ lines_count= fp[lineno]; drawcache->valid_head--; - } else if (lineno > new_tail - fp) { /* we-re inside valid tail lines */ + } + else if (lineno > new_tail - fp) { /* we-re inside valid tail lines */ lines_count= fp[lineno]; - } else { + } + else { lines_count= text_get_visible_lines(st, ar, line->line); } @@ -896,16 +900,17 @@ static void text_update_drawcache(SpaceText *st, ARegion *ar) drawcache->line_height= fp; } - } else { - if(drawcache->line_height) { + } + else { + if (drawcache->line_height) { MEM_freeN(drawcache->line_height); drawcache->line_height= NULL; } - if(full_update || drawcache->update_flag) { + if (full_update || drawcache->update_flag) { nlines= BLI_countlist(&txt->lines); - if(st->showlinenrs) + if (st->showlinenrs) st->linenrs_tot= (int)floor(log10((float)nlines)) + 1; } @@ -936,24 +941,25 @@ void text_drawcache_tag_update(SpaceText *st, int full) if (st == NULL) return; - if(st->drawcache) { + if (st->drawcache) { DrawCache *drawcache= (DrawCache *)st->drawcache; Text *txt= st->text; - if(drawcache->update_flag) { + if (drawcache->update_flag) { /* happens when tagging update from space listener */ /* should do nothing to prevent locally tagged cache be fully recalculated */ return; } - if(!full) { + if (!full) { int sellno= BLI_findindex(&txt->lines, txt->sell); int curlno= BLI_findindex(&txt->lines, txt->curl); - if(curlno < sellno) { + if (curlno < sellno) { drawcache->valid_head= curlno; drawcache->valid_tail= drawcache->nlines - sellno - 1; - } else { + } + else { drawcache->valid_head= sellno; drawcache->valid_tail= drawcache->nlines - curlno - 1; } @@ -961,9 +967,10 @@ void text_drawcache_tag_update(SpaceText *st, int full) /* quick cache recalculation is also used in delete operator, * which could merge lines which are adjacent to current selection lines * expand recalculate area to this lines */ - if(drawcache->valid_head>0) drawcache->valid_head--; - if(drawcache->valid_tail>0) drawcache->valid_tail--; - } else { + if (drawcache->valid_head>0) drawcache->valid_head--; + if (drawcache->valid_tail>0) drawcache->valid_tail--; + } + else { drawcache->valid_head= 0; drawcache->valid_tail= 0; } @@ -976,8 +983,8 @@ void text_free_caches(SpaceText *st) { DrawCache *drawcache= (DrawCache *)st->drawcache; - if(drawcache) { - if(drawcache->line_height) + if (drawcache) { + if (drawcache->line_height) MEM_freeN(drawcache->line_height); MEM_freeN(drawcache); @@ -1003,22 +1010,22 @@ int text_get_visible_lines(SpaceText *st, ARegion *ar, const char *str) lines= 1; start= 0; end= max; - for(i= 0, j= 0; str[j]; j+=BLI_str_utf8_size(str+j)) { + for (i= 0, j= 0; str[j]; j+=BLI_str_utf8_size(str+j)) { /* Mimic replacement of tabs */ ch= str[j]; - if(ch=='\t') { + if (ch=='\t') { chars= st->tabnumber-i%st->tabnumber; ch= ' '; } else chars= 1; - while(chars--) { - if(i-start >= max) { + while (chars--) { + if (i-start >= max) { lines++; start= end; end += max; } - else if(ch==' ' || ch=='-') { + else if (ch==' ' || ch=='-') { end= i+1; } @@ -1031,7 +1038,7 @@ int text_get_visible_lines(SpaceText *st, ARegion *ar, const char *str) int text_get_span_wrap(SpaceText *st, ARegion *ar, TextLine *from, TextLine *to) { - if(st->wordwrap) { + if (st->wordwrap) { int ret=0; TextLine *tmp= from; @@ -1043,7 +1050,8 @@ int text_get_span_wrap(SpaceText *st, ARegion *ar, TextLine *from, TextLine *to) } return ret; - } else return txt_get_span(from, to); + } + else return txt_get_span(from, to); } int text_get_total_lines(SpaceText *st, ARegion *ar) @@ -1065,23 +1073,25 @@ static TextLine *first_visible_line(SpaceText *st, ARegion *ar, int *wrap_top) text_update_drawcache(st, ar); - if(wrap_top) *wrap_top= 0; + if (wrap_top) *wrap_top= 0; - if(st->wordwrap) { - while(i>0 && pline) { + if (st->wordwrap) { + while (i>0 && pline) { int lines= text_get_visible_lines_no(st, lineno); if (i-lines<0) { - if(wrap_top) *wrap_top= i; + if (wrap_top) *wrap_top= i; break; - } else { + } + else { pline= pline->next; i-= lines; lineno++; } } - } else { - for(i=st->top; pline->next && i>0; i--) + } + else { + for (i=st->top; pline->next && i>0; i--) pline= pline->next; } @@ -1114,7 +1124,7 @@ static void calc_text_rcts(SpaceText *st, ARegion *ar, rcti *scroll, rcti *back) scroll->ymax = 4+pix_available; /* when re-sizing a view-port with the bar at the bottom to a greater height more blank lines will be added */ - if(ltexth + blank_lines < st->top + st->viewlines) { + if (ltexth + blank_lines < st->top + st->viewlines) { blank_lines = st->top + st->viewlines - ltexth; } @@ -1122,7 +1132,7 @@ static void calc_text_rcts(SpaceText *st, ARegion *ar, rcti *scroll, rcti *back) barheight = (ltexth > 0)? (st->viewlines*pix_available)/ltexth: 0; pix_bardiff = 0; - if(barheight < 20) { + if (barheight < 20) { pix_bardiff = 20 - barheight; /* take into account the now non-linear sizing of the bar */ barheight = 20; } @@ -1136,52 +1146,52 @@ static void calc_text_rcts(SpaceText *st, ARegion *ar, rcti *scroll, rcti *back) CLAMP(st->txtbar.ymax, pix_bottom_margin, ar->winy - pix_top_margin); st->pix_per_line= (pix_available > 0)? (float) ltexth/pix_available: 0; - if(st->pix_per_line < 0.1f) st->pix_per_line=0.1f; + if (st->pix_per_line < 0.1f) st->pix_per_line=0.1f; curl_off= text_get_span_wrap(st, ar, st->text->lines.first, st->text->curl); sell_off= text_get_span_wrap(st, ar, st->text->lines.first, st->text->sell); lhlstart = MIN2(curl_off, sell_off); lhlend = MAX2(curl_off, sell_off); - if(ltexth > 0) { + if (ltexth > 0) { hlstart = (lhlstart * pix_available)/ltexth; hlend = (lhlend * pix_available)/ltexth; /* the scrollbar is non-linear sized */ - if(pix_bardiff > 0) { + if (pix_bardiff > 0) { /* the start of the highlight is in the current viewport */ - if(ltexth && st->viewlines && lhlstart >= st->top && lhlstart <= st->top + st->viewlines) { + if (ltexth && st->viewlines && lhlstart >= st->top && lhlstart <= st->top + st->viewlines) { /* speed the progresion of the start of the highlight through the scrollbar */ hlstart = ( ( (pix_available - pix_bardiff) * lhlstart) / ltexth) + (pix_bardiff * (lhlstart - st->top) / st->viewlines); } - else if(lhlstart > st->top + st->viewlines && hlstart < barstart + barheight && hlstart > barstart) { + else if (lhlstart > st->top + st->viewlines && hlstart < barstart + barheight && hlstart > barstart) { /* push hl start down */ hlstart = barstart + barheight; } - else if(lhlend > st->top && lhlstart < st->top && hlstart > barstart) { + else if (lhlend > st->top && lhlstart < st->top && hlstart > barstart) { /*fill out start */ hlstart = barstart; } - if(hlend <= hlstart) { + if (hlend <= hlstart) { hlend = hlstart + 2; } /* the end of the highlight is in the current viewport */ - if(ltexth && st->viewlines && lhlend >= st->top && lhlend <= st->top + st->viewlines) { + if (ltexth && st->viewlines && lhlend >= st->top && lhlend <= st->top + st->viewlines) { /* speed the progresion of the end of the highlight through the scrollbar */ hlend = (((pix_available - pix_bardiff )*lhlend)/ltexth) + (pix_bardiff * (lhlend - st->top)/st->viewlines); } - else if(lhlend < st->top && hlend >= barstart - 2 && hlend < barstart + barheight) { + else if (lhlend < st->top && hlend >= barstart - 2 && hlend < barstart + barheight) { /* push hl end up */ hlend = barstart; } - else if(lhlend > st->top + st->viewlines && lhlstart < st->top + st->viewlines && hlend < barstart + barheight) { + else if (lhlend > st->top + st->viewlines && lhlstart < st->top + st->viewlines && hlend < barstart + barheight) { /* fill out end */ hlend = barstart + barheight; } - if(hlend <= hlstart) { + if (hlend <= hlstart) { hlstart = hlend - 2; } } @@ -1191,7 +1201,7 @@ static void calc_text_rcts(SpaceText *st, ARegion *ar, rcti *scroll, rcti *back) hlend = 0; } - if(hlend - hlstart < 2) { + if (hlend - hlstart < 2) { hlend = hlstart + 2; } @@ -1241,16 +1251,16 @@ static void draw_markers(SpaceText *st, ARegion *ar) topy= txt_get_span(text->lines.first, top); - for(marker= text->markers.first; marker; marker= next) { + for (marker= text->markers.first; marker; marker= next) { next= marker->next; /* invisible line (before top) */ - if(marker->linenolinenolines, marker->lineno); /* Remove broken markers */ - if(marker->end>line->len || marker->start>marker->end) { + if (marker->end>line->len || marker->start>marker->end) { BLI_freelinkN(&text->markers, marker); continue; } @@ -1264,13 +1274,13 @@ static void draw_markers(SpaceText *st, ARegion *ar) x2 = text_get_char_pos(st, line->line, marker->end) - st->left + offc; /* invisible part of line (before top, after last visible line) */ - if(y2 < 0 || y1 > st->top+st->viewlines) continue; + if (y2 < 0 || y1 > st->top+st->viewlines) continue; glColor3ubv(marker->color); x= st->showlinenrs ? TXT_OFFSET + TEXTXLOC : TXT_OFFSET; y= ar->winy-3; - if(y1==y2) { + if (y1==y2) { y -= y1*st->lheight; glBegin(GL_LINE_LOOP); glVertex2i(x+x2*st->cwidth+1, y); @@ -1289,7 +1299,7 @@ static void draw_markers(SpaceText *st, ARegion *ar) glEnd(); y-=st->lheight; - for(i=y1+1; iwinx, y); @@ -1318,24 +1328,24 @@ static void draw_documentation(SpaceText *st, ARegion *ar) int i, br, lines; int boxw, boxh, l, x, y /* , top */ /* UNUSED */; - if(!st || !st->text) return; - if(!texttool_text_is_active(st->text)) return; + if (!st || !st->text) return; + if (!texttool_text_is_active(st->text)) return; docs = texttool_docs_get(); - if(!docs) return; + if (!docs) return; /* Count the visible lines to the cursor */ - for(tmp=st->text->curl, l=-st->top; tmp; tmp=tmp->prev, l++); - if(l<0) return; + for (tmp=st->text->curl, l=-st->top; tmp; tmp=tmp->prev, l++); + if (l<0) return; - if(st->showlinenrs) { + if (st->showlinenrs) { x= st->cwidth*(st->text->curc-st->left) + TXT_OFFSET + TEXTXLOC - 4; } else { x= st->cwidth*(st->text->curc-st->left) + TXT_OFFSET - 4; } - if(texttool_suggest_first()) { + if (texttool_suggest_first()) { x += SUGG_LIST_WIDTH*st->cwidth + 50; } @@ -1366,32 +1376,32 @@ static void draw_documentation(SpaceText *st, ARegion *ar) UI_ThemeColor(TH_TEXT); i= 0; br= DOC_WIDTH; lines= 0; // XXX -doc_scroll; - for(p=docs; *p; p++) { - if(*p == '\r' && *(++p) != '\n') *(--p)= '\n'; /* Fix line endings */ - if(*p == ' ' || *p == '\t') + for (p=docs; *p; p++) { + if (*p == '\r' && *(++p) != '\n') *(--p)= '\n'; /* Fix line endings */ + if (*p == ' ' || *p == '\t') br= i; - else if(*p == '\n') { + else if (*p == '\n') { buf[i]= '\0'; - if(lines>=0) { + if (lines>=0) { y -= st->lheight; text_draw(st, buf, 0, 0, 1, x+4, y-3, NULL); } i= 0; br= DOC_WIDTH; lines++; } buf[i++]= *p; - if(i == DOC_WIDTH) { /* Reached the width, go to last break and wrap there */ + if (i == DOC_WIDTH) { /* Reached the width, go to last break and wrap there */ buf[br]= '\0'; - if(lines>=0) { + if (lines>=0) { y -= st->lheight; text_draw(st, buf, 0, 0, 1, x+4, y-3, NULL); } p -= i-br-1; /* Rewind pointer to last break */ i= 0; br= DOC_WIDTH; lines++; } - if(lines >= DOC_HEIGHT) break; + if (lines >= DOC_HEIGHT) break; } - if(0 /* XXX doc_scroll*/ > 0 && lines < DOC_HEIGHT) { + if (0 /* XXX doc_scroll*/ > 0 && lines < DOC_HEIGHT) { // XXX doc_scroll--; draw_documentation(st, ar); } @@ -1406,23 +1416,23 @@ static void draw_suggestion_list(SpaceText *st, ARegion *ar) char str[SUGG_LIST_WIDTH+1]; int w, boxw=0, boxh, i, l, x, y, b, *top; - if(!st || !st->text) return; - if(!texttool_text_is_active(st->text)) return; + if (!st || !st->text) return; + if (!texttool_text_is_active(st->text)) return; first = texttool_suggest_first(); last = texttool_suggest_last(); - if(!first || !last) return; + if (!first || !last) return; text_pop_suggest_list(); sel = texttool_suggest_selected(); top = texttool_suggest_top(); /* Count the visible lines to the cursor */ - for(tmp=st->text->curl, l=-st->top; tmp; tmp=tmp->prev, l++); - if(l<0) return; + for (tmp=st->text->curl, l=-st->top; tmp; tmp=tmp->prev, l++); + if (l<0) return; - if(st->showlinenrs) { + if (st->showlinenrs) { x = st->cwidth*(st->text->curc-st->left) + TXT_OFFSET + TEXTXLOC - 4; } else { @@ -1439,9 +1449,9 @@ static void draw_suggestion_list(SpaceText *st, ARegion *ar) glRecti(x, y, x+boxw, y-boxh); /* Set the top 'item' of the visible list */ - for(i=0, item=first; i<*top && item->next; i++, item=item->next); + for (i=0, item=first; i<*top && item->next; i++, item=item->next); - for(i=0; inext) { + for (i=0; inext) { y -= st->lheight; @@ -1449,7 +1459,7 @@ static void draw_suggestion_list(SpaceText *st, ARegion *ar) w = BLF_width(mono, str); - if(item == sel) { + if (item == sel) { UI_ThemeColor(TH_SHADE2); glRecti(x+16, y-3, x+16+w, y+st->lheight-3); } @@ -1461,13 +1471,13 @@ static void draw_suggestion_list(SpaceText *st, ARegion *ar) case 'v': UI_ThemeColor(TH_SYNTAX_N); break; case '?': UI_ThemeColor(TH_TEXT); b=0; break; } - if(b) { + if (b) { glRecti(x+8, y+2, x+11, y+5); UI_ThemeColor(TH_TEXT); } text_draw(st, str, 0, 0, 1, x+16, y-1, NULL); - if(item == last) break; + if (item == last) break; } } @@ -1480,7 +1490,7 @@ static void draw_cursor(SpaceText *st, ARegion *ar) int x, y, w, i; /* Draw the selection */ - if(text->curl!=text->sell || text->curc!=text->selc) { + if (text->curl!=text->sell || text->curc!=text->selc) { int offl, offc; /* Convert all to view space character coordinates */ wrap_offset(st, ar, text->curl, text->curc, &offl, &offc); @@ -1490,16 +1500,16 @@ static void draw_cursor(SpaceText *st, ARegion *ar) vsell = txt_get_span(text->lines.first, text->sell) - st->top + offl; vselc = text_get_char_pos(st, text->sell->line, text->selc) - st->left + offc; - if(vcurc<0) vcurc=0; - if(vselc<0) vselc=0, hidden=1; + if (vcurc<0) vcurc=0; + if (vselc<0) vselc=0, hidden=1; UI_ThemeColor(TH_SHADE2); x= st->showlinenrs ? TXT_OFFSET + TEXTXLOC : TXT_OFFSET; y= ar->winy-2; - if(vcurl==vsell) { + if (vcurl==vsell) { y -= vcurl*st->lheight; - if(vcurc < vselc) + if (vcurc < vselc) glRecti(x+vcurc*st->cwidth-1, y, x+vselc*st->cwidth, y-st->lheight); else glRecti(x+vselc*st->cwidth-1, y, x+vcurc*st->cwidth, y-st->lheight); @@ -1507,7 +1517,7 @@ static void draw_cursor(SpaceText *st, ARegion *ar) else { int froml, fromc, tol, toc; - if(vcurl < vsell) { + if (vcurl < vsell) { froml= vcurl; tol= vsell; fromc= vcurc; toc= vselc; } @@ -1518,7 +1528,7 @@ static void draw_cursor(SpaceText *st, ARegion *ar) y -= froml*st->lheight; glRecti(x+fromc*st->cwidth-1, y, ar->winx, y-st->lheight); y-=st->lheight; - for(i=froml+1; iwinx, y-st->lheight), y-=st->lheight; glRecti(x-4, y, x+toc*st->cwidth, y-st->lheight); y-=st->lheight; @@ -1530,16 +1540,16 @@ static void draw_cursor(SpaceText *st, ARegion *ar) vsell = txt_get_span(text->lines.first, text->sell) - st->top + offl; vselc = text_get_char_pos(st, text->sell->line, text->selc) - st->left + offc; - if(vselc<0) { + if (vselc<0) { vselc= 0; hidden= 1; } } - if(st->line_hlight) { + if (st->line_hlight) { int x1, x2, y1, y2; - if(st->wordwrap) { + if (st->wordwrap) { int visible_lines = text_get_visible_lines(st, ar, text->sell->line); int offl, offc; @@ -1547,12 +1557,13 @@ static void draw_cursor(SpaceText *st, ARegion *ar) y1= ar->winy-2 - (vsell-offl)*st->lheight; y2= y1-st->lheight*visible_lines+1; - } else { + } + else { y1= ar->winy-2 - vsell*st->lheight; y2= y1-st->lheight+1; } - if(!(y1<0 || y2 > ar->winy)) { /* check we need to draw */ + if (!(y1<0 || y2 > ar->winy)) { /* check we need to draw */ x1= st->showlinenrs ? TXT_OFFSET + TEXTXLOC : TXT_OFFSET; x2= x1 + ar->winx; @@ -1565,17 +1576,17 @@ static void draw_cursor(SpaceText *st, ARegion *ar) } } - if(!hidden) { + if (!hidden) { /* Draw the cursor itself (we draw the sel. cursor as this is the leading edge) */ x= st->showlinenrs ? TXT_OFFSET + TEXTXLOC : TXT_OFFSET; x += vselc*st->cwidth; y= ar->winy-2 - vsell*st->lheight; - if(st->overwrite) { + if (st->overwrite) { char ch= text->sell->line[text->selc]; w= st->cwidth; - if(ch=='\t') w*= st->tabnumber-(vselc+st->left)%st->tabnumber; + if (ch=='\t') w*= st->tabnumber-(vselc+st->left)%st->tabnumber; UI_ThemeColor(TH_HILITE); glRecti(x, y-st->lheight-1, x+w, y-st->lheight+1); @@ -1599,13 +1610,13 @@ static void draw_brackets(SpaceText *st, ARegion *ar) char ch; // showsyntax must be on or else the format string will be null - if(!text->curl || !st->showsyntax) return; + if (!text->curl || !st->showsyntax) return; startl= text->curl; startc= text->curc; b= text_check_bracket(startl->line[startc]); - if(b==0 && startc>0) b = text_check_bracket(startl->line[--startc]); - if(b==0) return; + if (b==0 && startc>0) b = text_check_bracket(startl->line[--startc]); + if (b==0) return; linep= startl; c= startc; @@ -1616,33 +1627,33 @@ static void draw_brackets(SpaceText *st, ARegion *ar) stack= 0; /* Don't highlight backets if syntax HL is off or bracket in string or comment. */ - if(!linep->format || linep->format[fc] == 'l' || linep->format[fc] == '#') + if (!linep->format || linep->format[fc] == 'l' || linep->format[fc] == '#') return; - if(b>0) { + if (b>0) { /* opening bracket, search forward for close */ fc++; c+= BLI_str_utf8_size(linep->line+c); - while(linep) { - while(clen) { - if(linep->format && linep->format[fc] != 'l' && linep->format[fc] != '#') { + while (linep) { + while (clen) { + if (linep->format && linep->format[fc] != 'l' && linep->format[fc] != '#') { b= text_check_bracket(linep->line[c]); - if(b==find) { - if(stack==0) { + if (b==find) { + if (stack==0) { endl= linep; endc= c; break; } stack--; } - else if(b==-find) { + else if (b==-find) { stack++; } } fc++; c+= BLI_str_utf8_size(linep->line+c); } - if(endl) break; + if (endl) break; linep= linep->next; c= 0; fc= 0; @@ -1652,28 +1663,28 @@ static void draw_brackets(SpaceText *st, ARegion *ar) /* closing bracket, search backward for open */ fc--; if (c>0) c -= linep->line+c-BLI_str_prev_char_utf8(linep->line+c); - while(linep) { - while(fc>=0) { - if(linep->format && linep->format[fc] != 'l' && linep->format[fc] != '#') { + while (linep) { + while (fc>=0) { + if (linep->format && linep->format[fc] != 'l' && linep->format[fc] != '#') { b= text_check_bracket(linep->line[c]); - if(b==find) { - if(stack==0) { + if (b==find) { + if (stack==0) { endl= linep; endc= c; break; } stack--; } - else if(b==-find) { + else if (b==-find) { stack++; } } fc--; if (c>0) c -= linep->line+c-BLI_str_prev_char_utf8(linep->line+c); } - if(endl) break; + if (endl) break; linep= linep->prev; - if(linep) { + if (linep) { if (linep->format) fc= strlen(linep->format)-1; else fc= -1; if (linep->len) c= BLI_str_prev_char_utf8(linep->line+linep->len)-linep->line; @@ -1682,7 +1693,7 @@ static void draw_brackets(SpaceText *st, ARegion *ar) } } - if(!endl || endc==-1) + if (!endl || endc==-1) return; UI_ThemeColor(TH_HILITE); @@ -1694,7 +1705,7 @@ static void draw_brackets(SpaceText *st, ARegion *ar) wrap_offset(st, ar, startl, startc, &offl, &offc); viewc= text_get_char_pos(st, startl->line, startc) - st->left + offc; - if(viewc >= 0){ + if (viewc >= 0) { viewl= txt_get_span(text->lines.first, startl) - st->top + offl; text_font_draw_character(st, x+viewc*st->cwidth, y-viewl*st->lheight, ch); @@ -1706,7 +1717,7 @@ static void draw_brackets(SpaceText *st, ARegion *ar) wrap_offset(st, ar, endl, endc, &offl, &offc); viewc= text_get_char_pos(st, endl->line, endc) - st->left + offc; - if(viewc >= 0) { + if (viewc >= 0) { viewl= txt_get_span(text->lines.first, endl) - st->top + offl; text_font_draw_character(st, x+viewc*st->cwidth, y-viewl*st->lheight, ch); @@ -1725,17 +1736,17 @@ void draw_text_main(SpaceText *st, ARegion *ar) int i, x, y, winx, linecount= 0, lineno= 0; int wraplinecount= 0, wrap_skip= 0; - if(st->lheight) st->viewlines= (int)ar->winy/st->lheight; + if (st->lheight) st->viewlines= (int)ar->winy/st->lheight; else st->viewlines= 0; /* if no text, nothing to do */ - if(!text) + if (!text) return; text_update_drawcache(st, ar); /* make sure all the positional pointers exist */ - if(!text->curl || !text->sell || !text->lines.first || !text->lines.last) + if (!text->curl || !text->sell || !text->lines.first || !text->lines.last) txt_clean_text(text); /* update rects for scroll */ @@ -1744,22 +1755,24 @@ void draw_text_main(SpaceText *st, ARegion *ar) /* update syntax formatting if needed */ tmp= text->lines.first; lineno= 0; - for(i= 0; itop && tmp; i++) { - if(st->showsyntax && !tmp->format) + for (i= 0; itop && tmp; i++) { + if (st->showsyntax && !tmp->format) txt_format_line(st, tmp, 0); - if(st->wordwrap) { + if (st->wordwrap) { int lines= text_get_visible_lines_no(st, lineno); if (wraplinecount+lines>st->top) { wrap_skip= st->top-wraplinecount; break; - } else { + } + else { wraplinecount+= lines; tmp= tmp->next; linecount++; } - } else { + } + else { tmp= tmp->next; linecount++; } @@ -1772,7 +1785,7 @@ void draw_text_main(SpaceText *st, ARegion *ar) st->cwidth= MAX2(st->cwidth, 1); /* draw line numbers background */ - if(st->showlinenrs) { + if (st->showlinenrs) { x= TXT_OFFSET + TEXTXLOC; UI_ThemeColor(TH_GRID); @@ -1791,13 +1804,13 @@ void draw_text_main(SpaceText *st, ARegion *ar) /* draw the text */ UI_ThemeColor(TH_TEXT); - for(i=0; y>0 && iviewlines && tmp; i++, tmp= tmp->next) { - if(st->showsyntax && !tmp->format) + for (i=0; y>0 && iviewlines && tmp; i++, tmp= tmp->next) { + if (st->showsyntax && !tmp->format) txt_format_line(st, tmp, 0); - if(st->showlinenrs && !wrap_skip) { + if (st->showlinenrs && !wrap_skip) { /* draw line number */ - if(tmp == text->curl) + if (tmp == text->curl) UI_ThemeColor(TH_HILITE); else UI_ThemeColor(TH_TEXT); @@ -1809,7 +1822,7 @@ void draw_text_main(SpaceText *st, ARegion *ar) UI_ThemeColor(TH_TEXT); } - if(st->wordwrap) { + if (st->wordwrap) { /* draw word wrapped text */ int lines = text_draw_wrapped(st, tmp->line, x, y, winx-x, tmp->format, wrap_skip); y -= lines*st->lheight; @@ -1823,7 +1836,7 @@ void draw_text_main(SpaceText *st, ARegion *ar) wrap_skip= 0; } - if(st->flags&ST_SHOW_MARGIN) { + if (st->flags&ST_SHOW_MARGIN) { UI_ThemeColor(TH_HILITE); glBegin(GL_LINES); @@ -1861,12 +1874,12 @@ void text_scroll_to_cursor(SpaceText *st, ScrArea *sa) ARegion *ar= NULL; int i, x, winx= 0; - if(ELEM3(NULL, st, st->text, st->text->curl)) return; + if (ELEM3(NULL, st, st->text, st->text->curl)) return; text= st->text; - for(ar=sa->regionbase.first; ar; ar= ar->next) - if(ar->regiontype==RGN_TYPE_WINDOW) { + for (ar=sa->regionbase.first; ar; ar= ar->next) + if (ar->regiontype==RGN_TYPE_WINDOW) { winx= ar->winx; break; } @@ -1876,27 +1889,27 @@ void text_scroll_to_cursor(SpaceText *st, ScrArea *sa) text_update_character_width(st); i= txt_get_span(text->lines.first, text->sell); - if(st->wordwrap) { + if (st->wordwrap) { int offl, offc; wrap_offset(st, ar, text->sell, text->selc, &offl, &offc); i+= offl; } - if(st->top+st->viewlines <= i || st->top > i) + if (st->top+st->viewlines <= i || st->top > i) st->top= i - st->viewlines/2; - if(st->wordwrap) { + if (st->wordwrap) { st->left= 0; } else { x= text_draw(st, text->sell->line, st->left, text->selc, 0, 0, 0, NULL); - if(x==0 || x>winx) + if (x==0 || x>winx) st->left= text->curc-0.5*winx/st->cwidth; } - if(st->top < 0) st->top= 0; - if(st->left <0) st->left= 0; + if (st->top < 0) st->top= 0; + if (st->left <0) st->left= 0; } void text_update_cursor_moved(bContext *C) diff --git a/source/blender/editors/space_text/text_header.c b/source/blender/editors/space_text/text_header.c index 02de29e098b..f4f92ac8db3 100644 --- a/source/blender/editors/space_text/text_header.c +++ b/source/blender/editors/space_text/text_header.c @@ -79,13 +79,13 @@ static ARegion *text_has_properties_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), "properties region"); @@ -108,7 +108,7 @@ static int text_properties_exec(bContext *C, wmOperator *UNUSED(op)) ScrArea *sa= CTX_wm_area(C); ARegion *ar= text_has_properties_region(sa); - if(ar) + if (ar) ED_region_toggle_hidden(C, ar); return OPERATOR_FINISHED; @@ -134,9 +134,9 @@ void TEXT_OT_properties(wmOperatorType *ot) uiPopupMenu *pup; - if(text) { + if (text) { pup= uiPupMenuBegin(C, "Text", ICON_NONE); - if(txt_has_sel(text)) { + if (txt_has_sel(text)) { uiItemO(layout, NULL, ICON_NONE, "TEXT_OT_cut"); uiItemO(layout, NULL, ICON_NONE, "TEXT_OT_copy"); } @@ -173,7 +173,7 @@ void TEXT_OT_properties(wmOperatorType *ot) uiPopupMenu *pup; - if(text) { + if (text) { pup= uiPupMenuBegin(C, "Text", ICON_NONE); uiItemO(layout, NULL, ICON_NONE, "TEXT_OT_new"); uiItemO(layout, NULL, ICON_NONE, "TEXT_OT_open"); diff --git a/source/blender/editors/space_text/text_ops.c b/source/blender/editors/space_text/text_ops.c index fd4b334eeec..8230da838e7 100644 --- a/source/blender/editors/space_text/text_ops.c +++ b/source/blender/editors/space_text/text_ops.c @@ -89,10 +89,10 @@ static int text_edit_poll(bContext *C) { Text *text= CTX_data_edit_text(C); - if(!text) + if (!text) return 0; - if(text->id.lib) { + if (text->id.lib) { // BKE_report(op->reports, RPT_ERROR, "Can't edit external libdata"); return 0; } @@ -105,10 +105,10 @@ static int text_space_edit_poll(bContext *C) SpaceText *st= CTX_wm_space_text(C); Text *text= CTX_data_edit_text(C); - if(!st || !text) + if (!st || !text) return 0; - if(text->id.lib) { + if (text->id.lib) { // BKE_report(op->reports, RPT_ERROR, "Can't edit external libdata"); return 0; } @@ -122,13 +122,13 @@ static int text_region_edit_poll(bContext *C) Text *text= CTX_data_edit_text(C); ARegion *ar= CTX_wm_region(C); - if(!st || !text) + if (!st || !text) return 0; - if(!ar || ar->regiontype != RGN_TYPE_WINDOW) + if (!ar || ar->regiontype != RGN_TYPE_WINDOW) return 0; - if(text->id.lib) { + if (text->id.lib) { // BKE_report(op->reports, RPT_ERROR, "Can't edit external libdata"); return 0; } @@ -140,11 +140,11 @@ static int text_region_edit_poll(bContext *C) void text_update_line_edited(TextLine *line) { - if(!line) + if (!line) return; /* we just free format here, and let it rebuild during draw */ - if(line->format) { + if (line->format) { MEM_freeN(line->format); line->format= NULL; } @@ -154,7 +154,7 @@ void text_update_edited(Text *text) { TextLine *line; - for(line=text->lines.first; line; line=line->next) + for (line=text->lines.first; line; line=line->next) text_update_line_edited(line); } @@ -172,18 +172,18 @@ static int text_new_exec(bContext *C, wmOperator *UNUSED(op)) /* hook into UI */ uiIDContextProperty(C, &ptr, &prop); - if(prop) { + if (prop) { /* when creating new ID blocks, use is already 1, but RNA * pointer se also increases user, so this compensates it */ /* doesnt always seem to happen... (ton) */ - if(text->id.us>1) + if (text->id.us>1) text->id.us--; RNA_id_pointer_create(&text->id, &idptr); RNA_property_pointer_set(&ptr, prop, idptr); RNA_property_update(C, &ptr, prop); } - else if(st) { + else if (st) { st->text= text; st->top= 0; text_drawcache_tag_update(st, 1); @@ -238,18 +238,18 @@ static int text_open_exec(bContext *C, wmOperator *op) text= add_text(str, G.main->name); - if(!text) { - if(op->customdata) MEM_freeN(op->customdata); + if (!text) { + if (op->customdata) MEM_freeN(op->customdata); return OPERATOR_CANCELLED; } - if(!op->customdata) + if (!op->customdata) text_open_init(C, op); /* hook into UI */ pprop= op->customdata; - if(pprop->prop) { + if (pprop->prop) { /* when creating new ID blocks, use is already 1, but RNA * pointer se also increases user, so this compensates it */ text->id.us--; @@ -258,13 +258,13 @@ static int text_open_exec(bContext *C, wmOperator *op) RNA_property_pointer_set(&pprop->ptr, pprop->prop, idptr); RNA_property_update(C, &pprop->ptr, pprop->prop); } - else if(st) { + else if (st) { st->text= text; st->top= 0; } if (internal) { - if(text->name) + if (text->name) MEM_freeN(text->name); text->name = NULL; @@ -283,7 +283,7 @@ static int text_open_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) Text *text= CTX_data_edit_text(C); char *path= (text && text->name)? text->name: G.main->name; - if(RNA_struct_property_is_set(op->ptr, "filepath")) + if (RNA_struct_property_is_set(op->ptr, "filepath")) return text_open_exec(C, op); text_open_init(C, op); @@ -320,13 +320,13 @@ static int text_reload_exec(bContext *C, wmOperator *op) { Text *text= CTX_data_edit_text(C); - if(!reopen_text(text)) { + if (!reopen_text(text)) { BKE_report(op->reports, RPT_ERROR, "Could not reopen file"); return OPERATOR_CANCELLED; } #ifdef WITH_PYTHON - if(text->compiled) + if (text->compiled) BPY_text_free_code(text); #endif @@ -366,13 +366,13 @@ static int text_unlink_exec(bContext *C, wmOperator *UNUSED(op)) Text *text= CTX_data_edit_text(C); /* make the previous text active, if its not there make the next text active */ - if(st) { - if(text->id.prev) { + if (st) { + if (text->id.prev) { st->text = text->id.prev; text_update_cursor_moved(C); WM_event_add_notifier(C, NC_TEXT|ND_CURSOR, st->text); } - else if(text->id.next) { + else if (text->id.next) { st->text = text->id.next; text_update_cursor_moved(C); WM_event_add_notifier(C, NC_TEXT|ND_CURSOR, st->text); @@ -412,7 +412,7 @@ static int text_make_internal_exec(bContext *C, wmOperator *UNUSED(op)) text->flags |= TXT_ISMEM | TXT_ISDIRTY; - if(text->name) { + if (text->name) { MEM_freeN(text->name); text->name= NULL; } @@ -444,7 +444,7 @@ static int text_save_poll(bContext *C) { Text *text= CTX_data_edit_text(C); - if(!text_edit_poll(C)) + if (!text_edit_poll(C)) return 0; return (text->name != NULL && !(text->flags & TXT_ISMEM)); @@ -461,14 +461,14 @@ static void txt_write_file(Text *text, ReportList *reports) BLI_path_abs(filepath, G.main->name); fp= BLI_fopen(filepath, "w"); - if(fp==NULL) { + if (fp==NULL) { BKE_reportf(reports, RPT_ERROR, "Unable to save \"%s\": %s", filepath, errno ? strerror(errno) : "Unknown error writing file"); return; } tmp= text->lines.first; - while(tmp) { - if(tmp->next) fprintf(fp, "%s\n", tmp->line); + while (tmp) { + if (tmp->next) fprintf(fp, "%s\n", tmp->line); else fprintf(fp, "%s", tmp->line); tmp= tmp->next; @@ -476,7 +476,7 @@ static void txt_write_file(Text *text, ReportList *reports) fclose (fp); - if(stat(filepath, &st) == 0) { + if (stat(filepath, &st) == 0) { text->mtime= st.st_mtime; } else { @@ -484,7 +484,7 @@ static void txt_write_file(Text *text, ReportList *reports) BKE_reportf(reports, RPT_WARNING, "Unable to stat \"%s\": %s", filepath, errno ? strerror(errno) : "Unknown error starrng file"); } - if(text->flags & TXT_ISDIRTY) + if (text->flags & TXT_ISDIRTY) text->flags ^= TXT_ISDIRTY; } @@ -519,12 +519,12 @@ static int text_save_as_exec(bContext *C, wmOperator *op) Text *text= CTX_data_edit_text(C); char str[FILE_MAX]; - if(!text) + if (!text) return OPERATOR_CANCELLED; RNA_string_get(op->ptr, "filepath", str); - if(text->name) MEM_freeN(text->name); + if (text->name) MEM_freeN(text->name); text->name= BLI_strdup(str); text->flags &= ~TXT_ISMEM; @@ -541,12 +541,12 @@ static int text_save_as_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(even Text *text= CTX_data_edit_text(C); char *str; - if(RNA_struct_property_is_set(op->ptr, "filepath")) + if (RNA_struct_property_is_set(op->ptr, "filepath")) return text_save_as_exec(C, op); - if(text->name) + if (text->name) str= text->name; - else if(text->flags & TXT_ISMEM) + else if (text->flags & TXT_ISMEM) str= text->id.name+2; else str= G.main->name; @@ -591,7 +591,7 @@ static int text_run_script(bContext *C, ReportList *reports) int curc_prev= text->curc; if (BPY_text_exec(C, text, reports, !is_live)) { - if(is_live) { + if (is_live) { /* for nice live updates */ WM_event_add_notifier(C, NC_WINDOW|NA_EDITED, NULL); } @@ -599,8 +599,8 @@ static int text_run_script(bContext *C, ReportList *reports) } /* Don't report error messages while live editing */ - if(!is_live) { - if(text->curl != curl_prev || curc_prev != text->curc) { + if (!is_live) { + if (text->curl != curl_prev || curc_prev != text->curc) { text_update_cursor_moved(C); WM_event_add_notifier(C, NC_TEXT|NA_EDITED, text); } @@ -654,30 +654,30 @@ static int text_refresh_pyconstraints_exec(bContext *UNUSED(C), wmOperator *UNUS short update; /* check all pyconstraints */ - for(ob= CTX_data_main(C)->object.first; ob; ob= ob->id.next) { + for (ob= CTX_data_main(C)->object.first; ob; ob= ob->id.next) { update = 0; - if(ob->type==OB_ARMATURE && ob->pose) { + if (ob->type==OB_ARMATURE && ob->pose) { bPoseChannel *pchan; - for(pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) { - for(con = pchan->constraints.first; con; con= con->next) { - if(con->type==CONSTRAINT_TYPE_PYTHON) { + for (pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) { + for (con = pchan->constraints.first; con; con= con->next) { + if (con->type==CONSTRAINT_TYPE_PYTHON) { bPythonConstraint *data = con->data; - if(data->text==text) BPY_pyconstraint_update(ob, con); + if (data->text==text) BPY_pyconstraint_update(ob, con); update = 1; } } } } - for(con = ob->constraints.first; con; con= con->next) { - if(con->type==CONSTRAINT_TYPE_PYTHON) { + for (con = ob->constraints.first; con; con= con->next) { + if (con->type==CONSTRAINT_TYPE_PYTHON) { bPythonConstraint *data = con->data; - if(data->text==text) BPY_pyconstraint_update(ob, con); + if (data->text==text) BPY_pyconstraint_update(ob, con); update = 1; } } - if(update) { + if (update) { DAG_id_tag_update(&ob->id, OB_RECALC_DATA); } } @@ -707,25 +707,25 @@ static char *txt_copy_selected(Text *text) char *buf= NULL; int charf, charl, length= 0; - if(!text) return NULL; - if(!text->curl) return NULL; - if(!text->sell) return NULL; + if (!text) return NULL; + if (!text->curl) return NULL; + if (!text->sell) return NULL; - if(!txt_has_sel(text)) return NULL; + if (!txt_has_sel(text)) return NULL; - if(text->curl==text->sell) { + if (text->curl==text->sell) { linef= linel= text->curl; - if(text->curc < text->selc) { + if (text->curc < text->selc) { charf= text->curc; charl= text->selc; } - else{ + else { charf= text->selc; charl= text->curc; } } - else if(txt_get_span(text->curl, text->sell)<0) { + else if (txt_get_span(text->curl, text->sell)<0) { linef= text->sell; linel= text->curl; @@ -740,7 +740,7 @@ static char *txt_copy_selected(Text *text) charl= text->selc; } - if(linef == linel) { + if (linef == linel) { length= charl-charf; buf= MEM_callocN(length+1, "cut buffera"); @@ -753,7 +753,7 @@ static char *txt_copy_selected(Text *text) length++; /* For the '\n' */ tmp= linef->next; - while(tmp && tmp!= linel) { + while (tmp && tmp!= linel) { length+= tmp->len+1; tmp= tmp->next; } @@ -766,7 +766,7 @@ static char *txt_copy_selected(Text *text) buf[length++]='\n'; tmp= linef->next; - while(tmp && tmp!=linel) { + while (tmp && tmp!=linel) { strncpy(buf+length, tmp->line, tmp->len); length+= tmp->len; @@ -791,7 +791,7 @@ static int text_paste_exec(bContext *C, wmOperator *op) buf= WM_clipboard_text_get(selection); - if(!buf) + if (!buf) return OPERATOR_CANCELLED; text_drawcache_tag_update(CTX_wm_space_text(C), 0); @@ -805,7 +805,7 @@ static int text_paste_exec(bContext *C, wmOperator *op) WM_event_add_notifier(C, NC_TEXT|NA_EDITED, text); /* run the script while editing, evil but useful */ - if(CTX_wm_space_text(C)->live_edit) + if (CTX_wm_space_text(C)->live_edit) text_run_script(C, NULL); return OPERATOR_FINISHED; @@ -834,7 +834,7 @@ static void txt_copy_clipboard(Text *text) buf= txt_copy_selected(text); - if(buf) { + if (buf) { WM_clipboard_text_set(buf, 0); MEM_freeN(buf); } @@ -876,7 +876,7 @@ static int text_cut_exec(bContext *C, wmOperator *UNUSED(op)) WM_event_add_notifier(C, NC_TEXT|NA_EDITED, text); /* run the script while editing, evil but useful */ - if(CTX_wm_space_text(C)->live_edit) + if (CTX_wm_space_text(C)->live_edit) text_run_script(C, NULL); return OPERATOR_FINISHED; @@ -902,7 +902,7 @@ static int text_indent_exec(bContext *C, wmOperator *UNUSED(op)) text_drawcache_tag_update(CTX_wm_space_text(C), 0); - if(txt_has_sel(text)) { + if (txt_has_sel(text)) { txt_order_cursors(text); txt_indent(text); } @@ -935,7 +935,7 @@ static int text_unindent_exec(bContext *C, wmOperator *UNUSED(op)) { Text *text= CTX_data_edit_text(C); - if(txt_has_sel(text)) { + if (txt_has_sel(text)) { text_drawcache_tag_update(CTX_wm_space_text(C), 0); txt_order_cursors(text); @@ -979,16 +979,17 @@ static int text_line_break_exec(bContext *C, wmOperator *UNUSED(op)) curts= setcurr_tab_spaces(text, space); txt_split_curline(text); - for(a=0; a < curts; a++) { + for (a=0; a < curts; a++) { if (text->flags & TXT_TABSTOSPACES) { txt_add_char(text, ' '); - } else { + } + else { txt_add_char(text, '\t'); } } - if(text->curl) { - if(text->curl->prev) + if (text->curl) { + if (text->curl->prev) text_update_line_edited(text->curl->prev); text_update_line_edited(text->curl); } @@ -1017,7 +1018,7 @@ static int text_comment_exec(bContext *C, wmOperator *UNUSED(op)) { Text *text= CTX_data_edit_text(C); - if(txt_has_sel(text)) { + if (txt_has_sel(text)) { text_drawcache_tag_update(CTX_wm_space_text(C), 0); txt_order_cursors(text); @@ -1050,7 +1051,7 @@ static int text_uncomment_exec(bContext *C, wmOperator *UNUSED(op)) { Text *text= CTX_data_edit_text(C); - if(txt_has_sel(text)) { + if (txt_has_sel(text)) { text_drawcache_tag_update(CTX_wm_space_text(C), 0); txt_order_cursors(text); @@ -1100,14 +1101,14 @@ static int text_convert_whitespace_exec(bContext *C, wmOperator *op) tmp = text->lines.first; //first convert to all space, this make it a lot easier to convert to tabs because there is no mixtures of ' ' && '\t' - while(tmp) { + while (tmp) { text_check_line = tmp->line; number = flatten_string(st, &fs, text_check_line)+1; flatten_string_free(&fs); new_line = MEM_callocN(number, "Converted_Line"); j = 0; - for(a=0; a < strlen(text_check_line); a++) { //foreach char in line - if(text_check_line[a] == '\t') { //checking for tabs + for (a=0; a < strlen(text_check_line); a++) { //foreach char in line + if (text_check_line[a] == '\t') { //checking for tabs //get the number of spaces this tabs is showing //i don't like doing it this way but will look into it later new_line[j] = '\0'; @@ -1118,7 +1119,7 @@ static int text_convert_whitespace_exec(bContext *C, wmOperator *op) number = flatten_string(st, &fs, new_line)-number; flatten_string_free(&fs); - for(extra = 0; extra < number; extra++) { + for (extra = 0; extra < number; extra++) { new_line[j] = ' '; j++; } @@ -1130,8 +1131,8 @@ static int text_convert_whitespace_exec(bContext *C, wmOperator *op) } new_line[j] = '\0'; // put new_line in the tmp->line spot still need to try and set the curc correctly - if(tmp->line) MEM_freeN(tmp->line); - if(tmp->format) MEM_freeN(tmp->format); + if (tmp->line) MEM_freeN(tmp->line); + if (tmp->format) MEM_freeN(tmp->format); tmp->line = new_line; tmp->len = strlen(new_line); @@ -1143,38 +1144,38 @@ static int text_convert_whitespace_exec(bContext *C, wmOperator *op) //start over from the beginning tmp = text->lines.first; - while(tmp) { + while (tmp) { text_check_line = tmp->line; extra = 0; - for(a = 0; a < strlen(text_check_line); a++) { + for (a = 0; a < strlen(text_check_line); a++) { number = 0; - for(j = 0; j < (size_t)st->tabnumber; j++) { - if((a+j) <= strlen(text_check_line)) { //check to make sure we are not pass the end of the line - if(text_check_line[a+j] != ' ') { + for (j = 0; j < (size_t)st->tabnumber; j++) { + if ((a+j) <= strlen(text_check_line)) { //check to make sure we are not pass the end of the line + if (text_check_line[a+j] != ' ') { number = 1; } } } - if(!number) { //found all number of space to equal a tab + if (!number) { //found all number of space to equal a tab a = a+(st->tabnumber-1); extra = extra+1; } } - if( extra > 0 ) { //got tabs make malloc and do what you have to do + if ( extra > 0 ) { //got tabs make malloc and do what you have to do new_line = MEM_callocN(strlen(text_check_line)-(((st->tabnumber*extra)-extra)-1), "Converted_Line"); extra = 0; //reuse vars - for(a = 0; a < strlen(text_check_line); a++) { + for (a = 0; a < strlen(text_check_line); a++) { number = 0; - for(j = 0; j < (size_t)st->tabnumber; j++) { - if((a+j) <= strlen(text_check_line)) { //check to make sure we are not pass the end of the line - if(text_check_line[a+j] != ' ') { + for (j = 0; j < (size_t)st->tabnumber; j++) { + if ((a+j) <= strlen(text_check_line)) { //check to make sure we are not pass the end of the line + if (text_check_line[a+j] != ' ') { number = 1; } } } - if(!number) { //found all number of space to equal a tab + if (!number) { //found all number of space to equal a tab new_line[extra] = '\t'; a = a+(st->tabnumber-1); ++extra; @@ -1187,8 +1188,8 @@ static int text_convert_whitespace_exec(bContext *C, wmOperator *op) } new_line[extra] = '\0'; // put new_line in the tmp->line spot still need to try and set the curc correctly - if(tmp->line) MEM_freeN(tmp->line); - if(tmp->format) MEM_freeN(tmp->format); + if (tmp->line) MEM_freeN(tmp->line); + if (tmp->format) MEM_freeN(tmp->format); tmp->line = new_line; tmp->len = strlen(new_line); @@ -1310,10 +1311,10 @@ static int text_previous_marker_exec(bContext *C, wmOperator *UNUSED(op)) lineno= txt_get_span(text->lines.first, text->curl); mrk= text->markers.last; - while(mrk && (mrk->lineno>lineno || (mrk->lineno==lineno && mrk->end > text->curc))) + while (mrk && (mrk->lineno>lineno || (mrk->lineno==lineno && mrk->end > text->curc))) mrk= mrk->prev; - if(!mrk) mrk= text->markers.last; - if(mrk) { + if (!mrk) mrk= text->markers.last; + if (mrk) { txt_move_to(text, mrk->lineno, mrk->start, 0); txt_move_to(text, mrk->lineno, mrk->end, 1); } @@ -1346,10 +1347,10 @@ static int text_next_marker_exec(bContext *C, wmOperator *UNUSED(op)) lineno= txt_get_span(text->lines.first, text->curl); mrk= text->markers.first; - while(mrk && (mrk->linenolineno==lineno && mrk->start <= text->curc))) + while (mrk && (mrk->linenolineno==lineno && mrk->start <= text->curc))) mrk= mrk->next; - if(!mrk) mrk= text->markers.first; - if(mrk) { + if (!mrk) mrk= text->markers.first; + if (mrk) { txt_move_to(text, mrk->lineno, mrk->start, 0); txt_move_to(text, mrk->lineno, mrk->end, 1); } @@ -1427,60 +1428,60 @@ static int text_get_cursor_rel(SpaceText* st, ARegion *ar, TextLine *linein, int end= max; chop= loop= 1; - for(i=0, j=0; loop; j+=BLI_str_utf8_size(linein->line+j)) { + for (i=0, j=0; loop; j+=BLI_str_utf8_size(linein->line+j)) { int chars; /* Mimic replacement of tabs */ ch= linein->line[j]; - if(ch=='\t') { + if (ch=='\t') { chars= st->tabnumber-i%st->tabnumber; ch= ' '; } else chars= 1; - while(chars--) { - if(rell==0 && i-start==relc) { + while (chars--) { + if (rell==0 && i-start==relc) { /* current position could be wrapped to next line */ /* this should be checked when end of current line would be reached */ selc= j; found= 1; } - else if(i-end==relc) { + else if (i-end==relc) { curs= j; } - if(i-start>=max) { - if(found) { + if (i-start>=max) { + if (found) { /* exact cursor position was found, check if it's */ /* still on needed line (hasn't been wrapped) */ - if(selc>endj && !chop) selc= endj; + if (selc>endj && !chop) selc= endj; loop= 0; break; } - if(chop) endj= j; + if (chop) endj= j; start= end; end += max; chop= 1; rell--; - if(rell==0 && i-start>=relc) { + if (rell==0 && i-start>=relc) { selc= curs; loop= 0; break; } } else if (ch=='\0') { - if(!found) selc= linein->len; + if (!found) selc= linein->len; loop= 0; break; } - else if(ch==' ' || ch=='-') { - if(found) { + else if (ch==' ' || ch=='-') { + if (found) { loop= 0; break; } - if(rell==0 && i-start>=relc) { + if (rell==0 && i-start>=relc) { selc= curs; loop= 0; break; @@ -1506,12 +1507,12 @@ static int cursor_skip_find_line(SpaceText* st, ARegion *ar, *rell= lines; /* handle current line */ - if(lines>0) { + if (lines>0) { visible_lines= text_get_visible_lines(st, ar, (*linep)->line); - if(*rell-visible_lines+offl>=0) { - if(!(*linep)->next) { - if(offl < visible_lines-1) { + if (*rell-visible_lines+offl>=0) { + if (!(*linep)->next) { + if (offl < visible_lines-1) { *rell= visible_lines-1; return 1; } @@ -1522,14 +1523,16 @@ static int cursor_skip_find_line(SpaceText* st, ARegion *ar, *rell-= visible_lines-offl; *linep=(*linep)->next; - } else { + } + else { *rell+= offl; return 1; } - } else { - if(*rell+offl<=0) { - if(!(*linep)->prev) { - if(offl) { + } + else { + if (*rell+offl<=0) { + if (!(*linep)->prev) { + if (offl) { *rell= 0; return 1; } @@ -1540,33 +1543,35 @@ static int cursor_skip_find_line(SpaceText* st, ARegion *ar, *rell+= offl; *linep=(*linep)->prev; - } else { + } + else { *rell+= offl; return 1; } } /* skip lines and find destination line and offsets */ - while(*linep) { + while (*linep) { visible_lines= text_get_visible_lines(st, ar, (*linep)->line); - if(lines<0) { /* moving top */ - if(*rell+visible_lines >= 0) { + if (lines<0) { /* moving top */ + if (*rell+visible_lines >= 0) { *rell+= visible_lines; break; } - if(!(*linep)->prev) { + if (!(*linep)->prev) { *rell= 0; break; } *rell+= visible_lines; *linep=(*linep)->prev; - } else { /* moving bottom */ - if(*rell-visible_lines < 0) break; + } + else { /* moving bottom */ + if (*rell-visible_lines < 0) break; - if(!(*linep)->next) { + if (!(*linep)->next) { *rell= visible_lines-1; break; } @@ -1602,34 +1607,34 @@ static void txt_wrap_move_bol(SpaceText *st, ARegion *ar, short sel) chop= loop= 1; *charp= 0; - for(i=0, j=0; loop; j+=BLI_str_utf8_size((*linep)->line+j)) { + for (i=0, j=0; loop; j+=BLI_str_utf8_size((*linep)->line+j)) { int chars; /* Mimic replacement of tabs */ ch= (*linep)->line[j]; - if(ch=='\t') { + if (ch=='\t') { chars= st->tabnumber-i%st->tabnumber; ch= ' '; } else chars= 1; - while(chars--) { - if(i-start>=max) { + while (chars--) { + if (i-start>=max) { *charp= endj; - if(j>=oldc) { - if(ch=='\0') *charp= txt_utf8_index_to_offset((*linep)->line, start); + if (j>=oldc) { + if (ch=='\0') *charp= txt_utf8_index_to_offset((*linep)->line, start); loop= 0; break; } - if(chop) endj= j; + if (chop) endj= j; start= end; end += max; chop= 1; } - else if(ch==' ' || ch=='-' || ch=='\0') { - if(j>=oldc) { + else if (ch==' ' || ch=='-' || ch=='\0') { + if (j>=oldc) { *charp= txt_utf8_index_to_offset((*linep)->line, start); loop= 0; break; @@ -1670,22 +1675,22 @@ static void txt_wrap_move_eol(SpaceText *st, ARegion *ar, short sel) chop= loop= 1; *charp= 0; - for(i=0, j=0; loop; j+=BLI_str_utf8_size((*linep)->line+j)) { + for (i=0, j=0; loop; j+=BLI_str_utf8_size((*linep)->line+j)) { int chars; /* Mimic replacement of tabs */ ch= (*linep)->line[j]; - if(ch=='\t') { + if (ch=='\t') { chars= st->tabnumber-i%st->tabnumber; ch= ' '; } else chars= 1; - while(chars--) { - if(i-start>=max) { - if(chop) endj= BLI_str_prev_char_utf8((*linep)->line+j)-(*linep)->line; + while (chars--) { + if (i-start>=max) { + if (chop) endj= BLI_str_prev_char_utf8((*linep)->line+j)-(*linep)->line; - if(endj>=oldc) { - if(ch=='\0') *charp= (*linep)->len; + if (endj>=oldc) { + if (ch=='\0') *charp= (*linep)->len; else *charp= endj; loop= 0; break; @@ -1694,11 +1699,13 @@ static void txt_wrap_move_eol(SpaceText *st, ARegion *ar, short sel) start= end; end += max; chop= 1; - } else if(ch=='\0') { + } + else if (ch=='\0') { *charp= (*linep)->len; loop= 0; break; - } else if(ch==' ' || ch=='-') { + } + else if (ch==' ' || ch=='-') { end= i+1; endj= j; chop= 0; @@ -1729,18 +1736,20 @@ static void txt_wrap_move_up(SpaceText *st, ARegion *ar, short sel) wrap_offset_in_line(st, ar, *linep, *charp, &offl, &offc); col= text_get_char_pos(st, (*linep)->line, *charp) + offc; - if(offl) { + if (offl) { *charp= text_get_cursor_rel(st, ar, *linep, offl-1, col); newl= BLI_findindex(&text->lines, linep); - } else { - if((*linep)->prev) { + } + else { + if ((*linep)->prev) { int visible_lines; *linep= (*linep)->prev; visible_lines= text_get_visible_lines(st, ar, (*linep)->line); *charp= text_get_cursor_rel(st, ar, *linep, visible_lines-1, col); newl--; - } else *charp= 0; + } + else *charp= 0; } if (!sel) txt_pop_sel(text); @@ -1766,15 +1775,17 @@ static void txt_wrap_move_down(SpaceText *st, ARegion *ar, short sel) wrap_offset_in_line(st, ar, *linep, *charp, &offl, &offc); col= text_get_char_pos(st, (*linep)->line, *charp) + offc; visible_lines= text_get_visible_lines(st, ar, (*linep)->line); - if(offllines, linep); - } else { - if((*linep)->next) { + } + else { + if ((*linep)->next) { *linep= (*linep)->next; *charp= text_get_cursor_rel(st, ar, *linep, 0, col); newl++; - } else *charp= (*linep)->len; + } + else *charp= (*linep)->len; } if (!sel) txt_pop_sel(text); @@ -1797,13 +1808,14 @@ static void cursor_skip(SpaceText* st, ARegion *ar, Text *text, int lines, int s oldl= txt_get_span(text->lines.first, *linep); oldc= *charp; - if(st && ar && st->wordwrap) { + if (st && ar && st->wordwrap) { int rell, relc; /* find line and offsets inside it needed to set cursor position */ - if(cursor_skip_find_line(st, ar, lines, linep, charp, &rell, &relc)) + if (cursor_skip_find_line(st, ar, lines, linep, charp, &rell, &relc)) *charp= text_get_cursor_rel (st, ar, *linep, rell, relc); - } else { + } + else { while (lines>0 && (*linep)->next) { *linep= (*linep)->next; lines--; @@ -1827,17 +1839,17 @@ static int text_move_cursor(bContext *C, int type, int select) ARegion *ar= CTX_wm_region(C); /* ensure we have the right region, it's optional */ - if(ar && ar->regiontype != RGN_TYPE_WINDOW) + if (ar && ar->regiontype != RGN_TYPE_WINDOW) ar= NULL; switch(type) { case LINE_BEGIN: - if(st && st->wordwrap && ar) txt_wrap_move_bol(st, ar, select); + if (st && st->wordwrap && ar) txt_wrap_move_bol(st, ar, select); else txt_move_bol(text, select); break; case LINE_END: - if(st && st->wordwrap && ar) txt_wrap_move_eol(st, ar, select); + if (st && st->wordwrap && ar) txt_wrap_move_eol(st, ar, select); else txt_move_eol(text, select); break; @@ -1866,22 +1878,22 @@ static int text_move_cursor(bContext *C, int type, int select) break; case PREV_LINE: - if(st && st->wordwrap && ar) txt_wrap_move_up(st, ar, select); + if (st && st->wordwrap && ar) txt_wrap_move_up(st, ar, select); else txt_move_up(text, select); break; case NEXT_LINE: - if(st && st->wordwrap && ar) txt_wrap_move_down(st, ar, select); + if (st && st->wordwrap && ar) txt_wrap_move_down(st, ar, select); else txt_move_down(text, select); break; case PREV_PAGE: - if(st) cursor_skip(st, ar, st->text, -st->viewlines, select); + if (st) cursor_skip(st, ar, st->text, -st->viewlines, select); else cursor_skip(NULL, NULL, text, -10, select); break; case NEXT_PAGE: - if(st) cursor_skip(st, ar, st->text, st->viewlines, select); + if (st) cursor_skip(st, ar, st->text, st->viewlines, select); else cursor_skip(NULL, NULL, text, 10, select); break; } @@ -1946,9 +1958,9 @@ static int text_jump_exec(bContext *C, wmOperator *op) int line= RNA_int_get(op->ptr, "line"); short nlines= txt_get_span(text->lines.first, text->lines.last)+1; - if(line < 1) + if (line < 1) txt_move_toline(text, 1, 0); - else if(line > nlines) + else if (line > nlines) txt_move_toline(text, nlines-1, 0); else txt_move_toline(text, line-1, 0); @@ -1997,13 +2009,13 @@ static int text_delete_exec(bContext *C, wmOperator *op) text_drawcache_tag_update(CTX_wm_space_text(C), 0); - if(type == DEL_PREV_WORD) + if (type == DEL_PREV_WORD) txt_backspace_word(text); - else if(type == DEL_PREV_CHAR) + else if (type == DEL_PREV_CHAR) txt_backspace_char(text); - else if(type == DEL_NEXT_WORD) + else if (type == DEL_NEXT_WORD) txt_delete_word(text); - else if(type == DEL_NEXT_CHAR) + else if (type == DEL_NEXT_CHAR) txt_delete_char(text); text_update_line_edited(text->curl); @@ -2012,7 +2024,7 @@ static int text_delete_exec(bContext *C, wmOperator *op) WM_event_add_notifier(C, NC_TEXT|NA_EDITED, text); /* run the script while editing, evil but useful */ - if(CTX_wm_space_text(C)->live_edit) + if (CTX_wm_space_text(C)->live_edit) text_run_script(C, NULL); return OPERATOR_FINISHED; @@ -2070,8 +2082,8 @@ static void txt_screen_skip(SpaceText *st, ARegion *ar, int lines) last= text_get_total_lines(st, ar); last= last - (st->viewlines/2); - if(st->top>last) st->top= last; - if(st->top<0) st->top= 0; + if (st->top>last) st->top= last; + if (st->top<0) st->top= 0; } /* quick enum for tsc->zone (scroller handles) */ @@ -2104,7 +2116,7 @@ static int text_scroll_exec(bContext *C, wmOperator *op) int lines= RNA_int_get(op->ptr, "lines"); - if(lines == 0) + if (lines == 0) return OPERATOR_CANCELLED; txt_screen_skip(st, ar, lines*U.wheellinescroll); @@ -2124,7 +2136,7 @@ static void text_scroll_apply(bContext *C, wmOperator *op, wmEvent *event) text_update_character_width(st); - if(tsc->first) { + if (tsc->first) { tsc->old[0]= mval[0]; tsc->old[1]= mval[1]; tsc->first= 0; @@ -2133,7 +2145,7 @@ static void text_scroll_apply(bContext *C, wmOperator *op, wmEvent *event) tsc->delta[0]+= mval[0] - tsc->old[0]; tsc->delta[1]+= mval[1] - tsc->old[1]; - if(!tsc->scrollbar) { + if (!tsc->scrollbar) { txtdelta[0]= -tsc->delta[0]/st->cwidth; txtdelta[1]= tsc->delta[1]/st->lheight; @@ -2145,15 +2157,15 @@ static void text_scroll_apply(bContext *C, wmOperator *op, wmEvent *event) tsc->delta[1]+= txtdelta[1]/st->pix_per_line; } - if(txtdelta[0] || txtdelta[1]) { + if (txtdelta[0] || txtdelta[1]) { txt_screen_skip(st, ar, txtdelta[1]); - if(st->wordwrap) { + if (st->wordwrap) { st->left= 0; } else { st->left+= txtdelta[0]; - if(st->left<0) st->left= 0; + if (st->left<0) st->left= 0; } ED_area_tag_redraw(CTX_wm_area(C)); @@ -2179,13 +2191,13 @@ static int text_scroll_modal(bContext *C, wmOperator *op, wmEvent *event) switch(event->type) { case MOUSEMOVE: - if(tsc->zone == SCROLLHANDLE_BAR) + if (tsc->zone == SCROLLHANDLE_BAR) text_scroll_apply(C, op, event); break; case LEFTMOUSE: case RIGHTMOUSE: case MIDDLEMOUSE: - if(ELEM(tsc->zone, SCROLLHANDLE_MIN_OUTSIDE, SCROLLHANDLE_MAX_OUTSIDE)) { + if (ELEM(tsc->zone, SCROLLHANDLE_MIN_OUTSIDE, SCROLLHANDLE_MAX_OUTSIDE)) { int last; st->top+= st->viewlines * (tsc->zone==SCROLLHANDLE_MIN_OUTSIDE ? 1 : -1); @@ -2216,7 +2228,7 @@ static int text_scroll_invoke(bContext *C, wmOperator *op, wmEvent *event) SpaceText *st= CTX_wm_space_text(C); TextScroll *tsc; - if(RNA_struct_property_is_set(op->ptr, "lines")) + if (RNA_struct_property_is_set(op->ptr, "lines")) return text_scroll_exec(C, op); tsc= MEM_callocN(sizeof(TextScroll), "TextScroll"); @@ -2279,10 +2291,10 @@ static int text_region_scroll_poll(bContext *C) Text *text= CTX_data_edit_text(C); ARegion *ar= CTX_wm_region(C); - if(!st || !text) + if (!st || !text) return 0; - if(!ar || ar->regiontype != RGN_TYPE_WINDOW) + if (!ar || ar->regiontype != RGN_TYPE_WINDOW) return 0; return 1; @@ -2296,22 +2308,22 @@ static int text_scroll_bar_invoke(bContext *C, wmOperator *op, wmEvent *event) const int *mval= event->mval; int zone= -1; - if(RNA_struct_property_is_set(op->ptr, "lines")) + if (RNA_struct_property_is_set(op->ptr, "lines")) return text_scroll_exec(C, op); /* verify we are in the right zone */ - if(mval[0]>st->txtbar.xmin && mval[0]txtbar.xmax) { - if(mval[1]>=st->txtbar.ymin && mval[1]<=st->txtbar.ymax) { + if (mval[0]>st->txtbar.xmin && mval[0]txtbar.xmax) { + if (mval[1]>=st->txtbar.ymin && mval[1]<=st->txtbar.ymax) { /* mouse inside scroll handle */ zone = SCROLLHANDLE_BAR; } - else if(mval[1]>TXT_SCROLL_SPACE && mval[1]winy-TXT_SCROLL_SPACE) { - if(mval[1]txtbar.ymin) zone= SCROLLHANDLE_MIN_OUTSIDE; + else if (mval[1]>TXT_SCROLL_SPACE && mval[1]winy-TXT_SCROLL_SPACE) { + if (mval[1]txtbar.ymin) zone= SCROLLHANDLE_MIN_OUTSIDE; else zone= SCROLLHANDLE_MAX_OUTSIDE; } } - if(zone == -1) { + if (zone == -1) { /* we are outside slider - nothing to do */ return OPERATOR_PASS_THROUGH; } @@ -2375,8 +2387,8 @@ static int flatten_len(SpaceText *st, const char *str) { int i, total = 0; - for(i = 0; str[i]; i += BLI_str_utf8_size(str+i)) { - if(str[i]=='\t') { + for (i = 0; str[i]; i += BLI_str_utf8_size(str+i)) { + if (str[i]=='\t') { total += st->tabnumber - total%st->tabnumber; } else total++; @@ -2389,7 +2401,7 @@ static int flatten_index_to_offset(SpaceText *st, const char *str, int index) { int i, j; for (i= 0, j= 0; i < index; j += BLI_str_utf8_size(str+j)) - if(str[j]=='\t') + if (str[j]=='\t') i += st->tabnumber - i%st->tabnumber; else i++; @@ -2407,7 +2419,8 @@ static TextLine *get_first_visible_line(SpaceText *st, ARegion *ar, int *y) if (i-lines < 0) { *y += i; break; - } else { + } + else { linep = linep->next; i -= lines; } @@ -2426,7 +2439,7 @@ static void text_cursor_set_to_pos_wrapped(SpaceText *st, ARegion *ar, int x, in /* Point to first visible line */ TextLine *linep = get_first_visible_line(st, ar, &y); - while(loop && linep) { + while (loop && linep) { int i = 0, start = 0, end = max; /* view */ int j = 0, curs = 0, endj = 0; /* mem */ int chop = 1; /* flags */ @@ -2436,7 +2449,7 @@ static void text_cursor_set_to_pos_wrapped(SpaceText *st, ARegion *ar, int x, in /* Mimic replacement of tabs */ ch = linep->line[j]; - if(ch == '\t') { + if (ch == '\t') { chars = st->tabnumber - i%st->tabnumber; ch = ' '; } @@ -2457,7 +2470,7 @@ static void text_cursor_set_to_pos_wrapped(SpaceText *st, ARegion *ar, int x, in found = 1; /* Prepare curs for next wrap */ } - else if(i - end == x) { + else if (i - end == x) { curs = j; } if (i - start >= max) { @@ -2469,11 +2482,11 @@ static void text_cursor_set_to_pos_wrapped(SpaceText *st, ARegion *ar, int x, in break; } - if(chop) endj = j; + if (chop) endj = j; start = end; end += max; - if(j < linep->len) + if (j < linep->len) y--; chop = 1; @@ -2489,7 +2502,7 @@ static void text_cursor_set_to_pos_wrapped(SpaceText *st, ARegion *ar, int x, in break; } - if(y == 0 && i-start >= x) { + if (y == 0 && i-start >= x) { charp = curs; loop = 0; break; @@ -2501,12 +2514,12 @@ static void text_cursor_set_to_pos_wrapped(SpaceText *st, ARegion *ar, int x, in i++; } - if(ch == '\0') break; + if (ch == '\0') break; } - if(!loop || found) break; + if (!loop || found) break; - if(!linep->next) { + if (!linep->next) { charp = linep->len; break; } @@ -2522,7 +2535,7 @@ static void text_cursor_set_to_pos_wrapped(SpaceText *st, ARegion *ar, int x, in } if (linep && charp != -1) { - if(sel) { text->sell = linep; text->selc = charp; } + if (sel) { text->sell = linep; text->selc = charp; } else { text->curl = linep; text->curc = charp; } } } @@ -2533,13 +2546,13 @@ static void text_cursor_set_to_pos(SpaceText *st, ARegion *ar, int x, int y, int text_update_character_width(st); y= (ar->winy - 2 - y)/st->lheight; - if(st->showlinenrs) x-= TXT_OFFSET+TEXTXLOC; + if (st->showlinenrs) x-= TXT_OFFSET+TEXTXLOC; else x-= TXT_OFFSET; - if(x<0) x= 0; + if (x<0) x= 0; x = text_pixel_x_to_index(st, x) + st->left; - if(st->wordwrap) { + if (st->wordwrap) { text_cursor_set_to_pos_wrapped(st, ar, x, y, sel); } else { @@ -2547,24 +2560,24 @@ static void text_cursor_set_to_pos(SpaceText *st, ARegion *ar, int x, int y, int int *charp; int w; - if(sel) { linep= &text->sell; charp= &text->selc; } + if (sel) { linep= &text->sell; charp= &text->selc; } else { linep= &text->curl; charp= &text->curc; } y-= txt_get_span(text->lines.first, *linep) - st->top; - if(y>0) { - while(y-- != 0) if((*linep)->next) *linep= (*linep)->next; + if (y>0) { + while (y-- != 0) if((*linep)->next) *linep= (*linep)->next; } - else if(y<0) { - while(y++ != 0) if((*linep)->prev) *linep= (*linep)->prev; + else if (y<0) { + while (y++ != 0) if((*linep)->prev) *linep= (*linep)->prev; } w= flatten_len(st, (*linep)->line); - if(xline, x); + if (xline, x); else *charp= (*linep)->len; } - if(!sel) txt_pop_sel(text); + if (!sel) txt_pop_sel(text); } static void text_cursor_set_apply(bContext *C, wmOperator *op, wmEvent *event) @@ -2573,18 +2586,18 @@ static void text_cursor_set_apply(bContext *C, wmOperator *op, wmEvent *event) ARegion *ar= CTX_wm_region(C); SetSelection *ssel= op->customdata; - if(event->mval[1]<0 || event->mval[1]>ar->winy) { + if (event->mval[1]<0 || event->mval[1]>ar->winy) { int d= (ssel->old[1]-event->mval[1])*st->pix_per_line; - if(d) txt_screen_skip(st, ar, d); + if (d) txt_screen_skip(st, ar, d); text_cursor_set_to_pos(st, ar, event->mval[0], event->mval[1]<0?0:ar->winy, 1); text_update_cursor_moved(C); WM_event_add_notifier(C, NC_TEXT|ND_CURSOR, st->text); } - else if(!st->wordwrap && (event->mval[0]<0 || event->mval[0]>ar->winx)) { - if(event->mval[0]>ar->winx) st->left++; - else if(event->mval[0]<0 && st->left>0) st->left--; + else if (!st->wordwrap && (event->mval[0]<0 || event->mval[0]>ar->winx)) { + if (event->mval[0]>ar->winx) st->left++; + else if (event->mval[0]<0 && st->left>0) st->left--; text_cursor_set_to_pos(st, ar, event->mval[0], event->mval[1], 1); @@ -2611,7 +2624,7 @@ static void text_cursor_set_exit(bContext *C, wmOperator *op) int linep2, charp2; char *buffer; - if(txt_has_sel(text)) { + if (txt_has_sel(text)) { buffer = txt_sel_to_buf(text); WM_clipboard_text_set(buffer, 1); MEM_freeN(buffer); @@ -2620,7 +2633,7 @@ static void text_cursor_set_exit(bContext *C, wmOperator *op) linep2= txt_get_span(st->text->lines.first, st->text->sell); charp2= st->text->selc; - if(ssel->sell!=linep2 || ssel->selc!=charp2) + if (ssel->sell!=linep2 || ssel->selc!=charp2) txt_undo_add_toop(st->text, UNDO_STO, ssel->sell, ssel->selc, linep2, charp2); text_update_cursor_moved(C); @@ -2634,7 +2647,7 @@ static int text_set_selection_invoke(bContext *C, wmOperator *op, wmEvent *event SpaceText *st= CTX_wm_space_text(C); SetSelection *ssel; - if(event->mval[0]>=st->txtbar.xmin) + if (event->mval[0]>=st->txtbar.xmin) return OPERATOR_PASS_THROUGH; op->customdata= MEM_callocN(sizeof(SetSelection), "SetCursor"); @@ -2721,7 +2734,7 @@ static int text_cursor_set_invoke(bContext *C, wmOperator *op, wmEvent *event) { SpaceText *st= CTX_wm_space_text(C); - if(event->mval[0]>=st->txtbar.xmin) + if (event->mval[0]>=st->txtbar.xmin) return OPERATOR_PASS_THROUGH; RNA_int_set(op->ptr, "x", event->mval[0]); @@ -2761,17 +2774,17 @@ static int text_line_number_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent text_update_character_width(st); - if(!st->showlinenrs) + if (!st->showlinenrs) return OPERATOR_PASS_THROUGH; - if(!(mval[0]>2 && mval[0]<(TXT_OFFSET + TEXTXLOC) && mval[1]>2 && mval[1]winy-2)) + if (!(mval[0]>2 && mval[0]<(TXT_OFFSET + TEXTXLOC) && mval[1]>2 && mval[1]winy-2)) return OPERATOR_PASS_THROUGH; - if(!(event->ascii>='0' && event->ascii<='9')) + if (!(event->ascii>='0' && event->ascii<='9')) return OPERATOR_PASS_THROUGH; time = PIL_check_seconds_timer(); - if(last_jump < time-1) + if (last_jump < time-1) jump_to= 0; jump_to *= 10; @@ -2813,12 +2826,13 @@ static int text_insert_exec(bContext *C, wmOperator *op) str= RNA_string_get_alloc(op->ptr, "text", NULL, 0); - if(st && st->overwrite) { + if (st && st->overwrite) { while (str[i]) { code = BLI_str_utf8_as_unicode_step(str, &i); done |= txt_replace_char(text, code); } - } else { + } + else { while (str[i]) { code = BLI_str_utf8_as_unicode_step(str, &i); done |= txt_add_char(text, code); @@ -2827,7 +2841,7 @@ static int text_insert_exec(bContext *C, wmOperator *op) MEM_freeN(str); - if(!done) + if (!done) return OPERATOR_CANCELLED; text_update_line_edited(text->curl); @@ -2843,9 +2857,9 @@ static int text_insert_invoke(bContext *C, wmOperator *op, wmEvent *event) int ret; // if(!RNA_struct_property_is_set(op->ptr, "text")) { /* always set from keymap XXX */ - if(!RNA_string_length(op->ptr, "text")) { + if (!RNA_string_length(op->ptr, "text")) { /* if alt/ctrl/super are pressed pass through */ - if(event->ctrl || event->oskey) { + if (event->ctrl || event->oskey) { return OPERATOR_PASS_THROUGH; } else { @@ -2855,7 +2869,8 @@ static int text_insert_invoke(bContext *C, wmOperator *op, wmEvent *event) if (event->utf8_buf[0]) { len = BLI_str_utf8_size(event->utf8_buf); memcpy(str, event->utf8_buf, len); - } else { + } + else { /* in theory, ghost can set value to extended ascii here */ len = BLI_str_utf8_from_unicode(event->ascii, str); } @@ -2867,7 +2882,7 @@ static int text_insert_invoke(bContext *C, wmOperator *op, wmEvent *event) ret = text_insert_exec(C, op); /* run the script while editing, evil but useful */ - if(ret==OPERATOR_FINISHED && CTX_wm_space_text(C)->live_edit) + if (ret==OPERATOR_FINISHED && CTX_wm_space_text(C)->live_edit) text_run_script(C, NULL); return ret; @@ -2908,18 +2923,18 @@ static int text_find_and_replace(bContext *C, wmOperator *op, short mode) int found = 0; char *tmp; - if(!st->findstr[0] || (mode == TEXT_REPLACE && !st->replacestr[0])) + if (!st->findstr[0] || (mode == TEXT_REPLACE && !st->replacestr[0])) return OPERATOR_CANCELLED; flags= st->flags; - if(flags & ST_FIND_ALL) + if (flags & ST_FIND_ALL) flags ^= ST_FIND_WRAP; do { int proceed= 0; - if(first) { - if(text->markers.first) + if (first) { + if (text->markers.first) WM_event_add_notifier(C, NC_TEXT|NA_EDITED, text); txt_clear_markers(text, TMARK_GRP_FINDALL, 0); @@ -2928,16 +2943,16 @@ static int text_find_and_replace(bContext *C, wmOperator *op, short mode) first= 0; /* Replace current */ - if(mode!=TEXT_FIND && txt_has_sel(text)) { + if (mode!=TEXT_FIND && txt_has_sel(text)) { tmp= txt_sel_to_buf(text); - if(flags & ST_MATCH_CASE) proceed= strcmp(st->findstr, tmp)==0; + if (flags & ST_MATCH_CASE) proceed= strcmp(st->findstr, tmp)==0; else proceed= BLI_strcasecmp(st->findstr, tmp)==0; - if(proceed) { - if(mode==TEXT_REPLACE) { + if (proceed) { + if (mode==TEXT_REPLACE) { txt_insert_buf(text, st->replacestr); - if(text->curl && text->curl->format) { + if (text->curl && text->curl->format) { MEM_freeN(text->curl->format); text->curl->format= NULL; } @@ -2945,12 +2960,12 @@ static int text_find_and_replace(bContext *C, wmOperator *op, short mode) WM_event_add_notifier(C, NC_TEXT|NA_EDITED, text); text_drawcache_tag_update(CTX_wm_space_text(C), 1); } - else if(mode==TEXT_MARK_ALL) { + else if (mode==TEXT_MARK_ALL) { unsigned char color[4]; UI_GetThemeColor4ubv(TH_SHADE2, color); - if(txt_find_marker(text, text->curl, text->selc, TMARK_GRP_FINDALL, 0)) { - if(tmp) MEM_freeN(tmp), tmp=NULL; + if (txt_find_marker(text, text->curl, text->selc, TMARK_GRP_FINDALL, 0)) { + if (tmp) MEM_freeN(tmp), tmp=NULL; break; } @@ -2964,14 +2979,14 @@ static int text_find_and_replace(bContext *C, wmOperator *op, short mode) } /* Find next */ - if(txt_find_string(text, st->findstr, flags & ST_FIND_WRAP, flags & ST_MATCH_CASE)) { + if (txt_find_string(text, st->findstr, flags & ST_FIND_WRAP, flags & ST_MATCH_CASE)) { text_update_cursor_moved(C); WM_event_add_notifier(C, NC_TEXT|ND_CURSOR, text); } - else if(flags & ST_FIND_ALL) { - if(text==start) break; - if(!start) start= text; - if(text->id.next) + else if (flags & ST_FIND_ALL) { + if (text==start) break; + if (!start) start= text; + if (text->id.next) text= st->text= text->id.next; else text= st->text= bmain->text.first; @@ -2981,11 +2996,11 @@ static int text_find_and_replace(bContext *C, wmOperator *op, short mode) first= 1; } else { - if(!found && !proceed) BKE_reportf(op->reports, RPT_ERROR, "Text not found: %s", st->findstr); + if (!found && !proceed) BKE_reportf(op->reports, RPT_ERROR, "Text not found: %s", st->findstr); break; } found = 1; - } while(mode==TEXT_MARK_ALL); + } while (mode==TEXT_MARK_ALL); return OPERATOR_FINISHED; } @@ -3057,7 +3072,7 @@ static int text_find_set_selected_exec(bContext *C, wmOperator *op) BLI_strncpy(st->findstr, tmp, ST_MAX_FIND_STR); MEM_freeN(tmp); - if(!st->findstr[0]) + if (!st->findstr[0]) return OPERATOR_FINISHED; return text_find_and_replace(C, op, TEXT_FIND); @@ -3123,24 +3138,24 @@ int text_file_modified(Text *text) int result; char file[FILE_MAX]; - if(!text || !text->name) + if (!text || !text->name) return 0; BLI_strncpy(file, text->name, FILE_MAX); BLI_path_abs(file, G.main->name); - if(!BLI_exists(file)) + if (!BLI_exists(file)) return 2; result = stat(file, &st); - if(result == -1) + if (result == -1) return -1; - if((st.st_mode & S_IFMT) != S_IFREG) + if ((st.st_mode & S_IFMT) != S_IFREG) return -1; - if(st.st_mtime > text->mtime) + if (st.st_mtime > text->mtime) return 1; return 0; @@ -3152,16 +3167,16 @@ static void text_ignore_modified(Text *text) int result; char file[FILE_MAX]; - if(!text || !text->name) return; + if (!text || !text->name) return; BLI_strncpy(file, text->name, FILE_MAX); BLI_path_abs(file, G.main->name); - if(!BLI_exists(file)) return; + if (!BLI_exists(file)) return; result = stat(file, &st); - if(result == -1 || (st.st_mode & S_IFMT) != S_IFREG) + if (result == -1 || (st.st_mode & S_IFMT) != S_IFREG) return; text->mtime= st.st_mtime; @@ -3195,7 +3210,7 @@ static int text_resolve_conflict_invoke(bContext *C, wmOperator *op, wmEvent *UN switch(text_file_modified(text)) { case 1: - if(text->flags & TXT_ISDIRTY) { + if (text->flags & TXT_ISDIRTY) { /* modified locally and externally, ahhh. offer more possibilites. */ pup= uiPupMenuBegin(C, "File Modified Outside and Inside Blender", ICON_NONE); layout= uiPupMenuLayout(pup); @@ -3278,12 +3293,12 @@ void ED_text_undo_step(bContext *C, int step) { Text *text= CTX_data_edit_text(C); - if(!text) + if (!text) return; - if(step==1) + if (step==1) txt_do_undo(text); - else if(step==-1) + else if (step==-1) txt_do_redo(text); text_update_edited(text); diff --git a/source/blender/editors/space_text/text_python.c b/source/blender/editors/space_text/text_python.c index 88bd6b9c4c0..f8472a132e1 100644 --- a/source/blender/editors/space_text/text_python.c +++ b/source/blender/editors/space_text/text_python.c @@ -55,24 +55,24 @@ int text_do_suggest_select(SpaceText *st, ARegion *ar) int tgti, *top; int mval[2] = {0, 0}; - if(!st || !st->text) return 0; - if(!texttool_text_is_active(st->text)) return 0; + if (!st || !st->text) return 0; + if (!texttool_text_is_active(st->text)) return 0; first = texttool_suggest_first(); last = texttool_suggest_last(); /* sel = texttool_suggest_selected(); */ /* UNUSED */ top = texttool_suggest_top(); - if(!last || !first) + if (!last || !first) return 0; /* Count the visible lines to the cursor */ - for(tmp=st->text->curl, l=-st->top; tmp; tmp=tmp->prev, l++); - if(l<0) return 0; + for (tmp=st->text->curl, l=-st->top; tmp; tmp=tmp->prev, l++); + if (l<0) return 0; text_update_character_width(st); - if(st->showlinenrs) { + if (st->showlinenrs) { x = st->cwidth*(st->text->curc-st->left) + TXT_OFFSET + TEXTXLOC - 4; } else { @@ -85,19 +85,19 @@ int text_do_suggest_select(SpaceText *st, ARegion *ar) // XXX getmouseco_areawin(mval); - if(mval[0]next; i++, item=item->next); + for (i=0, item=first; i<*top && item->next; i++, item=item->next); /* Work out the target item index in the visible list */ tgti = (y-mval[1]-4) / st->lheight; - if(tgti<0 || tgti>SUGG_LIST_SIZE) + if (tgti<0 || tgti>SUGG_LIST_SIZE) return 1; - for(i=tgti; i>0 && item->next; i--, item=item->next); - if(item) + for (i=tgti; i>0 && item->next; i--, item=item->next); + if (item) texttool_suggest_select(item); return 1; } @@ -112,13 +112,13 @@ void text_pop_suggest_list(void) top= texttool_suggest_top(); i= 0; - while(item && item != sel) { + while (item && item != sel) { item= item->next; i++; } - if(i > *top+SUGG_LIST_SIZE-1) + if (i > *top+SUGG_LIST_SIZE-1) *top= i-SUGG_LIST_SIZE+1; - else if(i < *top) + else if (i < *top) *top= i; } @@ -127,16 +127,16 @@ static void get_suggest_prefix(Text *text, int offset) int i, len; char *line, tmp[256]; - if(!text) return; - if(!texttool_text_is_active(text)) return; + if (!text) return; + if (!texttool_text_is_active(text)) return; line= text->curl->line; - for(i=text->curc-1+offset; i>=0; i--) - if(!text_check_identifier(line[i])) + for (i=text->curc-1+offset; i>=0; i--) + if (!text_check_identifier(line[i])) break; i++; len= text->curc-i+offset; - if(len > 255) { + if (len > 255) { printf("Suggestion prefix too long\n"); len = 255; } @@ -151,29 +151,29 @@ static void confirm_suggestion(Text *text, int skipleft) int i, over=0; char *line; - if(!text) return; - if(!texttool_text_is_active(text)) return; + if (!text) return; + if (!texttool_text_is_active(text)) return; sel = texttool_suggest_selected(); - if(!sel) return; + if (!sel) return; line= text->curl->line; i=text->curc-skipleft-1; - while(i>=0) { - if(!text_check_identifier(line[i])) + while (i>=0) { + if (!text_check_identifier(line[i])) break; over++; i--; } - for(i=0; iname); - for(i=0; itext)) return 0; - if(!st->text || st->text->id.lib) return 0; + if (!texttool_text_is_active(st->text)) return 0; + if (!st->text || st->text->id.lib) return 0; - if(st->doplugins && texttool_text_is_active(st->text)) { - if(texttool_suggest_first()) tools |= TOOL_SUGG_LIST; - if(texttool_docs_get()) tools |= TOOL_DOCUMENT; + if (st->doplugins && texttool_text_is_active(st->text)) { + if (texttool_suggest_first()) tools |= TOOL_SUGG_LIST; + if (texttool_docs_get()) tools |= TOOL_DOCUMENT; } - if(ascii) { - if(tools & TOOL_SUGG_LIST) { - if((ascii != '_' && ascii != '*' && ispunct(ascii)) || text_check_whitespace(ascii)) { + if (ascii) { + if (tools & TOOL_SUGG_LIST) { + if ((ascii != '_' && ascii != '*' && ispunct(ascii)) || text_check_whitespace(ascii)) { confirm_suggestion(st->text, 0); text_update_line_edited(st->text->curl); } - else if((st->overwrite && txt_replace_char(st->text, ascii)) || txt_add_char(st->text, ascii)) { + else if ((st->overwrite && txt_replace_char(st->text, ascii)) || txt_add_char(st->text, ascii)) { get_suggest_prefix(st->text, 0); text_pop_suggest_list(); swallow= 1; draw= 1; } } - if(tools & TOOL_DOCUMENT) texttool_docs_clear(), doc_scroll= 0, draw= 1; + if (tools & TOOL_DOCUMENT) texttool_docs_clear(), doc_scroll= 0, draw= 1; } - else if(val==1 && evnt) { + else if (val==1 && evnt) { switch (evnt) { case LEFTMOUSE: - if(text_do_suggest_select(st, ar)) + if (text_do_suggest_select(st, ar)) swallow= 1; else { - if(tools & TOOL_SUGG_LIST) texttool_suggest_clear(); - if(tools & TOOL_DOCUMENT) texttool_docs_clear(), doc_scroll= 0; + if (tools & TOOL_SUGG_LIST) texttool_suggest_clear(); + if (tools & TOOL_DOCUMENT) texttool_docs_clear(), doc_scroll= 0; } draw= 1; break; case MIDDLEMOUSE: - if(text_do_suggest_select(st, ar)) { + if (text_do_suggest_select(st, ar)) { confirm_suggestion(st->text, 0); text_update_line_edited(st->text->curl); swallow= 1; } else { - if(tools & TOOL_SUGG_LIST) texttool_suggest_clear(); - if(tools & TOOL_DOCUMENT) texttool_docs_clear(), doc_scroll= 0; + if (tools & TOOL_SUGG_LIST) texttool_suggest_clear(); + if (tools & TOOL_DOCUMENT) texttool_docs_clear(), doc_scroll= 0; } draw= 1; break; case ESCKEY: draw= swallow= 1; - if(tools & TOOL_SUGG_LIST) texttool_suggest_clear(); - else if(tools & TOOL_DOCUMENT) texttool_docs_clear(), doc_scroll= 0; + if (tools & TOOL_SUGG_LIST) texttool_suggest_clear(); + else if (tools & TOOL_DOCUMENT) texttool_docs_clear(), doc_scroll= 0; else draw= swallow= 0; break; case RETKEY: - if(tools & TOOL_SUGG_LIST) { + if (tools & TOOL_SUGG_LIST) { confirm_suggestion(st->text, 0); text_update_line_edited(st->text->curl); swallow= 1; draw= 1; } - if(tools & TOOL_DOCUMENT) texttool_docs_clear(), doc_scroll= 0, draw= 1; + if (tools & TOOL_DOCUMENT) texttool_docs_clear(), doc_scroll= 0, draw= 1; break; case LEFTARROWKEY: case BACKSPACEKEY: - if(tools & TOOL_SUGG_LIST) { - if(qual) + if (tools & TOOL_SUGG_LIST) { + if (qual) texttool_suggest_clear(); else { /* Work out which char we are about to delete/pass */ - if(st->text->curl && st->text->curc > 0) { + if (st->text->curl && st->text->curc > 0) { char ch= st->text->curl->line[st->text->curc-1]; - if((ch=='_' || !ispunct(ch)) && !text_check_whitespace(ch)) { + if ((ch=='_' || !ispunct(ch)) && !text_check_whitespace(ch)) { get_suggest_prefix(st->text, -1); text_pop_suggest_list(); } @@ -278,17 +278,17 @@ static short UNUSED_FUNCTION(do_texttools)(SpaceText *st, char ascii, unsigned s texttool_suggest_clear(); } } - if(tools & TOOL_DOCUMENT) texttool_docs_clear(), doc_scroll= 0; + if (tools & TOOL_DOCUMENT) texttool_docs_clear(), doc_scroll= 0; break; case RIGHTARROWKEY: - if(tools & TOOL_SUGG_LIST) { - if(qual) + if (tools & TOOL_SUGG_LIST) { + if (qual) texttool_suggest_clear(); else { /* Work out which char we are about to pass */ - if(st->text->curl && st->text->curc < st->text->curl->len) { + if (st->text->curl && st->text->curc < st->text->curl->len) { char ch= st->text->curl->line[st->text->curc+1]; - if((ch=='_' || !ispunct(ch)) && !text_check_whitespace(ch)) { + if ((ch=='_' || !ispunct(ch)) && !text_check_whitespace(ch)) { get_suggest_prefix(st->text, 1); text_pop_suggest_list(); } @@ -299,24 +299,24 @@ static short UNUSED_FUNCTION(do_texttools)(SpaceText *st, char ascii, unsigned s texttool_suggest_clear(); } } - if(tools & TOOL_DOCUMENT) texttool_docs_clear(), doc_scroll= 0; + if (tools & TOOL_DOCUMENT) texttool_docs_clear(), doc_scroll= 0; break; case PAGEDOWNKEY: scroll= SUGG_LIST_SIZE-1; case WHEELDOWNMOUSE: case DOWNARROWKEY: - if(tools & TOOL_DOCUMENT) { + if (tools & TOOL_DOCUMENT) { doc_scroll++; swallow= 1; draw= 1; break; } - else if(tools & TOOL_SUGG_LIST) { + else if (tools & TOOL_SUGG_LIST) { SuggItem *sel = texttool_suggest_selected(); - if(!sel) { + if (!sel) { texttool_suggest_select(texttool_suggest_first()); } - else while(sel && sel!=texttool_suggest_last() && sel->next && scroll--) { + else while (sel && sel!=texttool_suggest_last() && sel->next && scroll--) { texttool_suggest_select(sel->next); sel= sel->next; } @@ -329,15 +329,15 @@ static short UNUSED_FUNCTION(do_texttools)(SpaceText *st, char ascii, unsigned s scroll= SUGG_LIST_SIZE-1; case WHEELUPMOUSE: case UPARROWKEY: - if(tools & TOOL_DOCUMENT) { - if(doc_scroll>0) doc_scroll--; + if (tools & TOOL_DOCUMENT) { + if (doc_scroll>0) doc_scroll--; swallow= 1; draw= 1; break; } - else if(tools & TOOL_SUGG_LIST) { + else if (tools & TOOL_SUGG_LIST) { SuggItem *sel = texttool_suggest_selected(); - while(sel && sel!=texttool_suggest_first() && sel->prev && scroll--) { + while (sel && sel!=texttool_suggest_first() && sel->prev && scroll--) { texttool_suggest_select(sel->prev); sel= sel->prev; } @@ -350,8 +350,8 @@ static short UNUSED_FUNCTION(do_texttools)(SpaceText *st, char ascii, unsigned s case LEFTSHIFTKEY: break; default: - if(tools & TOOL_SUGG_LIST) texttool_suggest_clear(), draw= 1; - if(tools & TOOL_DOCUMENT) texttool_docs_clear(), doc_scroll= 0, draw= 1; + if (tools & TOOL_SUGG_LIST) texttool_suggest_clear(), draw= 1; + if (tools & TOOL_DOCUMENT) texttool_docs_clear(), doc_scroll= 0, draw= 1; } } @@ -365,13 +365,13 @@ static short UNUSED_FUNCTION(do_texttools)(SpaceText *st, char ascii, unsigned s #if 0 #ifdef WITH_PYTHON /* Run text plugin scripts if enabled */ - if(st->doplugins && event && val) { - if(BPY_menu_do_shortcut(PYMENU_TEXTPLUGIN, event, qual)) { + if (st->doplugins && event && val) { + if (BPY_menu_do_shortcut(PYMENU_TEXTPLUGIN, event, qual)) { do_draw= 1; } } #endif - if(do_draw) + if (do_draw) ; // XXX redraw_alltext(); #endif @@ -383,26 +383,26 @@ static short UNUSED_FUNCTION(do_textmarkers)(SpaceText *st, char ascii, unsigned int qual= 0; // XXX text= st->text; - if(!text || text->id.lib || text->curl != text->sell) return 0; + if (!text || text->id.lib || text->curl != text->sell) return 0; marker= txt_find_marker(text, text->sell, text->selc, 0, 0); - if(marker && (marker->start > text->curc || marker->end < text->curc)) + if (marker && (marker->start > text->curc || marker->end < text->curc)) marker= NULL; - if(!marker) { + if (!marker) { /* Find the next temporary marker */ - if(evnt==TABKEY) { + if (evnt==TABKEY) { int lineno= txt_get_span(text->lines.first, text->curl); mrk= text->markers.first; - while(mrk) { - if(!marker && (mrk->flags & TMARK_TEMP)) marker= mrk; - if((mrk->flags & TMARK_TEMP) && (mrk->lineno > lineno || (mrk->lineno==lineno && mrk->end > text->curc))) { + while (mrk) { + if (!marker && (mrk->flags & TMARK_TEMP)) marker= mrk; + if ((mrk->flags & TMARK_TEMP) && (mrk->lineno > lineno || (mrk->lineno==lineno && mrk->end > text->curc))) { marker= mrk; break; } mrk= mrk->next; } - if(marker) { + if (marker) { txt_move_to(text, marker->lineno, marker->start, 0); txt_move_to(text, marker->lineno, marker->end, 1); // XXX text_update_cursor_moved(C); @@ -412,60 +412,60 @@ static short UNUSED_FUNCTION(do_textmarkers)(SpaceText *st, char ascii, unsigned swallow= 1; } } - else if(evnt==ESCKEY) { - if(txt_clear_markers(text, 0, TMARK_TEMP)) swallow= 1; - else if(txt_clear_markers(text, 0, 0)) swallow= 1; + else if (evnt==ESCKEY) { + if (txt_clear_markers(text, 0, TMARK_TEMP)) swallow= 1; + else if (txt_clear_markers(text, 0, 0)) swallow= 1; else return 0; evnt= ascii= val= 0; draw= 1; } - if(!swallow) return 0; + if (!swallow) return 0; } - if(ascii) { - if(marker->flags & TMARK_EDITALL) { + if (ascii) { + if (marker->flags & TMARK_EDITALL) { c= text->curc-marker->start; s= text->selc-marker->start; - if(s<0 || s>marker->end-marker->start) return 0; + if (s<0 || s>marker->end-marker->start) return 0; mrk= txt_next_marker(text, marker); - while(mrk) { + while (mrk) { nxt=txt_next_marker(text, mrk); /* mrk may become invalid */ txt_move_to(text, mrk->lineno, mrk->start+c, 0); - if(s!=c) txt_move_to(text, mrk->lineno, mrk->start+s, 1); - if(st->overwrite) { - if(txt_replace_char(text, ascii)) + if (s!=c) txt_move_to(text, mrk->lineno, mrk->start+s, 1); + if (st->overwrite) { + if (txt_replace_char(text, ascii)) text_update_line_edited(st->text->curl); } else { - if(txt_add_char(text, ascii)) { + if (txt_add_char(text, ascii)) { text_update_line_edited(st->text->curl); } } - if(mrk==marker || mrk==nxt) break; + if (mrk==marker || mrk==nxt) break; mrk=nxt; } swallow= 1; draw= 1; } } - else if(val) { + else if (val) { switch(evnt) { case BACKSPACEKEY: - if(marker->flags & TMARK_EDITALL) { + if (marker->flags & TMARK_EDITALL) { c= text->curc-marker->start; s= text->selc-marker->start; - if(s<0 || s>marker->end-marker->start) return 0; + if (s<0 || s>marker->end-marker->start) return 0; mrk= txt_next_marker(text, marker); - while(mrk) { + while (mrk) { nxt= txt_next_marker(text, mrk); /* mrk may become invalid */ txt_move_to(text, mrk->lineno, mrk->start+c, 0); - if(s!=c) txt_move_to(text, mrk->lineno, mrk->start+s, 1); + if (s!=c) txt_move_to(text, mrk->lineno, mrk->start+s, 1); txt_backspace_char(text); text_update_line_edited(st->text->curl); - if(mrk==marker || mrk==nxt) break; + if (mrk==marker || mrk==nxt) break; mrk= nxt; } swallow= 1; @@ -473,19 +473,19 @@ static short UNUSED_FUNCTION(do_textmarkers)(SpaceText *st, char ascii, unsigned } break; case DELKEY: - if(marker->flags & TMARK_EDITALL) { + if (marker->flags & TMARK_EDITALL) { c= text->curc-marker->start; s= text->selc-marker->start; - if(s<0 || s>marker->end-marker->start) return 0; + if (s<0 || s>marker->end-marker->start) return 0; mrk= txt_next_marker(text, marker); - while(mrk) { + while (mrk) { nxt= txt_next_marker(text, mrk); /* mrk may become invalid */ txt_move_to(text, mrk->lineno, mrk->start+c, 0); - if(s!=c) txt_move_to(text, mrk->lineno, mrk->start+s, 1); + if (s!=c) txt_move_to(text, mrk->lineno, mrk->start+s, 1); txt_delete_char(text); text_update_line_edited(st->text->curl); - if(mrk==marker || mrk==nxt) break; + if (mrk==marker || mrk==nxt) break; mrk= nxt; } swallow= 1; @@ -493,20 +493,20 @@ static short UNUSED_FUNCTION(do_textmarkers)(SpaceText *st, char ascii, unsigned } break; case TABKEY: - if(qual & LR_SHIFTKEY) { + if (qual & LR_SHIFTKEY) { nxt= marker->prev; - if(!nxt) nxt= text->markers.last; + if (!nxt) nxt= text->markers.last; } else { nxt= marker->next; - if(!nxt) nxt= text->markers.first; + if (!nxt) nxt= text->markers.first; } - if(marker->flags & TMARK_TEMP) { - if(nxt==marker) nxt= NULL; + if (marker->flags & TMARK_TEMP) { + if (nxt==marker) nxt= NULL; BLI_freelinkN(&text->markers, marker); } mrk= nxt; - if(mrk) { + if (mrk) { txt_move_to(text, mrk->lineno, mrk->start, 0); txt_move_to(text, mrk->lineno, mrk->end, 1); // XXX text_update_cursor_moved(C); @@ -521,7 +521,7 @@ static short UNUSED_FUNCTION(do_textmarkers)(SpaceText *st, char ascii, unsigned case ZKEY: if(evnt==ZKEY && !(qual & LR_CTRLKEY)) break; case RETKEY: case ESCKEY: - if(marker->flags & (TMARK_EDITALL | TMARK_TEMP)) + if (marker->flags & (TMARK_EDITALL | TMARK_TEMP)) txt_clear_markers(text, marker->group, 0); else BLI_freelinkN(&text->markers, marker); @@ -532,11 +532,11 @@ static short UNUSED_FUNCTION(do_textmarkers)(SpaceText *st, char ascii, unsigned case LEFTMOUSE: break; case FKEY: /* Allow find */ - if(qual & LR_SHIFTKEY) swallow= 1; + if (qual & LR_SHIFTKEY) swallow= 1; break; default: - if(qual!=0 && qual!=LR_SHIFTKEY) + if (qual!=0 && qual!=LR_SHIFTKEY) swallow= 1; /* Swallow all other shortcut events */ } } diff --git a/source/blender/editors/space_time/space_time.c b/source/blender/editors/space_time/space_time.c index 82ec3c46c73..5e56dfa728e 100644 --- a/source/blender/editors/space_time/space_time.c +++ b/source/blender/editors/space_time/space_time.c @@ -106,7 +106,7 @@ static void time_draw_cache(SpaceTime *stime, Object *ob) /* iterate over pointcaches on the active object, * add spacetimecache and vertex array for each */ - for(pid=pidlist.first; pid; pid=pid->next) { + for (pid=pidlist.first; pid; pid=pid->next) { float col[4], *fp; int i, sta = pid->cache->startframe, end = pid->cache->endframe; int len = (end - sta + 1)*4; @@ -130,12 +130,12 @@ static void time_draw_cache(SpaceTime *stime, Object *ob) break; } - if(pid->cache->cached_frames == NULL) + if (pid->cache->cached_frames == NULL) continue; /* make sure we have stc with correct array length */ - if(stc == NULL || MEM_allocN_len(stc->array) != len*2*sizeof(float)) { - if(stc) { + if (stc == NULL || MEM_allocN_len(stc->array) != len*2*sizeof(float)) { + if (stc) { MEM_freeN(stc->array); } else { @@ -227,7 +227,7 @@ static void time_draw_cache(SpaceTime *stime, Object *ob) BLI_freelistN(&pidlist); /* free excessive caches */ - while(stc) { + while (stc) { SpaceTimeCache *tmp = stc->next; BLI_remlink(&stime->caches, stc); MEM_freeN(stc->array); @@ -380,7 +380,7 @@ static void time_refresh(const bContext *UNUSED(C), ScrArea *sa) { /* find the main timeline region and refresh cache display*/ ARegion *ar= BKE_area_find_region_type(sa, RGN_TYPE_WINDOW); - if(ar) { + if (ar) { SpaceTime *stime = (SpaceTime *)sa->spacedata.first; time_cache_refresh(stime); } @@ -511,7 +511,7 @@ static void time_main_area_listener(ARegion *ar, wmNotifier *wmn) /* context changes */ switch(wmn->category) { case NC_SPACE: - if(wmn->data == ND_SPACE_TIME) + if (wmn->data == ND_SPACE_TIME) ED_region_tag_redraw(ar); break; @@ -551,7 +551,7 @@ static void time_header_area_listener(ARegion *ar, wmNotifier *wmn) /* context changes */ switch(wmn->category) { case NC_SCREEN: - if(wmn->data==ND_ANIMPLAY) + if (wmn->data==ND_ANIMPLAY) ED_region_tag_redraw(ar); break; @@ -567,7 +567,7 @@ static void time_header_area_listener(ARegion *ar, wmNotifier *wmn) } case NC_SPACE: - if(wmn->data == ND_SPACE_TIME) + if (wmn->data == ND_SPACE_TIME) ED_region_tag_redraw(ar); break; } diff --git a/source/blender/editors/space_view3d/drawarmature.c b/source/blender/editors/space_view3d/drawarmature.c index 0f3110c478f..aae0348de20 100644 --- a/source/blender/editors/space_view3d/drawarmature.c +++ b/source/blender/editors/space_view3d/drawarmature.c @@ -2565,7 +2565,7 @@ int draw_armature(Scene *scene, View3D *v3d, ARegion *ar, Base *base, int dt, in draw_ebones(v3d, ar, ob, dt); arm->flag &= ~ARM_EDITMODE; } - else{ + else { /* Draw Pose */ if (ob->pose && ob->pose->chanbase.first) { /* drawing posemode selection indices or colors only in these cases */ diff --git a/source/blender/editors/space_view3d/drawmesh.c b/source/blender/editors/space_view3d/drawmesh.c index 816667978f1..082707fbefb 100644 --- a/source/blender/editors/space_view3d/drawmesh.c +++ b/source/blender/editors/space_view3d/drawmesh.c @@ -152,7 +152,7 @@ static DMDrawOption draw_mesh_face_select__setHiddenOpts(void *userData, int ind else return DM_DRAW_OPTION_SKIP; } - else if(flags & eEdge_Select) + else if (flags & eEdge_Select) return DM_DRAW_OPTION_NORMAL; else return DM_DRAW_OPTION_SKIP; diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c index c0c117242d7..e8e1083805a 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -3970,7 +3970,7 @@ static int drawDispList(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *bas GPU_end_object_materials(); } } - else{ + else { /* MetaBalls use DL_INDEX4 type of DispList */ retval= drawDispListwire(lb); } @@ -4451,7 +4451,7 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, RegionView3D *rv weight_to_rgb(ma_col, intensity); } } - else{ + else { ChildParticle *cpa= &psys->child[a-totpart]; pa_time=psys_get_child_time(psys,cpa,cfra,&pa_birthtime,&pa_dietime); @@ -4732,7 +4732,7 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, RegionView3D *rv glNormalPointer(GL_FLOAT, 0, pdd->ndata); glEnable(GL_LIGHTING); } - else{ + else { glDisableClientState(GL_NORMAL_ARRAY); glDisable(GL_LIGHTING); } @@ -4899,7 +4899,7 @@ static void draw_ptcache_edit(Scene *scene, View3D *v3d, PTCacheEdit *edit) if (key->flag&PEK_SELECT) { copy_v3_v3(cd,sel_col); } - else{ + else { copy_v3_v3(cd,nosel_col); } diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index 03b571a8f73..1f6ec45f908 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -1488,7 +1488,7 @@ unsigned int view3d_sample_backbuf_rect(ViewContext *vc, const int mval[2], int goto exit; } } - else{ + else { *dist= (short) sqrt( (float)distance ); // XXX, this distance is wrong - index = *tbuf - min+1; // messy yah, but indices start at 1 goto exit; diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c index a2616de124a..f8404937f7e 100644 --- a/source/blender/editors/space_view3d/view3d_edit.c +++ b/source/blender/editors/space_view3d/view3d_edit.c @@ -2833,7 +2833,7 @@ static int viewnumpad_exec(bContext *C, wmOperator *op) smooth_view(C, v3d, ar, NULL, v3d->camera, rv3d->ofs, rv3d->viewquat, &rv3d->dist, &v3d->lens); } - else{ + else { /* return to settings of last view */ /* does smooth_view too */ axis_set_view(C, v3d, ar, diff --git a/source/blender/editors/space_view3d/view3d_snap.c b/source/blender/editors/space_view3d/view3d_snap.c index 1cc63e02c5d..fdaf34e2e3c 100644 --- a/source/blender/editors/space_view3d/view3d_snap.c +++ b/source/blender/editors/space_view3d/view3d_snap.c @@ -176,7 +176,7 @@ static void special_transvert_update(Object *obedit) copy_v3_v3(ebo->head, ebo->parent->tail); } /* If this bone has a parent tip that has NOT been moved */ - else{ + else { copy_v3_v3(ebo->parent->tail, ebo->head); } } diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index e027e0a37f7..04b6a095117 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -104,7 +104,7 @@ static int doEdgeSlide(TransInfo *t, float perc); void setTransformViewMatrices(TransInfo *t) { - if(t->spacetype==SPACE_VIEW3D && t->ar && t->ar->regiontype == RGN_TYPE_WINDOW) { + if (t->spacetype==SPACE_VIEW3D && t->ar && t->ar->regiontype == RGN_TYPE_WINDOW) { RegionView3D *rv3d = t->ar->regiondata; copy_m4_m4(t->viewmat, rv3d->viewmat); @@ -144,7 +144,7 @@ void convertViewVec(TransInfo *t, float r_vec[3], int dx, int dy) mval_f[1] = dy; ED_view3d_win_to_delta(t->ar, mval_f, r_vec); } - else if(t->spacetype==SPACE_IMAGE) { + else if (t->spacetype==SPACE_IMAGE) { float aspx, aspy; convertViewVec2D(t->view, r_vec, dx, dy); @@ -153,13 +153,13 @@ void convertViewVec(TransInfo *t, float r_vec[3], int dx, int dy) r_vec[0] *= aspx; r_vec[1] *= aspy; } - else if(ELEM(t->spacetype, SPACE_IPO, SPACE_NLA)) { + else if (ELEM(t->spacetype, SPACE_IPO, SPACE_NLA)) { convertViewVec2D(t->view, r_vec, dx, dy); } - else if(ELEM(t->spacetype, SPACE_NODE, SPACE_SEQ)) { + else if (ELEM(t->spacetype, SPACE_NODE, SPACE_SEQ)) { convertViewVec2D(&t->ar->v2d, r_vec, dx, dy); } - else if(t->spacetype==SPACE_CLIP) { + else if (t->spacetype==SPACE_CLIP) { View2D *v2d = t->view; float divx, divy; @@ -179,10 +179,10 @@ void convertViewVec(TransInfo *t, float r_vec[3], int dx, int dy) void projectIntView(TransInfo *t, const float vec[3], int adr[2]) { if (t->spacetype==SPACE_VIEW3D) { - if(t->ar->regiontype == RGN_TYPE_WINDOW) + if (t->ar->regiontype == RGN_TYPE_WINDOW) project_int_noclip(t->ar, vec, adr); } - else if(t->spacetype==SPACE_IMAGE) { + else if (t->spacetype==SPACE_IMAGE) { float aspx, aspy, v[2]; ED_space_image_uv_aspect(t->sa->spacedata.first, &aspx, &aspy); @@ -191,7 +191,7 @@ void projectIntView(TransInfo *t, const float vec[3], int adr[2]) UI_view2d_to_region_no_clip(t->view, v[0], v[1], adr, adr+1); } - else if(t->spacetype == SPACE_ACTION) { + else if (t->spacetype == SPACE_ACTION) { int out[2] = {0, 0}; #if 0 SpaceAction *sact = t->sa->spacedata.first; @@ -210,21 +210,21 @@ void projectIntView(TransInfo *t, const float vec[3], int adr[2]) adr[0]= out[0]; adr[1]= out[1]; } - else if(ELEM(t->spacetype, SPACE_IPO, SPACE_NLA)) { + else if (ELEM(t->spacetype, SPACE_IPO, SPACE_NLA)) { int out[2] = {0, 0}; UI_view2d_to_region_no_clip((View2D *)t->view, vec[0], vec[1], out, out+1); adr[0]= out[0]; adr[1]= out[1]; } - else if(t->spacetype==SPACE_SEQ) { /* XXX not tested yet, but should work */ + else if (t->spacetype==SPACE_SEQ) { /* XXX not tested yet, but should work */ int out[2] = {0, 0}; UI_view2d_to_region_no_clip((View2D *)t->view, vec[0], vec[1], out, out+1); adr[0]= out[0]; adr[1]= out[1]; } - else if(t->spacetype==SPACE_CLIP) { + else if (t->spacetype==SPACE_CLIP) { UI_view2d_to_region_no_clip(t->view, vec[0], vec[1], adr, adr+1); } } @@ -262,7 +262,7 @@ void applyAspectRatio(TransInfo *t, float *vec) SpaceImage *sima= t->sa->spacedata.first; float aspx, aspy; - if((sima->flag & SI_COORDFLOATS)==0) { + if ((sima->flag & SI_COORDFLOATS)==0) { int width, height; ED_space_image_size(sima, &width, &height); @@ -282,7 +282,7 @@ void removeAspectRatio(TransInfo *t, float *vec) SpaceImage *sima= t->sa->spacedata.first; float aspx, aspy; - if((sima->flag & SI_COORDFLOATS)==0) { + if ((sima->flag & SI_COORDFLOATS)==0) { int width, height; ED_space_image_size(sima, &width, &height); @@ -301,7 +301,7 @@ static void viewRedrawForce(const bContext *C, TransInfo *t) if (t->spacetype == SPACE_VIEW3D) { /* Do we need more refined tags? */ - if(t->flag & T_POSE) + if (t->flag & T_POSE) WM_event_add_notifier(C, NC_OBJECT|ND_POSE, NULL); else WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, NULL); @@ -323,17 +323,17 @@ static void viewRedrawForce(const bContext *C, TransInfo *t) else if (t->spacetype == SPACE_NLA) { WM_event_add_notifier(C, NC_ANIMATION|ND_NLA|NA_EDITED, NULL); } - else if(t->spacetype == SPACE_NODE) { + else if (t->spacetype == SPACE_NODE) { //ED_area_tag_redraw(t->sa); WM_event_add_notifier(C, NC_SPACE|ND_SPACE_NODE_VIEW, NULL); } - else if(t->spacetype == SPACE_SEQ) { + else if (t->spacetype == SPACE_SEQ) { WM_event_add_notifier(C, NC_SCENE|ND_SEQUENCER, NULL); } else if (t->spacetype==SPACE_IMAGE) { // XXX how to deal with lock? SpaceImage *sima= (SpaceImage*)t->sa->spacedata.first; - if(sima->lock) WM_event_add_notifier(C, NC_GEOM|ND_DATA, t->obedit->data); + if (sima->lock) WM_event_add_notifier(C, NC_GEOM|ND_DATA, t->obedit->data); else ED_area_tag_redraw(t->sa); } else if (t->spacetype==SPACE_CLIP) { @@ -351,7 +351,7 @@ static void viewRedrawPost(bContext *C, TransInfo *t) { ED_area_headerprint(t->sa, NULL); - if(t->spacetype == SPACE_VIEW3D) { + if (t->spacetype == SPACE_VIEW3D) { /* if autokeying is enabled, send notifiers that keyframes were added */ if (IS_AUTOKEY_ON(t->scene)) WM_main_add_notifier(NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL); @@ -362,15 +362,15 @@ static void viewRedrawPost(bContext *C, TransInfo *t) } #if 0 // TRANSFORM_FIX_ME - if(t->spacetype==SPACE_VIEW3D) { + if (t->spacetype==SPACE_VIEW3D) { allqueue(REDRAWBUTSOBJECT, 0); allqueue(REDRAWVIEW3D, 0); } - else if(t->spacetype==SPACE_IMAGE) { + else if (t->spacetype==SPACE_IMAGE) { allqueue(REDRAWIMAGE, 0); allqueue(REDRAWVIEW3D, 0); } - else if(ELEM3(t->spacetype, SPACE_ACTION, SPACE_NLA, SPACE_IPO)) { + else if (ELEM3(t->spacetype, SPACE_ACTION, SPACE_NLA, SPACE_IPO)) { allqueue(REDRAWVIEW3D, 0); allqueue(REDRAWACTION, 0); allqueue(REDRAWNLA, 0); @@ -393,7 +393,7 @@ void BIF_selectOrientation(void) val= pupmenu(str_menu); MEM_freeN(str_menu); - if(val >= 0) { + if (val >= 0) { G.vd->twmode = val; } #endif @@ -418,23 +418,27 @@ static void view_editmove(unsigned short UNUSED(event)) switch(event) { case WHEELUPMOUSE: - if( G.qual & LR_SHIFTKEY ) { - if( G.qual & LR_ALTKEY ) { + if ( G.qual & LR_SHIFTKEY ) { + if ( G.qual & LR_ALTKEY ) { G.qual &= ~LR_SHIFTKEY; persptoetsen(PAD2); G.qual |= LR_SHIFTKEY; - } else { + } + else { persptoetsen(PAD2); } - } else if( G.qual & LR_CTRLKEY ) { - if( G.qual & LR_ALTKEY ) { + } + else if ( G.qual & LR_CTRLKEY ) { + if ( G.qual & LR_ALTKEY ) { G.qual &= ~LR_CTRLKEY; persptoetsen(PAD4); G.qual |= LR_CTRLKEY; - } else { + } + else { persptoetsen(PAD4); } - } else if(U.uiflag & USER_WHEELZOOMDIR) + } + else if (U.uiflag & USER_WHEELZOOMDIR) persptoetsen(PADMINUS); else persptoetsen(PADPLUSKEY); @@ -442,23 +446,27 @@ static void view_editmove(unsigned short UNUSED(event)) refresh = 1; break; case WHEELDOWNMOUSE: - if( G.qual & LR_SHIFTKEY ) { - if( G.qual & LR_ALTKEY ) { + if ( G.qual & LR_SHIFTKEY ) { + if ( G.qual & LR_ALTKEY ) { G.qual &= ~LR_SHIFTKEY; persptoetsen(PAD8); G.qual |= LR_SHIFTKEY; - } else { + } + else { persptoetsen(PAD8); } - } else if( G.qual & LR_CTRLKEY ) { - if( G.qual & LR_ALTKEY ) { + } + else if ( G.qual & LR_CTRLKEY ) { + if ( G.qual & LR_ALTKEY ) { G.qual &= ~LR_CTRLKEY; persptoetsen(PAD6); G.qual |= LR_CTRLKEY; - } else { + } + else { persptoetsen(PAD6); } - } else if(U.uiflag & USER_WHEELZOOMDIR) + } + else if (U.uiflag & USER_WHEELZOOMDIR) persptoetsen(PADPLUSKEY); else persptoetsen(PADMINUS); @@ -531,7 +539,7 @@ wmKeyMap* transform_modal_keymap(wmKeyConfig *keyconf) wmKeyMap *keymap= WM_modalkeymap_get(keyconf, "Transform Modal Map"); /* this function is called for each spacetype, only needs to add map once */ - if(keymap) return NULL; + if (keymap) return NULL; keymap= WM_modalkeymap_add(keyconf, "Transform Modal Map", modal_items); @@ -610,15 +618,15 @@ int transformEvent(TransInfo *t, wmEvent *event) break; case TFM_MODAL_TRANSLATE: /* only switch when... */ - if( ELEM3(t->mode, TFM_ROTATION, TFM_RESIZE, TFM_TRACKBALL) ) { + if ( ELEM3(t->mode, TFM_ROTATION, TFM_RESIZE, TFM_TRACKBALL) ) { resetTransRestrictions(t); restoreTransObjects(t); initTranslation(t); initSnapping(t, NULL); // need to reinit after mode change t->redraw |= TREDRAW_HARD; } - else if(t->mode == TFM_TRANSLATION) { - if(t->options&CTX_MOVIECLIP) { + else if (t->mode == TFM_TRANSLATION) { + if (t->options&CTX_MOVIECLIP) { restoreTransObjects(t); t->flag^= T_ALT_TRANSFORM; @@ -628,8 +636,8 @@ int transformEvent(TransInfo *t, wmEvent *event) break; case TFM_MODAL_ROTATE: /* only switch when... */ - if(!(t->options & CTX_TEXTURE) && !(t->options & CTX_MOVIECLIP)) { - if( ELEM4(t->mode, TFM_ROTATION, TFM_RESIZE, TFM_TRACKBALL, TFM_TRANSLATION) ) { + if (!(t->options & CTX_TEXTURE) && !(t->options & CTX_MOVIECLIP)) { + if ( ELEM4(t->mode, TFM_ROTATION, TFM_RESIZE, TFM_TRACKBALL, TFM_TRANSLATION) ) { resetTransRestrictions(t); @@ -648,7 +656,7 @@ int transformEvent(TransInfo *t, wmEvent *event) break; case TFM_MODAL_RESIZE: /* only switch when... */ - if( ELEM3(t->mode, TFM_ROTATION, TFM_TRANSLATION, TFM_TRACKBALL) ) { + if ( ELEM3(t->mode, TFM_ROTATION, TFM_TRANSLATION, TFM_TRACKBALL) ) { resetTransRestrictions(t); restoreTransObjects(t); initResize(t); @@ -760,9 +768,9 @@ int transformEvent(TransInfo *t, wmEvent *event) t->redraw |= TREDRAW_HARD; break; case TFM_MODAL_PROPSIZE_UP: - if(t->flag & T_PROP_EDIT) { + if (t->flag & T_PROP_EDIT) { t->prop_size*= 1.1f; - if(t->spacetype==SPACE_VIEW3D && t->persp != RV3D_ORTHO) + if (t->spacetype==SPACE_VIEW3D && t->persp != RV3D_ORTHO) t->prop_size= MIN2(t->prop_size, ((View3D *)t->view)->far); calculatePropRatio(t); } @@ -863,7 +871,7 @@ int transformEvent(TransInfo *t, wmEvent *event) break; case GKEY: /* only switch when... */ - if( ELEM3(t->mode, TFM_ROTATION, TFM_RESIZE, TFM_TRACKBALL) ) { + if ( ELEM3(t->mode, TFM_ROTATION, TFM_RESIZE, TFM_TRACKBALL) ) { resetTransRestrictions(t); restoreTransObjects(t); initTranslation(t); @@ -873,7 +881,7 @@ int transformEvent(TransInfo *t, wmEvent *event) break; case SKEY: /* only switch when... */ - if( ELEM3(t->mode, TFM_ROTATION, TFM_TRANSLATION, TFM_TRACKBALL) ) { + if ( ELEM3(t->mode, TFM_ROTATION, TFM_TRANSLATION, TFM_TRACKBALL) ) { resetTransRestrictions(t); restoreTransObjects(t); initResize(t); @@ -883,8 +891,8 @@ int transformEvent(TransInfo *t, wmEvent *event) break; case RKEY: /* only switch when... */ - if(!(t->options & CTX_TEXTURE) && !(t->options & CTX_MOVIECLIP)) { - if( ELEM4(t->mode, TFM_ROTATION, TFM_RESIZE, TFM_TRACKBALL, TFM_TRANSLATION) ) { + if (!(t->options & CTX_TEXTURE) && !(t->options & CTX_MOVIECLIP)) { + if ( ELEM4(t->mode, TFM_ROTATION, TFM_RESIZE, TFM_TRACKBALL, TFM_TRANSLATION) ) { resetTransRestrictions(t); @@ -918,21 +926,25 @@ int transformEvent(TransInfo *t, wmEvent *event) if (t->flag & T_2D_EDIT) { if (cmode == 'X') { stopConstraint(t); - } else { + } + else { setUserConstraint(t, V3D_MANIP_GLOBAL, (CON_AXIS0), "along X"); } - } else { + } + else { if (cmode == 'X') { if (t->con.orientation != V3D_MANIP_GLOBAL) { stopConstraint(t); - } else { + } + else { short orientation = t->current_orientation != V3D_MANIP_GLOBAL ? t->current_orientation : V3D_MANIP_LOCAL; if ((t->modifiers & MOD_CONSTRAINT_PLANE) == 0) setUserConstraint(t, orientation, (CON_AXIS0), "along %s X"); else if (t->modifiers & MOD_CONSTRAINT_PLANE) setUserConstraint(t, orientation, (CON_AXIS1|CON_AXIS2), "locking %s X"); } - } else { + } + else { if ((t->modifiers & MOD_CONSTRAINT_PLANE) == 0) setUserConstraint(t, V3D_MANIP_GLOBAL, (CON_AXIS0), "along %s X"); else if (t->modifiers & MOD_CONSTRAINT_PLANE) @@ -947,21 +959,25 @@ int transformEvent(TransInfo *t, wmEvent *event) if (t->flag & T_2D_EDIT) { if (cmode == 'Y') { stopConstraint(t); - } else { + } + else { setUserConstraint(t, V3D_MANIP_GLOBAL, (CON_AXIS1), "along Y"); } - } else { + } + else { if (cmode == 'Y') { if (t->con.orientation != V3D_MANIP_GLOBAL) { stopConstraint(t); - } else { + } + else { short orientation = t->current_orientation != V3D_MANIP_GLOBAL ? t->current_orientation : V3D_MANIP_LOCAL; if ((t->modifiers & MOD_CONSTRAINT_PLANE) == 0) setUserConstraint(t, orientation, (CON_AXIS1), "along %s Y"); else if (t->modifiers & MOD_CONSTRAINT_PLANE) setUserConstraint(t, orientation, (CON_AXIS0|CON_AXIS2), "locking %s Y"); } - } else { + } + else { if ((t->modifiers & MOD_CONSTRAINT_PLANE) == 0) setUserConstraint(t, V3D_MANIP_GLOBAL, (CON_AXIS1), "along %s Y"); else if (t->modifiers & MOD_CONSTRAINT_PLANE) @@ -976,14 +992,16 @@ int transformEvent(TransInfo *t, wmEvent *event) if (cmode == 'Z') { if (t->con.orientation != V3D_MANIP_GLOBAL) { stopConstraint(t); - } else { + } + else { short orientation = t->current_orientation != V3D_MANIP_GLOBAL ? t->current_orientation : V3D_MANIP_LOCAL; if ((t->modifiers & MOD_CONSTRAINT_PLANE) == 0) setUserConstraint(t, orientation, (CON_AXIS2), "along %s Z"); else if (t->modifiers & MOD_CONSTRAINT_PLANE) setUserConstraint(t, orientation, (CON_AXIS0|CON_AXIS1), "locking %s Z"); } - } else { + } + else { if ((t->modifiers & MOD_CONSTRAINT_PLANE) == 0) setUserConstraint(t, V3D_MANIP_GLOBAL, (CON_AXIS2), "along %s Z"); else if (t->modifiers & MOD_CONSTRAINT_PLANE) @@ -1000,9 +1018,9 @@ int transformEvent(TransInfo *t, wmEvent *event) } break; case PADPLUSKEY: - if(event->alt && t->flag & T_PROP_EDIT) { + if (event->alt && t->flag & T_PROP_EDIT) { t->prop_size *= 1.1f; - if(t->spacetype==SPACE_VIEW3D && t->persp != RV3D_ORTHO) + if (t->spacetype==SPACE_VIEW3D && t->persp != RV3D_ORTHO) t->prop_size= MIN2(t->prop_size, ((View3D *)t->view)->far); calculatePropRatio(t); } @@ -1017,7 +1035,7 @@ int transformEvent(TransInfo *t, wmEvent *event) t->redraw= 1; break; case PADMINUS: - if(event->alt && t->flag & T_PROP_EDIT) { + if (event->alt && t->flag & T_PROP_EDIT) { t->prop_size*= 0.90909090f; calculatePropRatio(t); } @@ -1060,7 +1078,7 @@ int transformEvent(TransInfo *t, wmEvent *event) break; // case LEFTMOUSE: // case RIGHTMOUSE: -// if(WM_modal_tweak_exit(event, t->event_type)) +// if (WM_modal_tweak_exit(event, t->event_type)) //// if (t->options & CTX_TWEAK) // t->state = TRANS_CONFIRM; // break; @@ -1205,7 +1223,7 @@ static void drawArc(float size, float angle_start, float angle_end, int segments glBegin(GL_LINE_STRIP); - for( angle = angle_start; angle < angle_end; angle += delta) + for ( angle = angle_start; angle < angle_end; angle += delta) { glVertex2f( cosf(angle) * size, sinf(angle) * size); } @@ -1218,7 +1236,7 @@ static int helpline_poll(bContext *C) { ARegion *ar= CTX_wm_region(C); - if(ar && ar->regiontype==RGN_TYPE_WINDOW) + if (ar && ar->regiontype==RGN_TYPE_WINDOW) return 1; return 0; } @@ -1236,13 +1254,13 @@ static void drawHelpline(bContext *UNUSED(C), int x, int y, void *customdata) mval[1]= y; copy_v3_v3(vecrot, t->center); - if(t->flag & T_EDIT) { + if (t->flag & T_EDIT) { Object *ob= t->obedit; - if(ob) mul_m4_v3(ob->obmat, vecrot); + if (ob) mul_m4_v3(ob->obmat, vecrot); } - else if(t->flag & T_POSE) { + else if (t->flag & T_POSE) { Object *ob=t->poseobj; - if(ob) mul_m4_v3(ob->obmat, vecrot); + if (ob) mul_m4_v3(ob->obmat, vecrot); } projectFloatView(t, vecrot, cent); // no overflow in extreme cases @@ -1436,7 +1454,8 @@ void saveTransform(bContext *C, TransInfo *t, wmOperator *op) /* do we check for parameter? */ if (t->modifiers & MOD_SNAP) { ts->snap_flag |= SCE_SNAP; - } else { + } + else { ts->snap_flag &= ~SCE_SNAP; } @@ -1474,7 +1493,8 @@ void saveTransform(bContext *C, TransInfo *t, wmOperator *op) * */ if (t->con.mode & CON_APPLY) { RNA_enum_set(op->ptr, "constraint_orientation", t->con.orientation); - } else { + } + else { RNA_enum_set(op->ptr, "constraint_orientation", t->current_orientation); } @@ -1509,7 +1529,7 @@ int initTransform(bContext *C, TransInfo *t, wmOperator *op, wmEvent *event, int if ( (prop = RNA_struct_find_property(op->ptr, "texture_space")) && RNA_property_is_set(op->ptr, prop)) { - if(RNA_property_boolean_get(op->ptr, prop)) { + if (RNA_property_boolean_get(op->ptr, prop)) { options |= CTX_TEXTURE; } } @@ -1540,7 +1560,7 @@ int initTransform(bContext *C, TransInfo *t, wmOperator *op, wmEvent *event, int return 0; } - if(t->spacetype == SPACE_VIEW3D) + if (t->spacetype == SPACE_VIEW3D) { //calc_manipulator_stats(curarea); initTransformOrientation(C, t); @@ -1550,13 +1570,13 @@ int initTransform(bContext *C, TransInfo *t, wmOperator *op, wmEvent *event, int //t->draw_handle_pixel = ED_region_draw_cb_activate(t->ar->type, drawTransformPixel, t, REGION_DRAW_POST_PIXEL); t->draw_handle_cursor = WM_paint_cursor_activate(CTX_wm_manager(C), helpline_poll, drawHelpline, t); } - else if(t->spacetype == SPACE_IMAGE) { + else if (t->spacetype == SPACE_IMAGE) { unit_m3(t->spacemtx); t->draw_handle_view = ED_region_draw_cb_activate(t->ar->type, drawTransformView, t, REGION_DRAW_POST_VIEW); //t->draw_handle_pixel = ED_region_draw_cb_activate(t->ar->type, drawTransformPixel, t, REGION_DRAW_POST_PIXEL); t->draw_handle_cursor = WM_paint_cursor_activate(CTX_wm_manager(C), helpline_poll, drawHelpline, t); } - else if(t->spacetype == SPACE_CLIP) { + else if (t->spacetype == SPACE_CLIP) { unit_m3(t->spacemtx); t->draw_handle_view = ED_region_draw_cb_activate(t->ar->type, drawTransformView, t, REGION_DRAW_POST_VIEW); t->options |= CTX_MOVIECLIP; @@ -1572,7 +1592,7 @@ int initTransform(bContext *C, TransInfo *t, wmOperator *op, wmEvent *event, int } /* Stupid code to have Ctrl-Click on manipulator work ok */ - if(event) + if (event) { wmKeyMap *keymap = WM_keymap_active(CTX_wm_manager(C), op->type->modalkeymap); wmKeyMapItem *kmi; @@ -1646,7 +1666,7 @@ int initTransform(bContext *C, TransInfo *t, wmOperator *op, wmEvent *event, int case TFM_BONESIZE: { /* used for both B-Bone width (bonesize) as for deform-dist (envelope) */ bArmature *arm= t->poseobj->data; - if(arm->drawtype==ARM_ENVELOPE) + if (arm->drawtype==ARM_ENVELOPE) initBoneEnvelope(t); else initBoneSize(t); @@ -1711,7 +1731,7 @@ int initTransform(bContext *C, TransInfo *t, wmOperator *op, wmEvent *event, int break; } - if(t->state == TRANS_CANCEL) + if (t->state == TRANS_CANCEL) { postTrans(C, t); return 0; @@ -1723,9 +1743,10 @@ int initTransform(bContext *C, TransInfo *t, wmOperator *op, wmEvent *event, int { float values[4]= {0}; /* in case value isn't length 4, avoid uninitialized memory */ - if(RNA_property_array_check(prop)) { + if (RNA_property_array_check(prop)) { RNA_float_get_array(op->ptr, "value", values); - } else { + } + else { values[0]= RNA_float_get(op->ptr, "value"); } @@ -1784,7 +1805,8 @@ void transformApply(bContext *C, TransInfo *t) viewRedrawForce(C, t); } t->redraw = TREDRAW_NOTHING; - } else if (t->redraw & TREDRAW_SOFT) { + } + else if (t->redraw & TREDRAW_SOFT) { viewRedrawForce(C, t); } @@ -1823,10 +1845,10 @@ int transformEnd(bContext *C, TransInfo *t) if (t->state != TRANS_STARTING && t->state != TRANS_RUNNING) { /* handle restoring objects */ - if(t->state == TRANS_CANCEL) + if (t->state == TRANS_CANCEL) { /* exception, edge slide transformed UVs too */ - if(t->mode==TFM_EDGE_SLIDE) + if (t->mode==TFM_EDGE_SLIDE) doEdgeSlide(t, 0.0f); exit_code = OPERATOR_CANCELLED; @@ -1847,11 +1869,11 @@ int transformEnd(bContext *C, TransInfo *t) /* Undo as last, certainly after special_trans_update! */ - if(t->state == TRANS_CANCEL) { -// if(t->undostr) ED_undo_push(C, t->undostr); + if (t->state == TRANS_CANCEL) { +// if (t->undostr) ED_undo_push(C, t->undostr); } else { -// if(t->undostr) ED_undo_push(C, t->undostr); +// if (t->undostr) ED_undo_push(C, t->undostr); // else ED_undo_push(C, transform_to_undostr(t)); } t->undostr= NULL; @@ -1868,31 +1890,31 @@ int transformEnd(bContext *C, TransInfo *t) static void protectedTransBits(short protectflag, float *vec) { - if(protectflag & OB_LOCK_LOCX) + if (protectflag & OB_LOCK_LOCX) vec[0]= 0.0f; - if(protectflag & OB_LOCK_LOCY) + if (protectflag & OB_LOCK_LOCY) vec[1]= 0.0f; - if(protectflag & OB_LOCK_LOCZ) + if (protectflag & OB_LOCK_LOCZ) vec[2]= 0.0f; } static void protectedSizeBits(short protectflag, float *size) { - if(protectflag & OB_LOCK_SCALEX) + if (protectflag & OB_LOCK_SCALEX) size[0]= 1.0f; - if(protectflag & OB_LOCK_SCALEY) + if (protectflag & OB_LOCK_SCALEY) size[1]= 1.0f; - if(protectflag & OB_LOCK_SCALEZ) + if (protectflag & OB_LOCK_SCALEZ) size[2]= 1.0f; } static void protectedRotateBits(short protectflag, float *eul, float *oldeul) { - if(protectflag & OB_LOCK_ROTX) + if (protectflag & OB_LOCK_ROTX) eul[0]= oldeul[0]; - if(protectflag & OB_LOCK_ROTY) + if (protectflag & OB_LOCK_ROTY) eul[1]= oldeul[1]; - if(protectflag & OB_LOCK_ROTZ) + if (protectflag & OB_LOCK_ROTZ) eul[2]= oldeul[2]; } @@ -2125,7 +2147,7 @@ static void constraintRotLim(TransInfo *UNUSED(t), TransData *td) continue; /* only do conversion if necessary, to preserve quats and eulers */ - if(!dolimit) { + if (!dolimit) { constraintob_from_transdata(&cob, td); dolimit= 1; } @@ -2149,7 +2171,7 @@ static void constraintRotLim(TransInfo *UNUSED(t), TransData *td) } } - if(dolimit) { + if (dolimit) { /* copy results from cob->matrix */ if (td->ext->rotOrder == ROT_MODE_QUAT) { /* quats */ @@ -2278,7 +2300,7 @@ void initWarp(TransInfo *t) t->flag |= T_NO_CONSTRAINT; /* we need min/max in view space */ - for(i = 0; i < t->total; i++) { + for (i = 0; i < t->total; i++) { float center[3]; copy_v3_v3(center, t->data[i].center); mul_m3_v3(t->data[i].mtx, center); @@ -2369,7 +2391,7 @@ int Warp(TransInfo *t, const int UNUSED(mval[2])) circumfac /= 2; /* only need 180 on each side to make 360 */ - for(i = 0; i < t->total; i++, td++) { + for (i = 0; i < t->total; i++, td++) { float loc[3]; if (td->flag & TD_NOACTION) break; @@ -2505,7 +2527,7 @@ int Shear(TransInfo *t, const int UNUSED(mval[2])) mul_m3_m3m3(tmat, smat, persmat); mul_m3_m3m3(totmat, persinv, tmat); - for(i = 0 ; i < t->total; i++, td++) { + for (i = 0 ; i < t->total; i++, td++) { if (td->flag & TD_NOACTION) break; @@ -2620,9 +2642,9 @@ static void TransMat3ToSize( float mat[][3], float smat[][3], float *size) size[2]= normalize_v3(vec); /* first tried with dotproduct... but the sign flip is crucial */ - if( VECSIGNFLIP(mat[0], smat[0]) ) size[0]= -size[0]; - if( VECSIGNFLIP(mat[1], smat[1]) ) size[1]= -size[1]; - if( VECSIGNFLIP(mat[2], smat[2]) ) size[2]= -size[2]; + if ( VECSIGNFLIP(mat[0], smat[0]) ) size[0]= -size[0]; + if ( VECSIGNFLIP(mat[1], smat[1]) ) size[1]= -size[1]; + if ( VECSIGNFLIP(mat[2], smat[2]) ) size[2]= -size[2]; } @@ -2674,7 +2696,7 @@ static void ElementResize(TransInfo *t, TransData *td, float mat[3][3]) protectedSizeBits(td->protectflag, fsize); if ((t->flag & T_V3D_ALIGN)==0) { // align mode doesn't resize objects itself - if((td->flag & TD_SINGLESIZE) && !(t->con.mode & CON_APPLY)) { + if ((td->flag & TD_SINGLESIZE) && !(t->con.mode & CON_APPLY)) { /* scale val and reset size */ *td->val = td->ival * (1 + (fsize[0] - 1) * td->factor); @@ -2731,7 +2753,7 @@ int Resize(TransInfo *t, const int mval[2]) char str[200]; /* for manipulator, center handle, the scaling can't be done relative to center */ - if( (t->flag & T_USES_MANIPULATOR) && t->con.mode==0) + if ( (t->flag & T_USES_MANIPULATOR) && t->con.mode==0) { ratio = 1.0f - ((t->imval[0] - mval[0]) + (t->imval[1] - mval[1]))/100.0f; } @@ -2767,7 +2789,7 @@ int Resize(TransInfo *t, const int mval[2]) headerResize(t, size, str); - for(i = 0, td=t->data; i < t->total; i++, td++) { + for (i = 0, td=t->data; i < t->total; i++, td++) { if (td->flag & TD_NOACTION) break; @@ -2784,7 +2806,7 @@ int Resize(TransInfo *t, const int mval[2]) if (t->con.applySize) t->con.applySize(t, NULL, mat); - for(i = 0, td=t->data; i < t->total; i++, td++) + for (i = 0, td=t->data; i < t->total; i++, td++) ElementResize(t, td, mat); } @@ -2819,7 +2841,7 @@ void initToSphere(TransInfo *t) t->flag |= T_NO_CONSTRAINT; // Calculate average radius - for(i = 0 ; i < t->total; i++, td++) { + for (i = 0 ; i < t->total; i++, td++) { t->val += len_v3v3(t->center, td->iloc); } @@ -2861,7 +2883,7 @@ int ToSphere(TransInfo *t, const int UNUSED(mval[2])) } - for(i = 0 ; i < t->total; i++, td++) { + for (i = 0 ; i < t->total; i++, td++) { float tratio; if (td->flag & TD_NOACTION) break; @@ -2953,11 +2975,11 @@ static void ElementRotation(TransInfo *t, TransData *td, float mat[3][3], short add_v3_v3v3(td->loc, td->iloc, vec); - if(td->flag & TD_USEQUAT) { + if (td->flag & TD_USEQUAT) { mul_serie_m3(fmat, td->mtx, mat, td->smtx, NULL, NULL, NULL, NULL, NULL); mat3_to_quat( quat,fmat); // Actual transform - if(td->ext->quat) { + if (td->ext->quat) { mul_qt_qtqt(td->ext->quat, quat, td->ext->iquat); /* is there a reason not to have this here? -jahka */ @@ -2998,7 +3020,7 @@ static void ElementRotation(TransInfo *t, TransData *td, float mat[3][3], short sub_v3_v3v3(vec, vec, td->center); // Translation needed from the initial location /* special exception, see TD_PBONE_LOCAL_MTX definition comments */ - if(td->flag & TD_PBONE_LOCAL_MTX_P) { + if (td->flag & TD_PBONE_LOCAL_MTX_P) { /* do nothing */ } else if (td->flag & TD_PBONE_LOCAL_MTX_C) { @@ -3148,7 +3170,7 @@ static void applyRotation(TransInfo *t, float angle, float axis[3]) vec_rot_to_mat3( mat,axis, angle); - for(i = 0 ; i < t->total; i++, td++) { + for (i = 0 ; i < t->total; i++, td++) { if (td->flag & TD_NOACTION) break; @@ -3180,7 +3202,8 @@ int Rotation(TransInfo *t, const int UNUSED(mval[2])) if ((t->con.mode & CON_APPLY) && t->con.applyRot) { t->con.applyRot(t, NULL, t->axis, NULL); - } else { + } + else { /* reset axis if constraint is not set */ copy_v3_v3(t->axis, t->axis_orig); } @@ -3251,7 +3274,7 @@ static void applyTrackball(TransInfo *t, float axis1[3], float axis2[3], float a mul_m3_m3m3(mat, smat, totmat); - for(i = 0 ; i < t->total; i++, td++) { + for (i = 0 ; i < t->total; i++, td++) { if (td->flag & TD_NOACTION) break; @@ -3342,7 +3365,7 @@ void initTranslation(TransInfo *t) t->num.flag = 0; t->num.idx_max = t->idx_max; - if(t->spacetype == SPACE_VIEW3D) { + if (t->spacetype == SPACE_VIEW3D) { RegionView3D *rv3d = t->ar->regiondata; if (rv3d) { @@ -3351,7 +3374,7 @@ void initTranslation(TransInfo *t) t->snap[2] = t->snap[1] * 0.1f; } } - else if(ELEM(t->spacetype, SPACE_IMAGE, SPACE_CLIP)) { + else if (ELEM(t->spacetype, SPACE_IMAGE, SPACE_CLIP)) { t->snap[0] = 0.0f; t->snap[1] = 0.125f; t->snap[2] = 0.0625f; @@ -3383,10 +3406,10 @@ static void headerTranslation(TransInfo *t, float vec[3], char *str) applyAspectRatio(t, dvec); dist = len_v3(vec); - if(!(t->flag & T_2D_EDIT) && t->scene->unit.system) { + if (!(t->flag & T_2D_EDIT) && t->scene->unit.system) { int i, do_split= t->scene->unit.flag & USER_UNIT_OPT_SPLIT ? 1:0; - for(i=0; i<3; i++) + for (i=0; i<3; i++) bUnit_AsString(&tvec[i*20], 20, dvec[i]*t->scene->unit.scale_length, 4, t->scene->unit.system, B_UNIT_LENGTH, do_split, 1); } else { @@ -3396,17 +3419,17 @@ static void headerTranslation(TransInfo *t, float vec[3], char *str) } } - if(!(t->flag & T_2D_EDIT) && t->scene->unit.system) + if (!(t->flag & T_2D_EDIT) && t->scene->unit.system) bUnit_AsString(distvec, sizeof(distvec), dist*t->scene->unit.scale_length, 4, t->scene->unit.system, B_UNIT_LENGTH, t->scene->unit.flag & USER_UNIT_OPT_SPLIT, 0); - else if( dist > 1e10f || dist < -1e10f ) /* prevent string buffer overflow */ + else if ( dist > 1e10f || dist < -1e10f ) /* prevent string buffer overflow */ sprintf(distvec, "%.4e", dist); else sprintf(distvec, "%.4f", dist); - if(t->flag & T_AUTOIK) { + if (t->flag & T_AUTOIK) { short chainlen= t->settings->autoik_chainlen; - if(chainlen) + if (chainlen) sprintf(autoik, "AutoIK-Len: %d", chainlen); else autoik[0]= '\0'; @@ -3427,7 +3450,7 @@ static void headerTranslation(TransInfo *t, float vec[3], char *str) } } else { - if(t->flag & T_2D_EDIT) + if (t->flag & T_2D_EDIT) spos += sprintf(spos, "Dx: %s Dy: %s (%s)%s %s", &tvec[0], &tvec[20], distvec, t->con.text, t->proptext); else spos += sprintf(spos, "Dx: %s Dy: %s Dz: %s (%s)%s %s %s", &tvec[0], &tvec[20], &tvec[40], distvec, t->con.text, t->proptext, &autoik[0]); @@ -3445,7 +3468,7 @@ static void applyTranslation(TransInfo *t, float vec[3]) float tvec[3]; int i; - for(i = 0 ; i < t->total; i++, td++) { + for (i = 0 ; i < t->total; i++, td++) { if (td->flag & TD_NOACTION) break; @@ -3594,7 +3617,7 @@ int ShrinkFatten(TransInfo *t, const int UNUSED(mval[2])) } - for(i = 0 ; i < t->total; i++, td++) { + for (i = 0 ; i < t->total; i++, td++) { if (td->flag & TD_NOACTION) break; @@ -3664,7 +3687,7 @@ int Tilt(TransInfo *t, const int UNUSED(mval[2])) sprintf(str, "Tilt: %.2f %s", RAD2DEGF(final), t->proptext); } - for(i = 0 ; i < t->total; i++, td++) { + for (i = 0 ; i < t->total; i++, td++) { if (td->flag & TD_NOACTION) break; @@ -3731,14 +3754,14 @@ int CurveShrinkFatten(TransInfo *t, const int UNUSED(mval[2])) sprintf(str, "Shrink/Fatten: %3f", ratio); } - for(i = 0 ; i < t->total; i++, td++) { + for (i = 0 ; i < t->total; i++, td++) { if (td->flag & TD_NOACTION) break; if (td->flag & TD_SKIP) continue; - if(td->val) { + if (td->val) { // *td->val= ratio; *td->val= td->ival*ratio; if (*td->val <= 0.0f) *td->val = 0.001f; @@ -3802,7 +3825,7 @@ int PushPull(TransInfo *t, const int UNUSED(mval[2])) t->con.applyRot(t, NULL, axis, NULL); } - for(i = 0 ; i < t->total; i++, td++) { + for (i = 0 ; i < t->total; i++, td++) { if (td->flag & TD_NOACTION) break; @@ -3872,7 +3895,7 @@ void initBevel(TransInfo *t) int handleEventBevel(TransInfo *t, wmEvent *event) { if (event->val==KM_PRESS) { - if(!G.editBMesh) return 0; + if (!G.editBMesh) return 0; switch (event->type) { case MIDDLEMOUSE: @@ -3933,7 +3956,7 @@ int Bevel(TransInfo *t, const int UNUSED(mval[2])) } if (distance < 0) distance = -distance; - for(i = 0 ; i < t->total; i++, td++) { + for (i = 0 ; i < t->total; i++, td++) { if (td->axismtx[1][0] > 0 && distance > td->axismtx[1][0]) { d = td->axismtx[1][0]; } @@ -4005,7 +4028,7 @@ int BevelWeight(TransInfo *t, const int UNUSED(mval[2])) sprintf(str, "Bevel Weight: %.3f %s", weight, t->proptext); } - for(i = 0 ; i < t->total; i++, td++) { + for (i = 0 ; i < t->total; i++, td++) { if (td->flag & TD_NOACTION) break; @@ -4078,7 +4101,7 @@ int Crease(TransInfo *t, const int UNUSED(mval[2])) sprintf(str, "Crease: %.3f %s", crease, t->proptext); } - for(i = 0 ; i < t->total; i++, td++) { + for (i = 0 ; i < t->total; i++, td++) { if (td->flag & TD_NOACTION) break; @@ -4199,7 +4222,7 @@ int BoneSize(TransInfo *t, const int mval[2]) headerBoneSize(t, size, str); - for(i = 0 ; i < t->total; i++, td++) { + for (i = 0 ; i < t->total; i++, td++) { if (td->flag & TD_NOACTION) break; @@ -4261,7 +4284,7 @@ int BoneEnvelope(TransInfo *t, const int UNUSED(mval[2])) sprintf(str, "Envelope: %3f", ratio); } - for(i = 0 ; i < t->total; i++, td++) { + for (i = 0 ; i < t->total; i++, td++) { if (td->flag & TD_NOACTION) break; @@ -4314,7 +4337,8 @@ static BMLoop *get_next_loop(BMesh *UNUSED(bm), BMVert *v, BMLoop *l, if (l->e == nexte) { if (i) { mul_v3_fl(a, 1.0f / (float)i); - } else { + } + else { float f1[3], f2[3], f3[3]; sub_v3_v3v3(f1, BM_edge_other_vert(olde, v)->co, v->co); @@ -4330,7 +4354,8 @@ static BMLoop *get_next_loop(BMesh *UNUSED(bm), BMVert *v, BMLoop *l, copy_v3_v3(vec, a); return l; - } else { + } + else { sub_v3_v3v3(n, BM_edge_other_vert(l->e, v)->co, v->co); add_v3_v3v3(a, a, n); i += 1; @@ -4379,7 +4404,8 @@ static int createSlideVerts(TransInfo *t) if (!v3d) { /*ok, let's try to survive this*/ unit_m4(projectMat); - } else { + } + else { ED_view3d_ob_project_mat_get(rv3d, t->obedit, projectMat); } @@ -4480,7 +4506,8 @@ static int createSlideVerts(TransInfo *t) if (l2 != l1) { l = BM_face_other_edge_loop(l2->f, l2->e, v); sub_v3_v3v3(vec2, BM_edge_other_vert(l->e, v)->co, v->co); - } else { + } + else { l2 = NULL; } @@ -4573,14 +4600,16 @@ static int createSlideVerts(TransInfo *t) if (tempsv[j].down) { ED_view3d_project_float_v3(ar, tempsv[j].down->co, vec1, projectMat); - } else { + } + else { add_v3_v3v3(vec1, v->co, tempsv[j].downvec); ED_view3d_project_float_v3(ar, vec1, vec1, projectMat); } if (tempsv[j].up) { ED_view3d_project_float_v3(ar, tempsv[j].up->co, vec2, projectMat); - } else { + } + else { add_v3_v3v3(vec1, v->co, tempsv[j].upvec); ED_view3d_project_float_v3(ar, vec2, vec2, projectMat); } @@ -4710,7 +4739,8 @@ void projectSVData(TransInfo *t, int final) if (sld->perc < 0.0 && BM_vert_in_face(l3->radial_next->f, tempsv->down)) { copyf = BLI_smallhash_lookup(&sld->origfaces, (uintptr_t)l3->radial_next->f); - } else if (sld->perc > 0.0 && BM_vert_in_face(l3->radial_next->f, tempsv->up)) { + } + else if (sld->perc > 0.0 && BM_vert_in_face(l3->radial_next->f, tempsv->up)) { copyf = BLI_smallhash_lookup(&sld->origfaces, (uintptr_t)l3->radial_next->f); } if (!copyf) @@ -4742,8 +4772,8 @@ void projectSVData(TransInfo *t, int final) BLI_smallhash_release(&visit); } -void freeSlideTempFaces(SlideData *sld){ - if(sld->origfaces_init){ +void freeSlideTempFaces(SlideData *sld) { + if (sld->origfaces_init) { SmallHashIter hiter; BMFace *copyf; @@ -4764,13 +4794,13 @@ void freeSlideVerts(TransInfo *t) SlideData *sld = t->customData; #if 0 /*BMESH_TODO*/ - if(me->drawflag & ME_DRAWEXTRA_EDGELEN) { + if (me->drawflag & ME_DRAWEXTRA_EDGELEN) { TransDataSlideVert *tempsv; LinkNode *look = sld->vertlist; GHash *vertgh = sld->vhash; - while(look) { + while (look) { tempsv = BLI_ghash_lookup(vertgh,(EditVert*)look->link); - if(tempsv != NULL) { + if (tempsv != NULL) { tempsv->up->f &= !SELECT; tempsv->down->f &= !SELECT; } @@ -4803,7 +4833,7 @@ void initEdgeSlide(TransInfo *t) t->mode = TFM_EDGE_SLIDE; t->transform = EdgeSlide; - if(!createSlideVerts(t)) { + if (!createSlideVerts(t)) { t->state= TRANS_CANCEL; return; } @@ -4993,7 +5023,7 @@ int BakeTime(TransInfo *t, const int mval[2]) float fac = 0.1f; - if(t->mouse.precision) { + if (t->mouse.precision) { /* calculate ratio for shiftkey pos, and for total, and blend these for precision */ time= (float)(t->center2d[0] - t->mouse.precision_mval[0]) * fac; time+= 0.1f*((float)(t->center2d[0]*fac - mval[0]) -time); @@ -5025,7 +5055,7 @@ int BakeTime(TransInfo *t, const int mval[2]) sprintf(str, "Time: %.3f %s", time, t->proptext); } - for(i = 0 ; i < t->total; i++, td++) { + for (i = 0 ; i < t->total; i++, td++) { if (td->flag & TD_NOACTION) break; @@ -5084,7 +5114,7 @@ int Mirror(TransInfo *t, const int UNUSED(mval[2])) sprintf(str, "Mirror%s", t->con.text); - for(i = 0, td=t->data; i < t->total; i++, td++) { + for (i = 0, td=t->data; i < t->total; i++, td++) { if (td->flag & TD_NOACTION) break; @@ -5103,7 +5133,7 @@ int Mirror(TransInfo *t, const int UNUSED(mval[2])) size_to_mat3( mat,size); - for(i = 0, td=t->data; i < t->total; i++, td++) { + for (i = 0, td=t->data; i < t->total; i++, td++) { if (td->flag & TD_NOACTION) break; @@ -5115,7 +5145,7 @@ int Mirror(TransInfo *t, const int UNUSED(mval[2])) recalcData(t); - if(t->flag & T_2D_EDIT) + if (t->flag & T_2D_EDIT) ED_area_headerprint(t->sa, "Select a mirror axis (X, Y)"); else ED_area_headerprint(t->sa, "Select a mirror axis (X, Y, Z)"); @@ -5144,7 +5174,7 @@ int Align(TransInfo *t, const int UNUSED(mval[2])) /* saving original center */ copy_v3_v3(center, t->center); - for(i = 0 ; i < t->total; i++, td++) + for (i = 0 ; i < t->total; i++, td++) { float mat[3][3], invmat[3][3]; @@ -5159,7 +5189,7 @@ int Align(TransInfo *t, const int UNUSED(mval[2])) copy_v3_v3(t->center, td->center); } else { - if(t->settings->selectmode & SCE_SELECT_FACE) { + if (t->settings->selectmode & SCE_SELECT_FACE) { copy_v3_v3(t->center, td->center); } } @@ -5219,7 +5249,7 @@ static void applySeqSlide(TransInfo *t, float val[2]) TransData *td = t->data; int i; - for(i = 0 ; i < t->total; i++, td++) { + for (i = 0 ; i < t->total; i++, td++) { float tvec[2]; if (td->flag & TD_NOACTION) @@ -5574,7 +5604,8 @@ void initTimeSlide(TransInfo *t) /* set flag for drawing stuff */ saction->flag |= SACTION_MOVING; - } else { + } + else { t->state = TRANS_CANCEL; } diff --git a/source/blender/editors/transform/transform_constraints.c b/source/blender/editors/transform/transform_constraints.c index 017501bd78e..18e9c1a47b8 100644 --- a/source/blender/editors/transform/transform_constraints.c +++ b/source/blender/editors/transform/transform_constraints.c @@ -183,21 +183,21 @@ static void postConstraintChecks(TransInfo *t, float vec[3], float pvec[3]) static void viewAxisCorrectCenter(TransInfo *t, float t_con_center[3]) { - if(t->spacetype == SPACE_VIEW3D) { + if (t->spacetype == SPACE_VIEW3D) { // View3D *v3d = t->sa->spacedata.first; const float min_dist= 1.0f; // v3d->near; float dir[3]; float l; sub_v3_v3v3(dir, t_con_center, t->viewinv[3]); - if(dot_v3v3(dir, t->viewinv[2]) < 0.0f) { + if (dot_v3v3(dir, t->viewinv[2]) < 0.0f) { negate_v3(dir); } project_v3_v3v3(dir, dir, t->viewinv[2]); l= len_v3(dir); - if(l < min_dist) { + if (l < min_dist) { float diff[3]; normalize_v3_v3(diff, t->viewinv[2]); mul_v3_fl(diff, min_dist - l); @@ -212,7 +212,7 @@ static void axisProjection(TransInfo *t, float axis[3], float in[3], float out[3 float norm[3], vec[3], factor, angle; float t_con_center[3]; - if(in[0]==0.0f && in[1]==0.0f && in[2]==0.0f) + if (in[0]==0.0f && in[1]==0.0f && in[2]==0.0f) return; copy_v3_v3(t_con_center, t->con.center); @@ -229,11 +229,11 @@ static void axisProjection(TransInfo *t, float axis[3], float in[3], float out[3 /* For when view is parallel to constraint... will cause NaNs otherwise * So we take vertical motion in 3D space and apply it to the * constraint axis. Nice for camera grab + MMB */ - if(angle < 5.0f) { + if (angle < 5.0f) { project_v3_v3v3(vec, in, t->viewinv[1]); factor = dot_v3v3(t->viewinv[1], vec) * 2.0f; /* since camera distance is quite relative, use quadratic relationship. holding shift can compensate */ - if(factor<0.0f) factor*= -factor; + if (factor<0.0f) factor*= -factor; else factor*= factor; copy_v3_v3(out, axis); @@ -261,10 +261,12 @@ static void axisProjection(TransInfo *t, float axis[3], float in[3], float out[3 copy_v3_v3(out, axis); if (factor > 0) { mul_v3_fl(out, 1000000000.0f); - } else { + } + else { mul_v3_fl(out, -1000000000.0f); } - } else { + } + else { add_v3_v3v3(v2, t_con_center, axis); add_v3_v3v3(v4, v, norm); @@ -276,9 +278,9 @@ static void axisProjection(TransInfo *t, float axis[3], float in[3], float out[3 /* possible some values become nan when * viewpoint and object are both zero */ - if(!finite(out[0])) out[0]= 0.0f; - if(!finite(out[1])) out[1]= 0.0f; - if(!finite(out[2])) out[2]= 0.0f; + if (!finite(out[0])) out[0]= 0.0f; + if (!finite(out[1])) out[1]= 0.0f; + if (!finite(out[2])) out[2]= 0.0f; } } } @@ -654,7 +656,7 @@ void drawConstraint(TransInfo *t) /* nasty exception for Z constraint in camera view */ // TRANSFORM_FIX_ME -// if((t->flag & T_OBJECT) && G.vd->camera==OBACT && G.vd->persp==V3D_CAMOB) +// if ((t->flag & T_OBJECT) && G.vd->camera==OBACT && G.vd->persp==V3D_CAMOB) // return; if (tc->drawExtra) { @@ -676,7 +678,7 @@ void drawConstraint(TransInfo *t) glColor3ubv((GLubyte *)col2); depth_test_enabled = glIsEnabled(GL_DEPTH_TEST); - if(depth_test_enabled) + if (depth_test_enabled) glDisable(GL_DEPTH_TEST); setlinestyle(1); @@ -686,7 +688,7 @@ void drawConstraint(TransInfo *t) glEnd(); setlinestyle(0); - if(depth_test_enabled) + if (depth_test_enabled) glEnable(GL_DEPTH_TEST); } @@ -712,7 +714,7 @@ void drawPropCircle(const struct bContext *C, TransInfo *t) UI_ThemeColor(TH_GRID); - if(t->spacetype == SPACE_VIEW3D && rv3d != NULL) { + if (t->spacetype == SPACE_VIEW3D && rv3d != NULL) { copy_m4_m4(tmat, rv3d->viewmat); invert_m4_m4(imat, tmat); } @@ -725,10 +727,10 @@ void drawPropCircle(const struct bContext *C, TransInfo *t) copy_v3_v3(center, t->center); - if((t->spacetype == SPACE_VIEW3D) && t->obedit) { + if ((t->spacetype == SPACE_VIEW3D) && t->obedit) { mul_m4_v3(t->obedit->obmat, center); /* because t->center is in local space */ } - else if(t->spacetype == SPACE_IMAGE) { + else if (t->spacetype == SPACE_IMAGE) { float aspx, aspy; ED_space_image_uv_aspect(t->sa->spacedata.first, &aspx, &aspy); @@ -766,7 +768,7 @@ static void drawObjectConstraint(TransInfo *t) td++; - for(i=1;itotal;i++,td++) { + for (i=1;itotal;i++,td++) { if (t->con.mode & CON_AXIS0) { drawLine(t, td->ob->obmat[3], td->axismtx[0], 'X', 0); } diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c index 1c1fea9f505..6669bfdb3ca 100644 --- a/source/blender/editors/transform/transform_conversions.c +++ b/source/blender/editors/transform/transform_conversions.c @@ -175,7 +175,7 @@ void sort_trans_data_dist(TransInfo *t) TransData *start = t->data; int i = 1; - while(i < t->total && start->flag & TD_SELECTED) { + while (i < t->total && start->flag & TD_SELECTED) { start++; i++; } @@ -217,11 +217,11 @@ static void set_prop_dist(TransInfo *t, short with_dist) TransData *tob; int a; - for(a=0, tob= t->data; atotal; a++, tob++) { + for (a=0, tob= t->data; atotal; a++, tob++) { tob->rdist= 0.0f; // init, it was mallocced - if((tob->flag & TD_SELECTED)==0) { + if ((tob->flag & TD_SELECTED)==0) { TransData *td; int i; float dist, vec[3]; @@ -229,7 +229,7 @@ static void set_prop_dist(TransInfo *t, short with_dist) tob->rdist = -1.0f; // signal for next loop for (i = 0, td= t->data; i < t->total; i++, td++) { - if(td->flag & TD_SELECTED) { + if (td->flag & TD_SELECTED) { sub_v3_v3v3(vec, tob->center, td->center); mul_m3_v3(tob->mtx, vec); dist = normalize_v3(vec); @@ -269,7 +269,7 @@ static void createTransTexspace(TransInfo *t) } id = ob->data; - if(id == NULL || !ELEM3( GS(id->name), ID_ME, ID_CU, ID_MB )) { + if (id == NULL || !ELEM3( GS(id->name), ID_ME, ID_CU, ID_MB )) { t->total = 0; return; } @@ -319,7 +319,7 @@ static void createTransEdge(TransInfo *t) if (countsel == 0) return; - if(propmode) { + if (propmode) { t->total = count; } else { @@ -332,7 +332,7 @@ static void createTransEdge(TransInfo *t) invert_m3_m3(smtx, mtx); BM_ITER(eed, &iter, em->bm, BM_EDGES_OF_MESH, NULL) { - if(!BM_elem_flag_test(eed, BM_ELEM_HIDDEN) && (BM_elem_flag_test(eed, BM_ELEM_SELECT) || propmode)) { + if (!BM_elem_flag_test(eed, BM_ELEM_HIDDEN) && (BM_elem_flag_test(eed, BM_ELEM_SELECT) || propmode)) { float *bweight = CustomData_bmesh_get(&em->bm->edata, eed->head.data, CD_BWEIGHT); float *crease = CustomData_bmesh_get(&em->bm->edata, eed->head.data, CD_CREASE); @@ -371,13 +371,13 @@ static bKinematicConstraint *has_targetless_ik(bPoseChannel *pchan) { bConstraint *con= pchan->constraints.first; - for(;con; con= con->next) { - if(con->type==CONSTRAINT_TYPE_KINEMATIC && (con->enforce!=0.0f)) { + for (;con; con= con->next) { + if (con->type==CONSTRAINT_TYPE_KINEMATIC && (con->enforce!=0.0f)) { bKinematicConstraint *data= con->data; - if(data->tar==NULL) + if (data->tar==NULL) return data; - if(data->tar->type==OB_ARMATURE && data->subtarget[0]==0) + if (data->tar->type==OB_ARMATURE && data->subtarget[0]==0) return data; } } @@ -396,13 +396,13 @@ static short apply_targetless_ik(Object *ob) for (pchan=ob->pose->chanbase.first; pchan; pchan=pchan->next) { data= has_targetless_ik(pchan); - if(data && (data->flag & CONSTRAINT_IK_AUTO)) { + if (data && (data->flag & CONSTRAINT_IK_AUTO)) { /* fill the array with the bones of the chain (armature.c does same, keep it synced) */ segcount= 0; /* exclude tip from chain? */ - if(!(data->flag & CONSTRAINT_IK_TIP)) + if (!(data->flag & CONSTRAINT_IK_TIP)) parchan= pchan->parent; else parchan= pchan; @@ -412,9 +412,9 @@ static short apply_targetless_ik(Object *ob) chanlist[segcount]= parchan; segcount++; - if(segcount==data->rootbone || segcount>255) break; // 255 is weak + if (segcount==data->rootbone || segcount>255) break; // 255 is weak } - for(;segcount;segcount--) { + for (;segcount;segcount--) { Bone *bone; float rmat[4][4]/*, tmat[4][4], imat[4][4]*/; @@ -429,7 +429,7 @@ static short apply_targetless_ik(Object *ob) /* XXX Old code. Will remove it later. */ #if 0 - if(parchan->parent) { + if (parchan->parent) { Bone *parbone= parchan->parent->bone; float offs_bone[4][4]; @@ -443,7 +443,7 @@ static short apply_targetless_ik(Object *ob) offs_bone[3][1]+= parbone->length; /* pose_mat(b-1) * offs_bone */ - if(parchan->bone->flag & BONE_HINGE) { + if (parchan->bone->flag & BONE_HINGE) { /* the rotation of the parent restposition */ copy_m4_m4(rmat, parbone->arm_mat); /* rmat used as temp */ @@ -454,7 +454,7 @@ static short apply_targetless_ik(Object *ob) mult_m4_m4m4(tmat, rmat, offs_bone); } - else if(parchan->bone->flag & BONE_NO_SCALE) { + else if (parchan->bone->flag & BONE_NO_SCALE) { mult_m4_m4m4(tmat, parchan->parent->pose_mat, offs_bone); normalize_m4(tmat); } @@ -612,9 +612,9 @@ static void add_pose_transdata(TransInfo *t, bPoseChannel *pchan, Object *ob, Tr copy_m3_m3(bmat, pchan->bone->bone_mat); if (pchan->parent) { - if(pchan->bone->flag & BONE_HINGE) { + if (pchan->bone->flag & BONE_HINGE) { copy_m3_m4(pmat, pchan->parent->bone->arm_mat); - if(!(pchan->bone->flag & BONE_NO_SCALE)) { + if (!(pchan->bone->flag & BONE_NO_SCALE)) { float tsize[3], tsmat[3][3]; mat4_to_size(tsize, pchan->parent->pose_mat); size_to_mat3(tsmat, tsize); @@ -623,7 +623,7 @@ static void add_pose_transdata(TransInfo *t, bPoseChannel *pchan, Object *ob, Tr } else { copy_m3_m4(pmat, pchan->parent->pose_mat); - if(pchan->bone->flag & BONE_NO_SCALE) + if (pchan->bone->flag & BONE_NO_SCALE) normalize_m3(pmat); } @@ -651,7 +651,7 @@ static void add_pose_transdata(TransInfo *t, bPoseChannel *pchan, Object *ob, Tr /* exceptional case: rotate the pose bone which also applies transformation * when a parentless bone has BONE_NO_LOCAL_LOCATION [] */ if (!ELEM(t->mode, TFM_TRANSLATION, TFM_RESIZE) && (pchan->bone->flag & BONE_NO_LOCAL_LOCATION)) { - if(pchan->parent) { + if (pchan->parent) { /* same as td->smtx but without pchan->bone->bone_mat */ td->flag |= TD_PBONE_LOCAL_MTX_C; mul_m3_m3m3(td->ext->l_smtx, pchan->bone->bone_mat, td->smtx); @@ -669,7 +669,7 @@ static void add_pose_transdata(TransInfo *t, bPoseChannel *pchan, Object *ob, Tr if (t->mode==TFM_BONESIZE) { bArmature *arm= t->poseobj->data; - if(arm->drawtype==ARM_ENVELOPE) { + if (arm->drawtype==ARM_ENVELOPE) { td->loc= NULL; td->val= &bone->dist; td->ival= bone->dist; @@ -685,8 +685,8 @@ static void add_pose_transdata(TransInfo *t, bPoseChannel *pchan, Object *ob, Tr /* in this case we can do target-less IK grabbing */ if (t->mode==TFM_TRANSLATION) { bKinematicConstraint *data= has_targetless_ik(pchan); - if(data) { - if(data->flag & CONSTRAINT_IK_TIP) { + if (data) { + if (data->flag & CONSTRAINT_IK_TIP) { copy_v3_v3(data->grabtarget, pchan->pose_tail); } else { @@ -710,8 +710,8 @@ static void bone_children_clear_transflag(int mode, short around, ListBase *lb) { Bone *bone= lb->first; - for(;bone;bone= bone->next) { - if((bone->flag & BONE_HINGE) && (bone->flag & BONE_CONNECTED)) + for (;bone;bone= bone->next) { + if ((bone->flag & BONE_HINGE) && (bone->flag & BONE_CONNECTED)) { bone->flag |= BONE_HINGE_CHILD_TRANSFORM; } @@ -757,28 +757,28 @@ int count_set_pose_transflags(int *out_mode, short around, Object *ob) /* make sure no bone can be transformed when a parent is transformed */ /* since pchans are depsgraph sorted, the parents are in beginning of list */ - if(mode != TFM_BONESIZE) { - for(pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) { + if (mode != TFM_BONESIZE) { + for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) { bone = pchan->bone; - if(bone->flag & BONE_TRANSFORM) + if (bone->flag & BONE_TRANSFORM) bone_children_clear_transflag(mode, around, &bone->childbase); } } /* now count, and check if we have autoIK or have to switch from translate to rotate */ hastranslation = 0; - for(pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) { + for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) { bone = pchan->bone; - if(bone->flag & BONE_TRANSFORM) { + if (bone->flag & BONE_TRANSFORM) { total++; - if(mode == TFM_TRANSLATION) { - if( has_targetless_ik(pchan)==NULL ) { - if(pchan->parent && (pchan->bone->flag & BONE_CONNECTED)) { - if(pchan->bone->flag & BONE_HINGE_CHILD_TRANSFORM) + if (mode == TFM_TRANSLATION) { + if ( has_targetless_ik(pchan)==NULL ) { + if (pchan->parent && (pchan->bone->flag & BONE_CONNECTED)) { + if (pchan->bone->flag & BONE_HINGE_CHILD_TRANSFORM) hastranslation = 1; } - else if((pchan->protectflag & OB_LOCK_LOC)!=OB_LOCK_LOC) + else if ((pchan->protectflag & OB_LOCK_LOC)!=OB_LOCK_LOC) hastranslation = 1; } else @@ -788,7 +788,7 @@ int count_set_pose_transflags(int *out_mode, short around, Object *ob) } /* if there are no translatable bones, do rotation */ - if(mode == TFM_TRANSLATION && !hastranslation) + if (mode == TFM_TRANSLATION && !hastranslation) { *out_mode = TFM_ROTATION; } @@ -876,7 +876,7 @@ static void pose_grab_with_ik_clear(Object *ob) continue; } pchan->constflag |= PCHAN_HAS_IK; - if(data->tar==NULL || (data->tar->type==OB_ARMATURE && data->subtarget[0]==0)) + if (data->tar==NULL || (data->tar->type==OB_ARMATURE && data->subtarget[0]==0)) pchan->constflag |= PCHAN_HAS_TARGET; } } @@ -1067,7 +1067,7 @@ static void createTransPose(TransInfo *t, Object *ob) /* set flags and count total (warning, can change transform to rotate) */ t->total = count_set_pose_transflags(&t->mode, t->around, ob); - if(t->total == 0) return; + if (t->total == 0) return; t->flag |= T_POSE; t->poseobj= ob; /* we also allow non-active objects to be transformed, in weightpaint */ @@ -1075,7 +1075,7 @@ static void createTransPose(TransInfo *t, Object *ob) /* init trans data */ td = t->data = MEM_callocN(t->total*sizeof(TransData), "TransPoseBone"); tdx = t->ext = MEM_callocN(t->total*sizeof(TransDataExtension), "TransPoseBoneExt"); - for(i=0; itotal; i++, td++, tdx++) { + for (i=0; itotal; i++, td++, tdx++) { td->ext= tdx; td->val = NULL; } @@ -1089,7 +1089,7 @@ static void createTransPose(TransInfo *t, Object *ob) } } - if(td != (t->data+t->total)) { + if (td != (t->data+t->total)) { // XXX use transform operator reports // BKE_report(op->reports, RPT_DEBUG, "Bone selection count error"); } @@ -1191,7 +1191,7 @@ static void createTransArmatureVerts(TransInfo *t) } else if (t->mode==TFM_BONESIZE) { if (ebo->flag & BONE_SELECTED) { - if(arm->drawtype==ARM_ENVELOPE) + if (arm->drawtype==ARM_ENVELOPE) { td->loc= NULL; td->val= &ebo->dist; @@ -1305,15 +1305,15 @@ static void createTransMBallVerts(TransInfo *t) int propmode = t->flag & T_PROP_EDIT; /* count totals */ - for(ml= mb->editelems->first; ml; ml= ml->next) { - if(ml->flag & SELECT) countsel++; - if(propmode) count++; + for (ml= mb->editelems->first; ml; ml= ml->next) { + if (ml->flag & SELECT) countsel++; + if (propmode) count++; } /* note: in prop mode we need at least 1 selected */ if (countsel==0) return; - if(propmode) t->total = count; + if (propmode) t->total = count; else t->total = countsel; td = t->data= MEM_callocN(t->total*sizeof(TransData), "TransObData(MBall EditMode)"); @@ -1322,13 +1322,13 @@ static void createTransMBallVerts(TransInfo *t) copy_m3_m4(mtx, t->obedit->obmat); invert_m3_m3(smtx, mtx); - for(ml= mb->editelems->first; ml; ml= ml->next) { - if(propmode || (ml->flag & SELECT)) { + for (ml= mb->editelems->first; ml; ml= ml->next) { + if (propmode || (ml->flag & SELECT)) { td->loc= &ml->x; copy_v3_v3(td->iloc, td->loc); copy_v3_v3(td->center, td->loc); - if(ml->flag & SELECT) td->flag= TD_SELECTED | TD_USEQUAT | TD_SINGLESIZE; + if (ml->flag & SELECT) td->flag= TD_SELECTED | TD_USEQUAT | TD_SINGLESIZE; else td->flag= TD_USEQUAT; copy_m3_m3(td->smtx, smtx); @@ -1337,11 +1337,11 @@ static void createTransMBallVerts(TransInfo *t) td->ext = tx; /* Radius of MetaElem (mass of MetaElem influence) */ - if(ml->flag & MB_SCALE_RAD) { + if (ml->flag & MB_SCALE_RAD) { td->val = &ml->rad; td->ival = ml->rad; } - else{ + else { td->val = &ml->s; td->ival = ml->s; } @@ -1374,7 +1374,7 @@ static void calc_distanceCurveVerts(TransData *head, TransData *tail) td_near = td; td->dist = 0.0f; } - else if(td_near) { + else if (td_near) { float dist; dist = len_v3v3(td_near->center, td->center); if (dist < (td-1)->dist) { @@ -1395,7 +1395,7 @@ static void calc_distanceCurveVerts(TransData *head, TransData *tail) td_near = td; td->dist = 0.0f; } - else if(td_near) { + else if (td_near) { float dist; dist = len_v3v3(td_near->center, td->center); if (td->flag & TD_NOTCONNECTED || dist < td->dist || (td+1)->dist < td->dist) { @@ -1440,31 +1440,32 @@ static void createTransCurveVerts(bContext *C, TransInfo *t) ListBase *nurbs; /* to be sure */ - if(cu->editnurb==NULL) return; + if (cu->editnurb==NULL) return; /* count total of vertices, check identical as in 2nd loop for making transdata! */ nurbs= curve_editnurbs(cu); - for(nu= nurbs->first; nu; nu= nu->next) { - if(nu->type == CU_BEZIER) { - for(a=0, bezt= nu->bezt; apntsu; a++, bezt++) { - if(bezt->hide==0) { + for (nu= nurbs->first; nu; nu= nu->next) { + if (nu->type == CU_BEZIER) { + for (a=0, bezt= nu->bezt; apntsu; a++, bezt++) { + if (bezt->hide==0) { if (hide_handles) { - if(bezt->f2 & SELECT) countsel+=3; - if(propmode) count+= 3; - } else { - if(bezt->f1 & SELECT) countsel++; - if(bezt->f2 & SELECT) countsel++; - if(bezt->f3 & SELECT) countsel++; - if(propmode) count+= 3; + if (bezt->f2 & SELECT) countsel+=3; + if (propmode) count+= 3; + } + else { + if (bezt->f1 & SELECT) countsel++; + if (bezt->f2 & SELECT) countsel++; + if (bezt->f3 & SELECT) countsel++; + if (propmode) count+= 3; } } } } else { - for(a= nu->pntsu*nu->pntsv, bp= nu->bp; a>0; a--, bp++) { - if(bp->hide==0) { - if(propmode) count++; - if(bp->f1 & SELECT) countsel++; + for (a= nu->pntsu*nu->pntsv, bp= nu->bp; a>0; a--, bp++) { + if (bp->hide==0) { + if (propmode) count++; + if (bp->f1 & SELECT) countsel++; } } } @@ -1472,7 +1473,7 @@ static void createTransCurveVerts(bContext *C, TransInfo *t) /* note: in prop mode we need at least 1 selected */ if (countsel==0) return; - if(propmode) t->total = count; + if (propmode) t->total = count; else t->total = countsel; t->data= MEM_callocN(t->total*sizeof(TransData), "TransObData(Curve EditMode)"); @@ -1480,15 +1481,15 @@ static void createTransCurveVerts(bContext *C, TransInfo *t) invert_m3_m3(smtx, mtx); td = t->data; - for(nu= nurbs->first; nu; nu= nu->next) { - if(nu->type == CU_BEZIER) { + for (nu= nurbs->first; nu; nu= nu->next) { + if (nu->type == CU_BEZIER) { TransData *head, *tail; head = tail = td; - for(a=0, bezt= nu->bezt; apntsu; a++, bezt++) { - if(bezt->hide==0) { + for (a=0, bezt= nu->bezt; apntsu; a++, bezt++) { + if (bezt->hide==0) { TransDataCurveHandleFlags *hdata = NULL; - if( propmode || + if ( propmode || ((bezt->f2 & SELECT) && hide_handles) || ((bezt->f1 & SELECT) && hide_handles == 0) ) { @@ -1496,10 +1497,11 @@ static void createTransCurveVerts(bContext *C, TransInfo *t) td->loc= bezt->vec[0]; copy_v3_v3(td->center, bezt->vec[(hide_handles || bezt->f2 & SELECT) ? 1:0]); if (hide_handles) { - if(bezt->f2 & SELECT) td->flag= TD_SELECTED; + if (bezt->f2 & SELECT) td->flag= TD_SELECTED; else td->flag= 0; - } else { - if(bezt->f1 & SELECT) td->flag= TD_SELECTED; + } + else { + if (bezt->f1 & SELECT) td->flag= TD_SELECTED; else td->flag= 0; } td->ext = NULL; @@ -1516,21 +1518,23 @@ static void createTransCurveVerts(bContext *C, TransInfo *t) } /* This is the Curve Point, the other two are handles */ - if(propmode || (bezt->f2 & SELECT)) { + if (propmode || (bezt->f2 & SELECT)) { copy_v3_v3(td->iloc, bezt->vec[1]); td->loc= bezt->vec[1]; copy_v3_v3(td->center, td->loc); - if(bezt->f2 & SELECT) td->flag= TD_SELECTED; + if (bezt->f2 & SELECT) td->flag= TD_SELECTED; else td->flag= 0; td->ext = NULL; if (t->mode==TFM_CURVE_SHRINKFATTEN) { /* || t->mode==TFM_RESIZE) {*/ /* TODO - make points scale */ td->val = &(bezt->radius); td->ival = bezt->radius; - } else if (t->mode==TFM_TILT) { + } + else if (t->mode==TFM_TILT) { td->val = &(bezt->alfa); td->ival = bezt->alfa; - } else { + } + else { td->val = NULL; } @@ -1547,7 +1551,7 @@ static void createTransCurveVerts(bContext *C, TransInfo *t) count++; tail++; } - if( propmode || + if ( propmode || ((bezt->f2 & SELECT) && hide_handles) || ((bezt->f3 & SELECT) && hide_handles == 0) ) { @@ -1555,10 +1559,11 @@ static void createTransCurveVerts(bContext *C, TransInfo *t) td->loc= bezt->vec[2]; copy_v3_v3(td->center, bezt->vec[(hide_handles || bezt->f2 & SELECT) ? 1:2]); if (hide_handles) { - if(bezt->f2 & SELECT) td->flag= TD_SELECTED; + if (bezt->f2 & SELECT) td->flag= TD_SELECTED; else td->flag= 0; - } else { - if(bezt->f3 & SELECT) td->flag= TD_SELECTED; + } + else { + if (bezt->f3 & SELECT) td->flag= TD_SELECTED; else td->flag= 0; } td->ext = NULL; @@ -1594,20 +1599,21 @@ static void createTransCurveVerts(bContext *C, TransInfo *t) else { TransData *head, *tail; head = tail = td; - for(a= nu->pntsu*nu->pntsv, bp= nu->bp; a>0; a--, bp++) { - if(bp->hide==0) { - if(propmode || (bp->f1 & SELECT)) { + for (a= nu->pntsu*nu->pntsv, bp= nu->bp; a>0; a--, bp++) { + if (bp->hide==0) { + if (propmode || (bp->f1 & SELECT)) { copy_v3_v3(td->iloc, bp->vec); td->loc= bp->vec; copy_v3_v3(td->center, td->loc); - if(bp->f1 & SELECT) td->flag= TD_SELECTED; + if (bp->f1 & SELECT) td->flag= TD_SELECTED; else td->flag= 0; td->ext = NULL; if (t->mode==TFM_CURVE_SHRINKFATTEN || t->mode==TFM_RESIZE) { td->val = &(bp->radius); td->ival = bp->radius; - } else { + } + else { td->val = &(bp->alfa); td->ival = bp->alfa; } @@ -1645,10 +1651,10 @@ static void createTransLatticeVerts(TransInfo *t) bp = latt->def; a = latt->pntsu * latt->pntsv * latt->pntsw; - while(a--) { - if(bp->hide==0) { - if(bp->f1 & SELECT) countsel++; - if(propmode) count++; + while (a--) { + if (bp->hide==0) { + if (bp->f1 & SELECT) countsel++; + if (propmode) count++; } bp++; } @@ -1656,7 +1662,7 @@ static void createTransLatticeVerts(TransInfo *t) /* note: in prop mode we need at least 1 selected */ if (countsel==0) return; - if(propmode) t->total = count; + if (propmode) t->total = count; else t->total = countsel; t->data= MEM_callocN(t->total*sizeof(TransData), "TransObData(Lattice EditMode)"); @@ -1666,13 +1672,13 @@ static void createTransLatticeVerts(TransInfo *t) td = t->data; bp = latt->def; a = latt->pntsu * latt->pntsv * latt->pntsw; - while(a--) { - if(propmode || (bp->f1 & SELECT)) { - if(bp->hide==0) { + while (a--) { + if (propmode || (bp->f1 & SELECT)) { + if (bp->hide==0) { copy_v3_v3(td->iloc, bp->vec); td->loc= bp->vec; copy_v3_v3(td->center, td->loc); - if(bp->f1 & SELECT) td->flag= TD_SELECTED; + if (bp->f1 & SELECT) td->flag= TD_SELECTED; else td->flag= 0; copy_m3_m3(td->smtx, smtx); copy_m3_m3(td->mtx, mtx); @@ -1706,33 +1712,33 @@ static void createTransParticleVerts(bContext *C, TransInfo *t) int count = 0, hasselected = 0; int propmode = t->flag & T_PROP_EDIT; - if(edit==NULL || t->settings->particle.selectmode==SCE_SELECT_PATH) return; + if (edit==NULL || t->settings->particle.selectmode==SCE_SELECT_PATH) return; psys = edit->psys; - if(psys) + if (psys) psmd = psys_get_modifier(ob,psys); base->flag |= BA_HAS_RECALC_DATA; - for(i=0, point=edit->points; itotpoint; i++, point++) { + for (i=0, point=edit->points; itotpoint; i++, point++) { point->flag &= ~PEP_TRANSFORM; transformparticle= 0; - if((point->flag & PEP_HIDE)==0) { - for(k=0, key=point->keys; ktotkey; k++, key++) { - if((key->flag&PEK_HIDE)==0) { - if(key->flag&PEK_SELECT) { + if ((point->flag & PEP_HIDE)==0) { + for (k=0, key=point->keys; ktotkey; k++, key++) { + if ((key->flag&PEK_HIDE)==0) { + if (key->flag&PEK_SELECT) { hasselected= 1; transformparticle= 1; } - else if(propmode) + else if (propmode) transformparticle= 1; } } } - if(transformparticle) { + if (transformparticle) { count += point->totkey; point->flag |= PEP_TRANSFORM; } @@ -1744,7 +1750,7 @@ static void createTransParticleVerts(bContext *C, TransInfo *t) t->total = count; td = t->data = MEM_callocN(t->total * sizeof(TransData), "TransObData(Particle Mode)"); - if(t->mode == TFM_BAKE_TIME) + if (t->mode == TFM_BAKE_TIME) tx = t->ext = MEM_callocN(t->total * sizeof(TransDataExtension), "Particle_TransExtension"); else tx = t->ext = NULL; @@ -1753,17 +1759,17 @@ static void createTransParticleVerts(bContext *C, TransInfo *t) invert_m4_m4(ob->imat,ob->obmat); - for(i=0, point=edit->points; itotpoint; i++, point++) { + for (i=0, point=edit->points; itotpoint; i++, point++) { TransData *head, *tail; head = tail = td; - if(!(point->flag & PEP_TRANSFORM)) continue; + if (!(point->flag & PEP_TRANSFORM)) continue; - if(psys && !(psys->flag & PSYS_GLOBAL_HAIR)) + if (psys && !(psys->flag & PSYS_GLOBAL_HAIR)) psys_mat_hair_to_global(ob, psmd->dm, psys->part->from, psys->particles + i, mat); - for(k=0, key=point->keys; ktotkey; k++, key++) { - if(key->flag & PEK_USE_WCO) { + for (k=0, key=point->keys; ktotkey; k++, key++) { + if (key->flag & PEK_USE_WCO) { copy_v3_v3(key->world_co, key->co); mul_m4_v3(mat, key->world_co); td->loc = key->world_co; @@ -1774,34 +1780,34 @@ static void createTransParticleVerts(bContext *C, TransInfo *t) copy_v3_v3(td->iloc, td->loc); copy_v3_v3(td->center, td->loc); - if(key->flag & PEK_SELECT) + if (key->flag & PEK_SELECT) td->flag |= TD_SELECTED; - else if(!propmode) + else if (!propmode) td->flag |= TD_SKIP; unit_m3(td->mtx); unit_m3(td->smtx); /* don't allow moving roots */ - if(k==0 && pset->flag & PE_LOCK_FIRST && (!psys || !(psys->flag & PSYS_GLOBAL_HAIR))) + if (k==0 && pset->flag & PE_LOCK_FIRST && (!psys || !(psys->flag & PSYS_GLOBAL_HAIR))) td->protectflag |= OB_LOCK_LOC; td->ob = ob; td->ext = tx; - if(t->mode == TFM_BAKE_TIME) { + if (t->mode == TFM_BAKE_TIME) { td->val = key->time; td->ival = *(key->time); /* abuse size and quat for min/max values */ td->flag |= TD_NO_EXT; - if(k==0) tx->size = NULL; + if (k==0) tx->size = NULL; else tx->size = (key - 1)->time; - if(k == point->totkey - 1) tx->quat = NULL; + if (k == point->totkey - 1) tx->quat = NULL; else tx->quat = (key + 1)->time; } td++; - if(tx) + if (tx) tx++; tail++; } @@ -1823,26 +1829,26 @@ void flushTransParticles(TransInfo *t) float mat[4][4], imat[4][4], co[3]; int i, k, propmode = t->flag & T_PROP_EDIT; - if(psys) + if (psys) psmd = psys_get_modifier(ob, psys); /* we do transform in world space, so flush world space position * back to particle local space (only for hair particles) */ td= t->data; - for(i=0, point=edit->points; itotpoint; i++, point++, td++) { - if(!(point->flag & PEP_TRANSFORM)) continue; + for (i=0, point=edit->points; itotpoint; i++, point++, td++) { + if (!(point->flag & PEP_TRANSFORM)) continue; - if(psys && !(psys->flag & PSYS_GLOBAL_HAIR)) { + if (psys && !(psys->flag & PSYS_GLOBAL_HAIR)) { psys_mat_hair_to_global(ob, psmd->dm, psys->part->from, psys->particles + i, mat); invert_m4_m4(imat,mat); - for(k=0, key=point->keys; ktotkey; k++, key++) { + for (k=0, key=point->keys; ktotkey; k++, key++) { copy_v3_v3(co, key->world_co); mul_m4_v3(imat, co); /* optimization for proportional edit */ - if(!propmode || !compare_v3v3(key->co, co, 0.0001f)) { + if (!propmode || !compare_v3v3(key->co, co, 0.0001f)) { copy_v3_v3(key->co, co); point->flag |= PEP_EDIT_RECALC; } @@ -1985,10 +1991,10 @@ static void VertsToTransData(TransInfo *t, TransData *td, BMEditMesh *em, BMVert copy_v3_v3(td->center, td->loc); - if(t->around==V3D_LOCAL) { - if(em->selectmode & SCE_SELECT_FACE) + if (t->around==V3D_LOCAL) { + if (em->selectmode & SCE_SELECT_FACE) get_face_center(td->center, em->bm, eve); - else if(em->selectmode & SCE_SELECT_EDGE) + else if (em->selectmode & SCE_SELECT_EDGE) get_edge_center(td->center, em->bm, eve); } copy_v3_v3(td->iloc, td->loc); @@ -2044,19 +2050,19 @@ static void createTransEditVerts(bContext *C, TransInfo *t) * use the values for vertex mirror - campbell */ // transform now requires awareness for select mode, so we tag the f1 flags in verts - if(selectmode & SCE_SELECT_VERTEX) { + if (selectmode & SCE_SELECT_VERTEX) { BM_ITER(eve, &iter, bm, BM_VERTS_OF_MESH, NULL) { BM_elem_flag_set(eve, BM_ELEM_TAG, BM_elem_flag_test(eve, BM_ELEM_SELECT)); } } - else if(selectmode & SCE_SELECT_EDGE) { + else if (selectmode & SCE_SELECT_EDGE) { BMEdge *eed; eve = BM_iter_new(&iter, bm, BM_VERTS_OF_MESH, NULL); - for( ; eve; eve=BM_iter_step(&iter)) BM_elem_flag_disable(eve, BM_ELEM_TAG); + for ( ; eve; eve=BM_iter_step(&iter)) BM_elem_flag_disable(eve, BM_ELEM_TAG); eed = BM_iter_new(&iter, bm, BM_EDGES_OF_MESH, NULL); - for( ; eed; eed=BM_iter_step(&iter)) { + for ( ; eed; eed=BM_iter_step(&iter)) { if (BM_elem_flag_test(eed, BM_ELEM_SELECT)) { BM_elem_flag_enable(eed->v1, BM_ELEM_TAG); BM_elem_flag_enable(eed->v2, BM_ELEM_TAG); @@ -2066,10 +2072,10 @@ static void createTransEditVerts(bContext *C, TransInfo *t) else { BMFace *efa; eve = BM_iter_new(&iter, bm, BM_VERTS_OF_MESH, NULL); - for( ; eve; eve=BM_iter_step(&iter)) BM_elem_flag_disable(eve, BM_ELEM_TAG); + for ( ; eve; eve=BM_iter_step(&iter)) BM_elem_flag_disable(eve, BM_ELEM_TAG); efa = BM_iter_new(&iter, bm, BM_FACES_OF_MESH, NULL); - for( ; efa; efa=BM_iter_step(&iter)) { + for ( ; efa; efa=BM_iter_step(&iter)) { if (BM_elem_flag_test(efa, BM_ELEM_SELECT)) { BMIter liter; BMLoop *l; @@ -2087,13 +2093,13 @@ static void createTransEditVerts(bContext *C, TransInfo *t) * verts*/ selstate = MEM_callocN(sizeof(*selstate) * bm->totvert, __func__); eve = BM_iter_new(&iter, bm, BM_VERTS_OF_MESH, NULL); - for(a=0; eve; eve=BM_iter_step(&iter), a++) { + for (a=0; eve; eve=BM_iter_step(&iter), a++) { if (!BM_elem_flag_test(eve, BM_ELEM_HIDDEN)) { if (BM_elem_flag_test(eve, BM_ELEM_TAG)) { selstate[a] = 1; countsel++; } - if(propmode) count++; + if (propmode) count++; } } @@ -2111,7 +2117,7 @@ static void createTransEditVerts(bContext *C, TransInfo *t) } - if(propmode) { + if (propmode) { t->total = count; /* allocating scratch arrays */ @@ -2125,13 +2131,13 @@ static void createTransEditVerts(bContext *C, TransInfo *t) copy_m3_m4(mtx, t->obedit->obmat); invert_m3_m3(smtx, mtx); - if(propmode & T_PROP_CONNECTED) { + if (propmode & T_PROP_CONNECTED) { editmesh_set_connectivity_distance(em, mtx, dists); } /* detect CrazySpace [tm] */ - if(modifiers_getCageIndex(t->scene, t->obedit, NULL, 1)>=0) { - if(modifiers_isCorrectableDeformed(t->obedit)) { + if (modifiers_getCageIndex(t->scene, t->obedit, NULL, 1)>=0) { + if (modifiers_isCorrectableDeformed(t->obedit)) { /* check if we can use deform matrices for modifier from the * start up to stack, they are more accurate than quats */ totleft= editbmesh_get_first_deform_matrices(t->scene, t->obedit, em, &defmats, &defcos); @@ -2139,25 +2145,25 @@ static void createTransEditVerts(bContext *C, TransInfo *t) /* if we still have more modifiers, also do crazyspace * correction with quats, relative to the coordinates after * the modifiers that support deform matrices (defcos) */ - if(totleft > 0) { + if (totleft > 0) { mappedcos= crazyspace_get_mapped_editverts(t->scene, t->obedit); quats= MEM_mallocN( (t->total)*sizeof(float)*4, "crazy quats"); crazyspace_set_quats_editmesh(em, (float*)defcos, mappedcos, quats); /* BMESH_TODO, abuses vertex index, should use an int array */ - if(mappedcos) + if (mappedcos) MEM_freeN(mappedcos); } - if(defcos) + if (defcos) MEM_freeN(defcos); } } /* find out which half we do */ - if(mirror) { + if (mirror) { eve = BM_iter_new(&iter, bm, BM_VERTS_OF_MESH, NULL); - for(a=0; eve; eve=BM_iter_step(&iter), a++) { - if(!BM_elem_flag_test(eve, BM_ELEM_HIDDEN) && selstate[a] && eve->co[0]!=0.0f) { - if(eve->co[0]<0.0f) + for (a=0; eve; eve=BM_iter_step(&iter), a++) { + if (!BM_elem_flag_test(eve, BM_ELEM_HIDDEN) && selstate[a] && eve->co[0]!=0.0f) { + if (eve->co[0]<0.0f) { t->mirror = -1; mirror = -1; @@ -2168,37 +2174,38 @@ static void createTransEditVerts(bContext *C, TransInfo *t) } eve = BM_iter_new(&iter, bm, BM_VERTS_OF_MESH, NULL); - for(a=0; eve; eve=BM_iter_step(&iter), a++) { - if(!BM_elem_flag_test(eve, BM_ELEM_HIDDEN)) { - if(propmode || selstate[a]) { + for (a=0; eve; eve=BM_iter_step(&iter), a++) { + if (!BM_elem_flag_test(eve, BM_ELEM_HIDDEN)) { + if (propmode || selstate[a]) { float *bweight = CustomData_bmesh_get(&bm->vdata, eve->head.data, CD_BWEIGHT); VertsToTransData(t, tob, em, eve, bweight); /* selected */ - if(selstate[a]) tob->flag |= TD_SELECTED; + if (selstate[a]) tob->flag |= TD_SELECTED; /* active */ - if(eve == eve_act) tob->flag |= TD_ACTIVE; + if (eve == eve_act) tob->flag |= TD_ACTIVE; - if(propmode) { + if (propmode) { if (propmode & T_PROP_CONNECTED) { tob->dist = dists[a]; - } else { + } + else { tob->flag |= TD_NOTCONNECTED; tob->dist = MAXFLOAT; } } /* CrazySpace */ - if(defmats || (quats && BM_elem_index_get(eve) != -1)) { + if (defmats || (quats && BM_elem_index_get(eve) != -1)) { float mat[3][3], qmat[3][3], imat[3][3]; /* use both or either quat and defmat correction */ - if(quats && BM_elem_index_get(eve) != -1) { + if (quats && BM_elem_index_get(eve) != -1) { quat_to_mat3(qmat, quats + 4*BM_elem_index_get(eve)); - if(defmats) + if (defmats) mul_serie_m3(mat, mtx, qmat, defmats[a], NULL, NULL, NULL, NULL, NULL); else @@ -2218,9 +2225,9 @@ static void createTransEditVerts(bContext *C, TransInfo *t) } /* Mirror? */ - if( (mirror>0 && tob->iloc[0]>0.0f) || (mirror<0 && tob->iloc[0]<0.0f)) { + if ( (mirror>0 && tob->iloc[0]>0.0f) || (mirror<0 && tob->iloc[0]<0.0f)) { BMVert *vmir= EDBM_GetMirrorVert(em, eve); //t->obedit, em, eve, tob->iloc, a); - if(vmir && vmir != eve) { + if (vmir && vmir != eve) { tob->extra = vmir; } } @@ -2232,7 +2239,7 @@ static void createTransEditVerts(bContext *C, TransInfo *t) if (mirror != 0) { tob = t->data; - for( a = 0; a < t->total; a++, tob++ ) + for ( a = 0; a < t->total; a++, tob++ ) { if (ABS(tob->loc[0]) <= 0.00001f) { @@ -2243,9 +2250,9 @@ static void createTransEditVerts(bContext *C, TransInfo *t) cleanup: /* crazy space free */ - if(quats) + if (quats) MEM_freeN(quats); - if(defmats) + if (defmats) MEM_freeN(defmats); if (dists) MEM_freeN(dists); @@ -2265,13 +2272,13 @@ void flushTransNodes(TransInfo *t) TransData2D *td; /* flush to 2d vector from internally used 3d vector */ - for(a=0, td= t->data2d; atotal; a++, td++) { + for (a=0, td= t->data2d; atotal; a++, td++) { td->loc2d[0]= td->loc[0]; td->loc2d[1]= td->loc[1]; } /* handle intersection with noodles */ - if(t->total==1) { + if (t->total==1) { ED_node_link_intersect_test(t->sa, 1); } @@ -2301,7 +2308,7 @@ void flushTransSeq(TransInfo *t) Sequence *seq_prev= NULL; /* flush to 2d vector from internally used 3d vector */ - for(a=0, td= t->data, td2d= t->data2d; atotal; a++, td++, td2d++) { + for (a=0, td= t->data, td2d= t->data2d; atotal; a++, td++, td2d++) { tdsq= (TransDataSeq *)td->extra; seq= tdsq->seq; old_start = seq->start; @@ -2334,7 +2341,7 @@ void flushTransSeq(TransInfo *t) } if (seq != seq_prev) { - if(seq->depth==0) { + if (seq->depth==0) { /* Calculate this strip and all nested strips * children are ALWAYS transformed first * so we don't need to do this in another loop. */ @@ -2344,7 +2351,7 @@ void flushTransSeq(TransInfo *t) calc_sequence_disp(t->scene, seq); } - if(tdsq->sel_flag == SELECT) + if (tdsq->sel_flag == SELECT) seq_offset_animdata(t->scene, seq, seq->start - old_start); } seq_prev= seq; @@ -2370,16 +2377,16 @@ void flushTransSeq(TransInfo *t) /* need to do the overlap check in a new loop otherwise adjacent strips * will not be updated and we'll get false positives */ seq_prev= NULL; - for(a=0, td= t->data, td2d= t->data2d; atotal; a++, td++, td2d++) { + for (a=0, td= t->data, td2d= t->data2d; atotal; a++, td++, td2d++) { tdsq= (TransDataSeq *)td->extra; seq= tdsq->seq; if (seq != seq_prev) { - if(seq->depth==0) { + if (seq->depth==0) { /* test overlap, displayes red outline */ seq->flag &= ~SEQ_OVERLAP; - if( seq_test_overlap(seqbasep, seq) ) { + if ( seq_test_overlap(seqbasep, seq) ) { seq->flag |= SEQ_OVERLAP; } } @@ -2415,7 +2422,7 @@ static void UVsToTransData(SpaceImage *sima, TransData *td, TransData2D *td2d, f td->ext= NULL; td->val= NULL; - if(selected) { + if (selected) { td->flag |= TD_SELECTED; td->dist= 0.0; } @@ -2442,13 +2449,13 @@ static void createTransUVs(bContext *C, TransInfo *t) int count=0, countsel=0; int propmode = t->flag & T_PROP_EDIT; - if(!ED_space_image_show_uvedit(sima, t->obedit)) return; + if (!ED_space_image_show_uvedit(sima, t->obedit)) return; /* count */ BM_ITER(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL) { tf= CustomData_bmesh_get(&em->bm->pdata, efa->head.data, CD_MTEXPOLY); - if(!uvedit_face_visible(scene, ima, efa, tf)) { + if (!uvedit_face_visible(scene, ima, efa, tf)) { BM_elem_flag_disable(efa, BM_ELEM_TAG); continue; } @@ -2458,7 +2465,7 @@ static void createTransUVs(bContext *C, TransInfo *t) if (uvedit_uv_selected(em, scene, l)) countsel++; - if(propmode) + if (propmode) count++; } } @@ -2472,7 +2479,7 @@ static void createTransUVs(bContext *C, TransInfo *t) * treated just as if they were 3d verts */ t->data2d= MEM_callocN(t->total*sizeof(TransData2D), "TransObData2D(UV Editing)"); - if(sima->flag & SI_CLIP_UV) + if (sima->flag & SI_CLIP_UV) t->flag |= T_CLIP_UV; td= t->data; @@ -2508,11 +2515,11 @@ void flushTransUVs(TransInfo *t) invy= 1.0f/aspy; /* flush to 2d vector from internally used 3d vector */ - for(a=0, td= t->data2d; atotal; a++, td++) { + for (a=0, td= t->data2d; atotal; a++, td++) { td->loc2d[0]= td->loc[0]*invx; td->loc2d[1]= td->loc[1]*invy; - if((sima->flag & SI_PIXELSNAP) && (t->state != TRANS_CANCEL)) { + if ((sima->flag & SI_PIXELSNAP) && (t->state != TRANS_CANCEL)) { td->loc2d[0]= (float)floor(width*td->loc2d[0] + 0.5f)/width; td->loc2d[1]= (float)floor(height*td->loc2d[1] + 0.5f)/height; } @@ -2529,36 +2536,36 @@ int clipUVTransform(TransInfo *t, float *vec, int resize) min[0]= min[1]= 0.0f; max[0]= aspx; max[1]= aspy; - for(a=0, td= t->data; atotal; a++, td++) { + for (a=0, td= t->data; atotal; a++, td++) { DO_MINMAX2(td->loc, min, max); } - if(resize) { - if(min[0] < 0.0f && t->center[0] > 0.0f && t->center[0] < aspx*0.5f) + if (resize) { + if (min[0] < 0.0f && t->center[0] > 0.0f && t->center[0] < aspx*0.5f) vec[0] *= t->center[0]/(t->center[0] - min[0]); - else if(max[0] > aspx && t->center[0] < aspx) + else if (max[0] > aspx && t->center[0] < aspx) vec[0] *= (t->center[0] - aspx)/(t->center[0] - max[0]); else clipx= 0; - if(min[1] < 0.0f && t->center[1] > 0.0f && t->center[1] < aspy*0.5f) + if (min[1] < 0.0f && t->center[1] > 0.0f && t->center[1] < aspy*0.5f) vec[1] *= t->center[1]/(t->center[1] - min[1]); - else if(max[1] > aspy && t->center[1] < aspy) + else if (max[1] > aspy && t->center[1] < aspy) vec[1] *= (t->center[1] - aspy)/(t->center[1] - max[1]); else clipy= 0; } else { - if(min[0] < 0.0f) + if (min[0] < 0.0f) vec[0] -= min[0]; - else if(max[0] > aspx) + else if (max[0] > aspx) vec[0] -= max[0]-aspx; else clipx= 0; - if(min[1] < 0.0f) + if (min[1] < 0.0f) vec[1] -= min[1]; - else if(max[1] > aspy) + else if (max[1] > aspy) vec[1] -= max[1]-aspy; else clipy= 0; @@ -3711,9 +3718,9 @@ static void beztmap_to_data (TransInfo *t, FCurve *fcu, BeztMap *bezms, int totv td2d->loc2d= (bezts + bezm->newIndex)->vec[1]; /* if only control point is selected, the handle pointers need to be updated as well */ - if(td2d->h1) + if (td2d->h1) td2d->h1= (bezts + bezm->newIndex)->vec[0]; - if(td2d->h2) + if (td2d->h2) td2d->h2= (bezts + bezm->newIndex)->vec[2]; adjusted[j] = 1; @@ -3721,7 +3728,7 @@ static void beztmap_to_data (TransInfo *t, FCurve *fcu, BeztMap *bezms, int totv /* the handle type pointer has to be updated too */ if (adjusted[j] && td->flag & TD_BEZTRIPLE && td->hdata) { - if(bezm->swapHs == 1) { + if (bezm->swapHs == 1) { td->hdata->h1 = &(bezts + bezm->newIndex)->h2; td->hdata->h2 = &(bezts + bezm->newIndex)->h1; } @@ -3890,7 +3897,8 @@ static void SeqTransInfo(TransInfo *t, Sequence *seq, int *recursive, int *count else *flag |= SEQ_LEFTSEL; } } - } else { + } + else { t->frame_side= 'B'; @@ -3910,7 +3918,8 @@ static void SeqTransInfo(TransInfo *t, Sequence *seq, int *recursive, int *count if ((seq->flag & (SEQ_LEFTSEL|SEQ_RIGHTSEL)) == (SEQ_LEFTSEL|SEQ_RIGHTSEL)) { *flag= seq->flag; *count= 2; /* we need 2 transdata's */ - } else { + } + else { *flag= seq->flag; *count= 1; /* selected or with a handle selected */ } @@ -4086,7 +4095,7 @@ static void freeSeqData(TransInfo *t) { Editing *ed= seq_give_editing(t->scene, FALSE); - if(ed != NULL) { + if (ed != NULL) { ListBase *seqbasep= ed->seqbasep; TransData *td= t->data; int a; @@ -4103,7 +4112,7 @@ static void freeSeqData(TransInfo *t) #if 0 // default 2.4 behavior /* flush to 2d vector from internally used 3d vector */ - for(a=0; atotal; a++, td++) { + for (a=0; atotal; a++, td++) { if ((seq != seq_prev) && (seq->depth==0) && (seq->flag & SEQ_OVERLAP)) { seq= ((TransDataSeq *)td->extra)->seq; shuffle_seq(seqbasep, seq); @@ -4116,7 +4125,7 @@ static void freeSeqData(TransInfo *t) { int overlap= 0; - for(a=0; atotal; a++, td++) { + for (a=0; atotal; a++, td++) { seq_prev= NULL; seq= ((TransDataSeq *)td->extra)->seq; if ((seq != seq_prev) && (seq->depth==0) && (seq->flag & SEQ_OVERLAP)) { @@ -4126,18 +4135,18 @@ static void freeSeqData(TransInfo *t) seq_prev= seq; } - if(overlap) { + if (overlap) { int has_effect= 0; - for(seq= seqbasep->first; seq; seq= seq->next) + for (seq= seqbasep->first; seq; seq= seq->next) seq->tmp= NULL; td= t->data; seq_prev= NULL; - for(a=0; atotal; a++, td++) { + for (a=0; atotal; a++, td++) { seq= ((TransDataSeq *)td->extra)->seq; if ((seq != seq_prev)) { /* check effects strips, we cant change their time */ - if((seq->type & SEQ_EFFECT) && seq->seq1) { + if ((seq->type & SEQ_EFFECT) && seq->seq1) { has_effect= TRUE; } else { @@ -4149,14 +4158,14 @@ static void freeSeqData(TransInfo *t) shuffle_seq_time(seqbasep, t->scene); - if(has_effect) { + if (has_effect) { /* update effects strips based on strips just moved in time */ td= t->data; seq_prev= NULL; - for(a=0; atotal; a++, td++) { + for (a=0; atotal; a++, td++) { seq= ((TransDataSeq *)td->extra)->seq; if ((seq != seq_prev)) { - if((seq->type & SEQ_EFFECT) && seq->seq1) { + if ((seq->type & SEQ_EFFECT) && seq->seq1) { calc_sequence(t->scene, seq); } } @@ -4165,11 +4174,11 @@ static void freeSeqData(TransInfo *t) /* now if any effects _still_ overlap, we need to move them up */ td= t->data; seq_prev= NULL; - for(a=0; atotal; a++, td++) { + for (a=0; atotal; a++, td++) { seq= ((TransDataSeq *)td->extra)->seq; if ((seq != seq_prev)) { - if((seq->type & SEQ_EFFECT) && seq->seq1) { - if(seq_test_overlap(seqbasep, seq)) { + if ((seq->type & SEQ_EFFECT) && seq->seq1) { + if (seq_test_overlap(seqbasep, seq)) { shuffle_seq(seqbasep, seq, t->scene); } } @@ -4181,9 +4190,9 @@ static void freeSeqData(TransInfo *t) } #endif - for(seq= seqbasep->first; seq; seq= seq->next) { + for (seq= seqbasep->first; seq; seq= seq->next) { /* We might want to build a list of effects that need to be updated during transform */ - if(seq->type & SEQ_EFFECT) { + if (seq->type & SEQ_EFFECT) { if (seq->seq1 && seq->seq1->flag & SELECT) calc_sequence(t->scene, seq); else if (seq->seq2 && seq->seq2->flag & SELECT) calc_sequence(t->scene, seq); else if (seq->seq3 && seq->seq3->flag & SELECT) calc_sequence(t->scene, seq); @@ -4194,7 +4203,7 @@ static void freeSeqData(TransInfo *t) } else { /* Cancelled, need to update the strips display */ - for(a=0; atotal; a++, td++) { + for (a=0; atotal; a++, td++) { seq= ((TransDataSeq *)td->extra)->seq; if ((seq != seq_prev) && (seq->depth==0)) { calc_sequence_disp(t->scene, seq); @@ -4250,12 +4259,12 @@ static void createTransSeqData(bContext *C, TransInfo *t) #ifdef XXX_DURIAN_ANIM_TX_HACK { Sequence *seq; - for(seq= ed->seqbasep->first; seq; seq= seq->next) { + for (seq= ed->seqbasep->first; seq; seq= seq->next) { /* hack */ - if((seq->flag & SELECT)==0 && seq->type & SEQ_EFFECT) { + if ((seq->flag & SELECT)==0 && seq->type & SEQ_EFFECT) { Sequence *seq_user; int i; - for(i=0; i<3; i++) { + for (i=0; i<3; i++) { seq_user= *((&seq->seq1) + i); if ( seq_user && (seq_user->flag & SELECT) && !(seq_user->flag & SEQ_LOCK) && @@ -4458,7 +4467,7 @@ static void set_trans_object_base_flags(TransInfo *t) Base *base; /* don't do it if we're not actually going to recalculate anything */ - if(t->mode == TFM_DUMMY) + if (t->mode == TFM_DUMMY) return; /* makes sure base flags and object flags are identical */ @@ -4466,22 +4475,22 @@ static void set_trans_object_base_flags(TransInfo *t) /* handle pending update events, otherwise they got copied below */ for (base= scene->base.first; base; base= base->next) { - if(base->object->recalc) + if (base->object->recalc) object_handle_update(t->scene, base->object); } for (base= scene->base.first; base; base= base->next) { base->flag &= ~BA_WAS_SEL; - if(TESTBASELIB_BGMODE(v3d, scene, base)) { + if (TESTBASELIB_BGMODE(v3d, scene, base)) { Object *ob= base->object; Object *parsel= ob->parent; /* if parent selected, deselect */ - while(parsel) { - if(parsel->flag & SELECT) { + while (parsel) { + if (parsel->flag & SELECT) { Base *parbase = object_in_scene(parsel, scene); - if(parbase) { /* in rare cases this can fail */ + if (parbase) { /* in rare cases this can fail */ if TESTBASELIB_BGMODE(v3d, scene, parbase) { break; } @@ -4490,12 +4499,13 @@ static void set_trans_object_base_flags(TransInfo *t) parsel= parsel->parent; } - if(parsel) + if (parsel) { /* rotation around local centers are allowed to propagate */ if ((t->mode == TFM_ROTATION || t->mode == TFM_TRACKBALL) && t->around == V3D_LOCAL) { base->flag |= BA_TRANSFORM_CHILD; - } else { + } + else { base->flag &= ~SELECT; base->flag |= BA_WAS_SEL; } @@ -4511,9 +4521,9 @@ static void set_trans_object_base_flags(TransInfo *t) /* and we store them temporal in base (only used for transform code) */ /* this because after doing updates, the object->recalc is cleared */ for (base= scene->base.first; base; base= base->next) { - if(base->object->recalc & OB_RECALC_OB) + if (base->object->recalc & OB_RECALC_OB) base->flag |= BA_HAS_RECALC_OB; - if(base->object->recalc & OB_RECALC_DATA) + if (base->object->recalc & OB_RECALC_DATA) base->flag |= BA_HAS_RECALC_DATA; } } @@ -4547,11 +4557,11 @@ static int count_proportional_objects(TransInfo *t) { /* mark all parents */ for (base= scene->base.first; base; base= base->next) { - if(TESTBASELIB_BGMODE(v3d, scene, base)) { + if (TESTBASELIB_BGMODE(v3d, scene, base)) { Object *parent = base->object->parent; /* flag all parents */ - while(parent) { + while (parent) { parent->flag |= BA_TRANSFORM_PARENT; parent = parent->parent; } @@ -4591,9 +4601,9 @@ static int count_proportional_objects(TransInfo *t) /* and we store them temporal in base (only used for transform code) */ /* this because after doing updates, the object->recalc is cleared */ for (base= scene->base.first; base; base= base->next) { - if(base->object->recalc & OB_RECALC_OB) + if (base->object->recalc & OB_RECALC_OB) base->flag |= BA_HAS_RECALC_OB; - if(base->object->recalc & OB_RECALC_DATA) + if (base->object->recalc & OB_RECALC_DATA) base->flag |= BA_HAS_RECALC_DATA; } @@ -4607,7 +4617,7 @@ static void clear_trans_object_base_flags(TransInfo *t) for (base= sce->base.first; base; base = base->next) { - if(base->flag & BA_WAS_SEL) + if (base->flag & BA_WAS_SEL) base->flag |= SELECT; base->flag &= ~(BA_WAS_SEL|BA_HAS_RECALC_OB|BA_HAS_RECALC_DATA|BA_TEMP_TAG|BA_TRANSFORM_CHILD|BA_TRANSFORM_PARENT); @@ -4868,7 +4878,7 @@ void special_aftertrans_update(bContext *C, TransInfo *t) if (t->obedit) { if (canceled==0) { /* we need to delete the temporary faces before automerging */ - if(t->mode == TFM_EDGE_SLIDE){ + if (t->mode == TFM_EDGE_SLIDE) { SlideData *sld = t->customData; /* handle multires re-projection, done @@ -4910,8 +4920,8 @@ void special_aftertrans_update(bContext *C, TransInfo *t) /* cant use , TFM_TIME_EXTEND * for some reason EXTEND is changed into TRANSLATE, so use frame_side instead */ - if(t->mode == TFM_SEQ_SLIDE) { - if(t->frame_side == 'B') + if (t->mode == TFM_SEQ_SLIDE) { + if (t->frame_side == 'B') ED_markers_post_apply_transform(&t->scene->markers, t->scene, TFM_TIME_TRANSLATE, t->values[0], t->frame_side); } else if (ELEM(t->frame_side, 'L', 'R')) { @@ -4924,7 +4934,7 @@ void special_aftertrans_update(bContext *C, TransInfo *t) SpaceNode *snode= (SpaceNode *)t->sa->spacedata.first; ED_node_update_hierarchy(C, snode->edittree); - if(canceled == 0) + if (canceled == 0) ED_node_link_insert(t->sa); /* clear link line */ @@ -4934,7 +4944,7 @@ void special_aftertrans_update(bContext *C, TransInfo *t) SpaceClip *sc= t->sa->spacedata.first; MovieClip *clip= ED_space_clip(sc); - if(t->scene->nodetree) { + if (t->scene->nodetree) { /* tracks can be used for stabilization nodes, * flush update for such nodes */ nodeUpdateID(t->scene->nodetree, &clip->id); @@ -5104,7 +5114,7 @@ void special_aftertrans_update(bContext *C, TransInfo *t) * Note: if the refresh is really needed after cancel then some way * has to be added to not update handle types (see bug 22289). */ - if(!canceled) + if (!canceled) ANIM_editkeyframes_refresh(&ac); } else if (t->spacetype == SPACE_NLA) { @@ -5156,7 +5166,7 @@ void special_aftertrans_update(bContext *C, TransInfo *t) ob= t->poseobj; arm= ob->data; - if((t->flag & T_AUTOIK) && (t->options & CTX_AUTOCONFIRM)) { + if ((t->flag & T_AUTOIK) && (t->options & CTX_AUTOCONFIRM)) { /* when running transform non-interactively (operator exec), * we need to update the pose otherwise no updates get called during * transform and the auto-ik is not applied. see [#26164] */ @@ -5175,7 +5185,7 @@ void special_aftertrans_update(bContext *C, TransInfo *t) /* not forget to clear the auto flag */ for (pchan=ob->pose->chanbase.first; pchan; pchan=pchan->next) { bKinematicConstraint *data= has_targetless_ik(pchan); - if(data) data->flag &= ~CONSTRAINT_IK_AUTO; + if (data) data->flag &= ~CONSTRAINT_IK_AUTO; } } @@ -5220,8 +5230,8 @@ void special_aftertrans_update(bContext *C, TransInfo *t) /* flag object caches as outdated */ BKE_ptcache_ids_from_object(&pidlist, ob, t->scene, MAX_DUPLI_RECUR); - for(pid=pidlist.first; pid; pid=pid->next) { - if(pid->type != PTCACHE_TYPE_PARTICLES) /* particles don't need reset on geometry change */ + for (pid=pidlist.first; pid; pid=pid->next) { + if (pid->type != PTCACHE_TYPE_PARTICLES) /* particles don't need reset on geometry change */ pid->cache->flag |= PTCACHE_OUTDATED; } BLI_freelistN(&pidlist); @@ -5270,7 +5280,7 @@ void special_aftertrans_update(bContext *C, TransInfo *t) #if 0 // TRANSFORM_FIX_ME - if(resetslowpar) + if (resetslowpar) reset_slowparents(); #endif } @@ -5286,7 +5296,7 @@ static void createTransObject(bContext *C, TransInfo *t) /* count */ t->total= CTX_DATA_COUNT(C, selected_objects); - if(!t->total) { + if (!t->total) { /* clear here, main transform function escapes too */ clear_trans_object_base_flags(t); return; @@ -5390,7 +5400,7 @@ static void createTransNodeData(bContext *C, TransInfo *t) SpaceNode *snode= t->sa->spacedata.first; bNode *node; - if(!snode->edittree) { + if (!snode->edittree) { t->total= 0; return; } @@ -5445,13 +5455,14 @@ static void markerToTransDataInit(TransData *td, TransData2D *td2d, tdt->mode = transDataTracking_ModeTracks; - if(anchor) { + if (anchor) { td2d->loc[0] = rel[0]; /* hold original location */ td2d->loc[1] = rel[1]; tdt->loc= loc; td2d->loc2d = loc; /* current location */ - } else { + } + else { td2d->loc[0] = loc[0]; /* hold original location */ td2d->loc[1] = loc[1]; @@ -5465,8 +5476,8 @@ static void markerToTransDataInit(TransData *td, TransData2D *td2d, tdt->markersnr= track->markersnr; tdt->markers= track->markers; - if(rel) { - if(!anchor) { + if (rel) { + if (!anchor) { td2d->loc[0]+= rel[0]; td2d->loc[1]+= rel[1]; } @@ -5474,7 +5485,7 @@ static void markerToTransDataInit(TransData *td, TransData2D *td2d, copy_v2_v2(tdt->srelative, rel); } - if(off) + if (off) copy_v2_v2(tdt->soffset, off); td->flag = 0; @@ -5504,15 +5515,15 @@ static void trackToTransData(SpaceClip *sc, TransData *td, TransData2D *td2d, markerToTransDataInit(td++, td2d++, tdt++, track, TRACK_AREA_POINT, track->offset, marker->pos, track->offset); - if(track->flag&SELECT) + if (track->flag&SELECT) markerToTransDataInit(td++, td2d++, tdt++, track, TRACK_AREA_POINT, marker->pos, NULL, NULL); - if(track->pat_flag&SELECT) { + if (track->pat_flag&SELECT) { markerToTransDataInit(td++, td2d++, tdt++, track, TRACK_AREA_PAT, track->pat_min, marker->pos, NULL); markerToTransDataInit(td++, td2d++, tdt++, track, TRACK_AREA_PAT, track->pat_max, marker->pos, NULL); } - if(track->search_flag&SELECT) { + if (track->search_flag&SELECT) { markerToTransDataInit(td++, td2d++, tdt++, track, TRACK_AREA_SEARCH, track->search_min, marker->pos, NULL); markerToTransDataInit(td++, td2d++, tdt++, track, TRACK_AREA_SEARCH, track->search_max, marker->pos, NULL); } @@ -5522,8 +5533,8 @@ static void transDataTrackingFree(TransInfo *t) { TransDataTracking *tdt= t->customData; - if(tdt) { - if(tdt->smarkers) MEM_freeN(tdt->smarkers); + if (tdt) { + if (tdt->smarkers) MEM_freeN(tdt->smarkers); MEM_freeN(tdt); } } @@ -5544,21 +5555,21 @@ static void createTransTrackingTracksData(bContext *C, TransInfo *t) t->total = 0; track = tracksbase->first; - while(track) { - if(TRACK_VIEW_SELECTED(sc, track) && (track->flag&TRACK_LOCKED)==0) { + while (track) { + if (TRACK_VIEW_SELECTED(sc, track) && (track->flag&TRACK_LOCKED)==0) { marker= BKE_tracking_get_marker(track, framenr); t->total++; /* offset */ - if(track->flag&SELECT) t->total++; - if(track->pat_flag&SELECT) t->total+= 2; - if(track->search_flag&SELECT) t->total+= 2; + if (track->flag&SELECT) t->total++; + if (track->pat_flag&SELECT) t->total+= 2; + if (track->search_flag&SELECT) t->total+= 2; } track = track->next; } - if(t->total==0) + if (t->total==0) return; td = t->data = MEM_callocN(t->total*sizeof(TransData), "TransTracking TransData"); @@ -5569,8 +5580,8 @@ static void createTransTrackingTracksData(bContext *C, TransInfo *t) /* create actual data */ track = tracksbase->first; - while(track) { - if(TRACK_VIEW_SELECTED(sc, track) && (track->flag&TRACK_LOCKED)==0) { + while (track) { + if (TRACK_VIEW_SELECTED(sc, track) && (track->flag&TRACK_LOCKED)==0) { marker= BKE_tracking_get_marker(track, framenr); trackToTransData(sc, td, td2d, tdt, track); @@ -5580,17 +5591,17 @@ static void createTransTrackingTracksData(bContext *C, TransInfo *t) td2d++; tdt++; - if((marker->flag&MARKER_DISABLED)==0) { - if(track->flag&SELECT) {td++; td2d++; tdt++;} - if(track->pat_flag&SELECT) {td+= 2; td2d+= 2;tdt+=2;} + if ((marker->flag&MARKER_DISABLED)==0) { + if (track->flag&SELECT) {td++; td2d++; tdt++;} + if (track->pat_flag&SELECT) {td+= 2; td2d+= 2;tdt+=2;} } - if(track->search_flag&SELECT) { + if (track->search_flag&SELECT) { td+= 2; td2d+= 2; tdt+= 2; - if(marker->flag&MARKER_DISABLED) { + if (marker->flag&MARKER_DISABLED) { td+= 3; td2d+= 3; tdt+= 3; @@ -5658,19 +5669,19 @@ static void createTransTrackingCurvesData(bContext *C, TransInfo *t) t->total = 0; track = tracksbase->first; - while(track) { - if(TRACK_VIEW_SELECTED(sc, track) && (track->flag & TRACK_LOCKED)==0) { - for(i = 1; i < track->markersnr; i++) { + while (track) { + if (TRACK_VIEW_SELECTED(sc, track) && (track->flag & TRACK_LOCKED)==0) { + for (i = 1; i < track->markersnr; i++) { marker = &track->markers[i]; prev_marker = &track->markers[i-1]; - if((marker->flag & MARKER_DISABLED) || (prev_marker->flag & MARKER_DISABLED)) + if ((marker->flag & MARKER_DISABLED) || (prev_marker->flag & MARKER_DISABLED)) continue; - if(marker->flag & MARKER_GRAPH_SEL_X) + if (marker->flag & MARKER_GRAPH_SEL_X) t->total += 1; - if(marker->flag & MARKER_GRAPH_SEL_Y) + if (marker->flag & MARKER_GRAPH_SEL_Y) t->total += 1; } } @@ -5678,7 +5689,7 @@ static void createTransTrackingCurvesData(bContext *C, TransInfo *t) track = track->next; } - if(t->total==0) + if (t->total==0) return; td = t->data = MEM_callocN(t->total*sizeof(TransData), "TransTracking TransData"); @@ -5689,23 +5700,23 @@ static void createTransTrackingCurvesData(bContext *C, TransInfo *t) /* create actual data */ track = tracksbase->first; - while(track) { - if(TRACK_VIEW_SELECTED(sc, track) && (track->flag & TRACK_LOCKED)==0) { - for(i = 1; i < track->markersnr; i++) { + while (track) { + if (TRACK_VIEW_SELECTED(sc, track) && (track->flag & TRACK_LOCKED)==0) { + for (i = 1; i < track->markersnr; i++) { marker = &track->markers[i]; prev_marker = &track->markers[i-1]; - if((marker->flag & MARKER_DISABLED) || (prev_marker->flag & MARKER_DISABLED)) + if ((marker->flag & MARKER_DISABLED) || (prev_marker->flag & MARKER_DISABLED)) continue; - if(marker->flag & MARKER_GRAPH_SEL_X) { + if (marker->flag & MARKER_GRAPH_SEL_X) { markerToTransCurveDataInit(td, td2d, tdt, marker, &track->markers[i-1], 0, width); td += 1; td2d += 1; tdt += 1; } - if(marker->flag & MARKER_GRAPH_SEL_Y) { + if (marker->flag & MARKER_GRAPH_SEL_Y) { markerToTransCurveDataInit(td, td2d, tdt, marker, &track->markers[i-1], 1, height); td += 1; @@ -5727,13 +5738,13 @@ static void createTransTrackingData(bContext *C, TransInfo *t) t->total = 0; - if(!clip || !BKE_movieclip_has_frame(clip, &sc->user)) + if (!clip || !BKE_movieclip_has_frame(clip, &sc->user)) return; - if(!ELEM(t->mode, TFM_RESIZE, TFM_TRANSLATION)) + if (!ELEM(t->mode, TFM_RESIZE, TFM_TRANSLATION)) return; - if(ar->regiontype == RGN_TYPE_PREVIEW) { + if (ar->regiontype == RGN_TYPE_PREVIEW) { /* transformation was called from graph editor */ createTransTrackingCurvesData(C, t); } @@ -5752,37 +5763,37 @@ static void cancelTransTracking(TransInfo *t) MovieTrackingMarker *marker; int a, framenr = sc->user.framenr; - if(tdt->mode == transDataTracking_ModeTracks) { + if (tdt->mode == transDataTracking_ModeTracks) { track = tracksbase->first; - while(track) { - if(TRACK_VIEW_SELECTED(sc, track) && (track->flag & TRACK_LOCKED)==0) { + while (track) { + if (TRACK_VIEW_SELECTED(sc, track) && (track->flag & TRACK_LOCKED)==0) { marker = BKE_tracking_get_marker(track, framenr); marker->flag = tdt->flag; tdt++; - if(track->flag&SELECT) tdt++; - if(track->pat_flag&SELECT) tdt += 2; - if(track->search_flag&SELECT) tdt += 2; + if (track->flag&SELECT) tdt++; + if (track->pat_flag&SELECT) tdt += 2; + if (track->search_flag&SELECT) tdt += 2; } track = track->next; } } - else if(tdt->mode == transDataTracking_ModeCurves) { + else if (tdt->mode == transDataTracking_ModeCurves) { MovieTrackingMarker *prev_marker; track = tracksbase->first; - while(track) { - if(TRACK_VIEW_SELECTED(sc, track) && (track->flag & TRACK_LOCKED)==0) { - for(a = 1; a < track->markersnr; a++) { + while (track) { + if (TRACK_VIEW_SELECTED(sc, track) && (track->flag & TRACK_LOCKED)==0) { + for (a = 1; a < track->markersnr; a++) { marker = &track->markers[a]; prev_marker = &track->markers[a-1]; - if((marker->flag & MARKER_DISABLED) || (prev_marker->flag & MARKER_DISABLED)) + if ((marker->flag & MARKER_DISABLED) || (prev_marker->flag & MARKER_DISABLED)) continue; - if(marker->flag & (MARKER_GRAPH_SEL_X|MARKER_GRAPH_SEL_Y)) { + if (marker->flag & (MARKER_GRAPH_SEL_X|MARKER_GRAPH_SEL_Y)) { marker->flag = tdt->flag; } } @@ -5800,19 +5811,19 @@ void flushTransTracking(TransInfo *t) TransDataTracking *tdt; int a; - if(t->state == TRANS_CANCEL) + if (t->state == TRANS_CANCEL) cancelTransTracking(t); /* flush to 2d vector from internally used 3d vector */ - for(a=0, td= t->data, td2d= t->data2d, tdt= t->customData; atotal; a++, td2d++, td++, tdt++) { - if(tdt->mode == transDataTracking_ModeTracks) { - if(t->flag&T_ALT_TRANSFORM) { - if(tdt->area==TRACK_AREA_POINT && tdt->relative) { + for (a=0, td= t->data, td2d= t->data2d, tdt= t->customData; atotal; a++, td2d++, td++, tdt++) { + if (tdt->mode == transDataTracking_ModeTracks) { + if (t->flag&T_ALT_TRANSFORM) { + if (tdt->area==TRACK_AREA_POINT && tdt->relative) { float d[2], d2[2]; - if(!tdt->smarkers) { + if (!tdt->smarkers) { tdt->smarkers= MEM_callocN(sizeof(*tdt->smarkers)*tdt->markersnr, "flushTransTracking markers"); - for(a= 0; amarkersnr; a++) + for (a= 0; amarkersnr; a++) copy_v2_v2(tdt->smarkers[a], tdt->markers[a].pos); } @@ -5821,22 +5832,22 @@ void flushTransTracking(TransInfo *t) sub_v2_v2v2(d2, td2d->loc, tdt->srelative); - for(a= 0; amarkersnr; a++) + for (a= 0; amarkersnr; a++) add_v2_v2v2(tdt->markers[a].pos, tdt->smarkers[a], d2); negate_v2_v2(td2d->loc2d, d); } } - if(tdt->area!=TRACK_AREA_POINT || tdt->relative==0) { + if (tdt->area!=TRACK_AREA_POINT || tdt->relative==0) { td2d->loc2d[0] = td2d->loc[0]; td2d->loc2d[1] = td2d->loc[1]; - if(tdt->relative) + if (tdt->relative) sub_v2_v2(td2d->loc2d, tdt->relative); } } - else if(tdt->mode == transDataTracking_ModeCurves) { + else if (tdt->mode == transDataTracking_ModeCurves) { td2d->loc2d[tdt->coord] = tdt->prev_pos[tdt->coord] + td2d->loc[1] * tdt->scale; } } @@ -5855,7 +5866,7 @@ void createTransData(bContext *C, TransInfo *t) t->ext = NULL; t->flag |= T_EDIT; createTransEdge(t); - if(t->data && t->flag & T_PROP_EDIT) { + if (t->data && t->flag & T_PROP_EDIT) { sort_trans_data(t); // makes selected become first in array set_prop_dist(t, 1); sort_trans_data_dist(t); @@ -5868,7 +5879,7 @@ void createTransData(bContext *C, TransInfo *t) else if (t->spacetype == SPACE_IMAGE) { t->flag |= T_POINTS|T_2D_EDIT; createTransUVs(C, t); - if(t->data && (t->flag & T_PROP_EDIT)) { + if (t->data && (t->flag & T_PROP_EDIT)) { sort_trans_data(t); // makes selected become first in array set_prop_dist(t, 1); sort_trans_data_dist(t); @@ -5898,7 +5909,7 @@ void createTransData(bContext *C, TransInfo *t) } #endif } - else if(t->spacetype == SPACE_NODE) { + else if (t->spacetype == SPACE_NODE) { t->flag |= T_2D_EDIT|T_POINTS; createTransNodeData(C, t); if (t->data && (t->flag & T_PROP_EDIT)) { @@ -5935,7 +5946,7 @@ void createTransData(bContext *C, TransInfo *t) t->flag |= T_EDIT|T_POINTS; - if(t->data && t->flag & T_PROP_EDIT) { + if (t->data && t->flag & T_PROP_EDIT) { if (ELEM(t->obedit->type, OB_CURVE, OB_MESH)) { sort_trans_data(t); // makes selected become first in array set_prop_dist(t, 0); @@ -5949,7 +5960,7 @@ void createTransData(bContext *C, TransInfo *t) } /* exception... hackish, we want bonesize to use bone orientation matrix (ton) */ - if(t->mode==TFM_BONESIZE) { + if (t->mode==TFM_BONESIZE) { t->flag &= ~(T_EDIT|T_POINTS); t->flag |= T_POSE; t->poseobj = ob; /* <- tsk tsk, this is going to give issues one day */ @@ -5964,11 +5975,11 @@ void createTransData(bContext *C, TransInfo *t) /* important that ob_armature can be set even when its not selected [#23412] * lines below just check is also visible */ Object *ob_armature= modifiers_isDeformedByArmature(ob); - if(ob_armature && ob_armature->mode & OB_MODE_POSE) { + if (ob_armature && ob_armature->mode & OB_MODE_POSE) { Base *base_arm= object_in_scene(ob_armature, t->scene); - if(base_arm) { + if (base_arm) { View3D *v3d = t->view; - if(BASE_VISIBLE(v3d, base_arm)) { + if (BASE_VISIBLE(v3d, base_arm)) { createTransPose(t, ob_armature); } } @@ -5980,7 +5991,7 @@ void createTransData(bContext *C, TransInfo *t) createTransParticleVerts(C, t); t->flag |= T_POINTS; - if(t->data && t->flag & T_PROP_EDIT) { + if (t->data && t->flag & T_PROP_EDIT) { sort_trans_data(t); // makes selected become first in array set_prop_dist(t, 1); sort_trans_data_dist(t); @@ -5997,7 +6008,7 @@ void createTransData(bContext *C, TransInfo *t) createTransObject(C, t); t->flag |= T_OBJECT; - if(t->data && t->flag & T_PROP_EDIT) { + if (t->data && t->flag & T_PROP_EDIT) { // selected objects are already first, no need to presort set_prop_dist(t, 1); sort_trans_data_dist(t); @@ -6007,7 +6018,7 @@ void createTransData(bContext *C, TransInfo *t) { View3D *v3d = t->view; RegionView3D *rv3d = CTX_wm_region_view3d(C); - if(rv3d && (t->flag & T_OBJECT) && v3d->camera == OBACT && rv3d->persp==RV3D_CAMOB) + if (rv3d && (t->flag & T_OBJECT) && v3d->camera == OBACT && rv3d->persp==RV3D_CAMOB) { t->flag |= T_CAMERA; } diff --git a/source/blender/editors/transform/transform_generics.c b/source/blender/editors/transform/transform_generics.c index 350d2365511..8e22ccd943d 100644 --- a/source/blender/editors/transform/transform_generics.c +++ b/source/blender/editors/transform/transform_generics.c @@ -147,17 +147,17 @@ static void clipMirrorModifier(TransInfo *t, Object *ob) if ((md->type==eModifierType_Mirror) && (md->mode & eModifierMode_Realtime)) { MirrorModifierData *mmd = (MirrorModifierData*) md; - if(mmd->flag & MOD_MIR_CLIPPING) { + if (mmd->flag & MOD_MIR_CLIPPING) { axis = 0; - if(mmd->flag & MOD_MIR_AXIS_X) { + if (mmd->flag & MOD_MIR_AXIS_X) { axis |= 1; tolerance[0] = mmd->tolerance; } - if(mmd->flag & MOD_MIR_AXIS_Y) { + if (mmd->flag & MOD_MIR_AXIS_Y) { axis |= 2; tolerance[1] = mmd->tolerance; } - if(mmd->flag & MOD_MIR_AXIS_Z) { + if (mmd->flag & MOD_MIR_AXIS_Z) { axis |= 4; tolerance[2] = mmd->tolerance; } @@ -174,7 +174,7 @@ static void clipMirrorModifier(TransInfo *t, Object *ob) invert_m4_m4(imtx, mtx); } - for(i = 0 ; i < t->total; i++, td++) { + for (i = 0 ; i < t->total; i++, td++) { int clip; float loc[3], iloc[3]; @@ -195,8 +195,8 @@ static void clipMirrorModifier(TransInfo *t, Object *ob) } clip = 0; - if(axis & 1) { - if(fabsf(iloc[0])<=tolerance[0] || + if (axis & 1) { + if (fabsf(iloc[0])<=tolerance[0] || loc[0]*iloc[0]<0.0f) { loc[0]= 0.0f; @@ -204,16 +204,16 @@ static void clipMirrorModifier(TransInfo *t, Object *ob) } } - if(axis & 2) { - if(fabs(iloc[1])<=tolerance[1] || + if (axis & 2) { + if (fabs(iloc[1])<=tolerance[1] || loc[1]*iloc[1]<0.0f) { loc[1]= 0.0f; clip = 1; } } - if(axis & 4) { - if(fabs(iloc[2])<=tolerance[2] || + if (axis & 4) { + if (fabs(iloc[2])<=tolerance[2] || loc[2]*iloc[2]<0.0f) { loc[2]= 0.0f; @@ -241,7 +241,7 @@ static void editbmesh_apply_to_mirror(TransInfo *t) BMVert *eve; int i; - for(i = 0 ; i < t->total; i++, td++) { + for (i = 0 ; i < t->total; i++, td++) { if (td->flag & TD_NOACTION) break; if (td->loc==NULL) @@ -627,7 +627,7 @@ static void recalcData_image(TransInfo *t) SpaceImage *sima= t->sa->spacedata.first; flushTransUVs(t); - if(sima->flag & SI_LIVE_UNWRAP) + if (sima->flag & SI_LIVE_UNWRAP) ED_uvedit_live_unwrap_re_solve(); DAG_id_tag_update(t->obedit->data, 0); @@ -645,18 +645,18 @@ static void recalcData_clip(TransInfo *t) flushTransTracking(t); track= tracksbase->first; - while(track) { - if(TRACK_VIEW_SELECTED(sc, track) && (track->flag & TRACK_LOCKED)==0) { + while (track) { + if (TRACK_VIEW_SELECTED(sc, track) && (track->flag & TRACK_LOCKED)==0) { if (t->mode == TFM_TRANSLATION) { - if(TRACK_AREA_SELECTED(track, TRACK_AREA_PAT)) + if (TRACK_AREA_SELECTED(track, TRACK_AREA_PAT)) BKE_tracking_clamp_track(track, CLAMP_PAT_POS); - if(TRACK_AREA_SELECTED(track, TRACK_AREA_SEARCH)) + if (TRACK_AREA_SELECTED(track, TRACK_AREA_SEARCH)) BKE_tracking_clamp_track(track, CLAMP_SEARCH_POS); } else if (t->mode == TFM_RESIZE) { - if(TRACK_AREA_SELECTED(track, TRACK_AREA_PAT)) + if (TRACK_AREA_SELECTED(track, TRACK_AREA_PAT)) BKE_tracking_clamp_track(track, CLAMP_PAT_DIM); - if(TRACK_AREA_SELECTED(track, TRACK_AREA_SEARCH)) + if (TRACK_AREA_SELECTED(track, TRACK_AREA_SEARCH)) BKE_tracking_clamp_track(track, CLAMP_SEARCH_DIM); } } @@ -678,7 +678,7 @@ static void recalcData_view3d(TransInfo *t) ListBase *nurbs= curve_editnurbs(cu); Nurb *nu= nurbs->first; - if(t->state != TRANS_CANCEL) { + if (t->state != TRANS_CANCEL) { clipMirrorModifier(t, t->obedit); applyProject(t); } @@ -686,40 +686,40 @@ static void recalcData_view3d(TransInfo *t) DAG_id_tag_update(t->obedit->data, 0); /* sets recalc flags */ if (t->state == TRANS_CANCEL) { - while(nu) { + while (nu) { calchandlesNurb(nu); /* Cant do testhandlesNurb here, it messes up the h1 and h2 flags */ nu= nu->next; } } else { /* Normal updating */ - while(nu) { + while (nu) { test2DNurb(nu); calchandlesNurb(nu); nu= nu->next; } } } - else if(t->obedit->type==OB_LATTICE) { + else if (t->obedit->type==OB_LATTICE) { Lattice *la= t->obedit->data; - if(t->state != TRANS_CANCEL) { + if (t->state != TRANS_CANCEL) { applyProject(t); } DAG_id_tag_update(t->obedit->data, 0); /* sets recalc flags */ - if(la->editlatt->latt->flag & LT_OUTSIDE) outside_lattice(la->editlatt->latt); + if (la->editlatt->latt->flag & LT_OUTSIDE) outside_lattice(la->editlatt->latt); } else if (t->obedit->type == OB_MESH) { BMEditMesh *em = BMEdit_FromObject(t->obedit); /* mirror modifier clipping? */ - if(t->state != TRANS_CANCEL) { + if (t->state != TRANS_CANCEL) { /* apply clipping after so we never project past the clip plane [#25423] */ applyProject(t); clipMirrorModifier(t, t->obedit); } - if((t->options & CTX_NO_MIRROR) == 0 && (t->flag & T_MIRROR)) + if ((t->options & CTX_NO_MIRROR) == 0 && (t->flag & T_MIRROR)) editbmesh_apply_to_mirror(t); DAG_id_tag_update(t->obedit->data, 0); /* sets recalc flags */ @@ -727,14 +727,14 @@ static void recalcData_view3d(TransInfo *t) EDBM_RecalcNormals(em); BMEdit_RecalcTessellation(em); } - else if(t->obedit->type==OB_ARMATURE) { /* no recalc flag, does pose */ + else if (t->obedit->type==OB_ARMATURE) { /* no recalc flag, does pose */ bArmature *arm= t->obedit->data; ListBase *edbo = arm->edbo; EditBone *ebo; TransData *td = t->data; int i; - if(t->state != TRANS_CANCEL) { + if (t->state != TRANS_CANCEL) { applyProject(t); } @@ -745,27 +745,27 @@ static void recalcData_view3d(TransInfo *t) /* If this bone has a parent tip that has been moved */ if (ebo->parent->flag & BONE_TIPSEL) { copy_v3_v3 (ebo->head, ebo->parent->tail); - if(t->mode==TFM_BONE_ENVELOPE) ebo->rad_head= ebo->parent->rad_tail; + if (t->mode==TFM_BONE_ENVELOPE) ebo->rad_head= ebo->parent->rad_tail; } /* If this bone has a parent tip that has NOT been moved */ - else{ + else { copy_v3_v3 (ebo->parent->tail, ebo->head); - if(t->mode==TFM_BONE_ENVELOPE) ebo->parent->rad_tail= ebo->rad_head; + if (t->mode==TFM_BONE_ENVELOPE) ebo->parent->rad_tail= ebo->rad_head; } } /* on extrude bones, oldlength==0.0f, so we scale radius of points */ ebo->length= len_v3v3(ebo->head, ebo->tail); - if(ebo->oldlength==0.0f) { + if (ebo->oldlength==0.0f) { ebo->rad_head= 0.25f*ebo->length; ebo->rad_tail= 0.10f*ebo->length; ebo->dist= 0.25f*ebo->length; - if(ebo->parent) { - if(ebo->rad_head > ebo->parent->rad_tail) + if (ebo->parent) { + if (ebo->rad_head > ebo->parent->rad_tail) ebo->rad_head= ebo->parent->rad_tail; } } - else if(t->mode!=TFM_BONE_ENVELOPE) { + else if (t->mode!=TFM_BONE_ENVELOPE) { /* if bones change length, lets do that for the deform distance as well */ ebo->dist*= ebo->length/ebo->oldlength; ebo->rad_head*= ebo->length/ebo->oldlength; @@ -778,7 +778,7 @@ static void recalcData_view3d(TransInfo *t) if (t->mode != TFM_BONE_ROLL) { /* fix roll */ - for(i = 0; i < t->total; i++, td++) + for (i = 0; i < t->total; i++, td++) { if (td->extra) { @@ -804,18 +804,18 @@ static void recalcData_view3d(TransInfo *t) } } - if(arm->flag & ARM_MIRROR_EDIT) + if (arm->flag & ARM_MIRROR_EDIT) transform_armature_mirror_update(t->obedit); } else { - if(t->state != TRANS_CANCEL) { + if (t->state != TRANS_CANCEL) { applyProject(t); } DAG_id_tag_update(t->obedit->data, 0); /* sets recalc flags */ } } - else if( (t->flag & T_POSE) && t->poseobj) { + else if ( (t->flag & T_POSE) && t->poseobj) { Object *ob= t->poseobj; bArmature *arm= ob->data; @@ -840,8 +840,8 @@ static void recalcData_view3d(TransInfo *t) else where_is_pose(t->scene, ob); } - else if(base && (base->object->mode & OB_MODE_PARTICLE_EDIT) && PE_get_current(t->scene, base->object)) { - if(t->state != TRANS_CANCEL) { + else if (base && (base->object->mode & OB_MODE_PARTICLE_EDIT) && PE_get_current(t->scene, base->object)) { + if (t->state != TRANS_CANCEL) { applyProject(t); } flushTransParticles(t); @@ -849,7 +849,7 @@ static void recalcData_view3d(TransInfo *t) else { int i; - if(t->state != TRANS_CANCEL) { + if (t->state != TRANS_CANCEL) { applyProject(t); } @@ -965,8 +965,8 @@ int initTransInfo (bContext *C, TransInfo *t, wmOperator *op, wmEvent *event) /* moving: is shown in drawobject() (transform color) */ // TRANSFORM_FIX_ME -// if(obedit || (t->flag & T_POSE) ) G.moving= G_TRANSFORM_EDIT; -// else if(G.f & G_PARTICLEEDIT) G.moving= G_TRANSFORM_PARTICLE; +// if (obedit || (t->flag & T_POSE) ) G.moving= G_TRANSFORM_EDIT; +// else if (G.f & G_PARTICLEEDIT) G.moving= G_TRANSFORM_PARTICLE; // else G.moving= G_TRANSFORM_OBJ; t->scene = sce; @@ -1029,7 +1029,7 @@ int initTransInfo (bContext *C, TransInfo *t, wmOperator *op, wmEvent *event) /* Assign the space type, some exceptions for running in different mode */ - if(sa == NULL) { + if (sa == NULL) { /* background mode */ t->spacetype= SPACE_EMPTY; } @@ -1043,7 +1043,7 @@ int initTransInfo (bContext *C, TransInfo *t, wmOperator *op, wmEvent *event) } - if(t->spacetype == SPACE_VIEW3D) + if (t->spacetype == SPACE_VIEW3D) { View3D *v3d = sa->spacedata.first; @@ -1057,7 +1057,7 @@ int initTransInfo (bContext *C, TransInfo *t, wmOperator *op, wmEvent *event) v3d->twtype = 0; } - if(v3d->flag & V3D_ALIGN) t->flag |= T_V3D_ALIGN; + if (v3d->flag & V3D_ALIGN) t->flag |= T_V3D_ALIGN; t->around = v3d->around; if (op && RNA_struct_find_property(op->ptr, "constraint_orientation") && RNA_struct_property_is_set(op->ptr, "constraint_orientation")) @@ -1074,16 +1074,16 @@ int initTransInfo (bContext *C, TransInfo *t, wmOperator *op, wmEvent *event) } /* exceptional case */ - if(t->around==V3D_LOCAL && (t->settings->selectmode & SCE_SELECT_FACE)) { - if(ELEM3(t->mode, TFM_ROTATION, TFM_RESIZE, TFM_TRACKBALL)) { + if (t->around==V3D_LOCAL && (t->settings->selectmode & SCE_SELECT_FACE)) { + if (ELEM3(t->mode, TFM_ROTATION, TFM_RESIZE, TFM_TRACKBALL)) { t->options |= CTX_NO_PET; } } /* initialize UV transform from */ if (op && RNA_struct_find_property(op->ptr, "correct_uv")) { - if(RNA_struct_property_is_set(op->ptr, "correct_uv")) { - if(RNA_boolean_get(op->ptr, "correct_uv")) { + if (RNA_struct_property_is_set(op->ptr, "correct_uv")) { + if (RNA_boolean_get(op->ptr, "correct_uv")) { t->settings->uvcalc_flag |= UVCALC_TRANSFORM_CORRECT; } else { @@ -1096,24 +1096,24 @@ int initTransInfo (bContext *C, TransInfo *t, wmOperator *op, wmEvent *event) } } - else if(t->spacetype==SPACE_IMAGE) { + else if (t->spacetype==SPACE_IMAGE) { SpaceImage *sima = sa->spacedata.first; // XXX for now, get View2D from the active region t->view = &ar->v2d; t->around = sima->around; } - else if(t->spacetype==SPACE_NODE) { + else if (t->spacetype==SPACE_NODE) { // XXX for now, get View2D from the active region t->view = &ar->v2d; t->around = V3D_CENTER; } - else if(t->spacetype==SPACE_IPO) { + else if (t->spacetype==SPACE_IPO) { SpaceIpo *sipo= sa->spacedata.first; t->view = &ar->v2d; t->around = sipo->around; } else { - if(ar) { + if (ar) { // XXX for now, get View2D from the active region t->view = &ar->v2d; // XXX for now, the center point is the midpoint of the data @@ -1254,7 +1254,7 @@ void postTrans (bContext *C, TransInfo *t) int a; /* free data malloced per trans-data */ - for(a=0, td= t->data; atotal; a++, td++) { + for (a=0, td= t->data; atotal; a++, td++) { if (td->flag & TD_BEZTRIPLE) MEM_freeN(td->hdata); } @@ -1269,12 +1269,12 @@ void postTrans (bContext *C, TransInfo *t) t->data2d= NULL; } - if(t->spacetype==SPACE_IMAGE) { + if (t->spacetype==SPACE_IMAGE) { SpaceImage *sima= t->sa->spacedata.first; - if(sima->flag & SI_LIVE_UNWRAP) + if (sima->flag & SI_LIVE_UNWRAP) ED_uvedit_live_unwrap_end(t->state == TRANS_CANCEL); } - else if(t->spacetype==SPACE_VIEW3D) { + else if (t->spacetype==SPACE_VIEW3D) { View3D *v3d = t->sa->spacedata.first; /* restore manipulator */ if (t->flag & T_MODAL) { @@ -1318,10 +1318,10 @@ static void restoreElement(TransData *td) if (td->ext->rot) { copy_v3_v3(td->ext->rot, td->ext->irot); } - if(td->ext->rotAngle) { + if (td->ext->rotAngle) { *td->ext->rotAngle= td->ext->irotAngle; } - if(td->ext->rotAxis) { + if (td->ext->rotAxis) { copy_v3_v3(td->ext->rotAxis, td->ext->irotAxis); } /* XXX, drotAngle & drotAxis not used yet */ @@ -1405,7 +1405,7 @@ void calculateCenterCursor2D(TransInfo *t) float aspx=1.0, aspy=1.0; float *cursor= NULL; - if(t->spacetype==SPACE_IMAGE) { + if (t->spacetype==SPACE_IMAGE) { SpaceImage *sima= (SpaceImage *)t->sa->spacedata.first; /* only space supported right now but may change */ ED_space_image_uv_aspect(sima, &aspx, &aspy); @@ -1438,7 +1438,7 @@ void calculateCenterMedian(TransInfo *t) int total = 0; int i; - for(i = 0; i < t->total; i++) { + for (i = 0; i < t->total; i++) { if (t->data[i].flag & TD_SELECTED) { if (!(t->data[i].flag & TD_NOCENTER)) { @@ -1454,7 +1454,7 @@ void calculateCenterMedian(TransInfo *t) break; } } - if(i) + if (i) mul_v3_fl(partial, 1.0f / total); copy_v3_v3(t->center, partial); @@ -1466,7 +1466,7 @@ void calculateCenterBound(TransInfo *t) float max[3]; float min[3]; int i; - for(i = 0; i < t->total; i++) { + for (i = 0; i < t->total; i++) { if (i) { if (t->data[i].flag & TD_SELECTED) { if (!(t->data[i].flag & TD_NOCENTER)) @@ -1501,9 +1501,9 @@ void calculateCenter(TransInfo *t) calculateCenterMedian(t); break; case V3D_CURSOR: - if(t->spacetype==SPACE_IMAGE) + if (t->spacetype==SPACE_IMAGE) calculateCenterCursor2D(t); - else if(t->spacetype==SPACE_IPO) + else if (t->spacetype==SPACE_IPO) calculateCenterCursorGraph2D(t); else calculateCenterCursor(t); @@ -1542,7 +1542,7 @@ void calculateCenter(TransInfo *t) } /* END EDIT MODE ACTIVE ELEMENT */ calculateCenterMedian(t); - if((t->flag & (T_EDIT|T_POSE))==0) + if ((t->flag & (T_EDIT|T_POSE))==0) { Scene *scene = t->scene; Object *ob= OBACT; @@ -1583,7 +1583,7 @@ void calculateCenter(TransInfo *t) projectIntView(t, axis, t->center2d); /* rotate only needs correct 2d center, grab needs initgrabz() value */ - if(t->mode==TFM_TRANSLATION) + if (t->mode==TFM_TRANSLATION) { copy_v3_v3(t->center, axis); copy_v3_v3(t->con.center, t->center); @@ -1594,7 +1594,7 @@ void calculateCenter(TransInfo *t) if (t->spacetype==SPACE_VIEW3D) { /* initgrabz() defines a factor for perspective depth correction, used in window_to_3d_delta() */ - if(t->flag & (T_EDIT|T_POSE)) { + if (t->flag & (T_EDIT|T_POSE)) { Object *ob= t->obedit?t->obedit:t->poseobj; float vec[3]; @@ -1616,7 +1616,7 @@ void calculatePropRatio(TransInfo *t) short connected = t->flag & T_PROP_CONNECTED; if (t->flag & T_PROP_EDIT) { - for(i = 0 ; i < t->total; i++, td++) { + for (i = 0 ; i < t->total; i++, td++) { if (td->flag & TD_SELECTED) { td->factor = 1.0f; } @@ -1710,7 +1710,7 @@ void calculatePropRatio(TransInfo *t) } } else { - for(i = 0 ; i < t->total; i++, td++) { + for (i = 0 ; i < t->total; i++, td++) { td->factor = 1.0; } t->proptext[0]= '\0'; diff --git a/source/blender/editors/transform/transform_input.c b/source/blender/editors/transform/transform_input.c index 3faddeb6639..bd3fb20f77f 100644 --- a/source/blender/editors/transform/transform_input.c +++ b/source/blender/editors/transform/transform_input.c @@ -236,7 +236,7 @@ static void InputAngle(TransInfo *UNUSED(t), MouseInput *mi, const int mval[2], float dphi; dphi = saacos((float)deler); - if( (dx1*dy2-dx2*dy1)>0.0 ) dphi= -dphi; + if ( (dx1*dy2-dx2*dy1)>0.0 ) dphi= -dphi; /* If the angle is zero, because of lack of precision close to the 1.0 value in acos * approximate the angle with the opposite side of the normalized triangle @@ -256,7 +256,7 @@ static void InputAngle(TransInfo *UNUSED(t), MouseInput *mi, const int mval[2], dy = dy1 - dy2; dphi = sqrt(dx*dx + dy*dy); - if( (dx1*dy2-dx2*dy1)>0.0 ) dphi= -dphi; + if ( (dx1*dy2-dx2*dy1)>0.0 ) dphi= -dphi; } if (mi->precision) { @@ -307,7 +307,7 @@ void initMouseInputMode(TransInfo *t, MouseInput *mi, MouseInputMode mode) /* TODO, holding R-key can cause mem leak, but this causes [#28903] * disable for now. */ #if 0 - if(mi->data) { + if (mi->data) { MEM_freeN(mi->data); mi->data= NULL; } diff --git a/source/blender/editors/transform/transform_manipulator.c b/source/blender/editors/transform/transform_manipulator.c index faf8071bd45..e30406ea568 100644 --- a/source/blender/editors/transform/transform_manipulator.c +++ b/source/blender/editors/transform/transform_manipulator.c @@ -120,25 +120,25 @@ static void calc_tw_center(Scene *scene, float *co) static void protectflag_to_drawflags(short protectflag, short *drawflags) { - if(protectflag & OB_LOCK_LOCX) + if (protectflag & OB_LOCK_LOCX) *drawflags &= ~MAN_TRANS_X; - if(protectflag & OB_LOCK_LOCY) + if (protectflag & OB_LOCK_LOCY) *drawflags &= ~MAN_TRANS_Y; - if(protectflag & OB_LOCK_LOCZ) + if (protectflag & OB_LOCK_LOCZ) *drawflags &= ~MAN_TRANS_Z; - if(protectflag & OB_LOCK_ROTX) + if (protectflag & OB_LOCK_ROTX) *drawflags &= ~MAN_ROT_X; - if(protectflag & OB_LOCK_ROTY) + if (protectflag & OB_LOCK_ROTY) *drawflags &= ~MAN_ROT_Y; - if(protectflag & OB_LOCK_ROTZ) + if (protectflag & OB_LOCK_ROTZ) *drawflags &= ~MAN_ROT_Z; - if(protectflag & OB_LOCK_SCALEX) + if (protectflag & OB_LOCK_SCALEX) *drawflags &= ~MAN_SCALE_X; - if(protectflag & OB_LOCK_SCALEY) + if (protectflag & OB_LOCK_SCALEY) *drawflags &= ~MAN_SCALE_Y; - if(protectflag & OB_LOCK_SCALEZ) + if (protectflag & OB_LOCK_SCALEZ) *drawflags &= ~MAN_SCALE_Z; } @@ -147,7 +147,7 @@ static void stats_pose(Scene *scene, RegionView3D *rv3d, bPoseChannel *pchan) { Bone *bone= pchan->bone; - if(bone) { + if (bone) { if (bone->flag & BONE_TRANSFORM) { calc_tw_center(scene, pchan->pose_head); protectflag_to_drawflags(pchan->protectflag, &rv3d->twdrawflag); @@ -205,9 +205,9 @@ int gimbal_axis(Object *ob, float gmat[][3]) if (ob->mode & OB_MODE_POSE) { bPoseChannel *pchan= get_active_posechannel(ob); - if(pchan) { + if (pchan) { float mat[3][3], tmat[3][3], obmat[3][3]; - if(test_rotmode_euler(pchan->rotmode)) { + if (test_rotmode_euler(pchan->rotmode)) { eulO_to_gimbal_axis(mat, pchan->eul, pchan->rotmode); } else if (pchan->rotmode == ROT_MODE_AXISANGLE) { @@ -242,10 +242,10 @@ int gimbal_axis(Object *ob, float gmat[][3]) } } else { - if(test_rotmode_euler(ob->rotmode)) { + if (test_rotmode_euler(ob->rotmode)) { eulO_to_gimbal_axis(gmat, ob->rot, ob->rotmode); } - else if(ob->rotmode == ROT_MODE_AXISANGLE) { + else if (ob->rotmode == ROT_MODE_AXISANGLE) { axis_angle_to_gimbal_axis(gmat, ob->rotAxis, ob->rotAngle); } else { /* quat */ @@ -290,11 +290,11 @@ int calc_manipulator_stats(const bContext *C) INIT_MINMAX(scene->twmin, scene->twmax); zero_v3(scene->twcent); - if(obedit) { + if (obedit) { ob= obedit; - if((ob->lay & v3d->lay)==0) return 0; + if ((ob->lay & v3d->lay)==0) return 0; - if(obedit->type==OB_MESH) { + if (obedit->type==OB_MESH) { BMEditMesh *em = BMEdit_FromObject(obedit); BMEditSelection ese; float vec[3]= {0,0,0}; @@ -314,24 +314,24 @@ int calc_manipulator_stats(const bContext *C) /* do vertices/edges/faces for center depending on selection * mode. note we can't use just vertex selection flag because * it is not flush down on changes */ - if(ts->selectmode & SCE_SELECT_VERTEX) { + if (ts->selectmode & SCE_SELECT_VERTEX) { BM_ITER(eve, &iter, bm, BM_VERTS_OF_MESH, NULL) { - if(!BM_elem_flag_test(eve, BM_ELEM_HIDDEN)) { - if(BM_elem_flag_test(eve, BM_ELEM_SELECT)) { + if (!BM_elem_flag_test(eve, BM_ELEM_HIDDEN)) { + if (BM_elem_flag_test(eve, BM_ELEM_SELECT)) { totsel++; calc_tw_center(scene, eve->co); } } } } - else if(ts->selectmode & SCE_SELECT_EDGE) { + else if (ts->selectmode & SCE_SELECT_EDGE) { BMIter itersub; BMEdge *eed; BM_ITER(eve, &iter, bm, BM_VERTS_OF_MESH, NULL) { - if(!BM_elem_flag_test(eve, BM_ELEM_HIDDEN)) { + if (!BM_elem_flag_test(eve, BM_ELEM_HIDDEN)) { /* check the vertex has a selected edge, only add it once */ BM_ITER(eed, &itersub, bm, BM_EDGES_OF_VERT, eve) { - if(BM_elem_flag_test(eed, BM_ELEM_SELECT)) { + if (BM_elem_flag_test(eed, BM_ELEM_SELECT)) { totsel++; calc_tw_center(scene, eve->co); break; @@ -344,10 +344,10 @@ int calc_manipulator_stats(const bContext *C) BMIter itersub; BMFace *efa; BM_ITER(eve, &iter, bm, BM_VERTS_OF_MESH, NULL) { - if(!BM_elem_flag_test(eve, BM_ELEM_HIDDEN)) { + if (!BM_elem_flag_test(eve, BM_ELEM_HIDDEN)) { /* check the vertex has a selected face, only add it once */ BM_ITER(efa, &itersub, bm, BM_FACES_OF_VERT, eve) { - if(BM_elem_flag_test(efa, BM_ELEM_SELECT)) { + if (BM_elem_flag_test(efa, BM_ELEM_SELECT)) { totsel++; calc_tw_center(scene, eve->co); break; @@ -362,7 +362,7 @@ int calc_manipulator_stats(const bContext *C) bArmature *arm= obedit->data; EditBone *ebo; for (ebo= arm->edbo->first; ebo; ebo=ebo->next) { - if(EBONE_VISIBLE(arm, ebo)) { + if (EBONE_VISIBLE(arm, ebo)) { if (ebo->flag & BONE_TIPSEL) { calc_tw_center(scene, ebo->tail); totsel++; @@ -392,11 +392,11 @@ int calc_manipulator_stats(const bContext *C) ListBase *nurbs= curve_editnurbs(cu); nu= nurbs->first; - while(nu) { - if(nu->type == CU_BEZIER) { + while (nu) { + if (nu->type == CU_BEZIER) { bezt= nu->bezt; a= nu->pntsu; - while(a--) { + while (a--) { /* exceptions * if handles are hidden then only check the center points. * If the center knot is selected then only use this as the center point. @@ -412,11 +412,11 @@ int calc_manipulator_stats(const bContext *C) totsel++; } else { - if(bezt->f1) { + if (bezt->f1) { calc_tw_center(scene, bezt->vec[0]); totsel++; } - if(bezt->f3) { + if (bezt->f3) { calc_tw_center(scene, bezt->vec[2]); totsel++; } @@ -427,8 +427,8 @@ int calc_manipulator_stats(const bContext *C) else { bp= nu->bp; a= nu->pntsu*nu->pntsv; - while(a--) { - if(bp->f1 & SELECT) { + while (a--) { + if (bp->f1 & SELECT) { calc_tw_center(scene, bp->vec); totsel++; } @@ -439,13 +439,13 @@ int calc_manipulator_stats(const bContext *C) } } } - else if(obedit->type==OB_MBALL) { + else if (obedit->type==OB_MBALL) { MetaBall *mb = (MetaBall*)obedit->data; MetaElem *ml /* , *ml_sel=NULL */ /* UNUSED */; ml= mb->editelems->first; - while(ml) { - if(ml->flag & SELECT) { + while (ml) { + if (ml->flag & SELECT) { calc_tw_center(scene, &ml->x); /* ml_sel = ml; */ /* UNUSED */ totsel++; @@ -453,15 +453,15 @@ int calc_manipulator_stats(const bContext *C) ml= ml->next; } } - else if(obedit->type==OB_LATTICE) { + else if (obedit->type==OB_LATTICE) { BPoint *bp; Lattice *lt= obedit->data; bp= lt->editlatt->latt->def; a= lt->editlatt->latt->pntsu*lt->editlatt->latt->pntsv*lt->editlatt->latt->pntsw; - while(a--) { - if(bp->f1 & SELECT) { + while (a--) { + if (bp->f1 & SELECT) { calc_tw_center(scene, bp->vec); totsel++; } @@ -470,24 +470,24 @@ int calc_manipulator_stats(const bContext *C) } /* selection center */ - if(totsel) { + if (totsel) { mul_v3_fl(scene->twcent, 1.0f/(float)totsel); // centroid! mul_m4_v3(obedit->obmat, scene->twcent); mul_m4_v3(obedit->obmat, scene->twmin); mul_m4_v3(obedit->obmat, scene->twmax); } } - else if(ob && (ob->mode & OB_MODE_POSE)) { + else if (ob && (ob->mode & OB_MODE_POSE)) { bPoseChannel *pchan; int mode = TFM_ROTATION; // mislead counting bones... bah. We don't know the manipulator mode, could be mixed - if((ob->lay & v3d->lay)==0) return 0; + if ((ob->lay & v3d->lay)==0) return 0; totsel = count_set_pose_transflags(&mode, 0, ob); - if(totsel) { + if (totsel) { /* use channels to get stats */ - for(pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) { + for (pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) { stats_pose(scene, rv3d, pchan); } @@ -497,22 +497,22 @@ int calc_manipulator_stats(const bContext *C) mul_m4_v3(ob->obmat, scene->twmax); } } - else if(ob && (ob->mode & OB_MODE_ALL_PAINT)) { + else if (ob && (ob->mode & OB_MODE_ALL_PAINT)) { ; } - else if(ob && ob->mode & OB_MODE_PARTICLE_EDIT) { + else if (ob && ob->mode & OB_MODE_PARTICLE_EDIT) { PTCacheEdit *edit= PE_get_current(scene, ob); PTCacheEditPoint *point; PTCacheEditKey *ek; int k; - if(edit) { + if (edit) { point = edit->points; - for(a=0; atotpoint; a++,point++) { - if(point->flag & PEP_HIDE) continue; + for (a=0; atotpoint; a++,point++) { + if (point->flag & PEP_HIDE) continue; - for(k=0, ek=point->keys; ktotkey; k++, ek++) { - if(ek->flag & PEK_SELECT) { + for (k=0, ek=point->keys; ktotkey; k++, ek++) { + if (ek->flag & PEK_SELECT) { calc_tw_center(scene, ek->flag & PEK_USE_WCO ? ek->world_co : ek->co); totsel++; } @@ -520,7 +520,7 @@ int calc_manipulator_stats(const bContext *C) } /* selection center */ - if(totsel) + if (totsel) mul_v3_fl(scene->twcent, 1.0f/(float)totsel); // centroid! } } @@ -528,11 +528,11 @@ int calc_manipulator_stats(const bContext *C) /* we need the one selected object, if its not active */ ob= OBACT; - if(ob && !(ob->flag & SELECT)) ob= NULL; + if (ob && !(ob->flag & SELECT)) ob= NULL; - for(base= scene->base.first; base; base= base->next) { + for (base= scene->base.first; base; base= base->next) { if TESTBASELIB(v3d, base) { - if(ob==NULL) + if (ob==NULL) ob= base->object; calc_tw_center(scene, base->object->obmat[3]); protectflag_to_drawflags(base->object->protectflag, &rv3d->twdrawflag); @@ -541,13 +541,13 @@ int calc_manipulator_stats(const bContext *C) } /* selection center */ - if(totsel) { + if (totsel) { mul_v3_fl(scene->twcent, 1.0f/(float)totsel); // centroid! } } /* global, local or normal orientation? */ - if(ob && totsel) { + if (ob && totsel) { switch(v3d->twmode) { @@ -564,7 +564,7 @@ int calc_manipulator_stats(const bContext *C) /* if not gimbal, fall through to normal */ } case V3D_MANIP_NORMAL: - if(obedit || ob->mode & OB_MODE_POSE) { + if (obedit || ob->mode & OB_MODE_POSE) { float mat[3][3]; ED_getTransformOrientationMatrix(C, mat, (v3d->around == V3D_ACTIVE)); copy_m4_m3(rv3d->twmat, mat); @@ -664,7 +664,7 @@ static void partial_doughnut(float radring, float radhole, int start, int end, i float ring_delta, side_delta; int i, j, docaps= 1; - if(start==0 && end==nrings) docaps= 0; + if (start==0 && end==nrings) docaps= 0; ring_delta= 2.0f*(float)M_PI/(float)nrings; side_delta= 2.0f*(float)M_PI/(float)nsides; @@ -673,15 +673,15 @@ static void partial_doughnut(float radring, float radhole, int start, int end, i cos_theta= (float)cos(theta); sin_theta= (float)sin(theta); - for(i= nrings - 1; i >= 0; i--) { + for (i= nrings - 1; i >= 0; i--) { theta1= theta + ring_delta; cos_theta1= (float)cos(theta1); sin_theta1= (float)sin(theta1); - if(docaps && i==start) { // cap + if (docaps && i==start) { // cap glBegin(GL_POLYGON); phi= 0.0; - for(j= nsides; j >= 0; j--) { + for (j= nsides; j >= 0; j--) { float cos_phi, sin_phi, dist; phi += side_delta; @@ -693,10 +693,10 @@ static void partial_doughnut(float radring, float radhole, int start, int end, i } glEnd(); } - if(i>=start && i<=end) { + if (i>=start && i<=end) { glBegin(GL_QUAD_STRIP); phi= 0.0; - for(j= nsides; j >= 0; j--) { + for (j= nsides; j >= 0; j--) { float cos_phi, sin_phi, dist; phi += side_delta; @@ -710,10 +710,10 @@ static void partial_doughnut(float radring, float radhole, int start, int end, i glEnd(); } - if(docaps && i==end) { // cap + if (docaps && i==end) { // cap glBegin(GL_POLYGON); phi= 0.0; - for(j= nsides; j >= 0; j--) { + for (j= nsides; j >= 0; j--) { float cos_phi, sin_phi, dist; phi -= side_delta; @@ -754,22 +754,22 @@ static void manipulator_setcolor(View3D *v3d, char axis, int colcode, unsigned c unsigned char col[4]= {0}; col[3]= alpha; - if(colcode==MAN_GHOST) { + if (colcode==MAN_GHOST) { col[3]= 70; } - else if(colcode==MAN_MOVECOL) { + else if (colcode==MAN_MOVECOL) { UI_GetThemeColor3ubv(TH_TRANSFORM, col); } else { switch(axis) { case 'C': UI_GetThemeColor3ubv(TH_TRANSFORM, col); - if(v3d->twmode == V3D_MANIP_LOCAL) { + if (v3d->twmode == V3D_MANIP_LOCAL) { col[0]= col[0]>200?255:col[0]+55; col[1]= col[1]>200?255:col[1]+55; col[2]= col[2]>200?255:col[2]+55; } - else if(v3d->twmode == V3D_MANIP_NORMAL) { + else if (v3d->twmode == V3D_MANIP_NORMAL) { col[0]= col[0]<55?0:col[0]-55; col[1]= col[1]<55?0:col[1]-55; col[2]= col[2]<55?0:col[2]-55; @@ -799,27 +799,27 @@ static void draw_manipulator_axes(View3D *v3d, RegionView3D *rv3d, int colcode, { /* axes */ - if(flagx) { + if (flagx) { manipulator_setcolor(v3d, 'X', colcode, axisBlendAngle(rv3d->twangle[0])); - if(flagx & MAN_SCALE_X) glLoadName(MAN_SCALE_X); - else if(flagx & MAN_TRANS_X) glLoadName(MAN_TRANS_X); + if (flagx & MAN_SCALE_X) glLoadName(MAN_SCALE_X); + else if (flagx & MAN_TRANS_X) glLoadName(MAN_TRANS_X); glBegin(GL_LINES); glVertex3f(0.2f, 0.0f, 0.0f); glVertex3f(1.0f, 0.0f, 0.0f); glEnd(); } - if(flagy) { - if(flagy & MAN_SCALE_Y) glLoadName(MAN_SCALE_Y); - else if(flagy & MAN_TRANS_Y) glLoadName(MAN_TRANS_Y); + if (flagy) { + if (flagy & MAN_SCALE_Y) glLoadName(MAN_SCALE_Y); + else if (flagy & MAN_TRANS_Y) glLoadName(MAN_TRANS_Y); manipulator_setcolor(v3d, 'Y', colcode, axisBlendAngle(rv3d->twangle[1])); glBegin(GL_LINES); glVertex3f(0.0f, 0.2f, 0.0f); glVertex3f(0.0f, 1.0f, 0.0f); glEnd(); } - if(flagz) { - if(flagz & MAN_SCALE_Z) glLoadName(MAN_SCALE_Z); - else if(flagz & MAN_TRANS_Z) glLoadName(MAN_TRANS_Z); + if (flagz) { + if (flagz & MAN_SCALE_Z) glLoadName(MAN_SCALE_Z); + else if (flagz & MAN_TRANS_Z) glLoadName(MAN_TRANS_Z); manipulator_setcolor(v3d, 'Z', colcode, axisBlendAngle(rv3d->twangle[2])); glBegin(GL_LINES); glVertex3f(0.0f, 0.0f, 0.2f); @@ -859,11 +859,11 @@ static void draw_manipulator_rotate(View3D *v3d, RegionView3D *rv3d, int moving, int colcode; int ortho; - if(moving) colcode= MAN_MOVECOL; + if (moving) colcode= MAN_MOVECOL; else colcode= MAN_RGB; /* when called while moving in mixed mode, do not draw when... */ - if((drawflags & MAN_ROT_C)==0) return; + if ((drawflags & MAN_ROT_C)==0) return; /* Init stuff */ glDisable(GL_DEPTH_TEST); @@ -877,7 +877,7 @@ static void draw_manipulator_rotate(View3D *v3d, RegionView3D *rv3d, int moving, glPushMatrix(); glTranslatef(rv3d->twmat[3][0], rv3d->twmat[3][1], rv3d->twmat[3][2]); - if(arcs) { + if (arcs) { /* clipplane makes nice handles, calc here because of multmatrix but with translate! */ copy_v3db_v3fl(plane, rv3d->viewinv[2]); plane[3]= -0.02f*size; // clip just a bit more @@ -887,28 +887,28 @@ static void draw_manipulator_rotate(View3D *v3d, RegionView3D *rv3d, int moving, glRotatef( -360.0f*saacos(rv3d->viewquat[0])/(float)M_PI, rv3d->viewquat[1], rv3d->viewquat[2], rv3d->viewquat[3]); /* Screen aligned help circle */ - if(arcs) { - if((G.f & G_PICKSEL)==0) { + if (arcs) { + if ((G.f & G_PICKSEL)==0) { UI_ThemeColorShade(TH_BACK, -30); drawcircball(GL_LINE_LOOP, unitmat[3], size, unitmat); } } /* Screen aligned trackball rot circle */ - if(drawflags & MAN_ROT_T) { - if(G.f & G_PICKSEL) glLoadName(MAN_ROT_T); + if (drawflags & MAN_ROT_T) { + if (G.f & G_PICKSEL) glLoadName(MAN_ROT_T); UI_ThemeColor(TH_TRANSFORM); drawcircball(GL_LINE_LOOP, unitmat[3], 0.2f*size, unitmat); } /* Screen aligned view rot circle */ - if(drawflags & MAN_ROT_V) { - if(G.f & G_PICKSEL) glLoadName(MAN_ROT_V); + if (drawflags & MAN_ROT_V) { + if (G.f & G_PICKSEL) glLoadName(MAN_ROT_V); UI_ThemeColor(TH_TRANSFORM); drawcircball(GL_LINE_LOOP, unitmat[3], 1.2f*size, unitmat); - if(moving) { + if (moving) { float vec[3]; vec[0]= 0; // XXX (float)(t->imval[0] - t->center2d[0]); vec[1]= 0; // XXX (float)(t->imval[1] - t->center2d[1]); @@ -927,7 +927,7 @@ static void draw_manipulator_rotate(View3D *v3d, RegionView3D *rv3d, int moving, ortho = is_orthogonal_m4(rv3d->twmat); /* apply the transform delta */ - if(moving) { + if (moving) { copy_m4_m4(matt, rv3d->twmat); // to copy the parts outside of [3][3] // XXX mul_m4_m3m4(matt, t->mat, rv3d->twmat); if (ortho) { @@ -943,11 +943,11 @@ static void draw_manipulator_rotate(View3D *v3d, RegionView3D *rv3d, int moving, } /* axes */ - if(arcs==0) { - if(!(G.f & G_PICKSEL)) { - if( (combo & V3D_MANIP_SCALE)==0) { + if (arcs==0) { + if (!(G.f & G_PICKSEL)) { + if ( (combo & V3D_MANIP_SCALE)==0) { /* axis */ - if( (drawflags & MAN_ROT_X) || (moving && (drawflags & MAN_ROT_Z)) ) { + if ( (drawflags & MAN_ROT_X) || (moving && (drawflags & MAN_ROT_Z)) ) { preOrthoFront(ortho, rv3d->twmat, 2); manipulator_setcolor(v3d, 'X', colcode, 255); glBegin(GL_LINES); @@ -956,7 +956,7 @@ static void draw_manipulator_rotate(View3D *v3d, RegionView3D *rv3d, int moving, glEnd(); postOrtho(ortho); } - if( (drawflags & MAN_ROT_Y) || (moving && (drawflags & MAN_ROT_X)) ) { + if ( (drawflags & MAN_ROT_Y) || (moving && (drawflags & MAN_ROT_X)) ) { preOrthoFront(ortho, rv3d->twmat, 0); manipulator_setcolor(v3d, 'Y', colcode, 255); glBegin(GL_LINES); @@ -965,7 +965,7 @@ static void draw_manipulator_rotate(View3D *v3d, RegionView3D *rv3d, int moving, glEnd(); postOrtho(ortho); } - if( (drawflags & MAN_ROT_Z) || (moving && (drawflags & MAN_ROT_Y)) ) { + if ( (drawflags & MAN_ROT_Z) || (moving && (drawflags & MAN_ROT_Y)) ) { preOrthoFront(ortho, rv3d->twmat, 1); manipulator_setcolor(v3d, 'Z', colcode, 255); glBegin(GL_LINES); @@ -978,20 +978,20 @@ static void draw_manipulator_rotate(View3D *v3d, RegionView3D *rv3d, int moving, } } - if(arcs==0 && moving) { + if (arcs==0 && moving) { /* Z circle */ - if(drawflags & MAN_ROT_Z) { + if (drawflags & MAN_ROT_Z) { preOrthoFront(ortho, matt, 2); - if(G.f & G_PICKSEL) glLoadName(MAN_ROT_Z); + if (G.f & G_PICKSEL) glLoadName(MAN_ROT_Z); manipulator_setcolor(v3d, 'Z', colcode, 255); drawcircball(GL_LINE_LOOP, unitmat[3], 1.0, unitmat); postOrtho(ortho); } /* X circle */ - if(drawflags & MAN_ROT_X) { + if (drawflags & MAN_ROT_X) { preOrthoFront(ortho, matt, 0); - if(G.f & G_PICKSEL) glLoadName(MAN_ROT_X); + if (G.f & G_PICKSEL) glLoadName(MAN_ROT_X); glRotatef(90.0, 0.0, 1.0, 0.0); manipulator_setcolor(v3d, 'X', colcode, 255); drawcircball(GL_LINE_LOOP, unitmat[3], 1.0, unitmat); @@ -999,9 +999,9 @@ static void draw_manipulator_rotate(View3D *v3d, RegionView3D *rv3d, int moving, postOrtho(ortho); } /* Y circle */ - if(drawflags & MAN_ROT_Y) { + if (drawflags & MAN_ROT_Y) { preOrthoFront(ortho, matt, 1); - if(G.f & G_PICKSEL) glLoadName(MAN_ROT_Y); + if (G.f & G_PICKSEL) glLoadName(MAN_ROT_Y); glRotatef(-90.0, 1.0, 0.0, 0.0); manipulator_setcolor(v3d, 'Y', colcode, 255); drawcircball(GL_LINE_LOOP, unitmat[3], 1.0, unitmat); @@ -1009,24 +1009,24 @@ static void draw_manipulator_rotate(View3D *v3d, RegionView3D *rv3d, int moving, postOrtho(ortho); } - if(arcs) glDisable(GL_CLIP_PLANE0); + if (arcs) glDisable(GL_CLIP_PLANE0); } // donut arcs - if(arcs) { + if (arcs) { glEnable(GL_CLIP_PLANE0); /* Z circle */ - if(drawflags & MAN_ROT_Z) { + if (drawflags & MAN_ROT_Z) { preOrthoFront(ortho, rv3d->twmat, 2); - if(G.f & G_PICKSEL) glLoadName(MAN_ROT_Z); + if (G.f & G_PICKSEL) glLoadName(MAN_ROT_Z); manipulator_setcolor(v3d, 'Z', colcode, 255); partial_doughnut(cusize/4.0f, 1.0f, 0, 48, 8, 48); postOrtho(ortho); } /* X circle */ - if(drawflags & MAN_ROT_X) { + if (drawflags & MAN_ROT_X) { preOrthoFront(ortho, rv3d->twmat, 0); - if(G.f & G_PICKSEL) glLoadName(MAN_ROT_X); + if (G.f & G_PICKSEL) glLoadName(MAN_ROT_X); glRotatef(90.0, 0.0, 1.0, 0.0); manipulator_setcolor(v3d, 'X', colcode, 255); partial_doughnut(cusize/4.0f, 1.0f, 0, 48, 8, 48); @@ -1034,9 +1034,9 @@ static void draw_manipulator_rotate(View3D *v3d, RegionView3D *rv3d, int moving, postOrtho(ortho); } /* Y circle */ - if(drawflags & MAN_ROT_Y) { + if (drawflags & MAN_ROT_Y) { preOrthoFront(ortho, rv3d->twmat, 1); - if(G.f & G_PICKSEL) glLoadName(MAN_ROT_Y); + if (G.f & G_PICKSEL) glLoadName(MAN_ROT_Y); glRotatef(-90.0, 1.0, 0.0, 0.0); manipulator_setcolor(v3d, 'Y', colcode, 255); partial_doughnut(cusize/4.0f, 1.0f, 0, 48, 8, 48); @@ -1047,13 +1047,13 @@ static void draw_manipulator_rotate(View3D *v3d, RegionView3D *rv3d, int moving, glDisable(GL_CLIP_PLANE0); } - if(arcs==0) { + if (arcs==0) { /* Z handle on X axis */ - if(drawflags & MAN_ROT_Z) { + if (drawflags & MAN_ROT_Z) { preOrthoFront(ortho, rv3d->twmat, 2); glPushMatrix(); - if(G.f & G_PICKSEL) glLoadName(MAN_ROT_Z); + if (G.f & G_PICKSEL) glLoadName(MAN_ROT_Z); manipulator_setcolor(v3d, 'Z', colcode, 255); partial_doughnut(0.7f*cusize, 1.0f, 31, 33, 8, 64); @@ -1063,10 +1063,10 @@ static void draw_manipulator_rotate(View3D *v3d, RegionView3D *rv3d, int moving, } /* Y handle on X axis */ - if(drawflags & MAN_ROT_Y) { + if (drawflags & MAN_ROT_Y) { preOrthoFront(ortho, rv3d->twmat, 1); glPushMatrix(); - if(G.f & G_PICKSEL) glLoadName(MAN_ROT_Y); + if (G.f & G_PICKSEL) glLoadName(MAN_ROT_Y); manipulator_setcolor(v3d, 'Y', colcode, 255); glRotatef(90.0, 1.0, 0.0, 0.0); @@ -1078,10 +1078,10 @@ static void draw_manipulator_rotate(View3D *v3d, RegionView3D *rv3d, int moving, } /* X handle on Z axis */ - if(drawflags & MAN_ROT_X) { + if (drawflags & MAN_ROT_X) { preOrthoFront(ortho, rv3d->twmat, 0); glPushMatrix(); - if(G.f & G_PICKSEL) glLoadName(MAN_ROT_X); + if (G.f & G_PICKSEL) glLoadName(MAN_ROT_X); manipulator_setcolor(v3d, 'X', colcode, 255); glRotatef(-90.0, 0.0, 1.0, 0.0); @@ -1097,7 +1097,7 @@ static void draw_manipulator_rotate(View3D *v3d, RegionView3D *rv3d, int moving, /* restore */ glLoadMatrixf(rv3d->viewmat); gluDeleteQuadric(qobj); - if(v3d->zbuf) glEnable(GL_DEPTH_TEST); + if (v3d->zbuf) glEnable(GL_DEPTH_TEST); } @@ -1168,17 +1168,17 @@ static void draw_manipulator_scale(View3D *v3d, RegionView3D *rv3d, int moving, float cusize= cywid*0.75f, dz; /* when called while moving in mixed mode, do not draw when... */ - if((drawflags & MAN_SCALE_C)==0) return; + if ((drawflags & MAN_SCALE_C)==0) return; glDisable(GL_DEPTH_TEST); /* not in combo mode */ - if( (combo & (V3D_MANIP_TRANSLATE|V3D_MANIP_ROTATE))==0) { + if ( (combo & (V3D_MANIP_TRANSLATE|V3D_MANIP_ROTATE))==0) { float size, unitmat[4][4]; int shift= 0; // XXX /* center circle, do not add to selection when shift is pressed (planar constraint) */ - if( (G.f & G_PICKSEL) && shift==0) glLoadName(MAN_SCALE_C); + if ( (G.f & G_PICKSEL) && shift==0) glLoadName(MAN_SCALE_C); manipulator_setcolor(v3d, 'C', colcode, 255); glPushMatrix(); @@ -1191,7 +1191,7 @@ static void draw_manipulator_scale(View3D *v3d, RegionView3D *rv3d, int moving, } else dz= 1.0f-4.0f*cusize; - if(moving) { + if (moving) { float matt[4][4]; copy_m4_m4(matt, rv3d->twmat); // to copy the parts outside of [3][3] @@ -1211,31 +1211,31 @@ static void draw_manipulator_scale(View3D *v3d, RegionView3D *rv3d, int moving, /* Z cube */ glTranslatef(0.0, 0.0, dz); - if(drawflags & MAN_SCALE_Z) { - if(G.f & G_PICKSEL) glLoadName(MAN_SCALE_Z); + if (drawflags & MAN_SCALE_Z) { + if (G.f & G_PICKSEL) glLoadName(MAN_SCALE_Z); manipulator_setcolor(v3d, 'Z', colcode, axisBlendAngle(rv3d->twangle[2])); drawsolidcube(cusize); } /* X cube */ glTranslatef(dz, 0.0, -dz); - if(drawflags & MAN_SCALE_X) { - if(G.f & G_PICKSEL) glLoadName(MAN_SCALE_X); + if (drawflags & MAN_SCALE_X) { + if (G.f & G_PICKSEL) glLoadName(MAN_SCALE_X); manipulator_setcolor(v3d, 'X', colcode, axisBlendAngle(rv3d->twangle[0])); drawsolidcube(cusize); } /* Y cube */ glTranslatef(-dz, dz, 0.0); - if(drawflags & MAN_SCALE_Y) { - if(G.f & G_PICKSEL) glLoadName(MAN_SCALE_Y); + if (drawflags & MAN_SCALE_Y) { + if (G.f & G_PICKSEL) glLoadName(MAN_SCALE_Y); manipulator_setcolor(v3d, 'Y', colcode, axisBlendAngle(rv3d->twangle[1])); drawsolidcube(cusize); } /* if shiftkey, center point as last, for selectbuffer order */ - if(G.f & G_PICKSEL) { + if (G.f & G_PICKSEL) { int shift= 0; // XXX - if(shift) { + if (shift) { glTranslatef(0.0, -dz, 0.0); glLoadName(MAN_SCALE_C); glBegin(GL_POINTS); @@ -1247,7 +1247,7 @@ static void draw_manipulator_scale(View3D *v3d, RegionView3D *rv3d, int moving, /* restore */ glLoadMatrixf(rv3d->viewmat); - if(v3d->zbuf) glEnable(GL_DEPTH_TEST); + if (v3d->zbuf) glEnable(GL_DEPTH_TEST); glFrontFace(GL_CCW); } @@ -1287,7 +1287,7 @@ static void draw_manipulator_translate(View3D *v3d, RegionView3D *rv3d, int UNUS int shift= 0; // XXX /* when called while moving in mixed mode, do not draw when... */ - if((drawflags & MAN_TRANS_C)==0) return; + if ((drawflags & MAN_TRANS_C)==0) return; // XXX if(moving) glTranslatef(t->vec[0], t->vec[1], t->vec[2]); glDisable(GL_DEPTH_TEST); @@ -1296,7 +1296,7 @@ static void draw_manipulator_translate(View3D *v3d, RegionView3D *rv3d, int UNUS gluQuadricDrawStyle(qobj, GLU_FILL); /* center circle, do not add to selection when shift is pressed (planar constraint) */ - if( (G.f & G_PICKSEL) && shift==0) glLoadName(MAN_TRANS_C); + if ( (G.f & G_PICKSEL) && shift==0) glLoadName(MAN_TRANS_C); manipulator_setcolor(v3d, 'C', colcode, 255); glPushMatrix(); @@ -1312,26 +1312,26 @@ static void draw_manipulator_translate(View3D *v3d, RegionView3D *rv3d, int UNUS glLoadName(-1); // translate drawn as last, only axis when no combo with scale, or for ghosting - if((combo & V3D_MANIP_SCALE)==0 || colcode==MAN_GHOST) + if ((combo & V3D_MANIP_SCALE)==0 || colcode==MAN_GHOST) draw_manipulator_axes(v3d, rv3d, colcode, drawflags & MAN_TRANS_X, drawflags & MAN_TRANS_Y, drawflags & MAN_TRANS_Z); /* offset in combo mode, for rotate a bit more */ - if(combo & (V3D_MANIP_ROTATE)) dz= 1.0f+2.0f*cylen; - else if(combo & (V3D_MANIP_SCALE)) dz= 1.0f+0.5f*cylen; + if (combo & (V3D_MANIP_ROTATE)) dz= 1.0f+2.0f*cylen; + else if (combo & (V3D_MANIP_SCALE)) dz= 1.0f+0.5f*cylen; else dz= 1.0f; /* Z Cone */ glTranslatef(0.0, 0.0, dz); - if(drawflags & MAN_TRANS_Z) { - if(G.f & G_PICKSEL) glLoadName(MAN_TRANS_Z); + if (drawflags & MAN_TRANS_Z) { + if (G.f & G_PICKSEL) glLoadName(MAN_TRANS_Z); manipulator_setcolor(v3d, 'Z', colcode, axisBlendAngle(rv3d->twangle[2])); draw_cone(qobj, cylen, cywid); } /* X Cone */ glTranslatef(dz, 0.0, -dz); - if(drawflags & MAN_TRANS_X) { - if(G.f & G_PICKSEL) glLoadName(MAN_TRANS_X); + if (drawflags & MAN_TRANS_X) { + if (G.f & G_PICKSEL) glLoadName(MAN_TRANS_X); glRotatef(90.0, 0.0, 1.0, 0.0); manipulator_setcolor(v3d, 'X', colcode, axisBlendAngle(rv3d->twangle[0])); draw_cone(qobj, cylen, cywid); @@ -1339,8 +1339,8 @@ static void draw_manipulator_translate(View3D *v3d, RegionView3D *rv3d, int UNUS } /* Y Cone */ glTranslatef(-dz, dz, 0.0); - if(drawflags & MAN_TRANS_Y) { - if(G.f & G_PICKSEL) glLoadName(MAN_TRANS_Y); + if (drawflags & MAN_TRANS_Y) { + if (G.f & G_PICKSEL) glLoadName(MAN_TRANS_Y); glRotatef(-90.0, 1.0, 0.0, 0.0); manipulator_setcolor(v3d, 'Y', colcode, axisBlendAngle(rv3d->twangle[1])); draw_cone(qobj, cylen, cywid); @@ -1349,7 +1349,7 @@ static void draw_manipulator_translate(View3D *v3d, RegionView3D *rv3d, int UNUS gluDeleteQuadric(qobj); glLoadMatrixf(rv3d->viewmat); - if(v3d->zbuf) glEnable(GL_DEPTH_TEST); + if (v3d->zbuf) glEnable(GL_DEPTH_TEST); } @@ -1361,7 +1361,7 @@ static void draw_manipulator_rotate_cyl(View3D *v3d, RegionView3D *rv3d, int mov float cywid= 0.25f*cylen; /* when called while moving in mixed mode, do not draw when... */ - if((drawflags & MAN_ROT_C)==0) return; + if ((drawflags & MAN_ROT_C)==0) return; /* prepare for screen aligned draw */ glPushMatrix(); @@ -1372,14 +1372,14 @@ static void draw_manipulator_rotate_cyl(View3D *v3d, RegionView3D *rv3d, int mov qobj= gluNewQuadric(); /* Screen aligned view rot circle */ - if(drawflags & MAN_ROT_V) { + if (drawflags & MAN_ROT_V) { float unitmat[4][4]= MAT4_UNITY; - if(G.f & G_PICKSEL) glLoadName(MAN_ROT_V); + if (G.f & G_PICKSEL) glLoadName(MAN_ROT_V); UI_ThemeColor(TH_TRANSFORM); drawcircball(GL_LINE_LOOP, unitmat[3], 1.2f*size, unitmat); - if(moving) { + if (moving) { float vec[3]; vec[0]= 0; // XXX (float)(t->imval[0] - t->center2d[0]); vec[1]= 0; // XXX (float)(t->imval[1] - t->center2d[1]); @@ -1395,7 +1395,7 @@ static void draw_manipulator_rotate_cyl(View3D *v3d, RegionView3D *rv3d, int mov glPopMatrix(); /* apply the transform delta */ - if(moving) { + if (moving) { float matt[4][4]; copy_m4_m4(matt, rv3d->twmat); // to copy the parts outside of [3][3] // XXX if (t->flag & T_USES_MANIPULATOR) { @@ -1410,10 +1410,10 @@ static void draw_manipulator_rotate_cyl(View3D *v3d, RegionView3D *rv3d, int mov glFrontFace(is_negative_m4(rv3d->twmat) ? GL_CW:GL_CCW); /* axis */ - if( (G.f & G_PICKSEL)==0 ) { + if ( (G.f & G_PICKSEL)==0 ) { // only draw axis when combo didn't draw scale axes - if((combo & V3D_MANIP_SCALE)==0) + if ((combo & V3D_MANIP_SCALE)==0) draw_manipulator_axes(v3d, rv3d, colcode, drawflags & MAN_ROT_X, drawflags & MAN_ROT_Y, drawflags & MAN_ROT_Z); /* only has to be set when not in picking */ @@ -1422,15 +1422,15 @@ static void draw_manipulator_rotate_cyl(View3D *v3d, RegionView3D *rv3d, int mov /* Z cyl */ glTranslatef(0.0, 0.0, 1.0); - if(drawflags & MAN_ROT_Z) { - if(G.f & G_PICKSEL) glLoadName(MAN_ROT_Z); + if (drawflags & MAN_ROT_Z) { + if (G.f & G_PICKSEL) glLoadName(MAN_ROT_Z); manipulator_setcolor(v3d, 'Z', colcode, 255); draw_cylinder(qobj, cylen, cywid); } /* X cyl */ glTranslatef(1.0, 0.0, -1.0); - if(drawflags & MAN_ROT_X) { - if(G.f & G_PICKSEL) glLoadName(MAN_ROT_X); + if (drawflags & MAN_ROT_X) { + if (G.f & G_PICKSEL) glLoadName(MAN_ROT_X); glRotatef(90.0, 0.0, 1.0, 0.0); manipulator_setcolor(v3d, 'X', colcode, 255); draw_cylinder(qobj, cylen, cywid); @@ -1438,8 +1438,8 @@ static void draw_manipulator_rotate_cyl(View3D *v3d, RegionView3D *rv3d, int mov } /* Y cylinder */ glTranslatef(-1.0, 1.0, 0.0); - if(drawflags & MAN_ROT_Y) { - if(G.f & G_PICKSEL) glLoadName(MAN_ROT_Y); + if (drawflags & MAN_ROT_Y) { + if (G.f & G_PICKSEL) glLoadName(MAN_ROT_Y); glRotatef(-90.0, 1.0, 0.0, 0.0); manipulator_setcolor(v3d, 'Y', colcode, 255); draw_cylinder(qobj, cylen, cywid); @@ -1450,7 +1450,7 @@ static void draw_manipulator_rotate_cyl(View3D *v3d, RegionView3D *rv3d, int mov gluDeleteQuadric(qobj); glLoadMatrixf(rv3d->viewmat); - if(v3d->zbuf) glEnable(GL_DEPTH_TEST); + if (v3d->zbuf) glEnable(GL_DEPTH_TEST); } @@ -1470,15 +1470,15 @@ void BIF_draw_manipulator(const bContext *C) RegionView3D *rv3d= ar->regiondata; int totsel; - if(!(v3d->twflag & V3D_USE_MANIPULATOR)) return; -// if(G.moving && (G.moving & G_TRANSFORM_MANIP)==0) return; + if (!(v3d->twflag & V3D_USE_MANIPULATOR)) return; +// if (G.moving && (G.moving & G_TRANSFORM_MANIP)==0) return; -// if(G.moving==0) { +// if (G.moving==0) { { v3d->twflag &= ~V3D_DRAW_MANIPULATOR; totsel= calc_manipulator_stats(C); - if(totsel==0) return; + if (totsel==0) return; v3d->twflag |= V3D_DRAW_MANIPULATOR; @@ -1489,9 +1489,9 @@ void BIF_draw_manipulator(const bContext *C) rv3d->twmat[3][0]= (scene->twmin[0] + scene->twmax[0])/2.0f; rv3d->twmat[3][1]= (scene->twmin[1] + scene->twmax[1])/2.0f; rv3d->twmat[3][2]= (scene->twmin[2] + scene->twmax[2])/2.0f; - if(v3d->around==V3D_ACTIVE && scene->obedit==NULL) { + if (v3d->around==V3D_ACTIVE && scene->obedit==NULL) { Object *ob= OBACT; - if(ob && !(ob->mode & OB_MODE_POSE)) + if (ob && !(ob->mode & OB_MODE_POSE)) copy_v3_v3(rv3d->twmat[3], ob->obmat[3]); } break; @@ -1510,23 +1510,23 @@ void BIF_draw_manipulator(const bContext *C) test_manipulator_axis(C); drawflags= rv3d->twdrawflag; /* set in calc_manipulator_stats */ - if(v3d->twflag & V3D_DRAW_MANIPULATOR) { + if (v3d->twflag & V3D_DRAW_MANIPULATOR) { glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); glEnable(GL_BLEND); - if(v3d->twtype & V3D_MANIP_ROTATE) { + if (v3d->twtype & V3D_MANIP_ROTATE) { - if(G.rt==3) { - if(G.moving) draw_manipulator_rotate_cyl(v3d, rv3d, 1, drawflags, v3d->twtype, MAN_MOVECOL); + if (G.rt==3) { + if (G.moving) draw_manipulator_rotate_cyl(v3d, rv3d, 1, drawflags, v3d->twtype, MAN_MOVECOL); else draw_manipulator_rotate_cyl(v3d, rv3d, 0, drawflags, v3d->twtype, MAN_RGB); } else draw_manipulator_rotate(v3d, rv3d, 0 /* G.moving*/, drawflags, v3d->twtype); } - if(v3d->twtype & V3D_MANIP_SCALE) { + if (v3d->twtype & V3D_MANIP_SCALE) { draw_manipulator_scale(v3d, rv3d, 0, drawflags, v3d->twtype, MAN_RGB); } - if(v3d->twtype & V3D_MANIP_TRANSLATE) { + if (v3d->twtype & V3D_MANIP_TRANSLATE) { draw_manipulator_translate(v3d, rv3d, 0, drawflags, v3d->twtype, MAN_RGB); } @@ -1559,13 +1559,13 @@ static int manipulator_selectbuf(ScrArea *sa, ARegion *ar, const int mval[2], fl glPushName(-2); /* do the drawing */ - if(v3d->twtype & V3D_MANIP_ROTATE) { - if(G.rt==3) draw_manipulator_rotate_cyl(v3d, rv3d, 0, MAN_ROT_C & rv3d->twdrawflag, v3d->twtype, MAN_RGB); + if (v3d->twtype & V3D_MANIP_ROTATE) { + if (G.rt==3) draw_manipulator_rotate_cyl(v3d, rv3d, 0, MAN_ROT_C & rv3d->twdrawflag, v3d->twtype, MAN_RGB); else draw_manipulator_rotate(v3d, rv3d, 0, MAN_ROT_C & rv3d->twdrawflag, v3d->twtype); } - if(v3d->twtype & V3D_MANIP_SCALE) + if (v3d->twtype & V3D_MANIP_SCALE) draw_manipulator_scale(v3d, rv3d, 0, MAN_SCALE_C & rv3d->twdrawflag, v3d->twtype, MAN_RGB); - if(v3d->twtype & V3D_MANIP_TRANSLATE) + if (v3d->twtype & V3D_MANIP_TRANSLATE) draw_manipulator_translate(v3d, rv3d, 0, MAN_TRANS_C & rv3d->twdrawflag, v3d->twtype, MAN_RGB); glPopName(); @@ -1575,29 +1575,29 @@ static int manipulator_selectbuf(ScrArea *sa, ARegion *ar, const int mval[2], fl setwinmatrixview3d(ar, v3d, NULL); mult_m4_m4m4(rv3d->persmat, rv3d->winmat, rv3d->viewmat); - if(hits==1) return buffer[3]; - else if(hits>1) { + if (hits==1) return buffer[3]; + else if (hits>1) { GLuint val, dep, mindep=0, mindeprot=0, minval=0, minvalrot=0; int a; /* we compare the hits in buffer, but value centers highest */ /* we also store the rotation hits separate (because of arcs) and return hits on other widgets if there are */ - for(a=0; ashift; - if(!(v3d->twflag & V3D_USE_MANIPULATOR)) return 0; - if(!(v3d->twflag & V3D_DRAW_MANIPULATOR)) return 0; + if (!(v3d->twflag & V3D_USE_MANIPULATOR)) return 0; + if (!(v3d->twflag & V3D_DRAW_MANIPULATOR)) return 0; /* Force orientation */ RNA_enum_set(op->ptr, "constraint_orientation", v3d->twmode); // find the hotspots first test narrow hotspot val= manipulator_selectbuf(sa, ar, event->mval, 0.5f*(float)U.tw_hotspot); - if(val) { + if (val) { // drawflags still global, for drawing call above drawflags= manipulator_selectbuf(sa, ar, event->mval, 0.2f*(float)U.tw_hotspot); - if(drawflags==0) drawflags= val; + if (drawflags==0) drawflags= val; if (drawflags & MAN_TRANS_C) { switch(drawflags) { case MAN_TRANS_C: break; case MAN_TRANS_X: - if(shift) { + if (shift) { constraint_axis[1] = 1; constraint_axis[2] = 1; } @@ -1651,7 +1651,7 @@ int BIF_do_manipulator(bContext *C, struct wmEvent *event, wmOperator *op) constraint_axis[0] = 1; break; case MAN_TRANS_Y: - if(shift) { + if (shift) { constraint_axis[0] = 1; constraint_axis[2] = 1; } @@ -1659,7 +1659,7 @@ int BIF_do_manipulator(bContext *C, struct wmEvent *event, wmOperator *op) constraint_axis[1] = 1; break; case MAN_TRANS_Z: - if(shift) { + if (shift) { constraint_axis[0] = 1; constraint_axis[1] = 1; } @@ -1674,7 +1674,7 @@ int BIF_do_manipulator(bContext *C, struct wmEvent *event, wmOperator *op) else if (drawflags & MAN_SCALE_C) { switch(drawflags) { case MAN_SCALE_X: - if(shift) { + if (shift) { constraint_axis[1] = 1; constraint_axis[2] = 1; } @@ -1682,7 +1682,7 @@ int BIF_do_manipulator(bContext *C, struct wmEvent *event, wmOperator *op) constraint_axis[0] = 1; break; case MAN_SCALE_Y: - if(shift) { + if (shift) { constraint_axis[0] = 1; constraint_axis[2] = 1; } @@ -1690,7 +1690,7 @@ int BIF_do_manipulator(bContext *C, struct wmEvent *event, wmOperator *op) constraint_axis[1] = 1; break; case MAN_SCALE_Z: - if(shift) { + if (shift) { constraint_axis[0] = 1; constraint_axis[1] = 1; } diff --git a/source/blender/editors/transform/transform_ops.c b/source/blender/editors/transform/transform_ops.c index ac6243e74ed..7c3bcb857eb 100644 --- a/source/blender/editors/transform/transform_ops.c +++ b/source/blender/editors/transform/transform_ops.c @@ -245,7 +245,7 @@ static int delete_orientation_poll(bContext *C) return 0; - if(v3d) { + if (v3d) { selected_index = (v3d->twmode - V3D_MANIP_CUSTOM); } @@ -341,7 +341,7 @@ static int transformops_data(bContext *C, wmOperator *op, wmEvent *event) G.moving = 1; /* store data */ - if(retval) { + if (retval) { op->customdata = t; } else { @@ -429,7 +429,7 @@ static int transform_invoke(bContext *C, wmOperator *op, wmEvent *event) return OPERATOR_CANCELLED; } - if(RNA_struct_property_is_set(op->ptr, "value")) { + if (RNA_struct_property_is_set(op->ptr, "value")) { return transform_exec(C, op); } else { diff --git a/source/blender/editors/transform/transform_orientations.c b/source/blender/editors/transform/transform_orientations.c index 6b68042444e..a1d4c3c990d 100644 --- a/source/blender/editors/transform/transform_orientations.c +++ b/source/blender/editors/transform/transform_orientations.c @@ -74,7 +74,7 @@ void BIF_clearTransformOrientation(bContext *C) BLI_freelistN(transform_spaces); // Need to loop over all view3d - if(v3d && v3d->twmode >= V3D_MANIP_CUSTOM) { + if (v3d && v3d->twmode >= V3D_MANIP_CUSTOM) { v3d->twmode = V3D_MANIP_GLOBAL; /* fallback to global */ } } @@ -297,7 +297,7 @@ void BIF_removeTransformOrientation(bContext *C, TransformOrientation *target) for (i = 0, ts = transform_spaces->first; ts; ts = ts->next, i++) { if (ts == target) { View3D *v3d = CTX_wm_view3d(C); - if(v3d) { + if (v3d) { int selected_index = (v3d->twmode - V3D_MANIP_CUSTOM); // Transform_fix_me NEED TO DO THIS FOR ALL VIEW3D @@ -323,7 +323,7 @@ void BIF_removeTransformOrientationIndex(bContext *C, int index) if (ts) { View3D *v3d = CTX_wm_view3d(C); - if(v3d) { + if (v3d) { int selected_index = (v3d->twmode - V3D_MANIP_CUSTOM); // Transform_fix_me NEED TO DO THIS FOR ALL VIEW3D @@ -358,7 +358,7 @@ void BIF_selectTransformOrientation(bContext *C, TransformOrientation *target) void BIF_selectTransformOrientationValue(bContext *C, int orientation) { View3D *v3d = CTX_wm_view3d(C); - if(v3d) /* currently using generic poll */ + if (v3d) /* currently using generic poll */ v3d->twmode = orientation; } @@ -381,19 +381,19 @@ EnumPropertyItem *BIF_enumTransformOrientation(bContext *C) RNA_enum_item_add(&item, &totitem, &local); RNA_enum_item_add(&item, &totitem, &view); - if(C) { + if (C) { scene= CTX_data_scene(C); - if(scene) { + if (scene) { transform_spaces = &scene->transform_spaces; ts = transform_spaces->first; } } - if(ts) + if (ts) RNA_enum_item_add_separator(&item, &totitem); - for(; ts; ts = ts->next) { + for (; ts; ts = ts->next) { tmp.identifier = "CUSTOM"; tmp.name= ts->name; tmp.value = i++; @@ -469,11 +469,11 @@ static int count_bone_select(bArmature *arm, ListBase *lb, int do_it) int do_next; int total = 0; - for(bone= lb->first; bone; bone= bone->next) { + for (bone= lb->first; bone; bone= bone->next) { bone->flag &= ~BONE_TRANSFORM; do_next = do_it; - if(do_it) { - if(bone->layer & arm->layer) { + if (do_it) { + if (bone->layer & arm->layer) { if (bone->flag & BONE_SELECTED) { bone->flag |= BONE_TRANSFORM; total++; @@ -507,7 +507,7 @@ void initTransformOrientation(bContext *C, TransInfo *t) } /* no gimbal fallthrough to normal */ case V3D_MANIP_NORMAL: - if(obedit || (ob && ob->mode & OB_MODE_POSE)) { + if (obedit || (ob && ob->mode & OB_MODE_POSE)) { strcpy(t->spacename, "normal"); ED_getTransformOrientationMatrix(C, t->spacemtx, (v3d->around == V3D_ACTIVE)); break; @@ -516,10 +516,11 @@ void initTransformOrientation(bContext *C, TransInfo *t) case V3D_MANIP_LOCAL: strcpy(t->spacename, "local"); - if(ob) { + if (ob) { copy_m3_m4(t->spacemtx, ob->obmat); normalize_m3(t->spacemtx); - } else { + } + else { unit_m3(t->spacemtx); } @@ -599,7 +600,7 @@ int getTransformOrientation(const bContext *C, float normal[3], float plane[3], BMIter iter; BM_ITER(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL) { - if(BM_elem_flag_test(efa, BM_ELEM_SELECT)) { + if (BM_elem_flag_test(efa, BM_ELEM_SELECT)) { add_v3_v3(normal, efa->no); sub_v3_v3v3(vec, BM_FACE_FIRST_LOOP(efa)->v->co, @@ -640,7 +641,7 @@ int getTransformOrientation(const bContext *C, float normal[3], float plane[3], BMIter iter; BM_ITER(eed, &iter, em->bm, BM_EDGES_OF_MESH, NULL) { - if(BM_elem_flag_test(eed, BM_ELEM_SELECT)) { + if (BM_elem_flag_test(eed, BM_ELEM_SELECT)) { sub_v3_v3v3(plane, eed->v2->co, eed->v1->co); break; } @@ -654,7 +655,7 @@ int getTransformOrientation(const bContext *C, float normal[3], float plane[3], BMIter iter; BM_ITER(eed, &iter, em->bm, BM_EDGES_OF_MESH, NULL) { - if(BM_elem_flag_test(eed, BM_ELEM_SELECT)) { + if (BM_elem_flag_test(eed, BM_ELEM_SELECT)) { /* use average vert normals as plane and edge vector as normal */ copy_v3_v3(plane, eed->v1->no); add_v3_v3(plane, eed->v2->no); @@ -749,7 +750,7 @@ int getTransformOrientation(const bContext *C, float normal[3], float plane[3], result = ORIENTATION_NORMAL; } } - else if(obedit->type==OB_MBALL){ + else if (obedit->type==OB_MBALL) { #if 0 // XXX /* editmball.c */ MetaElem *ml, *ml_sel = NULL; @@ -820,17 +821,17 @@ int getTransformOrientation(const bContext *C, float normal[3], float plane[3], mul_m3_v3(mat, plane); } } - else if(ob && (ob->mode & OB_MODE_POSE)) { + else if (ob && (ob->mode & OB_MODE_POSE)) { bArmature *arm= ob->data; bPoseChannel *pchan; int totsel; totsel = count_bone_select(arm, &arm->bonebase, 1); - if(totsel) { + if (totsel) { float imat[3][3], mat[3][3]; /* use channels to get stats */ - for(pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) { + for (pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) { if (pchan->bone && pchan->bone->flag & BONE_TRANSFORM) { add_v3_v3(normal, pchan->pose_mat[2]); add_v3_v3(plane, pchan->pose_mat[1]); @@ -849,17 +850,17 @@ int getTransformOrientation(const bContext *C, float normal[3], float plane[3], result = ORIENTATION_EDGE; } } - else if(ob && (ob->mode & (OB_MODE_ALL_PAINT|OB_MODE_PARTICLE_EDIT))) { + else if (ob && (ob->mode & (OB_MODE_ALL_PAINT|OB_MODE_PARTICLE_EDIT))) { /* pass */ } else { /* we need the one selected object, if its not active */ ob = OBACT; - if(ob && !(ob->flag & SELECT)) ob = NULL; + if (ob && !(ob->flag & SELECT)) ob = NULL; - for(base= scene->base.first; base; base= base->next) { + for (base= scene->base.first; base; base= base->next) { if TESTBASELIB(v3d, base) { - if(ob == NULL) { + if (ob == NULL) { ob= base->object; break; } diff --git a/source/blender/editors/transform/transform_snap.c b/source/blender/editors/transform/transform_snap.c index 5713812ebd6..7ad7b0f5c40 100644 --- a/source/blender/editors/transform/transform_snap.c +++ b/source/blender/editors/transform/transform_snap.c @@ -169,7 +169,8 @@ void drawSnapping(const struct bContext *C, TransInfo *t) for (p = t->tsnap.points.first; p; p = p->next) { if (p == t->tsnap.selectedPoint) { glColor4ubv(selectedCol); - } else { + } + else { glColor4ubv(col); } @@ -195,7 +196,7 @@ void drawSnapping(const struct bContext *C, TransInfo *t) glEnd(); } - if(v3d->zbuf) + if (v3d->zbuf) glEnable(GL_DEPTH_TEST); } else if (t->spacetype==SPACE_IMAGE) { @@ -265,12 +266,12 @@ void applyProject(TransInfo *t) float imat[4][4]; int i; - if(t->flag & (T_EDIT|T_POSE)) { + if (t->flag & (T_EDIT|T_POSE)) { Object *ob = t->obedit?t->obedit:t->poseobj; invert_m4_m4(imat, ob->obmat); } - for(i = 0 ; i < t->total; i++, td++) { + for (i = 0 ; i < t->total; i++, td++) { float iloc[3], loc[3], no[3]; float mval[2]; int dist = 1000; @@ -297,7 +298,7 @@ void applyProject(TransInfo *t) if (snapObjectsTransform(t, mval, &dist, loc, no, t->tsnap.modeSelect)) { -// if(t->flag & (T_EDIT|T_POSE)) { +// if (t->flag & (T_EDIT|T_POSE)) { // mul_m4_v3(imat, loc); // } // @@ -476,7 +477,7 @@ void initSnapping(TransInfo *t, wmOperator *op) } /* use scene defaults only when transform is modal */ else if (t->flag & T_MODAL) { - if(ELEM(t->spacetype, SPACE_VIEW3D, SPACE_IMAGE)) { + if (ELEM(t->spacetype, SPACE_VIEW3D, SPACE_IMAGE)) { if (ts->snap_flag & SCE_SNAP) { t->modifiers |= MOD_SNAP; } @@ -569,7 +570,7 @@ int updateSelectedSnapPoint(TransInfo *t) int closest_dist = 0; int screen_loc[2]; - for( p = t->tsnap.points.first; p; p = p->next ) { + for ( p = t->tsnap.points.first; p; p = p->next ) { int dx, dy; int dist; @@ -631,7 +632,8 @@ void getSnapPoint(TransInfo *t, float vec[3]) } mul_v3_fl(vec, 1.0f / total); - } else { + } + else { copy_v3_v3(vec, t->tsnap.snapPoint); } } @@ -681,7 +683,7 @@ static float RotationBetween(TransInfo *t, float p1[3], float p2[3]) float angle, start[3], end[3], center[3]; copy_v3_v3(center, t->center); - if(t->flag & (T_EDIT|T_POSE)) { + if (t->flag & (T_EDIT|T_POSE)) { Object *ob= t->obedit?t->obedit:t->poseobj; mul_m4_v3(ob->obmat, center); } @@ -737,7 +739,7 @@ static float ResizeBetween(TransInfo *t, float p1[3], float p2[3]) float d1[3], d2[3], center[3], len_d1; copy_v3_v3(center, t->center); - if(t->flag & (T_EDIT|T_POSE)) { + if (t->flag & (T_EDIT|T_POSE)) { Object *ob= t->obedit?t->obedit:t->poseobj; mul_m4_v3(ob->obmat, center); } @@ -897,7 +899,7 @@ static void CalcSnapGeometry(TransInfo *t, float *UNUSED(vec)) UI_view2d_region_to_view(&t->ar->v2d, t->mval[0], t->mval[1], co, co+1); - if(ED_uvedit_nearest_uv(t->scene, t->obedit, ima, co, t->tsnap.snapPoint)) + if (ED_uvedit_nearest_uv(t->scene, t->obedit, ima, co, t->tsnap.snapPoint)) { ED_space_image_uv_aspect(t->sa->spacedata.first, &aspx, &aspy); t->tsnap.snapPoint[0] *= aspx; @@ -919,7 +921,7 @@ static void TargetSnapCenter(TransInfo *t) if ((t->tsnap.status & TARGET_INIT) == 0) { copy_v3_v3(t->tsnap.snapTarget, t->center); - if(t->flag & (T_EDIT|T_POSE)) { + if (t->flag & (T_EDIT|T_POSE)) { Object *ob= t->obedit?t->obedit:t->poseobj; mul_m4_v3(ob->obmat, t->tsnap.snapTarget); } @@ -937,7 +939,7 @@ static void TargetSnapActive(TransInfo *t) TransData *active_td = NULL; int i; - for(td = t->data, i = 0 ; i < t->total && td->flag & TD_SELECTED ; i++, td++) + for (td = t->data, i = 0 ; i < t->total && td->flag & TD_SELECTED ; i++, td++) { if (td->flag & TD_ACTIVE) { @@ -950,7 +952,7 @@ static void TargetSnapActive(TransInfo *t) { copy_v3_v3(t->tsnap.snapTarget, active_td->center); - if(t->flag & (T_EDIT|T_POSE)) { + if (t->flag & (T_EDIT|T_POSE)) { Object *ob= t->obedit?t->obedit:t->poseobj; mul_m4_v3(ob->obmat, t->tsnap.snapTarget); } @@ -978,14 +980,14 @@ static void TargetSnapMedian(TransInfo *t) t->tsnap.snapTarget[1] = 0; t->tsnap.snapTarget[2] = 0; - for(td = t->data, i = 0 ; i < t->total && td->flag & TD_SELECTED ; i++, td++) + for (td = t->data, i = 0 ; i < t->total && td->flag & TD_SELECTED ; i++, td++) { add_v3_v3(t->tsnap.snapTarget, td->center); } mul_v3_fl(t->tsnap.snapTarget, 1.0 / i); - if(t->flag & (T_EDIT|T_POSE)) { + if (t->flag & (T_EDIT|T_POSE)) { Object *ob= t->obedit?t->obedit:t->poseobj; mul_m4_v3(ob->obmat, t->tsnap.snapTarget); } @@ -1005,7 +1007,7 @@ static void TargetSnapClosest(TransInfo *t) if (t->flag & T_OBJECT) { int i; - for(td = t->data, i = 0 ; i < t->total && td->flag & TD_SELECTED ; i++, td++) + for (td = t->data, i = 0 ; i < t->total && td->flag & TD_SELECTED ; i++, td++) { struct BoundBox *bb = object_get_boundbox(td->ob); @@ -1050,13 +1052,13 @@ static void TargetSnapClosest(TransInfo *t) } else { int i; - for(td = t->data, i = 0 ; i < t->total && td->flag & TD_SELECTED ; i++, td++) { + for (td = t->data, i = 0 ; i < t->total && td->flag & TD_SELECTED ; i++, td++) { float loc[3]; float dist; copy_v3_v3(loc, td->center); - if(t->flag & (T_EDIT|T_POSE)) { + if (t->flag & (T_EDIT|T_POSE)) { Object *ob= t->obedit?t->obedit:t->poseobj; mul_m4_v3(ob->obmat, loc); } @@ -1278,7 +1280,7 @@ static int snapArmature(short snap_mode, ARegion *ar, Object *ob, bArmature *arm mul_m4_v3(imat, ray_start_local); mul_mat3_m4_v3(imat, ray_normal_local); - if(arm->edbo) + if (arm->edbo) { EditBone *eBone; @@ -1381,9 +1383,9 @@ static int snapDerivedMesh(short snap_mode, ARegion *ar, Object *ob, DerivedMesh hit.index = -1; hit.dist = *r_depth * (*r_depth == FLT_MAX ? 1.0f : local_scale); - if(treeData.tree && BLI_bvhtree_ray_cast(treeData.tree, ray_start_local, ray_normal_local, 0.0f, &hit, treeData.raycast_callback, &treeData) != -1) + if (treeData.tree && BLI_bvhtree_ray_cast(treeData.tree, ray_start_local, ray_normal_local, 0.0f, &hit, treeData.raycast_callback, &treeData) != -1) { - if(hit.dist/local_scale <= *r_depth) { + if (hit.dist/local_scale <= *r_depth) { *r_depth= hit.dist/local_scale; copy_v3_v3(r_loc, hit.co); copy_v3_v3(r_no, hit.no); @@ -1413,7 +1415,7 @@ static int snapDerivedMesh(short snap_mode, ARegion *ar, Object *ob, DerivedMesh EDBM_init_index_arrays(em, 0, 0, 1); } - for( i = 0; i < totface; i++) { + for ( i = 0; i < totface; i++) { BMFace *efa = NULL; MFace *f = faces + i; @@ -1437,7 +1439,8 @@ static int snapDerivedMesh(short snap_mode, ARegion *ar, Object *ob, DerivedMesh if (efa && BM_elem_flag_test(efa, BM_ELEM_HIDDEN)) { test = 0; - } else if (efa) { + } + else if (efa) { BMIter iter; BMLoop *l; @@ -1493,7 +1496,7 @@ static int snapDerivedMesh(short snap_mode, ARegion *ar, Object *ob, DerivedMesh EDBM_init_index_arrays(em, 1, 0, 0); } - for( i = 0; i < totvert; i++) { + for ( i = 0; i < totvert; i++) { BMVert *eve = NULL; MVert *v = verts + i; @@ -1548,7 +1551,7 @@ static int snapDerivedMesh(short snap_mode, ARegion *ar, Object *ob, DerivedMesh EDBM_init_index_arrays(em, 0, 1, 0); } - for( i = 0; i < totedge; i++) { + for ( i = 0; i < totedge; i++) { BMEdge *eed = NULL; MEdge *e = edges + i; @@ -1670,7 +1673,7 @@ static int snapObjects(Scene *scene, View3D *v3d, ARegion *ar, Object *obedit, c DupliObject *dupli_ob; ListBase *lb = object_duplilist(scene, ob); - for(dupli_ob = lb->first; dupli_ob; dupli_ob = dupli_ob->next) + for (dupli_ob = lb->first; dupli_ob; dupli_ob = dupli_ob->next) { Object *dob = dupli_ob->ob; @@ -1792,7 +1795,7 @@ static int peelDerivedMesh(Object *ob, DerivedMesh *dm, float obmat[][4], MFace *faces = dm->getTessFaceArray(dm); int i; - for( i = 0; i < totface; i++) { + for ( i = 0; i < totface; i++) { MFace *f = faces + i; float lambda; int result; @@ -1879,7 +1882,7 @@ static int peelObjects(Scene *scene, View3D *v3d, ARegion *ar, Object *obedit, L DupliObject *dupli_ob; ListBase *lb = object_duplilist(scene, ob); - for(dupli_ob = lb->first; dupli_ob; dupli_ob = dupli_ob->next) + for (dupli_ob = lb->first; dupli_ob; dupli_ob = dupli_ob->next) { Object *dob = dupli_ob->ob; @@ -1992,7 +1995,7 @@ static void applyGrid(TransInfo *t, float *val, int max_index, float fac[3], Gea int i; float asp[3] = {1.0f, 1.0f, 1.0f}; // TODO: Remove hard coded limit here (3) - if(max_index > 2) { + if (max_index > 2) { printf("applyGrid: invalid index %d, clamping\n", max_index); max_index= 2; } @@ -2002,7 +2005,7 @@ static void applyGrid(TransInfo *t, float *val, int max_index, float fac[3], Gea return; /* evil hack - snapping needs to be adapted for image aspect ratio */ - if((t->spacetype==SPACE_IMAGE) && (t->mode==TFM_TRANSLATION)) { + if ((t->spacetype==SPACE_IMAGE) && (t->mode==TFM_TRANSLATION)) { ED_space_image_uv_aspect(t->sa->spacedata.first, asp, asp+1); } diff --git a/source/blender/editors/util/crazyspace.c b/source/blender/editors/util/crazyspace.c index 544a1c77d50..cef440668e6 100644 --- a/source/blender/editors/util/crazyspace.c +++ b/source/blender/editors/util/crazyspace.c @@ -78,7 +78,7 @@ static void make_vertexcos__mapFunc(void *userData, int index, float *co, float float *vec = mappedData->vertexcos; vec+= 3*index; - if(!mappedData->flags[index]) { + if (!mappedData->flags[index]) { /* we need coord from prototype vertex, not it clones or images, * suppose they stored in the beginning of vertex array stored in DM */ copy_v3_v3(vec, co); @@ -91,9 +91,9 @@ static int modifiers_disable_subsurf_temporary(Object *ob) ModifierData *md; int disabled = 0; - for(md=ob->modifiers.first; md; md=md->next) - if(md->type==eModifierType_Subsurf) - if(md->mode & eModifierMode_OnCage) { + for (md=ob->modifiers.first; md; md=md->next) + if (md->type==eModifierType_Subsurf) + if (md->mode & eModifierMode_OnCage) { md->mode ^= eModifierMode_DisableTemporary; disabled= 1; } @@ -112,7 +112,7 @@ float *crazyspace_get_mapped_editverts(Scene *scene, Object *obedit) MappedUserData userData; /* disable subsurf temporal, get mapped cos, and enable it */ - if(modifiers_disable_subsurf_temporary(obedit)) { + if (modifiers_disable_subsurf_temporary(obedit)) { /* need to make new derivemesh */ makeDerivedMesh(scene, obedit, me->edit_btmesh, CD_MASK_BAREMESH, 0); } @@ -194,13 +194,13 @@ void crazyspace_set_quats_editmesh(BMEditMesh *em, float *origcos, float *mapped intptr_t index= 0; /* two abused locations in vertices */ - for(eve= em->verts.first; eve; eve= eve->next, index++) { + for (eve= em->verts.first; eve; eve= eve->next, index++) { eve->tmp.p = NULL; eve->prev= (EditVert *)index; } /* first store two sets of tangent vectors in vertices, we derive it just from the face-edges */ - for(efa= em->faces.first; efa; efa= efa->next) { + for (efa= em->faces.first; efa; efa= efa->next) { /* retrieve mapped coordinates */ v1= mappedcos + 3*(intptr_t)(efa->v1->prev); @@ -211,39 +211,39 @@ void crazyspace_set_quats_editmesh(BMEditMesh *em, float *origcos, float *mapped co2= (origcos)? origcos + 3*(intptr_t)(efa->v2->prev): efa->v2->co; co3= (origcos)? origcos + 3*(intptr_t)(efa->v3->prev): efa->v3->co; - if(efa->v2->tmp.p==NULL && efa->v2->f1) { + if (efa->v2->tmp.p==NULL && efa->v2->f1) { set_crazy_vertex_quat(quats, co2, co3, co1, v2, v3, v1); efa->v2->tmp.p= (void*)quats; quats+= 4; } - if(efa->v4) { + if (efa->v4) { v4= mappedcos + 3*(intptr_t)(efa->v4->prev); co4= (origcos)? origcos + 3*(intptr_t)(efa->v4->prev): efa->v4->co; - if(efa->v1->tmp.p==NULL && efa->v1->f1) { + if (efa->v1->tmp.p==NULL && efa->v1->f1) { set_crazy_vertex_quat(quats, co1, co2, co4, v1, v2, v4); efa->v1->tmp.p= (void*)quats; quats+= 4; } - if(efa->v3->tmp.p==NULL && efa->v3->f1) { + if (efa->v3->tmp.p==NULL && efa->v3->f1) { set_crazy_vertex_quat(quats, co3, co4, co2, v3, v4, v2); efa->v3->tmp.p= (void*)quats; quats+= 4; } - if(efa->v4->tmp.p==NULL && efa->v4->f1) { + if (efa->v4->tmp.p==NULL && efa->v4->f1) { set_crazy_vertex_quat(quats, co4, co1, co3, v4, v1, v3); efa->v4->tmp.p= (void*)quats; quats+= 4; } } else { - if(efa->v1->tmp.p==NULL && efa->v1->f1) { + if (efa->v1->tmp.p==NULL && efa->v1->f1) { set_crazy_vertex_quat(quats, co1, co2, co3, v1, v2, v3); efa->v1->tmp.p= (void*)quats; quats+= 4; } - if(efa->v3->tmp.p==NULL && efa->v3->f1) { + if (efa->v3->tmp.p==NULL && efa->v3->f1) { set_crazy_vertex_quat(quats, co3, co1, co2, v3, v1, v2); efa->v3->tmp.p= (void*)quats; quats+= 4; @@ -252,7 +252,7 @@ void crazyspace_set_quats_editmesh(BMEditMesh *em, float *origcos, float *mapped } /* restore abused prev pointer */ - for(prev= NULL, eve= em->verts.first; eve; prev= eve, eve= eve->next) + for (prev= NULL, eve= em->verts.first; eve; prev= eve, eve= eve->next) eve->prev= prev; #endif } @@ -267,13 +267,13 @@ void crazyspace_set_quats_mesh(Mesh *me, float *origcos, float *mappedcos, float float *v1, *v2, *v3, *v4, *co1, *co2, *co3, *co4; mvert= me->mvert; - for(i=0; itotvert; i++, mvert++) + for (i=0; itotvert; i++, mvert++) mvert->flag&= ~ME_VERT_TMP_TAG; /* first store two sets of tangent vectors in vertices, we derive it just from the face-edges */ mvert= me->mvert; mface= me->mface; - for(i=0; itotface; i++, mface++) { + for (i=0; itotface; i++, mface++) { /* retrieve mapped coordinates */ v1= mappedcos + 3*mface->v1; @@ -284,34 +284,34 @@ void crazyspace_set_quats_mesh(Mesh *me, float *origcos, float *mappedcos, float co2= (origcos)? origcos + 3*mface->v2: mvert[mface->v2].co; co3= (origcos)? origcos + 3*mface->v3: mvert[mface->v3].co; - if((mvert[mface->v2].flag&ME_VERT_TMP_TAG)==0) { + if ((mvert[mface->v2].flag&ME_VERT_TMP_TAG)==0) { set_crazy_vertex_quat(&quats[mface->v2*4], co2, co3, co1, v2, v3, v1); mvert[mface->v2].flag|= ME_VERT_TMP_TAG; } - if(mface->v4) { + if (mface->v4) { v4= mappedcos + 3*mface->v4; co4= (origcos)? origcos + 3*mface->v4: mvert[mface->v4].co; - if((mvert[mface->v1].flag&ME_VERT_TMP_TAG)==0) { + if ((mvert[mface->v1].flag&ME_VERT_TMP_TAG)==0) { set_crazy_vertex_quat(&quats[mface->v1*4], co1, co2, co4, v1, v2, v4); mvert[mface->v1].flag|= ME_VERT_TMP_TAG; } - if((mvert[mface->v3].flag&ME_VERT_TMP_TAG)==0) { + if ((mvert[mface->v3].flag&ME_VERT_TMP_TAG)==0) { set_crazy_vertex_quat(&quats[mface->v3*4], co3, co4, co2, v3, v4, v2); mvert[mface->v3].flag|= ME_VERT_TMP_TAG; } - if((mvert[mface->v4].flag&ME_VERT_TMP_TAG)==0) { + if ((mvert[mface->v4].flag&ME_VERT_TMP_TAG)==0) { set_crazy_vertex_quat(&quats[mface->v4*4], co4, co1, co3, v4, v1, v3); mvert[mface->v4].flag|= ME_VERT_TMP_TAG; } } else { - if((mvert[mface->v1].flag&ME_VERT_TMP_TAG)==0) { + if ((mvert[mface->v1].flag&ME_VERT_TMP_TAG)==0) { set_crazy_vertex_quat(&quats[mface->v1*4], co1, co2, co3, v1, v2, v3); mvert[mface->v1].flag|= ME_VERT_TMP_TAG; } - if((mvert[mface->v3].flag&ME_VERT_TMP_TAG)==0) { + if ((mvert[mface->v3].flag&ME_VERT_TMP_TAG)==0) { set_crazy_vertex_quat(&quats[mface->v3*4], co3, co1, co2, v3, v1, v2); mvert[mface->v3].flag|= ME_VERT_TMP_TAG; } @@ -336,19 +336,19 @@ int editbmesh_get_first_deform_matrices(Scene *scene, Object *ob, BMEditMesh *em /* compute the deformation matrices and coordinates for the first * modifiers with on cage editing that are enabled and support computing * deform matrices */ - for(i = 0; md && i <= cageIndex; i++, md = md->next) { + for (i = 0; md && i <= cageIndex; i++, md = md->next) { ModifierTypeInfo *mti = modifierType_getInfo(md->type); - if(!editbmesh_modifier_is_enabled(scene, md, dm)) + if (!editbmesh_modifier_is_enabled(scene, md, dm)) continue; - if(mti->type==eModifierTypeType_OnlyDeform && mti->deformMatricesEM) { - if(!defmats) { + if (mti->type==eModifierTypeType_OnlyDeform && mti->deformMatricesEM) { + if (!defmats) { dm= getEditDerivedBMesh(em, ob, NULL); deformedVerts= editbmesh_get_vertex_cos(em, &numVerts); defmats= MEM_callocN(sizeof(*defmats)*numVerts, "defmats"); - for(a=0; anext, i++) - if(editbmesh_modifier_is_enabled(scene, md, dm) && modifier_isCorrectableDeformed(md)) + for (; md && i <= cageIndex; md = md->next, i++) + if (editbmesh_modifier_is_enabled(scene, md, dm) && modifier_isCorrectableDeformed(md)) numleft++; - if(dm) + if (dm) dm->release(dm); *deformmats= defmats; @@ -382,7 +382,7 @@ int sculpt_get_first_deform_matrices(Scene *scene, Object *ob, float (**deformma int has_multires = mmd != NULL && mmd->sculptlvl > 0; int numleft= 0; - if(has_multires) { + if (has_multires) { *deformmats= NULL; *deformcos= NULL; return numleft; @@ -391,37 +391,37 @@ int sculpt_get_first_deform_matrices(Scene *scene, Object *ob, float (**deformma dm= NULL; md= modifiers_getVirtualModifierList(ob); - for(; md; md= md->next) { + for (; md; md= md->next) { ModifierTypeInfo *mti= modifierType_getInfo(md->type); - if(!modifier_isEnabled(scene, md, eModifierMode_Realtime)) continue; + if (!modifier_isEnabled(scene, md, eModifierMode_Realtime)) continue; - if(mti->type==eModifierTypeType_OnlyDeform) { - if(!defmats) { + if (mti->type==eModifierTypeType_OnlyDeform) { + if (!defmats) { Mesh *me= (Mesh*)ob->data; dm= mesh_create_derived(me, ob, NULL); deformedVerts= mesh_getVertexCos(me, &numVerts); defmats= MEM_callocN(sizeof(*defmats)*numVerts, "defmats"); - for(a=0; adeformMatrices) mti->deformMatrices(md, ob, dm, deformedVerts, defmats, numVerts); + if (mti->deformMatrices) mti->deformMatrices(md, ob, dm, deformedVerts, defmats, numVerts); else break; } } - for(; md; md= md->next) { + for (; md; md= md->next) { ModifierTypeInfo *mti= modifierType_getInfo(md->type); - if(!modifier_isEnabled(scene, md, eModifierMode_Realtime)) continue; + if (!modifier_isEnabled(scene, md, eModifierMode_Realtime)) continue; - if(mti->type==eModifierTypeType_OnlyDeform) + if (mti->type==eModifierTypeType_OnlyDeform) numleft++; } - if(dm) + if (dm) dm->release(dm); *deformmats= defmats; @@ -434,7 +434,7 @@ void crazyspace_build_sculpt(Scene *scene, Object *ob, float (**deformmats)[3][3 { int totleft= sculpt_get_first_deform_matrices(scene, ob, deformmats, deformcos); - if(totleft) { + if (totleft) { /* there are deformation modifier which doesn't support deformation matrices * calculation. Need additional crazyspace correction */ @@ -445,15 +445,15 @@ void crazyspace_build_sculpt(Scene *scene, Object *ob, float (**deformmats)[3][3 ModifierData *md= modifiers_getVirtualModifierList(ob); Mesh *me= (Mesh*)ob->data; - for(; md; md= md->next) { + for (; md; md= md->next) { ModifierTypeInfo *mti= modifierType_getInfo(md->type); - if(!modifier_isEnabled(scene, md, eModifierMode_Realtime)) continue; + if (!modifier_isEnabled(scene, md, eModifierMode_Realtime)) continue; - if(mti->type==eModifierTypeType_OnlyDeform) { + if (mti->type==eModifierTypeType_OnlyDeform) { /* skip leading modifiers which have been already * handled in sculpt_get_first_deform_matrices */ - if(mti->deformMatrices && !deformed) + if (mti->deformMatrices && !deformed) continue; mti->deformVerts(md, ob, NULL, deformedVerts, me->totvert, 0, 0); @@ -465,7 +465,7 @@ void crazyspace_build_sculpt(Scene *scene, Object *ob, float (**deformmats)[3][3 crazyspace_set_quats_mesh(me, (float*)origVerts, (float*)deformedVerts, quats); - for(i=0; itotvert; i++) { + for (i=0; itotvert; i++) { float qmat[3][3], tmat[3][3]; quat_to_mat3(qmat, &quats[i*4]); @@ -477,14 +477,14 @@ void crazyspace_build_sculpt(Scene *scene, Object *ob, float (**deformmats)[3][3 MEM_freeN(quats); } - if(!*deformmats) { + if (!*deformmats) { int a, numVerts; Mesh *me= (Mesh*)ob->data; *deformcos= mesh_getVertexCos(me, &numVerts); *deformmats= MEM_callocN(sizeof(*(*deformmats))*numVerts, "defmats"); - for(a=0; aobject.first; ob; ob=ob->id.next) { + for (ob=bmain->object.first; ob; ob=ob->id.next) { int mode= ob->mode; - if(mode && (mode != OB_MODE_POSE)) { + if (mode && (mode != OB_MODE_POSE)) { ob->mode= 0; data= ob->data; - if(ob == obact && !ob->id.lib && !(data && data->lib)) + if (ob == obact && !ob->id.lib && !(data && data->lib)) ED_object_toggle_modes(C, mode); } } @@ -94,27 +94,27 @@ void ED_editors_exit(bContext *C) Main *bmain= CTX_data_main(C); Scene *sce; - if(!bmain) + if (!bmain) return; /* frees all editmode undos */ undo_editmode_clear(); ED_undo_paint_free(); - for(sce=bmain->scene.first; sce; sce= sce->id.next) { - if(sce->obedit) { + for (sce=bmain->scene.first; sce; sce= sce->id.next) { + if (sce->obedit) { Object *ob= sce->obedit; - if(ob) { - if(ob->type==OB_MESH) { + if (ob) { + if (ob->type==OB_MESH) { Mesh *me= ob->data; - if(me->edit_btmesh) { + if (me->edit_btmesh) { EDBM_FreeEditBMesh(me->edit_btmesh); MEM_freeN(me->edit_btmesh); me->edit_btmesh= NULL; } } - else if(ob->type==OB_ARMATURE) { + else if (ob->type==OB_ARMATURE) { ED_armature_edit_free(ob); } } @@ -135,17 +135,17 @@ void ED_editors_exit(bContext *C) void apply_keyb_grid(int shift, int ctrl, float *val, float fac1, float fac2, float fac3, int invert) { /* fac1 is for 'nothing', fac2 for CTRL, fac3 for SHIFT */ - if(invert) + if (invert) ctrl= !ctrl; - if(ctrl && shift) { - if(fac3 != 0.0f) *val= fac3*floorf(*val/fac3 +0.5f); + if (ctrl && shift) { + if (fac3 != 0.0f) *val= fac3*floorf(*val/fac3 +0.5f); } - else if(ctrl) { - if(fac2 != 0.0f) *val= fac2*floorf(*val/fac2 +0.5f); + else if (ctrl) { + if (fac2 != 0.0f) *val= fac2*floorf(*val/fac2 +0.5f); } else { - if(fac1 != 0.0f) *val= fac1*floorf(*val/fac1 +0.5f); + if (fac1 != 0.0f) *val= fac1*floorf(*val/fac1 +0.5f); } } @@ -176,13 +176,13 @@ void unpack_menu(bContext *C, const char *opname, const char *id_name, const cha RNA_enum_set(&props_ptr, "method", PF_REMOVE); RNA_string_set(&props_ptr, "id", id_name); - if(G.relbase_valid) { + if (G.relbase_valid) { char local_name[FILE_MAXDIR + FILE_MAX], fi[FILE_MAX]; BLI_strncpy(local_name, abs_name, sizeof(local_name)); BLI_splitdirstring(local_name, fi); BLI_snprintf(local_name, sizeof(local_name), "//%s/%s", folder, fi); - if(strcmp(abs_name, local_name)!=0) { + if (strcmp(abs_name, local_name)!=0) { switch(checkPackedFile(local_name, pf)) { case PF_NOFILE: BLI_snprintf(line, sizeof(line), "Create %s", local_name); diff --git a/source/blender/editors/util/editmode_undo.c b/source/blender/editors/util/editmode_undo.c index 8c0eb06be67..4416228e2d3 100644 --- a/source/blender/editors/util/editmode_undo.c +++ b/source/blender/editors/util/editmode_undo.c @@ -107,7 +107,7 @@ static UndoElem *curundo= NULL; static void undo_restore(UndoElem *undo, void *editdata, void *obdata) { - if(undo) { + if (undo) { undo->to_editmode(undo->undodata, editdata, obdata); } } @@ -130,7 +130,7 @@ void undo_editmode_push(bContext *C, const char *name, * this was giving conflicts for example when mesh changed due to keys or apply */ /* remove all undos after (also when curundo==NULL) */ - while(undobase.last != curundo) { + while (undobase.last != curundo) { uel= undobase.last; uel->freedata(uel->undodata); BLI_freelinkN(&undobase, uel); @@ -150,13 +150,13 @@ void undo_editmode_push(bContext *C, const char *name, /* limit amount to the maximum amount*/ nr= 0; uel= undobase.last; - while(uel) { + while (uel) { nr++; - if(nr==U.undosteps) break; + if (nr==U.undosteps) break; uel= uel->prev; } - if(uel) { - while(undobase.first!=uel) { + if (uel) { + while (undobase.first!=uel) { UndoElem *first= undobase.first; first->freedata(first->undodata); BLI_freelinkN(&undobase, first); @@ -172,23 +172,23 @@ void undo_editmode_push(bContext *C, const char *name, curundo->id= obedit->id; curundo->type= obedit->type; - if(U.undomemory != 0) { + if (U.undomemory != 0) { /* limit to maximum memory (afterwards, we can't know in advance) */ totmem= 0; maxmem= ((uintptr_t)U.undomemory)*1024*1024; uel= undobase.last; - while(uel && uel->prev) { + while (uel && uel->prev) { totmem+= uel->undosize; - if(totmem>maxmem) break; + if (totmem>maxmem) break; uel= uel->prev; } - if(uel) { - if(uel->prev && uel->prev->prev) + if (uel) { + if (uel->prev && uel->prev->prev) uel= uel->prev; - while(undobase.first!=uel) { + while (undobase.first!=uel) { UndoElem *first= undobase.first; first->freedata(first->undodata); BLI_freelinkN(&undobase, first); @@ -207,24 +207,24 @@ static void undo_clean_stack(bContext *C) /* side effect: when deleting/renaming object and start editing new one with same name */ uel= undobase.first; - while(uel) { + while (uel) { void *editdata= uel->getdata(C); int isvalid= 0; next= uel->next; /* for when objects are converted, renamed, or global undo changes pointers... */ - if(uel->type==obedit->type) { - if(strcmp(uel->id.name, obedit->id.name)==0) { - if(uel->validate_undo==NULL) + if (uel->type==obedit->type) { + if (strcmp(uel->id.name, obedit->id.name)==0) { + if (uel->validate_undo==NULL) isvalid= 1; - else if(uel->validate_undo(uel->undodata, editdata)) + else if (uel->validate_undo(uel->undodata, editdata)) isvalid= 1; } } - if(isvalid) + if (isvalid) uel->ob= obedit; else { - if(uel == curundo) + if (uel == curundo) curundo= NULL; uel->freedata(uel->undodata); @@ -234,7 +234,7 @@ static void undo_clean_stack(bContext *C) uel= next; } - if(curundo == NULL) curundo= undobase.last; + if (curundo == NULL) curundo= undobase.last; } /* 1= an undo, -1 is a redo. we have to make sure 'curundo' remains at current situation */ @@ -245,14 +245,14 @@ void undo_editmode_step(bContext *C, int step) /* prevent undo to happen on wrong object, stack can be a mix */ undo_clean_stack(C); - if(step==0) { + if (step==0) { undo_restore(curundo, curundo->getdata(C), obedit->data); } - else if(step==1) { + else if (step==1) { - if(curundo==NULL || curundo->prev==NULL) error("No more steps to undo"); + if (curundo==NULL || curundo->prev==NULL) error("No more steps to undo"); else { - if(G.f & G_DEBUG) printf("undo %s\n", curundo->name); + if (G.f & G_DEBUG) printf("undo %s\n", curundo->name); curundo= curundo->prev; undo_restore(curundo, curundo->getdata(C), obedit->data); } @@ -260,16 +260,16 @@ void undo_editmode_step(bContext *C, int step) else { /* curundo has to remain current situation! */ - if(curundo==NULL || curundo->next==NULL) error("No more steps to redo"); + if (curundo==NULL || curundo->next==NULL) error("No more steps to redo"); else { undo_restore(curundo->next, curundo->getdata(C), obedit->data); curundo= curundo->next; - if(G.f & G_DEBUG) printf("redo %s\n", curundo->name); + if (G.f & G_DEBUG) printf("redo %s\n", curundo->name); } } /* special case for editmesh, mode must be copied back to the scene */ - if(obedit->type == OB_MESH) { + if (obedit->type == OB_MESH) { EDBM_selectmode_to_scene(C); } @@ -283,7 +283,7 @@ void undo_editmode_clear(void) UndoElem *uel; uel= undobase.first; - while(uel) { + while (uel) { uel->freedata(uel->undodata); uel= uel->next; } @@ -297,8 +297,8 @@ void undo_editmode_number(bContext *C, int nr) UndoElem *uel; int a=1; - for(uel= undobase.first; uel; uel= uel->next, a++) { - if(a==nr) break; + for (uel= undobase.first; uel; uel= uel->next, a++) { + if (a==nr) break; } curundo= uel; undo_editmode_step(C, 0); @@ -308,11 +308,11 @@ void undo_editmode_name(bContext *C, const char *undoname) { UndoElem *uel; - for(uel= undobase.last; uel; uel= uel->prev) { - if(strcmp(undoname, uel->name)==0) + for (uel= undobase.last; uel; uel= uel->prev) { + if (strcmp(undoname, uel->name)==0) break; } - if(uel && uel->prev) { + if (uel && uel->prev) { curundo= uel->prev; undo_editmode_step(C, 0); } @@ -321,11 +321,11 @@ void undo_editmode_name(bContext *C, const char *undoname) /* undoname optionally, if NULL it just checks for existing undo steps */ int undo_editmode_valid(const char *undoname) { - if(undoname) { + if (undoname) { UndoElem *uel; - for(uel= undobase.last; uel; uel= uel->prev) { - if(strcmp(undoname, uel->name)==0) + for (uel= undobase.last; uel; uel= uel->prev) { + if (strcmp(undoname, uel->name)==0) break; } return uel != NULL; @@ -343,11 +343,11 @@ const char *undo_editmode_get_name(bContext *C, int nr, int *active) /* prevent wrong numbers to be returned */ undo_clean_stack(C); - if(active) *active= 0; + if (active) *active= 0; uel= BLI_findlink(&undobase, nr); - if(uel) { - if(active && uel==curundo) + if (uel) { + if (active && uel==curundo) *active= 1; return uel->name; } @@ -358,6 +358,6 @@ const char *undo_editmode_get_name(bContext *C, int nr, int *active) void *undo_editmode_get_prev(Object *ob) { UndoElem *ue= undobase.last; - if(ue && ue->prev && ue->prev->ob==ob) return ue->prev->undodata; + if (ue && ue->prev && ue->prev->ob==ob) return ue->prev->undodata; return NULL; } diff --git a/source/blender/editors/util/numinput.c b/source/blender/editors/util/numinput.c index a477a11e6c7..1d9e053376a 100644 --- a/source/blender/editors/util/numinput.c +++ b/source/blender/editors/util/numinput.c @@ -84,7 +84,7 @@ void outputNumInput(NumInput *n, char *str) else inv[0] = 0; - if( n->val[i] > 1e10f || n->val[i] < -1e10f ) + if ( n->val[i] > 1e10f || n->val[i] < -1e10f ) BLI_snprintf(&str[j*20], 20, "%s%.4e%c", inv, n->val[i], cur); else switch (n->ctrl[i]) { @@ -181,7 +181,8 @@ char handleNumInput(NumInput *n, wmEvent *event) default: return 0; } - } else { + } + else { switch (event->type) { case BACKSPACEKEY: if (n->ctrl[idx] == 0) { @@ -217,7 +218,7 @@ char handleNumInput(NumInput *n, wmEvent *event) } break; case PADMINUS: - if(event->alt) + if (event->alt) break; case MINUSKEY: if (n->flag & NUM_NO_NEGATIVE) @@ -289,7 +290,7 @@ char handleNumInput(NumInput *n, wmEvent *event) } else { /* float resolution breaks when over six digits after comma */ - if( ABS(n->ctrl[idx]) < 10000000) { + if ( ABS(n->ctrl[idx]) < 10000000) { n->val[idx] += Val / (float)n->ctrl[idx]; n->ctrl[idx] *= 10; } diff --git a/source/blender/editors/util/undo.c b/source/blender/editors/util/undo.c index 5478da31f7a..e46fe19d306 100644 --- a/source/blender/editors/util/undo.c +++ b/source/blender/editors/util/undo.c @@ -87,7 +87,7 @@ void ED_undo_push(bContext *C, const char *str) if (G.f & G_DEBUG) printf("undo push %s\n", str); - if(obedit) { + if (obedit) { #ifdef BMESH_EM_UNDO_RECALC_TESSFACE_WORKAROUND /* undo is causing tessface recalc, so without we need to do explicitly */ @@ -103,7 +103,7 @@ void ED_undo_push(bContext *C, const char *str) if (U.undosteps == 0) return; - if(obedit->type==OB_MESH) + if (obedit->type==OB_MESH) undo_push_mesh(C, str); else if ELEM(obedit->type, OB_CURVE, OB_SURF) undo_push_curve(C, str); @@ -116,17 +116,17 @@ void ED_undo_push(bContext *C, const char *str) else if (obedit->type==OB_ARMATURE) undo_push_armature(C, str); } - else if(obact && obact->mode & OB_MODE_PARTICLE_EDIT) { + else if (obact && obact->mode & OB_MODE_PARTICLE_EDIT) { if (U.undosteps == 0) return; PE_undo_push(CTX_data_scene(C), str); } else { - if(U.uiflag & USER_GLOBALUNDO) + if (U.uiflag & USER_GLOBALUNDO) BKE_write_undo(C, str); } - if(wm->file_saved) { + if (wm->file_saved) { wm->file_saved= 0; /* notifier that data changed, for save-over warning or header */ WM_event_add_notifier(C, NC_WM|ND_DATACHANGED, NULL); @@ -147,16 +147,16 @@ static int ed_undo_step(bContext *C, int step, const char *undoname) } /* grease pencil can be can be used in plenty of spaces, so check it first */ - if(ED_gpencil_session_active()) { + if (ED_gpencil_session_active()) { return ED_undo_gpencil_step(C, step, undoname); } - if(sa && sa->spacetype==SPACE_IMAGE) { + if (sa && sa->spacetype==SPACE_IMAGE) { SpaceImage *sima= (SpaceImage *)sa->spacedata.first; - if((obact && obact->mode & OB_MODE_TEXTURE_PAINT) || sima->flag & SI_DRAWTOOL) { - if(!ED_undo_paint_step(C, UNDO_PAINT_IMAGE, step, undoname) && undoname) - if(U.uiflag & USER_GLOBALUNDO) + if ((obact && obact->mode & OB_MODE_TEXTURE_PAINT) || sima->flag & SI_DRAWTOOL) { + if (!ED_undo_paint_step(C, UNDO_PAINT_IMAGE, step, undoname) && undoname) + if (U.uiflag & USER_GLOBALUNDO) BKE_undo_name(C, undoname); WM_event_add_notifier(C, NC_WINDOW, NULL); @@ -164,12 +164,12 @@ static int ed_undo_step(bContext *C, int step, const char *undoname) } } - if(sa && sa->spacetype==SPACE_TEXT) { + if (sa && sa->spacetype==SPACE_TEXT) { ED_text_undo_step(C, step); } - else if(obedit) { + else if (obedit) { if ELEM7(obedit->type, OB_MESH, OB_FONT, OB_CURVE, OB_SURF, OB_MBALL, OB_LATTICE, OB_ARMATURE) { - if(undoname) + if (undoname) undo_editmode_name(C, undoname); else undo_editmode_step(C, step); @@ -180,16 +180,16 @@ static int ed_undo_step(bContext *C, int step, const char *undoname) else { int do_glob_undo= 0; - if(obact && obact->mode & OB_MODE_TEXTURE_PAINT) { - if(!ED_undo_paint_step(C, UNDO_PAINT_IMAGE, step, undoname)) + if (obact && obact->mode & OB_MODE_TEXTURE_PAINT) { + if (!ED_undo_paint_step(C, UNDO_PAINT_IMAGE, step, undoname)) do_glob_undo= 1; } - else if(obact && obact->mode & OB_MODE_SCULPT) { - if(!ED_undo_paint_step(C, UNDO_PAINT_MESH, step, undoname)) + else if (obact && obact->mode & OB_MODE_SCULPT) { + if (!ED_undo_paint_step(C, UNDO_PAINT_MESH, step, undoname)) do_glob_undo= 1; } - else if(obact && obact->mode & OB_MODE_PARTICLE_EDIT) { - if(step==1) + else if (obact && obact->mode & OB_MODE_PARTICLE_EDIT) { + if (step==1) PE_undo(CTX_data_scene(C)); else PE_redo(CTX_data_scene(C)); @@ -198,13 +198,13 @@ static int ed_undo_step(bContext *C, int step, const char *undoname) do_glob_undo= 1; } - if(do_glob_undo) { - if(U.uiflag & USER_GLOBALUNDO) { + if (do_glob_undo) { + if (U.uiflag & USER_GLOBALUNDO) { // note python defines not valid here anymore. //#ifdef WITH_PYTHON // XXX BPY_scripts_clear_pyobjects(); //#endif - if(undoname) + if (undoname) BKE_undo_name(C, undoname); else BKE_undo_step(C, step); @@ -248,18 +248,18 @@ int ED_undo_valid(const bContext *C, const char *undoname) Object *obact= CTX_data_active_object(C); ScrArea *sa= CTX_wm_area(C); - if(sa && sa->spacetype==SPACE_IMAGE) { + if (sa && sa->spacetype==SPACE_IMAGE) { SpaceImage *sima= (SpaceImage *)sa->spacedata.first; - if((obact && obact->mode & OB_MODE_TEXTURE_PAINT) || sima->flag & SI_DRAWTOOL) { + if ((obact && obact->mode & OB_MODE_TEXTURE_PAINT) || sima->flag & SI_DRAWTOOL) { return 1; } } - if(sa && sa->spacetype==SPACE_TEXT) { + if (sa && sa->spacetype==SPACE_TEXT) { return 1; } - else if(obedit) { + else if (obedit) { if ELEM7(obedit->type, OB_MESH, OB_FONT, OB_CURVE, OB_SURF, OB_MBALL, OB_LATTICE, OB_ARMATURE) { return undo_editmode_valid(undoname); } @@ -268,19 +268,19 @@ int ED_undo_valid(const bContext *C, const char *undoname) /* if below tests fail, global undo gets executed */ - if(obact && obact->mode & OB_MODE_TEXTURE_PAINT) { - if( ED_undo_paint_valid(UNDO_PAINT_IMAGE, undoname) ) + if (obact && obact->mode & OB_MODE_TEXTURE_PAINT) { + if ( ED_undo_paint_valid(UNDO_PAINT_IMAGE, undoname) ) return 1; } - else if(obact && obact->mode & OB_MODE_SCULPT) { - if( ED_undo_paint_valid(UNDO_PAINT_MESH, undoname) ) + else if (obact && obact->mode & OB_MODE_SCULPT) { + if ( ED_undo_paint_valid(UNDO_PAINT_MESH, undoname) ) return 1; } - else if(obact && obact->mode & OB_MODE_PARTICLE_EDIT) { + else if (obact && obact->mode & OB_MODE_PARTICLE_EDIT) { return PE_undo_valid(CTX_data_scene(C)); } - if(U.uiflag & USER_GLOBALUNDO) { + if (U.uiflag & USER_GLOBALUNDO) { return BKE_undo_valid(undoname); } } @@ -355,14 +355,14 @@ int ED_undo_operator_repeat(bContext *C, struct wmOperator *op) { int ret= 0; - if(op) { + if (op) { wmWindowManager *wm= CTX_wm_manager(C); struct Scene *scene= CTX_data_scene(C); ARegion *ar= CTX_wm_region(C); ARegion *ar1= BKE_area_find_region_type(CTX_wm_area(C), RGN_TYPE_WINDOW); - if(ar1) + if (ar1) CTX_wm_region_set(C, ar1); if ( (WM_operator_repeat_check(C, op)) && @@ -380,12 +380,12 @@ int ED_undo_operator_repeat(bContext *C, struct wmOperator *op) printf("redo_cb: operator redo %s\n", op->type->name); ED_undo_pop_op(C, op); - if(op->type->check) { + if (op->type->check) { op->type->check(C, op); /* ignore return value since its running again anyway */ } retval= WM_operator_repeat(C, op); - if((retval & OPERATOR_FINISHED)==0) { + if ((retval & OPERATOR_FINISHED)==0) { if (G.f & G_DEBUG) printf("redo_cb: operator redo failed: %s, return %d\n", op->type->name, retval); ED_undo_redo(C); @@ -435,16 +435,16 @@ static int get_undo_system(bContext *C) Object *obedit= CTX_data_edit_object(C); /* find out which undo system */ - if(obedit) { + if (obedit) { if (ELEM7(obedit->type, OB_MESH, OB_FONT, OB_CURVE, OB_SURF, OB_MBALL, OB_LATTICE, OB_ARMATURE)) return UNDOSYSTEM_EDITMODE; } else { Object *obact= CTX_data_active_object(C); - if(obact && obact->mode & OB_MODE_PARTICLE_EDIT) + if (obact && obact->mode & OB_MODE_PARTICLE_EDIT) return UNDOSYSTEM_PARTICLE; - else if(U.uiflag & USER_GLOBALUNDO) + else if (U.uiflag & USER_GLOBALUNDO) return UNDOSYSTEM_GLOBAL; } @@ -457,22 +457,22 @@ static EnumPropertyItem *rna_undo_itemf(bContext *C, int undosys, int *totitem) EnumPropertyItem item_tmp= {0}, *item= NULL; int active, i= 0; - while(TRUE) { + while (TRUE) { const char *name= NULL; - if(undosys==UNDOSYSTEM_PARTICLE) { + if (undosys==UNDOSYSTEM_PARTICLE) { name= PE_undo_get_name(CTX_data_scene(C), i, &active); } - else if(undosys==UNDOSYSTEM_EDITMODE) { + else if (undosys==UNDOSYSTEM_EDITMODE) { name= undo_editmode_get_name(C, i, &active); } else { name= BKE_undo_get_name(i, &active); } - if(name) { + if (name) { item_tmp.identifier= item_tmp.name= name; - if(active) + if (active) item_tmp.icon= ICON_RESTRICT_VIEW_OFF; else item_tmp.icon= ICON_NONE; @@ -495,19 +495,19 @@ static int undo_history_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(even undosys= get_undo_system(C); - if(undosys) { + if (undosys) { EnumPropertyItem *item= rna_undo_itemf(C, undosys, &totitem); - if(totitem > 0) { + if (totitem > 0) { uiPopupMenu *pup= uiPupMenuBegin(C, op->type->name, ICON_NONE); uiLayout *layout= uiPupMenuLayout(pup); uiLayout *split= uiLayoutSplit(layout, 0, 0), *column = NULL; int i, c; - for(c=0, i=totitem-1; i >= 0; i--, c++) { - if( (c % 20)==0 ) + for (c=0, i=totitem-1; i >= 0; i--, c++) { + if ( (c % 20)==0 ) column= uiLayoutColumn(split, 0); - if(item[i].identifier) + if (item[i].identifier) uiItemIntO(column, item[i].name, item[i].icon, op->type->idname, "item", item[i].value); } @@ -524,14 +524,14 @@ static int undo_history_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(even /* note: also check ed_undo_step() in top if you change notifiers */ static int undo_history_exec(bContext *C, wmOperator *op) { - if(RNA_struct_property_is_set(op->ptr, "item")) { + if (RNA_struct_property_is_set(op->ptr, "item")) { int undosys= get_undo_system(C); int item= RNA_int_get(op->ptr, "item"); - if(undosys==UNDOSYSTEM_PARTICLE) { + if (undosys==UNDOSYSTEM_PARTICLE) { PE_undo_number(CTX_data_scene(C), item); } - else if(undosys==UNDOSYSTEM_EDITMODE) { + else if (undosys==UNDOSYSTEM_EDITMODE) { undo_editmode_number(C, item+1); WM_event_add_notifier(C, NC_GEOM|ND_DATA, NULL); } diff --git a/source/blender/editors/uvedit/uvedit_buttons.c b/source/blender/editors/uvedit/uvedit_buttons.c index a45a3555b51..ff673fa0eab 100644 --- a/source/blender/editors/uvedit/uvedit_buttons.c +++ b/source/blender/editors/uvedit/uvedit_buttons.c @@ -81,7 +81,7 @@ static int uvedit_center(Scene *scene, BMEditMesh *em, Image *UNUSED(ima), float } } - if(tot > 0) { + if (tot > 0) { center[0] /= tot; center[1] /= tot; } @@ -124,15 +124,15 @@ static void uvedit_vertex_buttons(const bContext *C, uiBlock *block) em = BMEdit_FromObject(obedit); - if(uvedit_center(scene, em, ima, center)) { + if (uvedit_center(scene, em, ima, center)) { copy_v2_v2(uvedit_old_center, center); - if(!(sima->flag & SI_COORDFLOATS)) { + if (!(sima->flag & SI_COORDFLOATS)) { uvedit_old_center[0] *= imx; uvedit_old_center[1] *= imy; } - if(sima->flag & SI_COORDFLOATS) { + if (sima->flag & SI_COORDFLOATS) { step= 1; digits= 3; } @@ -158,7 +158,7 @@ static void do_uvedit_vertex(bContext *C, void *UNUSED(arg), int event) float center[2], delta[2]; int imx, imy; - if(event != B_UVEDIT_VERTEX) + if (event != B_UVEDIT_VERTEX) return; em = BMEdit_FromObject(obedit); @@ -166,7 +166,7 @@ static void do_uvedit_vertex(bContext *C, void *UNUSED(arg), int event) ED_space_image_size(sima, &imx, &imy); uvedit_center(scene, em, ima, center); - if(sima->flag & SI_COORDFLOATS) { + if (sima->flag & SI_COORDFLOATS) { delta[0]= uvedit_old_center[0] - center[0]; delta[1]= uvedit_old_center[1] - center[1]; } diff --git a/source/blender/editors/uvedit/uvedit_draw.c b/source/blender/editors/uvedit/uvedit_draw.c index 66ba28e70a6..6767d543c5e 100644 --- a/source/blender/editors/uvedit/uvedit_draw.c +++ b/source/blender/editors/uvedit/uvedit_draw.c @@ -112,10 +112,10 @@ static int draw_uvs_face_check(Scene *scene) ToolSettings *ts= scene->toolsettings; /* checks if we are selecting only faces */ - if(ts->uv_flag & UV_SYNC_SELECTION) { - if(ts->selectmode == SCE_SELECT_FACE) + if (ts->uv_flag & UV_SYNC_SELECTION) { + if (ts->selectmode == SCE_SELECT_FACE) return 2; - else if(ts->selectmode & SCE_SELECT_FACE) + else if (ts->selectmode & SCE_SELECT_FACE) return 1; else return 0; @@ -152,7 +152,7 @@ static int draw_uvs_dm_shadow(DerivedMesh *dm) { /* draw shadow mesh - this is the mesh with the modifier applied */ - if(dm && dm->drawUVEdges && CustomData_has_layer(&dm->loopData, CD_MLOOPUV)) { + if (dm && dm->drawUVEdges && CustomData_has_layer(&dm->loopData, CD_MLOOPUV)) { glColor3ub(112, 112, 112); dm->drawUVEdges(dm); return 1; @@ -204,22 +204,22 @@ static void draw_uvs_stretch(SpaceImage *sima, Scene *scene, BMEditMesh *em, MTe //totuvarea += tf_area(tf, efa->v4!=0); totuvarea += poly_uv_area(tf_uv, efa->len); - if(uvedit_face_visible(scene, ima, efa, tf)) { + if (uvedit_face_visible(scene, ima, efa, tf)) { BM_elem_flag_enable(efa, BM_ELEM_TAG); } else { - if(tf == activetf) + if (tf == activetf) activetf= NULL; BM_elem_flag_disable(efa, BM_ELEM_TAG); } } - if(totarea < FLT_EPSILON || totuvarea < FLT_EPSILON) { + if (totarea < FLT_EPSILON || totuvarea < FLT_EPSILON) { col[0] = 1.0; col[1] = col[2] = 0.0; glColor3fv(col); BM_ITER(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL) { - if(BM_elem_flag_test(efa, BM_ELEM_TAG)) { + if (BM_elem_flag_test(efa, BM_ELEM_TAG)) { glBegin(GL_POLYGON); BM_ITER(l, &liter, em->bm, BM_LOOPS_OF_FACE, efa) { luv = CustomData_bmesh_get(&em->bm->ldata, l->head.data, CD_MLOOPUV); @@ -231,7 +231,7 @@ static void draw_uvs_stretch(SpaceImage *sima, Scene *scene, BMEditMesh *em, MTe } else { BM_ITER(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL) { - if(BM_elem_flag_test(efa, BM_ELEM_TAG)) { + if (BM_elem_flag_test(efa, BM_ELEM_TAG)) { area = BM_face_area_calc(em->bm, efa) / totarea; BLI_array_empty(tf_uv); @@ -253,9 +253,9 @@ static void draw_uvs_stretch(SpaceImage *sima, Scene *scene, BMEditMesh *em, MTe //uvarea = tf_area(tf, efa->v4!=0) / totuvarea; uvarea = poly_uv_area(tf_uv, efa->len) / totuvarea; - if(area < FLT_EPSILON || uvarea < FLT_EPSILON) + if (area < FLT_EPSILON || uvarea < FLT_EPSILON) areadiff = 1.0f; - else if(area>uvarea) + else if (area>uvarea) areadiff = 1.0f-(uvarea/area); else areadiff = 1.0f-(area/uvarea); @@ -286,13 +286,13 @@ static void draw_uvs_stretch(SpaceImage *sima, Scene *scene, BMEditMesh *em, MTe glShadeModel(GL_SMOOTH); - for(efa= em->faces.first; efa; efa= efa->next) { + for (efa= em->faces.first; efa; efa= efa->next) { tf= CustomData_em_get(&em->fdata, efa->head.data, CD_MTFACE); - if(uvedit_face_visible(scene, ima, efa, tf)) { + if (uvedit_face_visible(scene, ima, efa, tf)) { efa->tmp.p = tf; uv_copy_aspect(tf->uv, tf_uv, aspx, aspy); - if(efa->v4) { + if (efa->v4) { #if 0 /* Simple but slow, better reuse normalized vectors */ uvang1 = RAD2DEG(angle_v2v2v2(tf_uv[3], tf_uv[0], tf_uv[1])); @@ -410,7 +410,7 @@ static void draw_uvs_stretch(SpaceImage *sima, Scene *scene, BMEditMesh *em, MTe glEnd(); } else { - if(tf == activetf) + if (tf == activetf) activetf= NULL; efa->tmp.p = NULL; } @@ -430,24 +430,24 @@ static void draw_uvs_other(Scene *scene, Object *obedit, Image *curimage) glColor3ub(96, 96, 96); - for(base=scene->base.first; base; base=base->next) { + for (base=scene->base.first; base; base=base->next) { Object *ob= base->object; - if(!(base->flag & SELECT)) continue; - if(!(base->lay & scene->lay)) continue; - if(ob->restrictflag & OB_RESTRICT_VIEW) continue; + if (!(base->flag & SELECT)) continue; + if (!(base->lay & scene->lay)) continue; + if (ob->restrictflag & OB_RESTRICT_VIEW) continue; - if((ob->type==OB_MESH) && (ob!=obedit)) { + if ((ob->type==OB_MESH) && (ob!=obedit)) { Mesh *me= ob->data; - if(me->mtface) { + if (me->mtface) { MPoly *mface= me->mpoly; MTexPoly *tface= me->mtpoly; MLoopUV *mloopuv; int a, b; - for(a=me->totpoly; a>0; a--, tface++, mface++) { - if(tface->tpage == curimage) { + for (a=me->totpoly; a>0; a--, tface++, mface++) { + if (tface->tpage == curimage) { glBegin(GL_LINE_LOOP); mloopuv = me->mloopuv + mface->loopstart; @@ -467,19 +467,19 @@ static void draw_uvs_texpaint(SpaceImage *sima, Scene *scene, Object *ob) Mesh *me= ob->data; Image *curimage = ED_space_image(sima); - if(sima->flag & SI_DRAW_OTHER) + if (sima->flag & SI_DRAW_OTHER) draw_uvs_other(scene, ob, curimage); glColor3ub(112, 112, 112); - if(me->mtface) { + if (me->mtface) { MPoly *mface= me->mpoly; MTexPoly *tface= me->mtpoly; MLoopUV *mloopuv; int a, b; - for(a=me->totpoly; a>0; a--, tface++, mface++) { - if(tface->tpage == curimage) { + for (a=me->totpoly; a>0; a--, tface++, mface++) { + if (tface->tpage == curimage) { glBegin(GL_LINE_LOOP); mloopuv = me->mloopuv + mface->loopstart; @@ -517,13 +517,13 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, Object *obedit) ts= scene->toolsettings; drawfaces= draw_uvs_face_check(scene); - if(ts->uv_flag & UV_SYNC_SELECTION) + if (ts->uv_flag & UV_SYNC_SELECTION) interpedges= (ts->selectmode & SCE_SELECT_VERTEX); else interpedges= (ts->uv_selectmode == UV_SELECT_VERTEX); /* draw other uvs */ - if(sima->flag & SI_DRAW_OTHER) { + if (sima->flag & SI_DRAW_OTHER) { Image *curimage= (activetf)? activetf->tpage: NULL; draw_uvs_other(scene, obedit, curimage); @@ -531,29 +531,29 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, Object *obedit) /* 1. draw shadow mesh */ - if(sima->flag & SI_DRAWSHADOW) { + if (sima->flag & SI_DRAWSHADOW) { /* first try existing derivedmesh */ - if(!draw_uvs_dm_shadow(em->derivedFinal)) { + if (!draw_uvs_dm_shadow(em->derivedFinal)) { /* create one if it does not exist */ cagedm = editbmesh_get_derived_cage_and_final(scene, obedit, me->edit_btmesh, &finaldm, CD_MASK_BAREMESH|CD_MASK_MTFACE); /* when sync selection is enabled, all faces are drawn (except for hidden) * so if cage is the same as the final, theres no point in drawing this */ - if(!((ts->uv_flag & UV_SYNC_SELECTION) && (cagedm == finaldm))) + if (!((ts->uv_flag & UV_SYNC_SELECTION) && (cagedm == finaldm))) draw_uvs_dm_shadow(finaldm); /* release derivedmesh again */ - if(cagedm != finaldm) cagedm->release(cagedm); + if (cagedm != finaldm) cagedm->release(cagedm); finaldm->release(finaldm); } } /* 2. draw colored faces */ - if(sima->flag & SI_DRAW_STRETCH) { + if (sima->flag & SI_DRAW_STRETCH) { draw_uvs_stretch(sima, scene, em, activetf); } - else if(!(sima->flag & SI_NO_DRAWFACES)) { + else if (!(sima->flag & SI_NO_DRAWFACES)) { /* draw transparent faces */ UI_GetThemeColor4ubv(TH_FACE, col1); UI_GetThemeColor4ubv(TH_FACE_SELECT, col2); @@ -563,11 +563,11 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, Object *obedit) BM_ITER(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL) { tf= CustomData_bmesh_get(&em->bm->pdata, efa->head.data, CD_MTEXPOLY); - if(uvedit_face_visible(scene, ima, efa, tf)) { + if (uvedit_face_visible(scene, ima, efa, tf)) { BM_elem_flag_enable(efa, BM_ELEM_TAG); - if(tf==activetf) continue; /* important the temp boolean is set above */ + if (tf==activetf) continue; /* important the temp boolean is set above */ - if(uvedit_face_selected(scene, em, efa)) + if (uvedit_face_selected(scene, em, efa)) glColor4ubv((GLubyte *)col2); else glColor4ubv((GLubyte *)col1); @@ -580,7 +580,7 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, Object *obedit) glEnd(); } else { - if(tf == activetf) + if (tf == activetf) activetf= NULL; BM_elem_flag_disable(efa, BM_ELEM_TAG); } @@ -593,11 +593,11 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, Object *obedit) BM_ITER(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL) { tf= CustomData_bmesh_get(&em->bm->pdata, efa->head.data, CD_MTEXPOLY); - if(uvedit_face_visible(scene, ima, efa, tf)) { + if (uvedit_face_visible(scene, ima, efa, tf)) { BM_elem_flag_enable(efa, BM_ELEM_TAG); } else { - if(tf == activetf) + if (tf == activetf) activetf= NULL; BM_elem_flag_disable(efa, BM_ELEM_TAG); } @@ -607,7 +607,7 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, Object *obedit) /* 3. draw active face stippled */ - if(activef) { + if (activef) { glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); UI_ThemeColor4(TH_EDITMESH_ACTIVE); @@ -628,7 +628,7 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, Object *obedit) /* 4. draw edges */ - if(sima->flag & SI_SMOOTH_UV) { + if (sima->flag & SI_SMOOTH_UV) { glEnable(GL_LINE_SMOOTH); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); @@ -641,7 +641,7 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, Object *obedit) continue; tf = CustomData_bmesh_get(&em->bm->pdata, efa->head.data, CD_MTEXPOLY); - if(tf) { + if (tf) { cpack(0x111111); glBegin(GL_LINE_LOOP); @@ -676,7 +676,7 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, Object *obedit) break; case SI_UVDT_BLACK: /* black/white */ case SI_UVDT_WHITE: - if(sima->dt_uv==SI_UVDT_WHITE) glColor3f(1.0f, 1.0f, 1.0f); + if (sima->dt_uv==SI_UVDT_WHITE) glColor3f(1.0f, 1.0f, 1.0f); else glColor3f(0.0f, 0.0f, 0.0f); BM_ITER(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL) { @@ -711,11 +711,11 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, Object *obedit) col2[0] = col2[1] = col2[2] = 192; col2[3] = 255; glColor4ubv((unsigned char *)col2); - if(me->drawflag & ME_DRAWEDGES) { + if (me->drawflag & ME_DRAWEDGES) { int sel, lastsel = -1; UI_GetThemeColor4ubv(TH_VERTEX_SELECT, col1); - if(interpedges) { + if (interpedges) { glShadeModel(GL_SMOOTH); BM_ITER(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL) { @@ -743,7 +743,7 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, Object *obedit) glBegin(GL_LINES); BM_ITER(l, &liter, em->bm, BM_LOOPS_OF_FACE, efa) { sel = (uvedit_edge_selected(em, scene, l)? 1 : 0); - if(sel != lastsel){ + if (sel != lastsel) { glColor4ubv(sel ? (GLubyte *)col1 : (GLubyte *)col2); lastsel = sel; } @@ -774,14 +774,14 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, Object *obedit) break; } - if(sima->flag & SI_SMOOTH_UV) { + if (sima->flag & SI_SMOOTH_UV) { glDisable(GL_LINE_SMOOTH); glDisable(GL_BLEND); } /* 5. draw face centers */ - if(drawfaces) { + if (drawfaces) { float cent[2]; pointsize = UI_GetThemeValuef(TH_FACEDOT_SIZE); @@ -795,7 +795,7 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, Object *obedit) if (!BM_elem_flag_test(efa, BM_ELEM_TAG)) continue; - if(!uvedit_face_selected(scene, em, efa)) { + if (!uvedit_face_selected(scene, em, efa)) { poly_uv_center(em, efa, cent); bglVertex2fv(cent); } @@ -810,7 +810,7 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, Object *obedit) if (!BM_elem_flag_test(efa, BM_ELEM_TAG)) continue; - if(uvedit_face_selected(scene, em, efa)) { + if (uvedit_face_selected(scene, em, efa)) { poly_uv_center(em, efa, cent); bglVertex2fv(cent); } @@ -820,7 +820,7 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, Object *obedit) /* 6. draw uv vertices */ - if(drawfaces != 2) { /* 2 means Mesh Face Mode */ + if (drawfaces != 2) { /* 2 means Mesh Face Mode */ /* unselected uvs */ UI_ThemeColor(TH_VERTEX); pointsize = UI_GetThemeValuef(TH_VERTEX_SIZE); @@ -833,7 +833,7 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, Object *obedit) BM_ITER(l, &liter, em->bm, BM_LOOPS_OF_FACE, efa) { luv = CustomData_bmesh_get(&em->bm->ldata, l->head.data, CD_MLOOPUV); - if(!uvedit_uv_selected(em, scene, l)) + if (!uvedit_uv_selected(em, scene, l)) bglVertex2fv(luv->uv); } } @@ -852,7 +852,7 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, Object *obedit) BM_ITER(l, &liter, em->bm, BM_LOOPS_OF_FACE, efa) { luv = CustomData_bmesh_get(&em->bm->ldata, l->head.data, CD_MLOOPUV); - if(luv->flag & MLOOPUV_PINNED) + if (luv->flag & MLOOPUV_PINNED) bglVertex2fv(luv->uv); } } @@ -870,7 +870,7 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, Object *obedit) BM_ITER(l, &liter, em->bm, BM_LOOPS_OF_FACE, efa) { luv = CustomData_bmesh_get(&em->bm->ldata, l->head.data, CD_MLOOPUV); - if(uvedit_uv_selected(em, scene, l)) + if (uvedit_uv_selected(em, scene, l)) bglVertex2fv(luv->uv); } } @@ -878,7 +878,7 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, Object *obedit) } /* finally draw stitch preview */ - if(stitch_preview) { + if (stitch_preview) { int i, index = 0; glPushClientAttrib(GL_CLIENT_VERTEX_ARRAY_BIT); glEnableClientState(GL_VERTEX_ARRAY); @@ -891,7 +891,7 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, Object *obedit) glDrawArrays(GL_TRIANGLES, 0, stitch_preview->num_static_tris*3); glVertexPointer(2, GL_FLOAT, 0, stitch_preview->preview_polys); - for(i = 0; i < stitch_preview->num_polys; i++){ + for (i = 0; i < stitch_preview->num_polys; i++) { glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); UI_ThemeColor4(TH_STITCH_PREVIEW_FACE); glDrawArrays(GL_POLYGON, index, stitch_preview->uvs_per_polygon[i]); @@ -934,15 +934,15 @@ void draw_uvedit_main(SpaceImage *sima, ARegion *ar, Scene *scene, Object *obedi show_uvedit= ED_space_image_show_uvedit(sima, obedit); show_uvshadow= ED_space_image_show_uvshadow(sima, obedit); - if(show_uvedit || show_uvshadow || show_texpaint_uvshadow) { - if(show_uvshadow) + if (show_uvedit || show_uvshadow || show_texpaint_uvshadow) { + if (show_uvshadow) draw_uvs_shadow(obedit); - else if(show_uvedit) + else if (show_uvedit) draw_uvs(sima, scene, obedit); else draw_uvs_texpaint(sima, scene, obact); - if(show_uvedit && !(toolsettings->use_uv_sculpt)) + if (show_uvedit && !(toolsettings->use_uv_sculpt)) drawcursor_sima(sima, ar); } } diff --git a/source/blender/editors/uvedit/uvedit_ops.c b/source/blender/editors/uvedit/uvedit_ops.c index 6c050355a3e..1c5fc18e99f 100644 --- a/source/blender/editors/uvedit/uvedit_ops.c +++ b/source/blender/editors/uvedit/uvedit_ops.c @@ -94,7 +94,7 @@ int ED_uvedit_test(Object *obedit) if (!obedit) return 0; - if(obedit->type != OB_MESH) + if (obedit->type != OB_MESH) return 0; em = BMEdit_FromObject(obedit); @@ -116,10 +116,10 @@ static int UNUSED_FUNCTION(ED_operator_uvmap_mesh)(bContext *C) { Object *ob= CTX_data_active_object(C); - if(ob && ob->type==OB_MESH) { + if (ob && ob->type==OB_MESH) { Mesh *me = ob->data; - if(CustomData_get_layer(&me->fdata, CD_MTFACE) != NULL) + if (CustomData_get_layer(&me->fdata, CD_MTFACE) != NULL) return 1; } @@ -137,16 +137,16 @@ int ED_object_get_active_image(Object *ob, int mat_nr, Image **ima, ImageUser ** Material *ma= give_current_material(ob, mat_nr); bNode *node= (ma && ma->use_nodes)? nodeGetActiveTexture(ma->nodetree): NULL; - if(node && is_image_texture_node(node)) { - if(ima) *ima= (Image*)node->id; - if(iuser) *iuser= NULL; - if(node_r) *node_r= node; + if (node && is_image_texture_node(node)) { + if (ima) *ima= (Image*)node->id; + if (iuser) *iuser= NULL; + if (node_r) *node_r= node; return TRUE; } - if(ima) *ima= NULL; - if(iuser) *iuser= NULL; - if(node_r) *node_r= node; + if (ima) *ima= NULL; + if (iuser) *iuser= NULL; + if (node_r) *node_r= node; return FALSE; } @@ -156,7 +156,7 @@ void ED_object_assign_active_image(Main *bmain, Object *ob, int mat_nr, Image *i Material *ma= give_current_material(ob, mat_nr); bNode *node= (ma && ma->use_nodes)? nodeGetActiveTexture(ma->nodetree): NULL; - if(node && is_image_texture_node(node)) { + if (node && is_image_texture_node(node)) { node->id= &ima->id; ED_node_generic_update(bmain, ma->nodetree, node); } @@ -173,31 +173,31 @@ void ED_uvedit_assign_image(Main *bmain, Scene *scene, Object *obedit, Image *im int update= 0; /* skip assigning these procedural images... */ - if(ima && (ima->type==IMA_TYPE_R_RESULT || ima->type==IMA_TYPE_COMPOSITE)) + if (ima && (ima->type==IMA_TYPE_R_RESULT || ima->type==IMA_TYPE_COMPOSITE)) return; /* verify we have a mesh we can work with */ - if(!obedit || (obedit->type != OB_MESH)) + if (!obedit || (obedit->type != OB_MESH)) return; em = BMEdit_FromObject(obedit); - if(!em || !em->bm->totface) { + if (!em || !em->bm->totface) { return; } - if(scene_use_new_shading_nodes(scene)) { + if (scene_use_new_shading_nodes(scene)) { /* new shading system, assign image in material */ int sloppy= 1; BMFace *efa= BM_active_face_get(em->bm, sloppy); - if(efa) + if (efa) ED_object_assign_active_image(bmain, obedit, efa->mat_nr, ima); } else { /* old shading system, assign image to selected faces */ /* ensure we have a uv map */ - if(!CustomData_has_layer(&em->bm->pdata, CD_MTEXPOLY)) { + if (!CustomData_has_layer(&em->bm->pdata, CD_MTEXPOLY)) { BM_data_layer_add(em->bm, &em->bm->pdata, CD_MTEXPOLY); BM_data_layer_add(em->bm, &em->bm->ldata, CD_MLOOPUV); update= 1; @@ -207,11 +207,11 @@ void ED_uvedit_assign_image(Main *bmain, Scene *scene, Object *obedit, Image *im BM_ITER(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL) { tf = CustomData_bmesh_get(&em->bm->pdata, efa->head.data, CD_MTEXPOLY); - if(uvedit_face_visible(scene, previma, efa, tf)) { - if(ima) { + if (uvedit_face_visible(scene, previma, efa, tf)) { + if (ima) { tf->tpage= ima; - if(ima->id.us==0) id_us_plus(&ima->id); + if (ima->id.us==0) id_us_plus(&ima->id); else id_lib_extern(&ima->id); } else { @@ -223,7 +223,7 @@ void ED_uvedit_assign_image(Main *bmain, Scene *scene, Object *obedit, Image *im } /* and update depdency graph */ - if(update) + if (update) DAG_id_tag_update(obedit->data, 0); } @@ -239,14 +239,14 @@ static int uvedit_set_tile(Object *obedit, Image *ima, int curtile) MTexPoly *tf; /* verify if we have something to do */ - if(!ima || !ED_uvedit_test(obedit)) + if (!ima || !ED_uvedit_test(obedit)) return 0; - if((ima->tpageflag & IMA_TILES) == 0) + if ((ima->tpageflag & IMA_TILES) == 0) return 0; /* skip assigning these procedural images... */ - if(ima->type==IMA_TYPE_R_RESULT || ima->type==IMA_TYPE_COMPOSITE) + if (ima->type==IMA_TYPE_R_RESULT || ima->type==IMA_TYPE_COMPOSITE) return 0; em = BMEdit_FromObject(obedit); @@ -254,7 +254,7 @@ static int uvedit_set_tile(Object *obedit, Image *ima, int curtile) BM_ITER(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL) { tf = CustomData_bmesh_get(&em->bm->pdata, efa->head.data, CD_MTEXPOLY); - if(!BM_elem_flag_test(efa, BM_ELEM_HIDDEN) && BM_elem_flag_test(efa, BM_ELEM_SELECT)) + if (!BM_elem_flag_test(efa, BM_ELEM_HIDDEN) && BM_elem_flag_test(efa, BM_ELEM_SELECT)) tf->tile= curtile; /* set tile index */ } @@ -269,7 +269,7 @@ static void uvedit_pixel_to_float(SpaceImage *sima, float *dist, float pixeldist { int width, height; - if(sima) { + if (sima) { ED_space_image_size(sima, &width, &height); } else { @@ -287,7 +287,7 @@ int uvedit_face_visible_nolocal(Scene *scene, BMFace *efa) { ToolSettings *ts= scene->toolsettings; - if(ts->uv_flag & UV_SYNC_SELECTION) + if (ts->uv_flag & UV_SYNC_SELECTION) return (BM_elem_flag_test(efa, BM_ELEM_HIDDEN)==0); else return (BM_elem_flag_test(efa, BM_ELEM_HIDDEN)==0 && BM_elem_flag_test(efa, BM_ELEM_SELECT)); @@ -297,7 +297,7 @@ int uvedit_face_visible(Scene *scene, Image *ima, BMFace *efa, MTexPoly *tf) { ToolSettings *ts= scene->toolsettings; - if(ts->uv_flag & UV_SHOW_SAME_IMAGE) + if (ts->uv_flag & UV_SHOW_SAME_IMAGE) return (tf->tpage==ima)? uvedit_face_visible_nolocal(scene, efa): 0; else return uvedit_face_visible_nolocal(scene, efa); @@ -307,7 +307,7 @@ int uvedit_face_selected(Scene *scene, BMEditMesh *em, BMFace *efa) { ToolSettings *ts= scene->toolsettings; - if(ts->uv_flag & UV_SYNC_SELECTION) + if (ts->uv_flag & UV_SYNC_SELECTION) return (BM_elem_flag_test(efa, BM_ELEM_SELECT)); else { BMLoop *l; @@ -328,7 +328,7 @@ int uvedit_face_select(Scene *scene, BMEditMesh *em, BMFace *efa) { ToolSettings *ts= scene->toolsettings; - if(ts->uv_flag & UV_SYNC_SELECTION) + if (ts->uv_flag & UV_SYNC_SELECTION) BM_elem_select_set(em->bm, efa, TRUE); else { BMLoop *l; @@ -350,7 +350,7 @@ int uvedit_face_deselect(Scene *scene, BMEditMesh *em, BMFace *efa) { ToolSettings *ts= scene->toolsettings; - if(ts->uv_flag & UV_SYNC_SELECTION) { + if (ts->uv_flag & UV_SYNC_SELECTION) { BM_elem_select_set(em->bm, efa, FALSE); } else { @@ -373,7 +373,7 @@ int uvedit_edge_selected(BMEditMesh *em, Scene *scene, BMLoop *l) { ToolSettings *ts= scene->toolsettings; - if(ts->uv_flag & UV_SYNC_SELECTION) { + if (ts->uv_flag & UV_SYNC_SELECTION) { if (ts->selectmode & SCE_SELECT_FACE) { return BM_elem_flag_test(l->f, BM_ELEM_SELECT); } @@ -400,10 +400,10 @@ void uvedit_edge_select(BMEditMesh *em, Scene *scene, BMLoop *l) { ToolSettings *ts= scene->toolsettings; - if(ts->uv_flag & UV_SYNC_SELECTION) { - if(ts->selectmode & SCE_SELECT_FACE) + if (ts->uv_flag & UV_SYNC_SELECTION) { + if (ts->selectmode & SCE_SELECT_FACE) BM_elem_select_set(em->bm, l->f, TRUE); - else if(ts->selectmode & SCE_SELECT_EDGE) + else if (ts->selectmode & SCE_SELECT_EDGE) BM_elem_select_set(em->bm, l->e, TRUE); else { BM_elem_select_set(em->bm, l->e->v1, TRUE); @@ -426,10 +426,10 @@ void uvedit_edge_deselect(BMEditMesh *em, Scene *scene, BMLoop *l) { ToolSettings *ts= scene->toolsettings; - if(ts->uv_flag & UV_SYNC_SELECTION) { - if(ts->selectmode & SCE_SELECT_FACE) + if (ts->uv_flag & UV_SYNC_SELECTION) { + if (ts->selectmode & SCE_SELECT_FACE) BM_elem_select_set(em->bm, l->f, FALSE); - else if(ts->selectmode & SCE_SELECT_EDGE) + else if (ts->selectmode & SCE_SELECT_EDGE) BM_elem_select_set(em->bm, l->e, FALSE); else { BM_elem_select_set(em->bm, l->e->v1, FALSE); @@ -451,8 +451,8 @@ int uvedit_uv_selected(BMEditMesh *em, Scene *scene, BMLoop *l) { ToolSettings *ts= scene->toolsettings; - if(ts->uv_flag & UV_SYNC_SELECTION) { - if(ts->selectmode & SCE_SELECT_FACE) + if (ts->uv_flag & UV_SYNC_SELECTION) { + if (ts->selectmode & SCE_SELECT_FACE) return BM_elem_flag_test(l->f, BM_ELEM_SELECT); else return BM_elem_flag_test(l->v, BM_ELEM_SELECT); @@ -468,8 +468,8 @@ void uvedit_uv_select(BMEditMesh *em, Scene *scene, BMLoop *l) { ToolSettings *ts= scene->toolsettings; - if(ts->uv_flag & UV_SYNC_SELECTION) { - if(ts->selectmode & SCE_SELECT_FACE) + if (ts->uv_flag & UV_SYNC_SELECTION) { + if (ts->selectmode & SCE_SELECT_FACE) BM_elem_select_set(em->bm, l->f, TRUE); else BM_elem_select_set(em->bm, l->v, TRUE); @@ -485,8 +485,8 @@ void uvedit_uv_deselect(BMEditMesh *em, Scene *scene, BMLoop *l) { ToolSettings *ts= scene->toolsettings; - if(ts->uv_flag & UV_SYNC_SELECTION) { - if(ts->selectmode & SCE_SELECT_FACE) + if (ts->uv_flag & UV_SYNC_SELECTION) { + if (ts->selectmode & SCE_SELECT_FACE) BM_elem_select_set(em->bm, l->f, FALSE); else BM_elem_select_set(em->bm, l->v, FALSE); @@ -502,7 +502,7 @@ void uvedit_uv_deselect(BMEditMesh *em, Scene *scene, BMLoop *l) void uvedit_live_unwrap_update(SpaceImage *sima, Scene *scene, Object *obedit) { - if(sima && (sima->flag & SI_LIVE_UNWRAP)) { + if (sima && (sima->flag & SI_LIVE_UNWRAP)) { ED_uvedit_live_unwrap_begin(scene, obedit); ED_uvedit_live_unwrap_re_solve(); ED_uvedit_live_unwrap_end(0); @@ -529,7 +529,7 @@ void poly_uv_center(BMEditMesh *em, BMFace *f, float cent[2]) void uv_center(float uv[][2], float cent[2], int quad) { - if(quad) { + if (quad) { cent[0] = (uv[0][0] + uv[1][0] + uv[2][0] + uv[3][0]) / 4.0f; cent[1] = (uv[0][1] + uv[1][1] + uv[2][1] + uv[3][1]) / 4.0f; } @@ -541,7 +541,7 @@ void uv_center(float uv[][2], float cent[2], int quad) float uv_area(float uv[][2], int quad) { - if(quad) + if (quad) return area_tri_v2(uv[0], uv[1], uv[2]) + area_tri_v2(uv[0], uv[2], uv[3]); else return area_tri_v2(uv[0], uv[1], uv[2]); @@ -552,7 +552,7 @@ float poly_uv_area(float uv[][2], int len) //BMESH_TODO: make this not suck //maybe use scanfill? I dunno. - if(len >= 4) + if (len >= 4) return area_tri_v2(uv[0], uv[1], uv[2]) + area_tri_v2(uv[0], uv[2], uv[3]); else return area_tri_v2(uv[0], uv[1], uv[2]); @@ -599,7 +599,7 @@ int ED_uvedit_minmax(Scene *scene, Image *ima, Object *obedit, float *min, float sel= 0; BM_ITER(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL) { tf = CustomData_bmesh_get(&em->bm->pdata, efa->head.data, CD_MTEXPOLY); - if(!uvedit_face_visible(scene, ima, efa, tf)) + if (!uvedit_face_visible(scene, ima, efa, tf)) continue; BM_ITER(l, &liter, em->bm, BM_LOOPS_OF_FACE, efa) { @@ -627,7 +627,7 @@ static int ED_uvedit_median(Scene *scene, Image *ima, Object *obedit, float co[3 zero_v3(co); BM_ITER(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL) { tf= CustomData_bmesh_get(&em->bm->pdata, efa->head.data, CD_MTEXPOLY); - if(!uvedit_face_visible(scene, ima, efa, tf)) + if (!uvedit_face_visible(scene, ima, efa, tf)) continue; BM_ITER(l, &liter, em->bm, BM_LOOPS_OF_FACE, efa) { @@ -649,8 +649,8 @@ static int uvedit_center(Scene *scene, Image *ima, Object *obedit, float *cent, float min[2], max[2]; int change= 0; - if(mode==V3D_CENTER) { /* bounding box */ - if(ED_uvedit_minmax(scene, ima, obedit, min, max)) { + if (mode==V3D_CENTER) { /* bounding box */ + if (ED_uvedit_minmax(scene, ima, obedit, min, max)) { change = 1; cent[0]= (min[0]+max[0])/2.0f; @@ -658,13 +658,13 @@ static int uvedit_center(Scene *scene, Image *ima, Object *obedit, float *cent, } } else { - if(ED_uvedit_median(scene, ima, obedit, cent)) { + if (ED_uvedit_median(scene, ima, obedit, cent)) { change = 1; } } - if(change) { + if (change) { return 1; } @@ -690,7 +690,7 @@ void uv_find_nearest_edge(Scene *scene, Image *ima, BMEditMesh *em, float co[2], BM_ITER(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL) { tf= CustomData_bmesh_get(&em->bm->pdata, efa->head.data, CD_MTEXPOLY); - if(!uvedit_face_visible(scene, ima, efa, tf)) + if (!uvedit_face_visible(scene, ima, efa, tf)) continue; i = 0; @@ -700,7 +700,7 @@ void uv_find_nearest_edge(Scene *scene, Image *ima, BMEditMesh *em, float co[2], dist= dist_to_line_segment_v2(co, luv->uv, nextluv->uv); - if(dist < mindist) { + if (dist < mindist) { hit->tf= tf; hit->efa= efa; @@ -739,7 +739,7 @@ static void find_nearest_uv_face(Scene *scene, Image *ima, BMEditMesh *em, float BM_ITER(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL) { tf= CustomData_bmesh_get(&em->bm->pdata, efa->head.data, CD_MTEXPOLY); - if(!uvedit_face_visible(scene, ima, efa, tf)) + if (!uvedit_face_visible(scene, ima, efa, tf)) continue; cent[0]= cent[1]= 0.0f; @@ -753,7 +753,7 @@ static void find_nearest_uv_face(Scene *scene, Image *ima, BMEditMesh *em, float cent[1] /= efa->len; dist= fabs(co[0]- cent[0]) + fabs(co[1]- cent[1]); - if(dist < mindist) { + if (dist < mindist) { hit->tf= tf; hit->efa= efa; mindist= dist; @@ -797,7 +797,7 @@ static int nearest_uv_between(BMEditMesh *em, BMFace *efa, int UNUSED(nverts), i c1= v1[0]*m[1] - v1[1]*m[0]; c2= v1[0]*v2[1] - v1[1]*v2[0]; - if(c1*c2 < 0.0f) + if (c1*c2 < 0.0f) return 0; /* m and v1 on same side of v-v2? */ @@ -830,21 +830,21 @@ void uv_find_nearest_vert(Scene *scene, Image *ima, BMEditMesh *em, BM_ITER(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL) { tf= CustomData_bmesh_get(&em->bm->pdata, efa->head.data, CD_MTEXPOLY); - if(!uvedit_face_visible(scene, ima, efa, tf)) + if (!uvedit_face_visible(scene, ima, efa, tf)) continue; i = 0; BM_ITER(l, &liter, em->bm, BM_LOOPS_OF_FACE, efa) { luv = CustomData_bmesh_get(&em->bm->ldata, l->head.data, CD_MLOOPUV); - if(penalty && uvedit_uv_selected(em, scene, l)) + if (penalty && uvedit_uv_selected(em, scene, l)) dist= fabs(co[0]-luv->uv[0])+penalty[0] + fabs(co[1]-luv->uv[1])+penalty[1]; else dist= fabs(co[0]-luv->uv[0]) + fabs(co[1]-luv->uv[1]); - if(dist<=mindist) { - if(dist==mindist) - if(!nearest_uv_between(em, efa, efa->len, i, co, luv->uv)) { + if (dist<=mindist) { + if (dist==mindist) + if (!nearest_uv_between(em, efa, efa->len, i, co, luv->uv)) { i++; continue; } @@ -883,14 +883,14 @@ int ED_uvedit_nearest_uv(Scene *scene, Object *obedit, Image *ima, float co[2], BM_ITER(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL) { tf= CustomData_bmesh_get(&em->bm->pdata, efa->head.data, CD_MTEXPOLY); - if(!uvedit_face_visible(scene, ima, efa, tf)) + if (!uvedit_face_visible(scene, ima, efa, tf)) continue; BM_ITER(l, &liter, em->bm, BM_LOOPS_OF_FACE, efa) { luv = CustomData_bmesh_get(&em->bm->ldata, l->head.data, CD_MLOOPUV); dist= fabs(co[0]-luv->uv[0]) + fabs(co[1]-luv->uv[1]); - if(dist<=mindist) { + if (dist<=mindist) { mindist= dist; uv[0]= luv->uv[0]; @@ -910,14 +910,14 @@ static void uv_vertex_loop_flag(UvMapVert *first) UvMapVert *iterv; int count= 0; - for(iterv=first; iterv; iterv=iterv->next) { - if(iterv->separate && iterv!=first) + for (iterv=first; iterv; iterv=iterv->next) { + if (iterv->separate && iterv!=first) break; count++; } - if(count < 5) + if (count < 5) first->flag= 1; } @@ -929,10 +929,10 @@ static UvMapVert *uv_vertex_map_get(UvVertMap *vmap, BMFace *efa, int a) l = BM_iter_at_index(NULL, BM_LOOPS_OF_FACE, efa, a); first= EDBM_get_uv_map_vert(vmap, BM_elem_index_get(l->v)); - for(iterv=first; iterv; iterv=iterv->next) { - if(iterv->separate) + for (iterv=first; iterv; iterv=iterv->next) { + if (iterv->separate) first= iterv; - if(iterv->f == BM_elem_index_get(efa)) + if (iterv->f == BM_elem_index_get(efa)) return first; } @@ -945,8 +945,8 @@ UvElement *ED_get_uv_element(UvElementMap *map, BMFace *efa, BMLoop *l) element = map->vert[BM_elem_index_get(l->v)]; - for(; element; element = element->next) - if(element->face == efa) + for (; element; element = element->next) + if (element->face == efa) return element; return NULL; @@ -959,18 +959,18 @@ static int uv_edge_tag_faces(BMEditMesh *em, UvMapVert *first1, UvMapVert *first int tot = 0; /* count number of faces this edge has */ - for(iterv1=first1; iterv1; iterv1=iterv1->next) { - if(iterv1->separate && iterv1 != first1) + for (iterv1=first1; iterv1; iterv1=iterv1->next) { + if (iterv1->separate && iterv1 != first1) break; - for(iterv2=first2; iterv2; iterv2=iterv2->next) { - if(iterv2->separate && iterv2 != first2) + for (iterv2=first2; iterv2; iterv2=iterv2->next) { + if (iterv2->separate && iterv2 != first2) break; - if(iterv1->f == iterv2->f) { + if (iterv1->f == iterv2->f) { /* if face already tagged, don't do this edge */ efa= EDBM_get_face_for_index(em, iterv1->f); - if(BMO_elem_flag_test(em->bm, efa, EFA_F1_FLAG)) + if (BMO_elem_flag_test(em->bm, efa, EFA_F1_FLAG)) return 0; tot++; @@ -979,21 +979,21 @@ static int uv_edge_tag_faces(BMEditMesh *em, UvMapVert *first1, UvMapVert *first } } - if(*totface == 0) /* start edge */ + if (*totface == 0) /* start edge */ *totface= tot; - else if(tot != *totface) /* check for same number of faces as start edge */ + else if (tot != *totface) /* check for same number of faces as start edge */ return 0; /* tag the faces */ - for(iterv1=first1; iterv1; iterv1=iterv1->next) { - if(iterv1->separate && iterv1 != first1) + for (iterv1=first1; iterv1; iterv1=iterv1->next) { + if (iterv1->separate && iterv1 != first1) break; - for(iterv2=first2; iterv2; iterv2=iterv2->next) { - if(iterv2->separate && iterv2 != first2) + for (iterv2=first2; iterv2; iterv2=iterv2->next) { + if (iterv2->separate && iterv2 != first2) break; - if(iterv1->f == iterv2->f) { + if (iterv1->f == iterv2->f) { efa= EDBM_get_face_for_index(em, iterv1->f); BMO_elem_flag_enable(em->bm, efa, EFA_F1_FLAG); break; @@ -1022,7 +1022,7 @@ static int select_edgeloop(Scene *scene, Image *ima, BMEditMesh *em, NearestHit count = 0; BM_ITER(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL) { - if(!extend) { + if (!extend) { uvedit_face_deselect(scene, em, efa); } @@ -1045,7 +1045,7 @@ static int select_edgeloop(Scene *scene, Image *ima, BMEditMesh *em, NearestHit uv_edge_tag_faces(em, iterv1, iterv2, &starttotf); /* sorry, first edge isn't even ok */ - if(iterv1->flag==0 && iterv2->flag==0) looking= 0; + if (iterv1->flag==0 && iterv2->flag==0) looking= 0; else looking= 1; /* iterate */ @@ -1057,9 +1057,9 @@ static int select_edgeloop(Scene *scene, Image *ima, BMEditMesh *em, NearestHit BM_ITER(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL) { tf= CustomData_bmesh_get(&em->bm->pdata, efa->head.data, CD_MTEXPOLY); - if(!BMO_elem_flag_test(em->bm, efa, EFA_F1_FLAG) && uvedit_face_visible(scene, ima, efa, tf)) { + if (!BMO_elem_flag_test(em->bm, efa, EFA_F1_FLAG) && uvedit_face_visible(scene, ima, efa, tf)) { nverts= efa->len; - for(a=0; a